Snapshot is a perl script for creating backups based on Linux Logical Volume Management. Actually multiple modules are used as well but it is one script. When executed the script preforms the following tasks:
Some interesting features of the snapshot script are:
The scripts are developed and tested on centos 6.4 and have been used for a number of years already on a weekly basis on an opensuse 11.1 in the beginning, since late 2010 on 11.3, and since 2012 on opensuse 11.3, centos 6.2, 6.3, and 6.4.
The main entry point for backups is the mksnapshot script and its system configuration file /etc/sysconfig/snapshot. You should edit this configuration file to indicate which volumes you want to backup. Type mksnapshot without arguments for help and also see the comments in the configuration file.
The backup action of the mksnapshot script triggers the aforementioned snapshot perl script which is in /opt/snapshot directory. This script is usually not executed directly because it has an extensive command line. Instead configure the backup using /etc/sysconfig/snapshot and use mksnapshot.
Running mksnapshot requires you to specify one or more lifecycle phases or all of them using all. The lifecycle phases are:
The script produces a lot of logging output which is useful for troubleshooting and seeing the progress in real time. If you want to see a summary of the backup then use the script tailbackup which provides a much more condensed output showing you the results of the backup for each logical volume.
The iSCSI functionality is optional, login and logout simply do nothing if no iSCSI target is specified. I used iSCSI to be able to dynamically access a disk from a virtual machine. In that case USB is too slow and runtime plugging disks is not supported (yet) by Kernel Virtual Machine.
It is important to choose correct snapshot volume sizes. The volumes must be big enough to hold all changes to the snapshotted volumes for the duration of the backup. Typically, put the fastest changing volumes first. In my case this is the VCR directory where I am recording TV. This volume can have at most 4GB/hour of traffic so I make sure I back this up first snd also give it a larger snapshot volume.
Don't screw things up yourself by doing huge data transfers while the backup is running. If you modify data on the original volume, then the snapshot volume will use up more space (copy on write semantics).
Run the backup when the system is not heavily loaded. (In my case with the server running at home this is almost always :-)). This backup will impact system performance somewhat. You can reduce the load by throttling but that will make the backup take longer and may require larger snapshot volume sizes.
When taking a snapshot, some system activity must be frozen. This involves in particular databases. The backup script does this by invoking the scripts in the /etc/snapshot.d directory in alphabetical order with suspend before the snapshot takes place, and invoking these scripts in reverse order with resume after the snapshot volumes have been created.
Investigate all of these scripts to see whether they meet your needs and add, remove, or modify them as needed.
Use throttling to reduce the load on your system. Lower bandwidth does however come with the price of longer backup times and therefore possibly bigger required snapshot sizes.
The scripts are packaged in RPM format for Opensuse 11.3. The RPMs might work on other RPM based systems as well. The URL for the repository is http://wamblee.org/yum/public/. The RPM is snapshot
The subversion URL for read-only access is https://wamblee.org/svn/public/snapshot/trunk .
Use it at your own risk. I have not seen any instability of the system in the past year because of these backups (performed every week). However, on my previous server, throttling was absolutely necessary as the system could become unstable. I have not seen this issue on my newest server (Intel Xeon L5630, 24GB), but you have been warned.