projects
/
scripts.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update.
[scripts.git]
/
freeze-dir.sh
diff --git
a/freeze-dir.sh
b/freeze-dir.sh
index
5ae7015
..
0a23b49
100755
(executable)
--- a/
freeze-dir.sh
+++ b/
freeze-dir.sh
@@
-17,9
+17,17
@@
# Contact <francois@fleuret.org> for comments & bug reports #
#########################################################################
# Contact <francois@fleuret.org> for comments & bug reports #
#########################################################################
+# This command makes a backup copy of a given directory into a backup
+# 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
set -e
-[[ ${FREEZE_DIR} ]] || FREEZE_DIR=${HOME}/.backups
+# The default directory does not start with a period, as it may be
+# huge and should not be "hidden" from the user.
+
+[[ ${FREEZE_DIR} ]] || FREEZE_DIR=${HOME}/freezer
if [[ ! -d ${FREEZE_DIR} ]]; then
echo "Can not find directory ${FREEZE_DIR}" >&2
if [[ ! -d ${FREEZE_DIR} ]]; then
echo "Can not find directory ${FREEZE_DIR}" >&2
@@
-27,9
+35,9
@@
if [[ ! -d ${FREEZE_DIR} ]]; then
fi
while [[ "$1" ]]; do
fi
while [[ "$1" ]]; do
-
- dir=$(basename "$
1
")
- path=$(dirname "$
1
")
+ real_path="$(realpath "$1")"
+ dir=$(basename "$
{real_path}
")
+ path=$(dirname "$
{real_path}
")
full_path="${path}/${dir}"
date=$(date +%Y_%b_%d_%H:%M:%S)
full_path="${path}/${dir}"
date=$(date +%Y_%b_%d_%H:%M:%S)
@@
-54,7
+62,7
@@
while [[ "$1" ]]; do
if [[ -h "${current_backup}" ]]; then
rsync --link-dest="${current_backup}/" -axz "${full_path}/" "${new_backup}/"
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
else
if [[ -a ${current_backup} ]]; then
echo "${current_backup} exists and is not a symbolic link" >&2
@@
-64,7
+72,7
@@
while [[ "$1" ]]; do
fi
fi
fi
fi
- ln -s "${new_backup}" "${current_backup}"
+ ln -
v
s "${new_backup}" "${current_backup}"
sync
sync