Skip to content

Commit 21501c1

Browse files
authored
Merge pull request #881 from github/update-rsync-redirects
simplify complex redirects for ghe-rsync
2 parents 743e4ae + 09a92b9 commit 21501c1

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

share/github-backup-utils/ghe-rsync

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ set -o pipefail
1111
# shellcheck source=share/github-backup-utils/ghe-backup-config
1212
. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config"
1313

14-
# Filter vanished file warnings from both stdout (rsync versions < 3.x) and
15-
# stderr (rsync versions >= 3.x). The complex redirections are necessary to
16-
# filter stderr while also keeping stdout and stderr separated.
17-
ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)'
18-
1914
# Check for --ignore-missing-args parameter support and remove if unavailable.
2015
if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then
2116
parameters=("$@")
@@ -25,9 +20,15 @@ else
2520
done
2621
fi
2722

28-
(rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- |
29-
(egrep -v "$ignoreout" || true)) 3>&1 1>&2 2>&3 3>&- |
30-
(egrep -v "$ignoreout" || true)
23+
ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)'
24+
rsync_version_check=`rsync --version | egrep "version 3.[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
3132
res=$?
3233

3334
# Suppress exits with 24.

0 commit comments

Comments
 (0)