]> arthur.barton.de Git - bup.git/commitdiff
sync-trees: drop -X and retry if -X fails
authorRob Browning <rlb@defaultvalue.org>
Tue, 22 Mar 2016 05:13:14 +0000 (00:13 -0500)
committerRob Browning <rlb@defaultvalue.org>
Tue, 22 Mar 2016 05:13:16 +0000 (00:13 -0500)
It appears that rsync may fail 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>
Tested-by: Rob Browning <rlb@defaultvalue.org>
t/sync-tree

index e2b330e9f20418f9ed0abb7875dd0e879227b82d..11d4abe3dc3f7f0c8172293351a2321c4466487d 100755 (executable)
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+set -u
+
 usage() {
 cat <<EOF
 Usage: sync-tree [-h] [-c] [-x] SOURCE/ DEST/
@@ -45,10 +47,23 @@ else
     esac
 fi
 
+xattrs_available=''
 if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
     echo "Not syncing xattrs (not supported by available rsync)" 1>&2
 else
-    rsync_opts="$rsync_opts -X"
+    xattrs_available=yes
 fi
 
-exec rsync $rsync_opts "$src" "$dest"
+
+# 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"
+    if test $? -ne 0; then
+        # Try again without -X
+        exec rsync $rsync_opts "$src" "$dest"
+    fi
+else
+    exec rsync $rsync_opts "$src" "$dest"
+fi