3 # Test that src and dest trees are as identical as bup is capable of
4 # making them. For now, use rsync -niaHAX ...
11 Usage: compare-trees [-h] [-c] [-x] SOURCE DEST
16 Check file content (default)
18 Don't check file content (rely on size/timestamps, etc.)
22 verify_content=" --checksum"
24 while getopts "hcx" OPTION
28 c) verify_content=" --checksum";;
29 x) verify_content="";;
30 ?) usage 1>&2; exit 1;;
34 shift $(($OPTIND - 1))
45 tmpfile="$(mktemp /tmp/bup-test-XXXXXXX)"
46 trap "rm -rf '${tmpfile}'" EXIT
48 rsync_opts="-niaH$verify_content --delete"
50 rsync_version=$(rsync --version)
51 if [[ ! "$rsync_version" =~ "ACLs" ]] || [[ "$rsync_version" =~ "no ACLs" ]]; then
52 echo "Not comparing ACLs (not supported by available rsync)" 1>&2
56 echo "Not comparing ACLs (not yet supported on $OSTYPE)" 1>&2
59 rsync_opts="$rsync_opts -A"
64 if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
65 echo "Not comparing xattrs (not supported by available rsync)" 1>&2
67 rsync_opts="$rsync_opts -X"
70 rsync $rsync_opts "$src" "$dest" > "${tmpfile}"
72 if test $(wc -l < "${tmpfile}") != 0; then
73 echo "Differences between $src and $dest"