diff options
Diffstat (limited to 'backupStatistics.in')
-rw-r--r-- | backupStatistics.in | 76 |
1 files changed, 50 insertions, 26 deletions
diff --git a/backupStatistics.in b/backupStatistics.in index 38bee6b..1f3c8f7 100644 --- a/backupStatistics.in +++ b/backupStatistics.in @@ -91,37 +91,61 @@ do_stage() echo 'remove inodes with duplicate hashes' return 0 fi - while read line - do - original="$( - grep -m1 "^${line%% *} " "${cacheDir}/${backupID}.inodes.sorted" | \ - sed 's|^\S\+ ||' - )" - for kopieInode in ${line#* } + if [ -r "${cacheDir}/next.action" ] + then + startInode="$(cat "${cacheDir}/next.action")" + sed " + :vor; + / ${startInode}\( \|$\)/{ + s@^\(\S\+ \)\(.* \)\?${startInode}\( \|$\)@\1${startInode}\3@; + bnach + }; + d; + bvor; + :nach; + n; + bnach + " "${cacheDir}/${backupID}.duplicates" + else + cat "${cacheDir}/${backupID}.duplicates" + fi | \ + while read line do - OIFS="${IFS}" - IFS="$(printf '\n\t')" - for kopie in $( - grep "^${kopieInode} " "${cacheDir}/${backupID}.inodes.sorted" | \ + original="$( + grep -m1 "^${line%% *} " "${cacheDir}/${backupID}.inodes.sorted" | \ sed 's|^\S\+ ||' - ) + )" + for kopieInode in ${line#* } do - IFS="${OIFS}" - if ${paranoid} - then - diff "${original}" "${kopie}" - fi - echo "rm \"${kopie}\"" - echo "ln \"${original}\" \"${kopie}\"" - if ! ${dummy} - then - rm "${kopie}" - ln "${original}" "${kopie}" - fi + echo "${kopieInode}" > "${cacheDir}/next.action2" + mv "${cacheDir}/next.action2" "${cacheDir}/next.action" + OIFS="${IFS}" + IFS="$(printf '\n\t')" + for kopie in $( + grep "^${kopieInode} " "${cacheDir}/${backupID}.inodes.sorted" | \ + sed 's|^\S\+ ||' + ) + do + IFS="${OIFS}" + if ${paranoid} + then + diff "${original}" "${kopie}" + fi + echo "rm \"${kopie}\"" + echo "ln \"${original}\" \"${kopie}\"" + if ! ${dummy} + then + rm "${kopie}" + ln "${original}" "${kopie}" + fi + done done done - done < \ - "${cacheDir}/${backupID}.duplicates" + if [ -r "${cacheDir}/next.action" ] && \ + grep -q " $(cat "${cacheDir}/next.action")\( \|$\)" "${cacheDir}/${backupID}.duplicates" + then + rm -f "${cacheDir}/next.action" "${cacheDir}/next.action2" + fi ;; esac } |