use rsync --link-dest instead of cp -al + rsync (should be faster)
This commit is contained in:
parent
bd69150a8b
commit
c0210e073f
@ -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 \
|
||||||
|
--delete \
|
||||||
|
--delete-excluded \
|
||||||
|
--exclude-from='$EXCLUDES' \
|
||||||
|
--bwlimit='$BWLIMIT'"
|
||||||
|
|
||||||
|
if [ -d "$SNAPSHOT_RW/$NAME/daily.1/" ]
|
||||||
then
|
then
|
||||||
$CP -al "$SNAPSHOT_RW/$NAME/daily.0" "$SNAPSHOT_RW/$NAME/daily.1"
|
RSYNC_OPTS="$RSYNC_OPTS \
|
||||||
|
--link-dest='$SNAPSHOT_RW/$NAME/daily.1/'"
|
||||||
fi
|
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 \
|
$RSYNC \
|
||||||
-a \
|
$RSYNC_OPTS \
|
||||||
--delete \
|
|
||||||
--delete-excluded \
|
|
||||||
--exclude-from="$EXCLUDES" \
|
|
||||||
--bwlimit="$BWLIMIT" \
|
|
||||||
"${REMOTE_LOCATION}" \
|
"${REMOTE_LOCATION}" \
|
||||||
"$SNAPSHOT_RW/$NAME/daily.0"
|
"$SNAPSHOT_RW/$NAME/daily.0"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user