]> arthur.barton.de Git - bup.git/commitdiff
save: add test for --smaller, fix DESIGN document
authorJohannes Berg <johannes@sipsolutions.net>
Mon, 17 Feb 2020 19:03:22 +0000 (20:03 +0100)
committerRob Browning <rlb@defaultvalue.org>
Sun, 1 Mar 2020 22:54:42 +0000 (16:54 -0600)
Add a test for --smaller, in particular showing that the actual --smaller
behaviour doesn't match what's described in the DESIGN file, which says:

    Another interesting trick is that you can skip backing up files even if
    IX_HASHVALID *isn't* set, as long as you have that file's sha1 in the
    repository.  What that means is you've chosen not to backup the latest
    version of that file; instead, your new backup set just contains the
    most-recently-known valid version of that file.  This is a good trick if you
    want to do frequent backups of smallish files and infrequent backups of
    large ones (as in 'bup save --smaller').  Each of your backups will be
    "complete," in that they contain all the small files and the large ones, but
    intermediate ones will just contain out-of-date copies of the large files.

This ("Each of your backups will be 'complete,' [...]") would seem to indicate
all files should be present, but in fact neither new nor old files are actually
saved by 'bup save --smaller'.

To avoid confusion, also update the DESIGN documentation here.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
DESIGN
t/test-save-smaller [new file with mode: 0755]

diff --git a/DESIGN b/DESIGN
index e2419186ef057a4b398ce38c969f841445525cf1..8c2732dc96fc88ce28f08199cade221b485d3774 100644 (file)
--- a/DESIGN
+++ b/DESIGN
@@ -587,9 +587,10 @@ repository.  What that means is you've chosen not to backup the latest
 version of that file; instead, your new backup set just contains the
 most-recently-known valid version of that file.  This is a good trick if you
 want to do frequent backups of smallish files and infrequent backups of
-large ones (as in 'bup save --smaller').  Each of your backups will be
-"complete," in that they contain all the small files and the large ones, but
-intermediate ones will just contain out-of-date copies of the large files.
+large ones.  Each of your backups will be "complete," in that they contain
+all the small files and the large ones, but intermediate ones will just
+contain out-of-date copies of the large files. Note that this isn't done
+right now, and 'bup save --smaller' doesn't store bigger files _at all_.
 
 A final game we can play with the bupindex involves restoring: when you
 restore a directory from a previous backup, you can update the bupindex
diff --git a/t/test-save-smaller b/t/test-save-smaller
new file mode 100755 (executable)
index 0000000..6e625e6
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+. wvtest.sh
+. wvtest-bup.sh
+. t/lib.sh
+
+set -o pipefail
+
+top="$(WVPASS pwd)" || exit $?
+tmpdir="$(WVPASS wvmktempdir)" || exit $?
+export BUP_DIR="$tmpdir/bup"
+
+bup() { "$top/bup" "$@"; }
+
+WVPASS cd "$tmpdir"
+
+WVSTART "init"
+WVPASS bup init
+
+WVPASS mkdir "$tmpdir/save"
+WVPASS echo small0 > "$tmpdir/save/small"
+WVPASS echo bigbigbigbigbig01 > "$tmpdir/save/big1"
+big1sha="$(sha1sum < "$tmpdir/save/big1")"
+WVPASS bup index "$tmpdir/save"
+WVPASS bup save -vv -n test "$tmpdir/save"
+WVPASS mkdir "$tmpdir/restore1"
+WVPASS bup restore -v --outdir="$tmpdir/restore1/" "/test/latest$tmpdir/save/"
+WVPASS cmp "$tmpdir/restore1/small" "$tmpdir/save/small"
+WVPASS cmp "$tmpdir/restore1/big1" "$tmpdir/save/big1"
+
+WVSTART "save --smaller"
+WVPASS echo bigbigbigbigbig02 > "$tmpdir/save/big1"
+WVPASS echo bigbigbigbigbig03 > "$tmpdir/save/big2"
+WVPASS bup index "$tmpdir/save"
+WVPASS bup save -vv -n test --smaller=10 "$tmpdir/save"
+WVPASS mkdir "$tmpdir/restore2"
+WVPASS bup restore -v --outdir="$tmpdir/restore2/" "/test/latest$tmpdir/save/"
+WVPASS cmp "$tmpdir/restore2/small" "$tmpdir/save/small"
+# (per the original DESIGN document, we should've had the old version
+# of the modified large file, but really that isn't implemented)
+# must _not_ have this file at all
+WVFAIL test -f "$tmpdir/restore2/big1"
+# and not the new one either
+WVFAIL test -f "$tmpdir/restore2/big2"
+
+WVPASS rm -rf "$tmpdir"