From 73280fefc5b6c1e3a1665bf3e472c7ce171817e1 Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Mon, 23 Nov 2009 15:32:03 +0100 Subject: [PATCH] rearrange code according to OUR coding standard --- remote-backup | 57 +++++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/remote-backup b/remote-backup index 0821fd0..0eadba1 100755 --- a/remote-backup +++ b/remote-backup @@ -85,43 +85,52 @@ fi # rotating snapshots of /home (fixme: this should be more general) # step 1: delete the oldest snapshot, if it exists: -if [ -d $SNAPSHOT_RW/home/hourly.3 ] ; then \ -$RM -rf $SNAPSHOT_RW/home/hourly.3 ; \ -fi ; +if [ -d $SNAPSHOT_RW/home/hourly.3 ] +then + $RM -rf $SNAPSHOT_RW/home/hourly.3 +fi # step 2: shift the middle snapshots(s) back by one, if they exist -if [ -d $SNAPSHOT_RW/home/hourly.2 ] ; then \ -$MV $SNAPSHOT_RW/home/hourly.2 $SNAPSHOT_RW/home/hourly.3 ; \ -fi; -if [ -d $SNAPSHOT_RW/home/hourly.1 ] ; then \ -$MV $SNAPSHOT_RW/home/hourly.1 $SNAPSHOT_RW/home/hourly.2 ; \ -fi; +if [ -d $SNAPSHOT_RW/home/hourly.2 ] +then + $MV $SNAPSHOT_RW/home/hourly.2 $SNAPSHOT_RW/home/hourly.3 +fi +if [ -d $SNAPSHOT_RW/home/hourly.1 ] +then + $MV $SNAPSHOT_RW/home/hourly.1 $SNAPSHOT_RW/home/hourly.2 +fi # step 3: make a hard-link-only (except for dirs) copy of the latest snapshot, # if that exists -if [ -d $SNAPSHOT_RW/home/hourly.0 ] ; then \ -$CP -al $SNAPSHOT_RW/home/hourly.0 $SNAPSHOT_RW/home/hourly.1 ; \ -fi; +if [ -d $SNAPSHOT_RW/home/hourly.0 ] +then + $CP -al $SNAPSHOT_RW/home/hourly.0 $SNAPSHOT_RW/home/hourly.1 +fi # step 4: rsync from the system into the latest snapshot (notice that # rsync behaves like cp --remove-destination by default, so the destination # is unlinked first. If it were not so, this would copy over the other # snapshot(s) too! -$RSYNC \ - -va --delete --delete-excluded \ - --exclude-from="$EXCLUDES" \ - /home/ $SNAPSHOT_RW/home/hourly.0 ; +$RSYNC \ + -va \ + --delete \ + --delete-excluded \ + --exclude-from="$EXCLUDES" \ + /home/ \ + $SNAPSHOT_RW/home/hourly.0 # step 5: update the mtime of hourly.0 to reflect the snapshot time -$TOUCH $SNAPSHOT_RW/home/hourly.0 ; +$TOUCH $SNAPSHOT_RW/home/hourly.0 # and thats it for home. # now remount the RW snapshot mountpoint as readonly - -$MOUNT -o remount,ro $MOUNT_DEVICE $SNAPSHOT_RW ; -if (( $? )); then -{ - $ECHO "snapshot: could not remount $SNAPSHOT_RW readonly"; - exit; -} fi; +if [[ "$REMOUNT" == "true" ]] +then + $MOUNT -o remount,ro $MOUNT_DEVICE $SNAPSHOT_RW + if (( $? )) + then + $ECHO "snapshot: could not remount $SNAPSHOT_RW readonly" + exit + fi +fi