|
6 | 6 | #/ ghe-restore command when restoring into a cluster.
|
7 | 7 | set -e
|
8 | 8 |
|
| 9 | +sync_repo_info() { |
| 10 | + # node names changed in 2.8 and `ghe-cluster-each -u` isn't available |
| 11 | + # on GHE <= 2.7.X. We need to be backwards compatible. |
| 12 | + if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then |
| 13 | + for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do |
| 14 | + if ! ghe-rsync -av --delete \ |
| 15 | + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ |
| 16 | + --rsync-path="sudo -u git rsync" \ |
| 17 | + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ |
| 18 | + "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then |
| 19 | + echo "Error restoring /data/repositories/info to git-server-$uuid" 1>&2 |
| 20 | + fi |
| 21 | + done |
| 22 | + else |
| 23 | + for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do |
| 24 | + if ! ghe-rsync -av --delete \ |
| 25 | + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ |
| 26 | + --rsync-path="sudo -u git rsync" \ |
| 27 | + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ |
| 28 | + "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then |
| 29 | + echo "Error restoring /data/repositories/info to $route" 1>&2 |
| 30 | + fi |
| 31 | + done |
| 32 | + fi |
| 33 | +} |
| 34 | + |
9 | 35 | # Bring in the backup configuration
|
10 | 36 | . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config
|
11 | 37 |
|
@@ -46,7 +72,7 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki
|
46 | 72 | tmp_list=$tempdir/tmp_list
|
47 | 73 | to_restore=$tempdir/to_restore
|
48 | 74 |
|
49 |
| -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) |
| 75 | +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") |
50 | 76 | for hostname in $hostnames; do
|
51 | 77 | echo "
|
52 | 78 | Host $hostname
|
@@ -129,15 +155,7 @@ cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-
|
129 | 155 |
|
130 | 156 | if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then
|
131 | 157 | ghe_verbose "* Transferring repository info data"
|
132 |
| - for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do |
133 |
| - if ! ghe-rsync -av --delete \ |
134 |
| - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ |
135 |
| - --rsync-path="sudo -u git rsync" \ |
136 |
| - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ |
137 |
| - "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then |
138 |
| - echo "Error restoring /data/repositories/info to $route" |
139 |
| - fi |
140 |
| - done |
| 158 | + sync_repo_info |
141 | 159 | else
|
142 | 160 | ghe_verbose "* Removing repository info data"
|
143 | 161 | ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -- rm -f /data/repositories/info/*
|
|
0 commit comments