Linux Server Point in Time Snapshots
(a.k.a Roll Back, System Restore)
Overview
/cluster/bin/system_snapshot
/cluster/bin/system_restore
To take a snapshot, just run the system_snapshot executable. The first time you run this, it has to build a replica of your filesystem and will take much longer than on subsequent runs. It will build the duplicate filesystem tree in the /root/snapshots directory. The first run will also take up a lot of space because this initial replica is the same size as your existing filesystem. Subsequent updates store all changes as compressed diffs, and in general a huge amount of additional restore points can be stored without using up much additional storage.
The system_snapshot executable will also backup the Master Boot Record and the files in the boot partition. This enables you to boot from a CD and easily roll back a failed kernel upgrade or some other issue that may have rendered the system unbootable.
Typical output for system_snapshot looks like this:
root@sqlmaster ~ # /cluster/bin/system_snapshot
Current backup dir size is 2 GB
Checking to make sure snapshot directory does not exceed 1.5 times
the size of the primary filesystem, as specified in
/cluster/system_snapshots.conf configuration file.
Old snapshots will be removed as needed to create space. However, at
least 2 snapshots will always be retained and snapshots newer
than 86400 seconds will never be automatically removed.
Excluding databases found in /cluster/database_locations.
These are backed up separately by /cluster/bin/db_snapshot
Taking snapshot at Dec-11-2009--15hrs.59min
Exclusions
| */mnt/ | var/lib/heartbeat/* |
| /var/lock/subsys/* | /dev |
| /sys | /proc |
| /tmp | *.pid |
| *.*$ | *.swp |
| Note: Directories listed in /cluster/database_locations are also excluded. These are handled separately by the database snapshot tools. | |
Automatically Creating Restore Points
crontab -e
1 1 * * * /cluser/bin/system_snapshot
Rolling back to a Restore Point
root@sqlmaster ~ # /cluster/bin/system_restoreBackups currently available:Restore point 1: 12-11-2009 : at 15 hours, 25 min, and 29 seconds. ( 0 days, 0 hrs, 40 minutes ago)Restore point 2: 12-11-2009 : at 15 hours, 59 min, and 38 seconds. ( 0 days, 0 hrs, 6 minutes ago)The current server time is Fri Dec 11 16:05:58 EST 2009Any restore operation will exclude these databases:/var/lib/mysql/var/lib/mysql_recoveryThese are backed up separately by /cluster/bin/db_snapshot andrestoring a system snapshot with this tool WILL NOT touch the data,but any configuration files in /etc/ (like /etc/my.cnf ) will berestored to their prior state.Enter the number of the restore point to recover to (or press CTRL-C to exit): 2ARE YOU SURE? THIS WILL REVERT THE FILESYSTEM TO THIS POINT IN TIME!Changes since then will be lost, unless a more recent restore pointexists (if so, you can still roll forward).
To continue and revert the system to a prior point in time, type 'yes' :