summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2016-10-25 13:34:04 +0200
committerErich Eckner <git@eckner.net>2016-11-03 22:52:05 +0100
commitc9784fb76a27f0a2a4c0bfb303ab25da49ed8846 (patch)
tree59341f4d01ee27f5fb45981089913120189d89e1
parent22168377cb68fbb5c460a686fdf0efe672d04c39 (diff)
downloadhardlinkedBackups-c9784fb76a27f0a2a4c0bfb303ab25da49ed8846.tar.xz
split stage 3 into two (generate; sort) in backupStatistics
-rw-r--r--Makefile2
-rw-r--r--backupStatistics.in22
2 files changed, 16 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 90b42c1..3090227 100644
--- a/Makefile
+++ b/Makefile
@@ -34,7 +34,7 @@ all: man.commons backup backup.1 lastBackups lastBackups.1 backupStatistics back
s/#VERSION#/$(VERSION)/; \
s@#BINDIR#@$(BINDIR)@; \
s@#ETCDIR#@$(ETCDIR)@; \
- s@#NUMSTAGES#@5@; \
+ s@#NUMSTAGES#@6@; \
s@#HELPTEXT#\(\s\+\)#@ --help \1display this help and exit\n --version\1display version and exit@; \
" $< > $@ && \
( [[ "$@" = *.* ]] || chmod +x "$@" )
diff --git a/backupStatistics.in b/backupStatistics.in
index 1f3c8f7..f910db4 100644
--- a/backupStatistics.in
+++ b/backupStatistics.in
@@ -51,25 +51,33 @@ do_stage()
echo 'generate lists $inode -> $contentHash'
return 0
fi
- tmpDirA="$(mktemp -d)"
- tmpDirB="$(mktemp -d "${cacheDir}/tmp.XXXXXX")"
uniq -m1 "${cacheDir}/${backupID}.inodes.sorted" | \
parallel \
sha512sum {=s/^[[:digit:]]\+ //=} \| \
sed "\"s|^\([0-9a-f]\{128\}\) .*\$|\1 "{=s/^\([[:digit:]]\+\) .*/\\1/=}"|\"" \
- \; | \
- sort -T "${tmpDirA}" -T "${tmpDirB}" > \
+ \; > \
"${cacheDir}/${backupID}.content"
- rmdir "${tmpDirA}" "${tmpDirB}"
;;
4)
if [ "$2" == '##DESCRIBE##' ]
then
+ echo 'sort previous lists by $contentHash'
+ return 0
+ fi
+ tmpDirA="$(mktemp -d)"
+ tmpDirB="$(mktemp -d "${cacheDir}/tmp.XXXXXX")"
+ sort -T "${tmpDirA}" -T "${tmpDirB}" "${cacheDir}/${backupID}.content" > \
+ "${cacheDir}/${backupID}.content.sorted"
+ rmdir "${tmpDirA}" "${tmpDirB}"
+ ;;
+ 5)
+ if [ "$2" == '##DESCRIBE##' ]
+ then
echo 'find duplicate hashes'
return 0
fi
(
- uniq -m1 --all-repeated=separate "${cacheDir}/${backupID}.content"
+ uniq -m1 --all-repeated=separate "${cacheDir}/${backupID}.content.sorted"
echo ""
) | \
sed 's|^\S\+ ||' | \
@@ -85,7 +93,7 @@ do_stage()
sed 's| $||' > \
"${cacheDir}/${backupID}.duplicates"
;;
- 5)
+ 6)
if [ "$2" == '##DESCRIBE##' ]
then
echo 'remove inodes with duplicate hashes'