summaryrefslogtreecommitdiff
path: root/backupStatistics.in
diff options
context:
space:
mode:
Diffstat (limited to 'backupStatistics.in')
-rw-r--r--backupStatistics.in42
1 files changed, 27 insertions, 15 deletions
diff --git a/backupStatistics.in b/backupStatistics.in
index c68d071..c9123ec 100644
--- a/backupStatistics.in
+++ b/backupStatistics.in
@@ -94,26 +94,32 @@ do_stage()
while read line
do
original="$(
- grep "^${line%% *} " "${cacheDir}/${backupID}.inodes.sorted" | \
+ grep -m1 "^${line%% *} " "${cacheDir}/${backupID}.inodes.sorted" | \
sed 's|^\S\+ ||'
)"
for kopieInode in ${line#* }
do
- kopie="$(
+ OIFS="${IFS}"
+ IFS="$(printf '\n\t')"
+ for kopie in $(
grep "^${kopieInode} " "${cacheDir}/${backupID}.inodes.sorted" | \
sed 's|^\S\+ ||'
- )"
- diff "${original}" "${kopie}"
- if ${dummy}
- then
- echo "rm \"${kopie}\""
- echo "ln \"${original}\" \"${kopie}\""
- else
- exit 1
- DO NOT EXECUTE YET
- # rm "${kopie}"
- # ln "${original}" "${kopie}"
- fi
+ )
+ do
+ IFS="${OIFS}"
+ if ${paranoid}
+ then
+ diff "${original}" "${kopie}"
+ fi
+ if ${dummy}
+ then
+ echo "rm \"${kopie}\""
+ echo "ln \"${original}\" \"${kopie}\""
+ else
+ rm "${kopie}"
+ ln "${original}" "${kopie}"
+ fi
+ done
done
done < \
"${cacheDir}/${backupID}.duplicates"
@@ -132,6 +138,7 @@ With no options, tidy up all backups. THIS CAN BE VERY TIME CONSUMING.
Mandatory arguments to long options are mandatory for short options too.
-d, --dummy only generate lists, do not modify backupfiles
-m, --max=maxNum stop execution after step maxNum
+ -p, --paranoid test for file differences before relinking (test _should_ be obsolete)
-s, --skip=skipNum skip first skipNum steps
#HELPTEXT# #
@@ -148,10 +155,11 @@ the executed steps are:'
}
eval set -- "$(
- getopt -o dm:s: \
+ getopt -o dm:ps: \
--long dummy \
--long help \
--long max: \
+ --long paranoid \
--long skip: \
--long version \
-n "$(basename "$0")" -- "$@" || \
@@ -160,6 +168,7 @@ eval set -- "$(
dummy=false
maxNum=#NUMSTAGES#
+paranoid=false
skipNum=0
while true; do
@@ -174,6 +183,9 @@ while true; do
shift
maxNum=$1
;;
+ -p|--paranoid)
+ paranoid=true
+ ;;
-s|--skip)
shift
skipNum=$1