3 # Test that src and dest trees are as identical as bup is capable of
4 # making them. For now, use rsync -niaHAX ...
8 Usage: compare-trees [-h] [-c] [-x] SOURCE DEST
13 Check file content (default)
15 Don't check file content (rely on size/timestamps, etc.)
19 verify_content=" --checksum"
21 while getopts "hcx" OPTION
25 c) verify_content=" --checksum";;
26 x) verify_content="";;
27 ?) usage 1>&2; exit 1;;
31 shift $(($OPTIND - 1)) || exit $?
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"
61 if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
62 echo "Not comparing xattrs (not supported by available rsync)" 1>&2
64 rsync_opts="$rsync_opts -X"
67 rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $?
69 if test $(wc -l < "$tmpfile") != 0; then
70 echo "Differences between $src and $dest"