Database Backups

=Database Backups= You typically cannot backup databases using traditional backup tools because most databases leave files on disk in a somewhat inconsistent state. Instead, you must somehow pause the database server, take a snapshot of its filesystem contents, and then restart the server. This snapshot can then be backed up with traditional backup utilities, like Bacula

On UGCS, we put backups in /var/local/ -backups. Tarballs are named according to when they were created, and are usually kept for a week.

AFS
AFS databases are kept in /var/lib/openafs/db on the db servers (vlserver, ptserver, buserver). You need to shutdown the services with "bos shutdown server service", tar up the contents of /var/lib/openafs/db, and then restart the services.

On UGCS, there is a cron script on athena that does this daily and keeps the backups for 14 days.

Mysql
Unfortunately, you need to pay for online backup tools for mysql. Instead of that, you can use the following procedure:
 * 1) Run the SQL command "flush tables with read lock"
 * 2) Create an LVM snapshot of the filesystem mysql is on
 * 3) Unlock the tables
 * 4) Tar up /var/lib/mysql on the snapshot

Since taking an lvm snapshot requires basically no time, this results in little downtime. If you can't make a snapshot for some reason, you need to create the tarball as step 2, which may take a while if you have a large database.

On UGCS, poseidon has a script that does this. Backups are run daily and kept for 7 days.

Postgresql
Postgres has nice online backups. See http://www.postgresql.org/docs/8.1/static/backup-online.html for details. On poseidon, I have WAL archiving enabled, and the archive_command copies the WAL logs to /var/local/postgres-backups.

Ldap
OpenLDAP uses BerkelyDB to store stuff on disk. You can dump the database with "slapcat > file". This potentially doesn't scale very well, but we don't have problems with it on our installation.

On UGCS, hera backs up the ldap database daily to /mnt/db/ldap-backups (with slapcat) and keeps them for 7 days.

Kerberos
Kerberos databases are usually dumped to a data transfer format for propagation every hour or so. All you have to do is copy that file once a day (or as often as you'd like) to another location for backups.

On UGCS, zeus copies the slave_transfer file daily to /var/local/krb5kdc-backups and keeps copies for 7 days.