From fb74d94974aeea5a2c78d3e32afe2aaaaf0d6f61 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 17 Feb 2020 20:03:22 +0100 Subject: [PATCH] save: add test for --smaller, fix DESIGN document 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 Reviewed-by: Rob Browning --- DESIGN | 7 ++++--- t/test-save-smaller | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) create mode 100755 t/test-save-smaller diff --git a/DESIGN b/DESIGN index e241918..8c2732d 100644 --- 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 index 0000000..6e625e6 --- /dev/null +++ b/t/test-save-smaller @@ -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" -- 2.39.2