3 # backs up crucial directories on my server into the allotted backup area.
5 # Author: Chris Koeritz
7 # tests whether the last action worked or not, and if not, it issues the
8 # complaint passed as the arguments.
9 function check_if_failed()
12 echo "Step FAILed: $*"
17 # uses the failure checking function, but actually exits out of the script
18 # if there was a failure detected.
19 function exit_if_failed()
27 # given a source and target folder, this synchronizes the source into the target.
28 function synch_to_backup()
30 local source="$1"; shift
31 local dest="$1"; shift
32 if [ -z "$source" -o -z "$dest" ]; then
33 echo synch_to_backup function requires a source and a target folder to synch.
36 echo "Synchronizing $source into $dest."
37 ####hmmm: temporary measure until top-level dir bug fixed in synch_files app.
38 ### if [ ! -d "$dest" ]; then
40 ### if [ $? -ne 0 ]; then
41 ### echo "FAILed to make target directory: $dest"
45 synch_files "$source" "$dest"
46 check_if_failed "synching $source to $dest"
51 # main body of script...
53 # just undo it first, to try to be sure we know we are mounted properly later.
54 #NO LONGER USING MOUNT: umount /z/backup &>/dev/null
56 # now saddle up the backup.
57 #NO LONGER USING MOUNT: mount /z/backup/
58 #NO LONGER USING MOUNT: exit_if_failed "mounting backup folder"
60 # we should always be synching to an existing set in there. make sure they exist.
61 # for the first ever backup, this is not a good check...
62 #test -d /z/backup/etc -a -d /z/backup/home
63 #exit_if_failed "testing presence of prior backup"
67 synch_to_backup /etc /z/backup/etc/
71 for subdir in fred/Maildir git sharedspam svn trac www-data ; do
72 synch_to_backup /home/$subdir /z/backup/home/$subdir
77 synch_to_backup /var/lib/mailman /z/backup/var/lib/mailman
78 synch_to_backup /var/lib/mysql /z/backup/var/lib/mysql
82 #NO LONGER USING MOUNT: umount /z/backup/
83 #NO LONGER USING MOUNT: exit_if_failed "unmounting backup folder"