Skip to content

Commit 9fea5f8

Browse files
committed
Check the user that owns storage instead of assuming the git user
This ensures this keeps working if we would change the user that owns this directory in the future.
1 parent b67b5da commit 9fea5f8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

share/github-backup-utils/ghe-backup-storage

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ if ! ls $tempdir/*.rsync >/dev/null 2>&1; then
113113
exit 0
114114
fi
115115

116+
storage_user=$(ghe-ssh "$GHE_HOSTNAME" -- stat -c %U /data/user/storage || echo git)
117+
116118
# rsync all the storage objects
117119
bm_start "$(basename $0) - Storage object sync"
118120
for file_list in $tempdir/*.rsync; do
@@ -124,7 +126,7 @@ for file_list in $tempdir/*.rsync; do
124126
ghe-rsync -avr \
125127
-e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \
126128
$link_dest "$@" \
127-
--rsync-path='sudo -u git rsync' \
129+
--rsync-path="sudo -u $storage_user rsync" \
128130
--files-from="$file_list" \
129131
--ignore-missing-args \
130132
--size-only \

share/github-backup-utils/ghe-restore-storage

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ if ! ls $tempdir/*.rsync >/dev/null 2>&1; then
119119
exit 0
120120
fi
121121

122+
storage_user=$(ghe-ssh "$GHE_HOSTNAME" -- stat -c %U /data/user/storage || echo git)
123+
122124
# rsync all the objects to the storage server where they belong.
123125
# One rsync invocation per server available.
124126
bm_start "$(basename $0) - Restoring objects"
@@ -131,7 +133,7 @@ for file_list in $tempdir/*.rsync; do
131133
ghe_verbose "* Transferring data to $server ..."
132134
ghe-rsync -arvHR --delete \
133135
-e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \
134-
--rsync-path="sudo -u git rsync" \
136+
--rsync-path="sudo -u $storage_user rsync" \
135137
--files-from=$file_list \
136138
--size-only \
137139
"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \

0 commit comments

Comments
 (0)