Skip to content

Commit b3bbcca

Browse files
committed
Merge pull request #52 from github/fix-vanished-files-warnings
Fix vanished file warnings causing ES transfer to fail
2 parents caa2b2b + 5cad4fc commit b3bbcca

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

libexec/ghe-backup-es-rsync

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fi
4848
# directory, using a previous snapshot to avoid transferring files that have
4949
# already been transferred.
5050
echo "* Performing initial sync of ES indices ..." 1>&3
51-
rsync -avz \
51+
ghe-rsync -avz \
5252
-e "ghe-ssh -p $(ssh_port_part "$host")" \
5353
--rsync-path='sudo -u git rsync' \
5454
$link_dest \
@@ -73,7 +73,7 @@ ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null
7373

7474
# Transfer all ES indices again
7575
echo "* Performing follow-up sync of ES indices ..." 1>&3
76-
rsync -avz \
76+
ghe-rsync -avz \
7777
-e "ghe-ssh -p $(ssh_port_part "$host")" \
7878
--rsync-path='sudo -u git rsync' \
7979
$link_dest \

libexec/ghe-backup-pages-rsync

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fi
3232
# Transfer Pages data from a GitHub instance to the current snapshot
3333
# directory, using a previous snapshot to avoid transferring files that have
3434
# already been transferred.
35-
rsync -avz \
35+
ghe-rsync -avz \
3636
-e "ghe-ssh -p $(ssh_port_part "$host")" \
3737
--rsync-path='sudo -u git rsync' \
3838
$link_dest \

libexec/ghe-backup-repositories-rsync

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ echo "
9292
# already been transferred. A set of rsync filter rules are provided on stdin
9393
# for each invocation.
9494
rsync_repository_data () {
95-
rsync -av \
95+
ghe-rsync -av \
9696
-e "ghe-ssh -p $(ssh_port_part "$host")" \
9797
$link_dest "$@" \
9898
--rsync-path='sudo -u git rsync' \

libexec/ghe-restore-pages-rsync

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ host="$1"
2323
# Transfer all Pages data from the latest snapshot to the GitHub instance
2424
# in a single rsync invocation.
2525
if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/" ]; then
26-
rsync -avz --delete \
26+
ghe-rsync -avz --delete \
2727
-e "ghe-ssh -p $(ssh_port_part "$host")" \
2828
--rsync-path="sudo -u git rsync" \
2929
"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/" \

libexec/ghe-restore-repositories-rsync

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ host="$1"
2222

2323
# Transfer all git repository data from the latest snapshot to the GitHub
2424
# instance in a single rsync invocation.
25-
rsync -av --delete \
25+
ghe-rsync -av --delete \
2626
-e "ghe-ssh -p $(ssh_port_part "$host")" \
2727
--rsync-path="sudo -u git rsync" \
2828
"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/" \

libexec/ghe-rsync

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
#/ Usage: ghe-rsync
3+
#/ Run rsync with silenced vanished file warnings (non-critical).
4+
#
5+
# Based on the rsync-no-vanished support script included with rsync:
6+
# https://bugzilla.samba.org/show_bug.cgi?id=10356
7+
8+
set -o pipefail
9+
10+
# Filter vanished file warnings from both stdout (rsync versions < 3.x) and
11+
# stderr (rsync versions >= 3.x). The complex redirections are necessary to
12+
# filter stderr while also keeping stdout and stderr separated.
13+
IGNOREOUT='^(file has vanished: |rsync warning: some files vanished before they could be transferred)'
14+
(rsync "${@}" 3>&1 1>&2 2>&3 3>&- |
15+
(egrep -v "$IGNOREOUT" || true)) 3>&1 1>&2 2>&3 3>&- |
16+
(egrep -v "$IGNOREOUT" || true)
17+
res=$?
18+
19+
# rsync exits with 24 when vanished files are detected.
20+
if [ $res = 24 ]; then
21+
res=0
22+
fi
23+
24+
exit $res

0 commit comments

Comments
 (0)