Snapshot script for crashing boxes

This script will be updated and available at: http://partytime.wackyfunster.com/leet/snapshot.sh
I made a noarch RPM version as well, for those who prefer: http://partytime.wackyfunster.com/leet/snapshot-1.02.noarch.rpm

Here is an example of what real-world use might look like:

[root@wackyfunster root]# wget wackyfunster.com/leet/snapshot.sh
--00:47:01-- http://wackyfunster.com/leet/snapshot.sh
=> `snapshot.sh'
Resolving wackyfunster.com... 66.216.86.216
Connecting to wackyfunster.com|66.216.86.216|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://partytime.wackyfunster.com/leet/snapshot.sh [following]
--00:47:01-- http://partytime.wackyfunster.com/leet/snapshot.sh
=> `snapshot.sh'
Resolving partytime.wackyfunster.com... 66.216.86.216
Connecting to partytime.wackyfunster.com|66.216.86.216|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2,939 (2.9K) [application/x-sh]

100%[====================================>] 2,939 --.--K/s

00:47:01 (186.86 MB/s) - `snapshot.sh' saved [2939/2939]

[root@wackyfunster root]# chmod +x snapshot.sh
[root@wackyfunster root]# mv snapshot.sh /usr/local/bin
[root@wackyfunster root]# crontab -e
*/10 * * * * /usr/local/bin/snapshot.sh
crontab: installing new crontab

This will set the script to run once per 10 minutes, and archive the last hours worth of snapshots. The current snapshots will be stored in ~/.snapshot.cur
After a crash, this directory will be moved to ~/.snapshot.date (the date will be the first execution of the script after the server comes back up), and a symlink will be created from ~/.snapshot.last to the most recent set of snapshots.

As a note, if you need to change the commands executed by the script, just edit the section at the bottom (it's marked within the script), and make sure any output is redirected to ~/.snapshot.cur/snapshot.1

Submitted by jkelly on Thu, 2006-11-30 01:43. categories [ | ] login or register to post comments