use rsync --link-dest instead of cp -al + rsync (should be faster)

This commit is contained in:
Vincent Riquer 2011-01-31 10:18:15 +01:00
parent bd69150a8b
commit c0210e073f

View File

@ -105,8 +105,8 @@ do
$RM -rf "$SNAPSHOT_RW/$NAME/daily.${MAX_ROTATE}" $RM -rf "$SNAPSHOT_RW/$NAME/daily.${MAX_ROTATE}"
fi fi
# step 2: shift the middle snapshots(s) back by one, if they exist # step 2: shift the snapshots(s) back by one, if they exist
for backup_number in $(seq $((${MAX_ROTATE}-1)) -1 1) for backup_number in $(seq $((${MAX_ROTATE}-1)) -1 0)
do do
if [ -d "$SNAPSHOT_RW/$NAME/daily.${backup_number}" ] if [ -d "$SNAPSHOT_RW/$NAME/daily.${backup_number}" ]
then then
@ -115,23 +115,22 @@ do
fi fi
done done
# step 3: make a hard-link-only (except for dirs) copy of the latest snapshot, # step 3: rsync from the system, linking to latest snapshot if files are
# if that exists # identical.
if [ -d "$SNAPSHOT_RW/$NAME/daily.0" ] RSYNC_OPTS="-a \
then
$CP -al "$SNAPSHOT_RW/$NAME/daily.0" "$SNAPSHOT_RW/$NAME/daily.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 \
-a \
--delete \ --delete \
--delete-excluded \ --delete-excluded \
--exclude-from="$EXCLUDES" \ --exclude-from='$EXCLUDES' \
--bwlimit="$BWLIMIT" \ --bwlimit='$BWLIMIT'"
if [ -d "$SNAPSHOT_RW/$NAME/daily.1/" ]
then
RSYNC_OPTS="$RSYNC_OPTS \
--link-dest='$SNAPSHOT_RW/$NAME/daily.1/'"
fi
$RSYNC \
$RSYNC_OPTS \
"${REMOTE_LOCATION}" \ "${REMOTE_LOCATION}" \
"$SNAPSHOT_RW/$NAME/daily.0" "$SNAPSHOT_RW/$NAME/daily.0"