rearrange code according to OUR coding standard

This commit is contained in:
Vincent Riquer 2009-11-23 15:32:03 +01:00
parent e567b44c47
commit 73280fefc5

View File

@ -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 \
-va \
--delete \
--delete-excluded \
--exclude-from="$EXCLUDES" \
/home/ $SNAPSHOT_RW/home/hourly.0 ;
/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