Skip to content

Commit 6f24de5

Browse files
authored
Merge upstream (#84)
* Skip hookshot es backup on pre 2.0 * Only restore hookshot es backup to cluster * Correct minor spelling error * Backup and restore ca certificates * Don't suppress output * Check if command exists so to expose errors * Backup not restore * Use which instead of type to verify existence * Silence test output * Run bm_file_path first * Revert removal of bm_file_path from bm_start In case bm.sh is used outside or independently of ghe-backup or ghe-restore, such as when testing backup utilities individual components. * Rename bm_file_path to bm_init Should make the intention a bit more clear. * Add --version flag to all commands * Check for missing GHE_DATA_DIR variable in config ``` $ ./bin/ghe-backup ./bin/../share/github-backup-utils/ghe-backup-config: line 82: [: !=: unary operator expected mkdir: : No such file or directory ``` These errors occur because `GHE_DATA_DIR` is not defined before running`ghe-backup-config`, causing it to throw errors. ``` $ ./share/github-backup-utils/ghe-backup-config ./share/github-backup-utils/ghe-backup-config: line 82: [: !=: unary operator expected mkdir: : No such file or directory Error: GHE_DATA_DIR does not exist. ``` This change adds a test to ensure `GHE_DATA_DIR` is defined, else return an appropriate error. ``` $ ./bin/ghe-backup Error: GHE_DATA_DIR not set in config file. $ ./share/github-backup-utils/ghe-backup-config Error: GHE_DATA_DIR not set in config file. ``` * Check backup-utils are not being run on GitHub Enterprise host Customers occasionally configure backup-utils to run on the GitHub Enterprise host or HA replica. Apart from losing their backup if the appliance is lost, it leads to running out of disk space issues. This PR adds a check for this case and returns an informative error to guide the user.
1 parent 908a38c commit 6f24de5

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ enable when output is logged to a file.
172172
173173
When restoring to an already configured GHE instance, settings, certificate, and license data
174174
are *not* restored to prevent overwriting manual configuration on the restore
175-
host. This behavior can be overriden by passing the `-c` argument to `ghe-restore`,
175+
host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`,
176176
forcing settings, certificate, and license data to be overwritten with the backup copy's data.
177177
178178
### Scheduling backups

bin/ghe-backup

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ if [ "$GHE_BACKUP_STRATEGY" = "tarball" ]; then
120120
GHE_MAINTENANCE_MODE_ENABLED=true
121121
fi
122122

123+
# Create benchmark file
124+
bm_init > /dev/null
125+
123126
ghe-backup-store-version ||
124127
echo "Warning: storing backup-utils version remotely failed."
125128

@@ -159,11 +162,11 @@ if [ $GHE_VERSION_MAJOR -ge 2 ]; then
159162
echo "Backing up audit log ..."
160163
ghe-backup-es-audit-log ||
161164
failures="$failures audit-log"
162-
fi
163165

164-
echo "Backing up hookshot logs ..."
165-
ghe-backup-es-hookshot ||
166-
failures="$failures hookshot"
166+
echo "Backing up hookshot logs ..."
167+
ghe-backup-es-hookshot ||
168+
failures="$failures hookshot"
169+
fi
167170

168171
echo "Backing up Git repositories ..."
169172
if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then

bin/ghe-restore

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ if $instance_configured; then
203203
fi
204204
fi
205205

206+
# Create benchmark file
207+
bm_init > /dev/null
208+
206209
ghe-backup-store-version ||
207210
echo "Warning: storing backup-utils version remotely failed."
208211

@@ -328,14 +331,14 @@ fi
328331
if $cluster; then
329332
echo "Restoring ElasticSearch Audit logs"
330333
ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3
334+
335+
echo "Restoring hookshot logs ..."
336+
ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3
331337
else
332338
echo "Restoring Elasticsearch indices ..."
333339
ghe-restore-es-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3
334340
fi
335341

336-
echo "Restoring hookshot logs ..."
337-
ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3
338-
339342
# Restart an already running memcached to reset the cache after restore
340343
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
341344
echo "Restarting memcached ..." 1>&3

share/github-backup-utils/bm.sh

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ bm_start()
1818
{
1919
eval "$(bm_desc_to_varname $@)_start=$(date +%s)"
2020

21-
bm_file_path > /dev/null
21+
bm_init > /dev/null
2222
}
2323

24-
bm_file_path() {
24+
bm_init() {
2525
if [ -n "$BM_FILE_PATH" ]; then
2626
echo $BM_FILE_PATH
2727
return

share/github-backup-utils/ghe-backup-settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
4545
fi
4646
fi
4747

48-
if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates"; then
48+
if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates 1>/dev/null"; then
4949
echo "* Transferring CA certificates ..." 1>&3
5050
ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar
5151
fi

0 commit comments

Comments
 (0)