On the plus side, they actually do have support now, but it's new,
and not remotely as well tested as tar/rsync/whatever's. If you'd
- like to help test, please do; something like 'rsync -niaHAX src/
- restore/' may be useful on that front.
+ like to help test, please do (see t/compare-trees for one
+ comparison method).
In addition, at the moment, if any strip or graft-style options
are specified to 'bup save', then no metadata will be written for
--- /dev/null
+#!/usr/bin/env bash
+
+# Test that src and dest trees are as identical as bup is capable of
+# making them. For now, use rsync -niaHAX ...
+
+set -e
+set -o pipefail
+
+usage() {
+cat <<EOF
+Usage: compare-trees [-h] [-c] [-x] SOURCE DEST
+OPTIONS:
+ -h
+ Display help
+ -c
+ Check file content (default)
+ -x
+ Don't check file content (rely on size/timestamps, etc.)
+EOF
+}
+
+verify_content=" --checksum"
+
+while getopts "hc" OPTION
+do
+ case "$OPTION" in
+ h) usage; exit 0;;
+ c) verify_content=" --checksum";;
+ x) verify_content="";;
+ ?) usage 1>&2; exit 1;;
+ esac
+done
+
+shift $(($OPTIND - 1))
+
+if ! test $# -eq 2
+then
+ usage 1>&2
+ exit 1
+fi
+
+src="$1"
+dest="$2"
+
+tmpfile="$(mktemp)"
+trap "rm -rf '${tmpfile}'" EXIT
+
+rsync -niaHAX$verify_content --delete "$src" "$dest" > "${tmpfile}"
+if test $(wc -l < "${tmpfile}") != 0; then
+ echo "Differences between $src and $dest"
+ cat "${tmpfile}"
+ exit 1
+fi
+
+exit 0
fi
}
-compare-trees()
-{
- (
- set -e
- set -o pipefail
- tmpfile="$(mktemp)"
- trap "rm -rf '${tmpfile}'" EXIT
- rsync -ni -aHAX "$1" "$2" > "${tmpfile}"
- if test $(wc -l < "${tmpfile}") != 0; then
- echo "ERROR: detected differences between $1 and $2"
- cat "${tmpfile}"
- false
- fi
- )
-}
-
test-src-create-extract()
{
# Test bup meta create/extract for ./src -> ./src-restore.
mkdir src-restore
WVPASS bup restore -C src-restore "/src/latest$(pwd)/"
WVPASS test -d src-restore/src
- WVPASS compare-trees src/ src-restore/src/
+ WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
rm -rf src.bup
set +x
)
WVPASS bup index src
WVPASS bup save -t -n src src
hardlink-test-run-restore
- WVPASS compare-trees src/ src-restore/src/
+ WVPASS "$TOP/t/compare-trees" -c src/ src-restore/src/
# Test hardlink changes between index runs.
#