rearrange code according to OUR coding standard
This commit is contained in:
parent
e567b44c47
commit
73280fefc5
@ -85,43 +85,52 @@ fi
|
|||||||
# rotating snapshots of /home (fixme: this should be more general)
|
# rotating snapshots of /home (fixme: this should be more general)
|
||||||
|
|
||||||
# step 1: delete the oldest snapshot, if it exists:
|
# step 1: delete the oldest snapshot, if it exists:
|
||||||
if [ -d $SNAPSHOT_RW/home/hourly.3 ] ; then \
|
if [ -d $SNAPSHOT_RW/home/hourly.3 ]
|
||||||
$RM -rf $SNAPSHOT_RW/home/hourly.3 ; \
|
then
|
||||||
fi ;
|
$RM -rf $SNAPSHOT_RW/home/hourly.3
|
||||||
|
fi
|
||||||
|
|
||||||
# step 2: shift the middle snapshots(s) back by one, if they exist
|
# step 2: shift the middle snapshots(s) back by one, if they exist
|
||||||
if [ -d $SNAPSHOT_RW/home/hourly.2 ] ; then \
|
if [ -d $SNAPSHOT_RW/home/hourly.2 ]
|
||||||
$MV $SNAPSHOT_RW/home/hourly.2 $SNAPSHOT_RW/home/hourly.3 ; \
|
then
|
||||||
fi;
|
$MV $SNAPSHOT_RW/home/hourly.2 $SNAPSHOT_RW/home/hourly.3
|
||||||
if [ -d $SNAPSHOT_RW/home/hourly.1 ] ; then \
|
fi
|
||||||
$MV $SNAPSHOT_RW/home/hourly.1 $SNAPSHOT_RW/home/hourly.2 ; \
|
if [ -d $SNAPSHOT_RW/home/hourly.1 ]
|
||||||
fi;
|
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,
|
# step 3: make a hard-link-only (except for dirs) copy of the latest snapshot,
|
||||||
# if that exists
|
# if that exists
|
||||||
if [ -d $SNAPSHOT_RW/home/hourly.0 ] ; then \
|
if [ -d $SNAPSHOT_RW/home/hourly.0 ]
|
||||||
$CP -al $SNAPSHOT_RW/home/hourly.0 $SNAPSHOT_RW/home/hourly.1 ; \
|
then
|
||||||
fi;
|
$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
|
# step 4: rsync from the system into the latest snapshot (notice that
|
||||||
# rsync behaves like cp --remove-destination by default, so the destination
|
# 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
|
# is unlinked first. If it were not so, this would copy over the other
|
||||||
# snapshot(s) too!
|
# snapshot(s) too!
|
||||||
$RSYNC \
|
$RSYNC \
|
||||||
-va --delete --delete-excluded \
|
-va \
|
||||||
|
--delete \
|
||||||
|
--delete-excluded \
|
||||||
--exclude-from="$EXCLUDES" \
|
--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
|
# 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.
|
# and thats it for home.
|
||||||
|
|
||||||
# now remount the RW snapshot mountpoint as readonly
|
# now remount the RW snapshot mountpoint as readonly
|
||||||
|
if [[ "$REMOUNT" == "true" ]]
|
||||||
$MOUNT -o remount,ro $MOUNT_DEVICE $SNAPSHOT_RW ;
|
then
|
||||||
if (( $? )); then
|
$MOUNT -o remount,ro $MOUNT_DEVICE $SNAPSHOT_RW
|
||||||
{
|
if (( $? ))
|
||||||
$ECHO "snapshot: could not remount $SNAPSHOT_RW readonly";
|
then
|
||||||
exit;
|
$ECHO "snapshot: could not remount $SNAPSHOT_RW readonly"
|
||||||
} fi;
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user