Skip to content

Commit f26ee12

Browse files
authored
Merge pull request #834 from github/revert-804-master
Revert "fixed the problem that memory overflows when there are too many files…"
2 parents e52f363 + 4237571 commit f26ee12

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ GHE_HOSTNAME="$1"
2626
# us run this script directly.
2727
: ${GHE_RESTORE_SNAPSHOT:=current}
2828

29+
# Find the objects to restore
30+
storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindepth 4 -maxdepth 4 -type f -exec wc -c {} \;)
31+
32+
# No need to restore anything, early exit
33+
if [ -z "$storage_paths" ]; then
34+
echo "Warning: Storage backup missing. Skipping ..."
35+
exit 0
36+
fi
37+
2938
# Perform a host-check and establish GHE_REMOTE_XXX variables.
3039
ghe_remote_version_required "$GHE_HOSTNAME"
3140

@@ -42,22 +51,11 @@ tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX)
4251
remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-restore-XXXXXX)
4352
ssh_config_file_opt=
4453
opts="$GHE_EXTRA_SSH_OPTS"
45-
storage_paths=$tempdir/storage_paths
4654
tmp_list=$tempdir/tmp_list
4755
remote_tmp_list=$remote_tempdir/remote_tmp_list
4856
routes_list=$tempdir/routes_list
4957
remote_routes_list=$remote_tempdir/remote_routes_list
5058

51-
# Find the objects to restore
52-
cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/
53-
find storage -mindepth 4 -maxdepth 4 -type f -print0 | xargs -0 -n 1 -P 0 wc -c > $storage_paths
54-
55-
# No need to restore anything, early exit
56-
if [ ! -s $storage_paths ]; then
57-
echo "Warning: Storage backup missing. Skipping ..."
58-
exit 0
59-
fi
60-
6159
if $CLUSTER; then
6260
ssh_config_file="$tempdir/ssh_config"
6361
ssh_config_file_opt="-F $tempdir/ssh_config"
@@ -84,7 +82,7 @@ trap 'cleanup' EXIT
8482
# b63c30f6f885e59282c2aa22cfca846516b5e72621c10a58140fb04d133e2c17 5592492
8583
# ...
8684
bm_start "$(basename $0) - Building object list"
87-
cat $storage_paths | awk '{print $2 " " $1}' | awk -F/ '{print $NF }' > $tmp_list
85+
echo "$storage_paths" | awk '{print $2 " " $1}' | awk -F/ '{print $NF }' > $tmp_list
8886
bm_end "$(basename $0) - Building object list"
8987

9088
# The server returns the list of servers where the objects will be sent:

0 commit comments

Comments
 (0)