5 # Test that src and dest trees are as identical as bup is capable of
6 # making them. For now, use rsync -niaHAX ...
10 Usage: compare-trees [-h] [-c] [-x] SOURCE DEST
15 Check file content (default)
17 Don't check file content (rely on size/timestamps, etc.)
21 verify_content=" --checksum"
23 while test $# -gt 0; do
26 -c) verify_content=" --checksum"; shift;;
27 -x) verify_content=""; shift;;
28 -*) usage 1>&2; exit 2;;
42 tmpfile="$(mktemp /tmp/bup-test-XXXXXXX)" || exit $?
43 trap "rm -rf '$tmpfile'" EXIT || exit $?
45 rsync_opts="-niaH$verify_content --delete"
47 rsync_version=$(rsync --version)
48 if [[ ! "$rsync_version" =~ "ACLs" ]] || [[ "$rsync_version" =~ "no ACLs" ]]; then
49 echo "Not comparing ACLs (not supported by available rsync)" 1>&2
53 echo "Not comparing ACLs (not yet supported on $OSTYPE)" 1>&2
56 rsync_opts="$rsync_opts -A"
62 if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
63 echo "Not comparing xattrs (not supported by available rsync)" 1>&2
68 # Even in dry-run mode, rsync may fail if -X is specified and the
69 # filesystems don't support xattrs.
71 if test "$xattrs_available"; then
72 rsync $rsync_opts -X "$src" "$dest" > "$tmpfile"
73 if test $? -ne 0; then
74 # Try again without -X
75 rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $?
78 rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $?
81 if test $(wc -l < "$tmpfile") != 0; then
82 echo "Differences between $src and $dest" 1>&2