[freeside] Backing Up Freeside

Ivan Kohler ivan at sisd.com
Wed Sep 22 14:21:10 PDT 1999


On Wed, Sep 22, 1999 at 11:26:44AM -0600, Mike Hayward wrote:
> Seems to me the script in fs-1.2.2 to back up freeside doesn't back up
> all freeside state.  I'm assuming fs needs the state in the
> /usr/local/etc/freeside/counters... directory to maintain the db
> correctly.  Does this sound right?

Not strictly, no.  Freeside will recreate the files in a counter directory
if they are missing. 

> For a future release, it might be better to store all state,
> especially counters, in the database since it addresses the following
> three issues.

I chose to use counters in the filesystem because there is no standard way
to get the value of an auto-incrementing keyfield which is common across
all databases (as seen through DBI/DBD).

It certainly wouldn't be a bad idea to use the database-specific methods,
when available.  Patches are welcome.

> - Modifying files without locking from simultaneously executing perl
>   scripts creates a race condition and may corrupt the counters.

Whew!  Good thing I used File::CounterFile then.  Directly from the
File::CounterFile documentation:  "File locking is applied, so multiple
processes might try to access the same counters at the same time without
risk of counter destruction." 

> - Unless you use nfs, only one webserver can use an instance of
>   freeside.

Mmm... no, I don't see any problem with multiple separate webservers using
the same Freeside database, but maintaining their own counter directories. 
The counter files are used to decide _where to start looking_ for a new
key, not as the actual value of that key.  So if you have multiple
webservers, you'll just take a small performance hit.  Of course, if you
need to scale Freeside anywhere near this level, you're very large and
presumably have the resources to do this correctly (for example, by
patching Freeside as described above).

> - Only one copy of freeside can be installed on a machine.  This
>   would seems to make migration to new versions, etc. difficult.

Only one copy of Freeside can be installed on a machine because most of
Freeside is now installed with `perl Makefile.PL; make; make install', not
because of the counter director{y|ies}.

Multiple, separate instances of Freeside _data_ (database as well as
counter, conf and export directories) can be kept on a single machine.

> This is just an architectural suggestion, perhaps I'm out of line.

Archetecture suggestions are fine, but unless you back that up with code,
they're unlikely to have much effect.

> Following is a suggestive script of how to backup the entire state for
> fs-1.2.2, if indeed the counters & configuration are important.

Your suggested script with back up /usr/local/etc/freeside, but will miss
any database not named `freeside'.  Both of our scripts are specific to
MySQL.  If you're interested in contributing to Freeside, maybe you could
work on a script which: reads the mapsecrets configuration file and then
each secrets file to find out what specific database engine(s) (MySQL,
PostgreSQL, etc.) and database(s) need to be backed up, then does so,
serializing backups of the same engine, i.e. stop mysql, do all the mysql
backups, start mysql, stop postgresql, do all the postgresql backups,
start postgresql, etc. 

> - Mike
> 
> ----original: backup-freeside---------------------------------------------------
> #!/bin/sh
> /etc/init.d/apache stop
> /etc/init.d/mysql stop
> tar czvf var-lib-mysql-`date +%y%m%d%H%M%S`.tar.gz /var/lib/mysql
> /etc/init.d/mysql start
> /etc/init.d/apache start
> 
> ----modified: backup-freeside---------------------------------------------------
> #!/bin/sh
> apachectl stop
> mysqldump -t freeside > fs-backup.sql
> apachectl start
> tar -Pzcvf fs-backup-`date +%y%m%d%H%M%S`.tgz fs-backup.sql /usr/local/etc/freeside/
> rm fs-backup.sql
> 

-- 
Ivan Kohler <ivan at sisd.com> - finger for PGP key - <moc.dsis at navi> Relhok Navi
Open-source billing and administration for ISPs - http://www.sisd.com/freeside
20 4,16 * * * saytime # please don't be surprised if you find me dreaming too



More information about the freeside-users mailing list