Skip to content

Commit bcd59a9

Browse files
committed
Merge pull request #67 from github/no-gtar
remove GNU tar requirement for restoring to 2. add error message.
2 parents 6926763 + 602d011 commit bcd59a9

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

bin/ghe-restore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ if ! $restore_settings &&
119119
exit 1
120120
fi
121121

122+
# Restoring Elasticsearch to 11.10.3x via rsync requires GNU tar
123+
if [ "$GHE_VERSION_MAJOR.$GHE_VERSION_MINOR" = "1.0" ] && [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then
124+
if ! tar --version | grep -q GNU; then
125+
if ! command -v gtar >/dev/null 2>&1; then
126+
echo "GNU tar is required. Aborting." >&2
127+
exit 1
128+
fi
129+
fi
130+
fi
131+
122132
# Make sure the GitHub appliance is in maintenance mode and all writing
123133
# processes have bled out.
124134
ghe-maintenance-mode-enable "$host"

libexec/ghe-restore-es-rsync

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@ ghe_remote_version_required "$host"
2626
# The directory holding the snapshot to restore
2727
snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
2828

29-
# Use GNU tar on BSDs.
30-
TAR=tar
31-
if ! tar --version | grep -q GNU; then
32-
TAR=gtar
33-
fi
34-
3529
# Transfer all ES data from the latest snapshot to the GitHub instance.
3630
if [ ! -d "$snapshot_dir/elasticsearch" ]; then
3731
echo "Warning: Elasticsearch backup missing. Skipping ..."
@@ -41,9 +35,8 @@ if [ ! -d "$snapshot_dir/elasticsearch" ]; then
4135
elif [ "$GHE_VERSION_MAJOR" -gt 1 -a -f "$snapshot_dir/elasticsearch/elasticsearch.yml" ]; then
4236
cd "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/elasticsearch"
4337
ghe-ssh "$host" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-legacy'" 1>&3
44-
45-
$TAR -cf - --owner=root --group=root . |
46-
ghe-ssh "$host" -- "sudo tar -xf - -C '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-legacy'" 1>&3
38+
tar -cf - . |
39+
ghe-ssh "$host" -- "sudo tar --no-same-owner -xf - -C '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-legacy'" 1>&3
4740

4841
# restoring v2.0 ES snapshot into a v2.0 appliance
4942
elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then
@@ -60,6 +53,11 @@ elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then
6053

6154
# restoring v11.10.x ES snapshot into a v11.10.x appliance
6255
else
56+
# Use GNU tar on BSDs.
57+
TAR=tar
58+
if ! tar --version | grep -q GNU; then
59+
TAR=gtar
60+
fi
6361
cd "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"
6462
$TAR -cf - --owner=root --group=root elasticsearch |
6563
ghe-ssh "$host" -- 'ghe-import-es-indices' 1>&3

0 commit comments

Comments
 (0)