]> arthur.barton.de Git - bup.git/commitdiff
compare-trees: drop -X and retry if -X fails
authorRob Browning <rlb@defaultvalue.org>
Sat, 27 Feb 2016 20:07:41 +0000 (14:07 -0600)
committerRob Browning <rlb@defaultvalue.org>
Sat, 19 Mar 2016 20:21:36 +0000 (15:21 -0500)
It appears that rsync may fail, even during a --dry-run, if -X is
specified and the filesystem doesn't support xattrs.

Thanks to Greg Troxel for reporting the problem and helping test the
solution.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
t/compare-trees

index 41fb7ac7976e735609c134bc55af6b65f0bac013..aeaa086a86d1fb92b92bdb902cb34166e42abc44 100755 (executable)
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+set -u
+
 # Test that src and dest trees are as identical as bup is capable of
 # making them.  For now, use rsync -niaHAX ...
 
@@ -58,13 +60,25 @@ else
     esac
 fi
 
+xattrs_available=''
 if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
     echo "Not comparing xattrs (not supported by available rsync)" 1>&2
 else
-    rsync_opts="$rsync_opts -X"
+    xattrs_available=yes
 fi
 
-rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $?
+# Even in dry-run mode, rsync may fail if -X is specified and the
+# filesystems don't support xattrs.
+
+if test "$xattrs_available"; then
+    rsync $rsync_opts -X "$src" "$dest" > "$tmpfile"
+    if test $? -ne 0; then
+        # Try again without -X
+        rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $?
+    fi
+else
+    rsync $rsync_opts "$src" "$dest" > "$tmpfile" || exit $?
+fi
 
 if test $(wc -l < "$tmpfile") != 0; then
     echo "Differences between $src and $dest" 1>&2