modified error handling methods
[feisty_meow.git] / scripts / archival / serene_backer_upper.sh
1 #!/bin/bash
2
3 # backs up crucial directories on my server into the allotted backup area.
4 #
5 # Author: Chris Koeritz
6
7 # given a source and target folder, this synchronizes the source into the target.
8 function synch_to_backup()
9 {
10   local source="$1"; shift
11   local dest="$1"; shift
12   if [ -z "$source" -o -z "$dest" ]; then
13     echo synch_to_backup function requires a source and a target folder to synch.
14     exit 1
15   fi
16   echo "Synchronizing $source into $dest."
17   synch_files "$source" "$dest"
18   continue_on_error "synching $source to $dest"
19 }
20
21 ##############
22
23 # main body of script...
24
25 # just undo it first, to try to be sure we know we are mounted properly later.
26 #NO LONGER USING MOUNT: umount /z/backup &>/dev/null
27
28 # now saddle up the backup.
29 #NO LONGER USING MOUNT: mount /z/backup/
30 #NO LONGER USING MOUNT: exit_on_error "mounting backup folder"
31
32 # we should always be synching to an existing set in there.  make sure they exist.
33 # for the first ever backup, this is not a good check...
34 #test -d /z/backup/etc -a -d /z/backup/home
35 #exit_on_error "testing presence of prior backup"
36
37 ##############
38
39 synch_to_backup /etc /z/backup/etc/
40
41 ##############
42
43 for subdir in fred/Maildir git sharedspam svn trac www-data ; do 
44   synch_to_backup /home/$subdir /z/backup/home/$subdir
45 done
46
47 ##############
48
49 synch_to_backup /var/lib/mailman /z/backup/var/lib/mailman
50 synch_to_backup /var/lib/mysql /z/backup/var/lib/mysql
51
52 ##############
53
54 #NO LONGER USING MOUNT: umount /z/backup/
55 #NO LONGER USING MOUNT: exit_on_error "unmounting backup folder"
56
57