User Tools

Site Tools


application_specific_backups

Normally, Bacula backs up a file simply by reading its contents and various attributes. In the case of certain applications, however, this will not produce a consistent snapshot that can be used to bring the application back up later. The most common example of this is live databases, where the files on disk may be in an intermediate state, such as MySQL, PostgreSQL, or MS Exchange.

This section is intended to try and gather up various tips and tricks on how to force the data on disk into a safe consistent state, or extract the data out into a snapshot that can later be restored.

General Techniques

These are methods that can be applied to a wide range of tricky applications to back up. They may need some tweaking, but hopefully they will at least point you in a useful direction.

Linux LVM Snapshots

If you have Linux configured with LVM, it is possible to take a snapshot of a filesystem, and back up that static snapshot instead of the live one. This allows you to shut down the application for only a few moments while the LVM snapshot is created, let bacula take as long as it needs to back up the snapshot data, and then destroy the snapshot.

Before going any further, you should be familiar with Linux LVM, and LVM in general. If not, a good resource is the Linux LVM HOWTO at http://www.tldp.org/HOWTO/LVM-HOWTO/

The first pass is a run before script that must a) shut down the offending application and b) create and mount a snapshot of the filesystem containing the volatile data.

#!/bin/sh

echo "Shutting down lively database  `date`"
/etc/init.d/lively stop
modprobe dm-snapshot
sleep 3
lvm lvcreate --size 50G --snapshot --name uno_snap /dev/VG/LV_uno
sleep 3
echo "Restarting lively database  `date`"
/etc/init.d/lively start
mount -o ro /dev/VG/uno_snap /uno_snap
exit 0

The static snapshot is now ready to be backed up from the /uno_snap mountpoint. Your fileset should include this directory. Once the backup is done, you will need to clean up the snapshot and reclaim the used disk space.

#!/bin/sh
echo "Destroying /uno snapshot"
umount /uno_snap
lvm lvremove -f /dev/VG/uno_snap
exit 0

One caveat to note is that when you restore the data, Bacula will restore it to the snapshot location that it was backed up from. You will most likely need to manually move the data back to where the application is expecting it before you try to restart it.

The Bacula estimate command is not useful when you backup snapshots : it reports always 0 as the snapshot is only created at the beginning of the backup job.

Applications

These are scripts and configs aimed directly at a specific application.

These contributed solutions offer methods for backup. However, some could also use either additional information on how to perform a restore as well, or links to other pages with more complete information.

Contributions

Work in progress

Requested specific backup solutions

  • CVS
  • FreeBSD + UFS2 Snapshots
  • FreeBSD + ZFS Snapshots
application_specific_backups.txt · Last modified: 2014/07/23 13:35 by bekks