script to backup home and etc to off-machine storage.
[feisty_meow.git] / scripts / database / serene_backer_upper.sh
1 #!/bin/bash
2
3 function check_if_failed()
4 {
5   if [ $? -ne 0 ]; then
6     echo Step failed: $*
7     exit 1
8   fi
9 }
10
11 # just undo it first, to try to be sure we know we are mounted properly later.
12 umount /z/backup &>/dev/null
13
14 # now saddle up the backup.
15 mount /z/backup/
16 check_if_failed "mounting backup folder"
17
18 # we should always be synching to an existing set in there.  make sure they exist.
19 # for the first ever backup, this is not a good check...
20 test -d /z/backup/etc -a -d /z/backup/home
21 check_if_failed "testing presence of prior backup"
22
23 synch_files /etc /z/backup/etc/
24 check_if_failed "synching etc to backup"
25
26 synch_files /home /z/backup/home/
27 check_if_failed "synching home to backup"
28
29 umount /z/backup/
30 check_if_failed "unmounting backup folder"
31
32