#########################################################################
# This command makes a backup copy of a given directory into a backup
-# directory, tags it with the date and time, and uses rsync
-# intelligent features to avoid making superfluous copies of files
-# which are already backuped.
+# directory, tags it with the date and time, and uses rsync smart use
+# of hard links to avoid unnecessary duplicates of files already
+# backuped.
set -e
if [[ -h "${current_backup}" ]]; then
rsync --link-dest="${current_backup}/" -axz "${full_path}/" "${new_backup}/"
- rm -f "${current_backup}"
+ rm "${current_backup}"
else
if [[ -a ${current_backup} ]]; then
echo "${current_backup} exists and is not a symbolic link" >&2
fi
fi
- ln -s "${new_backup}" "${current_backup}"
+ ln -vs "${new_backup}" "${current_backup}"
sync