function check_if_failed()
{
if [ $? -ne 0 ]; then
- echo Step failed: $*
+ echo "Step FAILed: $*"
+ return 1
+ fi
+}
+
+function exit_if_failed()
+{
+ check_if_failed
+ if [ $? -ne 0 ]; then
+ exit 1
+ fi
+}
+
+function synch_to_backup()
+{
+ local source="$1"; shift
+ local dest="$1"; shift
+ if [ -z "$source" -o -z "$dest" ]; then
+ echo synch_to_backup function requires a source and a target folder to synch.
exit 1
fi
+ echo "Synchronizing $source into $dest."
+#hmmm: temporary measure until top-level dir bug fixed in synch_files app.
+ if [ ! -d "$dest" ]; then
+ mkdir -p "$dest"
+ if [ $? -ne 0 ]; then
+ echo "FAILed to make target directory: $dest"
+ return 1
+ fi
+ fi
+ synch_files "$source" "$dest"
+ check_if_failed "synching $source to $dest"
}
# just undo it first, to try to be sure we know we are mounted properly later.
# now saddle up the backup.
mount /z/backup/
-check_if_failed "mounting backup folder"
+exit_if_failed "mounting backup folder"
# we should always be synching to an existing set in there. make sure they exist.
# for the first ever backup, this is not a good check...
-test -d /z/backup/etc -a -d /z/backup/home
-check_if_failed "testing presence of prior backup"
+#test -d /z/backup/etc -a -d /z/backup/home
+#exit_if_failed "testing presence of prior backup"
+
+##############
+
+synch_to_backup /etc /z/backup/etc/
+
+##############
+
+for subdir in albums deepcore drupal fred git sharedspam sim svn trac ; do
+ synch_to_backup /home/$subdir /z/backup/home/$subdir
+done
+
+##############
-synch_files /etc /z/backup/etc/
-check_if_failed "synching etc to backup"
+synch_to_backup /var/lib/mailman /z/backup/var/lib/mailman
-synch_files /home /z/backup/home/
-check_if_failed "synching home to backup"
+##############
umount /z/backup/
-check_if_failed "unmounting backup folder"
+exit_if_failed "unmounting backup folder"