From 798ac97a52ab9314adb7d063f875b3f4b84a3d43 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sat, 7 Mar 2015 12:05:33 +0100 Subject: [PATCH] Re-enable dedup, add test (closes #95) --- cmd/restic/cmd_backup.go | 18 +++++++++--------- testsuite/test-backup-dedup.sh | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) create mode 100755 testsuite/test-backup-dedup.sh diff --git a/cmd/restic/cmd_backup.go b/cmd/restic/cmd_backup.go index 0921a8390..54e23b0e6 100644 --- a/cmd/restic/cmd_backup.go +++ b/cmd/restic/cmd_backup.go @@ -217,16 +217,16 @@ func (cmd CmdBackup) Execute(args []string) error { return nil } - // fmt.Printf("loading blobs\n") - // pb, err := newLoadBlobsProgress(s) - // if err != nil { - // return err - // } + fmt.Printf("loading blobs\n") + pb, err := newLoadBlobsProgress(s) + if err != nil { + return err + } - // err = arch.Preload(pb) - // if err != nil { - // return err - // } + err = arch.Preload(pb) + if err != nil { + return err + } _, id, err := arch.Snapshot(newArchiveProgress(stat), target, parentSnapshotID) if err != nil { diff --git a/testsuite/test-backup-dedup.sh b/testsuite/test-backup-dedup.sh new file mode 100755 index 000000000..a3f2e7a4d --- /dev/null +++ b/testsuite/test-backup-dedup.sh @@ -0,0 +1,23 @@ +set -e + +prepare +run restic init + +# first backup without dedup +run restic backup "${BASE}/fake-data" +size=$(du -sm "$RESTIC_REPOSITORY" | cut -f1) +debug "size before: $size" + +# second backup with dedup +run restic backup "${BASE}/fake-data" +size2=$(du -sm "$RESTIC_REPOSITORY" | cut -f1) +debug "size after: $size2" + +# check if the repository hasn't grown more than 5% +threshhold=$(($size+$size/20)) +debug "threshhold is $threshhold" +if [[ "$size2" -gt "$threshhold" ]]; then + fail "dedup failed, repo grown more than 5%, before ${size}MiB after ${size2}MiB threshhold ${threshhold}MiB" +fi + +cleanup