Skip to content

Commit 10c7bbe

Browse files
committed
keep supportability for rsync2.x with a version check
1 parent 3a54d0f commit 10c7bbe

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

share/github-backup-utils/ghe-rsync

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,15 @@ else
2020
done
2121
fi
2222

23-
# Rsync >=3.x sends errors to stderr, so we must combine with stdout before the pipe so we can grep properly.
2423
ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)'
25-
rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true)
24+
rsync_version_check=`rsync --version | egrep "version 2.[0-9]*.[0-9]*"`
25+
if [ -z "$rsync_version_check" ]; then
26+
# rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe
27+
rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true)
28+
else
29+
# rsync <3.x sends errors to stdout.
30+
rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS | (egrep -v "$ignoreout" || true)
31+
fi
2632
res=$?
2733

2834
# Suppress exits with 24.

0 commit comments

Comments
 (0)