6
6
# / argument is provided, it always overrides the configured restore host.
7
7
# /
8
8
# / Options:
9
+ # / -f Don't prompt for confirmation before restoring.
9
10
# / -c Restore appliance settings and license in addition to
10
11
# / datastores. Settings are not restored by default to
11
12
# / prevent overwriting different configuration on the
@@ -32,8 +33,13 @@ export GHE_RESTORE_SNAPSHOT
32
33
33
34
# Parse arguments
34
35
restore_settings=false
36
+ force=false
35
37
while true ; do
36
38
case " $1 " in
39
+ -f|--force)
40
+ force=true
41
+ shift
42
+ ;;
37
43
-s)
38
44
GHE_RESTORE_SNAPSHOT=" $( basename " $2 " ) "
39
45
shift 2
@@ -70,11 +76,39 @@ GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH")
70
76
# strategy file written in the snapshot directory.
71
77
GHE_BACKUP_STRATEGY=$( cat " $GHE_RESTORE_SNAPSHOT_PATH /strategy" )
72
78
73
- echo " Starting $GHE_BACKUP_STRATEGY restore of $host from snapshot $GHE_RESTORE_SNAPSHOT "
74
-
75
79
# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION.
76
80
ghe_remote_version_required " $host "
77
81
82
+ # Prompt to verify the restore host given is correct. Restoring overwrites
83
+ # important data on the destination appliance that cannot be recovered. This is
84
+ # mostly to prevent accidents where the backup host is given to restore instead
85
+ # of a separate restore host since they're used in such close proximity.
86
+ if ! $force ; then
87
+ echo
88
+ echo " WARNING: All data on GitHub Enterprise appliance $hostname ($GHE_REMOTE_VERSION )"
89
+ echo " will be overwritten with data from snapshot ${GHE_RESTORE_SNAPSHOT} ."
90
+ echo " Please verify that this is the correct restore host before continuing."
91
+ printf " Type 'yes' to continue: "
92
+
93
+ while read -r response; do
94
+ case $response in
95
+ yes|Yes|YES)
96
+ break
97
+ ;;
98
+ ' ' )
99
+ printf " Type 'yes' to continue: "
100
+ ;;
101
+ * )
102
+ echo " Restore aborted." 1>&2
103
+ exit 1
104
+ ;;
105
+ esac
106
+ done
107
+ echo
108
+ fi
109
+
110
+ echo " Starting $GHE_BACKUP_STRATEGY restore of $host from snapshot $GHE_RESTORE_SNAPSHOT "
111
+
78
112
# Verify the host has been fully configured at least once unless the -c
79
113
# argument was provided.
80
114
if ! $restore_settings &&
0 commit comments