@@ -97,6 +97,15 @@ elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
9797 restore_settings=true
9898fi
9999
100+ # Figure out if we're restoring into cluster
101+ cluster=false
102+ if ghe-ssh " $GHE_HOSTNAME " -- \
103+ " [ -f '$GHE_REMOTE_ROOT_DIR /etc/github/cluster' ]" ; then
104+ cluster=true
105+ instance_configured=true
106+ restore_settings=false
107+ fi
108+
100109# Figure out if this instance is in a replication pair
101110if ghe-ssh " $GHE_HOSTNAME " -- " ghe-repl-status -r 2>/dev/null" \
102111 | grep -Eq " replica|primary" ; then
176185# Make sure mysql and elasticsearch are prep'd and running before restoring into
177186# appliances v2.x or greater. These services will not have been started on appliances
178187# that have not been configured yet.
179- if [ " $GHE_VERSION_MAJOR " -ge 2 ]; then
188+ if ! $cluster ; then
189+ if [ " $GHE_VERSION_MAJOR " -ge 2 ]; then
180190 echo " sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" |
181191 ghe-ssh " $GHE_HOSTNAME " -- /bin/sh 1>&3
192+ fi
182193fi
183194
184- # Remove temporary 2.2 storage migration directory if it exists
185- echo " if [ -d /data/user/repositories-nw-backup ]; then sudo rm -rf /data/user/repositories-nw-backup; fi" |
186- ghe-ssh " $GHE_HOSTNAME " -- /bin/sh 1>&3
195+ echo " Restoring MySQL database ..."
196+ gzip -dc " $GHE_RESTORE_SNAPSHOT_PATH /mysql.sql.gz" | ghe-ssh " $GHE_HOSTNAME " -- ' ghe-import-mysql'
187197
188- echo " Restoring Git repositories ..."
189- ghe-restore-repositories- ${GHE_BACKUP_STRATEGY} " $GHE_HOSTNAME " 1>&3
198+ echo " Restoring Redis database ..."
199+ ghe-ssh " $GHE_HOSTNAME " -- ' ghe-import-redis ' < " $GHE_RESTORE_SNAPSHOT_PATH /redis.rdb " 1>&3
190200
191- echo " Restoring GitHub Pages ..."
192- ghe-restore-pages-${GHE_BACKUP_STRATEGY} " $GHE_HOSTNAME " 1>&3
201+ if $cluster ; then
202+ echo " Restoring Git repositories into cluster ..."
203+ ghe-restore-repositories-dgit " $GHE_HOSTNAME " 1>&3
193204
194- if [ " $GHE_VERSION_MAJOR " -ge 2 ]; then
195- echo " Restoring asset attachments ..."
196- ghe-restore-userdata alambic_assets " $GHE_HOSTNAME " 1>&3
205+ echo " Restoring Gists into cluster ..."
206+ ghe-restore-repositories-gist " $GHE_HOSTNAME " 1>&3
207+ else
208+ # Remove temporary 2.2 storage migration directory if it exists
209+ echo " if [ -d /data/user/repositories-nw-backup ]; then sudo rm -rf /data/user/repositories-nw-backup; fi" |
210+ ghe-ssh " $GHE_HOSTNAME " -- /bin/sh 1>&3
197211
198- echo " Restoring hook deliveries ..."
199- ghe-restore-userdata hookshot " $GHE_HOSTNAME " 1>&3
212+ echo " Restoring Git repositories ..."
213+ ghe-restore-repositories- ${GHE_BACKUP_STRATEGY} " $GHE_HOSTNAME " 1>&3
200214fi
201215
202- echo " Restoring MySQL database ..."
203- gzip -dc " $GHE_RESTORE_SNAPSHOT_PATH /mysql.sql.gz" | ghe-ssh " $GHE_HOSTNAME " -- ' ghe-import-mysql' 1>&3
204-
205- echo " Restoring Redis database ..."
206- ghe-ssh " $GHE_HOSTNAME " -- ' ghe-import-redis' < " $GHE_RESTORE_SNAPSHOT_PATH /redis.rdb" 1>&3
216+ if $cluster ; then
217+ echo " Restoring GitHub Pages into DPages..."
218+ ghe-restore-pages-dpages " $GHE_HOSTNAME " 1>&3
219+ else
220+ echo " Restoring GitHub Pages ..."
221+ ghe-restore-pages-${GHE_BACKUP_STRATEGY} " $GHE_HOSTNAME " 1>&3
222+ fi
207223
208224echo " Restoring SSH authorized keys ..."
209225ghe-ssh " $GHE_HOSTNAME " -- ' ghe-import-authorized-keys' < " $GHE_RESTORE_SNAPSHOT_PATH /authorized-keys.json" 1>&3
210226
211- echo " Restoring Elasticsearch indices ..."
212- ghe-restore-es-${GHE_BACKUP_STRATEGY} " $GHE_HOSTNAME " 1>&3
227+ if $cluster ; then
228+ echo " Restoring storage data ..."
229+ ghe-restore-alambic-cluster " $GHE_HOSTNAME " 1>&3
230+ elif [ " $GHE_VERSION_MAJOR " -ge 2 ]; then
231+ echo " Restoring asset attachments ..."
232+ ghe-restore-userdata alambic_assets " $GHE_HOSTNAME " 1>&3
233+
234+ echo " Restoring storage data ..."
235+ ghe-restore-userdata storage " $GHE_HOSTNAME " 1>&3
236+
237+ echo " Restoring hook deliveries ..."
238+ ghe-restore-userdata hookshot " $GHE_HOSTNAME " 1>&3
239+ fi
240+
241+ if $cluster ; then
242+ echo " Restoring ElasticSearch Audit logs"
243+ ghe-restore-es-audit-log " $GHE_HOSTNAME " 1>&3
244+ else
245+ echo " Restoring Elasticsearch indices ..."
246+ ghe-restore-es-${GHE_BACKUP_STRATEGY} " $GHE_HOSTNAME " 1>&3
247+ fi
213248
214249# Restart an already running memcached to reset the cache after restore
215250if [ " $GHE_VERSION_MAJOR " -ge 2 ]; then
220255
221256# When restoring to a host that has already been configured, kick off a
222257# config run to perform data migrations.
223- if $instance_configured ; then
258+ if $cluster ; then
259+ echo " Configuring cluster ..."
260+ ghe-ssh " $GHE_HOSTNAME " -- " ghe-cluster-config-apply" 1>&3 2>&3
261+ elif $instance_configured ; then
224262 echo " Configuring storage ..."
225263 if [ " $GHE_VERSION_MAJOR " -ge 2 ]; then
226- ghe-ssh " $GHE_HOSTNAME " -- " sudo ghe-config-apply --full" 1>&3
264+ ghe-ssh " $GHE_HOSTNAME " -- " ghe-config-apply --full" 1>&3 2 >&3
227265 else
228266 echo " This will take several minutes to complete..."
229267 ghe-ssh " $GHE_HOSTNAME " -- " sudo enterprise-configure" 1>&3 2>&3
@@ -239,8 +277,13 @@ update_restore_status "complete"
239277# Log restore complete message in /var/log/syslog on remote instance
240278ghe_remote_logger " Completed restore from $( hostname) / snapshot ${GHE_SNAPSHOT_TIMESTAMP} ."
241279
242- echo " Restoring SSH host keys ..."
243- ghe-ssh " $GHE_HOSTNAME " -- ' ghe-import-ssh-host-keys' < " $GHE_RESTORE_SNAPSHOT_PATH /ssh-host-keys.tar" 1>&3
280+ if ! $cluster ; then
281+ echo " Restoring SSH host keys ..."
282+ ghe-ssh " $GHE_HOSTNAME " -- ' ghe-import-ssh-host-keys' < " $GHE_RESTORE_SNAPSHOT_PATH /ssh-host-keys.tar" 1>&3
283+ fi
244284
245285echo " Completed restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT "
246- echo " Visit https://$hostname /setup/settings to review appliance configuration."
286+
287+ if ! $cluster ; then
288+ echo " Visit https://$hostname /setup/settings to review appliance configuration."
289+ fi
0 commit comments