Skip to content

Commit d95134c

Browse files
authored
Merge pull request #635 from github/parallelize_storage_restore
Add parallelized restore capability to ghe-restore-storage
2 parents ad89be0 + 26db3e4 commit d95134c

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

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

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

14+
# Check to make sure moreutils parallel is installed and working properly
15+
ghe_parallel_check
16+
1417
# Show usage and bail with no arguments
1518
[ -z "$*" ] && print_usage
1619

@@ -128,17 +131,32 @@ for file_list in $tempdir/*.rsync; do
128131
else
129132
server=$host
130133
fi
134+
131135
storage_user=$(ghe-ssh $ssh_config_file_opt $server:$port -- stat -c %U /data/user/storage || echo git)
132136

133-
ghe_verbose "* Transferring data to $server ..."
137+
rsync_commands+=("
138+
if [ -n \"$GHE_VERBOSE\" ]; then
139+
echo \"* Transferring data to $server ...\" 1>&3
140+
fi
141+
134142
ghe-rsync -arvHR --delete \
135-
-e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \
136-
--rsync-path="sudo -u $storage_user rsync" \
143+
-e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \
144+
--rsync-path=\"sudo -u $storage_user rsync\" \
137145
--files-from=$file_list \
138146
--size-only \
139-
"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \
140-
"$server:$GHE_REMOTE_DATA_USER_DIR/storage/" 1>&3
147+
\"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./\" \
148+
\"$server:$GHE_REMOTE_DATA_USER_DIR/storage/\" 1>&3
149+
")
141150
done
151+
152+
if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then
153+
$GHE_PARALLEL_COMMAND $GHE_PARALLEL_RSYNC_COMMAND_OPTIONS -- "${rsync_commands[@]}"
154+
else
155+
for c in "${rsync_commands[@]}"; do
156+
eval "$c"
157+
done
158+
fi
159+
142160
bm_end "$(basename $0) - Restoring objects"
143161

144162
if $CLUSTER; then

0 commit comments

Comments
 (0)