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.)
20 Check or don't check timestamps (checking is the default)
24 verify_content=" --checksum"
25 verify_times=' --times'
27 while test $# -gt 0; do
30 -c) verify_content=" --checksum"; shift;;
31 -x) verify_content=""; shift;;
32 --times) verify_times=' --times'; shift;;
33 --no-times) verify_times=''; shift;;
34 -*) usage 1>&2; exit 2;;
48 tmpfile="$(mktemp /tmp/bup-test-XXXXXXX)" || exit $?
49 trap "rm -rf '$tmpfile'" EXIT || exit $?
51 rsync_opts="-rlpgoD" # --archive, without --times
52 rsync_opts="$rsync_opts -niH --delete"
53 rsync_opts="$rsync_opts$verify_content"
54 rsync_opts="$rsync_opts$verify_times"
56 rsync_version=$(rsync --version)
57 if [[ ! "$rsync_version" =~ "ACLs" ]] || [[ "$rsync_version" =~ "no ACLs" ]]; then
58 echo "Not comparing ACLs (not supported by available rsync)" 1>&2
62 echo "Not comparing ACLs (not yet supported on $OSTYPE)" 1>&2
65 rsync_opts="$rsync_opts -A"
71 if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
72 echo "Not comparing xattrs (not supported by available rsync)" 1>&2
77 # Even in dry-run mode, rsync may fail if -X is specified and the
78 # filesystems don't support xattrs.
80 if test "$xattrs_available"; then
81 rsync $rsync_opts -X "$src" "$dest" > "$tmpfile"
82 if test $? -ne 0; then
83 # Try again without -X
84 rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $?
87 rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $?
90 if test $(wc -l < "$tmpfile") != 0; then
91 echo "Differences between $src and $dest" 1>&2