From 918970a40ab3af98b3ec72251d1c4769417cfb9e Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 14 Mar 2016 18:36:13 +0100 Subject: [PATCH 0001/2421] Batch restore gist repositories Speeds up Gist restores considerably. See https://github.com/github/enterprise2/issues/6930 --- .../ghe-restore-repositories-gist-batch | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 share/github-backup-utils/ghe-restore-repositories-gist-batch diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-batch b/share/github-backup-utils/ghe-restore-repositories-gist-batch new file mode 100755 index 000000000..1b60c44c9 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-repositories-gist-batch @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-repositories-gist +#/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when restoring into a cluster. +set -e + +# Bring in the backup configuration +cd $(dirname "$0")/../.. +. share/github-backup-utils/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +# Grab host arg +GHE_HOSTNAME="$1" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# Find the gists to restore +gist_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mindepth 6 -maxdepth 7 -name \*.git | grep gist | cut -d / -f2-) + +# No need to restore anything, early exit +if [ -z "$gist_paths" ]; then + echo "Warning: Gist backup missing. Skipping ..." + exit 0 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# Generate SSH config for forwarding + +config="" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) +for hostname in $hostnames; do + config="$config +Host $hostname + ServerAliveInterval 60 + ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" +done + +config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +echo "$config" > "$config_file" + +opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +tempdir=$(mktemp -d) + +cleanup() { + rm -rf $tempdir $config_file +} + +trap 'cleanup' INT TERM EXIT + +echo "$gist_paths" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-import-routes - \ + | while read g; do + server=$(echo $g | cut -d ',' -f1) + for r in $(echo $g | cut -d ',' -f2); do + echo $r >> $tempdir/$server.rsync + done +done + +for route in $tempdir/*.rsync; do + ghe-rsync -arHR --delete \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + --files-from=$route \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ + "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories" # & +done + +for gpath in $(cd $tempdir && cat *.rsync | sort | uniq); do + gid=$(basename $(echo $gpath | cut -d / -f6) .git) + shard="/data/repositories/$gpath" + routes=$(cd $tempdir && grep $gid *.rsync | cut -d : -f1 | sed 's/\.rsync//' | xargs echo -n) + echo "$gid $shard $routes" >> $tempdir/import +done + +cat $tempdir/import | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-import-finalize - From 12b0fba3c3831ef42f6a8c2f27ea9f974b3a5ca5 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 14 Mar 2016 20:09:39 +0100 Subject: [PATCH 0002/2421] Gist import fixes --- .../ghe-restore-repositories-gist-batch | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-batch b/share/github-backup-utils/ghe-restore-repositories-gist-batch index 1b60c44c9..f7f719589 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-batch +++ b/share/github-backup-utils/ghe-restore-repositories-gist-batch @@ -72,6 +72,7 @@ echo "$gist_paths" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' | ghe-ssh "$GHE_ done done +# rsync all the gist repositories for route in $tempdir/*.rsync; do ghe-rsync -arHR --delete \ -e "ssh -q $opts -p $port -F $config_file -l $user" \ @@ -81,11 +82,14 @@ for route in $tempdir/*.rsync; do "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories" # & done -for gpath in $(cd $tempdir && cat *.rsync | sort | uniq); do +# Add the imported gists to the database +( +cd $tempdir +for gpath in $(cat *.rsync | sort | uniq); do gid=$(basename $(echo $gpath | cut -d / -f6) .git) shard="/data/repositories/$gpath" - routes=$(cd $tempdir && grep $gid *.rsync | cut -d : -f1 | sed 's/\.rsync//' | xargs echo -n) + routes=$(grep "/$gid\.git" *.rsync | cut -d : -f1 | sed 's/\.rsync//' | xargs echo -n) echo "$gid $shard $routes" >> $tempdir/import done - -cat $tempdir/import | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-import-finalize - +) +cat $tempdir/import | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-import-finalize - >/dev/null From 71532db944c13f636dba903238e930cc71a221b6 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 14 Mar 2016 20:19:58 +0100 Subject: [PATCH 0003/2421] :lipstick: --- share/github-backup-utils/ghe-restore-repositories-gist-batch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-batch b/share/github-backup-utils/ghe-restore-repositories-gist-batch index f7f719589..beb52acdc 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-batch +++ b/share/github-backup-utils/ghe-restore-repositories-gist-batch @@ -64,6 +64,7 @@ cleanup() { trap 'cleanup' INT TERM EXIT +# Find the routes (servers) for each gist available locally echo "$gist_paths" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-import-routes - \ | while read g; do server=$(echo $g | cut -d ',' -f1) @@ -79,7 +80,7 @@ for route in $tempdir/*.rsync; do --rsync-path="sudo -u git rsync" \ --files-from=$route \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories" # & + "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories" done # Add the imported gists to the database From e9c26891ff3f7e20ca06a9f81f2bc846015d9077 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 14 Mar 2016 22:43:12 +0100 Subject: [PATCH 0004/2421] :lipstick: header docs --- share/github-backup-utils/ghe-restore-repositories-gist-batch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-batch b/share/github-backup-utils/ghe-restore-repositories-gist-batch index beb52acdc..787a6f477 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-batch +++ b/share/github-backup-utils/ghe-restore-repositories-gist-batch @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-repositories-gist +#/ Usage: ghe-restore-repositories-gist-batch #/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. #/ #/ Note: This script typically isn't called directly. It's invoked by the From af4299e033e8a7b0b4bb3d9fa95a270b3891af5d Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 21 Mar 2016 22:23:22 +0100 Subject: [PATCH 0005/2421] Speedup gist restores when using 2.5.3 --- bin/ghe-restore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 52b650138..d6b1b8d2d 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -203,7 +203,12 @@ if $cluster; then ghe-restore-repositories-dgit "$GHE_HOSTNAME" 1>&3 echo "Restoring Gists into cluster ..." - ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 + if echo "$GHE_VERSION_MAJOR.$GHE_VERSION_MINOR.$GHE_VERSION_PATCH" \ + | grep -Eq '2\.5\.([0-2])'; then + ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 + else + ghe-restore-repositories-gist-batch "$GHE_HOSTNAME" 1>&3 + fi else # Remove temporary 2.2 storage migration directory if it exists echo "if [ -d /data/user/repositories-nw-backup ]; then sudo rm -rf /data/user/repositories-nw-backup; fi" | From d0bc49a79991282342f623b0979fb5b49a1c49ec Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 21 Mar 2016 22:28:10 +0100 Subject: [PATCH 0006/2421] Warn if using the slow script to restore gists --- share/github-backup-utils/ghe-restore-repositories-gist | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index ea399e786..c1ffc2fd0 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -29,6 +29,7 @@ if [ -z "$gist_paths" ]; then exit 0 fi +echo "Warning: Upgrading to GitHub Enterprise 2.5.3 is recommended to speed up gist restores" # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" From 808b6b4cce36e8a2ee60496816d3a161f6ddc98c Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 21 Mar 2016 22:29:13 +0100 Subject: [PATCH 0007/2421] :lipstick: regex --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d6b1b8d2d..86a1d893f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -204,7 +204,7 @@ if $cluster; then echo "Restoring Gists into cluster ..." if echo "$GHE_VERSION_MAJOR.$GHE_VERSION_MINOR.$GHE_VERSION_PATCH" \ - | grep -Eq '2\.5\.([0-2])'; then + | grep -Eq '2\.5\.[0-2]'; then ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 else ghe-restore-repositories-gist-batch "$GHE_HOSTNAME" 1>&3 From 55c1e30f44611513cf4086bf992ac3c633b653eb Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Thu, 28 Apr 2016 15:58:38 +0200 Subject: [PATCH 0008/2421] [WiP] Speedup storage cluster restores Mostly an untested/unfinished skeleton right now. See https://github.com/github/enterprise2/issues/7356 --- .../ghe-restore-alambic-cluster-ng | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100755 share/github-backup-utils/ghe-restore-alambic-cluster-ng diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng new file mode 100755 index 000000000..029bbd433 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -0,0 +1,128 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-alambic-cluster-ng +#/ +#/ Restore storage objects from an rsync snapshot to a GitHub Cluster. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when restoring into a cluster. +set -e + +# Bring in the backup configuration +cd $(dirname "$0")/../.. +. share/github-backup-utils/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +# Grab host arg +GHE_HOSTNAME="$1" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# Find the objets to restore +storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindepth 4 -maxdepth 4 -type f -printf '%p %s\n' | cut -d / -f2-) + +# No need to restore anything, early exit +if [ -z "$storage_paths" ]; then + echo "Warning: Storage backup missing. Skipping ..." + exit 0 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +# Generate SSH config for forwarding +config="" +hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) +for hostname in $hostnames; do + config="$config +Host $hostname + ServerAliveInterval 60 + ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" +done + +config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +echo "$config" > "$config_file" + +# Stores compressed list of "oid size" tuples. +# We store it locally instead of piping it somewhere +# so we can debug and troubleshoot issues better. +tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) + +opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +tempdir=$(mktemp -d) + +cleanup() { + rm -rf $tempdir $config_file $tmp_list + true +} + +trap 'cleanup' EXIT + +# Find the routes (servers) for each storage object available locally +# Sends a list of " " tuples with the following format: +# +# # OID bytes +# b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b 5592001 +# b851fd1f147c644a9de778f19090ea785b415c69e2a2fba35a65144fa2753ab9 7340032 +# b65f657194ca6202c17b5062e4afc11843fc892a3f2febef8ac10971db7689a8 5591634 +# b63c30f6f885e59282c2aa22cfca846516b5e72621c10a58140fb04d133e2c17 5592492 +# ... +OLDIFS=$IFS; IFS=$'\n' +for path in $storage_paths; do + oid=$(echo $path | cut -d ' ' -f 1 | awk -F/ '{print $(NF)}') + size=$(echo $path | cut -d ' ' -f 2) + echo $oid $size +done | gzip > $tmp_list +IFS=$OLDIFS + +if [ -n "$GHE_VERBOSE" ]; then + echo "Sending the object list to the server..." 1>&3 + zcat $tmp_list +fi + +# The server receives the list of objects and returns the list servers where the objects will be sent. +# The format of the list returned by the sever: +# +# # hostname oid1 oid2 oid3 .... +# storage-server1 b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b b851fd1f147c644a9... +# storage-server2 b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b b851fd1f147c644a9... +# .. +# +# Should return one line per storage node in the cluster. +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-import-routes - \ + | while read obj; do + server=$(echo $obj | cut -d ',' -f1) + # builds the list of files to be sent rsync, one per storage server + for r in $(echo $obj | cut -d ',' -f2); do + oid_p1=$(echo $r | cut -c1) + oid_p2=$(echo $r | cut -c1-2) + oid_p3=$(echo $r | cut -c3-4) + # rebuild the original object path + echo "$oid_p1/$oid_p2/$oid_p3/$r" >> $tempdir/$server.rsync + done +done + +# rsync all the objects to the storage server where they belong. +# One rsync invocation per server available. +for route in $tempdir/*.rsync; do + ghe-rsync -arHR --delete \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + --files-from=$route \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ + "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/storage" +done + +# Add the imported objects to the database +# TODO? From ad635a3f0d66e4cf7c628076d6a61cbdf98dbe55 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 9 May 2016 02:17:23 -0700 Subject: [PATCH 0009/2421] Updated storage restores script To adapt it to the new scripts from https://github.com/github/github/pull/54646 --- .../ghe-restore-alambic-cluster-ng | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 029bbd433..21b8dca4d 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -54,9 +54,7 @@ done config_file=$(mktemp -t cluster-backup-restore-XXXXXX) echo "$config" > "$config_file" -# Stores compressed list of "oid size" tuples. -# We store it locally instead of piping it somewhere -# so we can debug and troubleshoot issues better. +# Stores a list of "oid size" tuples. tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -83,46 +81,42 @@ for path in $storage_paths; do oid=$(echo $path | cut -d ' ' -f 1 | awk -F/ '{print $(NF)}') size=$(echo $path | cut -d ' ' -f 2) echo $oid $size -done | gzip > $tmp_list +done > $tmp_list IFS=$OLDIFS if [ -n "$GHE_VERBOSE" ]; then - echo "Sending the object list to the server..." 1>&3 - zcat $tmp_list + echo "* Sending the object list to the server..." 1>&3 fi # The server receives the list of objects and returns the list servers where the objects will be sent. -# The format of the list returned by the sever: +# The format of the list returned by the server: # -# # hostname oid1 oid2 oid3 .... -# storage-server1 b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b b851fd1f147c644a9... -# storage-server2 b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b b851fd1f147c644a9... -# .. -# -# Should return one line per storage node in the cluster. -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-import-routes - \ +# # OID SERVER1 SERVER2 SERVER2 +# b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b server1 server2 server3 +# bc4cdd292e6b5387df2a42a907fcd5f3b6804a5d5ab427184faea5ef118d635e server1 server2 server3 +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-routes \ | while read obj; do - server=$(echo $obj | cut -d ',' -f1) - # builds the list of files to be sent rsync, one per storage server - for r in $(echo $obj | cut -d ',' -f2); do - oid_p1=$(echo $r | cut -c1) - oid_p2=$(echo $r | cut -c1-2) - oid_p3=$(echo $r | cut -c3-4) - # rebuild the original object path - echo "$oid_p1/$oid_p2/$oid_p3/$r" >> $tempdir/$server.rsync + echo "Received route: $obj" + oid=$(echo $obj | cut -d ' ' -f1) + oid_c1=$(echo $oid | cut -c1) + oid_c2=$(echo $oid | cut -c1-2) + oid_c3=$(echo $oid | cut -c3-4) + for server in $(echo $obj | cut -d ' ' -f2-); do + echo "* Adding $oid_c1/$oid_c2/$oid_c3/$oid to $tempdir/$server.rsync" 1>&3 + echo "$oid_c1/$oid_c2/$oid_c3/$oid" >> $tempdir/$server.rsync done done # rsync all the objects to the storage server where they belong. # One rsync invocation per server available. for route in $tempdir/*.rsync; do + echo "* rsync data to $(basename $route .rsync)..." 1>&3 ghe-rsync -arHR --delete \ -e "ssh -q $opts -p $port -F $config_file -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$route \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ - "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/storage" + "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/storage/" done -# Add the imported objects to the database -# TODO? +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-finalize From 246910664cdd9236baa75ad47dfd3b9e2b74391b Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 9 May 2016 11:34:30 +0200 Subject: [PATCH 0010/2421] Added ghe_verbose helper Write verbose messages to the verbose file descriptor. --- share/github-backup-utils/ghe-backup-config | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 386fbc894..40303833c 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -262,3 +262,11 @@ ghe_cluster_online_nodes () { role=$1 echo "ghe-config --get-regexp cluster.*.$role | egrep 'true$' | awk '{ print \$1; }' | awk 'BEGIN { FS=\".\" }; { print \$2 };' | xargs -I{} -n1 bash -c 'if [ \"\$(ghe-config cluster.\$hostname.offline)\" != true ]; then ghe-config cluster.{}.hostname; fi'" | ghe-ssh "$GHE_HOSTNAME" /bin/bash } + +# Usage: ghe_verbose +# Log if verbose mode is enabled (GHE_VERBOSE or `-v`). +ghe_verbose() { + if [ -n "$GHE_VERBOSE" ]; then + echo "$@" 1>&3 + fi +} From 0c5773390243157f9cdbd609a34fc18849eb9a93 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 9 May 2016 11:35:45 +0200 Subject: [PATCH 0011/2421] Use ghe_verbose in ghe-restore-alambic-cluster-ng --- .../ghe-restore-alambic-cluster-ng | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 21b8dca4d..c207e2392 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -84,9 +84,7 @@ for path in $storage_paths; do done > $tmp_list IFS=$OLDIFS -if [ -n "$GHE_VERBOSE" ]; then - echo "* Sending the object list to the server..." 1>&3 -fi +ghe_verbose "* Sending the object list to the server..." # The server receives the list of objects and returns the list servers where the objects will be sent. # The format of the list returned by the server: @@ -96,13 +94,13 @@ fi # bc4cdd292e6b5387df2a42a907fcd5f3b6804a5d5ab427184faea5ef118d635e server1 server2 server3 cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-routes \ | while read obj; do - echo "Received route: $obj" + ghe_verbose "Received route: $obj" oid=$(echo $obj | cut -d ' ' -f1) oid_c1=$(echo $oid | cut -c1) oid_c2=$(echo $oid | cut -c1-2) oid_c3=$(echo $oid | cut -c3-4) for server in $(echo $obj | cut -d ' ' -f2-); do - echo "* Adding $oid_c1/$oid_c2/$oid_c3/$oid to $tempdir/$server.rsync" 1>&3 + ghe_verbose "Adding $oid_c1/$oid_c2/$oid_c3/$oid to $tempdir/$server.rsync" echo "$oid_c1/$oid_c2/$oid_c3/$oid" >> $tempdir/$server.rsync done done @@ -110,7 +108,7 @@ done # rsync all the objects to the storage server where they belong. # One rsync invocation per server available. for route in $tempdir/*.rsync; do - echo "* rsync data to $(basename $route .rsync)..." 1>&3 + ghe_verbose "* rsync data to $(basename $route .rsync) ..." ghe-rsync -arHR --delete \ -e "ssh -q $opts -p $port -F $config_file -l $user" \ --rsync-path="sudo -u git rsync" \ @@ -119,4 +117,5 @@ for route in $tempdir/*.rsync; do "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/storage/" done +ghe_verbose "* Update storage database after the restore ..." cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-finalize From d5efaf8918c350ccb01cf81dc3d590052510d8a6 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 9 May 2016 03:17:35 -0700 Subject: [PATCH 0012/2421] Fix the list of objects to restore --- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index e6a99daaa..98cdac556 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -240,7 +240,7 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT if $cluster; then echo "Restoring storage data ..." - ghe-restore-alambic-cluster "$GHE_HOSTNAME" 1>&3 + ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then echo "Restoring asset attachments ..." diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index c207e2392..d640b07f4 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -56,12 +56,13 @@ echo "$config" > "$config_file" # Stores a list of "oid size" tuples. tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) +to_restore=$(mktemp -t cluster-backup-restore-XXXXXX) opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tempdir=$(mktemp -d) cleanup() { - rm -rf $tempdir $config_file $tmp_list + rm -rf $tempdir $config_file $tmp_list $to_restore true } @@ -103,6 +104,7 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore ghe_verbose "Adding $oid_c1/$oid_c2/$oid_c3/$oid to $tempdir/$server.rsync" echo "$oid_c1/$oid_c2/$oid_c3/$oid" >> $tempdir/$server.rsync done + echo "$obj" >> $to_restore done # rsync all the objects to the storage server where they belong. @@ -118,4 +120,4 @@ for route in $tempdir/*.rsync; do done ghe_verbose "* Update storage database after the restore ..." -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-finalize +cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-finalize From 3f05527979759fe9f16ee363a376f41876e1c640 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 17 May 2016 13:49:12 +0200 Subject: [PATCH 0013/2421] Use ghe-restore-alambic-cluster-ng when possible --- bin/ghe-restore | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 1361386c1..a877f85ae 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -239,7 +239,14 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT if $cluster; then echo "Restoring storage data ..." - ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 + if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/storage-cluster-restore-routes; then + echo "* Using ghe-restore-alambic-cluster-ng to restore" 1>&3 + # This restore script is faster but only available in + # GHE >= 2.6.3 + ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 + else + ghe-restore-alambic-cluster "$GHE_HOSTNAME" 1>&3 + fi ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then echo "Restoring asset attachments ..." From 8f7ef991e7a4df387bbc3518afa32b50d36aad0f Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 17 May 2016 15:57:54 +0200 Subject: [PATCH 0014/2421] Use the new ghe_verbose helper --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index a877f85ae..7b48497e9 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -240,7 +240,7 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT if $cluster; then echo "Restoring storage data ..." if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/storage-cluster-restore-routes; then - echo "* Using ghe-restore-alambic-cluster-ng to restore" 1>&3 + ghe_verbose "* Using ghe-restore-alambic-cluster-ng to restore" # This restore script is faster but only available in # GHE >= 2.6.3 ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 From c93ba018308ea3263047d2459bb25da42cf75390 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 16 May 2016 11:27:53 +1000 Subject: [PATCH 0015/2421] Document hard link requirement --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c1f119954..e8df1ceb6 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,8 @@ Backup host software requirements are modest: Linux or other modern Unix operating system with bash and [rsync][4] v2.6.4 or newer. The backup host must be able to establish network connections outbound to the -GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise 2.0 or newer instances, and TCP port 22 is used for older versions (11.10.34X). +GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise 2.0 +or newer instances, and TCP port 22 is used for older versions (11.10.34X). ##### Storage requirements @@ -57,6 +58,9 @@ patterns of the GitHub appliance. We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time. +As Repository, Search, and Pages data is stored efficiently via hard links, +backup snapshots must be written to a filesystem which supports hard links. + ##### GitHub Enterprise version requirements The backup utilities are fully supported under GitHub Enterprise 2.0 or From f2dd101fd048d79004f1505406b4c7fa28ecfc0c Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 16 May 2016 17:23:11 +1000 Subject: [PATCH 0016/2421] Support for systems lacking readlink -m --- share/github-backup-utils/ghe-backup-config | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index a7483bf3a..109ec1dd3 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -74,9 +74,12 @@ if [ -z "$GHE_HOSTNAME" ]; then exit 2 fi -# Canonicalize the data directory path, basing any relative paths on the -# backup-utils root. -GHE_DATA_DIR="$( cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR" )" +# Convert the data directory path to an absolute path, basing any relative +# paths on the backup-utils root, and using readlink, if available, to +# canonicalize the path. +if [ ${GHE_DATA_DIR:0:1} != "/" ]; then + GHE_DATA_DIR="$( cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR" 2> /dev/null || echo "$GHE_BACKUP_ROOT/$GHE_DATA_DIR" )" +fi GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} From fb470f4cbb442bfb416ca495190dbeeff3cbccb4 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 17 May 2016 10:36:22 +1000 Subject: [PATCH 0017/2421] Tweak wording --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8df1ceb6..6893d75b9 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ patterns of the GitHub appliance. We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time. -As Repository, Search, and Pages data is stored efficiently via hard links, -backup snapshots must be written to a filesystem which supports hard links. +The backup utilities use [hard links][12] to store data efficiently, so the backup +snapshots must be written to a filesystem with support for hard links. ##### GitHub Enterprise version requirements @@ -281,3 +281,4 @@ site setup or recovery, please contact our [Enterprise support team][7] instead. [9]: https://enterprise.github.com/help/articles/restoring-enterprise-data [10]: https://help.github.com/enterprise/2.0/admin-guide/migrating-to-a-different-platform-or-from-github-enterprise-11-10-34x/ [11]: https://help.github.com/enterprise/2.0/admin-guide/ +[12]: https://en.wikipedia.org/wiki/Hard_link From 1ce587ea073e38018347338600bbb9e227ab6659 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 17 May 2016 15:13:23 +1000 Subject: [PATCH 0018/2421] Travis refactor with osx --- .travis.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7d1d4ca2..adc20bd4c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,13 @@ --- -script: - - debuild -uc -us -before_install: - - sudo apt-get update -qq - - sudo apt-get install -y devscripts +matrix: + include: + - os: osx + before_install: + - brew update + - brew install gnu-tar + script: make test + - os: linux + addons: + apt: + packages: devscripts + script: debuild -uc -us From 7b963630f4b0a34a9614a7560b2d937291e38db9 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 17 May 2016 15:33:54 +1000 Subject: [PATCH 0019/2421] Tweak fsck mktemp for osx --- share/github-backup-utils/ghe-backup-fsck | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-fsck b/share/github-backup-utils/ghe-backup-fsck index cc4c67567..19fd68e55 100755 --- a/share/github-backup-utils/ghe-backup-fsck +++ b/share/github-backup-utils/ghe-backup-fsck @@ -18,7 +18,7 @@ fi sdir=$1 repos=0 errors=0 -log=$(mktemp) +log=$(mktemp -t ghe-backup-fsck-XXXXXX) t_start=$(date +%s) if git fsck -h | grep -q '\-\-dangling'; then git_cmd='git fsck --no-dangling' From f3eab1b8c65c91a8e50d7ccd6f2a0276105cfa0c Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 18 May 2016 17:38:51 +0200 Subject: [PATCH 0020/2421] Added echo removed by the last merge conflict --- bin/ghe-restore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7b48497e9..5dcac04d7 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -247,6 +247,7 @@ if $cluster; then else ghe-restore-alambic-cluster "$GHE_HOSTNAME" 1>&3 fi + echo "Restoring custom Git hooks ..." ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then echo "Restoring asset attachments ..." From 12a98bb6c038ba7d314d882435c6b359d2480bc2 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 23 May 2016 19:30:34 +0200 Subject: [PATCH 0021/2421] [WiP] adapt the gist restore script to the new protocol --- .../ghe-restore-repositories-gist-batch | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-batch b/share/github-backup-utils/ghe-restore-repositories-gist-batch index 787a6f477..08cb851a3 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-batch +++ b/share/github-backup-utils/ghe-restore-repositories-gist-batch @@ -57,20 +57,30 @@ echo "$config" > "$config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tempdir=$(mktemp -d) +tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) +to_restore=$(mktemp -t cluster-backup-restore-XXXXXX) cleanup() { rm -rf $tempdir $config_file } -trap 'cleanup' INT TERM EXIT +trap 'cleanup' EXIT # Find the routes (servers) for each gist available locally -echo "$gist_paths" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-import-routes - \ - | while read g; do - server=$(echo $g | cut -d ',' -f1) - for r in $(echo $g | cut -d ',' -f2); do - echo $r >> $tempdir/$server.rsync - done +OLDIFS=$IFS; IFS=$'\n' +for path in "$gist_paths"; do + echo $path | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' +done > $tmp_list +IFS=$OLDIFS + +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-routes \ + | while read route; do + for server in $(echo $route | cut -d ' ' -f2-); do + gist=$(echo $route | cut -d ' ' -f1) + ghe_verbose "Adding $route to $tempdir/$server.rsync" + echo "$gist" >> $tempdir/$server.rsync + done + echo "$route" >> $to_restore done # rsync all the gist repositories @@ -83,14 +93,4 @@ for route in $tempdir/*.rsync; do "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories" done -# Add the imported gists to the database -( -cd $tempdir -for gpath in $(cat *.rsync | sort | uniq); do - gid=$(basename $(echo $gpath | cut -d / -f6) .git) - shard="/data/repositories/$gpath" - routes=$(grep "/$gid\.git" *.rsync | cut -d : -f1 | sed 's/\.rsync//' | xargs echo -n) - echo "$gid $shard $routes" >> $tempdir/import -done -) -cat $tempdir/import | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-import-finalize - >/dev/null +cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-finalize From 87d41842e066ccae4ebe761f96d6eef2c73b2b76 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 23 May 2016 19:37:24 +0200 Subject: [PATCH 0022/2421] Renamed the script to be consistent --- ...e-repositories-gist-batch => ghe-restore-repositories-gist-ng} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename share/github-backup-utils/{ghe-restore-repositories-gist-batch => ghe-restore-repositories-gist-ng} (100%) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-batch b/share/github-backup-utils/ghe-restore-repositories-gist-ng similarity index 100% rename from share/github-backup-utils/ghe-restore-repositories-gist-batch rename to share/github-backup-utils/ghe-restore-repositories-gist-ng From 02dbe862f69049356317c84218202ef3246833d3 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 24 May 2016 13:44:27 +0200 Subject: [PATCH 0023/2421] Detect if ghe-restore-repositories-gist-ng can be used --- bin/ghe-restore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 6510f3a9c..e8647beeb 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -216,11 +216,11 @@ if $cluster; then ghe-restore-repositories-dgit "$GHE_HOSTNAME" 1>&3 echo "Restoring Gists into cluster ..." - if echo "$GHE_VERSION_MAJOR.$GHE_VERSION_MINOR.$GHE_VERSION_PATCH" \ - | grep -Eq '2\.5\.[0-2]'; then - ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 + if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/gist-cluster-restore-routes; then + ghe_verbose "* Using ghe-restore-repositories-gist-ng to restore" + ghe-restore-repositories-gist-ng "$GHE_HOSTNAME" 1>&3 else - ghe-restore-repositories-gist-batch "$GHE_HOSTNAME" 1>&3 + ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 fi else # Remove temporary 2.2 storage migration directory if it exists From f4b938d0470ad924ae592d3414a55275f2ca0f07 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 24 May 2016 19:43:39 +0200 Subject: [PATCH 0024/2421] ghe-restore-repositories-gist-ng fixes --- .../ghe-restore-repositories-gist-ng | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 08cb851a3..64e1b2fc7 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -33,9 +33,6 @@ fi ghe_remote_version_required "$GHE_HOSTNAME" # Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -44,53 +41,55 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" +tempdir=$(mktemp -d) +ssh_config_file=$tempdir/ssh_config +opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +tmp_list=$tempdir/tmp_list +to_restore=$tempdir/to_restore + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) for hostname in $hostnames; do - config="$config + echo " Host $hostname ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" + ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" >> $ssh_config_file done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" -tempdir=$(mktemp -d) -tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) -to_restore=$(mktemp -t cluster-backup-restore-XXXXXX) - cleanup() { - rm -rf $tempdir $config_file + rm -rf $tempdir } -trap 'cleanup' EXIT +#trap cleanup EXIT # Find the routes (servers) for each gist available locally OLDIFS=$IFS; IFS=$'\n' -for path in "$gist_paths"; do - echo $path | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g' +for path in $gist_paths; do + echo $path done > $tmp_list IFS=$OLDIFS cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-routes \ | while read route; do - for server in $(echo $route | cut -d ' ' -f2-); do + servers=$(echo $route | cut -d ' ' -f2-) + for server in $servers; do gist=$(echo $route | cut -d ' ' -f1) - ghe_verbose "Adding $route to $tempdir/$server.rsync" + ghe_verbose "Adding $gist to $tempdir/$server.rsync" echo "$gist" >> $tempdir/$server.rsync done - echo "$route" >> $to_restore + + gist_id=$(basename $(echo $route | cut -d ' ' -f 1) .git) + ghe_verbose "Route: $gist_id /data/repositories/$gist $servers" + echo "$gist_id /data/repositories/$gist $servers" >> $to_restore done # rsync all the gist repositories for route in $tempdir/*.rsync; do ghe-rsync -arHR --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$route \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories" + "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories/" done cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-finalize From e49efe2dcadf044f80dd0336a9514a5f8eced1b0 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 25 May 2016 19:24:34 +0200 Subject: [PATCH 0025/2421] Fix the way we source ghe-backup-config --- share/github-backup-utils/ghe-restore-repositories-gist-ng | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 64e1b2fc7..00a9d2c01 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -7,8 +7,7 @@ set -e # Bring in the backup configuration -cd $(dirname "$0")/../.. -. share/github-backup-utils/ghe-backup-config +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config # Show usage and bail with no arguments [ -z "$*" ] && print_usage From 018b4a606d0c50a106f67b2d5747a6dcf600a2bd Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 25 May 2016 21:32:07 +0200 Subject: [PATCH 0026/2421] Remove the warning for now --- share/github-backup-utils/ghe-restore-repositories-gist | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 1d7e255b2..84d59a569 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -28,7 +28,6 @@ if [ -z "$gist_paths" ]; then exit 0 fi -echo "Warning: Upgrading to GitHub Enterprise 2.5.3 is recommended to speed up gist restores" # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" From 102bb2705dcaa36c4e038ed3c963697f5e18e9eb Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 25 May 2016 21:38:42 +0200 Subject: [PATCH 0027/2421] The trap is required --- share/github-backup-utils/ghe-restore-repositories-gist-ng | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 00a9d2c01..ca32a2423 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -57,8 +57,7 @@ done cleanup() { rm -rf $tempdir } - -#trap cleanup EXIT +trap cleanup EXIT # Find the routes (servers) for each gist available locally OLDIFS=$IFS; IFS=$'\n' From 813e4e769c353cf4a5dcc55eda60da08fa7b2e72 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 30 May 2016 14:25:59 +0200 Subject: [PATCH 0028/2421] :lipstick: comment --- share/github-backup-utils/ghe-restore-repositories-gist-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index ca32a2423..1a1a5f356 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-repositories-gist-batch +#/ Usage: ghe-restore-repositories-gist-ng #/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. #/ #/ Note: This script typically isn't called directly. It's invoked by the From 7432a909da359177941f46e97e9e96d55cd0037e Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 20 Jun 2016 21:09:31 +0200 Subject: [PATCH 0029/2421] Speedup repo restores (cluster) (#46) * Speedup cluster repo restores New script that should speed things up * Use the new script when possible * Make the script executable * StrictHostKeyChecking=no for cluster nodes * Fix server to rsync * Transfer repository info * Fixes rsyncing repositores/info * Revert "Fixes rsyncing repositores/info" This reverts commit 9c8232a0afc176a17c0dee2bdbbb143637964415. * Fix the right script * Verbose rsync * Benchmark ghe-restore-repositories-dgit-ng * All's fine, we need to rsync this --- bin/ghe-restore | 7 +- .../ghe-restore-repositories-dgit-ng | 146 ++++++++++++++++++ 2 files changed, 152 insertions(+), 1 deletion(-) create mode 100755 share/github-backup-utils/ghe-restore-repositories-dgit-ng diff --git a/bin/ghe-restore b/bin/ghe-restore index 0185c2d1e..5dc34b736 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -217,7 +217,12 @@ bm_end "ghe-import-redis" if $cluster; then echo "Restoring Git repositories into cluster ..." - ghe-restore-repositories-dgit "$GHE_HOSTNAME" 1>&3 + if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/dgit-cluster-restore-routes; then + ghe_verbose "* Using ghe-restore-repositories-dgit-ng to restore" + ghe-restore-repositories-dgit-ng "$GHE_HOSTNAME" 1>&3 + else + ghe-restore-repositories-dgit "$GHE_HOSTNAME" 1>&3 + fi echo "Restoring Gists into cluster ..." if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/gist-cluster-restore-routes; then diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng new file mode 100755 index 000000000..651f3e63a --- /dev/null +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -0,0 +1,146 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-repositories-dgit-ng +#/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when restoring into a cluster. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +network_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mindepth 6 -maxdepth 7 -name \*.git -exec dirname {} \; | uniq | grep nw | cut -d / -f2-) + +if [ -z "$network_paths" ]; then + echo "Warning: Repositories backup missing. Skipping ..." + exit 0 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# Generate SSH config for forwarding +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +tempdir=$(mktemp -d) +ssh_config_file=$tempdir/ssh_config +opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +tmp_list=$tempdir/tmp_list +to_restore=$tempdir/to_restore + +hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) +for hostname in $hostnames; do + echo " +Host $hostname + ServerAliveInterval 60 + ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p + StrictHostKeyChecking=no" >> $ssh_config_file +done + +cleanup() { + for hostname in $hostnames; do + ghe-gc-enable -F $ssh_config_file $hostname:$port + done + rm -rf $tempdir +} +trap cleanup EXIT + +# Disable remote GC operations +for hostname in $hostnames; do + ghe-gc-disable -F $ssh_config_file $hostname:$port +done + +# Build a list of network paths to send to the server to calculate +# the restore routes, something like: +# +# a/nw/a8/3f/02/100000855 +# a/nw/a8/bc/8d/100000880 +# a/nw/a5/06/81/100000659 +# a/nw/a5/84/6f/100000708 +# a/nw/a5/e0/01/146 +# ... +# +# One network path per line. +OLDIFS=$IFS; IFS=$'\n' +for path in $network_paths; do + # Get the network ID + # The nework id from a repository is the last component of the path + # i.e. /data/repositories/a/nw/a5/bf/c9/37 network ID would be 37 + ghe_verbose "Adding network_path $path to the list of networks to send" + echo $path +done > $tmp_list +IFS=$OLDIFS + +# The server returns a list of routes: +# +# a/nw/a8/3f/02/100000855 dgit-node1 dgit-node2 dgit-node3 +# a/nw/a8/bc/8d/100000880 dgit-node1 dgit-node2 dgit-node4 +# a/nw/a5/06/81/100000659 dgit-node3 dgit-node2 dgit-node4 +# ... +# +# One route per line. +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-routes \ + | while read route; do + ghe_verbose "Received route $route" + servers=$(echo $route | cut -d ' ' -f2-) + for server in $servers; do + network_path=$(echo $route | cut -d ' ' -f1) + ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync + done + + network_id=$(echo $network_path | awk -F/ '{print $(NF)}') + ghe_verbose "Route: $network_id /data/repositories/$network_path $servers" + echo "$network_id /data/repositories/$network_path $servers" >> $to_restore +done + +# rsync all the repositories +for file_list in $tempdir/*.rsync; do + server=$(basename $file_list .rsync) + ghe_verbose "* Transferring repositories to $server" + ghe-rsync -avrHR --delete \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + --files-from=$file_list \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ + "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 +done + +# Tell dgit about the repositories restored +cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-finalize >&3 + +if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then + ghe_verbose "* Transferring repository info data" + for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do + if ! ghe-rsync -av --delete \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ + "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to $route" + fi + done +else + ghe_verbose "* Removing repository info data" + ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -- rm -f /data/repositories/info/* +fi + +bm_end "$(basename $0)" From ed4030c296bbe1119139b082d1812634f5efbd86 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 21 Jun 2016 00:57:39 +0200 Subject: [PATCH 0030/2421] Clusters: Restore Git over SSH host keys Restores Git over SSH (babeld) keys and distribute them to all the nodes in the cluster. Initially fixed by https://github.com/github/backup-utils/pull/228 and later reverted in https://github.com/github/backup-utils/pull/229, this new patch prevents the SSH host keys to be replaced, breaking `ghe-restore` in the process (new SSH connections after the host key restore will fail). Fixes https://github.com/github/backup-utils/226 --- bin/ghe-restore | 7 +++++ test/test-ghe-restore.sh | 58 ---------------------------------------- 2 files changed, 7 insertions(+), 58 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 5dc34b736..3ae96728d 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -319,6 +319,13 @@ ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_S if ! $cluster; then echo "Restoring SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 +else + # This will make sure that Git over SSH host keys (babeld) are + # copied to all the cluster nodes so babeld uses the same keys. + echo "Restoring Git over SSH host keys ..." + ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C /data/user/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld /data/user/common/ssh_host_*" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-cluster-config-update -s" 1>&3 fi echo "Completed restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index f91d515e2..7a765526c 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -466,61 +466,3 @@ begin_test "ghe-restore with tarball strategy" echo "$output" | grep -q 'fake ghe-export-repositories data' ) end_test - -begin_test "cluster: ghe-restore from v2.4.0 snapshot" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_cluster || exit 0 - setup_remote_metadata - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - echo "v2.4.0" > "$GHE_DATA_DIR/current/version" - - # run ghe-restore and write output to file for asserting against - if ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited non-zero - false - fi - - # verify restore error message - grep -q "Error: Snapshot must be from" "$TRASHDIR/restore-out" -) -end_test - -begin_test "cluster: ghe-restore from v2.5.0 snapshot" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_cluster || exit 0 - setup_remote_metadata - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" "$GHE_REMOTE_DATA_USER_DIR/common" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - echo "v2.5.0" > "$GHE_DATA_DIR/current/version" - - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - # verify that ghe-backup wrote its version information to the host - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] -) -end_test From d34ba25fb1ac28cc9b38445f66b419015072480a Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Tue, 21 Jun 2016 15:21:26 +0200 Subject: [PATCH 0031/2421] Improve backup of git-hooks (#45) This is the first step to exclude the extracted environments from the backup. This way they can be reextracted on restore. --- bin/ghe-backup | 6 +- bin/ghe-restore | 4 +- .../ghe-backup-git-hooks-cluster | 48 ++++++++++----- share/github-backup-utils/ghe-backup-userdata | 23 +++++++- .../ghe-restore-alambic-cluster-ng | 6 +- .../ghe-restore-git-hooks-cluster | 24 +++++++- .../ghe-restore-git-hooks-extract | 35 +++++++++++ .../github-backup-utils/ghe-restore-userdata | 2 +- test/bin/ghe-hook-env-update | 12 ++++ test/test-ghe-backup.sh | 59 ++++++++++++++----- test/test-ghe-restore.sh | 44 ++++++++++---- 11 files changed, 208 insertions(+), 55 deletions(-) create mode 100755 share/github-backup-utils/ghe-restore-git-hooks-extract create mode 100755 test/bin/ghe-hook-env-update diff --git a/bin/ghe-backup b/bin/ghe-backup index 71751e738..bc94c45bb 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -190,8 +190,10 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then failures="$failures hookshot" echo "Backing up custom Git hooks ..." - ghe-backup-userdata git-hooks || - failures="$failures git-hooks" + ghe-backup-userdata git-hooks/environments/tarballs || + failures="$failures git-hooks-environments" + ghe-backup-userdata git-hooks/repos || + failures="$failures git-hooks-repos" fi fi diff --git a/bin/ghe-restore b/bin/ghe-restore index 3ae96728d..ac465916a 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -274,7 +274,9 @@ elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then ghe-restore-userdata hookshot "$GHE_HOSTNAME" 1>&3 echo "Restoring custom Git hooks ..." - ghe-restore-userdata git-hooks "$GHE_HOSTNAME" 1>&3 + ghe-restore-userdata git-hooks/environments/tarballs "$GHE_HOSTNAME" 1>&3 + ghe-restore-userdata git-hooks/repos "$GHE_HOSTNAME" 1>&3 + ghe-restore-git-hooks-extract "$GHE_HOSTNAME" 1>&3 fi if $cluster; then diff --git a/share/github-backup-utils/ghe-backup-git-hooks-cluster b/share/github-backup-utils/ghe-backup-git-hooks-cluster index f8a657a9b..1cd0c243a 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks-cluster +++ b/share/github-backup-utils/ghe-backup-git-hooks-cluster @@ -58,12 +58,6 @@ cleanup() { trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate -# If we have a previous increment, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$backup_current" ]; then - link_dest="--link-dest=../../current/git-hooks" -fi - # Transfer Git hooks data from a GitHub instance to the current snapshot # directory, using a previous snapshot to avoid transferring files that have # already been transferred. A set of rsync filter rules are provided on stdin @@ -72,16 +66,42 @@ rsync_git_hooks_data () { port=$(ssh_port_part "$1") host=$(ssh_host_part "$1") - shift + subpath=$2 + shift 2 + + # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's + # --link-dest support. This also decreases physical space usage considerably. + if [ -d "$backup_current/$subpath" ] && [ "$(ls -A $backup_current/$subpath)" ]; then + + subdir="git-hooks/$subpath" + link_path=".." + while true; do + if [ $(dirname $subdir) = "." ]; then + break + fi + + if [ $(dirname $subdir) = "/" ]; then + break + fi + + link_path="../$link_path" + subdir=$(dirname $subdir) + done + + local link_dest="--link-dest=../${link_path}/current/git-hooks/$subpath" + fi + + # Ensure target directory exists, is needed with subdirectories + mkdir -p "$backup_dir/$subpath" + ghe-rsync -a \ -e "ssh -q $opts -p $port -F $config_file -l $user" $link_dest \ --rsync-path='sudo -u git rsync' \ - "$host:$GHE_REMOTE_DATA_USER_DIR/git-hooks/" \ - "$backup_dir" 1>&3 + "$host:$GHE_REMOTE_DATA_USER_DIR/git-hooks/$subpath/" \ + "$backup_dir/$subpath" 1>&3 } -for hostname in $hostnames; do - ghe-ssh -F $config_file "$hostname:122" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks' ]" || exit 0 - # We can stop after the first successful sync since hooks are the same everywhere - rsync_git_hooks_data $hostname:122 && break -done +hostname=$(echo $hostnames | awk '{ print $1; }') +ghe-ssh -F $config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks' ]" || exit 0 +rsync_git_hooks_data $hostname:122 environments/tarballs +rsync_git_hooks_data $hostname:122 repos diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata index 95390dbae..5cb68f8eb 100755 --- a/share/github-backup-utils/ghe-backup-userdata +++ b/share/github-backup-utils/ghe-backup-userdata @@ -23,14 +23,33 @@ ghe_remote_version_required "$host" # Verify that the user data directory exists. Bail out if not, which may be due # to an older version of GHE or no data has been added to this directory yet. -ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0 +ghe-ssh "$host" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0 # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$GHE_DATA_DIR/current/$dirname" ] && [ "$(ls -A $GHE_DATA_DIR/current/$dirname)" ]; then - link_dest="--link-dest=../../current/$dirname" + + subdir=$dirname + link_path=".." + while true; do + if [ $(dirname $subdir) = "." ]; then + break + fi + + if [ $(dirname $subdir) = "/" ]; then + break + fi + + link_path="../$link_path" + subdir=$(dirname $subdir) + done + + link_dest="--link-dest=../${link_path}/current/$dirname" fi +# Ensure target directory exists, is needed with subdirectories +mkdir -p "$GHE_SNAPSHOT_DIR/$dirname" + # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 9c1c87df4..675167cb9 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -23,7 +23,7 @@ GHE_HOSTNAME="$1" : ${GHE_RESTORE_SNAPSHOT:=current} # Find the objets to restore -storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindepth 4 -maxdepth 4 -type f -printf '%p %s\n' | cut -d / -f2-) +storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindepth 4 -maxdepth 4 -type f -exec wc -c {} \;) # No need to restore anything, early exit if [ -z "$storage_paths" ]; then @@ -80,8 +80,8 @@ trap 'cleanup' EXIT # ... OLDIFS=$IFS; IFS=$'\n' for path in $storage_paths; do - oid=$(echo $path | cut -d ' ' -f 1 | awk -F/ '{print $(NF)}') - size=$(echo $path | cut -d ' ' -f 2) + oid=$(echo $path | awk -F/ '{print $(NF)}') + size=$(echo $path | awk '{print $1}') echo $oid $size done > $tmp_list IFS=$OLDIFS diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index 50cffed8f..6dd1a7ee8 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -58,13 +58,31 @@ cleanup() { } trap 'cleanup' INT TERM EXIT -if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks" ]; then +if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; then + tarballs=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs && find . -type f) + hostname=$(echo $hostnames | awk '{ print $1; }') + + if [ -n "$hostname" ]; then + ghe-rsync -aH --delete \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs/" \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + + for tarball in $tarballs; do + env_id=$(echo $tarball | cut -d '/' -f 2) + ssh -q $opts -p $port -F $config_file -l $user $hostname "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" + done + fi +fi + +if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos" ]; then for hostname in $hostnames; do ghe-rsync -aH --delete \ -e "ssh -q $opts -p $port -F $config_file -l $user" \ --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/" & + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos/" \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" & done for pid in $(jobs -p); do diff --git a/share/github-backup-utils/ghe-restore-git-hooks-extract b/share/github-backup-utils/ghe-restore-git-hooks-extract new file mode 100755 index 000000000..9b19f23a6 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-git-hooks-extract @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-git-hooks-extract +#/ Restore custom Git hooks environments from tarballs +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-restore +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +if [ ! -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs ]; then + echo "Warning: No pre-receive hook environments. Skipping ..." + exit 0 +fi + +tarballs=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs && find . -type f) + +for tarball in $tarballs; do + env_id=$(echo $tarball | cut -d '/' -f 2) + ghe-ssh "$GHE_HOSTNAME" "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" +done diff --git a/share/github-backup-utils/ghe-restore-userdata b/share/github-backup-utils/ghe-restore-userdata index a544b75c3..abf1a6943 100755 --- a/share/github-backup-utils/ghe-restore-userdata +++ b/share/github-backup-utils/ghe-restore-userdata @@ -35,7 +35,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname" ]; then ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u git rsync" \ + --rsync-path="sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname && sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/$dirname" 1>&3 fi diff --git a/test/bin/ghe-hook-env-update b/test/bin/ghe-hook-env-update new file mode 100755 index 000000000..77bcd3580 --- /dev/null +++ b/test/bin/ghe-hook-env-update @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# Emulates a remote GitHub import command. Each of the ghe-import-* utilities +# that are run on the remote side have corresponding commands in this directory +# that symlink to this file. The command just gobbles up stdin and writes a +# simple success message. +env_id=$1 +tarball=$2 + +path=$(dirname $tarball)/../../ +mkdir -p $path/$1 +cd $path/$i +tar -zxf $tarball diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 2b7335cf6..1464cb1af 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -17,21 +17,30 @@ touch alice/index.html bob/index.html mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" echo "fake password hash data" > "$GHE_REMOTE_DATA_USER_DIR/common/manage-password" -# Create some fake hookshot data in the remote data directory if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + # Create some fake data in the remote data directory mkdir -p "$GHE_REMOTE_DATA_USER_DIR/hookshot" cd "$GHE_REMOTE_DATA_USER_DIR/hookshot" mkdir -p repository-123 repository-456 touch repository-123/test.bpack repository-456/test.bpack - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks" - cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks" - mkdir -p repository-123 repository-456 - touch repository-123/script.sh repository-456/foo.sh -fi + # Create some fake hooks in the remote data directory + mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" -# Create some fake alambic data in the remote data directory -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + mkdir -p 123/abcdef 456/fed314 + touch 123/abcdef/script.sh 456/fed314/foo.sh + + cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + mkdir -p 123/abcdef 456/fed314 + touch 123/abcdef/script.tar.gz 456/fed314/foo.tar.gz + + cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" + mkdir -p 321 654 + touch 321/script.sh 654/foo.sh + + # Create some fake alambic data in the remote data directory mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-assets/0000" touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-assets/0000/test.png" @@ -127,8 +136,14 @@ begin_test "ghe-backup first snapshot" # verify all hookshot user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" - # verify all git hooks data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks" "$GHE_DATA_DIR/current/git-hooks" + # verify all git hooks tarballs were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" + + # verify the extracted environments were not transferred + ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" + + # verify the extracted repositories were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" # verify all alambic assets user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" @@ -204,8 +219,14 @@ begin_test "ghe-backup subsequent snapshot" # verify all hookshot user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" - # verify all git hooks data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks" "$GHE_DATA_DIR/current/git-hooks" + # verify all git hooks tarballs were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" + + # verify the extracted environments were not transferred + ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" + + # verify the extracted repositories were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" # verify all alambic assets user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" @@ -282,8 +303,14 @@ begin_test "ghe-backup with relative data dir path" # verify all hookshot user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" - # verify all git hooks data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks" "$GHE_DATA_DIR/current/git-hooks" + # verify all git hooks tarballs were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" + + # verify the extracted environments were not transferred + ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" + + # verify the extracted repositories were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" # verify all alambic assets user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" @@ -375,8 +402,8 @@ begin_test "ghe-backup empty git-hooks directory" ( set -e - rm -rf $GHE_REMOTE_DATA_USER_DIR/git-hooks/repository-* - rm -rf $GHE_DATA_DIR/current/git-hooks/repository-* + rm -rf $GHE_REMOTE_DATA_USER_DIR/git-hooks/* + rm -rf $GHE_DATA_DIR/current/git-hooks/* ghe-backup # Check that the "--link-dest arg does not exist" message hasn't occurred. diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 7a765526c..a13f471c3 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -26,14 +26,25 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then mkdir -p repository-123 repository-456 touch repository-123/test.bpack repository-456/test.bpack - mkdir -p "$GHE_DATA_DIR/1/git-hooks" - cd "$GHE_DATA_DIR/1/git-hooks" - mkdir -p repository-123 repository-456 - touch repository-123/script.sh repository-456/foo.sh -fi - -# Create some fake alambic data in the remote data directory -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + # Create some fake environments + mkdir -p "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" + cd "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" + mkdir -p 123 456 + touch 123/script.sh 456/foo.sh + cd 123 + tar -czf script.tar.gz script.sh + cd ../456 + tar -czf foo.tar.gz foo.sh + cd .. + rm 123/script.sh 456/foo.sh + mkdir -p "$GHE_DATA_DIR/1/git-hooks/repos/1" + touch "$GHE_DATA_DIR/1/git-hooks/repos/1/bar.sh" + + cd "$GHE_DATA_DIR/1/git-hooks/environments" + mkdir -p 123 456 + touch 123/script.sh 456/foo.sh + + # Create some fake alambic data in the remote data directory mkdir -p "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-assets/0000" touch "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-assets/0000/test.png" @@ -128,7 +139,9 @@ begin_test "ghe-restore into configured vm" diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks" "$GHE_REMOTE_DATA_USER_DIR/git-hooks" + diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" @@ -260,7 +273,9 @@ begin_test "ghe-restore -c into unconfigured vm" diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks" "$GHE_REMOTE_DATA_USER_DIR/git-hooks" + diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" @@ -322,7 +337,9 @@ begin_test "ghe-restore into unconfigured vm" diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks" "$GHE_REMOTE_DATA_USER_DIR/git-hooks" + diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" @@ -373,8 +390,9 @@ begin_test "ghe-restore with host arg" # verify all hookshot user data was transferred diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" - # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks" "$GHE_REMOTE_DATA_USER_DIR/git-hooks" + diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" From 0b7c9036e93a5dde514d3d75077683af0eedda7f Mon Sep 17 00:00:00 2001 From: Mutwin Kraus Date: Mon, 27 Jun 2016 10:54:21 +0200 Subject: [PATCH 0032/2421] Restore es-hookshot backups --- bin/ghe-restore | 3 ++ .../ghe-restore-es-hookshot | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100755 share/github-backup-utils/ghe-restore-es-hookshot diff --git a/bin/ghe-restore b/bin/ghe-restore index ac465916a..eceab5729 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -287,6 +287,9 @@ else ghe-restore-es-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 fi +echo "Restoring hookshot logs ..." +ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 + # Restart an already running memcached to reset the cache after restore if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then echo "Restarting memcached ..." 1>&3 diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot new file mode 100755 index 000000000..b5a96722e --- /dev/null +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-es-hookshot +#/ Restores a backup of hookshot logs to ElasticSearch. +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-restore. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ $# -lt 1 ] && print_usage + +bm_start "$(basename $0)" + +GHE_HOSTNAME="$1" + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3 | sort | tail -1) + +indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz) + +for index in $indices; do + if [ -z "$last_index" ] || ! [ $index \< $last_index ]; then + echo "Restoring $index" + gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" + fi +done + +bm_end "$(basename $0)" From 072e6fa816f278d2cc1cc23134f616894955a770 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 27 Jun 2016 16:56:16 +0200 Subject: [PATCH 0033/2421] Git hooks backup fixes (#49) * Do not backup git-hooks tarballs when not present. * Make it possible to invoke ghe-backup-git-hooks-cluster directly. --- bin/ghe-backup | 2 +- .../ghe-backup-git-hooks-cluster | 44 ++++++++++++------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index bc94c45bb..7002879a4 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -175,7 +175,7 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then echo "Backing up custom Git hooks ..." ghe-backup-git-hooks-cluster || - failures="$failures alambic_assets" + failures="$failures git-hooks" else echo "Backing up asset attachments ..." ghe-backup-userdata alambic_assets || diff --git a/share/github-backup-utils/ghe-backup-git-hooks-cluster b/share/github-backup-utils/ghe-backup-git-hooks-cluster index 1d18dce53..295ce1c52 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks-cluster +++ b/share/github-backup-utils/ghe-backup-git-hooks-cluster @@ -9,30 +9,30 @@ set -e # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -backup_dir="$GHE_SNAPSHOT_DIR/git-hooks" - -# Location of last good backup for rsync --link-dest -backup_current="$GHE_DATA_DIR/current/git-hooks" - # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then echo "Error: rsync not found." 1>&2 exit 1 fi +bm_start "$(basename $0)" + +backup_dir="$GHE_SNAPSHOT_DIR/git-hooks" +# Location of last good backup for rsync --link-dest +backup_current="$GHE_DATA_DIR/current/git-hooks" + # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Generate SSH config for forwarding +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +# Generate SSH config for forwarding config="" # git server hostnames @@ -102,6 +102,16 @@ rsync_git_hooks_data () { } hostname=$(echo $hostnames | awk '{ print $1; }') -ghe-ssh -F $config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks' ]" || exit 0 -rsync_git_hooks_data $hostname:122 environments/tarballs -rsync_git_hooks_data $hostname:122 repos +if ghe-ssh -F $config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs' ]"; then + rsync_git_hooks_data $hostname:122 environments/tarballs +else + ghe_verbose "git-hooks environment tarballs not found. Skipping ..." +fi + +if ghe-ssh -F $config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos' ]"; then + rsync_git_hooks_data $hostname:122 repos +else + ghe_verbose "git-hooks repositories not found. Skipping ..." +fi + +bm_end "$(basename $0)" From 4f19a035d091b938a057412e0316eebe66491b4b Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Thu, 30 Jun 2016 20:14:16 +0200 Subject: [PATCH 0034/2421] Bump version to 2.7.0 (#51) --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index ec1cf33c3..24ba9a38d 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.6.3 +2.7.0 From a6382f4cdb048f975e718a31ecf777afa93bb646 Mon Sep 17 00:00:00 2001 From: Mutwin Kraus Date: Fri, 1 Jul 2016 16:07:09 +0200 Subject: [PATCH 0035/2421] Fix for older cluster restores (#52) * Verify that ghe-cluster-config-update exists at the correct path before executing * Run ghe-cluster-config-update at old path * Refactor to run ssh once --- bin/ghe-restore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index eceab5729..249ebb672 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -330,7 +330,8 @@ else echo "Restoring Git over SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C /data/user/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld /data/user/common/ssh_host_*" 1>&3 - ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-cluster-config-update -s" 1>&3 + echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else /usr/local/bin/ghe-cluster-config-update -s; fi" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi echo "Completed restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" From 2eeca4cacc8b5c14813177841a9f88d7f75bbfb9 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Mon, 25 Jul 2016 12:02:27 +0200 Subject: [PATCH 0036/2421] Remove restoring cluster.conf on restore (#53) This breaks restoring in a differently layed out cluster which is explicitly supported. --- share/github-backup-utils/ghe-restore-settings | 6 ------ 1 file changed, 6 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 89aa934b4..a0ac361f4 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -51,12 +51,6 @@ if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/manage-password" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-passwords" fi -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - echo "Restoring cluster configuration ..." - cat "$GHE_RESTORE_SNAPSHOT_PATH/cluster.conf" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo tee $GHE_REMOTE_CLUSTER_CONF_FILE >/dev/null" -fi - # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then echo "Restoring SAML keys ..." From 870d959210aa1c60ae886e79fd95af82b1fbf937 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 2 Aug 2016 14:58:08 +0200 Subject: [PATCH 0037/2421] ghe-restore-es-hookshot: minor logging tweaks (#56) Mostly to be consistent with the log output of other scripts. --- share/github-backup-utils/ghe-restore-es-hookshot | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index b5a96722e..0441e8582 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -25,8 +25,8 @@ indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz 2>/dev/null | for index in $indices; do if [ -z "$last_index" ] || ! [ $index \< $last_index ]; then - echo "Restoring $index" - gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" + ghe_verbose "* Restoring $index" + gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 fi done From d52fcc55109afd54610672bffa758542d1484347 Mon Sep 17 00:00:00 2001 From: Mutwin Kraus Date: Thu, 11 Aug 2016 13:23:18 +0200 Subject: [PATCH 0038/2421] Uuid nodenames (#58) * Use uuid hostnames for dgit, alambic, pages and gists replicas if uuids are configured * Move cluster hostname detection into ghe-cluster-hostnames --- .../github-backup-utils/ghe-cluster-hostnames | 31 +++++++++++++++++++ .../ghe-restore-alambic-cluster-ng | 3 +- .../ghe-restore-pages-dpages | 3 +- .../ghe-restore-repositories-dgit-ng | 8 ++--- .../ghe-restore-repositories-gist-ng | 3 +- 5 files changed, 38 insertions(+), 10 deletions(-) create mode 100755 share/github-backup-utils/ghe-cluster-hostnames diff --git a/share/github-backup-utils/ghe-cluster-hostnames b/share/github-backup-utils/ghe-cluster-hostnames new file mode 100755 index 000000000..32643d976 --- /dev/null +++ b/share/github-backup-utils/ghe-cluster-hostnames @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +#/ Usage: ghe-cluster-hostnames +#/ +#/ Finds all nodes of the cluster using the config on . +#/ If it is a 2.8 cluster the results are returned as prefix-uuid, +#/ otherwise the configured hostnames are returned. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore-* commands when restoring into a cluster. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +GHE_HOSTNAME="$1" +prefix="$2" + +if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) + hostnames='' + for uuid in $node_uuids; do + hostnames+="$prefix-$uuid " + done +else + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) +fi + +echo "$hostnames" diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 675167cb9..2794737d0 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -44,8 +44,7 @@ user="${host%@*}" # Generate SSH config for forwarding config="" -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -for hostname in $hostnames; do +for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server"); do config="$config Host $hostname ServerAliveInterval 60 diff --git a/share/github-backup-utils/ghe-restore-pages-dpages b/share/github-backup-utils/ghe-restore-pages-dpages index 581c7f570..4014e80df 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages +++ b/share/github-backup-utils/ghe-restore-pages-dpages @@ -45,8 +45,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -for hostname in $hostnames; do +for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "pages-server"); do config="$config Host $hostname ServerAliveInterval 60 diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 651f3e63a..31ca0d9b0 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -46,7 +46,7 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") for hostname in $hostnames; do echo " Host $hostname @@ -129,13 +129,13 @@ cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore- if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" - for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do + for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do if ! ghe-rsync -av --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to $route" + "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to git-server-$uuid" fi done else diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 05c6f0b64..d68d3a2ac 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -46,8 +46,7 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -for hostname in $hostnames; do +for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server"); do echo " Host $hostname ServerAliveInterval 60 From c975560c1aee48c4de47a156a9188e1aa700b8ea Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 19 Aug 2016 15:11:39 -0600 Subject: [PATCH 0039/2421] Always store backup-utils version --- .../github-backup-utils/ghe-backup-store-version | 7 ++++--- test/test-ghe-backup.sh | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-store-version b/share/github-backup-utils/ghe-backup-store-version index fb033d257..6148012c5 100755 --- a/share/github-backup-utils/ghe-backup-store-version +++ b/share/github-backup-utils/ghe-backup-store-version @@ -8,14 +8,15 @@ set -e bm_start "$(basename $0)" +version_info="$BACKUP_UTILS_VERSION" if [ -d $GHE_BACKUP_ROOT/.git ]; then - version_info="$BACKUP_UTILS_VERSION" ref=$(git --git-dir=$GHE_BACKUP_ROOT/.git rev-parse HEAD || true) if [ -n "$ref" ]; then version_info="$version_info:$ref" fi - echo "$version_info" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version >/dev/null 2>&1" fi +echo "$version_info" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version >/dev/null 2>&1" + bm_end "$(basename $0)" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 1bd622569..cdc024a87 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -440,3 +440,19 @@ begin_test "ghe-backup fsck" ! ghe-backup | grep -q "Repos verified:" ) end_test + +begin_test "ghe-backup stores version when not run from a clone" +( + set -e + + # Make sure this doesn't exist + rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" + + mv "$ROOTDIR/.git" "$ROOTDIR/.gittmp" + ghe-backup + mv "$ROOTDIR/.gittmp" "$ROOTDIR/.git" + + # verify that ghe-backup wrote its version information to the host + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] +) +end_test From 3caaa0f721df6f03a0cf259344cf696ecdd8263b Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Mon, 22 Aug 2016 15:03:46 -0400 Subject: [PATCH 0040/2421] [WIP] Backup repos from healthy nodes only once (#57) * Intermediate checkin. First pass of using the new cluster backup script. WIP * Run legacy sync if the new backup route script is not found, else run the new faster sync * Reverted the repo backup script and moving it over to a -ng script. Will toggle use of the new script from ghe-backup rather than from here. * Adding the script switch in ghe-backup to run the new script if we have the new faster backup script available. chmod +x for the new file * Added rsync include/exclude rules to the script * Uncommenting an echo that was commented out durig some performance tests * Had to include -r option for the new script, since --files-from recursive is not implied. This resulted in empty repo backup dirs. Also added benchmarks calls * Moved the rsync calls into a function so that they can be parallelized. * Capture bechmarks after waiting on jobs. Used aggregate time for all hosts rather than per host, since that makes more sense * Removing use of temp variable and using test -f instead * Removing obsoleted tempdir variable that was introduced before but was not removed when the new backup script was created * Warn if no repo routes are found * Adding archive repos to the backup. Currently this is brute force due to lack of a good way to get a healthy reader for an archived repo * Making sure we don't try rsyncing an empty or non-existant archived route file * Fix style: use 2 spaces * Fix style, use 2 spaces * Follow convention and use bm_start "$(basename $0)" * Fixing indent to 2 spaces. * following the standards for bm_start benchmarking stats --- bin/ghe-backup | 14 +- .../ghe-backup-repositories-cluster | 39 +- .../ghe-backup-repositories-cluster-ng | 354 ++++++++++++++++++ 3 files changed, 385 insertions(+), 22 deletions(-) create mode 100755 share/github-backup-utils/ghe-backup-repositories-cluster-ng diff --git a/bin/ghe-backup b/bin/ghe-backup index 2f1f1f4f0..46085d240 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -166,8 +166,18 @@ ghe-backup-es-hookshot || failures="$failures hookshot" echo "Backing up Git repositories ..." -ghe-backup-repositories-${GHE_BACKUP_STRATEGY} || -failures="$failures repositories" +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/dgit-cluster-backup-routes ; then + echo "* Using calculated routes method..." + ghe-backup-repositories-cluster-ng || failures="$failure repositories" + else + echo "* Using legacy method. A faster backup method is available on enterprise 2.7 and up." + ghe-backup-repositories-cluster || failures="$failures repositories" + fi +else + ghe-backup-repositories-${GHE_BACKUP_STRATEGY} || + failures="$failures repositories" +fi echo "Backing up GitHub Pages ..." ghe-backup-pages-${GHE_BACKUP_STRATEGY} || diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster b/share/github-backup-utils/ghe-backup-repositories-cluster index 6bb56782c..856ad2c7d 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster +++ b/share/github-backup-utils/ghe-backup-repositories-cluster @@ -51,8 +51,8 @@ backup_current="$GHE_DATA_DIR/current/repositories" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 + echo "Error: rsync not found." 1>&2 + exit 1 fi # Perform a host-check and establish GHE_REMOTE_XXX variables. @@ -108,7 +108,7 @@ done # If we have a previous increment, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$backup_current" ]; then - link_dest="--link-dest=../../current/repositories" + link_dest="--link-dest=../../current/repositories" fi # Transfer repository data from a GitHub instance to the current snapshot @@ -116,20 +116,19 @@ fi # already been transferred. A set of rsync filter rules are provided on stdin # for each invocation. rsync_repository_data () { - port=$(ssh_port_part "$1") - host=$(ssh_host_part "$1") - - shift - ghe-rsync -av \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --include-from=- --exclude=\* \ - "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 + port=$(ssh_port_part "$1") + host=$(ssh_host_part "$1") + + shift + ghe-rsync -av \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --include-from=- --exclude=\* \ + "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ + "$backup_dir" 1>&3 } - for hostname in $hostnames; do bm_start "$(basename $0) - $hostname" echo 1>&3 @@ -199,11 +198,11 @@ RULES + /*/nw/??/??/??/*/*.git/packed-refs RULES -# Sync loose refs and reflogs. This must be performed before object data is -# transferred to ensure that all referenced objects are included. -echo 1>&3 -echo "* Transferring refs and reflogs ..." 1>&3 -rsync_repository_data $hostname:122 -z <&3 + echo "* Transferring refs and reflogs ..." 1>&3 + rsync_repository_data $hostname:122 -z < + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +bm_start "$(basename $0)" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +backup_dir="$GHE_SNAPSHOT_DIR/repositories" + +# Location of last good backup for rsync --link-dest +backup_current="$GHE_DATA_DIR/current/repositories" + +tempdir=$(mktemp -d) +to_backup=$tempdir/to_backup + +# Verify rsync is available. +if ! rsync --version 1>/dev/null 2>&1; then + echo "Error: rsync not found." 1>&2 + exit 1 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$host" + +# Generate SSH config for forwarding + +config="" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +# git server hostnames +hostnames=$(ghe_cluster_online_nodes "git-server") +for hostname in $hostnames; do + config="$config +Host $hostname + ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p + StrictHostKeyChecking=no +" +done + +config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +echo "$config" > "$config_file" + +opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + +# Make sure root backup dir exists if this is the first run +mkdir -p "$backup_dir" + +# Removes the remote sync-in-progress file on exit, re-enabling GC operations +# on the remote instance. +cleanup() { + # Enable remote GC operations + for hostname in $hostnames; do + ghe-gc-enable -F $config_file $hostname:$port + done + rm -f $config_file + rm -rf $tempdir +} +trap 'cleanup' EXIT +trap 'exit $?' INT # ^C always terminate + +# Disable remote GC operations +for hostname in $hostnames; do + ghe-gc-disable -F $config_file $hostname:$port +done + +# If we have a previous increment, avoid transferring existing files via rsync's +# --link-dest support. This also decreases physical space usage considerably. +if [ -d "$backup_current" ]; then + link_dest="--link-dest=../../current/repositories" +fi + +# Calculate sync routes. This will store the healthy repo paths for each node +# +# This gets a repo path and stores the path in the $node.sync file +# a/nw/a8/3f/02/100000855 dgit-node1 >> dgit-node1.sync +# a/nw/a8/bc/8d/100000880 dgit-node3 >> dgit-node3.sync +# a/nw/a5/06/81/100000659 dgit-node2 >> dgit-node2.sync +# ... +#one route per line. +# +bm_start "$(basename $0) - Calculating Sync Routes" +ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-routes \ + | while read route; do + ghe_verbose "Got backup route $route" + server=$(echo $route | cut -d ' ' -f2-) + network_path=$(echo $route | cut -d ' ' -f1) + ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync +done +bm_end "$(basename $0) - Calculating Sync Routes" + +if ! ls $tempdir/*.rsync 2>/dev/null; then + echo "Warning: no routes found, skipping repositories backup ..." + exit 0 +fi + +# Transfer repository data from a GitHub instance to the current snapshot +# directory, using a previous snapshot to avoid transferring files that have +# already been transferred. A set of rsync filter rules are provided on stdin +# for each invocation. +rsync_repository_data () { + port=$(ssh_port_part "$1") + host=$(ssh_host_part "$1") + file_list="$2" + shift + shift + ghe-rsync -avr \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --include-from=- --exclude=\* \ + --files-from="$file_list" \ + "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ + "$backup_dir" 1>&3 +} + +sync_data (){ + # Sync all auxiliary repository data. This includes files and directories like + # HEAD, audit_log, config, description, info/, etc. No refs or object data + # should be transferred here. + echo 1>&3 + + echo "* Transferring auxiliary files ..." 1>&3 + rsync_repository_data $1:122 $2 -z <&3 + echo "* Transferring packed-refs files ..." 1>&3 + rsync_repository_data $1:122 $2 -z <&3 + echo "* Transferring refs and reflogs ..." 1>&3 + rsync_repository_data $1:122 $2 -z <&3 + echo "* Transferring objects and packs ..." 1>&3 + rsync_repository_data $1:122 $2 -H <&3 + echo "* Transferring special data directories ..." 1>&3 + rsync_repository_data $1:122 $2 <&3 + +} + +# rsync all the repositories +bm_start "$(basename $0) - Repo sync" +for file_list in $tempdir/*.rsync; do + hostname=$(basename $file_list .rsync) + + repo_num=$(cat $file_list | wc -l) + echo "* Transferring $repo_num repositories from $hostname" + + sync_data $hostname $file_list & +done +wait +bm_end "$(basename $0) - Repo sync" + +bm_start "$(basename $0) - Archived Repos" +ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-archived-repos-routes \ + | while read route; do + ar_route=$(dirname $route) + ghe_verbose "Got archived route $ar_route" + echo "$ar_route" >> $tempdir/archived_repos.rsync +done + +if ! test -f $tempdir/archived_repos.sync; then + echo "* No archived repositories found to backup." + exit 0 +fi + +for h in $hostnames; do + echo "* Transferring archived routes from $h" + sync_data $h $tempdir/archived_repos.rsync 2>/dev/null || true +done +bm_end "$(basename $0) - Archived Repos" + +bm_end "$(basename $0)" From ea61b4e6c3214a832f202d747dcc635e5ba305db Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Mon, 22 Aug 2016 15:03:46 -0400 Subject: [PATCH 0041/2421] Adding a script to speed up cluster backups on enterprise Only affects GHE cluster instances. No change for single appliance GHE. This will not impact GHE instances older than 2.6. You will need to upgrade to GHE 2.6.8 and 2.7.3 for this enhancement to be available. This will benefit cluster setups with 3 or more nodes. Some basic benchmarks: This test is with roughly 1.2k repos of a total size of 14G. Legacy script ``` real 4m2.751s user 1m11.998s sys 0m44.079s Repo sync with no pre-calculated routes took 241s ``` New script backing up the repositories ``` real 2m3.509s user 0m57.403s sys 0m31.405s * Transferring 297 repositories from ghe-test-dgit-fs1 * Transferring 304 repositories from ghe-test-dgit-fs2 * Transferring 268 repositories from ghe-test-dgit-fs3 * Transferring 280 repositories from ghe-test-dgit-fs4 Calculating sync routes took 4s Repo sync with calculated routes took 118s ``` --- bin/ghe-backup | 14 +- .../ghe-backup-repositories-cluster | 39 +- .../ghe-backup-repositories-cluster-ng | 354 ++++++++++++++++++ 3 files changed, 385 insertions(+), 22 deletions(-) create mode 100755 share/github-backup-utils/ghe-backup-repositories-cluster-ng diff --git a/bin/ghe-backup b/bin/ghe-backup index 2f1f1f4f0..46085d240 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -166,8 +166,18 @@ ghe-backup-es-hookshot || failures="$failures hookshot" echo "Backing up Git repositories ..." -ghe-backup-repositories-${GHE_BACKUP_STRATEGY} || -failures="$failures repositories" +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/dgit-cluster-backup-routes ; then + echo "* Using calculated routes method..." + ghe-backup-repositories-cluster-ng || failures="$failure repositories" + else + echo "* Using legacy method. A faster backup method is available on enterprise 2.7 and up." + ghe-backup-repositories-cluster || failures="$failures repositories" + fi +else + ghe-backup-repositories-${GHE_BACKUP_STRATEGY} || + failures="$failures repositories" +fi echo "Backing up GitHub Pages ..." ghe-backup-pages-${GHE_BACKUP_STRATEGY} || diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster b/share/github-backup-utils/ghe-backup-repositories-cluster index 6bb56782c..856ad2c7d 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster +++ b/share/github-backup-utils/ghe-backup-repositories-cluster @@ -51,8 +51,8 @@ backup_current="$GHE_DATA_DIR/current/repositories" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 + echo "Error: rsync not found." 1>&2 + exit 1 fi # Perform a host-check and establish GHE_REMOTE_XXX variables. @@ -108,7 +108,7 @@ done # If we have a previous increment, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$backup_current" ]; then - link_dest="--link-dest=../../current/repositories" + link_dest="--link-dest=../../current/repositories" fi # Transfer repository data from a GitHub instance to the current snapshot @@ -116,20 +116,19 @@ fi # already been transferred. A set of rsync filter rules are provided on stdin # for each invocation. rsync_repository_data () { - port=$(ssh_port_part "$1") - host=$(ssh_host_part "$1") - - shift - ghe-rsync -av \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --include-from=- --exclude=\* \ - "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 + port=$(ssh_port_part "$1") + host=$(ssh_host_part "$1") + + shift + ghe-rsync -av \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --include-from=- --exclude=\* \ + "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ + "$backup_dir" 1>&3 } - for hostname in $hostnames; do bm_start "$(basename $0) - $hostname" echo 1>&3 @@ -199,11 +198,11 @@ RULES + /*/nw/??/??/??/*/*.git/packed-refs RULES -# Sync loose refs and reflogs. This must be performed before object data is -# transferred to ensure that all referenced objects are included. -echo 1>&3 -echo "* Transferring refs and reflogs ..." 1>&3 -rsync_repository_data $hostname:122 -z <&3 + echo "* Transferring refs and reflogs ..." 1>&3 + rsync_repository_data $hostname:122 -z < + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +bm_start "$(basename $0)" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +backup_dir="$GHE_SNAPSHOT_DIR/repositories" + +# Location of last good backup for rsync --link-dest +backup_current="$GHE_DATA_DIR/current/repositories" + +tempdir=$(mktemp -d) +to_backup=$tempdir/to_backup + +# Verify rsync is available. +if ! rsync --version 1>/dev/null 2>&1; then + echo "Error: rsync not found." 1>&2 + exit 1 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$host" + +# Generate SSH config for forwarding + +config="" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +# git server hostnames +hostnames=$(ghe_cluster_online_nodes "git-server") +for hostname in $hostnames; do + config="$config +Host $hostname + ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p + StrictHostKeyChecking=no +" +done + +config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +echo "$config" > "$config_file" + +opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + +# Make sure root backup dir exists if this is the first run +mkdir -p "$backup_dir" + +# Removes the remote sync-in-progress file on exit, re-enabling GC operations +# on the remote instance. +cleanup() { + # Enable remote GC operations + for hostname in $hostnames; do + ghe-gc-enable -F $config_file $hostname:$port + done + rm -f $config_file + rm -rf $tempdir +} +trap 'cleanup' EXIT +trap 'exit $?' INT # ^C always terminate + +# Disable remote GC operations +for hostname in $hostnames; do + ghe-gc-disable -F $config_file $hostname:$port +done + +# If we have a previous increment, avoid transferring existing files via rsync's +# --link-dest support. This also decreases physical space usage considerably. +if [ -d "$backup_current" ]; then + link_dest="--link-dest=../../current/repositories" +fi + +# Calculate sync routes. This will store the healthy repo paths for each node +# +# This gets a repo path and stores the path in the $node.sync file +# a/nw/a8/3f/02/100000855 dgit-node1 >> dgit-node1.sync +# a/nw/a8/bc/8d/100000880 dgit-node3 >> dgit-node3.sync +# a/nw/a5/06/81/100000659 dgit-node2 >> dgit-node2.sync +# ... +#one route per line. +# +bm_start "$(basename $0) - Calculating Sync Routes" +ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-routes \ + | while read route; do + ghe_verbose "Got backup route $route" + server=$(echo $route | cut -d ' ' -f2-) + network_path=$(echo $route | cut -d ' ' -f1) + ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync +done +bm_end "$(basename $0) - Calculating Sync Routes" + +if ! ls $tempdir/*.rsync 2>/dev/null; then + echo "Warning: no routes found, skipping repositories backup ..." + exit 0 +fi + +# Transfer repository data from a GitHub instance to the current snapshot +# directory, using a previous snapshot to avoid transferring files that have +# already been transferred. A set of rsync filter rules are provided on stdin +# for each invocation. +rsync_repository_data () { + port=$(ssh_port_part "$1") + host=$(ssh_host_part "$1") + file_list="$2" + shift + shift + ghe-rsync -avr \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --include-from=- --exclude=\* \ + --files-from="$file_list" \ + "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ + "$backup_dir" 1>&3 +} + +sync_data (){ + # Sync all auxiliary repository data. This includes files and directories like + # HEAD, audit_log, config, description, info/, etc. No refs or object data + # should be transferred here. + echo 1>&3 + + echo "* Transferring auxiliary files ..." 1>&3 + rsync_repository_data $1:122 $2 -z <&3 + echo "* Transferring packed-refs files ..." 1>&3 + rsync_repository_data $1:122 $2 -z <&3 + echo "* Transferring refs and reflogs ..." 1>&3 + rsync_repository_data $1:122 $2 -z <&3 + echo "* Transferring objects and packs ..." 1>&3 + rsync_repository_data $1:122 $2 -H <&3 + echo "* Transferring special data directories ..." 1>&3 + rsync_repository_data $1:122 $2 <&3 + +} + +# rsync all the repositories +bm_start "$(basename $0) - Repo sync" +for file_list in $tempdir/*.rsync; do + hostname=$(basename $file_list .rsync) + + repo_num=$(cat $file_list | wc -l) + echo "* Transferring $repo_num repositories from $hostname" + + sync_data $hostname $file_list & +done +wait +bm_end "$(basename $0) - Repo sync" + +bm_start "$(basename $0) - Archived Repos" +ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-archived-repos-routes \ + | while read route; do + ar_route=$(dirname $route) + ghe_verbose "Got archived route $ar_route" + echo "$ar_route" >> $tempdir/archived_repos.rsync +done + +if ! test -f $tempdir/archived_repos.sync; then + echo "* No archived repositories found to backup." + exit 0 +fi + +for h in $hostnames; do + echo "* Transferring archived routes from $h" + sync_data $h $tempdir/archived_repos.rsync 2>/dev/null || true +done +bm_end "$(basename $0) - Archived Repos" + +bm_end "$(basename $0)" From 40ccc983832aaa52dc1de15fe5f196f1df85f1ad Mon Sep 17 00:00:00 2001 From: Pavan Ravipati Date: Wed, 24 Aug 2016 14:49:10 -0700 Subject: [PATCH 0042/2421] Add backup version note --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index c31afc5e2..e4ce1583e 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,9 @@ supported. We strongly recommend upgrading to the latest release if you're running a version prior to 11.10.342. Visit [enterprise.github.com][5] to download the most recent GitHub Enterprise version. +Note: You can only restore from snapshot that's at most two releases ahead of the version of GitHub Enterprise running on your backup host. For example, to restore from a snapshot running GitHub Enterprise 2.7, your backup host must be on GitHub Enterprise 2.6 or 2.5. You can't restore from 2.4 to 2.7, because that's three releases behind. + + ### Getting started 1. [Download the latest release version][release] and extract *or* clone the From 8948300e14fb001df8ab16335a7a22239b06c24a Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Fri, 26 Aug 2016 10:04:32 -0400 Subject: [PATCH 0043/2421] Fix hostname discovery (#61) Mostly bug fixes. * Fix hostname discovery by using the new scripts that introduced the uuid git-server names * Fixing the special directories rsync paths * Added some minor comments and also benchmark stats for the special directories sync --- .../ghe-backup-repositories-cluster-ng | 87 ++++++++++++------- 1 file changed, 57 insertions(+), 30 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 788067def..997898cfa 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -74,7 +74,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # git server hostnames -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") for hostname in $hostnames; do config="$config Host $hostname @@ -147,17 +147,32 @@ fi rsync_repository_data () { port=$(ssh_port_part "$1") host=$(ssh_host_part "$1") - file_list="$2" - shift - shift - ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --include-from=- --exclude=\* \ - --files-from="$file_list" \ - "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 + + #check if we are syncing from a given file list + if [[ "$2" == *".rsync" ]]; then + files_list="$2" + shift + shift + ghe-rsync -avr \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --include-from=- --exclude=\* \ + --files-from="$files_list" \ + "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ + "$backup_dir" 1>&3 + else + shift + ghe-rsync -avr \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --include-from=- --exclude=\* \ + "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ + "$backup_dir" 1>&3 + fi + + } sync_data (){ @@ -295,6 +310,29 @@ RULES + /*/nw/??/??/??/*/*.git/objects/** RULES + echo 1>&3 + +} + +# rsync all the repositories +bm_start "$(basename $0) - Repo sync" +for file_list in $tempdir/*.rsync; do + hostname=$(basename $file_list .rsync) + + repo_num=$(cat $file_list | wc -l) + echo "* Transferring $repo_num repositories from $hostname" + + sync_data $hostname $file_list & +done +wait +bm_end "$(basename $0) - Repo sync" + +# Since there are no routes for special data directories +# or archived repositories, we need to do this serially +# for all hostnames. Good candidate for future optimizations. + +bm_start "$(basename $0) - Special Data Directories Sync" +for h in $hostnames; do # Sync __special__ data directories, including the __alambic_assets__, # __hookshot__, and __purgatory__ directories. The __nodeload_archives__, # __gitmon__, and __render__ directories are excludes since they act only as @@ -304,8 +342,8 @@ RULES # /data/repositories. All other special user data directories have been moved under # the /data/user directory. echo 1>&3 - echo "* Transferring special data directories ..." 1>&3 - rsync_repository_data $1:122 $2 <&3 + rsync_repository_data $h:122 -z <&3 - -} - -# rsync all the repositories -bm_start "$(basename $0) - Repo sync" -for file_list in $tempdir/*.rsync; do - hostname=$(basename $file_list .rsync) - - repo_num=$(cat $file_list | wc -l) - echo "* Transferring $repo_num repositories from $hostname" - - sync_data $hostname $file_list & + echo 1>&3 done -wait -bm_end "$(basename $0) - Repo sync" +bm_end "$(basename $0) - Special Data Directories Sync" bm_start "$(basename $0) - Archived Repos" ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-archived-repos-routes \ @@ -340,7 +365,9 @@ ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-archived-repos-rout echo "$ar_route" >> $tempdir/archived_repos.rsync done -if ! test -f $tempdir/archived_repos.sync; then + + +if ! test -f $tempdir/archived_repos.rsync; then echo "* No archived repositories found to backup." exit 0 fi From 64925dccd794307a07757b3365c9614d62dbcf82 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Mon, 19 Sep 2016 07:27:59 -0700 Subject: [PATCH 0044/2421] Fixing special directory backups to be per host --- .../ghe-backup-repositories-cluster-ng | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 788067def..ccac1da1b 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -295,6 +295,29 @@ RULES + /*/nw/??/??/??/*/*.git/objects/** RULES + echo 1>&3 + +} + +# rsync all the repositories +bm_start "$(basename $0) - Repo sync" +for file_list in $tempdir/*.rsync; do + hostname=$(basename $file_list .rsync) + + repo_num=$(cat $file_list | wc -l) + echo "* Transferring $repo_num repositories from $hostname" + + sync_data $hostname $file_list & +done +wait +bm_end "$(basename $0) - Repo sync" + +# Since there are no routes for special data directories +# or archived repositories, we need to do this serially +# for all hostnames. Good candidate for future optimizations. + +bm_start "$(basename $0) - Special Data Directories Sync" +for h in $hostnames; do # Sync __special__ data directories, including the __alambic_assets__, # __hookshot__, and __purgatory__ directories. The __nodeload_archives__, # __gitmon__, and __render__ directories are excludes since they act only as @@ -304,8 +327,8 @@ RULES # /data/repositories. All other special user data directories have been moved under # the /data/user directory. echo 1>&3 - echo "* Transferring special data directories ..." 1>&3 - rsync_repository_data $1:122 $2 <&3 + rsync_repository_data $h:122 -z <&3 - -} - -# rsync all the repositories -bm_start "$(basename $0) - Repo sync" -for file_list in $tempdir/*.rsync; do - hostname=$(basename $file_list .rsync) - - repo_num=$(cat $file_list | wc -l) - echo "* Transferring $repo_num repositories from $hostname" - - sync_data $hostname $file_list & + echo 1>&3 done -wait -bm_end "$(basename $0) - Repo sync" +bm_end "$(basename $0) - Special Data Directories Sync" + bm_start "$(basename $0) - Archived Repos" ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-archived-repos-routes \ From e7fdba41c033ce4b33a1bb3eeb3daf5d28f40303 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Mon, 19 Sep 2016 07:30:09 -0700 Subject: [PATCH 0045/2421] Fix Typo in folder name for test --- share/github-backup-utils/ghe-backup-repositories-cluster-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index ccac1da1b..3939f00ea 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -351,7 +351,7 @@ ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-archived-repos-rout echo "$ar_route" >> $tempdir/archived_repos.rsync done -if ! test -f $tempdir/archived_repos.sync; then +if ! test -f $tempdir/archived_repos.rsync; then echo "* No archived repositories found to backup." exit 0 fi From b4b0007cac1eacb339188ffb10cf51e682c8c70d Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Mon, 19 Sep 2016 07:36:57 -0700 Subject: [PATCH 0046/2421] Fix a few bugs in the rsync function Make the switch to use files-from or -z option based on file extension. --- .../ghe-backup-repositories-cluster-ng | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 3939f00ea..f578c56c7 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -147,17 +147,31 @@ fi rsync_repository_data () { port=$(ssh_port_part "$1") host=$(ssh_host_part "$1") - file_list="$2" - shift - shift - ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --include-from=- --exclude=\* \ - --files-from="$file_list" \ - "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 + + #check if we are syncing from a given file list + if [[ "$2" == *".rsync" ]]; then + files_list="$2" + shift + shift + ghe-rsync -avr \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --include-from=- --exclude=\* \ + --files-from="$files_list" \ + "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ + "$backup_dir" 1>&3 + else + shift + ghe-rsync -avr \ + -e "ssh -q $opts -p $port -F $config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --include-from=- --exclude=\* \ + "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ + "$backup_dir" 1>&3 + fi + } sync_data (){ From 1c9c7a158f239531e696cd9eb5b8d2f74df29677 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 20 Sep 2016 13:52:48 +1000 Subject: [PATCH 0047/2421] Remove wcat.io from cibuild --- script/cibuild | 6 ------ 1 file changed, 6 deletions(-) diff --git a/script/cibuild b/script/cibuild index 32d13f504..413352f40 100755 --- a/script/cibuild +++ b/script/cibuild @@ -63,11 +63,5 @@ else exit 1 fi -# Publish package files on wcat.io -echo "Uploading packages ..." -for f in $pkg_files; do - printf "%-32s %-s\n" "$(curl -sT- https://wcat.io <"$f" || true)" "$f" -done - # Generate md5sums md5sum $pkg_files From 1662a8b793df20d3988f8c2643d4c67329cef685 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 20 Sep 2016 10:21:17 -0400 Subject: [PATCH 0048/2421] Detect leaked ssh keys in backup snapshots (#62) This adds detection of leaked SSH host keys in backup snapshots. Detection has been added to the backup as well as restore scripts. A standalone script is also provided to verify the status of all snapshots or individual backup snapshots. Example of a restore run: ``` $./bin/ghe-restore -v -f * Leaked key found in backup snapshot. * Snapshot file: /home/dev/backup-utils-private/data/20160826T114243/ssh-host-keys.tar * Key file: ssh_host_rsa_key.pub * Key: c5:23:20:32:3d:c3:23:e5:64:36:e2:09:c9:47:41:12 * The snapshot that is being restored contains a leaked SSH host key. * We recommend rolling the SSH host keys after completing the restore. * Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance. * (An upgrade may be required) ``` Example standalone run: ``` $>./share/githup-backup-utils/ghe-detect-leaked-ssh-keys * Leaked key found in backup snapshot. * Snapshot file: /home/dev/backup-utils-private/data/20160826T114243/ssh-host-keys.tar * Key file: ssh_host_rsa_key.pub * Key: c5:23:20:de:3d:c3:c9:e5:64:23:a1:09:c9:47:41:12 * Leaked key found in current backup snapshot. * Snapshot file: /home/dev/backup-utils-private/data/20160614T045039/ssh-host-keys.tar * Key file: ssh_host_rsa_key.pub * Key: c5:11:20:ac:3d:c3:c9:e5:54:36:a1:09:c9:47:41:45 * The current backup contains leaked SSH host keys. * current backup directory: /home/dev/backup-utils-private/data/20160614T045039 * We strongly recommend rolling your SSH host keys with ghe-ssh-roll-host-keys and making a new backup. * One or more older backup snapshots that contain leaked SSH host keys, * No immediate action is needed but when you use one of these older snapshots for a restore, please make sure to roll the SSH host keys after restore. * Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance. * (An upgrade may be required) ``` --- bin/ghe-backup | 4 + bin/ghe-restore | 5 + .../ghe-detect-leaked-ssh-keys | 125 +++++ .../ghe-ssh-leaked-host-keys-list.txt | 531 ++++++++++++++++++ test/bin/ghe-gen-fake-ssh-tar | 10 + test/test-ghe-backup.sh | 39 ++ test/test-ghe-detect-leaked-ssh-keys.sh | 71 +++ test/test-ghe-restore.sh | 38 ++ test/testlib.sh | 5 + 9 files changed, 828 insertions(+) create mode 100755 share/github-backup-utils/ghe-detect-leaked-ssh-keys create mode 100644 share/github-backup-utils/ghe-ssh-leaked-host-keys-list.txt create mode 100755 test/bin/ghe-gen-fake-ssh-tar create mode 100644 test/test-ghe-detect-leaked-ssh-keys.sh diff --git a/bin/ghe-backup b/bin/ghe-backup index 46085d240..2c9a41412 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -257,5 +257,9 @@ else exit 1 fi +# Detect if the created backup contains any leaked ssh keys +echo "Checking for leaked ssh keys ..." +ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" + # Make sure we exit zero after the conditional true diff --git a/bin/ghe-restore b/bin/ghe-restore index 99bfb6f44..ef3005a04 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -66,6 +66,11 @@ GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") export GHE_RESTORE_SNAPSHOT +# Detect if the backup we are restoring has a leaked ssh key +echo "Checking for leaked keys in the backup snapshot that is being restored ..." +ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" + + # Figure out whether to use the tarball or rsync restore strategy based on the # strategy file written in the snapshot directory. GHE_BACKUP_STRATEGY=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/strategy") diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys new file mode 100755 index 000000000..d599649e7 --- /dev/null +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -0,0 +1,125 @@ +#!/bin/bash +#/ Usage: ghe-detect-leaked-ssh-key [-s ] +#/ +#/ This utility will check each snapshot's existing SSH host keys against the list +#/ of known leaked SSH host keys from GitHub Enterprise packages. +#/ +#/ OPTIONS: +#/ -h | --help Show this message. +#/ -s |--snapshot Scan the snapshot with the given id. +#/ Available snapshots may be listed under the data directory. +#/ +set -e + +usage() { + grep '^#/' < "$0" | cut -c 4- +} + +TEMPDIR=$(mktemp -d) + +# Parse args. +ARGS=$(getopt --name "$0" --long help,snapshot: --options hs -- "$@") || { + usage + exit 2 +} +eval set -- $ARGS + +while [ $# -gt 0 ]; do + case "$1" in + -h|--help) + usage + exit 2 + ;; + -s|--snapshot) + shift 2 + snapshot=$1 + ;; + --) + shift + break + ;; + esac + shift +done + +ppid_script=$(ps -o args= $PPID | awk '{print $2}') +if [ -n "$ppid_script" ]; then + ppid_name=$(basename $ppid_script) +fi + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +fingerprint_blacklist=$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/ghe-ssh-leaked-host-keys-list.txt") + +keys="ssh_host_dsa_key.pub ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub ssh_host_rsa_key.pub" + +# Get all the host ssh keys tar from all snapshots directories +if [ -n "$snapshot" ]; then + ssh_tars=$(find "$snapshot" -maxdepth 1 -type f -iname 'ssh-host-keys.tar') +else + ssh_tars=$(find "$GHE_DATA_DIR" -maxdepth 2 -type f -iname 'ssh-host-keys.tar') +fi + +# Store the current backup snapshot folder +if [ -L "$GHE_DATA_DIR/current" ]; then + current_dir=$(readlink -f "$GHE_DATA_DIR/current") +fi + +leaked_keys_found=false +current_bkup=false +for tar_file in $ssh_tars; do + for key in $keys; do + if $(tar -tvf "$tar_file" $key &>/dev/null); then + tar -C $TEMPDIR -xvf "$tar_file" $key &>/dev/null + fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) + if echo "$fingerprint_blacklist" | grep -q "$fingerprint"; then + leaked_keys_found=true + if [ "$current_dir" == $(dirname "$tar_file") ]; then + current_bkup=true + echo "* Leaked key found in current backup snapshot." + else + echo "* Leaked key found in backup snapshot." + fi + echo "* Snapshot file: $tar_file" + echo "* Key file: $key" + echo "* Key: $fingerprint" + echo + fi + fi + done +done + +if $leaked_keys_found; then + if echo "$ppid_name" | grep -q 'ghe-restore'; then + echo + echo "* The snapshot that is being restored contains a leaked SSH host key." + echo "* We recommend rolling the SSH host keys after completing the restore." + echo "* Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance." + echo "* (An upgrade may be required)" + echo + elif echo "$ppid_name" | grep -q 'ghe-backup'; then + echo "* The current backup contains leaked SSH host keys." + echo "* We strongly recommend rolling your SSH host keys and making a new backup." + echo "* Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance." + echo "* (An upgrade may be required)" + else + if $current_bkup; then + echo "* The current backup contains leaked SSH host keys." + echo "* Current backup directory: $current_dir" + echo "* We strongly recommend rolling your SSH host keys and making a new backup." + echo "* Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance." + echo "* (An upgrade may be required)" + fi + echo + echo "* One or more older backup snapshots contain leaked SSH host keys." + echo "* No immediate action is needed but when you use one of these older snapshots for a restore, " + echo "* please make sure to roll the SSH host keys after restore." + echo "* Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance." + echo "* (An upgrade may be required)" + echo + fi +fi + +# Cleanup temp dir +rm -rf $TEMPDIR diff --git a/share/github-backup-utils/ghe-ssh-leaked-host-keys-list.txt b/share/github-backup-utils/ghe-ssh-leaked-host-keys-list.txt new file mode 100644 index 000000000..fc1e345f3 --- /dev/null +++ b/share/github-backup-utils/ghe-ssh-leaked-host-keys-list.txt @@ -0,0 +1,531 @@ +00:1e:18:e9:74:fb:d6:4e:ef:88:38:59:16:a3:a7:a3 +00:3d:07:23:20:f6:dc:fc:28:cb:1e:96:08:16:a6:8c +00:61:8b:a4:90:37:3f:8c:02:3c:5c:eb:3f:f7:c4:e0 +01:6f:6a:63:3b:a3:54:d5:e8:50:70:c2:83:bf:50:4b +01:80:47:81:28:6f:65:d3:dd:ca:2d:99:84:50:08:7d +01:bb:ca:3e:51:67:32:a0:c6:ba:4c:06:23:f7:19:6d +02:d8:1b:c8:7b:74:4b:70:65:a2:14:5a:7b:70:32:75 +03:3a:ff:42:01:fd:2a:08:d0:08:1a:78:25:79:19:28 +03:56:f0:3d:13:f2:3a:3b:fb:b7:0a:0b:db:51:aa:cd +04:47:f2:79:68:a0:ef:e2:ff:3b:3d:9f:de:c9:64:7c +04:bb:1b:fc:c3:8c:36:7b:a1:13:7a:27:d7:23:02:b3 +06:b8:78:f7:0e:d1:76:3f:43:9b:62:f9:75:b2:36:64 +06:d1:97:f1:ee:0c:91:c5:8d:81:6c:05:37:eb:74:b7 +07:17:ba:80:38:11:4b:60:d1:36:67:93:16:d2:ca:be +07:94:d6:29:5d:2b:7f:d4:e2:e6:ea:b4:80:50:e2:81 +08:0b:1e:a1:2b:72:eb:3e:6d:ec:65:cf:74:12:ef:50 +09:19:0b:ba:c6:05:09:33:97:78:bb:fa:f6:16:51:40 +0a:35:77:9f:53:47:c1:d1:78:f4:fc:c9:bc:f4:0f:bb +0a:61:2a:e4:9c:d7:4a:70:05:ea:54:20:fc:7a:2f:78 +0a:74:29:59:29:f8:2f:17:e1:7a:b7:3f:27:19:cb:28 +0b:10:8c:94:df:b6:ed:a3:e7:09:52:05:70:c8:e0:28 +0b:7d:ee:07:7a:55:69:fe:cd:e7:35:90:29:c0:b4:02 +0b:ce:93:2a:9d:5a:42:05:44:9a:d0:92:a2:6d:52:31 +0d:53:09:71:03:e1:55:c7:18:b2:38:ff:a4:42:bf:e4 +0d:9d:6a:69:8e:37:2a:43:d4:ef:95:cb:0b:8b:4d:66 +0d:c1:26:a4:f8:f6:e5:25:71:0b:8e:01:d7:b6:d9:84 +0e:20:8a:77:bf:eb:2a:ad:d9:11:c5:3e:32:c9:d1:4c +0e:df:dd:07:c7:29:d5:fb:cc:0a:7a:b9:1f:de:d5:5b +0f:ee:8d:02:2d:e1:76:f3:eb:f5:af:cb:38:9a:1c:33 +10:17:7e:66:b8:f7:5c:4a:4c:ae:c7:d0:c6:b3:cb:f0 +11:44:18:61:ca:fb:3f:82:06:68:a5:91:0a:f0:45:83 +11:51:12:89:0c:86:3b:b7:98:6f:52:d5:c9:83:8b:3e +11:99:17:05:a8:ee:c6:c9:04:c2:a2:c0:24:bf:c9:ce +11:b6:17:8e:a8:37:f9:d6:f5:b2:0a:38:d6:54:cd:1e +11:fb:cc:a5:a6:06:ed:f0:33:cc:02:57:6e:ac:23:e1 +11:fe:55:ad:89:71:d9:fa:02:88:f1:a1:28:f3:48:cd +12:5f:ac:a5:94:ab:8a:c4:72:70:d5:a2:27:15:f5:fe +14:32:6e:03:76:a6:82:86:a1:5b:8f:9a:f1:0d:df:21 +14:4a:ce:e5:12:fa:c1:0d:31:3c:b5:ba:df:3a:b5:08 +14:74:44:4f:6a:ef:d1:9d:8f:60:aa:de:33:63:b2:0a +16:25:d0:a8:b4:21:18:99:29:e3:2b:78:04:69:47:d6 +16:45:9a:7a:b5:f0:8b:06:15:8b:a9:05:c3:58:5a:f8 +16:4d:b7:05:cb:e7:95:a5:0a:43:5a:de:9c:31:96:02 +17:27:6c:c5:29:7f:09:ab:60:0a:f7:0b:b8:a9:87:f6 +17:58:62:5b:ed:ba:db:fd:41:27:c8:2f:20:08:ef:ad +17:b7:52:02:58:56:04:2c:05:be:87:93:bf:c4:f9:6b +17:fe:11:03:48:5e:37:77:25:ae:9c:21:1e:d6:db:66 +18:ae:cc:5b:8d:bb:25:bc:f0:9f:b1:b5:c4:9e:e8:0b +19:89:07:ce:da:54:11:a4:12:a6:7d:b5:d3:9b:5a:2c +1a:28:cc:9a:8b:2d:23:16:c7:88:db:9a:fe:a1:b2:a9 +1a:71:c4:5d:20:d8:5b:e7:69:99:21:61:2c:eb:5c:5c +1a:fe:0f:6d:a0:2f:6b:4d:2c:7a:bc:a7:98:90:7a:89 +1c:0c:bd:16:33:f4:4c:43:6f:1a:8d:e0:e0:cb:0b:56 +1c:b4:a1:16:e9:14:f1:ce:d2:97:ec:09:8e:b9:1e:5e +1c:ec:88:95:92:3e:7e:8d:ec:b8:54:45:02:80:ad:92 +1d:39:cc:b9:5a:b5:76:6e:00:d4:0a:87:ce:87:bd:2d +1d:ca:2a:ce:86:59:8f:59:b2:fb:5f:42:b5:3f:5c:09 +1e:1a:b2:5d:b2:11:f8:0e:51:b6:95:e2:49:10:88:a3 +1e:92:9f:93:d7:88:1b:ae:39:72:d6:92:cb:3a:f0:cb +1e:cb:30:2a:63:7e:3f:85:ad:04:6f:78:e2:cc:60:3a +1e:d8:cf:7d:3d:13:f9:3c:c1:e7:5a:14:f2:71:33:14 +1e:ee:23:36:a1:3c:7d:0d:20:15:fb:f4:f6:89:90:67 +1f:57:ba:04:05:9a:6a:e8:27:da:61:42:0f:b7:07:f0 +1f:c5:9f:c5:d3:40:65:cd:61:2d:37:0f:db:c3:b9:16 +1f:ed:81:ee:b1:96:82:b7:b6:f0:b2:83:04:f6:62:46 +20:bf:67:d9:c1:a6:0b:9b:0e:2a:22:86:ed:29:ba:6a +21:23:9d:46:e5:46:90:77:9f:e8:e2:6c:c3:47:f2:2e +21:8a:c9:fc:52:61:e3:66:81:bc:ef:d9:a5:04:9a:96 +21:9e:f5:99:75:b4:34:2e:ac:78:34:3d:92:0b:c0:e5 +22:cc:ca:f9:26:ae:4a:30:b1:25:02:f7:77:cc:fd:75 +22:e6:ca:93:be:52:68:a5:51:c3:b2:db:ce:50:64:68 +23:74:57:f4:e9:a5:7b:c4:43:22:9b:9c:13:dd:48:94 +24:a1:0c:d9:be:c5:0d:3a:dd:5a:1e:54:da:76:03:98 +25:30:0e:16:bb:b8:d3:4e:c3:73:be:e9:42:86:55:c5 +25:45:e5:a3:93:97:14:59:2a:b0:1a:1d:12:5c:4c:37 +25:c7:bf:5a:44:7d:bf:f9:0d:69:13:ea:3d:69:dc:5d +26:b1:3f:04:90:e7:98:8c:3f:ca:2b:85:71:78:ca:23 +26:d0:33:db:e9:92:e2:5a:3f:d2:5f:e8:2c:13:ee:6f +27:34:2d:e5:35:dd:2c:58:68:71:c6:34:a7:12:b1:0e +27:3e:e7:fc:47:62:19:29:d7:cb:34:bf:14:64:be:db +27:8e:30:11:10:ec:3a:30:40:98:49:7c:37:8e:e6:78 +27:99:83:24:ed:e0:9b:49:68:d9:8d:c1:e2:29:1e:62 +27:a9:de:f6:f4:c4:ff:de:68:42:bf:20:15:fc:76:2b +28:42:e5:ac:70:3a:43:ee:ae:85:44:8d:e5:c3:d7:cb +28:7e:1d:e7:10:e2:cb:4d:87:2d:9d:d2:55:8c:65:69 +28:ad:d7:c4:d8:d0:73:c5:37:f4:b3:86:5f:17:03:d1 +29:3c:b2:41:42:87:b5:1c:f4:f5:30:ba:20:c4:1a:68 +29:7e:20:3e:2d:30:ba:ef:2d:87:cb:ac:c4:d1:40:c0 +29:cb:bc:e8:bb:6a:9b:b6:ad:54:a8:10:f6:6d:87:1c +2c:71:09:84:fc:28:af:da:05:b3:24:92:79:a4:a3:65 +2c:a9:cb:e4:5a:c7:01:46:e8:dc:be:39:5a:5f:23:c1 +2e:ca:24:57:b9:1f:3b:c6:25:21:92:18:4b:cc:3d:5d +2f:9a:fe:1a:f6:20:38:d6:4d:a7:0b:01:65:c6:3d:7e +30:6e:89:da:84:18:84:dd:ac:4b:c4:4b:b4:1e:f7:53 +31:32:d4:f7:da:bc:bb:43:8e:d8:9c:54:45:95:b3:ee +31:c6:5e:da:b9:7b:50:96:e3:7a:a8:0d:ec:b8:e0:9c +33:c0:ef:01:ec:a2:7f:5f:98:29:f9:14:d3:aa:67:d8 +33:c9:1d:8b:e6:c0:41:16:27:07:11:0a:74:81:5d:b0 +33:e8:14:f4:b3:17:3d:d2:ff:fb:29:c7:1c:a1:d3:97 +34:07:4d:e8:6b:76:6c:d7:99:00:37:41:75:a6:61:56 +34:a2:60:9a:a5:4b:5b:85:d4:48:e6:74:c5:d3:70:3c +34:e6:d8:e0:3b:e8:5c:53:6c:35:46:bd:5c:5a:6a:38 +36:a7:fd:e9:60:60:86:0c:02:e7:55:ed:cb:53:fb:90 +37:56:00:e4:ae:be:e0:86:a3:ca:be:95:15:0f:56:4c +38:09:f2:78:7b:eb:7d:68:40:a8:47:2c:d7:2d:14:05 +38:0f:69:3b:14:dc:33:43:f8:b0:02:a8:ff:61:4e:3d +38:1e:d0:ee:e6:c0:0c:a7:83:84:90:89:b2:1e:b5:b0 +38:f4:0b:0f:2e:09:59:4b:9a:d6:99:de:32:84:cf:83 +39:06:09:72:0a:70:6d:25:da:dd:5d:43:eb:9a:7f:c5 +39:12:ab:30:6c:32:0f:9e:ae:59:f7:f9:6c:7a:18:c7 +39:74:02:dd:5a:56:ad:f0:d2:3f:d1:35:74:2a:c9:d3 +39:96:ab:4b:e9:59:ce:87:de:54:a2:30:3a:19:e7:69 +3a:22:e3:7b:a3:38:ae:6b:33:96:9d:a7:4d:71:06:5d +3a:e3:9e:30:e3:6c:68:cc:d0:57:d8:ae:cc:6c:13:01 +3b:dc:aa:c7:83:3d:cc:4e:00:88:69:78:fd:c0:39:76 +3c:2a:fd:86:17:c4:eb:87:71:35:1b:69:16:22:15:e3 +3c:f6:7b:77:80:e8:8d:5a:1b:ba:7b:ca:de:9b:0c:9c +3d:38:9c:12:e9:51:45:2d:c4:2a:db:9a:35:8c:8c:bc +3e:4d:78:2c:8c:e9:aa:03:65:d7:b4:37:1a:87:0e:e7 +3e:6d:23:16:2f:0e:8f:28:db:a7:f0:b3:b0:7e:78:6d +3e:7b:2c:f7:bc:88:3e:73:46:9e:96:f1:32:41:f4:22 +3e:89:2b:39:49:f9:46:fc:cc:6e:a3:65:7f:25:4f:48 +3e:d4:4d:e7:96:6b:aa:21:f1:5a:14:32:ac:4d:6a:de +3f:99:1d:13:0b:21:a4:cd:e2:cc:5f:fe:b8:ab:3a:85 +40:6c:dc:5c:f7:3e:5c:28:23:2c:6f:f8:7f:aa:18:7c +41:5d:5f:e5:6b:7e:da:aa:3d:3e:b9:df:87:33:f0:28 +42:95:59:c4:ab:4f:8d:9f:50:64:53:d7:c2:1e:4c:4d +42:9f:a8:bf:1c:33:0b:5b:f8:bf:5c:7b:3d:f6:34:81 +42:f5:7b:0e:96:ab:2e:87:d6:a1:81:c8:26:f7:af:9a +43:9d:f8:78:c5:07:5b:c0:98:25:67:a0:5f:2d:30:83 +44:30:fc:83:6e:cc:d4:f3:87:51:e9:be:f7:99:39:3c +45:a2:1a:00:71:d1:43:ac:87:cc:b0:a3:5a:a1:9a:56 +45:b3:1c:75:fe:f3:53:0f:d4:ca:6a:4d:5d:ec:3d:dc +45:fe:55:13:c1:e7:c8:e9:eb:98:de:39:a6:f7:2c:ed +46:29:59:2e:c5:10:c1:d4:0b:dc:3c:e4:e2:4f:3c:37 +46:50:92:6e:c9:a3:cf:8b:f7:ce:83:f8:4e:55:e3:70 +46:9f:fe:2e:6f:dd:52:7b:7c:9b:a4:d0:51:a1:be:93 +46:d6:93:0b:1a:a7:16:48:79:6f:07:8e:f8:bd:89:49 +47:29:8e:88:11:66:0d:fe:a7:76:d1:a3:28:a2:7c:60 +47:ac:25:c1:3d:b4:d0:95:33:10:88:6e:73:25:5d:90 +47:f4:65:31:e8:a0:a8:35:3d:c1:90:a5:73:95:45:e0 +48:7a:7b:9e:85:dd:34:0b:47:d8:97:13:2a:4c:c2:1d +49:1e:2c:cb:8f:c2:6a:8c:a2:ec:7f:df:bb:28:29:a4 +49:26:48:31:44:ca:2f:90:71:93:2f:f7:68:93:ed:0f +49:b2:4f:de:c4:61:50:aa:60:94:36:d0:24:54:5d:d5 +49:f1:58:ce:00:d2:6d:1d:79:68:f6:72:9c:c8:c4:1d +4a:89:1f:fb:b5:33:fb:7c:4c:4d:4c:24:2c:41:66:81 +4a:8b:3a:74:b9:06:dd:22:93:1b:33:be:34:22:f2:5a +4a:da:49:be:36:60:08:9f:f9:7a:9d:ff:d0:f8:1d:41 +4a:fb:75:6b:ec:68:2b:a8:ce:e0:aa:1d:96:1b:0b:be +4b:64:04:93:f2:2d:ff:00:5e:22:e9:d5:2b:93:4f:1a +4b:aa:34:a1:36:bc:f2:82:c6:7b:80:63:ba:ba:99:2c +4b:b3:af:d6:ee:32:93:45:20:51:81:f9:25:be:2a:13 +4b:b7:0e:ed:7c:b8:ff:53:a5:bb:10:d2:fe:f6:47:9b +4c:25:4b:69:90:a4:d7:22:e0:95:8a:9c:50:65:27:6e +4c:57:fc:61:e8:ae:e4:82:86:af:44:72:83:54:94:97 +4d:0b:7d:4a:0e:08:36:7d:49:ee:f3:de:c5:67:85:73 +4d:a7:db:15:2c:0c:6c:66:02:46:6b:f4:c6:c1:88:e0 +4d:ab:27:d0:9b:6e:20:f9:14:e2:43:56:a9:85:46:70 +4d:b1:3f:2e:59:29:ae:6a:06:78:e0:10:ff:7c:14:a9 +4d:ef:2b:0a:8d:ea:fe:48:3e:d1:48:6f:ad:a0:a8:73 +4d:f2:16:ff:10:2e:8f:32:63:1d:28:22:64:31:69:0f +4e:e4:8b:3d:2b:ec:f8:32:42:ec:66:fd:be:fc:fc:d0 +4f:02:61:52:d5:10:37:a8:d8:b6:f9:43:3d:42:e1:08 +4f:63:97:2f:6a:86:27:d1:35:af:9a:dc:9a:fd:00:6b +4f:fe:5d:9a:70:9e:7e:4d:e0:51:f4:d4:6b:34:a8:3c +50:1c:00:b1:74:2a:d2:44:3d:90:8e:63:af:52:22:12 +50:3f:cc:2f:01:78:fe:f7:86:4a:23:29:a8:15:46:b9 +50:af:22:33:c0:5d:47:77:2f:60:bd:0d:53:d3:ee:50 +51:14:57:97:ff:f4:81:24:31:ce:8e:5f:38:f6:47:02 +51:63:7a:dc:d4:7d:c7:bb:bf:ff:60:2a:d6:13:68:c5 +51:b8:8a:55:9d:02:12:ea:12:b7:10:22:50:76:59:5c +51:d8:0c:33:10:0d:84:68:90:cf:9e:72:7b:f9:b6:cb +52:6d:53:23:b4:20:93:d1:2e:91:c7:ba:d4:3c:a8:20 +52:af:2c:8f:5a:c1:9a:23:99:3d:d4:3a:ba:7a:96:b4 +53:48:55:2b:5a:7a:01:e7:3f:0d:40:a1:ca:40:aa:f8 +53:55:80:8b:25:60:01:cb:4d:d2:70:93:83:36:94:e0 +53:cc:c9:d6:06:84:73:49:83:0f:ee:86:69:32:9b:e2 +54:45:77:8c:e8:10:e0:84:4d:33:e5:dd:e8:65:78:ec +54:4d:a0:0e:45:7d:ec:2c:7b:0c:97:2b:50:0b:a0:fc +54:ca:36:f2:83:a5:ad:cf:71:55:15:94:3f:02:59:c4 +55:12:1b:8a:83:06:c5:62:5b:18:af:62:a1:82:48:6c +55:58:c8:fe:6c:d3:ae:2a:3a:87:77:c1:eb:de:24:8b +55:9a:fa:4f:3d:e9:46:ed:9f:e6:c4:0a:f5:6a:69:d4 +56:62:86:e7:ef:35:71:6f:b7:c3:68:3d:b5:dd:12:33 +56:6e:4d:18:c4:ce:66:96:7a:6c:99:0a:c1:70:aa:25 +56:bd:22:f2:35:b9:c2:88:3d:c4:c7:eb:8e:c1:42:1e +56:bd:df:db:27:32:3e:24:21:8d:9e:5b:4f:e2:b3:c2 +57:23:4d:9a:10:31:18:8d:1c:40:2e:66:f4:7e:4e:9b +57:bb:e0:7e:3d:58:64:e6:d4:81:9c:c3:f2:07:f9:52 +58:18:a1:5a:c3:72:5f:9b:5e:6e:e3:2f:dd:16:2e:bd +59:1d:76:0f:19:01:72:46:ed:20:35:ad:e4:f7:a5:0d +5a:b5:d0:12:ea:94:74:c2:29:f2:5f:4e:f5:20:f1:15 +5a:ea:ec:0c:37:23:08:81:5f:a1:d2:34:9f:89:fe:58 +5b:87:8d:d6:94:97:03:85:0b:07:c3:d4:3b:87:3d:38 +5b:e4:88:a2:2c:49:0f:9f:de:41:0c:d5:fc:cc:78:b8 +5d:06:17:3b:74:5b:e5:a5:23:3c:6d:ae:ed:09:03:7c +5e:99:49:26:a2:f8:6a:d6:a4:4e:28:89:4c:6a:45:9f +5e:bc:71:89:33:2a:e6:a2:dc:5c:18:f0:fd:e9:c6:a4 +5f:4f:03:35:22:4d:02:f9:d1:a1:58:13:f3:ac:b1:54 +5f:95:66:b2:7a:40:23:0b:89:1f:5b:01:65:34:ed:b8 +5f:98:09:52:f9:3c:4e:c0:0f:b7:12:32:96:29:3f:28 +60:13:12:7a:f6:39:7e:5d:5c:a0:4c:c3:ab:3f:36:f7 +60:63:24:1f:b9:e8:c5:af:2c:12:26:f7:ee:5d:fb:42 +61:5d:72:64:3c:c7:16:39:4d:fa:89:10:3c:84:d5:ee +61:5e:07:b2:6b:97:f3:4b:8c:95:9d:83:28:d1:9e:f1 +61:bc:40:b4:d6:ae:2e:19:4a:ad:a0:64:ed:21:42:2d +62:1e:ea:60:18:82:cb:19:45:79:36:f2:ad:6a:ee:f7 +63:3b:4c:ef:34:cc:ea:d9:c9:1e:be:c4:c2:98:d0:bc +63:8a:b0:91:ed:75:ba:1a:23:87:b9:e1:ac:6b:e9:68 +63:98:e7:95:6c:19:7a:51:24:1c:2a:86:4b:5d:44:97 +63:9e:59:15:b1:7b:07:36:5b:8f:f1:f7:1c:f3:d9:f2 +64:1e:d5:58:90:a8:6a:1e:38:67:8b:4c:b6:f4:d8:07 +64:6f:0b:70:16:33:b7:dd:bf:90:ee:2e:c9:d7:32:1e +65:5c:ea:98:d4:35:6e:ad:54:0d:3f:53:9f:52:ed:9f +65:7d:67:5b:26:5c:ea:50:57:bd:12:7b:c9:e3:52:4c +66:41:ff:81:df:8d:cf:0d:56:6b:e6:93:9d:7e:53:b5 +66:ed:dd:78:69:72:2d:5e:b7:bf:0e:a1:e8:eb:88:88 +67:14:86:86:93:d4:56:95:78:78:f4:35:85:06:ee:6f +67:2e:73:e9:da:fc:cb:37:fa:d3:4f:7f:83:5e:9f:43 +67:c4:07:16:2a:13:e1:66:47:1f:a0:c2:b2:ef:1a:98 +67:f9:56:2a:b9:85:9e:c5:f1:6b:42:b1:af:8e:4d:84 +68:12:5d:3f:b7:68:17:4f:bc:84:4e:94:32:99:ac:3e +68:81:4c:4d:81:79:60:54:9d:e7:e5:72:7a:09:f5:40 +68:93:6c:be:4b:9a:43:88:9a:f8:b7:3f:43:40:d9:6f +68:ce:5b:63:6c:c6:35:bb:86:1f:5f:d9:81:3f:d7:66 +69:2b:44:d3:0f:9c:5a:4d:e7:73:8b:a1:3c:ab:a0:28 +69:fb:0f:96:90:64:a0:4f:58:49:fd:a5:3f:ed:d9:d4 +6a:3c:ab:23:6b:56:df:60:9c:b4:2c:9b:a1:8c:76:46 +6a:6b:46:d6:8c:fc:e4:4f:8e:81:89:32:f7:12:0d:5e +6a:ea:05:78:ef:74:76:ed:da:fe:83:31:df:65:e5:62 +6a:fb:07:3b:25:9e:b4:27:aa:08:9f:1b:17:29:43:39 +6b:1f:00:92:14:ff:4e:58:d9:79:0d:8d:8d:b3:d6:bc +6c:60:4d:f8:61:34:39:6b:bb:e8:fd:66:5e:be:49:a3 +6c:89:43:0c:71:ef:3e:36:45:e5:fa:5d:35:90:5f:51 +6c:cc:b6:01:82:86:90:8a:90:22:24:54:ca:64:2e:4d +6c:d8:e5:7f:cd:e3:e9:85:4c:0c:b0:7e:00:0a:55:33 +6d:66:f9:26:ca:f2:be:a6:6b:c8:bd:f7:b3:ff:79:73 +6d:b1:3a:6a:95:87:c4:b4:3e:31:0b:39:48:08:98:14 +6e:0e:2c:91:4b:50:fe:af:74:3f:2e:71:57:6f:23:3b +6e:a4:96:d7:0c:e9:f9:e4:67:79:35:89:c4:38:60:05 +6e:b3:ed:66:77:22:c9:8f:2b:37:b6:53:eb:aa:2f:fd +6e:e5:c0:bb:0d:79:71:5c:a5:b4:2e:b4:51:44:7d:55 +6f:06:5d:25:f9:4c:74:75:de:cc:e8:5a:52:6b:3c:9b +70:63:53:83:e8:2d:1f:71:a4:75:9f:16:25:c9:19:71 +70:72:c8:5a:a8:46:fd:4a:0b:75:85:8c:4e:ce:6f:74 +71:47:18:eb:ca:f4:f2:11:5c:e7:aa:b1:84:d9:52:dd +72:14:4e:18:36:88:7e:5a:5a:30:3f:fd:1a:6e:a7:69 +72:65:94:63:11:82:d0:d2:4f:f5:fb:62:1a:de:ef:b7 +73:4b:7d:f4:c3:ed:68:da:f9:ce:9f:10:da:5e:53:e9 +73:e0:4e:e2:18:ae:47:59:ce:e5:fc:fd:98:6f:31:ed +73:e6:2e:bd:b2:09:75:f9:58:bf:fd:26:73:8c:48:c1 +75:96:b7:87:19:2a:94:51:dd:1b:21:17:af:1f:f3:6c +75:97:82:2e:4b:63:6b:df:86:5b:22:f8:ea:28:4f:1e +75:b2:5d:ea:bb:2e:02:ca:46:89:e6:68:84:dc:fb:0e +75:e4:11:39:ca:2c:6a:6b:a6:b8:89:9f:6c:ef:24:77 +76:58:e6:3e:ee:f1:08:df:9a:c8:63:a7:81:2a:a5:fe +77:84:62:ce:a8:54:48:6f:81:63:9d:89:2d:d9:d2:90 +78:28:2f:fb:8e:e0:42:52:64:0a:03:06:1a:4c:3d:9c +78:60:64:1c:ea:c2:3e:89:b9:f8:01:bc:f4:a9:39:0a +78:80:cd:7e:99:30:1d:a6:ca:f1:e3:f3:cb:44:2f:d6 +79:1f:ff:95:c1:d5:94:fa:8b:02:8b:c4:be:3b:7c:4c +7b:aa:98:f2:5b:df:86:2e:6f:f8:d9:c9:f0:cb:52:29 +7c:74:dc:30:ac:65:91:d1:2c:b0:e2:88:71:8a:24:b6 +7c:8f:5b:98:f7:f8:ce:77:15:7d:13:8b:0e:a7:de:72 +7d:13:07:89:f9:e3:73:2c:f6:59:c9:df:35:90:5f:63 +7d:60:3d:a6:3a:c4:17:9d:95:d7:e8:39:ec:6c:ef:ca +7d:9b:5f:5e:a9:01:a4:39:ee:cb:34:a3:28:c3:72:3a +7e:09:14:f1:7b:81:a9:aa:de:69:bb:07:3b:38:e7:ca +7e:3e:36:31:8e:e2:4f:7e:9d:43:f8:59:31:7f:99:10 +7e:72:72:fa:07:09:f3:24:14:89:34:7a:83:d4:18:b4 +7e:fa:90:60:a3:55:cd:fa:e9:a1:27:d8:00:71:1b:b9 +7f:53:2a:4c:6b:26:34:99:4f:3a:7a:6d:c8:82:62:2a +7f:99:2c:ba:25:33:21:af:28:00:11:c4:52:07:c7:46 +82:2b:5f:cd:a5:8f:82:3d:04:f9:95:85:a4:8c:25:90 +82:2e:bc:f6:19:6e:2d:9a:64:03:d5:8c:5b:d7:ee:dd +82:30:b6:73:69:da:fd:2d:1f:e0:b1:d2:43:f0:34:ee +82:65:1e:0b:5d:1b:65:36:b2:ce:69:7a:c3:3a:f7:b1 +82:67:45:b5:15:e8:f5:c2:8f:f4:fe:03:aa:f1:3a:b0 +83:4b:60:2e:df:3a:4a:57:8c:ba:be:04:72:b3:a3:f0 +83:7b:11:8c:3f:bb:e9:a4:45:04:a4:06:c5:e0:73:92 +83:e9:4a:a9:77:8d:4f:44:f9:ff:34:e1:a3:4d:9e:44 +83:f5:b2:4d:31:b0:49:79:bd:ed:44:c0:58:57:82:a8 +85:57:57:9a:27:3f:00:f4:d1:bb:6f:ab:ef:d4:f2:a0 +85:af:1e:99:bf:43:07:b9:c1:af:cc:c8:6e:da:1f:4c +87:f6:f1:76:a0:f0:cb:19:94:b7:ad:1f:f8:9b:72:cc +88:2d:c3:e4:b6:54:10:eb:7d:0b:9e:e5:30:3a:0c:cb +88:30:17:27:46:38:31:88:ae:2d:20:79:ba:c7:3b:19 +88:51:e5:72:ba:24:d9:79:12:55:99:f0:9f:b0:81:c2 +89:7b:9e:8b:18:d4:87:f8:e3:0a:15:fd:c5:46:86:66 +89:c7:56:d2:b8:98:86:a4:be:f2:e1:ca:14:ae:bf:82 +89:fe:6f:a0:ec:98:85:69:16:1a:3a:40:d2:96:75:03 +8b:ea:07:e7:63:29:e7:86:8c:2a:9c:1d:1b:c6:f0:4a +8c:2f:0f:53:17:49:54:9e:91:2b:be:ff:2b:5a:2c:24 +8c:a9:e4:54:05:5f:eb:7e:51:01:86:d0:38:6f:44:ad +8c:e7:4e:7d:12:72:51:00:2d:62:52:7a:01:26:7e:c0 +8d:15:06:83:38:b3:62:32:a0:24:d2:3e:38:83:0f:c1 +8d:5f:8d:d0:65:66:32:37:7e:88:e8:c0:b1:46:70:be +8d:f8:e9:d2:c6:04:69:44:70:cd:2a:b5:a5:08:b2:ec +8e:0f:75:96:b5:fa:c6:48:88:64:cb:da:a1:6e:99:e1 +8e:26:ab:7a:ba:28:b1:f1:14:f8:24:53:6c:bd:c1:16 +8e:2b:3b:25:a1:0d:29:00:a1:be:3f:92:ce:cc:bf:a3 +8e:35:0b:f7:b3:b6:cb:70:f2:c3:91:a9:53:a3:7a:7a +8e:3a:95:69:74:92:6f:22:51:a1:13:38:71:a3:92:ba +8f:8e:bf:ca:e8:96:c0:f5:d6:49:65:8f:21:94:b6:4d +8f:db:2a:23:13:fb:b0:8d:5b:d2:97:88:bc:8b:65:c4 +90:99:41:bc:8a:b6:fa:10:67:28:cd:4b:32:71:86:ba +92:7b:a0:41:28:49:4d:c4:de:c4:39:e2:b9:a9:80:c0 +93:53:5d:0c:3f:c4:61:3d:12:1c:94:78:69:6d:c8:b3 +93:ce:82:a8:ca:1a:52:f4:a2:bd:3d:87:44:30:bd:b8 +94:b3:79:3e:6f:79:8d:4c:56:43:93:57:06:d5:e6:72 +94:b6:86:e2:99:6a:b0:78:2d:4c:04:eb:c4:7b:df:a8 +94:fc:07:72:4e:85:fb:eb:f5:fd:26:63:41:39:12:84 +95:3a:f1:45:11:c9:1a:f0:6b:c3:aa:8d:e2:8c:af:6c +95:c2:c5:10:e8:32:01:ba:15:1e:77:24:06:2c:5a:76 +95:c5:02:66:c0:1a:a0:0e:f5:d9:47:bf:73:f7:ba:5f +95:f8:83:50:50:57:30:05:4c:95:41:a9:3f:35:be:1a +96:ee:a9:c9:98:f3:97:a5:8d:39:36:28:33:b7:25:6b +97:ee:a2:8e:aa:37:50:fc:b2:57:a3:df:99:57:be:b7 +98:a9:7d:15:e8:3e:aa:7b:74:b9:0f:ac:84:a3:ca:fc +99:2e:1d:83:ac:1c:51:04:1d:be:9c:7c:1b:ff:67:b7 +99:b4:32:76:56:83:2b:80:32:1d:87:a6:b7:9d:1e:83 +9a:15:c9:31:07:f5:73:fb:ec:06:25:14:34:dd:b4:57 +9a:1d:26:28:1e:89:2c:a8:27:3c:9d:33:ce:96:ac:55 +9a:6e:b7:09:ab:d4:c2:77:96:36:e8:dc:32:eb:6a:ca +9a:74:47:53:6d:4f:c5:c7:37:55:15:9a:2f:45:f2:82 +9a:a0:f3:7d:fb:27:b7:18:ec:36:46:9b:c1:d3:ef:ab +9b:8d:34:6a:60:93:98:fc:29:58:71:f3:7b:ed:de:c0 +9b:c2:a1:df:3a:2e:f3:7d:2e:a3:31:6f:d6:9c:d9:41 +9c:06:81:a0:b0:4d:57:fd:b1:88:fa:bc:fc:24:4a:41 +9d:1f:16:4a:09:39:e0:7f:9a:2f:ee:ce:a1:74:31:b3 +9d:a5:0d:73:a8:26:88:3b:d2:ba:fd:ba:e2:a1:25:9a +9d:d7:43:41:66:e9:dd:23:15:80:91:6f:52:e3:78:ca +9e:36:98:9b:77:61:17:a8:59:8a:66:36:75:c5:fb:22 +a0:1b:f0:49:00:e6:dd:e2:8e:17:44:bd:2f:af:04:b6 +a0:29:d8:55:29:66:23:1c:a0:40:59:ff:28:10:a9:13 +a0:37:3f:4c:cc:bf:cc:97:79:a7:25:a5:fe:c5:e0:a7 +a0:7e:dc:3f:58:c1:cd:c5:19:fb:de:b9:08:a5:3f:44 +a0:91:da:8a:f9:4f:0e:77:c3:58:21:30:a3:47:20:56 +a0:bc:c9:19:2a:a6:a9:b0:02:a5:0b:3e:ee:74:1e:13 +a0:c4:e4:bb:1c:5f:92:00:98:6c:52:fc:42:43:e9:b4 +a1:40:55:a0:62:00:16:3d:95:32:2e:cf:56:02:b0:7e +a1:ac:54:8f:43:4b:a3:36:93:1d:b1:a2:bc:14:37:53 +a2:7d:01:e4:b1:fa:f4:74:59:e3:72:25:52:9e:94:98 +a3:1b:23:8d:ce:a0:b0:46:c7:f4:9e:19:c3:55:b8:ad +a3:47:cd:e5:01:6d:4e:75:47:1d:8a:15:c8:47:6f:60 +a3:50:67:5c:a0:24:b1:3b:17:0f:2a:23:d4:fe:f4:03 +a4:4b:7c:19:b6:a5:45:2a:fe:1d:6b:a7:46:e8:93:56 +a4:be:df:16:dc:07:93:53:58:8c:05:0a:6c:7e:fd:a7 +a5:64:7a:6e:d7:0d:28:86:98:29:50:1b:7d:e3:fc:15 +a5:d4:65:30:dd:6b:c0:bb:b7:2e:b6:bf:1e:e2:79:9c +a6:9f:f8:2d:e2:53:a8:88:30:b9:45:c0:15:2d:3e:fa +a7:e0:e6:87:03:fe:09:a0:c4:00:aa:e2:ca:32:56:1b +a8:28:28:4d:36:04:f1:ff:ec:aa:a3:ae:08:0c:ed:75 +aa:c5:d3:08:34:21:df:6e:1f:05:7f:c3:7d:ff:37:67 +aa:ca:ab:94:45:b4:c4:3e:f3:0f:af:a2:b6:3c:7e:1b +aa:e7:af:b6:bf:6c:a6:bd:e8:22:6c:9f:78:9e:aa:24 +aa:f3:39:39:58:2b:61:ad:e8:d3:7a:f2:d2:e9:dd:7a +ab:06:a7:41:12:7a:05:43:c1:41:ec:c5:bb:93:35:42 +ab:75:cb:f0:35:4e:79:6e:6e:1c:1c:d4:43:9e:17:96 +ac:fc:e7:c9:89:49:cc:a2:a1:d1:34:bc:e7:ec:b3:41 +ad:16:c9:69:58:ea:04:4a:de:d5:a4:89:1f:fc:67:0c +ad:7e:66:ea:0f:3a:d9:1d:9b:73:4d:66:a1:78:94:23 +ad:9d:8d:d9:4f:75:d3:25:10:b2:5a:01:82:8b:94:8a +ad:ff:86:0f:b8:ec:2f:e3:a1:fe:ea:0a:50:9f:0d:2c +ae:75:ea:cf:c1:35:35:91:fb:1c:98:61:70:04:bb:8d +af:18:f2:d3:ce:4c:9b:ab:08:17:b4:21:0e:25:a9:c2 +af:57:2c:11:a2:13:3d:b2:07:a5:35:18:74:3f:69:7f +af:75:63:0b:6f:9e:73:f2:fd:a7:96:3f:cb:94:b0:a2 +af:91:d8:39:8a:3d:18:83:2b:8e:86:29:56:2f:b0:c1 +b0:73:6d:c2:a7:68:cd:fd:90:d4:b3:3f:a3:81:94:7b +b0:81:a5:6d:b1:7c:f4:d9:4b:36:66:0a:e4:fd:93:d8 +b0:90:da:33:e9:f4:7b:89:49:91:86:a0:34:95:4e:12 +b1:6f:df:5c:86:f9:c8:1b:5d:d6:3a:a6:01:81:f0:e4 +b1:86:b0:d1:ed:34:d4:bf:af:ca:bf:d3:2f:59:bc:92 +b2:69:82:2f:25:48:bb:fc:62:c7:9a:de:41:42:13:55 +b3:36:05:ea:e3:37:b8:32:c7:0a:f4:e1:54:de:85:f0 +b3:67:0b:de:16:bd:e8:2f:00:82:f7:7f:5e:bb:e7:c5 +b3:b2:90:80:10:61:de:9b:3d:7e:01:51:a1:00:f3:7d +b4:ac:a8:4b:7a:c0:bc:5f:0f:b0:c5:33:aa:3e:b5:d2 +b5:21:b3:41:09:72:79:b6:83:c7:37:19:3b:4f:44:d7 +b5:55:f0:96:fd:d7:e9:ab:87:b3:47:95:d1:d6:34:8c +b6:15:96:b7:44:b6:e8:f7:5b:de:e6:ba:71:87:5b:3b +b6:e4:c1:93:02:07:d1:7b:3f:22:1b:27:c3:f8:db:8b +b6:e5:f7:47:5e:38:01:bb:bd:8f:ef:43:a0:66:c7:fc +ba:a8:de:48:a7:c1:0b:45:35:88:ea:2b:23:c5:7c:9a +ba:c4:bb:99:88:27:d4:f6:f7:7b:58:e4:77:78:fd:1a +bb:cb:1f:49:1f:af:b7:97:98:f0:40:bc:51:5f:79:a4 +bc:52:e6:ca:85:c7:9b:fb:88:21:90:8a:34:60:92:52 +bc:cb:98:b4:35:21:ee:2b:95:dc:47:8c:b2:18:46:ff +bd:ab:bb:36:f7:ee:27:cf:2a:f4:bf:40:0b:97:31:5d +bd:b2:8d:9f:93:43:d2:2d:ba:6a:23:30:cc:6d:0e:d6 +bd:c5:05:37:f2:fd:a1:43:67:15:de:b1:7a:60:e8:48 +bd:f3:49:83:6d:96:55:0f:e7:96:90:35:99:ee:95:5a +be:1b:13:e2:ba:c4:ae:af:7c:80:00:14:a8:f4:ce:ca +be:8b:05:76:54:72:b8:74:f2:83:41:36:43:b4:c6:d2 +be:f9:71:f4:ef:d7:8e:30:e5:a8:10:88:c8:c5:22:18 +bf:5b:39:de:d8:50:ac:22:42:4c:25:c9:dd:06:71:5a +bf:9a:57:3c:a1:73:fe:ba:49:5c:ca:01:44:10:53:54 +bf:b9:11:3d:24:51:b7:88:6d:93:07:07:1d:58:85:fe +bf:f0:05:39:00:1a:16:3a:5f:e3:09:e3:2c:49:7f:f6 +c0:cb:fd:07:33:e9:62:14:6b:fb:d5:26:54:f3:c5:0d +c1:39:f4:ae:dd:c3:61:d5:d9:d0:ad:97:5e:20:42:e8 +c1:9a:75:7e:09:b3:1a:a3:95:4f:7f:85:67:44:2b:48 +c1:ae:ec:68:a2:86:03:1b:5d:69:04:c5:85:ca:93:39 +c1:b2:88:31:97:20:de:2d:e5:32:ee:2a:49:e3:55:2a +c2:38:c4:01:68:27:81:20:a0:b6:5b:5b:bd:ec:43:ea +c2:91:17:3f:8d:10:fc:3c:d0:10:da:e2:3a:13:59:ed +c2:ae:3e:a7:a2:ab:a2:54:49:30:05:b8:6a:b9:dd:43 +c2:fe:4f:17:d1:f3:57:fe:2f:5e:1f:49:03:2f:44:51 +c3:20:31:a4:58:2c:6f:2a:5a:a8:37:90:52:91:9c:f9 +c3:6f:55:73:5f:ea:df:0a:f3:10:ce:dc:cb:5e:51:ca +c3:ac:b3:ad:0d:83:aa:21:47:cd:10:ae:b2:dd:89:f7 +c4:21:8d:35:de:1d:7d:61:b0:b6:7d:2c:dd:3c:53:52 +c4:3a:25:19:87:62:6f:b0:f8:39:3c:35:6f:37:6d:ba +c4:d1:a4:cd:0f:64:ef:ea:e6:9a:a4:7c:c3:3d:8a:1f +c4:d6:a7:16:ff:60:70:8e:4a:56:b5:14:f3:2d:c5:53 +c4:fe:cb:8c:35:63:0c:df:a9:8e:a2:6e:47:d1:be:22 +c5:07:24:6e:9c:05:33:42:b0:ab:9e:4e:7b:21:da:48 +c5:60:9c:5c:0b:ed:c1:7a:b4:7e:9e:13:a1:0c:2d:c1 +c5:a4:31:76:ec:41:c3:0a:c5:82:66:96:71:fe:cd:b5 +c6:06:2d:09:88:a0:28:23:45:49:98:5f:eb:64:94:4f +c6:29:b8:06:1e:98:3b:ac:48:4e:5c:80:4e:ac:b0:9e +c6:30:27:20:6e:28:01:86:9f:d5:cd:0a:11:39:0c:14 +c7:37:f4:02:c4:05:e0:76:a1:b8:43:54:9e:8e:6c:85 +c7:c7:29:68:c4:0a:2b:2f:05:1f:d1:27:75:44:3d:f1 +c8:23:ea:d9:6e:a3:aa:88:de:81:d9:78:9b:2c:c7:fc +c8:2a:69:78:1d:43:46:7c:8a:e6:03:5e:a4:a2:5d:8d +c9:2d:0d:c3:b7:5f:31:73:1c:ee:08:44:12:49:5b:fc +c9:4e:95:21:03:3c:db:32:57:dd:0a:56:bd:b8:dc:c4 +c9:67:4f:17:4d:74:58:1b:b0:62:f3:88:b2:8a:f6:95 +ca:bf:3e:e2:7e:04:89:2f:22:b4:df:70:ea:09:2a:67 +cc:73:bb:df:1d:8b:ff:aa:32:37:d9:87:e7:3f:c1:c1 +cc:76:5f:3b:00:39:d3:89:9a:f4:e1:eb:01:3f:7c:d3 +cd:a8:0b:95:c8:a3:3b:df:15:ff:8f:5f:d1:91:27:9e +cd:fa:c2:73:da:2c:e6:1f:39:cb:1f:83:d9:96:2a:f0 +ce:a5:ac:7e:2e:a5:e6:53:9f:1c:f3:66:ae:bf:de:65 +ce:a7:d9:f1:b2:e9:d3:44:da:0e:b4:c6:3f:31:64:44 +cf:1d:19:7c:2f:35:b5:76:c6:76:dc:b0:fc:aa:dd:57 +cf:dc:13:cf:5e:60:74:38:f5:0c:64:2d:ba:35:e3:ed +d0:04:d3:8e:f0:f1:18:58:61:02:94:17:04:69:82:54 +d0:ef:0c:62:38:d9:4c:48:a7:ea:a6:54:90:82:dc:ab +d2:69:3f:c5:77:8d:6d:9d:06:47:4b:8f:7c:5f:98:6d +d4:3a:a8:99:e2:fb:e7:c5:5b:89:d9:f2:30:66:d6:6a +d5:bd:86:b0:93:96:42:9d:ef:f5:6e:5a:b2:5a:1a:82 +d6:20:9e:0e:55:d9:ea:3d:4a:41:ef:c8:08:d2:ba:20 +d6:92:21:4b:04:3b:22:f5:ee:85:0a:63:bf:b3:fe:9b +d6:ac:83:bd:60:ca:5d:c7:de:28:af:e7:23:6a:32:aa +d8:5c:5e:a2:46:cb:ca:75:cf:25:2c:a2:30:a6:3a:28 +d8:bc:92:66:15:6e:ba:10:27:9b:20:e8:00:16:8d:01 +d8:f7:67:ba:88:42:a4:9f:82:89:08:7f:4f:2f:d1:7a +d9:60:88:5c:c5:75:1b:ca:35:37:49:e0:e4:4a:16:40 +d9:99:f4:ef:47:03:06:50:59:b0:fb:7b:e1:9a:6a:48 +d9:a3:ab:3d:70:3b:17:05:7b:1f:31:c8:1b:00:22:59 +d9:b8:23:c6:ad:1c:23:bc:af:e8:46:f9:aa:06:bb:c1 +d9:ea:33:14:7a:cb:9f:85:0e:80:2d:b0:26:23:5b:26 +da:1c:39:e0:e8:2d:92:eb:48:89:35:5c:2e:bc:fb:e3 +da:47:7e:9e:9d:24:d9:c2:43:f1:07:e9:62:8b:79:f5 +da:72:2b:e5:5e:ad:14:60:58:ea:65:15:fa:ca:3c:a7 +db:72:a1:11:3d:bd:b4:c3:b1:5c:54:a6:02:a1:30:46 +dc:32:3a:ed:50:e9:d2:eb:8b:96:60:5d:3d:65:68:1f +dc:40:6b:2b:2c:06:b3:2c:61:fb:61:25:ed:2e:4c:c0 +dc:88:4b:c9:1f:74:b9:6f:c0:6c:00:69:46:5d:80:ee +dc:da:ab:82:6e:35:9f:df:44:32:2c:30:17:97:e5:72 +df:cb:ba:fe:21:32:41:0a:b4:a6:c9:bd:90:b6:61:6b +e0:26:f2:cd:ac:af:8b:08:ce:11:94:84:7c:ae:f9:32 +e0:7a:45:6f:19:ac:69:86:e4:7d:64:92:15:9e:ce:2d +e0:a7:80:40:8f:be:e6:ae:13:7c:f3:bb:08:0f:22:7a +e2:1f:e5:f5:f0:f9:dc:cd:83:44:c7:b7:4e:ab:06:32 +e2:47:7f:8e:1c:14:f9:dc:b8:81:1f:f5:58:f3:b6:d5 +e2:99:f4:ff:85:95:5a:5d:50:2e:42:d1:d2:65:40:38 +e3:a2:f0:47:f1:a7:bd:3b:07:0c:fb:82:e1:9f:6e:43 +e3:fb:64:9f:68:d6:3f:fa:1a:17:cd:51:3e:56:70:04 +e5:2e:ca:45:83:73:d6:39:64:1a:0e:26:56:68:47:22 +e6:d9:f4:b0:08:68:54:34:58:78:5d:b6:f1:cf:58:27 +e7:5b:88:f9:81:62:7b:5a:77:f1:69:7d:70:99:62:4f +e7:d5:94:31:00:97:9e:78:be:e0:07:b2:55:47:f0:08 +e7:dd:29:a1:dc:72:d6:89:33:c5:d7:e8:c6:97:18:67 +e9:09:87:1b:45:9d:f4:08:f3:de:f0:9c:b8:4d:e6:1f +ea:69:7a:b9:d2:ae:ac:32:73:2c:28:39:da:f7:6c:e0 +ea:f1:08:a0:6e:29:87:9d:61:66:97:3e:63:90:2e:d1 +ea:f5:52:98:b3:1f:c2:c8:4c:50:b7:ad:b5:f6:48:de +eb:05:63:fb:41:e1:f6:b7:85:97:e8:3f:62:a8:49:14 +eb:ad:4e:1d:84:9a:28:26:8f:1d:39:f3:c3:a0:4d:15 +eb:e7:fe:a2:56:82:df:51:a6:78:9f:15:56:60:84:40 +eb:f6:6f:e1:02:3b:ce:58:33:e0:c1:25:d6:0c:1f:f3 +ec:50:30:97:7e:f2:32:b1:c8:2f:34:4c:fe:08:27:9d +ed:20:b7:8d:42:21:50:6c:bc:f4:29:ca:a6:3a:cf:46 +ed:92:f8:b9:66:72:bd:13:35:56:81:ea:dd:b6:27:06 +ed:c2:94:f6:22:bb:73:75:28:e8:15:c4:25:88:c3:da +ef:36:9d:65:68:c9:b3:3c:97:8d:8e:fe:e3:85:96:e0 +ef:4e:1a:5c:7e:e5:64:34:5c:0b:be:74:87:38:5b:00 +ef:67:01:08:80:a6:2f:78:78:1f:28:5c:a9:ec:ca:04 +ef:72:c1:69:4d:46:57:e1:11:b5:30:89:f6:19:71:7c +f0:7d:6f:d9:43:c6:82:fd:43:38:31:f7:90:fc:6d:50 +f0:95:7d:70:82:5c:61:a0:b6:cb:52:1a:1e:9e:48:2c +f0:d7:3a:8b:2c:96:40:6e:7f:c8:18:15:50:8f:77:9c +f2:04:f8:b4:51:ea:ba:78:78:7e:de:31:23:ab:0c:d8 +f2:4c:b3:0f:c8:37:3d:41:52:0f:ba:b5:da:1a:d0:da +f2:b9:20:c8:1a:da:d3:a3:51:49:13:56:a4:4a:8c:83 +f3:5c:f6:c2:4d:d2:64:e0:66:77:e6:25:7a:20:62:d1 +f3:64:59:8d:a4:b8:ca:da:a8:46:1d:c4:d6:f0:46:6f +f3:cc:e8:24:50:56:d5:07:5f:b0:32:00:57:fc:fa:c0 +f3:e6:80:aa:25:f3:e6:1a:85:26:4e:a0:a4:fb:c3:78 +f4:81:fe:4d:42:f3:69:c3:0a:1f:05:82:20:e2:3e:dd +f5:05:c6:cd:cd:fb:49:b1:f7:c9:73:36:d2:5f:43:89 +f5:f6:25:03:16:7c:46:a4:40:91:ea:9f:27:75:63:b7 +f6:3c:78:64:ba:7c:3a:9a:75:86:86:6c:fe:2e:e3:17 +f6:97:2d:6a:7a:6a:25:ab:d5:ab:3d:2b:b6:23:67:53 +f6:9d:76:e1:1b:31:0a:3b:9a:06:95:bc:13:6a:e6:13 +f8:a2:e7:eb:55:a2:59:da:d1:e9:ee:26:4d:d2:7e:c5 +f9:98:93:1b:f9:d7:6b:12:ef:ac:64:0d:e3:f4:00:26 +fa:00:ad:3e:4a:69:72:da:bc:f0:36:21:73:70:57:01 +fa:69:86:20:03:78:c9:64:d8:18:18:25:b5:b5:23:ea +fa:84:e1:cc:df:f5:e0:0f:2b:5e:87:f6:c6:fb:ad:31 +fa:95:94:fa:66:5e:45:52:f7:6d:69:df:47:71:69:3b +fa:e7:29:c6:36:53:99:f7:cb:23:7d:92:9e:45:09:5a +fa:ef:2f:ae:01:91:4f:c3:bd:76:36:ac:f0:24:67:77 +fb:67:7c:e2:a3:8b:30:1c:19:2e:83:12:7a:99:63:12 +fb:a5:24:fd:a4:b0:19:d4:2f:a2:9c:21:40:ef:dd:ad +fc:02:65:ae:b4:8a:d6:64:05:7c:2d:53:11:7c:a0:e0 +fc:09:1e:1d:6c:9d:82:b0:fd:89:a9:78:45:e9:e0:bd +fc:cb:23:aa:46:7d:93:7f:e2:97:ce:b5:fe:aa:da:15 +fc:eb:1b:fb:50:fe:da:2e:47:e6:fd:16:5e:b6:ed:35 +fd:82:6b:62:dc:be:29:f0:eb:86:ea:d3:83:96:aa:30 +fd:b3:81:5a:44:67:8b:cc:a0:af:3c:36:22:79:c5:7e +fe:07:a4:38:40:77:0f:8e:64:bd:21:a0:89:1e:cb:e9 +fe:23:28:25:44:81:de:d5:e2:f5:d8:3e:99:1b:7d:3e +fe:40:71:ce:55:65:e6:f8:77:74:dd:28:5d:0a:d4:05 +fe:44:16:c2:34:62:80:df:80:74:86:29:2e:77:db:13 +ff:2f:b9:d0:a0:01:9d:c7:a2:6c:83:81:c2:2e:4c:ae diff --git a/test/bin/ghe-gen-fake-ssh-tar b/test/bin/ghe-gen-fake-ssh-tar new file mode 100755 index 000000000..163711178 --- /dev/null +++ b/test/bin/ghe-gen-fake-ssh-tar @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -x +# Add a custom ssh key that will be used as part of the backup and fingerprint injection for the tests +cat < "$GHE_REMOTE_DATA_USER_DIR/common/ssh_host_dsa_key.pub" +ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils +EOF + +tar -cf - -C "$GHE_REMOTE_DATA_USER_DIR/common" ssh_host_dsa_key.pub +set +x diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index cdc024a87..f7eef9b61 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -456,3 +456,42 @@ begin_test "ghe-backup stores version when not run from a clone" [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] ) end_test + +begin_test "ghe-backup with leaked SSH host key detection for current backup" +( + set -e + + SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) + # Inject the fingerprint into the blacklist + echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" + + # Re-link ghe-export-ssh-keys to generate a fake ssh + unlink "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" + cd "$ROOTDIR/test/bin" + ln -s ghe-gen-fake-ssh-tar ghe-export-ssh-host-keys + cd - + + # Run it + output=$(ghe-backup -v) + + # Set the export ssh link back + unlink "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" + cd "$ROOTDIR/test/bin" + ln -s ghe-fake-export-command ghe-export-ssh-host-keys + cd - + + # Test the output for leaked key detection + echo $output| grep "The current backup contains leaked SSH host keys" + +) +end_test + +begin_test "ghe-backup with no leaked keys" +( + set -e + + # Make sure there are no leaked key messages + ! ghe-backup -v | grep "Leaked key" + +) +end_test diff --git a/test/test-ghe-detect-leaked-ssh-keys.sh b/test/test-ghe-detect-leaked-ssh-keys.sh new file mode 100644 index 000000000..24a21c2a4 --- /dev/null +++ b/test/test-ghe-detect-leaked-ssh-keys.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# ghe-detect-leaked-ssh-keys command tests + +# Bring in testlib +ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +. $ROOTDIR/test/testlib.sh + + +# Add some fake repositories to the snapshot +mkdir -p "$GHE_DATA_DIR/1" + +# Make the current symlink +ln -s 1 "$GHE_DATA_DIR/current" + +# Make another backup snapshot based on 1 +cp -r "$GHE_DATA_DIR/1" "$GHE_DATA_DIR/2" + + +# Add a custom ssh key that will be used as part of the backup and fingerprint injection for the tests +cat < "$GHE_DATA_DIR/ssh_host_dsa_key.pub" +ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils +EOF + +SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) + +begin_test "ghe-detect-leaked-ssh-keys check -h dispays help message" +( + set -e + + ghe-detect-leaked-ssh-keys -h | grep "--help" +) +end_test + +begin_test "ghe-detect-leaked-ssh-keys clean snapshot test, no messages" +( + set -e + + # Test that there are no Leaked key messages + ! ghe-detect-leaked-ssh-keys | grep -q "Leaked key" +) +end_test + +begin_test "ghe-detect-leaked-ssh-keys leaked keys in current backup" +( + set -e + + # Add custom key to tar file + tar -cf "$GHE_DATA_DIR/1/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub + + # Inject the fingerprint into the blacklist + echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" + + ghe-detect-leaked-ssh-keys -s "$GHE_DATA_DIR/1" | grep "Leaked key found in current backup snapshot" +) +end_test + +begin_test "ghe-detect-leaked-ssh-keys leaked keys in old snapshot" +( + set -e + + # Add custom key to tar file in the older snapshot directory + tar -cf "$GHE_DATA_DIR/2/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub + + # Inject the fingerprint into the blacklist + echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" + + output=$(ghe-detect-leaked-ssh-keys -s "$GHE_DATA_DIR/2") + ! echo $ouput | grep -q "Leaked key in current backup" + echo $output | grep -q "One or more older backup snapshots" +) +end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index f17bc11dd..1d04b05b5 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -511,3 +511,41 @@ begin_test "ghe-restore cluster backup to non-cluster appliance" echo $output | grep -q "Snapshot from a GitHub Enterprise cluster cannot be restored" ) end_test + +begin_test "ghe-restore no leaked ssh host keys detected" +( + set -e + + # No leaked key message test + ! ghe-restore -v -f localhost | grep -q "Leaked key" +) +end_test + +begin_test "ghe-restore with current backup leaked key detection" +( + set -e + + + # Add a custom ssh key that will be used as part of the backup and fingerprint injection for the tests + cat < "$GHE_DATA_DIR/ssh_host_dsa_key.pub" +ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils +EOF + + # Add custom key to tar file + tar -cf "$GHE_DATA_DIR/current/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub + + SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) + # Inject the fingerprint into the blacklist + echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" + + # Running it and ignoring the actual script status but testing that the ssh host detection still happens + output=$(ghe-restore -v -f localhost) || true + + # Clean up, putting it back to its initial state + echo "fake ghe-export-ssh-host-keys data" > "$GHE_DATA_DIR/current/ssh-host-keys.tar" + + # Test for leaked key messages + echo $output | grep -q "Leaked key found in current backup snapshot" + echo $output | grep -q "The snapshot that is being restored contains a leaked SSH host key." +) +end_test diff --git a/test/testlib.sh b/test/testlib.sh index 0e83104c8..10f4c4e42 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -62,6 +62,11 @@ failures=0 # this runs at process exit atexit () { res=$? + + # cleanup injected test key + shared_path=$(dirname $(which ghe-detect-leaked-ssh-keys)) + sed -i '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" + [ -z "$KEEPTRASH" ] && rm -rf "$TRASHDIR" if [ $failures -gt 0 ] then exit 1 From 5ff3ed40201048d117c389eda2a6f0f1fb47d45b Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Mon, 26 Sep 2016 18:15:36 +0200 Subject: [PATCH 0049/2421] replace readlink -f with a portable approach --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 0604cab5b..d17f1c303 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -63,7 +63,7 @@ fi # Store the current backup snapshot folder if [ -L "$GHE_DATA_DIR/current" ]; then - current_dir=$(readlink -f "$GHE_DATA_DIR/current") + current_dir=$(cd "$GHE_DATA_DIR/current"; pwd -P) fi leaked_keys_found=false From a3fac8e930df318fe4a37e7b84d68fb209d28b8d Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Mon, 26 Sep 2016 18:45:59 +0200 Subject: [PATCH 0050/2421] add support for macOS Sierra ssh-keygen --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index d17f1c303..914a1c759 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -47,6 +47,11 @@ if [ -n "$ppid_script" ]; then ppid_name=$(basename $ppid_script) fi +sshkeygen_multiple_hash_formats=false +if (ssh-keygen --a-dedicated-help-flag-would-be-great 2>&1 | grep 'ssh-keygen -l ' | grep -q -- '-E'); then + sshkeygen_multiple_hash_formats=true +fi + # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config @@ -72,7 +77,11 @@ for tar_file in $ssh_tars; do for key in $keys; do if $(tar -tvf "$tar_file" $key &>/dev/null); then tar -C $TEMPDIR -xvf "$tar_file" $key &>/dev/null - fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) + if $sshkeygen_multiple_hash_formats; then + fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f2- -d':') + else + fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) + fi if echo "$fingerprint_blacklist" | grep -q "$fingerprint"; then leaked_keys_found=true if [ "$current_dir" == $(dirname "$tar_file") ]; then From 45afea2c98e177ae42bd87a86fc8a6f6a3cdc8ff Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Mon, 26 Sep 2016 18:59:20 +0200 Subject: [PATCH 0051/2421] cosmetic nit: even out `cut` whitespace --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 914a1c759..701dc4fc7 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -78,7 +78,7 @@ for tar_file in $ssh_tars; do if $(tar -tvf "$tar_file" $key &>/dev/null); then tar -C $TEMPDIR -xvf "$tar_file" $key &>/dev/null if $sshkeygen_multiple_hash_formats; then - fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f2- -d':') + fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f 2- -d ':') else fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) fi From d9ef9f686a9897c1f0f29a79000a24a74aaf7554 Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Mon, 26 Sep 2016 19:58:57 +0200 Subject: [PATCH 0052/2421] tighten ssh-keygen feature test --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 701dc4fc7..2452c5596 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -48,7 +48,7 @@ if [ -n "$ppid_script" ]; then fi sshkeygen_multiple_hash_formats=false -if (ssh-keygen --a-dedicated-help-flag-would-be-great 2>&1 | grep 'ssh-keygen -l ' | grep -q -- '-E'); then +if (ssh-keygen -E 2>&1 | head -1 | grep -q 'option requires an argument'); then sshkeygen_multiple_hash_formats=true fi From 08da6860eb2adcd1799592a99fcffd3cd8da8d1b Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Mon, 26 Sep 2016 19:58:57 +0200 Subject: [PATCH 0053/2421] Tighten ssh-keygen feature test --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 0604cab5b..1510942ef 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -47,6 +47,11 @@ if [ -n "$ppid_script" ]; then ppid_name=$(basename $ppid_script) fi +sshkeygen_multiple_hash_formats=false +if (ssh-keygen -E 2>&1 | head -1 | grep -q 'option requires an argument'); then + sshkeygen_multiple_hash_formats=true +fi + # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config From 1afd48c6191fc5cfbdc275a38e2ec629a1dca6c5 Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Mon, 26 Sep 2016 18:59:20 +0200 Subject: [PATCH 0054/2421] Cosmetic nit: even out `cut` whitespace --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 1510942ef..73e41742c 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -77,7 +77,11 @@ for tar_file in $ssh_tars; do for key in $keys; do if $(tar -tvf "$tar_file" $key &>/dev/null); then tar -C $TEMPDIR -xvf "$tar_file" $key &>/dev/null - fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) + if $sshkeygen_multiple_hash_formats; then + fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f 2- -d ':') + else + fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) + fi if echo "$fingerprint_blacklist" | grep -q "$fingerprint"; then leaked_keys_found=true if [ "$current_dir" == $(dirname "$tar_file") ]; then From dbbec580548b6d3f58f96d9977502c5b6045d5ff Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Mon, 26 Sep 2016 18:45:59 +0200 Subject: [PATCH 0055/2421] Add support for macOS Sierra ssh-keygen --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 73e41742c..233b883ce 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -48,7 +48,7 @@ if [ -n "$ppid_script" ]; then fi sshkeygen_multiple_hash_formats=false -if (ssh-keygen -E 2>&1 | head -1 | grep -q 'option requires an argument'); then +if (ssh-keygen --a-dedicated-help-flag-would-be-great 2>&1 | grep 'ssh-keygen -l ' | grep -q -- '-E'); then sshkeygen_multiple_hash_formats=true fi @@ -78,7 +78,11 @@ for tar_file in $ssh_tars; do if $(tar -tvf "$tar_file" $key &>/dev/null); then tar -C $TEMPDIR -xvf "$tar_file" $key &>/dev/null if $sshkeygen_multiple_hash_formats; then +<<<<<<< HEAD fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f 2- -d ':') +======= + fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f2- -d':') +>>>>>>> a3fac8e... add support for macOS Sierra ssh-keygen else fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) fi From 859dec3a40b313b3c88b30f4c4d655a7a40e9462 Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Mon, 26 Sep 2016 18:15:36 +0200 Subject: [PATCH 0056/2421] replace readlink -f with a portable approach --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 233b883ce..66391baea 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -68,7 +68,7 @@ fi # Store the current backup snapshot folder if [ -L "$GHE_DATA_DIR/current" ]; then - current_dir=$(readlink -f "$GHE_DATA_DIR/current") + current_dir=$(cd "$GHE_DATA_DIR/current"; pwd -P) fi leaked_keys_found=false From 80947c3e1b6a6d29f7dac2876a407b097766b6dc Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Thu, 29 Sep 2016 17:56:17 +0200 Subject: [PATCH 0057/2421] Fix merge conflicts --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 4 ---- 1 file changed, 4 deletions(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 66391baea..914a1c759 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -78,11 +78,7 @@ for tar_file in $ssh_tars; do if $(tar -tvf "$tar_file" $key &>/dev/null); then tar -C $TEMPDIR -xvf "$tar_file" $key &>/dev/null if $sshkeygen_multiple_hash_formats; then -<<<<<<< HEAD - fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f 2- -d ':') -======= fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f2- -d':') ->>>>>>> a3fac8e... add support for macOS Sierra ssh-keygen else fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) fi From 095473569129da1af6ef092a97c54232ac95f1ee Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Fri, 30 Sep 2016 09:07:54 +0200 Subject: [PATCH 0058/2421] Escape the dash --- test/test-ghe-detect-leaked-ssh-keys.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-detect-leaked-ssh-keys.sh b/test/test-ghe-detect-leaked-ssh-keys.sh index 54774615c..15fc6a4a7 100644 --- a/test/test-ghe-detect-leaked-ssh-keys.sh +++ b/test/test-ghe-detect-leaked-ssh-keys.sh @@ -25,7 +25,7 @@ begin_test "ghe-detect-leaked-ssh-keys check -h dispays help message" ( set -e - ghe-detect-leaked-ssh-keys -h | grep "--help" + ghe-detect-leaked-ssh-keys -h | grep "\-\-help" ) end_test From 5daf54d1b46ee3c49ebeed29b139c6c51cfb46ed Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 27 Oct 2016 06:56:11 +1100 Subject: [PATCH 0059/2421] Ignore errors from ps (#65) --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 2452c5596..9203dec57 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -42,7 +42,7 @@ while [ $# -gt 0 ]; do shift done -ppid_script=$(ps -o args= $PPID | awk '{print $2}') +ppid_script=$(ps -o args= $PPID 2>/dev/null | awk '{print $2}') if [ -n "$ppid_script" ]; then ppid_name=$(basename $ppid_script) fi From be59b44ac5d8b39529475c17b0bc8fdf697111e0 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Wed, 26 Oct 2016 15:58:28 -0400 Subject: [PATCH 0060/2421] Bump version 2.8.0 (#66) --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 860487ca1..834f26295 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.7.1 +2.8.0 From e22f68297b0630619dc356273ffa1854f9007bd0 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 27 Oct 2016 06:56:11 +1100 Subject: [PATCH 0061/2421] Ignore errors from ps --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 0604cab5b..d34911aac 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -42,7 +42,7 @@ while [ $# -gt 0 ]; do shift done -ppid_script=$(ps -o args= $PPID | awk '{print $2}') +ppid_script=$(ps -o args= $PPID 2>/dev/null | awk '{print $2}') if [ -n "$ppid_script" ]; then ppid_name=$(basename $ppid_script) fi From 49478344dec1c536bb15eac1c4ae0cbcf26e9bfb Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 8 Nov 2016 13:02:43 +0100 Subject: [PATCH 0062/2421] More portable argument parsing macOS uses Bash 3.X and argument parsing works differently in that version, breaking ghe-detect-leaked-ssh-keys. /cc @sridharavinash --- .../ghe-detect-leaked-ssh-keys | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 914a1c759..4228f91bc 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -13,30 +13,22 @@ set -e usage() { grep '^#/' < "$0" | cut -c 4- + exit 2 } TEMPDIR=$(mktemp -d) -# Parse args. -ARGS=$(getopt --name "$0" --long help,snapshot: --options hs -- "$@") || { - usage - exit 2 -} -eval set -- $ARGS - while [ $# -gt 0 ]; do case "$1" in -h|--help) usage - exit 2 ;; -s|--snapshot) - shift 2 - snapshot=$1 - ;; - --) + snapshot=$2 shift - break + ;; + *) + usage ;; esac shift @@ -61,6 +53,10 @@ keys="ssh_host_dsa_key.pub ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub ssh_h # Get all the host ssh keys tar from all snapshots directories if [ -n "$snapshot" ]; then + if [ ! -d "$snapshot" ]; then + echo "Invalid snapshot directory: $snapshot" >&2 + exit 1 + fi ssh_tars=$(find "$snapshot" -maxdepth 1 -type f -iname 'ssh-host-keys.tar') else ssh_tars=$(find "$GHE_DATA_DIR" -maxdepth 2 -type f -iname 'ssh-host-keys.tar') From 1b829e00f1ba42abdce489ff6011d24d0d6c43ee Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 9 Nov 2016 00:43:33 +0100 Subject: [PATCH 0063/2421] Don't try to use node UUIDs when GHE <= 2.7.X (#68) * Don't try to use node UUIDs when GHE <= 2.7.X Fixes https://github.com/github/enterprise2/issues/9566 * Added some comments * Fix typo --- .../ghe-restore-repositories-dgit-ng | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 31ca0d9b0..2a9dca290 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -6,6 +6,32 @@ #/ ghe-restore command when restoring into a cluster. set -e +sync_repo_info() { + # node names changed in 2.8 and `ghe-cluster-each -u` isn't available + # on GHE <= 2.7.X. We need to be backwards compatible. + if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then + for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do + if ! ghe-rsync -av --delete \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ + "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to git-server-$uuid" + fi + done + else + for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do + if ! ghe-rsync -av --delete \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ + "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to $route" + fi + done + fi +} + # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config @@ -129,15 +155,7 @@ cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore- if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" - for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do - if ! ghe-rsync -av --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to git-server-$uuid" - fi - done + sync_repo_info else ghe_verbose "* Removing repository info data" ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -- rm -f /data/repositories/info/* From 6c910749e4d2616f5d291d10964274784d2dc2f7 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Nov 2016 17:37:27 +1100 Subject: [PATCH 0064/2421] Stop cron and timerd during restore --- bin/ghe-restore | 20 ++++++++++++++++++++ test/bin/service | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 test/bin/service diff --git a/bin/ghe-restore b/bin/ghe-restore index 9bd19f76c..6310857df 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -200,6 +200,17 @@ fi ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." +# Stop cron and timerd, as scheduled jobs may disrupt the restore process. +if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + if $cluster; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop" + else + ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop" + ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop" + fi +fi + # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. if $restore_settings; then @@ -323,6 +334,15 @@ elif $instance_configured; then fi fi +# Start cron. Timerd will start automatically as part of the config run. +if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + if $cluster; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" + else + ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" + fi +fi + # Update the remote status to "complete". This has to happen before importing # ssh host keys because subsequent commands will fail due to the host key # changing otherwise. diff --git a/test/bin/service b/test/bin/service new file mode 100644 index 000000000..12c98b95f --- /dev/null +++ b/test/bin/service @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Fake service command for tests. +true From 389c2c15d07bdb1682ff348f3a4e24837c274fee Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Nov 2016 18:38:36 +1100 Subject: [PATCH 0065/2421] Update restore status on cluster nodes --- bin/ghe-restore | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 9bd19f76c..54e059eed 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -77,19 +77,6 @@ GHE_BACKUP_STRATEGY=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/strategy") # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" -# Keep other processes on the VM in the loop about the restore status. -# -# Other processes will look for these states: -# "restoring" - restore is currently in progress -# "failed" - restore has failed -# "complete" - restore has completed successfully -update_restore_status () { - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - echo "$1" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' 2>/dev/null" - fi -} - # Figure out if this instance has been configured or is entirely new. instance_configured=false if ghe-ssh "$GHE_HOSTNAME" -- \ @@ -167,6 +154,24 @@ fi echo "Starting restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNAPSHOT ..." +# Keep other processes on the VM or cluster in the loop about the restore status. +# +# Other processes will look for these states: +# "restoring" - restore is currently in progress +# "failed" - restore has failed +# "complete" - restore has completed successfully +update_restore_status () { + if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + if $cluster; then + echo "set -o pipefail; ghe-cluster-each -- \"echo '$1' | sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | + ghe-ssh "$GHE_HOSTNAME" /bin/bash + else + echo "$1" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" + fi + fi +} + # Update remote restore state file and setup failure trap trap "update_restore_status failed" EXIT update_restore_status "restoring" From 89675272b61326561e936808467a91e31fbfaee1 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Nov 2016 18:55:45 +1100 Subject: [PATCH 0066/2421] Set +x on fake service command --- test/bin/service | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/bin/service diff --git a/test/bin/service b/test/bin/service old mode 100644 new mode 100755 From 90217608190fe2d8441089bbba5ce6e83f8278da Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 9 Nov 2016 13:09:47 +0100 Subject: [PATCH 0067/2421] echo errors to stderr --- share/github-backup-utils/ghe-restore-repositories-dgit-ng | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 2a9dca290..488351277 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -16,7 +16,7 @@ sync_repo_info() { --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to git-server-$uuid" + echo "Error restoring /data/repositories/info to git-server-$uuid" 1>&2 fi done else @@ -26,7 +26,7 @@ sync_repo_info() { --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to $route" + echo "Error restoring /data/repositories/info to $route" 1>&2 fi done fi From 3ba0418adb7fe10f6ee1f2ef26e5382cdb29b5e8 Mon Sep 17 00:00:00 2001 From: Mutwin Kraus Date: Thu, 11 Aug 2016 13:23:18 +0200 Subject: [PATCH 0068/2421] UUID nodenames * Use uuid hostnames for dgit, alambic, pages and gists replicas if uuids are configured * Move cluster hostname detection into ghe-cluster-hostnames --- .../github-backup-utils/ghe-cluster-hostnames | 31 +++++++++++++++++++ .../ghe-restore-alambic-cluster-ng | 3 +- .../ghe-restore-pages-dpages | 3 +- .../ghe-restore-repositories-dgit-ng | 8 ++--- .../ghe-restore-repositories-gist-ng | 3 +- 5 files changed, 38 insertions(+), 10 deletions(-) create mode 100755 share/github-backup-utils/ghe-cluster-hostnames diff --git a/share/github-backup-utils/ghe-cluster-hostnames b/share/github-backup-utils/ghe-cluster-hostnames new file mode 100755 index 000000000..32643d976 --- /dev/null +++ b/share/github-backup-utils/ghe-cluster-hostnames @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +#/ Usage: ghe-cluster-hostnames +#/ +#/ Finds all nodes of the cluster using the config on . +#/ If it is a 2.8 cluster the results are returned as prefix-uuid, +#/ otherwise the configured hostnames are returned. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore-* commands when restoring into a cluster. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +GHE_HOSTNAME="$1" +prefix="$2" + +if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) + hostnames='' + for uuid in $node_uuids; do + hostnames+="$prefix-$uuid " + done +else + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) +fi + +echo "$hostnames" diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 675167cb9..2794737d0 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -44,8 +44,7 @@ user="${host%@*}" # Generate SSH config for forwarding config="" -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -for hostname in $hostnames; do +for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server"); do config="$config Host $hostname ServerAliveInterval 60 diff --git a/share/github-backup-utils/ghe-restore-pages-dpages b/share/github-backup-utils/ghe-restore-pages-dpages index 581c7f570..4014e80df 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages +++ b/share/github-backup-utils/ghe-restore-pages-dpages @@ -45,8 +45,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -for hostname in $hostnames; do +for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "pages-server"); do config="$config Host $hostname ServerAliveInterval 60 diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 651f3e63a..31ca0d9b0 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -46,7 +46,7 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") for hostname in $hostnames; do echo " Host $hostname @@ -129,13 +129,13 @@ cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore- if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" - for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do + for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do if ! ghe-rsync -av --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to $route" + "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to git-server-$uuid" fi done else diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 05c6f0b64..d68d3a2ac 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -46,8 +46,7 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -for hostname in $hostnames; do +for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server"); do echo " Host $hostname ServerAliveInterval 60 From 7f27d764dadca5be9fa8680831a88901ae6722dc Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Fri, 26 Aug 2016 10:04:32 -0400 Subject: [PATCH 0069/2421] Fix hostname discovery Mostly bug fixes. * Fix hostname discovery by using the new scripts that introduced the uuid git-server names * Fixing the special directories rsync paths * Added some minor comments and also benchmark stats for the special directories sync --- share/github-backup-utils/ghe-backup-repositories-cluster-ng | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index f578c56c7..5edd7d1d4 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -74,7 +74,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # git server hostnames -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") for hostname in $hostnames; do config="$config Host $hostname @@ -171,7 +171,6 @@ rsync_repository_data () { "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ "$backup_dir" 1>&3 fi - } sync_data (){ @@ -356,7 +355,6 @@ RULES done bm_end "$(basename $0) - Special Data Directories Sync" - bm_start "$(basename $0) - Archived Repos" ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-archived-repos-routes \ | while read route; do From 77564250cc68ba941e2756f138add5b4cd94016b Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Wed, 26 Oct 2016 15:58:28 -0400 Subject: [PATCH 0070/2421] Bump version 2.8.0 --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 860487ca1..834f26295 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.7.1 +2.8.0 From ad0ac39023547d12b2e40e0c0a64c88c33846308 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 9 Nov 2016 00:43:33 +0100 Subject: [PATCH 0071/2421] Don't try to use node UUIDs when GHE <= 2.7.X ghe-cluster-each -u isn't supported in GHE <= 2.7.X --- .../ghe-restore-repositories-dgit-ng | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 31ca0d9b0..2a9dca290 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -6,6 +6,32 @@ #/ ghe-restore command when restoring into a cluster. set -e +sync_repo_info() { + # node names changed in 2.8 and `ghe-cluster-each -u` isn't available + # on GHE <= 2.7.X. We need to be backwards compatible. + if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then + for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do + if ! ghe-rsync -av --delete \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ + "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to git-server-$uuid" + fi + done + else + for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do + if ! ghe-rsync -av --delete \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ + "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to $route" + fi + done + fi +} + # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config @@ -129,15 +155,7 @@ cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore- if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" - for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do - if ! ghe-rsync -av --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to git-server-$uuid" - fi - done + sync_repo_info else ghe_verbose "* Removing repository info data" ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -- rm -f /data/repositories/info/* From ebca53e441dbbfef6c63d7ea6f93c971cf68a431 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 19 Aug 2016 15:11:39 -0600 Subject: [PATCH 0072/2421] Always store backup-utils version --- .../github-backup-utils/ghe-backup-store-version | 7 ++++--- test/test-ghe-backup.sh | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-store-version b/share/github-backup-utils/ghe-backup-store-version index fb033d257..6148012c5 100755 --- a/share/github-backup-utils/ghe-backup-store-version +++ b/share/github-backup-utils/ghe-backup-store-version @@ -8,14 +8,15 @@ set -e bm_start "$(basename $0)" +version_info="$BACKUP_UTILS_VERSION" if [ -d $GHE_BACKUP_ROOT/.git ]; then - version_info="$BACKUP_UTILS_VERSION" ref=$(git --git-dir=$GHE_BACKUP_ROOT/.git rev-parse HEAD || true) if [ -n "$ref" ]; then version_info="$version_info:$ref" fi - echo "$version_info" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version >/dev/null 2>&1" fi +echo "$version_info" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version >/dev/null 2>&1" + bm_end "$(basename $0)" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 22b23eda1..8ea709bd0 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -476,6 +476,21 @@ begin_test "ghe-backup with no leaked keys" # Make sure there are no leaked key messages ! ghe-backup -v | grep "Leaked key" +) +end_test + +begin_test "ghe-backup stores version when not run from a clone" +( + set -e + + # Make sure this doesn't exist + rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" + + mv "$ROOTDIR/.git" "$ROOTDIR/.gittmp" + ghe-backup + mv "$ROOTDIR/.gittmp" "$ROOTDIR/.git" + # verify that ghe-backup wrote its version information to the host + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] ) end_test From d0272c0647a83a60dbfb89cbda00d48c8a651296 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 9 Nov 2016 13:09:47 +0100 Subject: [PATCH 0073/2421] Fix unwanted merge changes --- .../ghe-detect-leaked-ssh-keys | 2 +- .../ghe-restore-repositories-dgit-ng | 4 +-- test/test-ghe-backup.sh | 33 ++++++++++--------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 4228f91bc..d6ffb2e50 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -34,7 +34,7 @@ while [ $# -gt 0 ]; do shift done -ppid_script=$(ps -o args= $PPID | awk '{print $2}') +ppid_script=$(ps -o args= $PPID 2>/dev/null | awk '{print $2}') if [ -n "$ppid_script" ]; then ppid_name=$(basename $ppid_script) fi diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 2a9dca290..488351277 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -16,7 +16,7 @@ sync_repo_info() { --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to git-server-$uuid" + echo "Error restoring /data/repositories/info to git-server-$uuid" 1>&2 fi done else @@ -26,7 +26,7 @@ sync_repo_info() { --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to $route" + echo "Error restoring /data/repositories/info to $route" 1>&2 fi done fi diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 8ea709bd0..7269d3848 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -441,10 +441,26 @@ begin_test "ghe-backup fsck" ) end_test -begin_test "ghe-backup with leaked SSH host key detection for current backup" +begin_test "ghe-backup stores version when not run from a clone" ( set -e + # Make sure this doesn't exist + rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" + + mv "$ROOTDIR/.git" "$ROOTDIR/.gittmp" + ghe-backup + mv "$ROOTDIR/.gittmp" "$ROOTDIR/.git" + + # verify that ghe-backup wrote its version information to the host + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] +) +end_test + +begin_test "ghe-backup with leaked SSH host key detection for current backup" +( + set -e + SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) # Inject the fingerprint into the blacklist echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" @@ -476,21 +492,6 @@ begin_test "ghe-backup with no leaked keys" # Make sure there are no leaked key messages ! ghe-backup -v | grep "Leaked key" -) -end_test - -begin_test "ghe-backup stores version when not run from a clone" -( - set -e - # Make sure this doesn't exist - rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" - - mv "$ROOTDIR/.git" "$ROOTDIR/.gittmp" - ghe-backup - mv "$ROOTDIR/.gittmp" "$ROOTDIR/.git" - - # verify that ghe-backup wrote its version information to the host - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] ) end_test From fe2e8d7c6cef5c1c9bff0141b2cad45c52f96486 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 9 Nov 2016 15:41:29 +0100 Subject: [PATCH 0074/2421] Update debian/changelog --- debian/changelog | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index 6ea3d45d6..0c9b3e460 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +github-backup-utils (2.8.0) UNRELEASED; urgency=low + + * Adds support for GitHub Enterprise 2.8.0 + * Speedup storage restores #247 + * More portable backup-utils #260 + + -- rubiojr Wed, 09 Nov 2016 06:35:21 -0800 + github-backup-utils (2.7.1) UNRELEASED; urgency=medium * Cluster: fix offline cluster node detection #250 From 450573d9fffb36fbd21973bee9288a9a4e46791b Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Thu, 10 Nov 2016 16:10:16 -0800 Subject: [PATCH 0075/2421] Add "* No leaked keys found" Adds a message if No leaked keys are found. The current behavior is to just echo **"Checking for leaked ssh keys ..."** and then exit if no leaked keys are found. (https://github.com/github/backup-utils/blob/c299602f863b808e45f1b90e8a4ad632ffb3c7ad/bin/ghe-backup#L261). This can sometime be confusing if users are expecting output before the backup or restore process completes. --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index d6ffb2e50..f6c4cab22 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -124,6 +124,8 @@ if $leaked_keys_found; then echo "* (An upgrade may be required)" echo fi +else + echo "* No leaked keys found" fi # Cleanup temp dir From f5cfb38cb0c23c833ce6d8dc089c0c4b4b486ef1 Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Mon, 26 Sep 2016 19:58:57 +0200 Subject: [PATCH 0076/2421] Tighten ssh-keygen feature test --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index d6ffb2e50..0ed5dc7c3 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -40,7 +40,7 @@ if [ -n "$ppid_script" ]; then fi sshkeygen_multiple_hash_formats=false -if (ssh-keygen --a-dedicated-help-flag-would-be-great 2>&1 | grep 'ssh-keygen -l ' | grep -q -- '-E'); then +if (ssh-keygen -E 2>&1 | head -1 | grep -q 'option requires an argument'); then sshkeygen_multiple_hash_formats=true fi From 53b390d33fbdd264346525eca5851a548facec86 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sun, 13 Nov 2016 22:49:23 -0700 Subject: [PATCH 0077/2421] Specify backup extension The sed command in OS X requires an extension be passed when using the in-place flag. While it is possible to specify no extension, the way this is accomplished differs between the implementations. It is therefore simpler to specify a valid extension, and remove the resulting backup file immediately afterwards. --- test/testlib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 10f4c4e42..28910e403 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -65,7 +65,8 @@ atexit () { # cleanup injected test key shared_path=$(dirname $(which ghe-detect-leaked-ssh-keys)) - sed -i '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" + sed -i.bak '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" + rm -f "$shared_path/ghe-ssh-leaked-host-keys-list.txt.bak" [ -z "$KEEPTRASH" ] && rm -rf "$TRASHDIR" if [ $failures -gt 0 ] From 46d6cb2109870f4558a113e10a367a8a8172bc12 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sun, 13 Nov 2016 23:21:51 -0700 Subject: [PATCH 0078/2421] Don't remove backup file --- test/testlib.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 28910e403..50d27f824 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -66,7 +66,6 @@ atexit () { # cleanup injected test key shared_path=$(dirname $(which ghe-detect-leaked-ssh-keys)) sed -i.bak '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" - rm -f "$shared_path/ghe-ssh-leaked-host-keys-list.txt.bak" [ -z "$KEEPTRASH" ] && rm -rf "$TRASHDIR" if [ $failures -gt 0 ] From 4dcb1d0c874ee7834db7216ffae85505b8e06aff Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sun, 13 Nov 2016 23:46:14 -0700 Subject: [PATCH 0079/2421] Revert "Don't remove backup file" This reverts commit 46d6cb2109870f4558a113e10a367a8a8172bc12. --- test/testlib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/testlib.sh b/test/testlib.sh index 50d27f824..28910e403 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -66,6 +66,7 @@ atexit () { # cleanup injected test key shared_path=$(dirname $(which ghe-detect-leaked-ssh-keys)) sed -i.bak '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" + rm -f "$shared_path/ghe-ssh-leaked-host-keys-list.txt.bak" [ -z "$KEEPTRASH" ] && rm -rf "$TRASHDIR" if [ $failures -gt 0 ] From dedcf028457f5e55d413af75db452ba951f97de8 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Sun, 13 Nov 2016 23:53:33 -0700 Subject: [PATCH 0080/2421] Use Travis container infrastructure --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index adc20bd4c..37531612b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ matrix: - brew install gnu-tar script: make test - os: linux + sudo: false addons: apt: packages: devscripts From 1532d68cb38c53b3eebe1b5e920d26572b0a434a Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 14 Nov 2016 00:25:41 -0700 Subject: [PATCH 0081/2421] Remove mktemp -u invocations --- test/test-ghe-backup-config.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 8d7e20e1b..1d8170178 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -19,13 +19,13 @@ begin_test "ghe-backup-config GHE_CREATE_DATA_DIR disabled" ( set -e - export GHE_DATA_DIR=$(mktemp -d -u) + export GHE_DATA_DIR="$TRASHDIR/create-enabled-data" . share/github-backup-utils/ghe-backup-config 2>&1 \ | grep -q "Creating the backup data directory ..." test -d $GHE_DATA_DIR rm -rf $GHE_DATA_DIR - export GHE_DATA_DIR=$(mktemp -d -u) + export GHE_DATA_DIR="$TRASHDIR/create-disabled-data" export GHE_CREATE_DATA_DIR=no set +e error=$(. share/github-backup-utils/ghe-backup-config 2>&1) From e60bb748286966c9815a37757d468d0bd6fe38e2 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 14 Nov 2016 00:39:14 -0700 Subject: [PATCH 0082/2421] Add trusty container --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index 37531612b..8743059a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,3 +12,8 @@ matrix: apt: packages: devscripts script: debuild -uc -us + - os: linux + dist: trusty + sudo: false + group: beta + script: debuild -uc -us From 8fcdedc1efdcd90effed0ca2f0cea1675feae546 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 14 Nov 2016 00:48:59 -0700 Subject: [PATCH 0083/2421] Revert "Add trusty container" This reverts commit e60bb748286966c9815a37757d468d0bd6fe38e2. --- .travis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8743059a6..37531612b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,8 +12,3 @@ matrix: apt: packages: devscripts script: debuild -uc -us - - os: linux - dist: trusty - sudo: false - group: beta - script: debuild -uc -us From cc86fc8f82ec78c1da45473ef298bbddc075f459 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Nov 2016 17:37:27 +1100 Subject: [PATCH 0084/2421] Stop cron and timerd during restore --- bin/ghe-restore | 20 ++++++++++++++++++++ test/bin/service | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 test/bin/service diff --git a/bin/ghe-restore b/bin/ghe-restore index 9bd19f76c..6310857df 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -200,6 +200,17 @@ fi ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." +# Stop cron and timerd, as scheduled jobs may disrupt the restore process. +if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + if $cluster; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop" + else + ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop" + ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop" + fi +fi + # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. if $restore_settings; then @@ -323,6 +334,15 @@ elif $instance_configured; then fi fi +# Start cron. Timerd will start automatically as part of the config run. +if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + if $cluster; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" + else + ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" + fi +fi + # Update the remote status to "complete". This has to happen before importing # ssh host keys because subsequent commands will fail due to the host key # changing otherwise. diff --git a/test/bin/service b/test/bin/service new file mode 100644 index 000000000..12c98b95f --- /dev/null +++ b/test/bin/service @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Fake service command for tests. +true From b0062815f32eec93d31a3c606b65422d0ab86ff3 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Nov 2016 18:55:45 +1100 Subject: [PATCH 0085/2421] Set +x on fake service command --- test/bin/service | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/bin/service diff --git a/test/bin/service b/test/bin/service old mode 100644 new mode 100755 From 09835acd22f982cec4461318f3a7b82e9e8fe601 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 14 Nov 2016 22:07:08 +0100 Subject: [PATCH 0086/2421] Bump version: 2.8.1 Includes general improvements and bug fixes. * Stop cron and timerd during restore #266 * Fix compatibility issue with older versions of OpenSSH #263 --- debian/changelog | 7 +++++++ share/github-backup-utils/version | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 0c9b3e460..587de6472 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.8.1) UNRELEASED; urgency=medium + + * Stop cron and timerd during restore #266 + * Fix compatibility issue with older versions of OpenSSH #263 + + -- Sergio Rubio Mon, 14 Nov 2016 22:04:48 +0100 + github-backup-utils (2.8.0) UNRELEASED; urgency=low * Adds support for GitHub Enterprise 2.8.0 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 834f26295..dbe590065 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.8.0 +2.8.1 From 2e8b3fd69533904dde119120115fe97135bb6300 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 14 Nov 2016 22:30:37 +0100 Subject: [PATCH 0087/2421] Revert "Stop cron and timerd during restore" --- bin/ghe-restore | 20 -------------------- test/bin/service | 3 --- 2 files changed, 23 deletions(-) delete mode 100755 test/bin/service diff --git a/bin/ghe-restore b/bin/ghe-restore index 6310857df..9bd19f76c 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -200,17 +200,6 @@ fi ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." -# Stop cron and timerd, as scheduled jobs may disrupt the restore process. -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - if $cluster; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop" - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop" - else - ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop" - ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop" - fi -fi - # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. if $restore_settings; then @@ -334,15 +323,6 @@ elif $instance_configured; then fi fi -# Start cron. Timerd will start automatically as part of the config run. -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - if $cluster; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" - else - ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" - fi -fi - # Update the remote status to "complete". This has to happen before importing # ssh host keys because subsequent commands will fail due to the host key # changing otherwise. diff --git a/test/bin/service b/test/bin/service deleted file mode 100755 index 12c98b95f..000000000 --- a/test/bin/service +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -# Fake service command for tests. -true From 9270dd04a1541803bd28a8e1c35575f05de33a29 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 14 Nov 2016 15:30:33 -0700 Subject: [PATCH 0088/2421] Store output in a variable --- test/test-ghe-backup-config.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 1d8170178..0fa401d06 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -20,8 +20,8 @@ begin_test "ghe-backup-config GHE_CREATE_DATA_DIR disabled" set -e export GHE_DATA_DIR="$TRASHDIR/create-enabled-data" - . share/github-backup-utils/ghe-backup-config 2>&1 \ - | grep -q "Creating the backup data directory ..." + output=$(. share/github-backup-utils/ghe-backup-config 2>&1) + echo $output | grep -q "Creating the backup data directory ..." test -d $GHE_DATA_DIR rm -rf $GHE_DATA_DIR From e87182685d850adfa80c83bb14fd09e77cfb7d73 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 14 Nov 2016 15:34:31 -0700 Subject: [PATCH 0089/2421] Ignore errors when stopping and starting services (#75) --- bin/ghe-restore | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 6310857df..9c2aef137 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -202,12 +202,23 @@ echo "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + echo "Stopping cron and github-timerd ..." if $cluster; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop" - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop" + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron on one or more nodes" + fi + + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + fi else - ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop" - ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop" + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron" + fi + + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd" + fi fi fi @@ -336,10 +347,15 @@ fi # Start cron. Timerd will start automatically as part of the config run. if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + echo "Starting cron ..." if $cluster; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then + echo "* Warning: Failed to start cron on one or more nodes" + fi else - ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then + echo "* Warning: Failed to start cron" + fi fi fi From bff2a54d18c5b528ecfd82829b1a20869e977d8f Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 14 Nov 2016 15:50:34 -0700 Subject: [PATCH 0090/2421] Revert "Revert "Stop cron and timerd during restore"" This reverts commit 2e8b3fd69533904dde119120115fe97135bb6300. --- bin/ghe-restore | 20 ++++++++++++++++++++ test/bin/service | 3 +++ 2 files changed, 23 insertions(+) create mode 100755 test/bin/service diff --git a/bin/ghe-restore b/bin/ghe-restore index 9bd19f76c..6310857df 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -200,6 +200,17 @@ fi ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." +# Stop cron and timerd, as scheduled jobs may disrupt the restore process. +if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + if $cluster; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop" + else + ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop" + ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop" + fi +fi + # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. if $restore_settings; then @@ -323,6 +334,15 @@ elif $instance_configured; then fi fi +# Start cron. Timerd will start automatically as part of the config run. +if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + if $cluster; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" + else + ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" + fi +fi + # Update the remote status to "complete". This has to happen before importing # ssh host keys because subsequent commands will fail due to the host key # changing otherwise. diff --git a/test/bin/service b/test/bin/service new file mode 100755 index 000000000..12c98b95f --- /dev/null +++ b/test/bin/service @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Fake service command for tests. +true From e1363db72a308e8fd09aa4430bec7a0d883a2ef8 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 14 Nov 2016 15:34:31 -0700 Subject: [PATCH 0091/2421] Ignore errors when stopping and starting services (#75) --- bin/ghe-restore | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 6310857df..9c2aef137 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -202,12 +202,23 @@ echo "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + echo "Stopping cron and github-timerd ..." if $cluster; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop" - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop" + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron on one or more nodes" + fi + + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + fi else - ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop" - ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop" + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron" + fi + + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd" + fi fi fi @@ -336,10 +347,15 @@ fi # Start cron. Timerd will start automatically as part of the config run. if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + echo "Starting cron ..." if $cluster; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then + echo "* Warning: Failed to start cron on one or more nodes" + fi else - ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then + echo "* Warning: Failed to start cron" + fi fi fi From d0f74274ad750cbf92d2acbb74318691cc650f01 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 15 Nov 2016 10:42:28 +0100 Subject: [PATCH 0092/2421] Update the changelog --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 587de6472..848c4e3c6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,6 @@ github-backup-utils (2.8.1) UNRELEASED; urgency=medium - * Stop cron and timerd during restore #266 + * Stop cron and timerd during restore #269 * Fix compatibility issue with older versions of OpenSSH #263 -- Sergio Rubio Mon, 14 Nov 2016 22:04:48 +0100 From f1b6d10186004fb65f476806cb03e6b2ebbd03fe Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 15 Nov 2016 07:32:54 -0700 Subject: [PATCH 0093/2421] Remove unnecessary pipefail --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 54e059eed..27b2b7f89 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -163,7 +163,7 @@ ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNA update_restore_status () { if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then if $cluster; then - echo "set -o pipefail; ghe-cluster-each -- \"echo '$1' | sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | + echo "ghe-cluster-each -- \"echo '$1' | sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | ghe-ssh "$GHE_HOSTNAME" /bin/bash else echo "$1" | From 5b0c42473cdafbee59e005d36589ac16a19a2154 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 17 Nov 2016 02:32:54 -0700 Subject: [PATCH 0094/2421] Backup and restore UUID (#77) * Backup and restore uuid * Only display message when transferring * Add tests --- bin/ghe-restore | 7 +++ share/github-backup-utils/ghe-backup-settings | 4 ++ test/test-ghe-backup.sh | 22 +++++--- test/test-ghe-restore.sh | 54 ++++++++++++++++++- 4 files changed, 78 insertions(+), 9 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 9c2aef137..646959257 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -238,6 +238,13 @@ if ! $cluster; then fi fi +# Restore UUID if present and not restoring to cluster. +if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $cluster; then + echo "Restoring UUID ..." + cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" +fi + echo "Restoring MySQL database ..." bm_start "ghe-import-mysql" gzip -dc "$GHE_RESTORE_SNAPSHOT_PATH/mysql.sql.gz" | ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-mysql' diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index e98c7ae17..0982f55ce 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -51,6 +51,10 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "Error: Enterprise Cluster is not configured yet, backup will fail" >&2 exit 1 fi +else + if ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_DATA_USER_DIR/common/uuid 2>/dev/null" > uuid; then + echo "* Transferring UUID ..." 1>&3 + fi fi bm_end "$(basename $0)" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 7269d3848..31c904f7c 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -46,6 +46,9 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001" touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" + + # Create a fake UUID + echo "fake uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" fi # Create some fake elasticsearch data in the remote data directory @@ -130,9 +133,7 @@ begin_test "ghe-backup first snapshot" # verify manage-password file was backed up under v2.x VMs if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - fi - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then # verify all hookshot user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" @@ -147,6 +148,9 @@ begin_test "ghe-backup first snapshot" # verify all alambic assets user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" fi # verify that ghe-backup wrote its version information to the host @@ -213,9 +217,7 @@ begin_test "ghe-backup subsequent snapshot" # verify manage-password file was backed up under v2.x VMs if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - fi - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then # verify all hookshot user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" @@ -230,6 +232,9 @@ begin_test "ghe-backup subsequent snapshot" # verify all alambic assets user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" fi ) end_test @@ -312,9 +317,7 @@ begin_test "ghe-backup with relative data dir path" # verify manage-password file was backed up under v2.x VMs if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - fi - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then # verify all hookshot user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" @@ -329,6 +332,9 @@ begin_test "ghe-backup with relative data dir path" # verify all alambic assets user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" fi # verify that ghe-backup wrote its version information to the host @@ -459,8 +465,8 @@ end_test begin_test "ghe-backup with leaked SSH host key detection for current backup" ( - set -e - + set -e + SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) # Inject the fingerprint into the blacklist echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 1e9c392ff..003db96f3 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -19,8 +19,8 @@ mkdir -p gh-enterprise-es/node/0 touch gh-enterprise-es/node/0/stuff1 touch gh-enterprise-es/node/0/stuff2 -# Create some fake hookshot data in the remote data directory if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + # Create some fake hookshot data in the remote data directory mkdir -p "$GHE_DATA_DIR/1/hookshot" cd "$GHE_DATA_DIR/1/hookshot" mkdir -p repository-123 repository-456 @@ -50,6 +50,9 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then mkdir -p "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001" touch "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" + + # Create a fake uuid + echo "fake uuid" > "$GHE_DATA_DIR/1/uuid" fi # Add some fake repositories to the snapshot @@ -145,6 +148,9 @@ begin_test "ghe-restore into configured vm" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" fi ) end_test @@ -279,6 +285,9 @@ begin_test "ghe-restore -c into unconfigured vm" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" fi ) end_test @@ -344,6 +353,9 @@ begin_test "ghe-restore into unconfigured vm" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + # verify no config run after restore on unconfigured instance ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" fi @@ -396,6 +408,9 @@ begin_test "ghe-restore with host arg" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" fi ) end_test @@ -485,6 +500,43 @@ begin_test "ghe-restore with tarball strategy" ) end_test +begin_test "ghe-restore with empty uuid file" +( + set -e + + # Remove the UUID from the remote instance + rm -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # Zero-length the UUID file + cat /dev/null > "$GHE_DATA_DIR/current/uuid" + + # Run a restore + ghe-restore -v -f localhost + + # Verify no uuid is restored + [ ! -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" ] + +) +end_test + +begin_test "ghe-restore with no uuid file" +( set -e + + # Remove the UUID from the remote instance + rm -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # Remove the UUID file + rm -f "$GHE_DATA_DIR/current/uuid" + + # Run a restore + ghe-restore -v -f localhost + + # Verify no uuid is restored + [ ! -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" ] + +) +end_test + begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e From 96953913e0449a4d6c9b99dd883ef742c12410dd Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 17 Nov 2016 02:32:54 -0700 Subject: [PATCH 0095/2421] Backup and restore the appliance UUID When backing up and restoring GitHub Enterprise 2.8.X, we need to copy the UUID over, which is located in /data/user/common/uuid. Without this UUID, the appliance will have a different UUID after the restore, breaking all the existing routes for repositories and leaving repositories inaccessible after the restore. No data loss happens. The issue can be easily fixed by manually re-creating the UUID file after a restore (before re-configuring the appliance), adding the right UUID to it. This fix is required for customers running GitHub Enterprise 2.8.X (clusters not affected). It's highly recommended to backup a 2.8.X appliance with backup-utils 2.8.2, that will include a fix for this. Customers backing up and restoring older GitHub Enterprise versions are not affected. --- bin/ghe-restore | 7 +++ share/github-backup-utils/ghe-backup-settings | 4 ++ test/test-ghe-backup.sh | 22 +++++--- test/test-ghe-restore.sh | 54 ++++++++++++++++++- 4 files changed, 78 insertions(+), 9 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 9c2aef137..646959257 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -238,6 +238,13 @@ if ! $cluster; then fi fi +# Restore UUID if present and not restoring to cluster. +if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $cluster; then + echo "Restoring UUID ..." + cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" +fi + echo "Restoring MySQL database ..." bm_start "ghe-import-mysql" gzip -dc "$GHE_RESTORE_SNAPSHOT_PATH/mysql.sql.gz" | ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-mysql' diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index e98c7ae17..0982f55ce 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -51,6 +51,10 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "Error: Enterprise Cluster is not configured yet, backup will fail" >&2 exit 1 fi +else + if ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_DATA_USER_DIR/common/uuid 2>/dev/null" > uuid; then + echo "* Transferring UUID ..." 1>&3 + fi fi bm_end "$(basename $0)" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 7269d3848..31c904f7c 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -46,6 +46,9 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001" touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" + + # Create a fake UUID + echo "fake uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" fi # Create some fake elasticsearch data in the remote data directory @@ -130,9 +133,7 @@ begin_test "ghe-backup first snapshot" # verify manage-password file was backed up under v2.x VMs if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - fi - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then # verify all hookshot user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" @@ -147,6 +148,9 @@ begin_test "ghe-backup first snapshot" # verify all alambic assets user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" fi # verify that ghe-backup wrote its version information to the host @@ -213,9 +217,7 @@ begin_test "ghe-backup subsequent snapshot" # verify manage-password file was backed up under v2.x VMs if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - fi - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then # verify all hookshot user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" @@ -230,6 +232,9 @@ begin_test "ghe-backup subsequent snapshot" # verify all alambic assets user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" fi ) end_test @@ -312,9 +317,7 @@ begin_test "ghe-backup with relative data dir path" # verify manage-password file was backed up under v2.x VMs if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - fi - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then # verify all hookshot user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" @@ -329,6 +332,9 @@ begin_test "ghe-backup with relative data dir path" # verify all alambic assets user data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" fi # verify that ghe-backup wrote its version information to the host @@ -459,8 +465,8 @@ end_test begin_test "ghe-backup with leaked SSH host key detection for current backup" ( - set -e - + set -e + SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) # Inject the fingerprint into the blacklist echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 1e9c392ff..003db96f3 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -19,8 +19,8 @@ mkdir -p gh-enterprise-es/node/0 touch gh-enterprise-es/node/0/stuff1 touch gh-enterprise-es/node/0/stuff2 -# Create some fake hookshot data in the remote data directory if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + # Create some fake hookshot data in the remote data directory mkdir -p "$GHE_DATA_DIR/1/hookshot" cd "$GHE_DATA_DIR/1/hookshot" mkdir -p repository-123 repository-456 @@ -50,6 +50,9 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then mkdir -p "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001" touch "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" + + # Create a fake uuid + echo "fake uuid" > "$GHE_DATA_DIR/1/uuid" fi # Add some fake repositories to the snapshot @@ -145,6 +148,9 @@ begin_test "ghe-restore into configured vm" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" fi ) end_test @@ -279,6 +285,9 @@ begin_test "ghe-restore -c into unconfigured vm" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" fi ) end_test @@ -344,6 +353,9 @@ begin_test "ghe-restore into unconfigured vm" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + # verify no config run after restore on unconfigured instance ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" fi @@ -396,6 +408,9 @@ begin_test "ghe-restore with host arg" # verify all alambic assets user data was transferred diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" fi ) end_test @@ -485,6 +500,43 @@ begin_test "ghe-restore with tarball strategy" ) end_test +begin_test "ghe-restore with empty uuid file" +( + set -e + + # Remove the UUID from the remote instance + rm -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # Zero-length the UUID file + cat /dev/null > "$GHE_DATA_DIR/current/uuid" + + # Run a restore + ghe-restore -v -f localhost + + # Verify no uuid is restored + [ ! -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" ] + +) +end_test + +begin_test "ghe-restore with no uuid file" +( set -e + + # Remove the UUID from the remote instance + rm -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # Remove the UUID file + rm -f "$GHE_DATA_DIR/current/uuid" + + # Run a restore + ghe-restore -v -f localhost + + # Verify no uuid is restored + [ ! -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" ] + +) +end_test + begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e From 218ff46e8292b71ad06fd1dcf5365e9e255c8305 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Thu, 17 Nov 2016 15:04:35 +0100 Subject: [PATCH 0096/2421] Fix test enabling verbose mode "Creating the backup data directory" is echoed to fd 3 so will need to set verbose mode to redirect the output to stdout, so we can grep it. --- test/test-ghe-backup-config.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 0fa401d06..b8353ecc3 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -20,8 +20,9 @@ begin_test "ghe-backup-config GHE_CREATE_DATA_DIR disabled" set -e export GHE_DATA_DIR="$TRASHDIR/create-enabled-data" - output=$(. share/github-backup-utils/ghe-backup-config 2>&1) - echo $output | grep -q "Creating the backup data directory ..." + export GHE_VERBOSE=1 + . share/github-backup-utils/ghe-backup-config | + grep -q "Creating the backup data directory ..." test -d $GHE_DATA_DIR rm -rf $GHE_DATA_DIR From b051a3d5bf8aa7ad0599a12992a0a25bdb9d0f95 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Thu, 17 Nov 2016 15:58:51 +0100 Subject: [PATCH 0097/2421] Bump version: 2.8.2 Fixes an important bug that affects GitHub Enterprise 2.8 backups and restores. * Backup and restore the appliance UUID #272 --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 848c4e3c6..a584e38c8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.8.2) UNRELEASED; urgency=medium + + * Backup and restore the appliance UUID #272 + + -- Sergio Rubio Thu, 17 Nov 2016 15:58:08 +0100 + github-backup-utils (2.8.1) UNRELEASED; urgency=medium * Stop cron and timerd during restore #269 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index dbe590065..1817afea4 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.8.1 +2.8.2 From 88f7f2d8be4f0a1be41b333fb075883708daf61d Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 18 Nov 2016 11:33:38 -0700 Subject: [PATCH 0098/2421] Backup and restore ca certificates --- share/github-backup-utils/ghe-backup-settings | 4 ++++ share/github-backup-utils/ghe-restore-settings | 7 +++++++ test/bin/ghe-export-ssl-ca-certificates | 1 + test/bin/ghe-import-ssl-ca-certificates | 1 + test/test-ghe-backup.sh | 9 +++++++++ test/test-ghe-restore.sh | 7 +++++++ 6 files changed, 29 insertions(+) create mode 120000 test/bin/ghe-export-ssl-ca-certificates create mode 120000 test/bin/ghe-import-ssl-ca-certificates diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 0982f55ce..14f5fdac9 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -45,6 +45,10 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi +if ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar; then + echo "* Transferring CA certificates ..." 1>&3 +fi + if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "* Transferring cluster configuration ..." 1>&3 if ! ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_CLUSTER_CONF_FILE 2>/dev/null" > cluster.conf; then diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index a0ac361f4..069b57dae 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -58,4 +58,11 @@ if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -xf -" fi +# Restore CA certificates if present. +if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" ]; then + echo "Restoring CA certificates ..." + cat "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" | + ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates >/dev/null" +fi + bm_start "$(basename $0)" diff --git a/test/bin/ghe-export-ssl-ca-certificates b/test/bin/ghe-export-ssl-ca-certificates new file mode 120000 index 000000000..a772e4ad9 --- /dev/null +++ b/test/bin/ghe-export-ssl-ca-certificates @@ -0,0 +1 @@ +ghe-fake-export-command \ No newline at end of file diff --git a/test/bin/ghe-import-ssl-ca-certificates b/test/bin/ghe-import-ssl-ca-certificates new file mode 120000 index 000000000..bc329368a --- /dev/null +++ b/test/bin/ghe-import-ssl-ca-certificates @@ -0,0 +1 @@ +ghe-fake-import-command \ No newline at end of file diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 31c904f7c..53dd9b9dd 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -151,6 +151,9 @@ begin_test "ghe-backup first snapshot" # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] fi # verify that ghe-backup wrote its version information to the host @@ -235,6 +238,9 @@ begin_test "ghe-backup subsequent snapshot" # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] fi ) end_test @@ -335,6 +341,9 @@ begin_test "ghe-backup with relative data dir path" # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] fi # verify that ghe-backup wrote its version information to the host diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 003db96f3..035a588f8 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -79,6 +79,7 @@ echo "fake ghe-export-es-indices data" > "$GHE_DATA_DIR/current/elasticsearch.ta echo "fake ghe-export-ssh-host-keys data" > "$GHE_DATA_DIR/current/ssh-host-keys.tar" echo "fake ghe-export-repositories data" > "$GHE_DATA_DIR/current/repositories.tar" echo "fake ghe-export-settings data" > "$GHE_DATA_DIR/current/settings.json" +echo "fake ghe-export-ssl-ca-certificates data" > "$GHE_DATA_DIR/current/ssl-ca-certificates.tar" echo "fake license data" > "$GHE_DATA_DIR/current/enterprise.ghl" echo "fake manage password hash data" > "$GHE_DATA_DIR/current/manage-password" echo "rsync" > "$GHE_DATA_DIR/current/strategy" @@ -288,6 +289,9 @@ begin_test "ghe-restore -c into unconfigured vm" # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # verify ghe-export-ssl-ca-certificates was run + grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" fi ) end_test @@ -356,6 +360,9 @@ begin_test "ghe-restore into unconfigured vm" # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + # verify ghe-export-ssl-ca-certificates was run + grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" + # verify no config run after restore on unconfigured instance ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" fi From b9ed0ed10c84a784a57f1a627f6287339d482a23 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 18 Nov 2016 12:08:33 -0700 Subject: [PATCH 0099/2421] Don't suppress output --- share/github-backup-utils/ghe-restore-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 069b57dae..bcb453c1f 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -62,7 +62,7 @@ fi if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" ]; then echo "Restoring CA certificates ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" | - ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates >/dev/null" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates" fi bm_start "$(basename $0)" From fd3f1fafc52a0f39937e6adac597e7980c5e20da Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Nov 2016 18:38:36 +1100 Subject: [PATCH 0100/2421] Update restore status on cluster nodes --- bin/ghe-restore | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 646959257..7af4afa73 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -77,19 +77,6 @@ GHE_BACKUP_STRATEGY=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/strategy") # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" -# Keep other processes on the VM in the loop about the restore status. -# -# Other processes will look for these states: -# "restoring" - restore is currently in progress -# "failed" - restore has failed -# "complete" - restore has completed successfully -update_restore_status () { - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - echo "$1" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' 2>/dev/null" - fi -} - # Figure out if this instance has been configured or is entirely new. instance_configured=false if ghe-ssh "$GHE_HOSTNAME" -- \ @@ -167,6 +154,24 @@ fi echo "Starting restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNAPSHOT ..." +# Keep other processes on the VM or cluster in the loop about the restore status. +# +# Other processes will look for these states: +# "restoring" - restore is currently in progress +# "failed" - restore has failed +# "complete" - restore has completed successfully +update_restore_status () { + if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + if $cluster; then + echo "set -o pipefail; ghe-cluster-each -- \"echo '$1' | sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | + ghe-ssh "$GHE_HOSTNAME" /bin/bash + else + echo "$1" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" + fi + fi +} + # Update remote restore state file and setup failure trap trap "update_restore_status failed" EXIT update_restore_status "restoring" From c06a069053fb8955a75f297fd65128e0feb3956e Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 15 Nov 2016 07:32:54 -0700 Subject: [PATCH 0101/2421] Remove unnecessary pipefail --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7af4afa73..2755201b6 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -163,7 +163,7 @@ ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNA update_restore_status () { if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then if $cluster; then - echo "set -o pipefail; ghe-cluster-each -- \"echo '$1' | sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | + echo "ghe-cluster-each -- \"echo '$1' | sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | ghe-ssh "$GHE_HOSTNAME" /bin/bash else echo "$1" | From 1843d049c2c7bc8ddcdd01a816d843a0e794ea8e Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 5 Dec 2016 21:57:43 +1100 Subject: [PATCH 0102/2421] Test directory as admin user on 11.10 --- share/github-backup-utils/ghe-backup-userdata | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata index 9a8b7e923..9944e39dc 100755 --- a/share/github-backup-utils/ghe-backup-userdata +++ b/share/github-backup-utils/ghe-backup-userdata @@ -25,7 +25,11 @@ ghe_remote_version_required "$host" # Verify that the user data directory exists. Bail out if not, which may be due # to an older version of GHE or no data has been added to this directory yet. -ghe-ssh "$host" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0 +if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + ghe-ssh "$host" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0 +else + ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0 +fi # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. From 45005d5c0c035a1103335c1e7a9aa93da234c718 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 5 Dec 2016 22:04:40 +1100 Subject: [PATCH 0103/2421] Only create the directory on 2 and above --- share/github-backup-utils/ghe-restore-userdata | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-userdata b/share/github-backup-utils/ghe-restore-userdata index abf1a6943..24085d170 100755 --- a/share/github-backup-utils/ghe-restore-userdata +++ b/share/github-backup-utils/ghe-restore-userdata @@ -30,12 +30,17 @@ ghe_remote_version_required "$GHE_HOSTNAME" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} +# Create the remote user data directory +if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + ghe-ssh "$host" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname" +fi + # Transfer data from the latest snapshot to the GitHub instance in a single # rsync invocation. if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname" ]; then ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname && sudo -u git rsync" \ + --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/$dirname" 1>&3 fi From f2676bb8d7608d52e3743264fc3a6f265f074044 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 5 Dec 2016 22:18:00 +1100 Subject: [PATCH 0104/2421] Only create remote if local exists --- share/github-backup-utils/ghe-restore-userdata | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-userdata b/share/github-backup-utils/ghe-restore-userdata index 24085d170..2156ac041 100755 --- a/share/github-backup-utils/ghe-restore-userdata +++ b/share/github-backup-utils/ghe-restore-userdata @@ -30,14 +30,14 @@ ghe_remote_version_required "$GHE_HOSTNAME" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} -# Create the remote user data directory -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - ghe-ssh "$host" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname" -fi - # Transfer data from the latest snapshot to the GitHub instance in a single # rsync invocation. if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname" ]; then + # Create the remote user data directory + if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + ghe-ssh "$GHE_HOSTNAME" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname" + fi + ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u git rsync" \ From 04c32e888c3d07da9fcf4d1007ad22e1f04fa076 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 12 Dec 2016 18:40:33 +1100 Subject: [PATCH 0105/2421] Skip hookshot es backup on pre 2.0 --- bin/ghe-backup | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 870bf7fe8..5fc234e20 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -159,11 +159,11 @@ if [ $GHE_VERSION_MAJOR -ge 2 ]; then echo "Backing up audit log ..." ghe-backup-es-audit-log || failures="$failures audit-log" -fi -echo "Backing up hookshot logs ..." -ghe-backup-es-hookshot || -failures="$failures hookshot" + echo "Backing up hookshot logs ..." + ghe-backup-es-hookshot || + failures="$failures hookshot" +fi echo "Backing up Git repositories ..." if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then From 08941197a8f00b768a82be6667d7ad0d0a8ee8e8 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 12 Dec 2016 18:41:06 +1100 Subject: [PATCH 0106/2421] Only restore hookshot es backup to cluster --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 646959257..1e1c90374 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -322,14 +322,14 @@ fi if $cluster; then echo "Restoring ElasticSearch Audit logs" ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 + + echo "Restoring hookshot logs ..." + ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 else echo "Restoring Elasticsearch indices ..." ghe-restore-es-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 fi -echo "Restoring hookshot logs ..." -ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 - # Restart an already running memcached to reset the cache after restore if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then echo "Restarting memcached ..." 1>&3 From 4ee2edfdc79abb722a1cb4b277fc951c6d5b9a36 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 21 Dec 2016 21:07:40 +1100 Subject: [PATCH 0107/2421] Bump version: 2.8.3 Bug fixes. * Set restore status on all cluster nodes #274 * Fix pages backups and restores in GitHub Enterprise 11.10 #275 --- debian/changelog | 7 +++++++ share/github-backup-utils/version | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index a584e38c8..162db58f8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.8.3) UNRELEASED; urgency=medium + + * Set restore status on all cluster nodes #274 + * Fix pages backups and restores in GitHub Enterprise 11.10 #275 + + -- Steven Honson Wed, 21 Dec 2016 21:01:20 +1100 + github-backup-utils (2.8.2) UNRELEASED; urgency=medium * Backup and restore the appliance UUID #272 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 1817afea4..9f8d8a916 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.8.2 +2.8.3 From 6b5ee5a2c06dec929e2a00a2655c97f763142086 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 22 Dec 2016 13:36:55 +1100 Subject: [PATCH 0108/2421] Check if command exists so to expose errors --- share/github-backup-utils/ghe-backup-settings | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 14f5fdac9..8b1273f6e 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -45,8 +45,9 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi -if ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar; then +if ghe-ssh "$host" -- "type ghe-export-ssl-ca-certificates"; then echo "* Transferring CA certificates ..." 1>&3 + ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar fi if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then From ed0633cc77d9f3e308e3fd4c8997f449eac5aa9f Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 22 Dec 2016 13:38:53 +1100 Subject: [PATCH 0109/2421] Backup not restore --- share/github-backup-utils/ghe-backup-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 8b1273f6e..8133a36bf 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -1,6 +1,6 @@ #!/usr/bin/env bash #/ Usage: ghe-backup-settings -#/ Restore settings from a snapshot to the given . +#/ Backup settings from a snapshot to the given . set -e # Bring in the backup configuration From edb0e6f66f82ed1c18c3051fbfe21c4340eeaf87 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 22 Dec 2016 13:51:40 +1100 Subject: [PATCH 0110/2421] Use which instead of type to verify existence --- share/github-backup-utils/ghe-backup-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 8133a36bf..0a6b8d85c 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -45,7 +45,7 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi -if ghe-ssh "$host" -- "type ghe-export-ssl-ca-certificates"; then +if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates"; then echo "* Transferring CA certificates ..." 1>&3 ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar fi From 488d3397560464e5b0cff6e3f02bae84054b6acf Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Thu, 29 Dec 2016 15:24:57 -0700 Subject: [PATCH 0111/2421] Use Trusty for Travis builds --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 37531612b..120f6fe5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ matrix: - brew install gnu-tar script: make test - os: linux + dist: trusty sudo: false addons: apt: From 77c8429a932d4713258e6fa7b1dfe7776a34c3bf Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Thu, 29 Dec 2016 15:28:18 -0700 Subject: [PATCH 0112/2421] Add debhelper dep --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 120f6fe5a..d3abb8192 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,7 @@ matrix: sudo: false addons: apt: - packages: devscripts + packages: + - devscripts + - debhelper script: debuild -uc -us From d11e85cecd779c4b3ecc5cf8554824b015ebb2cc Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Thu, 29 Dec 2016 16:07:24 -0700 Subject: [PATCH 0113/2421] See if GCE is faster --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d3abb8192..b82389bf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ matrix: script: make test - os: linux dist: trusty - sudo: false + sudo: true addons: apt: packages: From 98cff871c99dc09122a5cd89fcb6818eff223b64 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Thu, 29 Dec 2016 17:44:13 -0700 Subject: [PATCH 0114/2421] Add Precise back in --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b82389bf2..45225295b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,15 @@ matrix: - brew update - brew install gnu-tar script: make test + - os: linux + sudo: false + addons: + apt: + packages: devscripts + script: debuild -uc -us - os: linux dist: trusty - sudo: true + sudo: required addons: apt: packages: From dec548e3b2561e29b68046d0070b0b2eff150d8a Mon Sep 17 00:00:00 2001 From: Sean Kelly Date: Thu, 5 Jan 2017 08:10:58 -0600 Subject: [PATCH 0115/2421] Update some bash bangpaths to use /usr/bin/env --- share/github-backup-utils/bm.sh | 2 +- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 56421a569..1f6500484 100644 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # bm.sh: benchmarking Bash code blocks # # Example: diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 0a5d61dc0..4287885ab 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash #/ Usage: ghe-detect-leaked-ssh-key [-s ] #/ #/ This utility will check each snapshot's existing SSH host keys against the list From 79b73df84a2b104653138c204502e0956d7a1abb Mon Sep 17 00:00:00 2001 From: Leigh Fort Date: Tue, 17 Jan 2017 12:55:28 +1100 Subject: [PATCH 0116/2421] Check utils are not being run on GitHub Enterprise host --- share/github-backup-utils/ghe-backup-config | 12 ++++++++++++ test/test-ghe-backup-config.sh | 21 ++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 23ce0fa06..934104e57 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -83,6 +83,18 @@ if [ ${GHE_DATA_DIR:0:1} != "/" ]; then GHE_DATA_DIR="$( cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR" 2> /dev/null || echo "$GHE_BACKUP_ROOT/$GHE_DATA_DIR" )" fi +# Assign the Release File path if it hasn't been provided (eg: by test suite) +[ -z "$GHE_RELEASE_FILE" ] && GHE_RELEASE_FILE="/etc/github/enterprise-release" + +# Check that utils are not being run directly on GHE appliance. +if [ -f "$GHE_RELEASE_FILE" ]; then + echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 + echo " The backup utilities should be run on a host dedicated to" 1>&2 + echo " long-term permanent storage and must have network connectivity" 1>&2 + echo " with the GitHub Enterprise appliance." 1>&2 + exit 2 +fi + GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} # Check that the data directory is set and create it if it doesn't exist. diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index b8353ecc3..929ceef78 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -41,6 +41,26 @@ begin_test "ghe-backup-config GHE_CREATE_DATA_DIR disabled" ) end_test +begin_test "ghe-backup-config run on GHE appliance" +( + set -e + + export GHE_RELEASE_FILE="$TRASHDIR/enterprise-release" + touch "$GHE_RELEASE_FILE" + set +e + error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + # should exit 2 + if [ $? != 2 ]; then + exit 1 + fi + set -e + echo "$error" | grep -q "Error: Backup Utils cannot be run on the GitHub Enterprise host." + + test -f "$GHE_RELEASE_FILE" + rm -rf "$GHE_RELEASE_FILE" +) +end_test + begin_test "ghe-backup-config ssh_host_part" ( set -e @@ -51,7 +71,6 @@ begin_test "ghe-backup-config ssh_host_part" ) end_test - begin_test "ghe-backup-config ssh_port_part" ( set -e From a40723085fca9ff9bae5aa1e33c82b89aafb8ab4 Mon Sep 17 00:00:00 2001 From: Leigh Fort Date: Wed, 18 Jan 2017 00:03:08 +1100 Subject: [PATCH 0117/2421] Fixing exit code --- share/github-backup-utils/ghe-backup-config | 2 +- test/test-ghe-backup-config.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 934104e57..b971c02d0 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -92,7 +92,7 @@ if [ -f "$GHE_RELEASE_FILE" ]; then echo " The backup utilities should be run on a host dedicated to" 1>&2 echo " long-term permanent storage and must have network connectivity" 1>&2 echo " with the GitHub Enterprise appliance." 1>&2 - exit 2 + exit 1 fi GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 929ceef78..2cab6c5dc 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -49,8 +49,8 @@ begin_test "ghe-backup-config run on GHE appliance" touch "$GHE_RELEASE_FILE" set +e error=$(. share/github-backup-utils/ghe-backup-config 2>&1) - # should exit 2 - if [ $? != 2 ]; then + # should exit 1 + if [ $? != 1 ]; then exit 1 fi set -e From 17807829bf1a8629fcb75c303da0c3b671f90e19 Mon Sep 17 00:00:00 2001 From: Leigh Fort Date: Wed, 18 Jan 2017 21:15:25 +1100 Subject: [PATCH 0118/2421] Changing syntax for assigning GHE_RELEASE_FILE if empty --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b971c02d0..75c114d65 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -84,7 +84,7 @@ if [ ${GHE_DATA_DIR:0:1} != "/" ]; then fi # Assign the Release File path if it hasn't been provided (eg: by test suite) -[ -z "$GHE_RELEASE_FILE" ] && GHE_RELEASE_FILE="/etc/github/enterprise-release" +: ${GHE_RELEASE_FILE:="/etc/github/enterprise-release"} # Check that utils are not being run directly on GHE appliance. if [ -f "$GHE_RELEASE_FILE" ]; then From 17514ad1aa7edf52b04a1e48052d2ea007fc0d7b Mon Sep 17 00:00:00 2001 From: Leigh Fort Date: Wed, 18 Jan 2017 21:06:05 +1100 Subject: [PATCH 0119/2421] Check for missing GHE_DATA_DIR variable in config --- share/github-backup-utils/ghe-backup-config | 6 ++++++ test/test-ghe-backup-config.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 23ce0fa06..c2970d237 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -76,6 +76,12 @@ if [ -z "$GHE_HOSTNAME" ]; then exit 2 fi +# Check that the GHE data directory is set. +if [ -z "$GHE_DATA_DIR" ]; then + echo "Error: GHE_DATA_DIR not set in config file." 1>&2 + exit 2 +fi + # Convert the data directory path to an absolute path, basing any relative # paths on the backup-utils root, and using readlink, if available, to # canonicalize the path. diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index b8353ecc3..7bac6a94d 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -15,6 +15,19 @@ export GHE_DATA_DIR GHE_REMOTE_DATA_DIR cd "$ROOTDIR" . "share/github-backup-utils/ghe-backup-config" +begin_test "ghe-backup-config GHE_DATA_DIR defined" +( + set +e + GHE_DATA_DIR= error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + # should exit 2 + if [ $? != 2 ]; then + exit 1 + fi + set -e + echo $error | grep -q "Error: GHE_DATA_DIR not set in config file." +) +end_test + begin_test "ghe-backup-config GHE_CREATE_DATA_DIR disabled" ( set -e From 212a4ea0e4edcf03d4563f37674f62849725466c Mon Sep 17 00:00:00 2001 From: John Stautinger Date: Wed, 18 Jan 2017 10:39:59 -0500 Subject: [PATCH 0120/2421] Correct minor spelling error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5cacb879e..eeb2801ad 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ enable when output is logged to a file. When restoring to an already configured GHE instance, settings, certificate, and license data are *not* restored to prevent overwriting manual configuration on the restore -host. This behavior can be overriden by passing the `-c` argument to `ghe-restore`, +host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`, forcing settings, certificate, and license data to be overwritten with the backup copy's data. ### Scheduling backups From dd679688d61ac85077bc3cbf1eee8b315044f2b2 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 18 Nov 2016 11:33:38 -0700 Subject: [PATCH 0121/2421] Backup and restore ca certificates --- share/github-backup-utils/ghe-backup-settings | 4 ++++ share/github-backup-utils/ghe-restore-settings | 7 +++++++ test/bin/ghe-export-ssl-ca-certificates | 1 + test/bin/ghe-import-ssl-ca-certificates | 1 + test/test-ghe-backup.sh | 9 +++++++++ test/test-ghe-restore.sh | 7 +++++++ 6 files changed, 29 insertions(+) create mode 120000 test/bin/ghe-export-ssl-ca-certificates create mode 120000 test/bin/ghe-import-ssl-ca-certificates diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 0982f55ce..14f5fdac9 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -45,6 +45,10 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi +if ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar; then + echo "* Transferring CA certificates ..." 1>&3 +fi + if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "* Transferring cluster configuration ..." 1>&3 if ! ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_CLUSTER_CONF_FILE 2>/dev/null" > cluster.conf; then diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index a0ac361f4..069b57dae 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -58,4 +58,11 @@ if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -xf -" fi +# Restore CA certificates if present. +if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" ]; then + echo "Restoring CA certificates ..." + cat "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" | + ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates >/dev/null" +fi + bm_start "$(basename $0)" diff --git a/test/bin/ghe-export-ssl-ca-certificates b/test/bin/ghe-export-ssl-ca-certificates new file mode 120000 index 000000000..a772e4ad9 --- /dev/null +++ b/test/bin/ghe-export-ssl-ca-certificates @@ -0,0 +1 @@ +ghe-fake-export-command \ No newline at end of file diff --git a/test/bin/ghe-import-ssl-ca-certificates b/test/bin/ghe-import-ssl-ca-certificates new file mode 120000 index 000000000..bc329368a --- /dev/null +++ b/test/bin/ghe-import-ssl-ca-certificates @@ -0,0 +1 @@ +ghe-fake-import-command \ No newline at end of file diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 31c904f7c..53dd9b9dd 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -151,6 +151,9 @@ begin_test "ghe-backup first snapshot" # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] fi # verify that ghe-backup wrote its version information to the host @@ -235,6 +238,9 @@ begin_test "ghe-backup subsequent snapshot" # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] fi ) end_test @@ -335,6 +341,9 @@ begin_test "ghe-backup with relative data dir path" # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] fi # verify that ghe-backup wrote its version information to the host diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 003db96f3..035a588f8 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -79,6 +79,7 @@ echo "fake ghe-export-es-indices data" > "$GHE_DATA_DIR/current/elasticsearch.ta echo "fake ghe-export-ssh-host-keys data" > "$GHE_DATA_DIR/current/ssh-host-keys.tar" echo "fake ghe-export-repositories data" > "$GHE_DATA_DIR/current/repositories.tar" echo "fake ghe-export-settings data" > "$GHE_DATA_DIR/current/settings.json" +echo "fake ghe-export-ssl-ca-certificates data" > "$GHE_DATA_DIR/current/ssl-ca-certificates.tar" echo "fake license data" > "$GHE_DATA_DIR/current/enterprise.ghl" echo "fake manage password hash data" > "$GHE_DATA_DIR/current/manage-password" echo "rsync" > "$GHE_DATA_DIR/current/strategy" @@ -288,6 +289,9 @@ begin_test "ghe-restore -c into unconfigured vm" # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # verify ghe-export-ssl-ca-certificates was run + grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" fi ) end_test @@ -356,6 +360,9 @@ begin_test "ghe-restore into unconfigured vm" # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + # verify ghe-export-ssl-ca-certificates was run + grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" + # verify no config run after restore on unconfigured instance ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" fi From 328e89a597453b235e101e2b14fd14123e7efe15 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 18 Nov 2016 12:08:33 -0700 Subject: [PATCH 0122/2421] Don't suppress output --- share/github-backup-utils/ghe-restore-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 069b57dae..bcb453c1f 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -62,7 +62,7 @@ fi if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" ]; then echo "Restoring CA certificates ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" | - ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates >/dev/null" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates" fi bm_start "$(basename $0)" From 88ed581f15af66a16c9b5449587b904b0dd5ba2d Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 22 Dec 2016 13:36:55 +1100 Subject: [PATCH 0123/2421] Check if command exists so to expose errors --- share/github-backup-utils/ghe-backup-settings | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 14f5fdac9..8b1273f6e 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -45,8 +45,9 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi -if ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar; then +if ghe-ssh "$host" -- "type ghe-export-ssl-ca-certificates"; then echo "* Transferring CA certificates ..." 1>&3 + ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar fi if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then From 074bd37963231c6f389a46475eef122f64401996 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 22 Dec 2016 13:38:53 +1100 Subject: [PATCH 0124/2421] Backup not restore --- share/github-backup-utils/ghe-backup-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 8b1273f6e..8133a36bf 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -1,6 +1,6 @@ #!/usr/bin/env bash #/ Usage: ghe-backup-settings -#/ Restore settings from a snapshot to the given . +#/ Backup settings from a snapshot to the given . set -e # Bring in the backup configuration From eb25675126a45df49044a2f21500e27fec460c75 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 22 Dec 2016 13:51:40 +1100 Subject: [PATCH 0125/2421] Use which instead of type to verify existence --- share/github-backup-utils/ghe-backup-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 8133a36bf..0a6b8d85c 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -45,7 +45,7 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi -if ghe-ssh "$host" -- "type ghe-export-ssl-ca-certificates"; then +if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates"; then echo "* Transferring CA certificates ..." 1>&3 ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar fi From 6fcde2cdb667997653c9ed9522e171f16e9e4cb9 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 2 Feb 2017 11:17:05 +1100 Subject: [PATCH 0126/2421] Silence test output --- share/github-backup-utils/ghe-backup-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 0a6b8d85c..d9a67c747 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -45,7 +45,7 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi -if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates"; then +if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates 1>/dev/null"; then echo "* Transferring CA certificates ..." 1>&3 ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar fi From 09f3e542c608271ce091a431fea692137c7630f0 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 9 Feb 2017 17:08:48 +1100 Subject: [PATCH 0127/2421] Run bm_file_path first --- bin/ghe-backup | 3 +++ bin/ghe-restore | 3 +++ share/github-backup-utils/bm.sh | 2 -- 3 files changed, 6 insertions(+), 2 deletions(-) mode change 100644 => 100755 share/github-backup-utils/bm.sh diff --git a/bin/ghe-backup b/bin/ghe-backup index 870bf7fe8..8bfa19058 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -120,6 +120,9 @@ if [ "$GHE_BACKUP_STRATEGY" = "tarball" ]; then GHE_MAINTENANCE_MODE_ENABLED=true fi +# Create benchmark file +bm_file_path > /dev/null + ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." diff --git a/bin/ghe-restore b/bin/ghe-restore index 2755201b6..fb6ec5ff7 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -202,6 +202,9 @@ if $instance_configured; then fi fi +# Create benchmark file +bm_file_path > /dev/null + ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh old mode 100644 new mode 100755 index 1f6500484..6be1aa33b --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -17,8 +17,6 @@ bm_desc_to_varname(){ bm_start() { eval "$(bm_desc_to_varname $@)_start=$(date +%s)" - - bm_file_path > /dev/null } bm_file_path() { From ea727ce966916b264973bd1bac9e1fc3ba00e84f Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 9 Feb 2017 17:25:23 +1100 Subject: [PATCH 0128/2421] 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. --- share/github-backup-utils/bm.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 6be1aa33b..1f6500484 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -17,6 +17,8 @@ bm_desc_to_varname(){ bm_start() { eval "$(bm_desc_to_varname $@)_start=$(date +%s)" + + bm_file_path > /dev/null } bm_file_path() { From a599322b77dc847dd4826fcb725ee65bd43f5abe Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Thu, 23 Feb 2017 12:46:34 +0100 Subject: [PATCH 0129/2421] Rename bm_file_path to bm_init Should make the intention a bit more clear. --- bin/ghe-backup | 2 +- bin/ghe-restore | 2 +- share/github-backup-utils/bm.sh | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 8bfa19058..5bd5b204a 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -121,7 +121,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "tarball" ]; then fi # Create benchmark file -bm_file_path > /dev/null +bm_init > /dev/null ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." diff --git a/bin/ghe-restore b/bin/ghe-restore index fb6ec5ff7..7c89351f5 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -203,7 +203,7 @@ if $instance_configured; then fi # Create benchmark file -bm_file_path > /dev/null +bm_init > /dev/null ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 1f6500484..554d338a9 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -18,10 +18,10 @@ bm_start() { eval "$(bm_desc_to_varname $@)_start=$(date +%s)" - bm_file_path > /dev/null + bm_init > /dev/null } -bm_file_path() { +bm_init() { if [ -n "$BM_FILE_PATH" ]; then echo $BM_FILE_PATH return From 908a38c44abebfa52febb248627a0fab59952656 Mon Sep 17 00:00:00 2001 From: Keeran Raj Hawoldar Date: Thu, 23 Feb 2017 12:04:15 +0000 Subject: [PATCH 0130/2421] add --version flag to all commands (#78) * add --version flag to all commands * add version flag to usage text --- bin/ghe-backup | 2 +- bin/ghe-restore | 1 + share/github-backup-utils/ghe-backup-config | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 870bf7fe8..8c31e4ee2 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup [-v] +#/ Usage: ghe-backup [-v] [--version] #/ Take snapshots of all GitHub Enterprise data, including Git repository data, #/ the MySQL database, instance settings, GitHub Pages data, etc. #/ diff --git a/bin/ghe-restore b/bin/ghe-restore index 2755201b6..05eca324c 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -6,6 +6,7 @@ #/ argument is provided, it always overrides the configured restore host. #/ #/ Options: +#/ --version Display version information. #/ -f Don't prompt for confirmation before restoring. #/ -c Restore appliance settings and license in addition to #/ datastores. Settings are not restored by default to diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 74a4057a9..5ac149f0b 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -25,6 +25,12 @@ PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" . $GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh +# Display version string if flag present for any command +if [ "$1" = "--version" ]; then + echo "GitHub backup-utils v$BACKUP_UTILS_VERSION" + exit 0 +fi + # Parse out -v (verbose) argument if [ "$1" = "-v" ]; then GHE_VERBOSE=true From 9559dbd99e7d90e317f5e7710b9332c64af4738e Mon Sep 17 00:00:00 2001 From: Keeran Raj Hawoldar Date: Thu, 23 Feb 2017 12:04:15 +0000 Subject: [PATCH 0131/2421] Add --version flag to all commands --- bin/ghe-backup | 2 +- bin/ghe-restore | 1 + share/github-backup-utils/ghe-backup-config | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 870bf7fe8..8c31e4ee2 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup [-v] +#/ Usage: ghe-backup [-v] [--version] #/ Take snapshots of all GitHub Enterprise data, including Git repository data, #/ the MySQL database, instance settings, GitHub Pages data, etc. #/ diff --git a/bin/ghe-restore b/bin/ghe-restore index 2755201b6..05eca324c 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -6,6 +6,7 @@ #/ argument is provided, it always overrides the configured restore host. #/ #/ Options: +#/ --version Display version information. #/ -f Don't prompt for confirmation before restoring. #/ -c Restore appliance settings and license in addition to #/ datastores. Settings are not restored by default to diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 23ce0fa06..34608fadc 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -25,6 +25,12 @@ PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" . $GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh +# Display version string if flag present for any command +if [ "$1" = "--version" ]; then + echo "GitHub backup-utils v$BACKUP_UTILS_VERSION" + exit 0 +fi + # Parse out -v (verbose) argument if [ "$1" = "-v" ]; then GHE_VERBOSE=true From a89a3e93146fdc6e7b9b45c2dcb5d8a678cf3f23 Mon Sep 17 00:00:00 2001 From: Leigh Fort Date: Wed, 18 Jan 2017 21:06:05 +1100 Subject: [PATCH 0132/2421] 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. ``` --- share/github-backup-utils/ghe-backup-config | 6 ++++++ test/test-ghe-backup-config.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 23ce0fa06..c2970d237 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -76,6 +76,12 @@ if [ -z "$GHE_HOSTNAME" ]; then exit 2 fi +# Check that the GHE data directory is set. +if [ -z "$GHE_DATA_DIR" ]; then + echo "Error: GHE_DATA_DIR not set in config file." 1>&2 + exit 2 +fi + # Convert the data directory path to an absolute path, basing any relative # paths on the backup-utils root, and using readlink, if available, to # canonicalize the path. diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index b8353ecc3..7bac6a94d 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -15,6 +15,19 @@ export GHE_DATA_DIR GHE_REMOTE_DATA_DIR cd "$ROOTDIR" . "share/github-backup-utils/ghe-backup-config" +begin_test "ghe-backup-config GHE_DATA_DIR defined" +( + set +e + GHE_DATA_DIR= error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + # should exit 2 + if [ $? != 2 ]; then + exit 1 + fi + set -e + echo $error | grep -q "Error: GHE_DATA_DIR not set in config file." +) +end_test + begin_test "ghe-backup-config GHE_CREATE_DATA_DIR disabled" ( set -e From 4a6b4878f320fd26288fd20464ea9c5b60b723bd Mon Sep 17 00:00:00 2001 From: Leigh Fort Date: Tue, 17 Jan 2017 12:55:28 +1100 Subject: [PATCH 0133/2421] 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. --- share/github-backup-utils/ghe-backup-config | 12 ++++++++++++ test/test-ghe-backup-config.sh | 21 ++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 23ce0fa06..75c114d65 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -83,6 +83,18 @@ if [ ${GHE_DATA_DIR:0:1} != "/" ]; then GHE_DATA_DIR="$( cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR" 2> /dev/null || echo "$GHE_BACKUP_ROOT/$GHE_DATA_DIR" )" fi +# Assign the Release File path if it hasn't been provided (eg: by test suite) +: ${GHE_RELEASE_FILE:="/etc/github/enterprise-release"} + +# Check that utils are not being run directly on GHE appliance. +if [ -f "$GHE_RELEASE_FILE" ]; then + echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 + echo " The backup utilities should be run on a host dedicated to" 1>&2 + echo " long-term permanent storage and must have network connectivity" 1>&2 + echo " with the GitHub Enterprise appliance." 1>&2 + exit 1 +fi + GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} # Check that the data directory is set and create it if it doesn't exist. diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index b8353ecc3..2cab6c5dc 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -41,6 +41,26 @@ begin_test "ghe-backup-config GHE_CREATE_DATA_DIR disabled" ) end_test +begin_test "ghe-backup-config run on GHE appliance" +( + set -e + + export GHE_RELEASE_FILE="$TRASHDIR/enterprise-release" + touch "$GHE_RELEASE_FILE" + set +e + error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + # should exit 1 + if [ $? != 1 ]; then + exit 1 + fi + set -e + echo "$error" | grep -q "Error: Backup Utils cannot be run on the GitHub Enterprise host." + + test -f "$GHE_RELEASE_FILE" + rm -rf "$GHE_RELEASE_FILE" +) +end_test + begin_test "ghe-backup-config ssh_host_part" ( set -e @@ -51,7 +71,6 @@ begin_test "ghe-backup-config ssh_host_part" ) end_test - begin_test "ghe-backup-config ssh_port_part" ( set -e From 6f24de5043d7a7c25c2578f4ebab6313add6258a Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Fri, 24 Feb 2017 13:11:13 +0100 Subject: [PATCH 0134/2421] 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. --- README.md | 2 +- bin/ghe-backup | 11 +++++++---- bin/ghe-restore | 9 ++++++--- share/github-backup-utils/bm.sh | 4 ++-- share/github-backup-utils/ghe-backup-settings | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) mode change 100644 => 100755 share/github-backup-utils/bm.sh diff --git a/README.md b/README.md index 5cacb879e..eeb2801ad 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,7 @@ enable when output is logged to a file. When restoring to an already configured GHE instance, settings, certificate, and license data are *not* restored to prevent overwriting manual configuration on the restore -host. This behavior can be overriden by passing the `-c` argument to `ghe-restore`, +host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`, forcing settings, certificate, and license data to be overwritten with the backup copy's data. ### Scheduling backups diff --git a/bin/ghe-backup b/bin/ghe-backup index 8c31e4ee2..852a9e104 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -120,6 +120,9 @@ if [ "$GHE_BACKUP_STRATEGY" = "tarball" ]; then GHE_MAINTENANCE_MODE_ENABLED=true fi +# Create benchmark file +bm_init > /dev/null + ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." @@ -159,11 +162,11 @@ if [ $GHE_VERSION_MAJOR -ge 2 ]; then echo "Backing up audit log ..." ghe-backup-es-audit-log || failures="$failures audit-log" -fi -echo "Backing up hookshot logs ..." -ghe-backup-es-hookshot || -failures="$failures hookshot" + echo "Backing up hookshot logs ..." + ghe-backup-es-hookshot || + failures="$failures hookshot" +fi echo "Backing up Git repositories ..." if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then diff --git a/bin/ghe-restore b/bin/ghe-restore index 05eca324c..b6f4d58e2 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -203,6 +203,9 @@ if $instance_configured; then fi fi +# Create benchmark file +bm_init > /dev/null + ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." @@ -328,14 +331,14 @@ fi if $cluster; then echo "Restoring ElasticSearch Audit logs" ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 + + echo "Restoring hookshot logs ..." + ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 else echo "Restoring Elasticsearch indices ..." ghe-restore-es-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 fi -echo "Restoring hookshot logs ..." -ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 - # Restart an already running memcached to reset the cache after restore if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then echo "Restarting memcached ..." 1>&3 diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh old mode 100644 new mode 100755 index 1f6500484..554d338a9 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -18,10 +18,10 @@ bm_start() { eval "$(bm_desc_to_varname $@)_start=$(date +%s)" - bm_file_path > /dev/null + bm_init > /dev/null } -bm_file_path() { +bm_init() { if [ -n "$BM_FILE_PATH" ]; then echo $BM_FILE_PATH return diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 0a6b8d85c..d9a67c747 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -45,7 +45,7 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi -if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates"; then +if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates 1>/dev/null"; then echo "* Transferring CA certificates ..." 1>&3 ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar fi From d2e6fd0869321751b6bc84b9c8ecc59e4572caab Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 27 Feb 2017 18:17:22 +0100 Subject: [PATCH 0135/2421] Do not remove the working copy's .git dir Safer to work on a throwaway dir insde TRASHDIR. --- test/test-ghe-backup.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 53dd9b9dd..dc747bf72 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -463,9 +463,12 @@ begin_test "ghe-backup stores version when not run from a clone" # Make sure this doesn't exist rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" - mv "$ROOTDIR/.git" "$ROOTDIR/.gittmp" - ghe-backup - mv "$ROOTDIR/.gittmp" "$ROOTDIR/.git" + tmpdir=$TRASHDIR/ghe-backup-stores-version + mkdir $tmpdir + git clone $ROOTDIR $tmpdir/backup-utils + cd $tmpdir/backup-utils + rm -rf .git + ./bin/ghe-backup # verify that ghe-backup wrote its version information to the host [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] From 7015a017921687c3e628a23e344c6e6136b64e74 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 27 Feb 2017 18:25:16 +0100 Subject: [PATCH 0136/2421] Make the tmp dir name random --- test/test-ghe-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index dc747bf72..ff53d9b0b 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -463,7 +463,7 @@ begin_test "ghe-backup stores version when not run from a clone" # Make sure this doesn't exist rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" - tmpdir=$TRASHDIR/ghe-backup-stores-version + tmpdir=$TRASHDIR/ghe-backup-stores-version-$RANDOM mkdir $tmpdir git clone $ROOTDIR $tmpdir/backup-utils cd $tmpdir/backup-utils From 6638ea64af0e290eff45c02d94119aeee3125ce3 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 27 Feb 2017 18:42:36 +0100 Subject: [PATCH 0137/2421] Use mktemp -d, simpler --- test/test-ghe-backup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index ff53d9b0b..6bb243bb3 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -463,8 +463,7 @@ begin_test "ghe-backup stores version when not run from a clone" # Make sure this doesn't exist rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" - tmpdir=$TRASHDIR/ghe-backup-stores-version-$RANDOM - mkdir $tmpdir + tmpdir=(mktemp -d $TRASHDIR/foo.XXXXXX) git clone $ROOTDIR $tmpdir/backup-utils cd $tmpdir/backup-utils rm -rf .git From 9cc75ed212af788350f0a6807a2945c4673e3cf0 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 27 Feb 2017 19:25:58 +0100 Subject: [PATCH 0138/2421] :fire: some cluster backup noise Backing up Git repositories ... * Using calculated routes method... /tmp/tmp.2HLa5AiPQV/git-server-1df34f8a-95dd-11e6-9f0e-060d3255d03f.rsync /tmp/tmp.2HLa5AiPQV/git-server-ba5589aa-95de-11e6-8fe1-023b382555e3.rsync /tmp/tmp.2HLa5AiPQV/git-server-a43bc744-95dc-11e6-b197-063e1f683c47.rsync --- share/github-backup-utils/ghe-backup-repositories-cluster-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 5edd7d1d4..a8e190a85 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -135,7 +135,7 @@ ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-routes \ done bm_end "$(basename $0) - Calculating Sync Routes" -if ! ls $tempdir/*.rsync 2>/dev/null; then +if ! ls $tempdir/*.rsync >/dev/null 2>&1; then echo "Warning: no routes found, skipping repositories backup ..." exit 0 fi From 95daaa85624d3ff6138338ab4b16f4c5cb1e17da Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 27 Feb 2017 21:03:41 +0100 Subject: [PATCH 0139/2421] Fix the bash --- test/test-ghe-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6bb243bb3..932ed8e1b 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -463,7 +463,7 @@ begin_test "ghe-backup stores version when not run from a clone" # Make sure this doesn't exist rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" - tmpdir=(mktemp -d $TRASHDIR/foo.XXXXXX) + tmpdir=$(mktemp -d $TRASHDIR/foo.XXXXXX) git clone $ROOTDIR $tmpdir/backup-utils cd $tmpdir/backup-utils rm -rf .git From f66bd7982e4e5368843dead83fae52aa07688093 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 27 Feb 2017 21:14:40 +0100 Subject: [PATCH 0140/2421] Suppress dd output noise ``` Starting restore of rubiojr5.foobar.com:122 from snapshot 20170227T112756 rubiojr5-app-1: 0+1 records in rubiojr5-app-1: 0+1 records out rubiojr5-app-1: 10 bytes (10 B) copied, 7.1914e-05 s, 139 kB/s Error: rubiojr5.foobar.com:122 must be put in maintenance mode before restoring. Aborting. rubiojr5-app-1: 0+1 records in rubiojr5-app-1: 0+1 records out rubiojr5-app-1: 7 bytes (7 B) copied, 8.4164e-05 s, 83.2 kB/s ``` --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b6f4d58e2..7588d81da 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -164,11 +164,11 @@ ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNA update_restore_status () { if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then if $cluster; then - echo "ghe-cluster-each -- \"echo '$1' | sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | + echo "ghe-cluster-each -- \"echo '$1' | sudo dd status=none of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | ghe-ssh "$GHE_HOSTNAME" /bin/bash else echo "$1" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd status=none of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" fi fi } @@ -251,7 +251,7 @@ fi if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $cluster; then echo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of='$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd status=none of='$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" fi echo "Restoring MySQL database ..." From 4ef4732b3eb5bc40fa6d5275672cccc9e7d8ead5 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 28 Feb 2017 12:53:57 +1100 Subject: [PATCH 0141/2421] Unshallow repository for ci in precise environment on travis Git 1.8, as used on the precise environment on travis, doesn't support cloning from a shallow repository. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 45225295b..b807bfcac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ matrix: addons: apt: packages: devscripts + before_script: git fetch --unshallow script: debuild -uc -us - os: linux dist: trusty From 01467741c4e4e44b8bc1891cd6bea45248ffb696 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 28 Feb 2017 10:04:51 +0100 Subject: [PATCH 0142/2421] Use the rsync backup strategy to backup all ha configurations --- bin/ghe-backup | 28 +++---------------- share/github-backup-utils/ghe-backup-strategy | 27 ++++++++++++++++++ 2 files changed, 31 insertions(+), 24 deletions(-) create mode 100755 share/github-backup-utils/ghe-backup-strategy diff --git a/bin/ghe-backup b/bin/ghe-backup index 852a9e104..943bd1921 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -85,33 +85,13 @@ echo "Starting backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP" ghe_remote_version_required echo "$GHE_REMOTE_VERSION" > version -# Figure out if we're restoring into cluster -cluster=false -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then - cluster=true -fi - # Log backup start message in /var/log/syslog on remote instance ghe_remote_logger "Starting backup from $(hostname) in snapshot $GHE_SNAPSHOT_TIMESTAMP ..." -# Determine whether to use the rsync or tarball backup strategy based on the -# remote appliance version. The tarball strategy must be used with GitHub -# Enterprise versions prior to 11.10.340 since rsync is not available. -# The tarball strategy may be forced for newer versions by setting -# GHE_BACKUP_STRATEGY=tarball in backup.config but this is not recommended. -: ${GHE_BACKUP_STRATEGY:=rsync} -if [ $GHE_VERSION_MAJOR -eq 1 -a $GHE_VERSION_PATCH -lt 340 ]; then - GHE_BACKUP_STRATEGY="tarball" -fi - -if $cluster; then - GHE_BACKUP_STRATEGY="cluster" -fi +export GHE_BACKUP_STRATEGY=${GHE_BACKUP_STRATEGY:-$(ghe-backup-strategy)} # Record the strategy with the snapshot so we will know how to restore. echo "$GHE_BACKUP_STRATEGY" > strategy -export GHE_BACKUP_STRATEGY # If we're using the tarball backup strategy, put the appliance in maintenance # mode and wait for all writing processes to bleed out. @@ -150,7 +130,7 @@ failures="$failures mysql" bm_end "ghe-export-mysql" echo "Backing up Redis database ..." -if $cluster; then +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-backup-redis-cluster > redis.rdb || failures="$failures redis" else @@ -187,7 +167,7 @@ ghe-backup-pages-${GHE_BACKUP_STRATEGY} || failures="$failures pages" if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - if $cluster; then + if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "Backing up asset attachments ..." ghe-backup-alambic-cluster || failures="$failures alambic_assets" @@ -216,7 +196,7 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi -if ! $cluster; then +if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then echo "Backing up Elasticsearch indices ..." ghe-backup-es-${GHE_BACKUP_STRATEGY} || failures="$failures elasticsearch" diff --git a/share/github-backup-utils/ghe-backup-strategy b/share/github-backup-utils/ghe-backup-strategy new file mode 100755 index 000000000..7ddab5167 --- /dev/null +++ b/share/github-backup-utils/ghe-backup-strategy @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-strategy +#/ +#/ Determine the backup strategy that will be used. +#/ +#/ The tarball strategy must be used with GitHub Enterprise versions prior to +#/ 11.10.340 since rsync is not available. +#/ +#/ The rsync strategy should be used for single VMs and all HA configurations. +#/ +#/ The cluster strategy should be used to backup GHE clusters. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +if [ $GHE_VERSION_MAJOR -eq 1 -a $GHE_VERSION_PATCH -lt 340 ]; then + echo "tarball" +elif ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then + echo "rsync" +elif ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then + echo "cluster" +else + echo "rsync" +fi From fdc52f824a4ea47d1c849258d7e9f5ae0e23e82d Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 28 Feb 2017 10:04:51 +0100 Subject: [PATCH 0143/2421] Use the rsync backup strategy to backup all ha configurations --- bin/ghe-backup | 28 +++---------------- share/github-backup-utils/ghe-backup-strategy | 27 ++++++++++++++++++ 2 files changed, 31 insertions(+), 24 deletions(-) create mode 100755 share/github-backup-utils/ghe-backup-strategy diff --git a/bin/ghe-backup b/bin/ghe-backup index 852a9e104..943bd1921 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -85,33 +85,13 @@ echo "Starting backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP" ghe_remote_version_required echo "$GHE_REMOTE_VERSION" > version -# Figure out if we're restoring into cluster -cluster=false -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then - cluster=true -fi - # Log backup start message in /var/log/syslog on remote instance ghe_remote_logger "Starting backup from $(hostname) in snapshot $GHE_SNAPSHOT_TIMESTAMP ..." -# Determine whether to use the rsync or tarball backup strategy based on the -# remote appliance version. The tarball strategy must be used with GitHub -# Enterprise versions prior to 11.10.340 since rsync is not available. -# The tarball strategy may be forced for newer versions by setting -# GHE_BACKUP_STRATEGY=tarball in backup.config but this is not recommended. -: ${GHE_BACKUP_STRATEGY:=rsync} -if [ $GHE_VERSION_MAJOR -eq 1 -a $GHE_VERSION_PATCH -lt 340 ]; then - GHE_BACKUP_STRATEGY="tarball" -fi - -if $cluster; then - GHE_BACKUP_STRATEGY="cluster" -fi +export GHE_BACKUP_STRATEGY=${GHE_BACKUP_STRATEGY:-$(ghe-backup-strategy)} # Record the strategy with the snapshot so we will know how to restore. echo "$GHE_BACKUP_STRATEGY" > strategy -export GHE_BACKUP_STRATEGY # If we're using the tarball backup strategy, put the appliance in maintenance # mode and wait for all writing processes to bleed out. @@ -150,7 +130,7 @@ failures="$failures mysql" bm_end "ghe-export-mysql" echo "Backing up Redis database ..." -if $cluster; then +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-backup-redis-cluster > redis.rdb || failures="$failures redis" else @@ -187,7 +167,7 @@ ghe-backup-pages-${GHE_BACKUP_STRATEGY} || failures="$failures pages" if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - if $cluster; then + if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "Backing up asset attachments ..." ghe-backup-alambic-cluster || failures="$failures alambic_assets" @@ -216,7 +196,7 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi fi -if ! $cluster; then +if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then echo "Backing up Elasticsearch indices ..." ghe-backup-es-${GHE_BACKUP_STRATEGY} || failures="$failures elasticsearch" diff --git a/share/github-backup-utils/ghe-backup-strategy b/share/github-backup-utils/ghe-backup-strategy new file mode 100755 index 000000000..7ddab5167 --- /dev/null +++ b/share/github-backup-utils/ghe-backup-strategy @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-strategy +#/ +#/ Determine the backup strategy that will be used. +#/ +#/ The tarball strategy must be used with GitHub Enterprise versions prior to +#/ 11.10.340 since rsync is not available. +#/ +#/ The rsync strategy should be used for single VMs and all HA configurations. +#/ +#/ The cluster strategy should be used to backup GHE clusters. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +if [ $GHE_VERSION_MAJOR -eq 1 -a $GHE_VERSION_PATCH -lt 340 ]; then + echo "tarball" +elif ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then + echo "rsync" +elif ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then + echo "cluster" +else + echo "rsync" +fi From 803ab98e43bcaab666f5924abd0cf8b9b0d6a51d Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 28 Feb 2017 10:55:29 +0100 Subject: [PATCH 0144/2421] Bump backup-utils to 2.9.0 (#87) --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 9f8d8a916..c8e38b614 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.8.3 +2.9.0 From 5162d0b9f55e4b43a729022bca33333bda124223 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 28 Feb 2017 20:57:19 +1100 Subject: [PATCH 0145/2421] Use sponge instead of dd status=none is not available on precise, so use sponge instead to maintain backwards compatibility. --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7588d81da..be133f09b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -164,11 +164,11 @@ ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNA update_restore_status () { if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then if $cluster; then - echo "ghe-cluster-each -- \"echo '$1' | sudo dd status=none of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | + echo "ghe-cluster-each -- \"echo '$1' | sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | ghe-ssh "$GHE_HOSTNAME" /bin/bash else echo "$1" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd status=none of='$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" + ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" fi fi } @@ -251,7 +251,7 @@ fi if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $cluster; then echo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd status=none of='$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" + ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" fi echo "Restoring MySQL database ..." From 3fc7d92800a8fbbd40527ec98e25b183f338a4e5 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 28 Feb 2017 21:26:17 +1100 Subject: [PATCH 0146/2421] Moreutils is required for travis --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 45225295b..32e28c5a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,15 @@ matrix: before_install: - brew update - brew install gnu-tar + - brew install moreutils script: make test - os: linux sudo: false addons: apt: - packages: devscripts + packages: + - devscripts + - moreutils script: debuild -uc -us - os: linux dist: trusty @@ -20,4 +23,5 @@ matrix: packages: - devscripts - debhelper + - moreutils script: debuild -uc -us From bc631ab960089477f2f1f17682f386cd9435c059 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 28 Feb 2017 11:41:42 -0500 Subject: [PATCH 0147/2421] Filter cluster hostnames based on prefix role This attempts to fix https://github.com/github/enterprise2/issues/10651 The script was not checking if the uuid host is in role as provided by a prefix. --- share/github-backup-utils/ghe-cluster-hostnames | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-cluster-hostnames b/share/github-backup-utils/ghe-cluster-hostnames index 32643d976..55a391e36 100755 --- a/share/github-backup-utils/ghe-cluster-hostnames +++ b/share/github-backup-utils/ghe-cluster-hostnames @@ -22,7 +22,12 @@ if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) hostnames='' for uuid in $node_uuids; do - hostnames+="$prefix-$uuid " + hostname_with_role=$(ghe-config --get-regexp cluster.*.uuid | grep $prefix | cut -d ' ' -f 1 | sed 's\uuid\git-server\g') || true + if [ -n "$hostname_with_role"]; then + if $(ghe-config $hostname_with_role); then + hostnames+="$prefix-$uuid " + fi + fi done else hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) From ad27e738e52a835c6ff34ebae9dd703bbf66b941 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 28 Feb 2017 12:06:47 -0500 Subject: [PATCH 0148/2421] ssh first into host then run ghe-config --- share/github-backup-utils/ghe-cluster-hostnames | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-cluster-hostnames b/share/github-backup-utils/ghe-cluster-hostnames index 55a391e36..949902732 100755 --- a/share/github-backup-utils/ghe-cluster-hostnames +++ b/share/github-backup-utils/ghe-cluster-hostnames @@ -22,7 +22,7 @@ if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) hostnames='' for uuid in $node_uuids; do - hostname_with_role=$(ghe-config --get-regexp cluster.*.uuid | grep $prefix | cut -d ' ' -f 1 | sed 's\uuid\git-server\g') || true + hostname_with_role=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | grep $prefix | cut -d ' ' -f 1 | sed 's\uuid\git-server\g') || true if [ -n "$hostname_with_role"]; then if $(ghe-config $hostname_with_role); then hostnames+="$prefix-$uuid " From 0a6ef0936b26fd42d35d179ee036387858ddb7d2 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 28 Feb 2017 12:10:01 -0500 Subject: [PATCH 0149/2421] use uuid var and fix hardcoded prefix --- share/github-backup-utils/ghe-cluster-hostnames | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-cluster-hostnames b/share/github-backup-utils/ghe-cluster-hostnames index 949902732..d8412dfe2 100755 --- a/share/github-backup-utils/ghe-cluster-hostnames +++ b/share/github-backup-utils/ghe-cluster-hostnames @@ -22,7 +22,7 @@ if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) hostnames='' for uuid in $node_uuids; do - hostname_with_role=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | grep $prefix | cut -d ' ' -f 1 | sed 's\uuid\git-server\g') || true + hostname_with_role=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | grep $uuid | cut -d ' ' -f 1 | sed 's\uuid\$prefix\g') || true if [ -n "$hostname_with_role"]; then if $(ghe-config $hostname_with_role); then hostnames+="$prefix-$uuid " From 9699f5399be97b832831866b3c4680ded8d936a0 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 28 Feb 2017 09:29:02 -0800 Subject: [PATCH 0150/2421] fix if block and make sure we ssh into host --- share/github-backup-utils/ghe-cluster-hostnames | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-cluster-hostnames b/share/github-backup-utils/ghe-cluster-hostnames index d8412dfe2..797854a07 100755 --- a/share/github-backup-utils/ghe-cluster-hostnames +++ b/share/github-backup-utils/ghe-cluster-hostnames @@ -22,9 +22,9 @@ if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) hostnames='' for uuid in $node_uuids; do - hostname_with_role=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | grep $uuid | cut -d ' ' -f 1 | sed 's\uuid\$prefix\g') || true - if [ -n "$hostname_with_role"]; then - if $(ghe-config $hostname_with_role); then + hostname_with_role=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | grep $uuid | cut -d ' ' -f 1 | sed "s/uuid/$prefix/g") || true + if [ -n "$hostname_with_role" ]; then + if $(ghe-ssh "$GHE_HOSTNAME" ghe-config $hostname_with_role); then hostnames+="$prefix-$uuid " fi fi From decfbba10c35f4d83be37eee50c72b5b40f815b1 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 28 Feb 2017 12:53:44 -0500 Subject: [PATCH 0151/2421] Moved the new functionality to a new file --- .../github-backup-utils/ghe-cluster-hostnames | 7 +--- share/github-backup-utils/ghe-cluster-nodes | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 6 deletions(-) create mode 100755 share/github-backup-utils/ghe-cluster-nodes diff --git a/share/github-backup-utils/ghe-cluster-hostnames b/share/github-backup-utils/ghe-cluster-hostnames index 797854a07..32643d976 100755 --- a/share/github-backup-utils/ghe-cluster-hostnames +++ b/share/github-backup-utils/ghe-cluster-hostnames @@ -22,12 +22,7 @@ if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) hostnames='' for uuid in $node_uuids; do - hostname_with_role=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | grep $uuid | cut -d ' ' -f 1 | sed "s/uuid/$prefix/g") || true - if [ -n "$hostname_with_role" ]; then - if $(ghe-ssh "$GHE_HOSTNAME" ghe-config $hostname_with_role); then - hostnames+="$prefix-$uuid " - fi - fi + hostnames+="$prefix-$uuid " done else hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes new file mode 100755 index 000000000..d959bccad --- /dev/null +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +#/ Usage: ghe-cluster-nodes +#/ +#/ Finds all nodes of the cluster using the config on . +#/ If it is a 2.8 cluster the results are returned as prefix-uuid, +#/ otherwise the configured hostnames are returned. +#/ Also filters nodes based on the prefix role. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore-* commands when restoring into a cluster. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +GHE_HOSTNAME="$1" +prefix="$2" + +if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) + hostnames='' + for uuid in $node_uuids; do + hostname_with_role=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | grep $uuid | cut -d ' ' -f 1 | sed "s/uuid/$prefix/g") || true + if [ -n "$hostname_with_role" ]; then + if $(ghe-ssh "$GHE_HOSTNAME" ghe-config $hostname_with_role); then + hostnames+="$prefix-$uuid " + fi + fi + done +else + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) +fi + +echo "$hostnames" From 0772169495fb9a855b25ed835bd7ab17b28c7f8c Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 28 Feb 2017 13:03:02 -0500 Subject: [PATCH 0152/2421] adding some comments --- share/github-backup-utils/ghe-cluster-nodes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index d959bccad..70a658b04 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -23,8 +23,10 @@ if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) hostnames='' for uuid in $node_uuids; do + #match uuid to role in prefix i.e git-server , git-web-server etc hostname_with_role=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | grep $uuid | cut -d ' ' -f 1 | sed "s/uuid/$prefix/g") || true if [ -n "$hostname_with_role" ]; then + #check that the prefix role value is true if $(ghe-ssh "$GHE_HOSTNAME" ghe-config $hostname_with_role); then hostnames+="$prefix-$uuid " fi From 5f0d129380a464c9954e2017c333b98a2edf340b Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 1 Mar 2017 10:53:46 +1100 Subject: [PATCH 0153/2421] Prevent restores to an appliance in a HA pair --- bin/ghe-restore | 12 ++++++------ test/test-ghe-restore.sh | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b6f4d58e2..dff8521f4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -115,12 +115,12 @@ if $cluster; then fi fi -# Figure out if this instance is in a replication pair -if ghe-ssh "$GHE_HOSTNAME" -- "ghe-repl-status -r 2>/dev/null" \ - | grep -Eq "replica|primary"; then - instance_configured=true - echo "WARNING: Restoring to a server with replication enabled interrupts replication." - echo " You will need to reconfigure replication after the restore completes." +# Figure out if this appliance is in a replication pair +if ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then + echo "Error: Restoring to an appliance with replication enabled is not supported." >&2 + echo " Please teardown replication before restoring." >&2 + exit 1 fi # Prompt to verify the restore host given is correct. Restoring overwrites diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 035a588f8..fbd1406b2 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -607,3 +607,24 @@ EOF echo $output | grep -q "The snapshot that is being restored contains a leaked SSH host key." ) end_test + +begin_test "ghe-restore fails when restore to an active HA pair" +( + set -e + + if [ "$GHE_VERSION_MAJOR" -le 1 ]; then + # noop GHE < 2.0, does not support replication + exit 0 + fi + + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + echo "rsync" > "$GHE_DATA_DIR/current/strategy" + touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + + ! output=$(ghe-restore -v -f localhost 2>&1) + + echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." +) +end_test From 7c6bd4bedceee2840b6951c38ca13dc56bfb740c Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 1 Mar 2017 10:53:46 +1100 Subject: [PATCH 0154/2421] Prevent restores to an appliance in a HA pair --- bin/ghe-restore | 12 ++++++------ test/test-ghe-restore.sh | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b6f4d58e2..dff8521f4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -115,12 +115,12 @@ if $cluster; then fi fi -# Figure out if this instance is in a replication pair -if ghe-ssh "$GHE_HOSTNAME" -- "ghe-repl-status -r 2>/dev/null" \ - | grep -Eq "replica|primary"; then - instance_configured=true - echo "WARNING: Restoring to a server with replication enabled interrupts replication." - echo " You will need to reconfigure replication after the restore completes." +# Figure out if this appliance is in a replication pair +if ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then + echo "Error: Restoring to an appliance with replication enabled is not supported." >&2 + echo " Please teardown replication before restoring." >&2 + exit 1 fi # Prompt to verify the restore host given is correct. Restoring overwrites diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 035a588f8..fbd1406b2 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -607,3 +607,24 @@ EOF echo $output | grep -q "The snapshot that is being restored contains a leaked SSH host key." ) end_test + +begin_test "ghe-restore fails when restore to an active HA pair" +( + set -e + + if [ "$GHE_VERSION_MAJOR" -le 1 ]; then + # noop GHE < 2.0, does not support replication + exit 0 + fi + + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + echo "rsync" > "$GHE_DATA_DIR/current/strategy" + touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + + ! output=$(ghe-restore -v -f localhost 2>&1) + + echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." +) +end_test From 7eaf5b7fa7d380e32ad74f0814e549f63cbf5750 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 28 Feb 2017 16:46:19 -0800 Subject: [PATCH 0155/2421] eliminate multiple ghe-ssh to the host. Get the cluster config data once and then use that to filter for role. --- share/github-backup-utils/ghe-cluster-nodes | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index 70a658b04..3e4b7c1ec 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -20,15 +20,16 @@ GHE_HOSTNAME="$1" prefix="$2" if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then - node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) + cluster_configs=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*) + node_uuids=$(echo "$cluster_configs" | grep -P "cluster.*.uuid" | cut -d ' ' -f 2) hostnames='' for uuid in $node_uuids; do #match uuid to role in prefix i.e git-server , git-web-server etc - hostname_with_role=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | grep $uuid | cut -d ' ' -f 1 | sed "s/uuid/$prefix/g") || true + hostname_with_role=$(echo "$cluster_configs" | grep "$uuid" | cut -d ' ' -f 1 | sed "s/uuid/$prefix/g") || true if [ -n "$hostname_with_role" ]; then #check that the prefix role value is true - if $(ghe-ssh "$GHE_HOSTNAME" ghe-config $hostname_with_role); then - hostnames+="$prefix-$uuid " + if grep "$hostname_with_role" <<< "$cluster_configs" > /dev/null ; then + hostnames+="$prefix-$uuid " fi fi done From 7fc1ace26cea88c361019e012bb8db018a00e0d7 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Tue, 28 Feb 2017 10:55:29 +0100 Subject: [PATCH 0156/2421] Bump version: 2.9.0 --- debian/changelog | 10 ++++++++++ share/github-backup-utils/version | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 162db58f8..bf83aff8c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +github-backup-utils (2.9.0) UNRELEASED; urgency=medium + + * Block restores to appliances with HA configured #291 + * Add a `--version` flag #284 + * Check backup-utils are not being run on GitHub Enterprise host #286 + * Backup and restore custom CA certificates #281 + * Hookshot backup/restores optimisations #276 + + -- Sergio Rubio Wed, 01 Mar 2017 09:39:26 -0800 + github-backup-utils (2.8.3) UNRELEASED; urgency=medium * Set restore status on all cluster nodes #274 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 9f8d8a916..c8e38b614 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.8.3 +2.9.0 From 270b8333d1dac74656b9d25921d4fab721a941b0 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Wed, 1 Mar 2017 19:01:55 +0100 Subject: [PATCH 0157/2421] The release tarball doesn't have a git revision --- RELEASING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index 43495d27c..a1767ba24 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -10,5 +10,5 @@ 5. Build that tarball package: `make dist` 6. Build the deb package: `make deb`. All the tests should pass. 7. Draft a new release at https://github.com/github/backup-utils/releases, including the release notes and attaching the tarball and deb packages. - The dist tarball you should upload has the git revision in the file name, i.e. something like `github-backup-utils-v2.5.0-1-g23c41cc.tar.gz` + The dist tarball you should upload has the git revision in the file name, i.e. something like `github-backup-utils-v2.5.0.tar.gz` 8. Push the head of the release to the 'stable' branch. From 555a7e9a3cffdea4729651c13bed3b93ade52e76 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Thu, 2 Mar 2017 12:23:08 -0500 Subject: [PATCH 0158/2421] Adding test for ghe-cluster-nodes filtering Use a fake set of ghe-config results and make sure that ghe-cluster-nodes filters based on that output. Changed the hardcoded data directory to use the env var for /data/user folder. Used -e instead of -P for MacOS compatibility. --- share/github-backup-utils/ghe-cluster-nodes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index 3e4b7c1ec..eaf5ff7f7 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -19,9 +19,9 @@ set -e GHE_HOSTNAME="$1" prefix="$2" -if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then +if ghe-ssh "$GHE_HOSTNAME" test -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid"; then cluster_configs=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*) - node_uuids=$(echo "$cluster_configs" | grep -P "cluster.*.uuid" | cut -d ' ' -f 2) + node_uuids=$(echo "$cluster_configs" | grep -e "cluster.*.uuid" | cut -d ' ' -f 2) hostnames='' for uuid in $node_uuids; do #match uuid to role in prefix i.e git-server , git-web-server etc From 80718b5a746ad05764662de5f6266691fff166b5 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Thu, 2 Mar 2017 12:36:02 -0500 Subject: [PATCH 0159/2421] Use defaults if the remote user data dir is not set --- share/github-backup-utils/ghe-cluster-nodes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index eaf5ff7f7..d4b50d743 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -13,6 +13,9 @@ set -e # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# Set user directory if not already exported from config +: ${GHE_REMOTE_DATA_USER_DIR:="/data/user"} + # Show usage and bail with no arguments [ -z "$*" ] && print_usage From ad53f75b7b6326a133a9dd4a3d4f8d126baaf3ee Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Thu, 2 Mar 2017 12:43:24 -0500 Subject: [PATCH 0160/2421] Forgot to add the test files :facepalm" --- test/bin/ghe-config | 1 + test/bin/ghe-config-cluster-values | 10 +++++++++ test/test-ghe-cluster-nodes.sh | 36 ++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 120000 test/bin/ghe-config create mode 100755 test/bin/ghe-config-cluster-values create mode 100755 test/test-ghe-cluster-nodes.sh diff --git a/test/bin/ghe-config b/test/bin/ghe-config new file mode 120000 index 000000000..ebe72d0da --- /dev/null +++ b/test/bin/ghe-config @@ -0,0 +1 @@ +ghe-config-cluster-values \ No newline at end of file diff --git a/test/bin/ghe-config-cluster-values b/test/bin/ghe-config-cluster-values new file mode 100755 index 000000000..9d6b90866 --- /dev/null +++ b/test/bin/ghe-config-cluster-values @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Usage: ghe-config +# Emulates the remote GitHub ghe-config command. Tests use this +# to assert that the command was executed. +set -e +echo "cluster.ghe-test-ha-primary.uuid 05cbcd42-f519-11e6-b6c9-002bd51dfa77 +cluster.ghe-test-ha-replica.uuid 08d94884-f519-11e6-88a1-0063a7c33551 +cluster.ghe-test-ha-primary.git-server true +cluster.ghe-test-ha-primary.web-server true +cluster.ghe-test-ha-replica.git-server true" diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh new file mode 100755 index 000000000..4ec03fcbf --- /dev/null +++ b/test/test-ghe-cluster-nodes.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash +# ghe-cluster-nodes command tests + +# Bring in testlib +. $(dirname "$0")/testlib.sh +# Setup backup snapshot data dir and remote repositories dir locations to use +# the per-test temp space. +GHE_DATA_DIR="$TRASHDIR/data" +GHE_REMOTE_DATA_DIR="$TRASHDIR/remote" +export GHE_DATA_DIR GHE_REMOTE_DATA_DIR +# Create a uuid file +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" +echo "fake uuids" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + +# Source in config file for hostname +. "$GHE_BACKUP_CONFIG" + +begin_test "ghe-cluster-nodes should return both uuids for git-server" +( + set -e + + output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + echo "$output" + [ "git-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 git-server-08d94884-f519-11e6-88a1-0063a7c33551 " = "$output" ] +) +end_test + +begin_test "ghe-cluster-nodes should return only one uuid for web-server" +( + set -e + + output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "web-server")" + echo "$output" + [ "web-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 " = "$output" ] +) +end_test From 2c14c629937bf8abd73ce8d61bb12eb3904ce142 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Wed, 8 Mar 2017 14:58:56 -0600 Subject: [PATCH 0161/2421] Dont set env var since it should already be set by config --- share/github-backup-utils/ghe-cluster-nodes | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index d4b50d743..31c4bb076 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -13,8 +13,11 @@ set -e # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config -# Set user directory if not already exported from config -: ${GHE_REMOTE_DATA_USER_DIR:="/data/user"} +# Check if the REMOTE DATA USER directory is set +if [ -z $GHE_REMOTE_DATA_USER_DIR ]; then + echo "Env variable GHE_REMOTE_DATA_USER_DIR is not set. Exiting" + exit 1 +fi # Show usage and bail with no arguments [ -z "$*" ] && print_usage From 4b548d7c3c6626d510db3c2353cc9ae81f15d393 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Wed, 8 Mar 2017 15:02:53 -0600 Subject: [PATCH 0162/2421] Update comment to include version 2.8 and later --- share/github-backup-utils/ghe-cluster-nodes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index 31c4bb076..4f178fd34 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -2,7 +2,7 @@ #/ Usage: ghe-cluster-nodes #/ #/ Finds all nodes of the cluster using the config on . -#/ If it is a 2.8 cluster the results are returned as prefix-uuid, +#/ If it is a 2.8 and later cluster version the results are returned as prefix-uuid, #/ otherwise the configured hostnames are returned. #/ Also filters nodes based on the prefix role. #/ From b75da5903eaa203bfc5d1ba56968a136e21bb485 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Thu, 9 Mar 2017 09:30:01 -0600 Subject: [PATCH 0163/2421] refactor uuid get using ghe-cluster-each refactor to make a simple call and also refactor tests --- share/github-backup-utils/ghe-cluster-nodes | 14 +++----------- test/bin/ghe-config | 2 +- test/bin/ghe-config-git-uuid | 8 ++++++++ test/test-ghe-cluster-nodes.sh | 11 +---------- 4 files changed, 13 insertions(+), 22 deletions(-) create mode 100755 test/bin/ghe-config-git-uuid diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index 4f178fd34..acf397729 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -21,23 +21,15 @@ fi # Show usage and bail with no arguments [ -z "$*" ] && print_usage - GHE_HOSTNAME="$1" prefix="$2" +role=$(echo "$prefix" | cut -d '-' -f1) if ghe-ssh "$GHE_HOSTNAME" test -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid"; then - cluster_configs=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*) - node_uuids=$(echo "$cluster_configs" | grep -e "cluster.*.uuid" | cut -d ' ' -f 2) + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config ghe-cluster-each -r "$role" -u) hostnames='' for uuid in $node_uuids; do - #match uuid to role in prefix i.e git-server , git-web-server etc - hostname_with_role=$(echo "$cluster_configs" | grep "$uuid" | cut -d ' ' -f 1 | sed "s/uuid/$prefix/g") || true - if [ -n "$hostname_with_role" ]; then - #check that the prefix role value is true - if grep "$hostname_with_role" <<< "$cluster_configs" > /dev/null ; then - hostnames+="$prefix-$uuid " - fi - fi + hostnames+="$prefix-$uuid " done else hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) diff --git a/test/bin/ghe-config b/test/bin/ghe-config index ebe72d0da..03ffca488 120000 --- a/test/bin/ghe-config +++ b/test/bin/ghe-config @@ -1 +1 @@ -ghe-config-cluster-values \ No newline at end of file +ghe-config-git-uuid \ No newline at end of file diff --git a/test/bin/ghe-config-git-uuid b/test/bin/ghe-config-git-uuid new file mode 100755 index 000000000..3229d9970 --- /dev/null +++ b/test/bin/ghe-config-git-uuid @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# Usage: ghe-config +# Emulates the remote GitHub ghe-config command. Tests use this +# to assert that the command was executed. +set -e +echo "05cbcd42-f519-11e6-b6c9-002bd51dfa77 +08d94884-f519-11e6-88a1-0063a7c33551 +" diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index 4ec03fcbf..3025e7620 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -19,18 +19,9 @@ begin_test "ghe-cluster-nodes should return both uuids for git-server" ( set -e + output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" echo "$output" [ "git-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 git-server-08d94884-f519-11e6-88a1-0063a7c33551 " = "$output" ] ) end_test - -begin_test "ghe-cluster-nodes should return only one uuid for web-server" -( - set -e - - output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "web-server")" - echo "$output" - [ "web-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 " = "$output" ] -) -end_test From ddb861bb063b3b31b0415a04b97c72d7049b6f53 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Thu, 9 Mar 2017 07:50:01 -0800 Subject: [PATCH 0164/2421] remove ghe-config since we only need ghe-cluster-each --- share/github-backup-utils/ghe-cluster-nodes | 2 +- test/bin/ghe-cluster-each | 1 + test/bin/ghe-config | 1 - test/bin/{ghe-config-git-uuid => git-uuids} | 0 4 files changed, 2 insertions(+), 2 deletions(-) create mode 120000 test/bin/ghe-cluster-each delete mode 120000 test/bin/ghe-config rename test/bin/{ghe-config-git-uuid => git-uuids} (100%) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index acf397729..6347f366a 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -26,7 +26,7 @@ prefix="$2" role=$(echo "$prefix" | cut -d '-' -f1) if ghe-ssh "$GHE_HOSTNAME" test -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid"; then - node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config ghe-cluster-each -r "$role" -u) + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -u) hostnames='' for uuid in $node_uuids; do hostnames+="$prefix-$uuid " diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each new file mode 120000 index 000000000..d7adc1af7 --- /dev/null +++ b/test/bin/ghe-cluster-each @@ -0,0 +1 @@ +git-uuids \ No newline at end of file diff --git a/test/bin/ghe-config b/test/bin/ghe-config deleted file mode 120000 index 03ffca488..000000000 --- a/test/bin/ghe-config +++ /dev/null @@ -1 +0,0 @@ -ghe-config-git-uuid \ No newline at end of file diff --git a/test/bin/ghe-config-git-uuid b/test/bin/git-uuids similarity index 100% rename from test/bin/ghe-config-git-uuid rename to test/bin/git-uuids From f04613f7ca87eb3959151443d7a242b5dfc81bf6 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Thu, 9 Mar 2017 10:02:27 -0600 Subject: [PATCH 0165/2421] removing unneeded config vars --- test/test-ghe-cluster-nodes.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index 3025e7620..b42c2ae37 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -12,9 +12,6 @@ export GHE_DATA_DIR GHE_REMOTE_DATA_DIR mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" echo "fake uuids" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" -# Source in config file for hostname -. "$GHE_BACKUP_CONFIG" - begin_test "ghe-cluster-nodes should return both uuids for git-server" ( set -e From 3674791b11e473e0297685477a7fe151d61b845b Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Fri, 10 Mar 2017 11:01:57 -0600 Subject: [PATCH 0166/2421] replace cluster-hostnames with new filtering script --- share/github-backup-utils/ghe-backup-repositories-cluster-ng | 2 +- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 +- share/github-backup-utils/ghe-restore-pages-dpages | 2 +- share/github-backup-utils/ghe-restore-repositories-dgit-ng | 2 +- share/github-backup-utils/ghe-restore-repositories-gist-ng | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index a8e190a85..70dbbfb54 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -74,7 +74,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # git server hostnames -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") for hostname in $hostnames; do config="$config Host $hostname diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 2794737d0..635b5bb2b 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -44,7 +44,7 @@ user="${host%@*}" # Generate SSH config for forwarding config="" -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server"); do +for hostname in $(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server"); do config="$config Host $hostname ServerAliveInterval 60 diff --git a/share/github-backup-utils/ghe-restore-pages-dpages b/share/github-backup-utils/ghe-restore-pages-dpages index 4014e80df..6dfa49cef 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages +++ b/share/github-backup-utils/ghe-restore-pages-dpages @@ -45,7 +45,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "pages-server"); do +for hostname in $(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server"); do config="$config Host $hostname ServerAliveInterval 60 diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 488351277..abc3a153f 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -72,7 +72,7 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") for hostname in $hostnames; do echo " Host $hostname diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index d68d3a2ac..da0cc618b 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -46,7 +46,7 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server"); do +for hostname in $(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server"); do echo " Host $hostname ServerAliveInterval 60 From e052a9ed3be69b44aa8115cf095cdd56b75f6269 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 5 Apr 2017 12:30:34 +1000 Subject: [PATCH 0167/2421] Wait for each sync_data process This will allow us to pass the exit code for each sync_data process through to the parent script. --- .../ghe-backup-repositories-cluster-ng | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index a8e190a85..7d2e34cdf 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -94,10 +94,15 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { + for pid in $(jobs -p); do + wait $pid + done + # Enable remote GC operations for hostname in $hostnames; do ghe-gc-enable -F $config_file $hostname:$port done + rm -f $config_file rm -rf $tempdir } @@ -322,7 +327,10 @@ for file_list in $tempdir/*.rsync; do sync_data $hostname $file_list & done -wait + +for pid in $(jobs -p); do + wait $pid +done bm_end "$(basename $0) - Repo sync" # Since there are no routes for special data directories From a35999bd04ef6a2ce9a12dd132eca57a5bc8899f Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 5 Apr 2017 12:32:30 +1000 Subject: [PATCH 0168/2421] Kill sync_data processes on cleanup --- share/github-backup-utils/ghe-backup-repositories-cluster-ng | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 7d2e34cdf..d6f2c3679 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -95,14 +95,14 @@ mkdir -p "$backup_dir" # on the remote instance. cleanup() { for pid in $(jobs -p); do - wait $pid + kill -KILL $pid > /dev/null 2>&1 || true done # Enable remote GC operations for hostname in $hostnames; do ghe-gc-enable -F $config_file $hostname:$port done - + rm -f $config_file rm -rf $tempdir } From 621509cfacb8466996cb81d5289c0227a2667dac Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 4 Apr 2017 22:28:32 -0700 Subject: [PATCH 0169/2421] minor wording fixes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bf4cf21d..0ac324ed4 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ supported. We strongly recommend upgrading to the latest release if you're running a version prior to 11.10.342. Visit [enterprise.github.com][5] to download the most recent GitHub Enterprise version. -Note: You can only restore from snapshot that's at most two releases ahead of the version of GitHub Enterprise running on your backup host. For example, to restore from a snapshot running GitHub Enterprise 2.7, your backup host must be on GitHub Enterprise 2.6 or 2.5. You can't restore from 2.4 to 2.7, because that's three releases behind. +Note: You can restore a snapshot that's at most two feature releases behind the restore target's version of GitHub Enterprise. For example, to restore a snapshot of GitHub Enterprise 2.4, the target GitHub Enterprise appliance must be running GitHub Enterprise 2.5.x or 2.6.x. You can't restore a snapshot from 2.4 to 2.7, because that's three releases ahead. ### Getting started From ac0338c8a7de3ec4bcf21cb5c12583e433835799 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 7 Apr 2017 21:05:01 +1000 Subject: [PATCH 0170/2421] Track completeness of elasticsearch dumps --- share/github-backup-utils/ghe-backup-es-audit-log | 8 ++++++-- share/github-backup-utils/ghe-backup-es-hookshot | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index a8afc1293..d3e84b838 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -34,11 +34,15 @@ fi current_index=audit_log-$(ghe-ssh "$host" 'date +"%Y-%m"') for index in $indices; do - if [ -f $GHE_DATA_DIR/current/audit-log/$index.gz -a $index \< $current_index ]; then - # Hard link any older indices since they are read only and won't change + if [ -f $GHE_DATA_DIR/current/audit-log/$index.gz -a -f $GHE_DATA_DIR/current/audit-log/$index.gz.complete -a $index \< $current_index ]; then + # Hard link any older indices that are complete, since these won't change ln $GHE_DATA_DIR/current/audit-log/$index.gz $GHE_SNAPSHOT_DIR/audit-log/$index.gz + ln $GHE_DATA_DIR/current/audit-log/$index.gz.complete $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete else ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index.gz + if [ $index \< $current_index ]; then + touch $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete + fi fi done diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index 2cf4c8aba..65f8f67e2 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -21,14 +21,19 @@ ghe_remote_version_required "$host" mkdir -p "$GHE_SNAPSHOT_DIR/hookshot" indices=$(ghe-ssh "$host" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3) + current_index=hookshot-logs-$(ghe-ssh "$host" 'date +"%Y-%m-%d"') for index in $indices; do - if [ -f $GHE_DATA_DIR/current/hookshot/$index.gz -a $index \< $current_index ]; then - # Hard link any older indices since they are read only and won't change + if [ -f $GHE_DATA_DIR/current/hookshot/$index.gz -a -f $GHE_DATA_DIR/current/hookshot/$index.gz.complete -a $index \< $current_index ]; then + # Hard link any older indices that are complete, since these won't change ln $GHE_DATA_DIR/current/hookshot/$index.gz $GHE_SNAPSHOT_DIR/hookshot/$index.gz + ln $GHE_DATA_DIR/current/hookshot/$index.gz.complete $GHE_SNAPSHOT_DIR/hookshot/$index.gz.complete else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json 'http://localhost:9201/$index'" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index.gz + ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index.gz + if [ $index \< $current_index ]; then + touch $GHE_SNAPSHOT_DIR/hookshot/$index.gz.complete + fi fi done From 04f141dae49fcfecc9ba65d29a4fdd7808ff6de8 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 7 Apr 2017 21:05:01 +1000 Subject: [PATCH 0171/2421] Track completeness of elasticsearch dumps --- share/github-backup-utils/ghe-backup-es-audit-log | 8 ++++++-- share/github-backup-utils/ghe-backup-es-hookshot | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index a8afc1293..d3e84b838 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -34,11 +34,15 @@ fi current_index=audit_log-$(ghe-ssh "$host" 'date +"%Y-%m"') for index in $indices; do - if [ -f $GHE_DATA_DIR/current/audit-log/$index.gz -a $index \< $current_index ]; then - # Hard link any older indices since they are read only and won't change + if [ -f $GHE_DATA_DIR/current/audit-log/$index.gz -a -f $GHE_DATA_DIR/current/audit-log/$index.gz.complete -a $index \< $current_index ]; then + # Hard link any older indices that are complete, since these won't change ln $GHE_DATA_DIR/current/audit-log/$index.gz $GHE_SNAPSHOT_DIR/audit-log/$index.gz + ln $GHE_DATA_DIR/current/audit-log/$index.gz.complete $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete else ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index.gz + if [ $index \< $current_index ]; then + touch $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete + fi fi done diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index 2cf4c8aba..65f8f67e2 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -21,14 +21,19 @@ ghe_remote_version_required "$host" mkdir -p "$GHE_SNAPSHOT_DIR/hookshot" indices=$(ghe-ssh "$host" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3) + current_index=hookshot-logs-$(ghe-ssh "$host" 'date +"%Y-%m-%d"') for index in $indices; do - if [ -f $GHE_DATA_DIR/current/hookshot/$index.gz -a $index \< $current_index ]; then - # Hard link any older indices since they are read only and won't change + if [ -f $GHE_DATA_DIR/current/hookshot/$index.gz -a -f $GHE_DATA_DIR/current/hookshot/$index.gz.complete -a $index \< $current_index ]; then + # Hard link any older indices that are complete, since these won't change ln $GHE_DATA_DIR/current/hookshot/$index.gz $GHE_SNAPSHOT_DIR/hookshot/$index.gz + ln $GHE_DATA_DIR/current/hookshot/$index.gz.complete $GHE_SNAPSHOT_DIR/hookshot/$index.gz.complete else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json 'http://localhost:9201/$index'" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index.gz + ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index.gz + if [ $index \< $current_index ]; then + touch $GHE_SNAPSHOT_DIR/hookshot/$index.gz.complete + fi fi done From d9aeea661cb1b058cf5f1e893c52e5070cf0dedf Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Sat, 8 Apr 2017 18:45:51 +0200 Subject: [PATCH 0172/2421] Automate backup-utils releases Script to automate backup-util releases using the existing conventions and format. The intention is to release with a single command: ``` ./script/release 2.9.1 ``` --- script/release | 301 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+) create mode 100755 script/release diff --git a/script/release b/script/release new file mode 100755 index 000000000..ea969b03a --- /dev/null +++ b/script/release @@ -0,0 +1,301 @@ +#!/usr/bin/env ruby +#/ Usage: release [--dry-run] +#/ +#/ Publish a backup-utils release: +#/ * Updates the package changelog +#/ * Bumps the backup-utils version if required +#/ * Creates the release pull request +#/ * Creates the release draft +#/ * Tags the release +#/ * Builds the release assets and uploads them +#/ +#/ Notes: +#/ * Needs GH_RELEASE_TOKEN available in the environment. +#/ * Export GH_OWNER, GH_AUTHOR and GH_REPO if you want to tweak the build +#/ changelog or use a different owner/repo +#/ * Only pull requests labeled with bug or feature will show up in the +#/ release page and the changelog. +#/ +# TODO: Auto-merge the release PR +# TODO: Tag the release +# TODO: Build and upload the binaries to the release draft +require 'json' +require 'net/http' +require 'time' +require 'erb' + +API_HOST = ENV["GH_HOST"] || "api.github.com" +API_PORT = 443 +GH_REPO = ENV["GH_REPO"] || "backup-utils" +GH_OWNER = ENV["GH_OWNER"] || "github" +GH_AUTHOR = ENV["GH_AUTHOR"] || "Sergio Rubio " +DEB_PKG_NAME = "github-backup-utils" + +CHANGELOG_TMPL = """ +<%G= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium + +<%- changes.each do |ch| -%> + * <%= ch.strip.chomp %> +<% end -%> + + -- <%= author %> <%= Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S %z') %> + +""" + +# Override Kernel.warn +def warn(msg) + unless $no_warn + Kernel.warn msg + end +end + +def client + @http ||= begin + c = Net::HTTP.new(API_HOST, API_PORT) + c.use_ssl = true + c + end +end + +def release_token + token = ENV["GH_RELEASE_TOKEN"] + raise "GH_RELEASE_TOKEN not set" if token.nil? + + token +end + +def get(path) + req = Net::HTTP::Get.new(path) + req['Authorization'] = "token #{release_token}" + client.request(req) +end + +def post(path, body) + req = Net::HTTP::Post.new(path) + req['Authorization'] = "token #{release_token}" + req.body = body + client.request(req) +end + +# +# tag "v0.0.1", "foo tag", +# "e1d0d72078f7fbef653e705bfb0fe018bd9c772e", +# "foolano", "test", +# "Foolano Garcia", "foolano@garciagarcia.com" +def tag(name, message, sha, owner, repo, tagger_name, tagger_email) + r = { + "tag": name, + "message": "#{message}\n", + "object": sha, + "type": "commit", + "tagger": { + "name": tagger_name, + "email": tagger_email, + "date": Time.now.utc.iso8601.to_s + } + }.to_json + res = post("/repos/#{owner}/#{repo}/git/tags", r) + + raise "Creating tag object failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess + + body = { + "ref": "refs/heads/#{name}", + "sha": sha + }.to_json + res = post("/repos/#{owner}/#{repo}/git/refs", body) + + raise "Creating tag ref failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess +end + +def bug_or_feature?(issue_hash) + return true if issue_hash["labels"].find { |l| ["bug", "feature"].include?(l["name"]) } + false +end + +def issue_from(owner, repo, issue) + res = get("/repos/#{owner}/#{repo}/issues/#{issue}") + raise "Issue ##{issue} not found in #{owner}/#{repo}" unless res.kind_of? Net::HTTPSuccess + + JSON.parse(res.body) +end + +def beautify_changes(changes, owner, repo) + c = [] + changes.each do |ch| + if ch =~ /#(\d+)/ + begin + j = issue_from(owner, repo, $1) + if bug_or_feature?(j) + c << "#{j['title']} ##{$1}" + end + rescue => e + warn "Warning: #{e.message}" + end + end + end + + c +end + +def changelog() + changes = `git log --pretty=oneline origin/stable...origin/master | grep "Merge pull request"`.lines + raise "Building the changelog failed" if $? != 0 + + changes +end + +def build_changelog(changes, package_name, package_version, author, owner, repo) + ERB.new(CHANGELOG_TMPL, nil, "-").result(binding) +end + +def update_changelog(changes, name, version, author, owner, repo, path = "debian/changelog") + raise "debian/changelog not found" unless File.exist?(path) + File.open("#{path}.new", 'w') do |f| + f.puts build_changelog changes, name, version, author, owner, repo + f.puts(File.read(path)) + end + File.rename("#{path}.new", path) +end + +def create_release(tag_name, branch, owner, repo, rel_name, rel_body, draft = true) + body = { + "tag_name": tag_name, + "target_commitish": branch, + "name": rel_name, + "body": rel_body, + "draft": draft, + "prerelease": false + }.to_json + res = post("/repos/#{owner}/#{repo}/releases", body) +end + +def list_releases(owner, repo) + res = get("/repos/#{owner}/#{repo}/releases") + raise "Error retrieving releases" unless res.kind_of? Net::HTTPSuccess + + JSON.parse(res.body) +end + +def release_available?(owner, repo, tag_name) + releases = list_releases owner, repo + return true if releases.find { |r| r["tag_name"] == tag_name } + + false +end + +def bump_version(new_version, path = "share/github-backup-utils/version") + current_version = Gem::Version.new(File.read(path).strip.chomp) + if Gem::Version.new(new_version) < current_version + raise "New version should be newer than #{current_version}" + end + File.open("#{path}.new", 'w') do |f| + f.puts new_version + end + File.rename("#{path}.new", path) +end + +def push_release_branch(version, changes) + if !system("git checkout --quiet -b release-#{version}") + raise "Creating release branch failed" + end + + if !system("git commit --quiet -m 'Bump version: #{version}\n#{changes}' debian/changelog share/github-backup-utils/version") + raise "Error commiting changelog and version" + end + + if !system("git push --quiet origin release-#{version}") + raise "Failed pushing the release branch" + end +end + +def create_release_pr(version, owner, repo, release_body) + body = { + "title": "Bump version: #{version}", + "body": release_body, + "head": "release-#{version}", + "base": "master" + }.to_json + res = post("/repos/#{owner}/#{repo}/pulls", body) + raise "Creating release PR failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess +end + +def can_auth? + !ENV["GH_RELEASE_TOKEN"].nil? +end + +args = ARGV.dup +dry_run = false +if args.include?("--dry-run") + dry_run = true + args.delete '--dry-run' +end + +if args.include?("--no-warn") + $no_warn = true + args.delete '--no-warn' +end + +if args.size < 1 + $stderr.puts "Usage: release [--dry-run] " + exit 1 +end + +begin + version = Gem::Version.new(args[0]) +rescue ArgumentError + $stderr.puts "Error parsing version #{args[0]}" + exit 1 +end + +release_changes = [] +release_a = false +if dry_run + if can_auth? + release_changes = beautify_changes(changelog, GH_OWNER, GH_REPO) + release_a = release_available?(GH_OWNER, GH_REPO, "v#{version}") + puts "Existing release: #{release_a}" + end + puts "New version: #{version}" + puts "Owner: #{GH_OWNER}" + puts "Repo: #{GH_REPO}" + puts "Author: #{GH_AUTHOR}" + puts "Token: #{ENV['GH_RELEASE_TOKEN'] && "set" || "unset"}" + if can_auth? + puts "Changelog:" + release_changes.each { |c| puts " * #{c}"} + end + exit +end + +if release_a + $stderr.puts "Release #{version} already exists." + exit 1 +end + +`git fetch --quiet origin --prune` +branches = `git branch --all | grep release-#{version}$` +if !branches.empty? + $stderr.puts "Release branch release-#{version} already exists." + $stderr.puts "Branches found:" + branches.each_line { |l| puts "* #{l.strip.chomp}" } + exit 1 +end + +puts "Bumping version to #{version}" +bump_version(version) + +puts "Updating changelog" +update_changelog release_changes, DEB_PKG_NAME, version, GH_AUTHOR, GH_OWNER, GH_REPO + +puts "Creating release" +release_title = "GitHub Enterprise Backup Utilities v#{version}" +release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}" +release_changes.each do |c| + release_body += "\n* #{c}" +end +create_release "v#{version}", "master", GH_OWNER, GH_REPO, release_title, release_body + +puts "Creating and publishing the release branch" +push_release_branch(version, release_changes) +create_release_pr(version, GH_OWNER, GH_REPO, release_body) +puts "Released!" From 278e2479c48da063d8172681d179a39f21e20f38 Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Sat, 8 Apr 2017 19:12:19 +0200 Subject: [PATCH 0173/2421] Added more TODOs --- script/release | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/release b/script/release index ea969b03a..ea34ded1a 100755 --- a/script/release +++ b/script/release @@ -19,6 +19,9 @@ # TODO: Auto-merge the release PR # TODO: Tag the release # TODO: Build and upload the binaries to the release draft +# TODO: Preflight check: make sure auth works and provide a friendly error otherwise +# TODO: Preflight check: Make sure the target owner/repo exists +# require 'json' require 'net/http' require 'time' From c48cadc03aec8a26d9651f9ab1fb7e4a2dbcff60 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 11 Apr 2017 14:29:31 -0400 Subject: [PATCH 0174/2421] Add an error message when GH_RELEASE_TOKEN is unset --- script/release | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/release b/script/release index ea34ded1a..5718094d1 100755 --- a/script/release +++ b/script/release @@ -266,6 +266,9 @@ if dry_run if can_auth? puts "Changelog:" release_changes.each { |c| puts " * #{c}"} + else + $stderr.puts "Release Failed: Please set a GH_RELEASE_TOKEN" + exit 1 end exit end From 0bf4e0f4ca0e8e4ac639456b9472c970f747d02b Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Tue, 11 Apr 2017 15:24:23 -0400 Subject: [PATCH 0175/2421] preflight check if repo doesn't exist --- script/release | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/script/release b/script/release index 5718094d1..910f32980 100755 --- a/script/release +++ b/script/release @@ -226,6 +226,11 @@ def can_auth? !ENV["GH_RELEASE_TOKEN"].nil? end +def repo_exists?(owner, repo) + res = get("/repos/#{owner}/#{repo}") + res.kind_of? Net::HTTPSuccess +end + args = ARGV.dup dry_run = false if args.include?("--dry-run") @@ -250,6 +255,11 @@ rescue ArgumentError exit 1 end +if !repo_exists?(GH_OWNER, GH_REPO) + $stderr.puts "The repo #{GH_REPO} does not exist for #{GH_OWNER}" + exit 1 +end + release_changes = [] release_a = false if dry_run From 8d53917f5b43d156b408638b3c2f1d165cf4c393 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Wed, 12 Apr 2017 11:02:26 -0400 Subject: [PATCH 0176/2421] Remove obsoleted archived routes backup This code is obsoleted now that we get the consolidated routes for all the routes included Archived Repos from one call. --- .../ghe-backup-repositories-cluster-ng | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index a8e190a85..277b8542b 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -355,23 +355,4 @@ RULES done bm_end "$(basename $0) - Special Data Directories Sync" -bm_start "$(basename $0) - Archived Repos" -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-archived-repos-routes \ - | while read route; do - ar_route=$(dirname $route) - ghe_verbose "Got archived route $ar_route" - echo "$ar_route" >> $tempdir/archived_repos.rsync -done - -if ! test -f $tempdir/archived_repos.rsync; then - echo "* No archived repositories found to backup." - exit 0 -fi - -for h in $hostnames; do - echo "* Transferring archived routes from $h" - sync_data $h $tempdir/archived_repos.rsync 2>/dev/null || true -done -bm_end "$(basename $0) - Archived Repos" - bm_end "$(basename $0)" From 316da03512d4cb5c339313f8f4754ca00429d6f1 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 4 May 2017 16:55:28 +1000 Subject: [PATCH 0177/2421] Allow settings to be restored to cluster using -c --- bin/ghe-restore | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 42da36b18..50e097794 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -94,7 +94,6 @@ if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then cluster=true instance_configured=true - restore_settings=false fi # Restoring a cluster backup to a standalone appliance is not supported From f305ab3c2bb815ef4292cd25aa9933fc9a37c655 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 4 May 2017 16:58:08 +1000 Subject: [PATCH 0178/2421] Remove redundunt instance_configured If the instance is a cluster, then it will be configured and the earlier check for /etc/github/configured will have set instance_configured to true. --- bin/ghe-restore | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 50e097794..f62412dc4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -93,7 +93,6 @@ cluster=false if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then cluster=true - instance_configured=true fi # Restoring a cluster backup to a standalone appliance is not supported From c812dceb50cec4d596abc11276354c5d7ce3a706 Mon Sep 17 00:00:00 2001 From: Junko Suzuki Date: Tue, 16 May 2017 11:50:48 +0900 Subject: [PATCH 0179/2421] Update ghe-host-check --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 992b28ac8..2b68de2f4 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -36,7 +36,7 @@ set -e if [ $rc -ne 0 ]; then case $rc in 255) - if echo "$output" | grep -i "port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange" >/dev/null; then + if echo "$output" | grep -i "port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out" >/dev/null; then exec "$(basename $0)" "$hostname:122" fi From 2277dcc96f0d20e5fcdb004df32bef9e4a356ffb Mon Sep 17 00:00:00 2001 From: Junko Suzuki Date: Tue, 16 May 2017 19:17:03 +0900 Subject: [PATCH 0180/2421] Update ghe-host-check --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 2b68de2f4..5bdf57747 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -36,7 +36,7 @@ set -e if [ $rc -ne 0 ]; then case $rc in 255) - if echo "$output" | grep -i "port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out" >/dev/null; then + if echo "$output" | grep -i "port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then exec "$(basename $0)" "$hostname:122" fi From 36ec087038b1fc56f4b60ba949a0fc70d9b6b550 Mon Sep 17 00:00:00 2001 From: Elijah Buck Date: Wed, 17 May 2017 14:30:55 -0700 Subject: [PATCH 0181/2421] Retry loop for redis-cli BGSAVE * redis-cli BGSAVE can fail if background rewriting is happening. It will still exist zero though, causing an infinite loop. Replaced with for loop. * The LASTSAVE checking loop now times out after 60 minutes. * Switched to bash instead of sh for nicer for loops. --- share/github-backup-utils/ghe-backup-redis | 21 +++++++++++++++---- .../ghe-backup-redis-cluster | 21 +++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index c338b6b15..d21c0c511 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -19,12 +19,25 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Force a redis BGSAVE, and wait for it to complete. sudo= [ "$GHE_VERSION_MAJOR" -ge 2 ] && sudo="sudo" -ghe-ssh "$GHE_HOSTNAME" /bin/sh </dev/null - while [ \$(redis-cli LASTSAVE) -eq \$timestamp ]; do - sleep 1 + for ((n=0; n<10; n++)); do + if redis-cli BGSAVE | grep -q ERR; then + sleep 15 + else + break + fi + done + for ((n=0; n<240; n++)); do + if [ \$(redis-cli LASTSAVE) -eq \$timestamp ]; then + sleep 15 + else + break + fi + if [ \$n -eq 239 ]; then + exit 1 + fi done $sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' EOF diff --git a/share/github-backup-utils/ghe-backup-redis-cluster b/share/github-backup-utils/ghe-backup-redis-cluster index a252a7867..651b6f37a 100755 --- a/share/github-backup-utils/ghe-backup-redis-cluster +++ b/share/github-backup-utils/ghe-backup-redis-cluster @@ -19,15 +19,28 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Force a redis BGSAVE, and wait for it to complete. sudo= [ "$GHE_VERSION_MAJOR" -ge 2 ] && sudo="sudo" -ghe-ssh "$GHE_HOSTNAME" /bin/sh </dev/null || echo "localhost") timestamp=\$(redis-cli -h \$redis_host LASTSAVE) - redis-cli -h \$redis_host BGSAVE 1>/dev/null - while [ \$(redis-cli -h \$redis_host LASTSAVE) -eq \$timestamp ]; do - sleep 1 + for ((n=0; n<10; n++)); do + if redis-cli -h \$redis_host BGSAVE | grep -q ERR; then + sleep 15 + else + break + fi + done + for ((n=0; n<240; n++)); do + if [ \$(redis-cli -h \$redis_host LASTSAVE) -eq \$timestamp ]; then + sleep 15 + else + break + fi + if [ \$n -eq 239 ]; then + exit 1 + fi done if [ "\$redis_host" != "localhost" ]; then From f3a351c4b5d6c06578bd722019c029be25b6cab8 Mon Sep 17 00:00:00 2001 From: Elijah Buck Date: Wed, 17 May 2017 16:55:11 -0700 Subject: [PATCH 0182/2421] disable debuild tests --- script/package-deb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/package-deb b/script/package-deb index b42f0d5fd..114d11fb6 100755 --- a/script/package-deb +++ b/script/package-deb @@ -24,7 +24,7 @@ git clone -q . "$distdir" cd "$distdir" git checkout -q "$PKG_HEAD" -debuild -uc -us 1>&2 +DEB_BUILD_OPTIONS=nocheck debuild -uc -us 1>&2 cd .. files=$(ls -1 *.deb *.tar.gz *.dsc *.changes) mv $files ../ From cd5e71334be08f9849d02a6306b628efecc3d41f Mon Sep 17 00:00:00 2001 From: Elijah Buck Date: Fri, 26 May 2017 15:09:53 -0700 Subject: [PATCH 0183/2421] for style --- share/github-backup-utils/ghe-backup-redis | 18 +++++++----------- .../ghe-backup-redis-cluster | 18 +++++++----------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index d21c0c511..e5911dc24 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -22,23 +22,19 @@ sudo= ghe-ssh "$GHE_HOSTNAME" /bin/bash </dev/null || echo "localhost") timestamp=\$(redis-cli -h \$redis_host LASTSAVE) - for ((n=0; n<10; n++)); do - if redis-cli -h \$redis_host BGSAVE | grep -q ERR; then - sleep 15 - else + for i in $(seq 10); do + if ! redis-cli -h \$redis_host BGSAVE | grep -q ERR; then break fi + sleep 15 done - for ((n=0; n<240; n++)); do - if [ \$(redis-cli -h \$redis_host LASTSAVE) -eq \$timestamp ]; then - sleep 15 - else + for n in $(seq 240); do + if [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then break fi - if [ \$n -eq 239 ]; then - exit 1 - fi + sleep 15 done + [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work if [ "\$redis_host" != "localhost" ]; then ssh \$redis_host $sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' From 3d605f9ddc831401fb493ddc40f14c3a58ac5fcf Mon Sep 17 00:00:00 2001 From: Elijah Buck Date: Fri, 26 May 2017 15:10:14 -0700 Subject: [PATCH 0184/2421] re-enable debuild tests --- script/package-deb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/package-deb b/script/package-deb index 114d11fb6..b42f0d5fd 100755 --- a/script/package-deb +++ b/script/package-deb @@ -24,7 +24,7 @@ git clone -q . "$distdir" cd "$distdir" git checkout -q "$PKG_HEAD" -DEB_BUILD_OPTIONS=nocheck debuild -uc -us 1>&2 +debuild -uc -us 1>&2 cd .. files=$(ls -1 *.deb *.tar.gz *.dsc *.changes) mv $files ../ From f3d2a3c257144c6e32046365794e4a63031044f2 Mon Sep 17 00:00:00 2001 From: Elijah Buck Date: Fri, 26 May 2017 15:29:11 -0700 Subject: [PATCH 0185/2421] escape $(seq --- share/github-backup-utils/ghe-backup-redis | 4 ++-- share/github-backup-utils/ghe-backup-redis-cluster | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index e5911dc24..49aa5d672 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -22,13 +22,13 @@ sudo= ghe-ssh "$GHE_HOSTNAME" /bin/bash </dev/null || echo "localhost") timestamp=\$(redis-cli -h \$redis_host LASTSAVE) - for i in $(seq 10); do + for i in \$(seq 10); do if ! redis-cli -h \$redis_host BGSAVE | grep -q ERR; then break fi sleep 15 done - for n in $(seq 240); do + for n in \$(seq 240); do if [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then break fi From f64895e165ba4d018e9abfe699d97b41e8f19e2f Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 29 May 2017 09:48:43 +0200 Subject: [PATCH 0186/2421] Use default niceness for restores --- bin/ghe-backup | 4 ++++ share/github-backup-utils/ghe-backup-config | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 943bd1921..969aadfb4 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -13,6 +13,10 @@ set -e # Used to record failed backup steps failures= +# CPU and IO throttling to keep backups from thrashing around. +export GHE_NICE=${GHE_NICE:-"nice -n 19"} +export GHE_IONICE=${GHE_IONICE:-"ionice -c 3"} + # Create the timestamped snapshot directory where files for this run will live, # change into it, and mark the snapshot as incomplete by touching the # 'incomplete' file. If the backup succeeds, this file will be removed diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 5ac149f0b..8936235b4 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -160,10 +160,6 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP" # allows the location to be overridden in tests. : ${GHE_REMOTE_METADATA_FILE:="$GHE_REMOTE_DATA_DIR/enterprise/chef_metadata.json"} -# CPU and IO throttling to keep backups and restores from thrashing around. -: ${GHE_NICE:="nice -n 19"} -: ${GHE_IONICE:="ionice -c 3"} - # The number of seconds to wait for in progress git-gc processes to complete # before starting the sync of git data. See share/github-backup-utils/ghe-backup-repositories-rsync # for more information. Default: 10 minutes. From 193d61564e98e094867e18fc5685852c314ff661 Mon Sep 17 00:00:00 2001 From: Elijah Buck Date: Tue, 30 May 2017 16:26:12 -0700 Subject: [PATCH 0187/2421] tests need sleep before LASTSAVE check --- share/github-backup-utils/ghe-backup-redis | 3 ++- share/github-backup-utils/ghe-backup-redis-cluster | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index 49aa5d672..ba71770f6 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -29,10 +29,11 @@ ghe-ssh "$GHE_HOSTNAME" /bin/bash < Date: Wed, 31 May 2017 09:31:27 -0700 Subject: [PATCH 0188/2421] sleep 1 --- share/github-backup-utils/ghe-backup-redis | 5 ++--- share/github-backup-utils/ghe-backup-redis-cluster | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index ba71770f6..a01f99aa2 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -28,12 +28,11 @@ ghe-ssh "$GHE_HOSTNAME" /bin/bash < Date: Fri, 2 Jun 2017 16:20:36 +0200 Subject: [PATCH 0189/2421] Use existing indices to speed up transfer --- share/github-backup-utils/ghe-restore-es-rsync | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index b33722872..7e276f92b 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -51,6 +51,7 @@ elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u elasticsearch rsync" \ + --copy-dest="$GHE_REMOTE_DATA_USER_DIR/elasticsearch" \ "$snapshot_dir/elasticsearch/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 From 64545a9dd206a2fe74cf295de24000b3b1b130d9 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 2 Jun 2017 17:15:19 +0200 Subject: [PATCH 0190/2421] Include the user data directory in the benchmark name --- share/github-backup-utils/ghe-restore-userdata | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-userdata b/share/github-backup-utils/ghe-restore-userdata index 2156ac041..c1d0ff884 100755 --- a/share/github-backup-utils/ghe-restore-userdata +++ b/share/github-backup-utils/ghe-restore-userdata @@ -11,7 +11,7 @@ set -e # Show usage and bail with no arguments [ $# -lt 2 ] && print_usage -bm_start "$(basename $0)" +bm_start "$(basename $0) - $1" # Grab userdata directory name and host args dirname="$1" @@ -37,7 +37,7 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname" ]; then if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname" fi - + ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u git rsync" \ @@ -45,4 +45,4 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname" ]; then "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/$dirname" 1>&3 fi -bm_end "$(basename $0)" +bm_start "$(basename $0) - $1" From da9ab8c1cc3e050b4d702b2c4b8ea916b07ded75 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 2 Jun 2017 17:34:27 +0200 Subject: [PATCH 0191/2421] Copy and paste mistake --- share/github-backup-utils/ghe-restore-userdata | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-userdata b/share/github-backup-utils/ghe-restore-userdata index c1d0ff884..3c35b5497 100755 --- a/share/github-backup-utils/ghe-restore-userdata +++ b/share/github-backup-utils/ghe-restore-userdata @@ -45,4 +45,4 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname" ]; then "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/$dirname" 1>&3 fi -bm_start "$(basename $0) - $1" +bm_end "$(basename $0) - $1" From 569cc8d81d0a340715e8cc2541b9381e4be4ff3d Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 8 Jun 2017 09:21:42 +1000 Subject: [PATCH 0192/2421] Bump version: 2.10.0 --- debian/changelog | 13 +++++++++++++ share/github-backup-utils/version | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index bf83aff8c..144d736a3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +github-backup-utils (2.10.0) UNRELEASED; urgency=medium + + * Include the user data directory in the benchmark name #311 + * Use existing Elasticsearch indices to speed up transfer during a restore #310 + * Improve detection of failures in cluster backup rsync threads #301 + * Improve redis backup robustness #306 + * Use default niceness for restores #308 + * Add additional case to SSH port detection logic #304 + * Suppress additional dd output noise #289 + * Track completeness of Elasticsearch JSON dumps #298 + + -- Steven Honson Thu, 08 Jun 2017 09:06:16 +1000 + github-backup-utils (2.9.0) UNRELEASED; urgency=medium * Block restores to appliances with HA configured #291 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index c8e38b614..10c2c0c3d 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.9.0 +2.10.0 From 602a2a106741ff548c9fe981b97ab6f1fd329376 Mon Sep 17 00:00:00 2001 From: Leigh Fort Date: Tue, 20 Jun 2017 11:22:48 +1000 Subject: [PATCH 0193/2421] Explicitly state OpenSSH in requirements --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ac324ed4..e2e154943 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ storage and must have network connectivity with the GitHub Enterprise appliance. ##### Backup host requirements Backup host software requirements are modest: Linux or other modern Unix -operating system with [bash][13], [git][14], and [rsync][4] v2.6.4 or newer. +operating system with [bash][13], [git][14], [OpenSSH][15] and [rsync][4] v2.6.4 or newer. The backup host must be able to establish network connections outbound to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise 2.0 @@ -287,3 +287,4 @@ site setup or recovery, please contact our [Enterprise support team][7] instead. [12]: https://en.wikipedia.org/wiki/Hard_link [13]: https://www.gnu.org/software/bash/ [14]: https://git-scm.com/ +[15]: https://www.openssh.com/ From d990e70532ba279a777c8222a6371ed98a594645 Mon Sep 17 00:00:00 2001 From: Leigh Fort Date: Tue, 20 Jun 2017 11:33:41 +1000 Subject: [PATCH 0194/2421] Fix grammar nit with serial comma --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2e154943..ac8b89a51 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ storage and must have network connectivity with the GitHub Enterprise appliance. ##### Backup host requirements Backup host software requirements are modest: Linux or other modern Unix -operating system with [bash][13], [git][14], [OpenSSH][15] and [rsync][4] v2.6.4 or newer. +operating system with [bash][13], [git][14], [OpenSSH][15], and [rsync][4] v2.6.4 or newer. The backup host must be able to establish network connections outbound to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise 2.0 From 64648155e157a28a806ce639ff797fc46ee76b75 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Mon, 24 Jul 2017 08:58:04 +1000 Subject: [PATCH 0195/2421] Improve argument handling * -v and --version can now be specified with other arguments in any order * Ensured -h|--help is handled consistently * Added consistent args to ghe-host-check * Added consistent args to ghe-backup * Consistency of args/help text improved by incorporating @cs-shadow's changes from #297 --- bin/ghe-backup | 34 ++++++++++- bin/ghe-host-check | 27 ++++++++- bin/ghe-restore | 65 ++++++++++++--------- share/github-backup-utils/ghe-backup-config | 58 +++++++++--------- 4 files changed, 123 insertions(+), 61 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 969aadfb4..00fc194ab 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -1,12 +1,40 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup [-v] [--version] +#/ Usage: ghe-backup [-h] [-v] [--version] #/ Take snapshots of all GitHub Enterprise data, including Git repository data, #/ the MySQL database, instance settings, GitHub Pages data, etc. #/ -#/ With -v, enable verbose output and show more information about what's being -#/ transferred. +#/ Options: +#/ -v Enable verbose output. +#/ --version Display version information. +#/ -h Show this message. + set -e +# Parse arguments +while true; do + case "$1" in + -h|--help) + export GHE_SHOW_HELP=true + shift + ;; + --version) + export GHE_SHOW_VERSION=true + shift + ;; + -v) + export GHE_VERBOSE=true + shift + ;; + -*) + echo "Error: invalid argument: '$1'" 1>&2 + exit 1 + ;; + *) + break + ;; + esac +done + # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 5bdf57747..ad29e7407 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -1,9 +1,34 @@ #!/usr/bin/env bash -#/ Usage: ghe-host-check [] +#/ Usage: ghe-host-check [-h] [--version] [] #/ Verify connectivity with the GitHub Enterprise host. When no is #/ provided, the $GHE_HOSTNAME configured in backup.config is assumed. +#/ +#/ Options: +#/ --version Display version information. +#/ -h Show this message. + set -e +while true; do + case "$1" in + -h|--help) + export GHE_SHOW_HELP=true + shift + ;; + --version) + export GHE_SHOW_VERSION=true + shift + ;; + -*) + echo "Error: invalid argument: '$1'" 1>&2 + exit 1 + ;; + *) + break + ;; + esac +done + # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config diff --git a/bin/ghe-restore b/bin/ghe-restore index 42da36b18..b2f612e07 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -1,12 +1,11 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore [-v] [-s ] [] +#/ Usage: ghe-restore [-h] [-v] [--version] [-s ] [] #/ Restores a GitHub instance from local backup snapshots. The is the #/ hostname or IP of the GitHub instance. The may be omitted when #/ the GHE_RESTORE_HOST config variable is set in backup.config. When a #/ argument is provided, it always overrides the configured restore host. #/ #/ Options: -#/ --version Display version information. #/ -f Don't prompt for confirmation before restoring. #/ -c Restore appliance settings and license in addition to #/ datastores. Settings are not restored by default to @@ -15,6 +14,8 @@ #/ -s Restore from the snapshot with the given id. Available #/ snapshots may be listed under the data directory. #/ -v Enable verbose output. +#/ --version Display version information and exit. +#/ -h Show this message. #/ #/ Note that the host must be reachable and your SSH key must be setup as #/ described in the following help article: @@ -22,36 +23,48 @@ #/ set -e -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config - # Parse arguments restore_settings=false force=false while true; do - case "$1" in - -f|--force) - force=true - shift - ;; - -s) - snapshot_id="$(basename "$2")" - shift 2 - ;; - -c) - restore_settings=true - shift - ;; - -*) - echo "Error: invalid argument: '$1'" 1>&2 - exit 1 - ;; - *) - break - ;; - esac + case "$1" in + -f|--force) + force=true + shift + ;; + -s) + snapshot_id="$(basename "$2")" + shift 2 + ;; + -c) + restore_settings=true + shift + ;; + -h|--help) + export GHE_SHOW_HELP=true + shift + ;; + --version) + export GHE_SHOW_VERSION=true + shift + ;; + -v) + export GHE_VERBOSE=true + shift + ;; + -*) + echo "Error: invalid argument: '$1'" 1>&2 + exit 1 + ;; + *) + break + ;; + esac done +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config + # Grab the host arg GHE_HOSTNAME="${1:-$GHE_RESTORE_HOST}" diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 8936235b4..10d000bb3 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -20,32 +20,41 @@ GHE_BACKUP_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" # Get the version from the version file. BACKUP_UTILS_VERSION="$(cat $GHE_BACKUP_ROOT/share/github-backup-utils/version)" -# Add the bin and share/github-backup-utils dirs to PATH -PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" - -. $GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh - -# Display version string if flag present for any command -if [ "$1" = "--version" ]; then - echo "GitHub backup-utils v$BACKUP_UTILS_VERSION" - exit 0 -fi - -# Parse out -v (verbose) argument -if [ "$1" = "-v" ]; then - GHE_VERBOSE=true - shift +# If a version check was requested, show the current version and exit +if [ -n "$GHE_SHOW_VERSION" ]; then + echo "GitHub backup-utils v$BACKUP_UTILS_VERSION" + exit 0 fi -export GHE_VERBOSE # If verbose logging is enabled, redirect fd 3 to stdout; otherwise, redirect it # to /dev/null. Write verbose output to fd 3. if [ -n "$GHE_VERBOSE" ]; then - exec 3>&1 + exec 3>&1 else - exec 3>/dev/null + exec 3>/dev/null fi +# Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage +print_usage () { + grep '^#/' <"$0" | cut -c 4- + exit ${1:-1} +} + +if [ -n "$GHE_SHOW_HELP" ]; then + print_usage +else + for a in "$@"; do + if [ "$a" = "--help" ] || [ "$a" = "-h" ]; then + print_usage + fi + done +fi + +# Add the bin and share/github-backup-utils dirs to PATH +PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" + +. $GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh + # Save off GHE_HOSTNAME from the environment since we want it to override the # backup.config value when set. GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" @@ -193,19 +202,6 @@ ghe_remote_version_config () { ############################################################################### ### Utility functions -# Function to print usage embedded in a script's opening doc comments. -print_usage () { - grep '^#/' <"$0" | cut -c 4- - exit ${1:-1} -} - -# Check for a "--help" arg and show usage -for a in "$@"; do - if [ "$a" = "--help" ]; then - print_usage - fi -done - # If we don't have a readlink command, parse ls -l output. if ! type readlink 1>/dev/null 2>&1; then readlink () { From fd5deddea448af79a0de35133efcef0d439b1baa Mon Sep 17 00:00:00 2001 From: Brent Beer Date: Mon, 31 Jul 2017 14:26:35 +0200 Subject: [PATCH 0196/2421] explain how to extract the download --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac8b89a51..0210561e1 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,11 @@ Note: You can restore a snapshot that's at most two feature releases behind the ### Getting started - 1. [Download the latest release version][release] and extract *or* clone the - repository using Git: + 1. [Download the latest release version][release] and extract the repository using `tar`: + + `tar -xvf /path/to/github-backup-utils-vMAJOR.MINOR.PATCH.tar.gz` + + *or* clone the repository using Git: `git clone -b stable https://github.com/github/backup-utils.git` From ee68ba8e6b00d28bc4db5cc263b862391892b599 Mon Sep 17 00:00:00 2001 From: Brent Beer Date: Mon, 31 Jul 2017 14:46:05 +0200 Subject: [PATCH 0197/2421] include -z in tar extraction example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0210561e1..dca834c5d 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Note: You can restore a snapshot that's at most two feature releases behind the 1. [Download the latest release version][release] and extract the repository using `tar`: - `tar -xvf /path/to/github-backup-utils-vMAJOR.MINOR.PATCH.tar.gz` + `tar -xzvf /path/to/github-backup-utils-vMAJOR.MINOR.PATCH.tar.gz` *or* clone the repository using Git: From f175e5d1ed8f9e9ea1cb623a5fc4e635351cf71c Mon Sep 17 00:00:00 2001 From: Sergio Rubio Date: Mon, 31 Jul 2017 15:29:00 +0200 Subject: [PATCH 0198/2421] Add fakeroot dep to travis.yml debuild now complains that fakeroot is missing for some reason. See https://travis-ci.org/github/backup-utils/jobs/259352688 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 7b805ce22..734f7ea25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ matrix: packages: - devscripts - moreutils + - fakeroot before_script: git fetch --unshallow script: debuild -uc -us - os: linux @@ -25,4 +26,5 @@ matrix: - devscripts - debhelper - moreutils + - fakeroot script: debuild -uc -us From 3d3183f41079e358b8774464907721fe1d94ac3b Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 1 Aug 2017 10:04:43 +1000 Subject: [PATCH 0199/2421] Update comment --- share/github-backup-utils/ghe-backup-repositories-cluster-ng | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 277b8542b..fd88dfd34 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -325,9 +325,8 @@ done wait bm_end "$(basename $0) - Repo sync" -# Since there are no routes for special data directories -# or archived repositories, we need to do this serially -# for all hostnames. Good candidate for future optimizations. +# Since there are no routes for special data directories, we need to do this +# serially for all hostnames. Good candidate for future optimizations. bm_start "$(basename $0) - Special Data Directories Sync" for h in $hostnames; do From 3af9754cd01a17e59d4665d97ef6061385928872 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Wed, 12 Apr 2017 11:02:26 -0400 Subject: [PATCH 0200/2421] Remove obsoleted archived routes backup This code is obsoleted now that we get the consolidated routes for all the routes included Archived Repos from one call. --- .../ghe-backup-repositories-cluster-ng | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index d6f2c3679..9aa5f2bf7 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -363,23 +363,4 @@ RULES done bm_end "$(basename $0) - Special Data Directories Sync" -bm_start "$(basename $0) - Archived Repos" -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-archived-repos-routes \ - | while read route; do - ar_route=$(dirname $route) - ghe_verbose "Got archived route $ar_route" - echo "$ar_route" >> $tempdir/archived_repos.rsync -done - -if ! test -f $tempdir/archived_repos.rsync; then - echo "* No archived repositories found to backup." - exit 0 -fi - -for h in $hostnames; do - echo "* Transferring archived routes from $h" - sync_data $h $tempdir/archived_repos.rsync 2>/dev/null || true -done -bm_end "$(basename $0) - Archived Repos" - bm_end "$(basename $0)" From 2ab11abe8988f0cdfbdfee0cf27f9be25caacc7a Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 1 Aug 2017 10:04:43 +1000 Subject: [PATCH 0201/2421] Update comment --- share/github-backup-utils/ghe-backup-repositories-cluster-ng | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 9aa5f2bf7..33785375d 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -333,9 +333,8 @@ for pid in $(jobs -p); do done bm_end "$(basename $0) - Repo sync" -# Since there are no routes for special data directories -# or archived repositories, we need to do this serially -# for all hostnames. Good candidate for future optimizations. +# Since there are no routes for special data directories, we need to do this +# serially for all hostnames. Good candidate for future optimizations. bm_start "$(basename $0) - Special Data Directories Sync" for h in $hostnames; do From e75c3846420e2a712c3dda09117dd2e30dc57d42 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 2 Aug 2017 16:46:02 +1000 Subject: [PATCH 0202/2421] Specify dist and disable container --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 734f7ea25..4fc7db15b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,8 @@ matrix: - brew install moreutils script: make test - os: linux - sudo: false + dist: precise + sudo: required addons: apt: packages: From 90d4dc58854d4076afc13e908f7a3d95d1ca1094 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 2 Aug 2017 16:48:49 +1000 Subject: [PATCH 0203/2421] Add debhelper to precise --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 4fc7db15b..2c491f667 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ matrix: apt: packages: - devscripts + - debhelper - moreutils - fakeroot before_script: git fetch --unshallow From b33cc6a275d1e529887d7a9169a8d6817efed981 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 4 Aug 2017 16:52:35 +1000 Subject: [PATCH 0204/2421] Move ssh config generation to a function --- .../ghe-backup-alambic-cluster | 22 +++---------- .../ghe-backup-git-hooks-cluster | 22 ++++--------- .../ghe-backup-pages-cluster | 22 +++---------- .../ghe-backup-repositories-cluster | 23 ++++--------- .../ghe-backup-repositories-cluster-ng | 25 ++++----------- .../ghe-restore-alambic-cluster | 17 +++------- .../ghe-restore-alambic-cluster-ng | 17 +++------- .../ghe-restore-git-hooks-cluster | 25 ++++----------- .../ghe-restore-pages-dpages | 19 +++-------- .../ghe-restore-repositories-dgit | 26 ++++----------- .../ghe-restore-repositories-dgit-ng | 9 ++---- .../ghe-restore-repositories-gist | 24 ++++---------- .../ghe-restore-repositories-gist-ng | 9 ++---- share/github-backup-utils/ghe-ssh-config | 32 +++++++++++++++++++ 14 files changed, 100 insertions(+), 192 deletions(-) create mode 100755 share/github-backup-utils/ghe-ssh-config diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster b/share/github-backup-utils/ghe-backup-alambic-cluster index 1f8a51df5..17fc97f20 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster +++ b/share/github-backup-utils/ghe-backup-alambic-cluster @@ -24,10 +24,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -36,19 +32,11 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# git server hostnames +# alambic server hostnames hostnames=$(ghe_cluster_online_nodes "storage-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done - -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -58,7 +46,7 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' EXIT INT @@ -80,7 +68,7 @@ for hostname in $hostnames; do # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ - -e "ssh -q $opts -p 122 -F $config_file -l $user" \ + -e "ssh -q $opts -p 122 -F $ssh_config_file -l $user" \ --rsync-path='sudo -u git rsync' \ $link_dest \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ diff --git a/share/github-backup-utils/ghe-backup-git-hooks-cluster b/share/github-backup-utils/ghe-backup-git-hooks-cluster index 870bdc4d2..6054c99bf 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks-cluster +++ b/share/github-backup-utils/ghe-backup-git-hooks-cluster @@ -34,28 +34,18 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# Generate SSH config for forwarding -config="" - # git server hostnames hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate @@ -97,20 +87,20 @@ rsync_git_hooks_data () { mkdir -p "$backup_dir/$subpath" ghe-rsync -av \ - -e "ssh -q $opts -p $port -F $config_file -l $user" $link_dest \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" $link_dest \ --rsync-path='sudo -u git rsync' \ "$host:$GHE_REMOTE_DATA_USER_DIR/git-hooks/$subpath/" \ "$backup_dir/$subpath" 1>&3 } hostname=$(echo $hostnames | awk '{ print $1; }') -if ghe-ssh -F $config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs' ]"; then +if ghe-ssh -F $ssh_config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs' ]"; then rsync_git_hooks_data $hostname:122 environments/tarballs else ghe_verbose "git-hooks environment tarballs not found. Skipping ..." fi -if ghe-ssh -F $config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos' ]"; then +if ghe-ssh -F $ssh_config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos' ]"; then rsync_git_hooks_data $hostname:122 repos else ghe_verbose "git-hooks repositories not found. Skipping ..." diff --git a/share/github-backup-utils/ghe-backup-pages-cluster b/share/github-backup-utils/ghe-backup-pages-cluster index 9d942ef99..d773c700c 100755 --- a/share/github-backup-utils/ghe-backup-pages-cluster +++ b/share/github-backup-utils/ghe-backup-pages-cluster @@ -24,10 +24,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -36,19 +32,11 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# git server hostnames +# Pages server hostnames hostnames=$(ghe_cluster_online_nodes "pages-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done - -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -58,7 +46,7 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' EXIT INT @@ -80,7 +68,7 @@ for hostname in $hostnames; do # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ - -e "ssh -q $opts -p 122 -F $config_file -l $user" \ + -e "ssh -q $opts -p 122 -F $ssh_config_file -l $user" \ --rsync-path='sudo -u git rsync' \ $link_dest \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/pages/" \ diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster b/share/github-backup-utils/ghe-backup-repositories-cluster index 856ad2c7d..28ff49ed1 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster +++ b/share/github-backup-utils/ghe-backup-repositories-cluster @@ -58,10 +58,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -72,16 +68,9 @@ user="${host%@*}" # git server hostnames hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -93,16 +82,16 @@ mkdir -p "$backup_dir" cleanup() { # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable -F $config_file $hostname:$port + ghe-gc-enable -F $ssh_config_file $hostname:$port done - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate # Disable remote GC operations for hostname in $hostnames; do - ghe-gc-disable -F $config_file $hostname:$port + ghe-gc-disable -F $ssh_config_file $hostname:$port done # If we have a previous increment, avoid transferring existing files via rsync's @@ -121,7 +110,7 @@ rsync_repository_data () { shift ghe-rsync -av \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 33785375d..e9132ef8e 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -61,10 +61,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -75,16 +71,9 @@ user="${host%@*}" # git server hostnames hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -100,10 +89,10 @@ cleanup() { # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable -F $config_file $hostname:$port + ghe-gc-enable -F $ssh_config_file $hostname:$port done - rm -f $config_file + rm -f $ssh_config_file rm -rf $tempdir } trap 'cleanup' EXIT @@ -111,7 +100,7 @@ trap 'exit $?' INT # ^C always terminate # Disable remote GC operations for hostname in $hostnames; do - ghe-gc-disable -F $config_file $hostname:$port + ghe-gc-disable -F $ssh_config_file $hostname:$port done # If we have a previous increment, avoid transferring existing files via rsync's @@ -159,7 +148,7 @@ rsync_repository_data () { shift shift ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ @@ -169,7 +158,7 @@ rsync_repository_data () { else shift ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster b/share/github-backup-utils/ghe-restore-alambic-cluster index 0aa2dd514..8064e0e57 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster +++ b/share/github-backup-utils/ghe-restore-alambic-cluster @@ -33,9 +33,6 @@ if [ -z "$storage_paths" ]; then exit 0 fi -# Generate SSH config for forwarding -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -45,15 +42,9 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -for hostname in $hostnames; do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -61,7 +52,7 @@ cleanup() { for pid in $(jobs -p); do kill -KILL $pid > /dev/null 1>&2 || true done - rm -rf $config_file ssh_routes_in ssh_routes_out ssh_finalize_out + rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_out } trap 'cleanup' INT TERM EXIT @@ -86,7 +77,7 @@ for storage_path in $storage_paths; do for route in $routes; do ghe-rsync -aHR --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./$storage_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/storage" & diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 2794737d0..dad0348c7 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -42,17 +42,10 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# Generate SSH config for forwarding -config="" -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server"); do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" -done +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server") -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" # Stores a list of "oid size" tuples. tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) @@ -62,7 +55,7 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tempdir=$(mktemp -d) cleanup() { - rm -rf $tempdir $config_file $tmp_list $to_restore + rm -rf $tempdir $ssh_config_file $tmp_list $to_restore true } @@ -112,7 +105,7 @@ done for route in $tempdir/*.rsync; do ghe_verbose "* rsync data to $(basename $route .rsync) ..." ghe-rsync -arHR --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$route \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index a34fd5dc3..df5a20748 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -24,9 +24,6 @@ ghe_remote_version_required "$GHE_HOSTNAME" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} -# Generate SSH config for forwarding -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -36,17 +33,9 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done - -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" + +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -54,7 +43,7 @@ cleanup() { for pid in $(jobs -p); do kill -KILL $pid > /dev/null 2>&1 || true done - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' INT TERM EXIT @@ -64,14 +53,14 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; if [ -n "$hostname" ]; then ghe-rsync -avH --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs/" \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" 1>&3 for tarball in $tarballs; do env_id=$(echo $tarball | cut -d '/' -f 2) - ssh -q $opts -p $port -F $config_file -l $user $hostname "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" 1>&3 2>&3 + ssh -q $opts -p $port -F $ssh_config_file -l $user $hostname "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" 1>&3 2>&3 done fi fi @@ -79,7 +68,7 @@ fi if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos" ]; then for hostname in $hostnames; do ghe-rsync -avH --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos/" \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" 1>&3 & diff --git a/share/github-backup-utils/ghe-restore-pages-dpages b/share/github-backup-utils/ghe-restore-pages-dpages index 4014e80df..c4e7ac834 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages +++ b/share/github-backup-utils/ghe-restore-pages-dpages @@ -33,10 +33,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -45,15 +41,10 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "pages-server"); do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" -done +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "pages-server") -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -61,7 +52,7 @@ cleanup() { for pid in $(jobs -p); do kill -KILL $pid > /dev/null 2>&1 || true done - rm -rf $config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out + rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out } trap 'cleanup' INT TERM EXIT @@ -92,7 +83,7 @@ for pages_path in $pages_paths; do for route in $routes; do ghe-rsync -aHR --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/./$pages_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/pages" & diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit b/share/github-backup-utils/ghe-restore-repositories-dgit index c73d44cb5..d7c451a1f 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit +++ b/share/github-backup-utils/ghe-restore-repositories-dgit @@ -31,10 +31,6 @@ if [ -z "$network_paths" ]; then exit 0 fi -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -44,17 +40,9 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -64,16 +52,16 @@ cleanup() { done # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable -F $config_file $hostname:$port + ghe-gc-enable -F $ssh_config_file $hostname:$port done - rm -rf $config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out + rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out } trap 'cleanup' INT TERM EXIT # Disable remote GC operations for hostname in $hostnames; do - ghe-gc-disable -F $config_file $hostname:$port + ghe-gc-disable -F $ssh_config_file $hostname:$port done rm -rf ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out @@ -98,7 +86,7 @@ for network_path in $network_paths; do for route in $routes; do ghe-rsync -aHR --delete \ --exclude ".sync_in_progress" \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./$network_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/repositories" & @@ -133,7 +121,7 @@ wait $ssh_finalize_pid > /dev/null 2>&1 || true if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do if ! ghe-rsync -a --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info"; then diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 488351277..adbe29839 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -73,13 +73,8 @@ tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") -for hostname in $hostnames; do - echo " -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no" >> $ssh_config_file -done + +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" cleanup() { for hostname in $hostnames; do diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index e8d6d26e7..3e66fb5c9 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -33,10 +33,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -46,17 +42,9 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -66,16 +54,16 @@ cleanup() { done # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable -F $config_file $hostname:$port + ghe-gc-enable -F $ssh_config_file $hostname:$port done - rm -rf $config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out + rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out } trap 'cleanup' INT TERM EXIT # Disable remote GC operations for hostname in $hostnames; do - ghe-gc-disable -F $config_file $hostname:$port + ghe-gc-disable -F $ssh_config_file $hostname:$port done rm -rf ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out @@ -105,7 +93,7 @@ for gist_path in $gist_paths; do for route in $routes; do ghe-rsync -aHR --delete \ --exclude ".sync_in_progress" \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./$gist_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/repositories" & diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index d68d3a2ac..5e4a7208d 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -46,12 +46,9 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server"); do - echo " -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" >> $ssh_config_file -done +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") + +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" cleanup() { rm -rf $tempdir diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config new file mode 100755 index 000000000..5d6ec992b --- /dev/null +++ b/share/github-backup-utils/ghe-ssh-config @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +#/ Usage: ghe-ssh-config [...] +#/ +#/ Returns a SSH configuration file. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-[backup|restore]-* commands. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +GHE_HOSTNAME="$1" +shift + +hosts="$@" + +proxy_host=$(ssh_host_part "$GHE_HOSTNAME") +proxy_port=$(ssh_port_part "$GHE_HOSTNAME") +proxy_user="${host%@*}" +[ "$proxy_user" = "$proxy_host" ] && proxy_user="admin" + +for host in $hosts; do + cat < Date: Fri, 4 Aug 2017 18:04:05 +1000 Subject: [PATCH 0205/2421] Enable ssh multiplexing --- share/github-backup-utils/ghe-ssh | 3 +++ share/github-backup-utils/ghe-ssh-config | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 0f8a73082..e8e5cb6ae 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -53,6 +53,9 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then exit 1 fi + +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$GHE_DATA_DIR/.sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" + # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 5d6ec992b..738818d5c 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -23,10 +23,14 @@ proxy_port=$(ssh_port_part "$GHE_HOSTNAME") proxy_user="${host%@*}" [ "$proxy_user" = "$proxy_host" ] && proxy_user="admin" +opts="$GHE_EXTRA_SSH_OPTS" + +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$GHE_DATA_DIR/.sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" + for host in $hosts; do cat < Date: Fri, 4 Aug 2017 18:06:42 +1000 Subject: [PATCH 0206/2421] Fix variable names --- share/github-backup-utils/ghe-ssh-config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 738818d5c..d833da1f6 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -20,7 +20,7 @@ hosts="$@" proxy_host=$(ssh_host_part "$GHE_HOSTNAME") proxy_port=$(ssh_port_part "$GHE_HOSTNAME") -proxy_user="${host%@*}" +proxy_user="${proxy_host%@*}" [ "$proxy_user" = "$proxy_host" ] && proxy_user="admin" opts="$GHE_EXTRA_SSH_OPTS" @@ -29,7 +29,7 @@ opts="$GHE_EXTRA_SSH_OPTS" for host in $hosts; do cat < Date: Fri, 4 Aug 2017 18:09:47 +1000 Subject: [PATCH 0207/2421] Capitals matter --- share/github-backup-utils/ghe-backup-alambic-cluster | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster b/share/github-backup-utils/ghe-backup-alambic-cluster index 17fc97f20..f6163e453 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster +++ b/share/github-backup-utils/ghe-backup-alambic-cluster @@ -32,7 +32,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# alambic server hostnames +# Alambic server hostnames hostnames=$(ghe_cluster_online_nodes "storage-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) From d048541634c2773ffe3639bfc294c127a574c9e4 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 3 Aug 2017 14:22:58 +1000 Subject: [PATCH 0208/2421] Run multiple parallel restore finalize threads --- .../github-backup-utils/ghe-restore-repositories-dgit-ng | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 488351277..114805b43 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -151,7 +151,13 @@ for file_list in $tempdir/*.rsync; do done # Tell dgit about the repositories restored -cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-finalize >&3 +ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 < Date: Thu, 3 Aug 2017 14:42:05 +1000 Subject: [PATCH 0209/2421] Run multiple parallel restore finalize threads for gists and storage --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 8 +++++++- .../github-backup-utils/ghe-restore-repositories-gist-ng | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 2794737d0..0c57d82ed 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -120,6 +120,12 @@ for route in $tempdir/*.rsync; do done ghe_verbose "* Update storage database after the restore ..." -cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-finalize +ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 done -cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-finalize +ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 < Date: Thu, 3 Aug 2017 14:51:06 +1000 Subject: [PATCH 0210/2421] Convert tabs to spaces --- .../github-backup-utils/ghe-restore-alambic-cluster-ng | 10 +++++----- .../ghe-restore-repositories-dgit-ng | 10 +++++----- .../ghe-restore-repositories-gist-ng | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 0c57d82ed..dbe40cd99 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -121,11 +121,11 @@ done ghe_verbose "* Update storage database after the restore ..." ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 <&3 < Date: Tue, 1 Aug 2017 17:19:40 +1000 Subject: [PATCH 0211/2421] Detailed benchmarking --- .../ghe-restore-repositories-dgit-ng | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index a36403343..d6943fdc1 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -105,6 +105,7 @@ done # ... # # One network path per line. +bm_start "$(basename $0) - Building network list" OLDIFS=$IFS; IFS=$'\n' for path in $network_paths; do # Get the network ID @@ -114,6 +115,7 @@ for path in $network_paths; do echo $path done > $tmp_list IFS=$OLDIFS +bm_end "$(basename $0) - Building network list" # The server returns a list of routes: # @@ -123,6 +125,7 @@ IFS=$OLDIFS # ... # # One route per line. +bm_start "$(basename $0) - Obtaining routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-routes \ | while read route; do ghe_verbose "Received route $route" @@ -137,11 +140,13 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-ro ghe_verbose "Route: $network_id /data/repositories/$network_path $servers" echo "$network_id /data/repositories/$network_path $servers" >> $to_restore done +bm_end "$(basename $0) - Obtaining routes" +bm_start "$(basename $0) - Restoring repository networks" # rsync all the repositories for file_list in $tempdir/*.rsync; do server=$(basename $file_list .rsync) - ghe_verbose "* Transferring repositories to $server" + ghe_verbose "* Transferring repository networks to $server" ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ @@ -149,8 +154,10 @@ for file_list in $tempdir/*.rsync; do "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 done +bm_end "$(basename $0) - Restoring repository networks" # Tell dgit about the repositories restored +bm_start "$(basename $0) - Finalizing routes" ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Thu, 3 Aug 2017 17:08:13 +1000 Subject: [PATCH 0212/2421] Extra benchmarking for gists and storage --- .../ghe-restore-alambic-cluster-ng | 8 ++++++++ .../ghe-restore-repositories-gist-ng | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index dbe40cd99..5959d5e0f 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -77,6 +77,7 @@ trap 'cleanup' EXIT # b65f657194ca6202c17b5062e4afc11843fc892a3f2febef8ac10971db7689a8 5591634 # b63c30f6f885e59282c2aa22cfca846516b5e72621c10a58140fb04d133e2c17 5592492 # ... +bm_start "$(basename $0) - Building object list" OLDIFS=$IFS; IFS=$'\n' for path in $storage_paths; do oid=$(echo $path | awk -F/ '{print $(NF)}') @@ -84,6 +85,7 @@ for path in $storage_paths; do echo $oid $size done > $tmp_list IFS=$OLDIFS +bm_end "$(basename $0) - Building object list" ghe_verbose "* Sending the object list to the server..." @@ -93,6 +95,7 @@ ghe_verbose "* Sending the object list to the server..." # # OID SERVER1 SERVER2 SERVER2 # b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b server1 server2 server3 # bc4cdd292e6b5387df2a42a907fcd5f3b6804a5d5ab427184faea5ef118d635e server1 server2 server3 +bm_start "$(basename $0) - Obtaining routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-routes \ | while read obj; do ghe_verbose "Received route: $obj" @@ -106,9 +109,11 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore done echo "$obj" >> $to_restore done +bm_end "$(basename $0) - Obtaining routes" # rsync all the objects to the storage server where they belong. # One rsync invocation per server available. +bm_start "$(basename $0) - Restoring objects" for route in $tempdir/*.rsync; do ghe_verbose "* rsync data to $(basename $route .rsync) ..." ghe-rsync -arHR --delete \ @@ -118,7 +123,9 @@ for route in $tempdir/*.rsync; do "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/storage/" done +bm_end "$(basename $0) - Restoring objects" +bm_start "$(basename $0) - Finalizing routes" ghe_verbose "* Update storage database after the restore ..." ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < $tmp_list IFS=$OLDIFS +bm_end "$(basename $0) - Building gist list" +bm_start "$(basename $0) - Obtaining routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-routes \ | while read route; do servers=$(echo $route | cut -d ' ' -f2-) @@ -78,8 +83,10 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-ro ghe_verbose "Route: $gist_id /data/repositories/$gist $servers" echo "$gist_id /data/repositories/$gist $servers" >> $to_restore done +bm_end "$(basename $0) - Obtaining routes" # rsync all the gist repositories +bm_start "$(basename $0) - Restoring gists" for route in $tempdir/*.rsync; do ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ @@ -88,7 +95,9 @@ for route in $tempdir/*.rsync; do "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 done +bm_end "$(basename $0) - Restoring gists" +bm_start "$(basename $0) - Finalizing routes" ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Fri, 4 Aug 2017 02:22:22 +1000 Subject: [PATCH 0213/2421] Optimise route calculations --- .../ghe-restore-repositories-dgit-ng | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index d6943fdc1..8e145e0c2 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -66,10 +66,12 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -tempdir=$(mktemp -d) +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$tempdir/ssh_config opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list +routes_list=$tempdir/routes_list to_restore=$tempdir/to_restore hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") @@ -85,6 +87,7 @@ cleanup() { for hostname in $hostnames; do ghe-gc-enable -F $ssh_config_file $hostname:$port done + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir rm -rf $tempdir } trap cleanup EXIT @@ -117,6 +120,10 @@ done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building network list" +bm_start "$(basename $0) - Transferring network list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +bm_end "$(basename $0) - Transferring network list" + # The server returns a list of routes: # # a/nw/a8/3f/02/100000855 dgit-node1 dgit-node2 dgit-node3 @@ -125,22 +132,18 @@ bm_end "$(basename $0) - Building network list" # ... # # One route per line. -bm_start "$(basename $0) - Obtaining routes" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-routes \ - | while read route; do - ghe_verbose "Received route $route" - servers=$(echo $route | cut -d ' ' -f2-) - for server in $servers; do - network_path=$(echo $route | cut -d ' ' -f1) - ghe_verbose "Adding $network_path to $tempdir/$server.rsync" - echo "$network_path" >> $tempdir/$server.rsync - done - - network_id=$(echo $network_path | awk -F/ '{print $(NF)}') - ghe_verbose "Route: $network_id /data/repositories/$network_path $servers" - echo "$network_id /data/repositories/$network_path $servers" >> $to_restore -done -bm_end "$(basename $0) - Obtaining routes" +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/dgit-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Transferring routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list +bm_end "$(basename $0) - Transferring routes" + +bm_start "$(basename $0) - Processing routes" +cat $routes_list | awk -vtempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore +bm_end "$(basename $0) - Processing routes" bm_start "$(basename $0) - Restoring repository networks" # rsync all the repositories From e99d4618fbd7506742aa68127306a32c625650fb Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 4 Aug 2017 02:25:51 +1000 Subject: [PATCH 0214/2421] Missing space --- share/github-backup-utils/ghe-restore-repositories-dgit-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 8e145e0c2..0caee1d6f 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -141,7 +141,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" -cat $routes_list | awk -vtempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore bm_end "$(basename $0) - Processing routes" From 4dec3874d23a8ae9312befd8e78d47524001fe6d Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 4 Aug 2017 10:38:54 +1000 Subject: [PATCH 0215/2421] Leverage existing temporary directory --- .../github-backup-utils/ghe-restore-repositories-dgit-ng | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 0caee1d6f..b3b400809 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -161,12 +161,11 @@ bm_end "$(basename $0) - Restoring repository networks" # Tell dgit about the repositories restored bm_start "$(basename $0) - Finalizing routes" -ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Fri, 11 Nov 2016 11:53:11 +0100 Subject: [PATCH 0216/2421] Store intermediate list of objects for faster performance --- .../ghe-restore-alambic-cluster-ng | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 5959d5e0f..1aa0c9793 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -56,6 +56,7 @@ echo "$config" > "$config_file" # Stores a list of "oid size" tuples. tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) +routes_list=$(mktemp -t cluster-backup-restore-XXXXXX) to_restore=$(mktemp -t cluster-backup-restore-XXXXXX) opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -96,8 +97,20 @@ ghe_verbose "* Sending the object list to the server..." # b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b server1 server2 server3 # bc4cdd292e6b5387df2a42a907fcd5f3b6804a5d5ab427184faea5ef118d635e server1 server2 server3 bm_start "$(basename $0) - Obtaining routes" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-routes \ - | while read obj; do +ghe-rsync -avz --delete \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + "$tmp_list" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $tmp_list)" 1>&3 + + +echo "cat $(basename $tmp_list) | github-env ./bin/storage-cluster-restore-routes > $(basename $routes_list)" | ghe-ssh "$GHE_HOSTNAME" + +ghe-rsync -avz --delete \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $routes_list)" \ + "$routes_list" 1>&3 + +cat $routes_list | while read obj; do ghe_verbose "Received route: $obj" oid=$(echo $obj | cut -d ' ' -f1) oid_c1=$(echo $oid | cut -c1) From 5c201d1d050688abbd26287d9d2b4ce96e2c1b82 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Fri, 11 Nov 2016 12:11:08 +0100 Subject: [PATCH 0217/2421] Execute remote script through bash --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 1aa0c9793..2c6bd607f 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -102,8 +102,7 @@ ghe-rsync -avz --delete \ "$tmp_list" \ "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $tmp_list)" 1>&3 - -echo "cat $(basename $tmp_list) | github-env ./bin/storage-cluster-restore-routes > $(basename $routes_list)" | ghe-ssh "$GHE_HOSTNAME" +echo "cat $(basename $tmp_list) | github-env ./bin/storage-cluster-restore-routes > $(basename $routes_list)" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ From bc20b994f0b318c322b22a5af353e0d424ccab37 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Fri, 11 Nov 2016 12:43:29 +0100 Subject: [PATCH 0218/2421] Optimize storage paths translation --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 2c6bd607f..21a635141 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -79,13 +79,7 @@ trap 'cleanup' EXIT # b63c30f6f885e59282c2aa22cfca846516b5e72621c10a58140fb04d133e2c17 5592492 # ... bm_start "$(basename $0) - Building object list" -OLDIFS=$IFS; IFS=$'\n' -for path in $storage_paths; do - oid=$(echo $path | awk -F/ '{print $(NF)}') - size=$(echo $path | awk '{print $1}') - echo $oid $size -done > $tmp_list -IFS=$OLDIFS +echo "$storage_paths" | awk '{print $2 " " $1}' | awk -F/ '{print $NF }' > $tmp_list bm_end "$(basename $0) - Building object list" ghe_verbose "* Sending the object list to the server..." From ff75fdc8ac1aefaa0ed76ba1420fbc8447a9a0ca Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 4 Aug 2017 12:10:12 +1000 Subject: [PATCH 0219/2421] Standardise transfer approach --- .../ghe-restore-alambic-cluster-ng | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 21a635141..fe459606d 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -51,19 +51,19 @@ Host $hostname ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" - -# Stores a list of "oid size" tuples. -tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) -routes_list=$(mktemp -t cluster-backup-restore-XXXXXX) -to_restore=$(mktemp -t cluster-backup-restore-XXXXXX) - +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +config_file=$tempdir/ssh_config opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" -tempdir=$(mktemp -d) +tmp_list=$tempdir/tmp_list +routes_list=$tempdir/routes_list +to_restore=$tempdir/to_restore + +echo "$config" > "$config_file" cleanup() { rm -rf $tempdir $config_file $tmp_list $to_restore + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir true } @@ -90,19 +90,20 @@ ghe_verbose "* Sending the object list to the server..." # # OID SERVER1 SERVER2 SERVER2 # b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b server1 server2 server3 # bc4cdd292e6b5387df2a42a907fcd5f3b6804a5d5ab427184faea5ef118d635e server1 server2 server3 -bm_start "$(basename $0) - Obtaining routes" -ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - "$tmp_list" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $tmp_list)" 1>&3 -echo "cat $(basename $tmp_list) | github-env ./bin/storage-cluster-restore-routes > $(basename $routes_list)" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +bm_start "$(basename $0) - Transferring object list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +bm_end "$(basename $0) - Transferring object list" + +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/storage-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +bm_end "$(basename $0) - Generating routes" -ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $routes_list)" \ - "$routes_list" 1>&3 +bm_start "$(basename $0) - Transferring routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list +bm_end "$(basename $0) - Transferring routes" +bm_start "$(basename $0) - Processing routes" cat $routes_list | while read obj; do ghe_verbose "Received route: $obj" oid=$(echo $obj | cut -d ' ' -f1) @@ -115,7 +116,7 @@ cat $routes_list | while read obj; do done echo "$obj" >> $to_restore done -bm_end "$(basename $0) - Obtaining routes" +bm_end "$(basename $0) - Processing routes" # rsync all the objects to the storage server where they belong. # One rsync invocation per server available. @@ -132,13 +133,11 @@ done bm_end "$(basename $0) - Restoring objects" bm_start "$(basename $0) - Finalizing routes" -ghe_verbose "* Update storage database after the restore ..." -ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Fri, 4 Aug 2017 12:30:55 +1000 Subject: [PATCH 0220/2421] Store intermediate lists --- .../ghe-restore-repositories-gist-ng | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index ac95fb9c1..258c4988b 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -42,10 +42,12 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -tempdir=$(mktemp -d) +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$tempdir/ssh_config opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list +routes_list=$tempdir/routes_list to_restore=$tempdir/to_restore for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server"); do @@ -56,6 +58,7 @@ Host $hostname done cleanup() { + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir rm -rf $tempdir } trap cleanup EXIT @@ -69,21 +72,32 @@ done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building gist list" -bm_start "$(basename $0) - Obtaining routes" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-routes \ - | while read route; do +bm_start "$(basename $0) - Transferring gist list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +bm_end "$(basename $0) - Transferring gist list" + +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/gist-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Transferring routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list +bm_end "$(basename $0) - Transferring routes" + +bm_start "$(basename $0) - Processing routes" +cat $routes_list | while read route; do servers=$(echo $route | cut -d ' ' -f2-) for server in $servers; do gist=$(echo $route | cut -d ' ' -f1) ghe_verbose "Adding $gist to $tempdir/$server.rsync" echo "$gist" >> $tempdir/$server.rsync - done + done - gist_id=$(basename $(echo $route | cut -d ' ' -f 1) .git) - ghe_verbose "Route: $gist_id /data/repositories/$gist $servers" - echo "$gist_id /data/repositories/$gist $servers" >> $to_restore + gist_id=$(basename $(echo $route | cut -d ' ' -f 1) .git) + ghe_verbose "Route: $gist_id /data/repositories/$gist $servers" + echo "$gist_id /data/repositories/$gist $servers" >> $to_restore done -bm_end "$(basename $0) - Obtaining routes" +bm_end "$(basename $0) - Processing routes" # rsync all the gist repositories bm_start "$(basename $0) - Restoring gists" @@ -98,12 +112,11 @@ done bm_end "$(basename $0) - Restoring gists" bm_start "$(basename $0) - Finalizing routes" -ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Fri, 4 Aug 2017 19:46:46 +1000 Subject: [PATCH 0221/2421] Optimise gist route processing --- .../ghe-restore-repositories-gist-ng | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 258c4988b..5e86629c6 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -85,18 +85,8 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" -cat $routes_list | while read route; do - servers=$(echo $route | cut -d ' ' -f2-) - for server in $servers; do - gist=$(echo $route | cut -d ' ' -f1) - ghe_verbose "Adding $gist to $tempdir/$server.rsync" - echo "$gist" >> $tempdir/$server.rsync - done - - gist_id=$(basename $(echo $route | cut -d ' ' -f 1) .git) - ghe_verbose "Route: $gist_id /data/repositories/$gist $servers" - echo "$gist_id /data/repositories/$gist $servers" >> $to_restore -done +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore bm_end "$(basename $0) - Processing routes" # rsync all the gist repositories From 195943232d082eb734b6ad29e905d91c450cf298 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 7 Aug 2017 10:39:08 +1000 Subject: [PATCH 0222/2421] Use calculated routes when backing up storage data from a cluster --- bin/ghe-backup | 53 +++++----- .../ghe-backup-alambic-cluster-ng | 100 ++++++++++++++++++ 2 files changed, 128 insertions(+), 25 deletions(-) create mode 100755 share/github-backup-utils/ghe-backup-alambic-cluster-ng diff --git a/bin/ghe-backup b/bin/ghe-backup index 969aadfb4..a2296b8d3 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -171,33 +171,36 @@ ghe-backup-pages-${GHE_BACKUP_STRATEGY} || failures="$failures pages" if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - echo "Backing up asset attachments ..." - ghe-backup-alambic-cluster || - failures="$failures alambic_assets" - - echo "Backing up custom Git hooks ..." - ghe-backup-git-hooks-cluster || - failures="$failures git-hooks" + if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + echo "Backing up storage data ..." + if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/storage-cluster-backup-routes; then + ghe-backup-alambic-cluster-ng || failures="$failure alambic" else - echo "Backing up asset attachments ..." - ghe-backup-userdata alambic_assets || - failures="$failures alambic_assets" - - echo "Backing up storage data ..." - ghe-backup-userdata storage || - failures="$failures storage" - - echo "Backing up hook deliveries ..." - ghe-backup-userdata hookshot || - failures="$failures hookshot" - - echo "Backing up custom Git hooks ..." - ghe-backup-userdata git-hooks/environments/tarballs || - failures="$failures git-hooks-environments" - ghe-backup-userdata git-hooks/repos || - failures="$failures git-hooks-repos" + ghe-backup-alambic-cluster || failures="$failures alambic" fi + + echo "Backing up custom Git hooks ..." + ghe-backup-git-hooks-cluster || + failures="$failures git-hooks" + else + echo "Backing up asset attachments ..." + ghe-backup-userdata alambic_assets || + failures="$failures alambic_assets" + + echo "Backing up storage data ..." + ghe-backup-userdata storage || + failures="$failures storage" + + echo "Backing up hook deliveries ..." + ghe-backup-userdata hookshot || + failures="$failures hookshot" + + echo "Backing up custom Git hooks ..." + ghe-backup-userdata git-hooks/environments/tarballs || + failures="$failures git-hooks-environments" + ghe-backup-userdata git-hooks/repos || + failures="$failures git-hooks-repos" + fi fi if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng new file mode 100755 index 000000000..bdb40238d --- /dev/null +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-alambic-cluster-ng +#/ Take an online, incremental snapshot of all Alambic Storage data using the +#/ calulated routes method. +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-backup when the cluster strategy is used. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +bm_start "$(basename $0)" + +# Set up remote host and root backup snapshot directory based on config +host="$GHE_HOSTNAME" +backup_dir="$GHE_SNAPSHOT_DIR/storage" + +# Verify rsync is available. +if ! rsync --version 1>/dev/null 2>&1; then + echo "Error: rsync not found." 1>&2 + exit 1 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$host" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +ssh_config_file=$tempdir/ssh_config +opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +routes_list=$tempdir/routes_list + +for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server"); do + echo " +Host $hostname + ServerAliveInterval 60 + ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" >> $ssh_config_file +done + +# Make sure root backup dir exists if this is the first run +mkdir -p "$backup_dir" + +# Removes the remote sync-in-progress file on exit, re-enabling GC operations +# on the remote instance. +cleanup() { + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir + rm -rf $tempdir +} +trap 'cleanup' EXIT INT + +# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's +# --link-dest support. This also decreases physical space usage considerably. +if [ -d "$GHE_DATA_DIR/current/storage" ] && [ "$(ls -A $GHE_DATA_DIR/current/storage)" ]; then + link_dest="--link-dest=../../current/storage" +fi + +bm_start "$(basename $0) - Generating routes" +echo "github-env ./bin/storage-cluster-backup-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Transferring routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list +bm_end "$(basename $0) - Transferring routes" + +bm_start "$(basename $0) - Processing routes" +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +bm_end "$(basename $0) - Processing routes" + +# rsync all the repositories +bm_start "$(basename $0) - Storage object sync" +for file_list in $tempdir/*.rsync; do + hostname=$(basename $file_list .rsync) + + object_num=$(cat $file_list | wc -l) + echo "* Transferring $object_num objects from $hostname" + + ghe-rsync -avr \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --files-from="$file_list" \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ + "$backup_dir" 1>&3 & +done + +for pid in $(jobs -p); do + wait $pid +done +bm_end "$(basename $0) - Storage object sync" + +bm_end "$(basename $0)" From c8f4ebb7ab52d838400e0d60b44418a7d94b929a Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 7 Aug 2017 14:56:17 +1000 Subject: [PATCH 0223/2421] Fix typo --- share/github-backup-utils/ghe-backup-alambic-cluster-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index bdb40238d..deb1232ec 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -1,7 +1,7 @@ #!/usr/bin/env bash #/ Usage: ghe-backup-alambic-cluster-ng #/ Take an online, incremental snapshot of all Alambic Storage data using the -#/ calulated routes method. +#/ calculated routes method. #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup when the cluster strategy is used. From c26033178c895cb5935489332e470c8ce0609d9d Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 7 Aug 2017 15:21:13 +1000 Subject: [PATCH 0224/2421] Use --size-only when copying objects As there is no concept of a read replica for storage objects, the object may be read from different storage servers on each backup, resulting in varying modified timestamps. As storage objects are content-addressable, we can safely compare on the size alone, rather than size and last modified. --- share/github-backup-utils/ghe-backup-alambic-cluster | 1 + share/github-backup-utils/ghe-backup-alambic-cluster-ng | 1 + 2 files changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster b/share/github-backup-utils/ghe-backup-alambic-cluster index 1f8a51df5..682519fdf 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster +++ b/share/github-backup-utils/ghe-backup-alambic-cluster @@ -83,6 +83,7 @@ for hostname in $hostnames; do -e "ssh -q $opts -p 122 -F $config_file -l $user" \ --rsync-path='sudo -u git rsync' \ $link_dest \ + --size-only \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ "$GHE_SNAPSHOT_DIR/storage" 1>&3 bm_end "$(basename $0) - $hostname" diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index deb1232ec..70bd160e6 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -88,6 +88,7 @@ for file_list in $tempdir/*.rsync; do $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --files-from="$file_list" \ + --size-only \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ "$backup_dir" 1>&3 & done From 193c871075c9e44bffc87e42e79b8c3657e3ab1c Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 7 Aug 2017 15:43:06 +1000 Subject: [PATCH 0225/2421] Use --size-only when copying objects As there is no concept of a read replica for storage objects, the object may be read from different storage servers on each backup, resulting in varying modified timestamps. As storage objects are content-addressable, we can safely compare on the size alone, rather than size and last modified. --- share/github-backup-utils/ghe-restore-alambic-cluster | 1 + share/github-backup-utils/ghe-restore-alambic-cluster-ng | 1 + 2 files changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster b/share/github-backup-utils/ghe-restore-alambic-cluster index 0aa2dd514..a611797c3 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster +++ b/share/github-backup-utils/ghe-restore-alambic-cluster @@ -88,6 +88,7 @@ for storage_path in $storage_paths; do ghe-rsync -aHR --delete \ -e "ssh -q $opts -p $port -F $config_file -l $user" \ --rsync-path="sudo -u git rsync" \ + --size-only \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./$storage_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/storage" & done diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index fe459606d..bdb523048 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -127,6 +127,7 @@ for route in $tempdir/*.rsync; do -e "ssh -q $opts -p $port -F $config_file -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$route \ + --size-only \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/storage/" done From 0d9c8942775c4a5ec968dbbc36e6fe0e9d34fc0d Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Mon, 7 Aug 2017 15:45:44 +1000 Subject: [PATCH 0226/2421] Added tests for optional ghe-backup flags --- test/test-ghe-backup.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 932ed8e1b..4ffe95916 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -512,3 +512,26 @@ begin_test "ghe-backup with no leaked keys" ) end_test + +begin_test "ghe-backup honours --version flag" +( + set -e + + # Make sure a partial version string is returned + ghe-backup --version | grep "GitHub backup-utils v" + +) +end_test + +begin_test "ghe-backup honours --help and -h flags" +( + set -e + + arg_help=`bin/ghe-backup --help | grep 'Usage:'` + arg_h=`bin/ghe-backup -h | grep 'Usage:'` + + # Make sure a Usage: string is returned and that it's the same for -h and --help + [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage:" + +) +end_test From cf4660783513c2fa12f8097dc9bfb75f5332e5ef Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 7 Aug 2017 15:48:07 +1000 Subject: [PATCH 0227/2421] Unnecessary cleanup --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index bdb523048..e842bfb3d 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -62,7 +62,7 @@ to_restore=$tempdir/to_restore echo "$config" > "$config_file" cleanup() { - rm -rf $tempdir $config_file $tmp_list $to_restore + rm -rf $tempdir ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir true } From 89058677e36260a09dea7ad44fb8b705deda36b1 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 7 Aug 2017 16:12:39 +1000 Subject: [PATCH 0228/2421] Optimise storage route processing --- .../ghe-restore-alambic-cluster-ng | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index e842bfb3d..3029417b1 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -57,7 +57,6 @@ config_file=$tempdir/ssh_config opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list routes_list=$tempdir/routes_list -to_restore=$tempdir/to_restore echo "$config" > "$config_file" @@ -104,18 +103,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" -cat $routes_list | while read obj; do - ghe_verbose "Received route: $obj" - oid=$(echo $obj | cut -d ' ' -f1) - oid_c1=$(echo $oid | cut -c1) - oid_c2=$(echo $oid | cut -c1-2) - oid_c3=$(echo $oid | cut -c3-4) - for server in $(echo $obj | cut -d ' ' -f2-); do - ghe_verbose "Adding $oid_c1/$oid_c2/$oid_c3/$oid to $tempdir/$server.rsync" - echo "$oid_c1/$oid_c2/$oid_c3/$oid" >> $tempdir/$server.rsync - done - echo "$obj" >> $to_restore -done +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' bm_end "$(basename $0) - Processing routes" # rsync all the objects to the storage server where they belong. @@ -134,9 +122,8 @@ done bm_end "$(basename $0) - Restoring objects" bm_start "$(basename $0) - Finalizing routes" -cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Mon, 7 Aug 2017 16:21:59 +1000 Subject: [PATCH 0229/2421] Added test cases for --help|h and --version to ghe-restore and ghe-host-check. Fixed a test failing in ghe-backup --- test/test-ghe-backup.sh | 4 ++-- test/test-ghe-host-check.sh | 23 +++++++++++++++++++++++ test/test-ghe-restore.sh | 23 +++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 4ffe95916..90a9ffda0 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -527,8 +527,8 @@ begin_test "ghe-backup honours --help and -h flags" ( set -e - arg_help=`bin/ghe-backup --help | grep 'Usage:'` - arg_h=`bin/ghe-backup -h | grep 'Usage:'` + arg_help=`ghe-backup --help | grep 'Usage:'` + arg_h=`ghe-backup -h | grep 'Usage:'` # Make sure a Usage: string is returned and that it's the same for -h and --help [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage:" diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 856603ad1..e79dc5c1e 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -24,3 +24,26 @@ begin_test "ghe-host-check with host arg" ghe-host-check example.com | grep example.com ) end_test + +begin_test "ghe-host-check honours --version flag" +( + set -e + + # Make sure a partial version string is returned + ghe-host-check --version | grep "GitHub backup-utils v" + +) +end_test + +begin_test "ghe-host-check honours --help and -h flags" +( + set -e + + arg_help=`ghe-host-check --help | grep 'Usage:'` + arg_h=`ghe-host-check -h | grep 'Usage:'` + + # Make sure a Usage: string is returned and that it's the same for -h and --help + [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage:" + +) +end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index fbd1406b2..b1a646b44 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -628,3 +628,26 @@ begin_test "ghe-restore fails when restore to an active HA pair" echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." ) end_test + +begin_test "ghe-restore honours --version flag" +( + set -e + + # Make sure a partial version string is returned + ghe-restore --version | grep "GitHub backup-utils v" + +) +end_test + +begin_test "ghe-restore honours --help and -h flags" +( + set -e + + arg_help=`ghe-restore --help | grep 'Usage:'` + arg_h=`ghe-restore -h | grep 'Usage:'` + + # Make sure a Usage: string is returned and that it's the same for -h and --help + [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage:" + +) +end_test From 9c857cd979ca7887895f482d5ce52b8f823a0f6e Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Mon, 7 Aug 2017 16:28:16 +1000 Subject: [PATCH 0230/2421] Attempting to fix failing tests... In ghe-backup, ghe-restore, ghe-host-check --- test/test-ghe-backup.sh | 6 +++--- test/test-ghe-host-check.sh | 6 +++--- test/test-ghe-restore.sh | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 90a9ffda0..67d96ec16 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -527,11 +527,11 @@ begin_test "ghe-backup honours --help and -h flags" ( set -e - arg_help=`ghe-backup --help | grep 'Usage:'` - arg_h=`ghe-backup -h | grep 'Usage:'` + arg_help=`ghe-backup --help | grep -o 'Usage: ghe-backup'` + arg_h=`ghe-backup -h | grep -o 'Usage: ghe-backup'` # Make sure a Usage: string is returned and that it's the same for -h and --help - [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage:" + [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage: ghe-backup" ) end_test diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index e79dc5c1e..b0e6f01bf 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -39,11 +39,11 @@ begin_test "ghe-host-check honours --help and -h flags" ( set -e - arg_help=`ghe-host-check --help | grep 'Usage:'` - arg_h=`ghe-host-check -h | grep 'Usage:'` + arg_help=`ghe-host-check --help | grep -o 'Usage: ghe-host-check'` + arg_h=`ghe-host-check -h | grep -o 'Usage: ghe-host-check'` # Make sure a Usage: string is returned and that it's the same for -h and --help - [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage:" + [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage: ghe-host-check" ) end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index b1a646b44..c748d2b80 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -643,11 +643,11 @@ begin_test "ghe-restore honours --help and -h flags" ( set -e - arg_help=`ghe-restore --help | grep 'Usage:'` - arg_h=`ghe-restore -h | grep 'Usage:'` + arg_help=`ghe-restore --help | grep -o 'Usage: ghe-restore'` + arg_h=`ghe-restore -h | grep -o 'Usage: ghe-restore'` # Make sure a Usage: string is returned and that it's the same for -h and --help - [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage:" + [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage: ghe-restore" ) end_test From 17674f94256a4886a01537cd58fe1ad2797ce019 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Tue, 8 Aug 2017 08:49:38 +1000 Subject: [PATCH 0231/2421] Another test fix... --- test/test-ghe-backup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 67d96ec16..ee732c258 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -531,7 +531,8 @@ begin_test "ghe-backup honours --help and -h flags" arg_h=`ghe-backup -h | grep -o 'Usage: ghe-backup'` # Make sure a Usage: string is returned and that it's the same for -h and --help - [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage: ghe-backup" + [ $arg_help = $arg_h ] + echo $arg_help | grep -q "Usage: ghe-backup" ) end_test From 0f1f04875e758f275669d3a545f2c871e6ec5e88 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Tue, 8 Aug 2017 08:52:38 +1000 Subject: [PATCH 0232/2421] Test Fix --- test/test-ghe-backup.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index ee732c258..0c06add6e 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -531,8 +531,7 @@ begin_test "ghe-backup honours --help and -h flags" arg_h=`ghe-backup -h | grep -o 'Usage: ghe-backup'` # Make sure a Usage: string is returned and that it's the same for -h and --help - [ $arg_help = $arg_h ] - echo $arg_help | grep -q "Usage: ghe-backup" + [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-backup" ) end_test From e9bb7e55b28813dad51315a7a1f3968ebf000760 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Tue, 8 Aug 2017 08:58:09 +1000 Subject: [PATCH 0233/2421] Fixing tests for ghe-restore and ghe-host-check --- test/test-ghe-host-check.sh | 2 +- test/test-ghe-restore.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index b0e6f01bf..6e260ab09 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -43,7 +43,7 @@ begin_test "ghe-host-check honours --help and -h flags" arg_h=`ghe-host-check -h | grep -o 'Usage: ghe-host-check'` # Make sure a Usage: string is returned and that it's the same for -h and --help - [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage: ghe-host-check" + [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-host-check" ) end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index c748d2b80..6aecf85b0 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -647,7 +647,7 @@ begin_test "ghe-restore honours --help and -h flags" arg_h=`ghe-restore -h | grep -o 'Usage: ghe-restore'` # Make sure a Usage: string is returned and that it's the same for -h and --help - [ $arg_help = $arg_h ] && echo $arg_help | grep -q "Usage: ghe-restore" + [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-restore" ) end_test From 4a6f1ebb0c083d1877677f1aba4083b822e04908 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 8 Aug 2017 09:56:45 +1000 Subject: [PATCH 0234/2421] Disable maintenance operations during storage backup --- .../ghe-backup-alambic-cluster | 12 +++++++++++- .../ghe-backup-alambic-cluster-ng | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster b/share/github-backup-utils/ghe-backup-alambic-cluster index 682519fdf..a74660e89 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster +++ b/share/github-backup-utils/ghe-backup-alambic-cluster @@ -36,7 +36,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# git server hostnames +# storage server hostnames hostnames=$(ghe_cluster_online_nodes "storage-server") for hostname in $hostnames; do @@ -58,10 +58,20 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { + # Enable remote maintenance operations + for hostname in $hostnames; do + ghe-gc-enable -F $config_file $hostname:$port + done + rm -f $config_file } trap 'cleanup' EXIT INT +# Disable remote maintenance operations +for hostname in $hostnames; do + ghe-gc-disable -F $config_file $hostname:$port +done + # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$GHE_DATA_DIR/current/storage" ] && [ "$(ls -A $GHE_DATA_DIR/current/storage)" ]; then diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 70bd160e6..61da258ea 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -39,7 +39,10 @@ ssh_config_file=$tempdir/ssh_config opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" routes_list=$tempdir/routes_list -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server"); do +# storage server hostnames +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server") + +for hostname in $hostnames; do echo " Host $hostname ServerAliveInterval 60 @@ -52,11 +55,21 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { + # Enable remote maintenance operations + for hostname in $hostnames; do + ghe-gc-enable -F $ssh_config_file $hostname:$port + done + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir rm -rf $tempdir } trap 'cleanup' EXIT INT +# Disable remote maintenance operations +for hostname in $hostnames; do + ghe-gc-disable -F $ssh_config_file $hostname:$port +done + # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$GHE_DATA_DIR/current/storage" ] && [ "$(ls -A $GHE_DATA_DIR/current/storage)" ]; then From 08f8ea1d665a1ccb434851849e98a1a2a1a88b36 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 4 Aug 2017 16:52:35 +1000 Subject: [PATCH 0235/2421] Move ssh config generation to a function --- .../ghe-backup-alambic-cluster | 22 +++---------- .../ghe-backup-git-hooks-cluster | 22 ++++--------- .../ghe-backup-pages-cluster | 22 +++---------- .../ghe-backup-repositories-cluster | 23 ++++--------- .../ghe-backup-repositories-cluster-ng | 25 ++++----------- .../ghe-restore-alambic-cluster | 17 +++------- .../ghe-restore-alambic-cluster-ng | 17 +++------- .../ghe-restore-git-hooks-cluster | 25 ++++----------- .../ghe-restore-pages-dpages | 19 +++-------- .../ghe-restore-repositories-dgit | 26 ++++----------- .../ghe-restore-repositories-dgit-ng | 9 ++---- .../ghe-restore-repositories-gist | 24 ++++---------- .../ghe-restore-repositories-gist-ng | 9 ++---- share/github-backup-utils/ghe-ssh-config | 32 +++++++++++++++++++ 14 files changed, 100 insertions(+), 192 deletions(-) create mode 100755 share/github-backup-utils/ghe-ssh-config diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster b/share/github-backup-utils/ghe-backup-alambic-cluster index 1f8a51df5..f6163e453 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster +++ b/share/github-backup-utils/ghe-backup-alambic-cluster @@ -24,10 +24,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -36,19 +32,11 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# git server hostnames +# Alambic server hostnames hostnames=$(ghe_cluster_online_nodes "storage-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done - -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -58,7 +46,7 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' EXIT INT @@ -80,7 +68,7 @@ for hostname in $hostnames; do # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ - -e "ssh -q $opts -p 122 -F $config_file -l $user" \ + -e "ssh -q $opts -p 122 -F $ssh_config_file -l $user" \ --rsync-path='sudo -u git rsync' \ $link_dest \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ diff --git a/share/github-backup-utils/ghe-backup-git-hooks-cluster b/share/github-backup-utils/ghe-backup-git-hooks-cluster index 870bdc4d2..6054c99bf 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks-cluster +++ b/share/github-backup-utils/ghe-backup-git-hooks-cluster @@ -34,28 +34,18 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# Generate SSH config for forwarding -config="" - # git server hostnames hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate @@ -97,20 +87,20 @@ rsync_git_hooks_data () { mkdir -p "$backup_dir/$subpath" ghe-rsync -av \ - -e "ssh -q $opts -p $port -F $config_file -l $user" $link_dest \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" $link_dest \ --rsync-path='sudo -u git rsync' \ "$host:$GHE_REMOTE_DATA_USER_DIR/git-hooks/$subpath/" \ "$backup_dir/$subpath" 1>&3 } hostname=$(echo $hostnames | awk '{ print $1; }') -if ghe-ssh -F $config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs' ]"; then +if ghe-ssh -F $ssh_config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs' ]"; then rsync_git_hooks_data $hostname:122 environments/tarballs else ghe_verbose "git-hooks environment tarballs not found. Skipping ..." fi -if ghe-ssh -F $config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos' ]"; then +if ghe-ssh -F $ssh_config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos' ]"; then rsync_git_hooks_data $hostname:122 repos else ghe_verbose "git-hooks repositories not found. Skipping ..." diff --git a/share/github-backup-utils/ghe-backup-pages-cluster b/share/github-backup-utils/ghe-backup-pages-cluster index 9d942ef99..d773c700c 100755 --- a/share/github-backup-utils/ghe-backup-pages-cluster +++ b/share/github-backup-utils/ghe-backup-pages-cluster @@ -24,10 +24,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -36,19 +32,11 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# git server hostnames +# Pages server hostnames hostnames=$(ghe_cluster_online_nodes "pages-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done - -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -58,7 +46,7 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' EXIT INT @@ -80,7 +68,7 @@ for hostname in $hostnames; do # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ - -e "ssh -q $opts -p 122 -F $config_file -l $user" \ + -e "ssh -q $opts -p 122 -F $ssh_config_file -l $user" \ --rsync-path='sudo -u git rsync' \ $link_dest \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/pages/" \ diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster b/share/github-backup-utils/ghe-backup-repositories-cluster index 856ad2c7d..28ff49ed1 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster +++ b/share/github-backup-utils/ghe-backup-repositories-cluster @@ -58,10 +58,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -72,16 +68,9 @@ user="${host%@*}" # git server hostnames hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -93,16 +82,16 @@ mkdir -p "$backup_dir" cleanup() { # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable -F $config_file $hostname:$port + ghe-gc-enable -F $ssh_config_file $hostname:$port done - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate # Disable remote GC operations for hostname in $hostnames; do - ghe-gc-disable -F $config_file $hostname:$port + ghe-gc-disable -F $ssh_config_file $hostname:$port done # If we have a previous increment, avoid transferring existing files via rsync's @@ -121,7 +110,7 @@ rsync_repository_data () { shift ghe-rsync -av \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index d6f2c3679..936a8f971 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -61,10 +61,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -75,16 +71,9 @@ user="${host%@*}" # git server hostnames hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -100,10 +89,10 @@ cleanup() { # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable -F $config_file $hostname:$port + ghe-gc-enable -F $ssh_config_file $hostname:$port done - rm -f $config_file + rm -f $ssh_config_file rm -rf $tempdir } trap 'cleanup' EXIT @@ -111,7 +100,7 @@ trap 'exit $?' INT # ^C always terminate # Disable remote GC operations for hostname in $hostnames; do - ghe-gc-disable -F $config_file $hostname:$port + ghe-gc-disable -F $ssh_config_file $hostname:$port done # If we have a previous increment, avoid transferring existing files via rsync's @@ -159,7 +148,7 @@ rsync_repository_data () { shift shift ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ @@ -169,7 +158,7 @@ rsync_repository_data () { else shift ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster b/share/github-backup-utils/ghe-restore-alambic-cluster index 0aa2dd514..8064e0e57 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster +++ b/share/github-backup-utils/ghe-restore-alambic-cluster @@ -33,9 +33,6 @@ if [ -z "$storage_paths" ]; then exit 0 fi -# Generate SSH config for forwarding -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -45,15 +42,9 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -for hostname in $hostnames; do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -61,7 +52,7 @@ cleanup() { for pid in $(jobs -p); do kill -KILL $pid > /dev/null 1>&2 || true done - rm -rf $config_file ssh_routes_in ssh_routes_out ssh_finalize_out + rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_out } trap 'cleanup' INT TERM EXIT @@ -86,7 +77,7 @@ for storage_path in $storage_paths; do for route in $routes; do ghe-rsync -aHR --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./$storage_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/storage" & diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 2794737d0..dad0348c7 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -42,17 +42,10 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# Generate SSH config for forwarding -config="" -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server"); do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" -done +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server") -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" # Stores a list of "oid size" tuples. tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) @@ -62,7 +55,7 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tempdir=$(mktemp -d) cleanup() { - rm -rf $tempdir $config_file $tmp_list $to_restore + rm -rf $tempdir $ssh_config_file $tmp_list $to_restore true } @@ -112,7 +105,7 @@ done for route in $tempdir/*.rsync; do ghe_verbose "* rsync data to $(basename $route .rsync) ..." ghe-rsync -arHR --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$route \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index a34fd5dc3..df5a20748 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -24,9 +24,6 @@ ghe_remote_version_required "$GHE_HOSTNAME" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} -# Generate SSH config for forwarding -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -36,17 +33,9 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done - -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" + +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -54,7 +43,7 @@ cleanup() { for pid in $(jobs -p); do kill -KILL $pid > /dev/null 2>&1 || true done - rm -f $config_file + rm -f $ssh_config_file } trap 'cleanup' INT TERM EXIT @@ -64,14 +53,14 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; if [ -n "$hostname" ]; then ghe-rsync -avH --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs/" \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" 1>&3 for tarball in $tarballs; do env_id=$(echo $tarball | cut -d '/' -f 2) - ssh -q $opts -p $port -F $config_file -l $user $hostname "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" 1>&3 2>&3 + ssh -q $opts -p $port -F $ssh_config_file -l $user $hostname "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" 1>&3 2>&3 done fi fi @@ -79,7 +68,7 @@ fi if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos" ]; then for hostname in $hostnames; do ghe-rsync -avH --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos/" \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" 1>&3 & diff --git a/share/github-backup-utils/ghe-restore-pages-dpages b/share/github-backup-utils/ghe-restore-pages-dpages index 4014e80df..c4e7ac834 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages +++ b/share/github-backup-utils/ghe-restore-pages-dpages @@ -33,10 +33,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -45,15 +41,10 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "pages-server"); do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" -done +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "pages-server") -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -61,7 +52,7 @@ cleanup() { for pid in $(jobs -p); do kill -KILL $pid > /dev/null 2>&1 || true done - rm -rf $config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out + rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out } trap 'cleanup' INT TERM EXIT @@ -92,7 +83,7 @@ for pages_path in $pages_paths; do for route in $routes; do ghe-rsync -aHR --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/./$pages_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/pages" & diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit b/share/github-backup-utils/ghe-restore-repositories-dgit index c73d44cb5..d7c451a1f 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit +++ b/share/github-backup-utils/ghe-restore-repositories-dgit @@ -31,10 +31,6 @@ if [ -z "$network_paths" ]; then exit 0 fi -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -44,17 +40,9 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -64,16 +52,16 @@ cleanup() { done # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable -F $config_file $hostname:$port + ghe-gc-enable -F $ssh_config_file $hostname:$port done - rm -rf $config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out + rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out } trap 'cleanup' INT TERM EXIT # Disable remote GC operations for hostname in $hostnames; do - ghe-gc-disable -F $config_file $hostname:$port + ghe-gc-disable -F $ssh_config_file $hostname:$port done rm -rf ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out @@ -98,7 +86,7 @@ for network_path in $network_paths; do for route in $routes; do ghe-rsync -aHR --delete \ --exclude ".sync_in_progress" \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./$network_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/repositories" & @@ -133,7 +121,7 @@ wait $ssh_finalize_pid > /dev/null 2>&1 || true if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do if ! ghe-rsync -a --delete \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info"; then diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 488351277..adbe29839 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -73,13 +73,8 @@ tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") -for hostname in $hostnames; do - echo " -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no" >> $ssh_config_file -done + +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" cleanup() { for hostname in $hostnames; do diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index e8d6d26e7..3e66fb5c9 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -33,10 +33,6 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" -# Generate SSH config for forwarding - -config="" - # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") @@ -46,17 +42,9 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" hostnames=$(ghe_cluster_online_nodes "git-server") -for hostname in $hostnames; do - config="$config -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p - StrictHostKeyChecking=no -" -done -config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -echo "$config" > "$config_file" +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -66,16 +54,16 @@ cleanup() { done # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable -F $config_file $hostname:$port + ghe-gc-enable -F $ssh_config_file $hostname:$port done - rm -rf $config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out + rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out } trap 'cleanup' INT TERM EXIT # Disable remote GC operations for hostname in $hostnames; do - ghe-gc-disable -F $config_file $hostname:$port + ghe-gc-disable -F $ssh_config_file $hostname:$port done rm -rf ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out @@ -105,7 +93,7 @@ for gist_path in $gist_paths; do for route in $routes; do ghe-rsync -aHR --delete \ --exclude ".sync_in_progress" \ - -e "ssh -q $opts -p $port -F $config_file -l $user" \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./$gist_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/repositories" & diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index d68d3a2ac..5e4a7208d 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -46,12 +46,9 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -for hostname in $(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server"); do - echo " -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" >> $ssh_config_file -done +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") + +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" cleanup() { rm -rf $tempdir diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config new file mode 100755 index 000000000..5d6ec992b --- /dev/null +++ b/share/github-backup-utils/ghe-ssh-config @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +#/ Usage: ghe-ssh-config [...] +#/ +#/ Returns a SSH configuration file. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-[backup|restore]-* commands. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +GHE_HOSTNAME="$1" +shift + +hosts="$@" + +proxy_host=$(ssh_host_part "$GHE_HOSTNAME") +proxy_port=$(ssh_port_part "$GHE_HOSTNAME") +proxy_user="${host%@*}" +[ "$proxy_user" = "$proxy_host" ] && proxy_user="admin" + +for host in $hosts; do + cat < Date: Fri, 4 Aug 2017 18:04:05 +1000 Subject: [PATCH 0236/2421] Enable ssh multiplexing --- share/github-backup-utils/ghe-ssh | 3 +++ share/github-backup-utils/ghe-ssh-config | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 0f8a73082..e8e5cb6ae 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -53,6 +53,9 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then exit 1 fi + +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$GHE_DATA_DIR/.sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" + # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 5d6ec992b..d833da1f6 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -20,13 +20,17 @@ hosts="$@" proxy_host=$(ssh_host_part "$GHE_HOSTNAME") proxy_port=$(ssh_port_part "$GHE_HOSTNAME") -proxy_user="${host%@*}" +proxy_user="${proxy_host%@*}" [ "$proxy_user" = "$proxy_host" ] && proxy_user="admin" +opts="$GHE_EXTRA_SSH_OPTS" + +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$GHE_DATA_DIR/.sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" + for host in $hosts; do cat < Date: Thu, 3 Aug 2017 14:22:58 +1000 Subject: [PATCH 0237/2421] Run multiple parallel restore finalize threads --- .../github-backup-utils/ghe-restore-repositories-dgit-ng | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index adbe29839..40f46f8d3 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -146,7 +146,13 @@ for file_list in $tempdir/*.rsync; do done # Tell dgit about the repositories restored -cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-finalize >&3 +ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 < Date: Thu, 3 Aug 2017 14:42:05 +1000 Subject: [PATCH 0238/2421] Run multiple parallel restore finalize threads for gists and storage --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 8 +++++++- .../github-backup-utils/ghe-restore-repositories-gist-ng | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index dad0348c7..6c42b0d5f 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -113,6 +113,12 @@ for route in $tempdir/*.rsync; do done ghe_verbose "* Update storage database after the restore ..." -cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-finalize +ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 done -cat $to_restore | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-finalize +ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 < Date: Thu, 3 Aug 2017 14:51:06 +1000 Subject: [PATCH 0239/2421] Convert tabs to spaces --- .../github-backup-utils/ghe-restore-alambic-cluster-ng | 10 +++++----- .../ghe-restore-repositories-dgit-ng | 10 +++++----- .../ghe-restore-repositories-gist-ng | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 6c42b0d5f..7e29fc3ec 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -114,11 +114,11 @@ done ghe_verbose "* Update storage database after the restore ..." ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 <&3 < Date: Tue, 1 Aug 2017 17:19:40 +1000 Subject: [PATCH 0240/2421] Detailed benchmarking --- .../ghe-restore-repositories-dgit-ng | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index ad66a344d..a24623b0d 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -100,6 +100,7 @@ done # ... # # One network path per line. +bm_start "$(basename $0) - Building network list" OLDIFS=$IFS; IFS=$'\n' for path in $network_paths; do # Get the network ID @@ -109,6 +110,7 @@ for path in $network_paths; do echo $path done > $tmp_list IFS=$OLDIFS +bm_end "$(basename $0) - Building network list" # The server returns a list of routes: # @@ -118,6 +120,7 @@ IFS=$OLDIFS # ... # # One route per line. +bm_start "$(basename $0) - Obtaining routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-routes \ | while read route; do ghe_verbose "Received route $route" @@ -132,11 +135,13 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-ro ghe_verbose "Route: $network_id /data/repositories/$network_path $servers" echo "$network_id /data/repositories/$network_path $servers" >> $to_restore done +bm_end "$(basename $0) - Obtaining routes" +bm_start "$(basename $0) - Restoring repository networks" # rsync all the repositories for file_list in $tempdir/*.rsync; do server=$(basename $file_list .rsync) - ghe_verbose "* Transferring repositories to $server" + ghe_verbose "* Transferring repository networks to $server" ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ @@ -144,8 +149,10 @@ for file_list in $tempdir/*.rsync; do "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 done +bm_end "$(basename $0) - Restoring repository networks" # Tell dgit about the repositories restored +bm_start "$(basename $0) - Finalizing routes" ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Thu, 3 Aug 2017 17:08:13 +1000 Subject: [PATCH 0241/2421] Extra benchmarking for gists and storage --- .../ghe-restore-alambic-cluster-ng | 8 ++++++++ .../ghe-restore-repositories-gist-ng | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 7e29fc3ec..9193cdba2 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -70,6 +70,7 @@ trap 'cleanup' EXIT # b65f657194ca6202c17b5062e4afc11843fc892a3f2febef8ac10971db7689a8 5591634 # b63c30f6f885e59282c2aa22cfca846516b5e72621c10a58140fb04d133e2c17 5592492 # ... +bm_start "$(basename $0) - Building object list" OLDIFS=$IFS; IFS=$'\n' for path in $storage_paths; do oid=$(echo $path | awk -F/ '{print $(NF)}') @@ -77,6 +78,7 @@ for path in $storage_paths; do echo $oid $size done > $tmp_list IFS=$OLDIFS +bm_end "$(basename $0) - Building object list" ghe_verbose "* Sending the object list to the server..." @@ -86,6 +88,7 @@ ghe_verbose "* Sending the object list to the server..." # # OID SERVER1 SERVER2 SERVER2 # b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b server1 server2 server3 # bc4cdd292e6b5387df2a42a907fcd5f3b6804a5d5ab427184faea5ef118d635e server1 server2 server3 +bm_start "$(basename $0) - Obtaining routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-routes \ | while read obj; do ghe_verbose "Received route: $obj" @@ -99,9 +102,11 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore done echo "$obj" >> $to_restore done +bm_end "$(basename $0) - Obtaining routes" # rsync all the objects to the storage server where they belong. # One rsync invocation per server available. +bm_start "$(basename $0) - Restoring objects" for route in $tempdir/*.rsync; do ghe_verbose "* rsync data to $(basename $route .rsync) ..." ghe-rsync -arHR --delete \ @@ -111,7 +116,9 @@ for route in $tempdir/*.rsync; do "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/storage/" done +bm_end "$(basename $0) - Restoring objects" +bm_start "$(basename $0) - Finalizing routes" ghe_verbose "* Update storage database after the restore ..." ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < $tmp_list IFS=$OLDIFS +bm_end "$(basename $0) - Building gist list" +bm_start "$(basename $0) - Obtaining routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-routes \ | while read route; do servers=$(echo $route | cut -d ' ' -f2-) @@ -75,8 +80,10 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-ro ghe_verbose "Route: $gist_id /data/repositories/$gist $servers" echo "$gist_id /data/repositories/$gist $servers" >> $to_restore done +bm_end "$(basename $0) - Obtaining routes" # rsync all the gist repositories +bm_start "$(basename $0) - Restoring gists" for route in $tempdir/*.rsync; do ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ @@ -85,7 +92,9 @@ for route in $tempdir/*.rsync; do "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 done +bm_end "$(basename $0) - Restoring gists" +bm_start "$(basename $0) - Finalizing routes" ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Fri, 4 Aug 2017 02:22:22 +1000 Subject: [PATCH 0242/2421] Optimise route calculations --- .../ghe-restore-repositories-dgit-ng | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index a24623b0d..67b64e55a 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -66,10 +66,12 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -tempdir=$(mktemp -d) +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$tempdir/ssh_config opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list +routes_list=$tempdir/routes_list to_restore=$tempdir/to_restore hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") @@ -80,6 +82,7 @@ cleanup() { for hostname in $hostnames; do ghe-gc-enable -F $ssh_config_file $hostname:$port done + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir rm -rf $tempdir } trap cleanup EXIT @@ -112,6 +115,10 @@ done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building network list" +bm_start "$(basename $0) - Transferring network list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +bm_end "$(basename $0) - Transferring network list" + # The server returns a list of routes: # # a/nw/a8/3f/02/100000855 dgit-node1 dgit-node2 dgit-node3 @@ -120,22 +127,18 @@ bm_end "$(basename $0) - Building network list" # ... # # One route per line. -bm_start "$(basename $0) - Obtaining routes" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-restore-routes \ - | while read route; do - ghe_verbose "Received route $route" - servers=$(echo $route | cut -d ' ' -f2-) - for server in $servers; do - network_path=$(echo $route | cut -d ' ' -f1) - ghe_verbose "Adding $network_path to $tempdir/$server.rsync" - echo "$network_path" >> $tempdir/$server.rsync - done - - network_id=$(echo $network_path | awk -F/ '{print $(NF)}') - ghe_verbose "Route: $network_id /data/repositories/$network_path $servers" - echo "$network_id /data/repositories/$network_path $servers" >> $to_restore -done -bm_end "$(basename $0) - Obtaining routes" +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/dgit-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Transferring routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list +bm_end "$(basename $0) - Transferring routes" + +bm_start "$(basename $0) - Processing routes" +cat $routes_list | awk -vtempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore +bm_end "$(basename $0) - Processing routes" bm_start "$(basename $0) - Restoring repository networks" # rsync all the repositories From 2c60253f4198074435c4b22d1f20fb4d8d88fc40 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 4 Aug 2017 02:25:51 +1000 Subject: [PATCH 0243/2421] Missing space --- share/github-backup-utils/ghe-restore-repositories-dgit-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 67b64e55a..6a23f93ac 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -136,7 +136,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" -cat $routes_list | awk -vtempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore bm_end "$(basename $0) - Processing routes" From 9fb2f499453e94fb6dc97e9d5a3339bfdf789efd Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 4 Aug 2017 10:38:54 +1000 Subject: [PATCH 0244/2421] Leverage existing temporary directory --- .../github-backup-utils/ghe-restore-repositories-dgit-ng | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 6a23f93ac..de07161f7 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -156,12 +156,11 @@ bm_end "$(basename $0) - Restoring repository networks" # Tell dgit about the repositories restored bm_start "$(basename $0) - Finalizing routes" -ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Fri, 11 Nov 2016 11:53:11 +0100 Subject: [PATCH 0245/2421] Store intermediate list of objects for faster performance --- .../ghe-restore-alambic-cluster-ng | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 9193cdba2..056e82d13 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -49,6 +49,7 @@ ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" # Stores a list of "oid size" tuples. tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) +routes_list=$(mktemp -t cluster-backup-restore-XXXXXX) to_restore=$(mktemp -t cluster-backup-restore-XXXXXX) opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" @@ -89,8 +90,20 @@ ghe_verbose "* Sending the object list to the server..." # b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b server1 server2 server3 # bc4cdd292e6b5387df2a42a907fcd5f3b6804a5d5ab427184faea5ef118d635e server1 server2 server3 bm_start "$(basename $0) - Obtaining routes" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-restore-routes \ - | while read obj; do +ghe-rsync -avz --delete \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + "$tmp_list" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $tmp_list)" 1>&3 + + +echo "cat $(basename $tmp_list) | github-env ./bin/storage-cluster-restore-routes > $(basename $routes_list)" | ghe-ssh "$GHE_HOSTNAME" + +ghe-rsync -avz --delete \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $routes_list)" \ + "$routes_list" 1>&3 + +cat $routes_list | while read obj; do ghe_verbose "Received route: $obj" oid=$(echo $obj | cut -d ' ' -f1) oid_c1=$(echo $oid | cut -c1) From 9a05388a3e60727acb12b57756824056280a4afd Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Fri, 11 Nov 2016 12:11:08 +0100 Subject: [PATCH 0246/2421] Execute remote script through bash --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 056e82d13..725852774 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -95,8 +95,7 @@ ghe-rsync -avz --delete \ "$tmp_list" \ "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $tmp_list)" 1>&3 - -echo "cat $(basename $tmp_list) | github-env ./bin/storage-cluster-restore-routes > $(basename $routes_list)" | ghe-ssh "$GHE_HOSTNAME" +echo "cat $(basename $tmp_list) | github-env ./bin/storage-cluster-restore-routes > $(basename $routes_list)" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ From 8b880c9dbd1e616fd6a027a2727fa90652c7cc46 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Fri, 11 Nov 2016 12:43:29 +0100 Subject: [PATCH 0247/2421] Optimize storage paths translation --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 725852774..160111268 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -72,13 +72,7 @@ trap 'cleanup' EXIT # b63c30f6f885e59282c2aa22cfca846516b5e72621c10a58140fb04d133e2c17 5592492 # ... bm_start "$(basename $0) - Building object list" -OLDIFS=$IFS; IFS=$'\n' -for path in $storage_paths; do - oid=$(echo $path | awk -F/ '{print $(NF)}') - size=$(echo $path | awk '{print $1}') - echo $oid $size -done > $tmp_list -IFS=$OLDIFS +echo "$storage_paths" | awk '{print $2 " " $1}' | awk -F/ '{print $NF }' > $tmp_list bm_end "$(basename $0) - Building object list" ghe_verbose "* Sending the object list to the server..." From d51fe29cb77b30a7cf5fbe352b59292ac2c7bd02 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 4 Aug 2017 12:10:12 +1000 Subject: [PATCH 0248/2421] Standardise transfer approach --- .../ghe-restore-alambic-cluster-ng | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 160111268..42541afa3 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -44,19 +44,20 @@ user="${host%@*}" hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server") -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +ssh_config_file=$tempdir/ssh_config ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -# Stores a list of "oid size" tuples. -tmp_list=$(mktemp -t cluster-backup-restore-XXXXXX) -routes_list=$(mktemp -t cluster-backup-restore-XXXXXX) -to_restore=$(mktemp -t cluster-backup-restore-XXXXXX) - opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" -tempdir=$(mktemp -d) +tmp_list=$tempdir/tmp_list +routes_list=$tempdir/routes_list +to_restore=$tempdir/to_restore + +echo "$config" > "$config_file" cleanup() { rm -rf $tempdir $ssh_config_file $tmp_list $to_restore + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir true } @@ -83,19 +84,20 @@ ghe_verbose "* Sending the object list to the server..." # # OID SERVER1 SERVER2 SERVER2 # b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b server1 server2 server3 # bc4cdd292e6b5387df2a42a907fcd5f3b6804a5d5ab427184faea5ef118d635e server1 server2 server3 -bm_start "$(basename $0) - Obtaining routes" -ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - "$tmp_list" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $tmp_list)" 1>&3 -echo "cat $(basename $tmp_list) | github-env ./bin/storage-cluster-restore-routes > $(basename $routes_list)" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +bm_start "$(basename $0) - Transferring object list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +bm_end "$(basename $0) - Transferring object list" + +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/storage-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +bm_end "$(basename $0) - Generating routes" -ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$(basename $routes_list)" \ - "$routes_list" 1>&3 +bm_start "$(basename $0) - Transferring routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list +bm_end "$(basename $0) - Transferring routes" +bm_start "$(basename $0) - Processing routes" cat $routes_list | while read obj; do ghe_verbose "Received route: $obj" oid=$(echo $obj | cut -d ' ' -f1) @@ -108,7 +110,7 @@ cat $routes_list | while read obj; do done echo "$obj" >> $to_restore done -bm_end "$(basename $0) - Obtaining routes" +bm_end "$(basename $0) - Processing routes" # rsync all the objects to the storage server where they belong. # One rsync invocation per server available. @@ -125,13 +127,11 @@ done bm_end "$(basename $0) - Restoring objects" bm_start "$(basename $0) - Finalizing routes" -ghe_verbose "* Update storage database after the restore ..." -ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Fri, 4 Aug 2017 12:30:55 +1000 Subject: [PATCH 0249/2421] Store intermediate lists --- .../ghe-restore-repositories-gist-ng | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 37203a896..d54ecc0a5 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -42,10 +42,12 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -tempdir=$(mktemp -d) +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$tempdir/ssh_config opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list +routes_list=$tempdir/routes_list to_restore=$tempdir/to_restore hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") @@ -53,6 +55,7 @@ hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" cleanup() { + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir rm -rf $tempdir } trap cleanup EXIT @@ -66,21 +69,32 @@ done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building gist list" -bm_start "$(basename $0) - Obtaining routes" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-restore-routes \ - | while read route; do +bm_start "$(basename $0) - Transferring gist list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +bm_end "$(basename $0) - Transferring gist list" + +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/gist-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Transferring routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list +bm_end "$(basename $0) - Transferring routes" + +bm_start "$(basename $0) - Processing routes" +cat $routes_list | while read route; do servers=$(echo $route | cut -d ' ' -f2-) for server in $servers; do gist=$(echo $route | cut -d ' ' -f1) ghe_verbose "Adding $gist to $tempdir/$server.rsync" echo "$gist" >> $tempdir/$server.rsync - done + done - gist_id=$(basename $(echo $route | cut -d ' ' -f 1) .git) - ghe_verbose "Route: $gist_id /data/repositories/$gist $servers" - echo "$gist_id /data/repositories/$gist $servers" >> $to_restore + gist_id=$(basename $(echo $route | cut -d ' ' -f 1) .git) + ghe_verbose "Route: $gist_id /data/repositories/$gist $servers" + echo "$gist_id /data/repositories/$gist $servers" >> $to_restore done -bm_end "$(basename $0) - Obtaining routes" +bm_end "$(basename $0) - Processing routes" # rsync all the gist repositories bm_start "$(basename $0) - Restoring gists" @@ -95,12 +109,11 @@ done bm_end "$(basename $0) - Restoring gists" bm_start "$(basename $0) - Finalizing routes" -ghe-ssh "$GHE_HOSTNAME" -- /bin/sh >&3 <&3 < Date: Fri, 4 Aug 2017 19:46:46 +1000 Subject: [PATCH 0250/2421] Optimise gist route processing --- .../ghe-restore-repositories-gist-ng | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index d54ecc0a5..f1eab54b3 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -82,18 +82,8 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" -cat $routes_list | while read route; do - servers=$(echo $route | cut -d ' ' -f2-) - for server in $servers; do - gist=$(echo $route | cut -d ' ' -f1) - ghe_verbose "Adding $gist to $tempdir/$server.rsync" - echo "$gist" >> $tempdir/$server.rsync - done - - gist_id=$(basename $(echo $route | cut -d ' ' -f 1) .git) - ghe_verbose "Route: $gist_id /data/repositories/$gist $servers" - echo "$gist_id /data/repositories/$gist $servers" >> $to_restore -done +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore bm_end "$(basename $0) - Processing routes" # rsync all the gist repositories From 0626af036a3008e93496e6eb90439e58434ce2ea Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 7 Aug 2017 15:43:06 +1000 Subject: [PATCH 0251/2421] Use --size-only when copying objects As there is no concept of a read replica for storage objects, the object may be read from different storage servers on each backup, resulting in varying modified timestamps. As storage objects are content-addressable, we can safely compare on the size alone, rather than size and last modified. --- share/github-backup-utils/ghe-restore-alambic-cluster | 1 + share/github-backup-utils/ghe-restore-alambic-cluster-ng | 1 + 2 files changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster b/share/github-backup-utils/ghe-restore-alambic-cluster index 8064e0e57..be4e8434d 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster +++ b/share/github-backup-utils/ghe-restore-alambic-cluster @@ -79,6 +79,7 @@ for storage_path in $storage_paths; do ghe-rsync -aHR --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ + --size-only \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./$storage_path" \ "$route:$GHE_REMOTE_DATA_USER_DIR/storage" & done diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 42541afa3..cbc6fe20b 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -121,6 +121,7 @@ for route in $tempdir/*.rsync; do -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$route \ + --size-only \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/storage/" done From 3adb5af217502c2f97f02d2bc1337309efc1e24a Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 7 Aug 2017 15:48:07 +1000 Subject: [PATCH 0252/2421] Unnecessary cleanup --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index cbc6fe20b..35540528e 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -56,7 +56,7 @@ to_restore=$tempdir/to_restore echo "$config" > "$config_file" cleanup() { - rm -rf $tempdir $ssh_config_file $tmp_list $to_restore + rm -rf $tempdir ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir true } From d923143c9d5bc992393ed00da7f437c28063d117 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 7 Aug 2017 16:12:39 +1000 Subject: [PATCH 0253/2421] Optimise storage route processing --- .../ghe-restore-alambic-cluster-ng | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 35540528e..7a16f85e5 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -51,7 +51,6 @@ ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list routes_list=$tempdir/routes_list -to_restore=$tempdir/to_restore echo "$config" > "$config_file" @@ -98,18 +97,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" -cat $routes_list | while read obj; do - ghe_verbose "Received route: $obj" - oid=$(echo $obj | cut -d ' ' -f1) - oid_c1=$(echo $oid | cut -c1) - oid_c2=$(echo $oid | cut -c1-2) - oid_c3=$(echo $oid | cut -c3-4) - for server in $(echo $obj | cut -d ' ' -f2-); do - ghe_verbose "Adding $oid_c1/$oid_c2/$oid_c3/$oid to $tempdir/$server.rsync" - echo "$oid_c1/$oid_c2/$oid_c3/$oid" >> $tempdir/$server.rsync - done - echo "$obj" >> $to_restore -done +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' bm_end "$(basename $0) - Processing routes" # rsync all the objects to the storage server where they belong. @@ -128,9 +116,8 @@ done bm_end "$(basename $0) - Restoring objects" bm_start "$(basename $0) - Finalizing routes" -cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Wed, 9 Aug 2017 21:13:45 +1000 Subject: [PATCH 0254/2421] We don't need to echo the ssh config to a file This must have slipped in during a merge. --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 7a16f85e5..50fafe22a 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -52,8 +52,6 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list routes_list=$tempdir/routes_list -echo "$config" > "$config_file" - cleanup() { rm -rf $tempdir ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir From ab7b808e9f9ca98003845090b1863545bba3057c Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Aug 2017 21:21:49 +1000 Subject: [PATCH 0255/2421] Use tmpdir for ssh multiplex control sockets --- share/github-backup-utils/ghe-backup-config | 3 +++ share/github-backup-utils/ghe-ssh | 2 +- share/github-backup-utils/ghe-ssh-config | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 8936235b4..92dbf8df7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -176,6 +176,9 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP" # The location of the file used to disable GC operations on the remote side. : ${SYNC_IN_PROGRESS_FILE:="$GHE_REMOTE_DATA_USER_DIR/repositories/.sync_in_progress"} +# Base path for temporary directories and files. +: ${TMPDIR:="/tmp"} + ############################################################################### ### Dynamic remote version config diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index e8e5cb6ae..6450bcb9b 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -54,7 +54,7 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then fi -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$GHE_DATA_DIR/.sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index d833da1f6..574d1ea85 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -25,7 +25,7 @@ proxy_user="${proxy_host%@*}" opts="$GHE_EXTRA_SSH_OPTS" -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$GHE_DATA_DIR/.sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" for host in $hosts; do cat < Date: Wed, 9 Aug 2017 21:25:19 +1000 Subject: [PATCH 0256/2421] We don't need to echo the ssh config to a file (#106) This must have slipped in during a merge. --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 7a16f85e5..50fafe22a 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -52,8 +52,6 @@ opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecki tmp_list=$tempdir/tmp_list routes_list=$tempdir/routes_list -echo "$config" > "$config_file" - cleanup() { rm -rf $tempdir ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir From f840086994732c27691ef5c0423122680d7b68a9 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Aug 2017 21:30:07 +1000 Subject: [PATCH 0257/2421] Make it obvious that these are related to github enterprise --- share/github-backup-utils/ghe-ssh | 2 +- share/github-backup-utils/ghe-ssh-config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 6450bcb9b..aaa0f427c 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -54,7 +54,7 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then fi -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 574d1ea85..fdccc20ba 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -25,7 +25,7 @@ proxy_user="${proxy_host%@*}" opts="$GHE_EXTRA_SSH_OPTS" -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" for host in $hosts; do cat < Date: Wed, 9 Aug 2017 21:21:49 +1000 Subject: [PATCH 0258/2421] Use tmpdir for ssh multiplex control sockets --- share/github-backup-utils/ghe-backup-config | 3 +++ share/github-backup-utils/ghe-ssh | 2 +- share/github-backup-utils/ghe-ssh-config | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 8936235b4..92dbf8df7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -176,6 +176,9 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP" # The location of the file used to disable GC operations on the remote side. : ${SYNC_IN_PROGRESS_FILE:="$GHE_REMOTE_DATA_USER_DIR/repositories/.sync_in_progress"} +# Base path for temporary directories and files. +: ${TMPDIR:="/tmp"} + ############################################################################### ### Dynamic remote version config diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index e8e5cb6ae..6450bcb9b 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -54,7 +54,7 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then fi -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$GHE_DATA_DIR/.sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index d833da1f6..574d1ea85 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -25,7 +25,7 @@ proxy_user="${proxy_host%@*}" opts="$GHE_EXTRA_SSH_OPTS" -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$GHE_DATA_DIR/.sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" for host in $hosts; do cat < Date: Wed, 9 Aug 2017 21:30:07 +1000 Subject: [PATCH 0259/2421] Make it obvious that these are related to github enterprise --- share/github-backup-utils/ghe-ssh | 2 +- share/github-backup-utils/ghe-ssh-config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 6450bcb9b..aaa0f427c 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -54,7 +54,7 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then fi -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 574d1ea85..fdccc20ba 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -25,7 +25,7 @@ proxy_user="${proxy_host%@*}" opts="$GHE_EXTRA_SSH_OPTS" -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" for host in $hosts; do cat < Date: Wed, 9 Aug 2017 16:51:29 +0200 Subject: [PATCH 0260/2421] Disabling SSH Muxing for now. (#108) This is causing all of the enterprise2-migration builds to timeout and fail. I don't know the immediate cause so going to disable this first so we don't have CI broken. --- share/github-backup-utils/ghe-ssh | 1 + share/github-backup-utils/ghe-ssh-config | 1 + 2 files changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index aaa0f427c..bf02aec54 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -53,6 +53,7 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then exit 1 fi +GHE_DISABLE_SSH_MUX=1 [ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index fdccc20ba..6f63d26eb 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -24,6 +24,7 @@ proxy_user="${proxy_host%@*}" [ "$proxy_user" = "$proxy_host" ] && proxy_user="admin" opts="$GHE_EXTRA_SSH_OPTS" +GHE_DISABLE_SSH_MUX=1 [ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" From ae4294a40a0f95413f572ebe80d6fbcbefe99496 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 10 Aug 2017 14:12:03 +1000 Subject: [PATCH 0261/2421] Revert "Disabling SSH Muxing for now. (#108)" This reverts commit 1b623f8133a678cf67250541a8b68f2aef1d778a. --- share/github-backup-utils/ghe-ssh | 1 - share/github-backup-utils/ghe-ssh-config | 1 - 2 files changed, 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index bf02aec54..aaa0f427c 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -53,7 +53,6 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then exit 1 fi -GHE_DISABLE_SSH_MUX=1 [ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 6f63d26eb..fdccc20ba 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -24,7 +24,6 @@ proxy_user="${proxy_host%@*}" [ "$proxy_user" = "$proxy_host" ] && proxy_user="admin" opts="$GHE_EXTRA_SSH_OPTS" -GHE_DISABLE_SSH_MUX=1 [ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" From ea0c7a641b248111ae6a63507f92cea3ab333bfb Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 10 Aug 2017 21:10:57 +1000 Subject: [PATCH 0262/2421] Workaround openssh bug Open the master control socket in the background, ensuring that stderr won't hold things up. Works around the bug described in https://bugzilla.mindrot.org/show_bug.cgi?id=1988. --- share/github-backup-utils/ghe-ssh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index aaa0f427c..62eacd5b5 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -53,8 +53,12 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then exit 1 fi - -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +if [ -z "$GHE_DISABLE_SSH_MUX" ]; then + controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)" + opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" + # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 + [ -S $controlpath ] || ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true +fi # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x From ad04cb87d2f8f0f2af6e67634459f2cf6f7a1422 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Aug 2017 16:56:35 +1000 Subject: [PATCH 0263/2421] Filter legacy hostnames This matches the behaviour of the ghe_cluster_online_nodes function. --- share/github-backup-utils/ghe-cluster-nodes | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index 6347f366a..6b10f0c11 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -2,8 +2,8 @@ #/ Usage: ghe-cluster-nodes #/ #/ Finds all nodes of the cluster using the config on . -#/ If it is a 2.8 and later cluster version the results are returned as prefix-uuid, -#/ otherwise the configured hostnames are returned. +#/ If it is a 2.8 and later cluster version the results are returned as +#/ prefix-uuid, otherwise the configured hostnames are returned. #/ Also filters nodes based on the prefix role. #/ #/ Note: This script typically isn't called directly. It's invoked by the @@ -32,7 +32,7 @@ if ghe-ssh "$GHE_HOSTNAME" test -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid"; then hostnames+="$prefix-$uuid " done else - hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) + hostnames=$(echo "ghe-config --get-regexp cluster.*.$role | egrep 'true$' | awk '{ print \$1; }' | awk 'BEGIN { FS=\".\" }; { print \$2 };' | xargs -I{} -n1 bash -c 'if [ \"\$(ghe-config cluster.{}.offline)\" != true ]; then ghe-config cluster.{}.hostname; fi'" | ghe-ssh "$GHE_HOSTNAME" /bin/bash) fi echo "$hostnames" From cfb0b736b75beba2024628d2ee71de0e6c6ffaa7 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Aug 2017 17:01:23 +1000 Subject: [PATCH 0264/2421] Use ghe-cluster-nodes everywhere --- share/github-backup-utils/ghe-backup-alambic-cluster | 2 +- share/github-backup-utils/ghe-backup-git-hooks-cluster | 2 +- share/github-backup-utils/ghe-backup-pages-cluster | 2 +- share/github-backup-utils/ghe-backup-repositories-cluster | 2 +- share/github-backup-utils/ghe-restore-git-hooks-cluster | 2 +- share/github-backup-utils/ghe-restore-repositories-dgit | 2 +- share/github-backup-utils/ghe-restore-repositories-gist | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster b/share/github-backup-utils/ghe-backup-alambic-cluster index f6163e453..75235c732 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster +++ b/share/github-backup-utils/ghe-backup-alambic-cluster @@ -33,7 +33,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # Alambic server hostnames -hostnames=$(ghe_cluster_online_nodes "storage-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-backup-git-hooks-cluster b/share/github-backup-utils/ghe-backup-git-hooks-cluster index 6054c99bf..b633ed0a3 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks-cluster +++ b/share/github-backup-utils/ghe-backup-git-hooks-cluster @@ -35,7 +35,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # git server hostnames -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-backup-pages-cluster b/share/github-backup-utils/ghe-backup-pages-cluster index d773c700c..dc60d9e4a 100755 --- a/share/github-backup-utils/ghe-backup-pages-cluster +++ b/share/github-backup-utils/ghe-backup-pages-cluster @@ -33,7 +33,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # Pages server hostnames -hostnames=$(ghe_cluster_online_nodes "pages-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster b/share/github-backup-utils/ghe-backup-repositories-cluster index 28ff49ed1..bb62b8a48 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster +++ b/share/github-backup-utils/ghe-backup-repositories-cluster @@ -67,7 +67,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # git server hostnames -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index df5a20748..df7514523 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -32,7 +32,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit b/share/github-backup-utils/ghe-restore-repositories-dgit index d7c451a1f..c790b4cd1 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit +++ b/share/github-backup-utils/ghe-restore-repositories-dgit @@ -39,7 +39,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 3e66fb5c9..0beaee5fc 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -41,7 +41,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" From a21cec12fad76f2f4a97dc5ba8d34656428d0c93 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 9 Aug 2017 17:02:10 +1000 Subject: [PATCH 0265/2421] Remove redundant function and command --- share/github-backup-utils/ghe-backup-config | 7 ----- .../github-backup-utils/ghe-cluster-hostnames | 31 ------------------- 2 files changed, 38 deletions(-) delete mode 100755 share/github-backup-utils/ghe-cluster-hostnames diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 8936235b4..24bc1f8f8 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -287,13 +287,6 @@ ghe_remote_logger () { ghe-ssh "$GHE_HOSTNAME" -- logger -t backup-utils || true } -# Usage: ghe_cluster_online_nodes role -# Returns the online nodes with a certain role in cluster -ghe_cluster_online_nodes () { - role=$1 - echo "ghe-config --get-regexp cluster.*.$role | egrep 'true$' | awk '{ print \$1; }' | awk 'BEGIN { FS=\".\" }; { print \$2 };' | xargs -I{} -n1 bash -c 'if [ \"\$(ghe-config cluster.{}.offline)\" != true ]; then ghe-config cluster.{}.hostname; fi'" | ghe-ssh "$GHE_HOSTNAME" /bin/bash -} - # Usage: ghe_verbose # Log if verbose mode is enabled (GHE_VERBOSE or `-v`). ghe_verbose() { diff --git a/share/github-backup-utils/ghe-cluster-hostnames b/share/github-backup-utils/ghe-cluster-hostnames deleted file mode 100755 index 32643d976..000000000 --- a/share/github-backup-utils/ghe-cluster-hostnames +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-cluster-hostnames -#/ -#/ Finds all nodes of the cluster using the config on . -#/ If it is a 2.8 cluster the results are returned as prefix-uuid, -#/ otherwise the configured hostnames are returned. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore-* commands when restoring into a cluster. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -GHE_HOSTNAME="$1" -prefix="$2" - -if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then - node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) - hostnames='' - for uuid in $node_uuids; do - hostnames+="$prefix-$uuid " - done -else - hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -fi - -echo "$hostnames" From c1088ad5497bee576210219f5c549606580b9050 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 10 Aug 2017 22:49:40 +1000 Subject: [PATCH 0266/2421] Generate configuration file using ghe-ssh-config --- .../ghe-backup-alambic-cluster-ng | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 61da258ea..6b90ca3e4 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -33,22 +33,16 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" +# storage server hostnames +hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server") + tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$tempdir/ssh_config +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" routes_list=$tempdir/routes_list -# storage server hostnames -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server") - -for hostname in $hostnames; do - echo " -Host $hostname - ServerAliveInterval 60 - ProxyCommand ssh -q $GHE_EXTRA_SSH_OPTS -p $port $user@$host nc.openbsd %h %p" >> $ssh_config_file -done - # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" From d3f1d5388983377f52e6f43e6e5bc3f5ed5a9153 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 10 Aug 2017 22:36:51 +1000 Subject: [PATCH 0267/2421] Fix ssh config file variable name --- share/github-backup-utils/ghe-backup-alambic-cluster | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster b/share/github-backup-utils/ghe-backup-alambic-cluster index a74660e89..556021b17 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster +++ b/share/github-backup-utils/ghe-backup-alambic-cluster @@ -60,7 +60,7 @@ mkdir -p "$backup_dir" cleanup() { # Enable remote maintenance operations for hostname in $hostnames; do - ghe-gc-enable -F $config_file $hostname:$port + ghe-gc-enable -F $ssh_config_file $hostname:$port done rm -f $config_file @@ -69,7 +69,7 @@ trap 'cleanup' EXIT INT # Disable remote maintenance operations for hostname in $hostnames; do - ghe-gc-disable -F $config_file $hostname:$port + ghe-gc-disable -F $ssh_config_file $hostname:$port done # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's From 33b8152c730d254dc689818c657b635adc5413dc Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 10 Aug 2017 21:10:57 +1000 Subject: [PATCH 0268/2421] Workaround openssh bug Open the master control socket in the background, ensuring that stderr won't hold things up. Works around the bug described in https://bugzilla.mindrot.org/show_bug.cgi?id=1988. --- share/github-backup-utils/ghe-ssh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index aaa0f427c..62eacd5b5 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -53,8 +53,12 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then exit 1 fi - -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +if [ -z "$GHE_DISABLE_SSH_MUX" ]; then + controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)" + opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" + # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 + [ -S $controlpath ] || ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true +fi # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x From 59773f0416face126d6811c61c72b4daab009663 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sun, 13 Aug 2017 12:22:25 +1000 Subject: [PATCH 0269/2421] Prefer ssh port specified at command line --- share/github-backup-utils/ghe-ssh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 62eacd5b5..4bb5c3049 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -12,7 +12,11 @@ set -e opts="$GHE_EXTRA_SSH_OPTS" while true; do case "$1" in - -p|-l|-o|-F) + -p) + port="$2" + shift 2 + ;; + -l|-o|-F) opts="$opts $1 $2" shift 2 ;; @@ -37,7 +41,7 @@ if [ "$1" = "--" ]; then fi # Split host:port into parts -port=$(ssh_port_part "$host") +port=${port:-$(ssh_port_part "$host")} host=$(ssh_host_part "$host") # Add user / -l option From f907921e72ee3df5d388fe87d943caf283bf4ef6 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sun, 13 Aug 2017 12:56:12 +1000 Subject: [PATCH 0270/2421] Update comment --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 4bb5c3049..28a002a39 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -40,7 +40,7 @@ if [ "$1" = "--" ]; then shift fi -# Split host:port into parts +# Split host:port into parts. The port is only used if not specified earlier. port=${port:-$(ssh_port_part "$host")} host=$(ssh_host_part "$host") From 843894b6c0a078a26b60cc5035f18fcbc658261b Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sun, 13 Aug 2017 12:22:25 +1000 Subject: [PATCH 0271/2421] Prefer ssh port specified at command line --- share/github-backup-utils/ghe-ssh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 62eacd5b5..4bb5c3049 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -12,7 +12,11 @@ set -e opts="$GHE_EXTRA_SSH_OPTS" while true; do case "$1" in - -p|-l|-o|-F) + -p) + port="$2" + shift 2 + ;; + -l|-o|-F) opts="$opts $1 $2" shift 2 ;; @@ -37,7 +41,7 @@ if [ "$1" = "--" ]; then fi # Split host:port into parts -port=$(ssh_port_part "$host") +port=${port:-$(ssh_port_part "$host")} host=$(ssh_host_part "$host") # Add user / -l option From a12f9c7270ec58c52fbfc095271d8d20a07d99cd Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sun, 13 Aug 2017 12:56:12 +1000 Subject: [PATCH 0272/2421] Update comment --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 4bb5c3049..28a002a39 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -40,7 +40,7 @@ if [ "$1" = "--" ]; then shift fi -# Split host:port into parts +# Split host:port into parts. The port is only used if not specified earlier. port=${port:-$(ssh_port_part "$host")} host=$(ssh_host_part "$host") From 34beb4912941de31c4718d0af673b8b5ca703d7c Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 24 Aug 2017 23:28:16 -0700 Subject: [PATCH 0273/2421] Add note about file system case sensitivity Closes #241 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index dca834c5d..112215b08 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ and growth over time. The backup utilities use [hard links][12] to store data efficiently, so the backup snapshots must be written to a filesystem with support for hard links. +Using a [case sensitive][26] file system is strongly recommended to avoid conflicts. + ##### GitHub Enterprise version requirements The backup utilities are fully supported under GitHub Enterprise 2.0 or @@ -291,3 +293,4 @@ site setup or recovery, please contact our [Enterprise support team][7] instead. [13]: https://www.gnu.org/software/bash/ [14]: https://git-scm.com/ [15]: https://www.openssh.com/ +[16]: https://en.wikipedia.org/wiki/Case_sensitivity From 16d4a685c2ac84aa7729774633de076040fd3f54 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Fri, 25 Aug 2017 09:23:48 -0700 Subject: [PATCH 0274/2421] 26 != 16 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 112215b08..99313f0a2 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ and growth over time. The backup utilities use [hard links][12] to store data efficiently, so the backup snapshots must be written to a filesystem with support for hard links. -Using a [case sensitive][26] file system is strongly recommended to avoid conflicts. +Using a [case sensitive][16] file system is strongly recommended to avoid conflicts. ##### GitHub Enterprise version requirements From e335e7caa0cca2fb1fc2b79a309b0d929046b60d Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sat, 2 Sep 2017 16:10:45 +1000 Subject: [PATCH 0275/2421] Correct capitalisation for elasticsearch Dedicated to @michaeltwofish. --- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-backup-es-audit-log | 2 +- share/github-backup-utils/ghe-backup-es-hookshot | 2 +- share/github-backup-utils/ghe-restore-es-audit-log | 2 +- share/github-backup-utils/ghe-restore-es-hookshot | 2 +- share/github-backup-utils/ghe-restore-es-tarball | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 42da36b18..1061c22a5 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -329,7 +329,7 @@ elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then fi if $cluster; then - echo "Restoring ElasticSearch Audit logs" + echo "Restoring Elasticsearch Audit logs" ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 echo "Restoring hookshot logs ..." diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index d3e84b838..ddb49e478 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -1,6 +1,6 @@ #!/usr/bin/env bash #/ Usage: ghe-backup-es-audit-log -#/ Take a backup of audit logs in ElasticSearch. +#/ Take a backup of audit logs in Elasticsearch. #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index 65f8f67e2..86d5a3e0d 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -1,6 +1,6 @@ #!/usr/bin/env bash #/ Usage: ghe-backup-es-hookshot -#/ Take a backup of hookshot logs in ElasticSearch. +#/ Take a backup of hookshot logs in Elasticsearch. #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 10d8f43fd..33b205054 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -1,6 +1,6 @@ #!/usr/bin/env bash #/ Usage: ghe-restore-es-audit-log -#/ Take a backup of audit logs in ElasticSearch. +#/ Take a backup of audit logs in Elasticsearch. #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index 0441e8582..36ed15a96 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -1,6 +1,6 @@ #!/usr/bin/env bash #/ Usage: ghe-restore-es-hookshot -#/ Restores a backup of hookshot logs to ElasticSearch. +#/ Restores a backup of hookshot logs to Elasticsearch. #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-restore. diff --git a/share/github-backup-utils/ghe-restore-es-tarball b/share/github-backup-utils/ghe-restore-es-tarball index 4afc69907..93f5c77dc 100755 --- a/share/github-backup-utils/ghe-restore-es-tarball +++ b/share/github-backup-utils/ghe-restore-es-tarball @@ -21,7 +21,7 @@ bm_start "$(basename $0)" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} -# Restore ElasticSearch indices from tarball snapshot. +# Restore Elasticsearch indices from tarball snapshot. ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-es-indices' \ < "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/elasticsearch.tar" 1>&3 From 3fa44fceea0aab77b631f010ee28595f1fd280cd Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sat, 2 Sep 2017 16:11:41 +1000 Subject: [PATCH 0276/2421] Refresh previous months/days data --- share/github-backup-utils/ghe-restore-es-audit-log | 6 +++--- share/github-backup-utils/ghe-restore-es-hookshot | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 33b205054..57514dacb 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -19,14 +19,14 @@ GHE_HOSTNAME="$1" # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" -last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/audit_log*"' | cut -d ' ' -f 3 | sort | tail -1) +last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/audit_log*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1) indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz) for index in $indices; do if [ -z "$last_index" ] || ! [ $index \< $last_index ]; then - echo "Restoring $index" - gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" + ghe_verbose "* Restoring $index" + gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 fi done diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index 36ed15a96..3cccf4b56 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -19,7 +19,7 @@ GHE_HOSTNAME="$1" # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" -last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3 | sort | tail -1) +last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1) indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz) From ad46659f183b04df49edb8cec07532b455ba5084 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Sat, 2 Sep 2017 16:30:54 +1000 Subject: [PATCH 0277/2421] Fix comments Dedicated to @jatoben. --- share/github-backup-utils/ghe-restore-es-audit-log | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 57514dacb..811b270e2 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -1,9 +1,9 @@ #!/usr/bin/env bash #/ Usage: ghe-restore-es-audit-log -#/ Take a backup of audit logs in Elasticsearch. +#/ Restores a backup of audit logs to Elasticsearch. #/ #/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. +#/ ghe-restore. set -e # Bring in the backup configuration From def40748fd9a8847e1af5d7a6bb0d27061bc0fbb Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Thu, 7 Sep 2017 10:10:59 +0200 Subject: [PATCH 0278/2421] Bump version in preparation for 2.11 release (#112) --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 10c2c0c3d..46b81d815 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.10.0 +2.11.0 From 80ab7ac9526046131014488ad6b8a3dfc9b237ba Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 7 Sep 2017 17:14:41 +0100 Subject: [PATCH 0279/2421] Selectively allow restores to 2.11 Restores can only be made from backups of 2.9 or 2.10 that have already run the audit log migration, or from 2.11 backups. --- bin/ghe-restore | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 42da36b18..b33dee9cb 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -123,6 +123,16 @@ if ghe-ssh "$GHE_HOSTNAME" -- \ exit 1 fi +# Only allow restores of 2.9 and 2.10 to 2.11 and above, after running the audit log migration +if ! test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete && \ + ! echo $snapshot_instance_version | grep -Eq "v2\.[1-9][1-9]" && \ + echo $GHE_REMOTE_VERSION | grep -Eq "v2\.[1-9][1-9]"; then + echo "Error: Snapshot must be from GitHub Enterprise v2.9 or v.2.10 after running the" >&2 + echo " audit log migration, or from 2.11.0 or above." >&2 + echo "Please see https://git.io/v5rCE for the audit log migration procedure." >&2 + exit 1 +fi + # Prompt to verify the restore host given is correct. Restoring overwrites # important data on the destination appliance that cannot be recovered. This is # mostly to prevent accidents where the backup host is given to restore instead From 5ed601af646e3036fdcf087e73c8f0bce7c4f214 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 7 Sep 2017 17:15:37 +0100 Subject: [PATCH 0280/2421] Restore audit log migration sentinel file if it exists Only really needed when restoring to 2.9 or 2.10 instances to indicate the audit log indices have already been migrated. --- bin/ghe-restore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index b33dee9cb..d62665870 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -349,6 +349,11 @@ else ghe-restore-es-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 fi +# Restore the audit log migration sentinel file, if it exists in the snapshot +if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then + ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" +fi + # Restart an already running memcached to reset the cache after restore if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then echo "Restarting memcached ..." 1>&3 From 1cfb4a7801a3f91812859a52910c260b51141e18 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 7 Sep 2017 17:15:52 +0100 Subject: [PATCH 0281/2421] Add missing stderr redirect --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d62665870..b11d2fa1a 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -109,7 +109,7 @@ if $cluster; then snapshot_instance_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) if ! echo $snapshot_instance_version | \ grep -Eq "v2\.[5-9]|v2\.[1-9][0-9]|v[3-9]|v[1-9][0-9]"; then - echo "Error: Snapshot must be from GitHub Enterprise v2.5.0 or above to be restored" + echo "Error: Snapshot must be from GitHub Enterprise v2.5.0 or above to be restored" >&2 echo " into a cluster (detected $snapshot_instance_version). Aborting." >&2 exit 1 fi From 71b670daffbd497fd6fd303954be2f931a8042e1 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 7 Sep 2017 17:17:10 +0100 Subject: [PATCH 0282/2421] Backup audit log migration sentinel file --- share/github-backup-utils/ghe-backup-es-rsync | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 3e877df90..e0820d14b 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -96,4 +96,9 @@ ghe-rsync -avz \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 +# "Backup" audit log migration sentinel file +if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then + touch $GHE_SNAPSHOT_DIR/es-scan-complete +fi + bm_end "$(basename $0)" From a999f8f6e6aeffb63e6a2fea0bac00c733908dff Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 7 Sep 2017 17:19:00 +0100 Subject: [PATCH 0283/2421] Test audit log migration sentinel file is backed up --- test/test-ghe-backup.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 932ed8e1b..296429e09 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -49,6 +49,9 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then # Create a fake UUID echo "fake uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # Create fake audit log migration sentinel file + touch "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" fi # Create some fake elasticsearch data in the remote data directory @@ -154,6 +157,9 @@ begin_test "ghe-backup first snapshot" # check that ca certificates were backed up [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] + + # verify the audit log migration sentinel file has been created + [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] fi # verify that ghe-backup wrote its version information to the host @@ -241,6 +247,9 @@ begin_test "ghe-backup subsequent snapshot" # check that ca certificates were backed up [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] + + # verify the audit log migration sentinel file has been created + [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] fi ) end_test @@ -344,6 +353,9 @@ begin_test "ghe-backup with relative data dir path" # check that ca certificates were backed up [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] + + # verify the audit log migration sentinel file has been created + [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] fi # verify that ghe-backup wrote its version information to the host From 564fe1cc3da8b187bbd667666e5b199ddeac9a3f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 7 Sep 2017 17:23:31 +0100 Subject: [PATCH 0284/2421] Test audit log migration sentinel file is restored --- test/test-ghe-restore.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index fbd1406b2..142cf828f 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -83,6 +83,9 @@ echo "fake ghe-export-ssl-ca-certificates data" > "$GHE_DATA_DIR/current/ssl-ca- echo "fake license data" > "$GHE_DATA_DIR/current/enterprise.ghl" echo "fake manage password hash data" > "$GHE_DATA_DIR/current/manage-password" echo "rsync" > "$GHE_DATA_DIR/current/strategy" +if [ "$GHE_VERSION_MAJOR" -eq 2 ]; then + touch "$GHE_DATA_DIR/current/es-scan-complete" +fi begin_test "ghe-restore into configured vm" ( @@ -152,6 +155,11 @@ begin_test "ghe-restore into configured vm" # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] + fi fi ) end_test @@ -292,6 +300,11 @@ begin_test "ghe-restore -c into unconfigured vm" # verify ghe-export-ssl-ca-certificates was run grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" + + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] + fi fi ) end_test @@ -365,6 +378,11 @@ begin_test "ghe-restore into unconfigured vm" # verify no config run after restore on unconfigured instance ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" + + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] + fi fi ) end_test @@ -418,6 +436,11 @@ begin_test "ghe-restore with host arg" # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] + fi fi ) end_test From a9282a96876ced063f733995c329411e34fa6e58 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 7 Sep 2017 17:24:12 +0100 Subject: [PATCH 0285/2421] Test restore w/o audit log migration fails to 2.11 --- test/test-ghe-restore.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 142cf828f..f763619b7 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -651,3 +651,29 @@ begin_test "ghe-restore fails when restore to an active HA pair" echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." ) end_test + +begin_test "ghe-restore fails when restore 2.9/2.10 snapshot without audit log migration sentinel file to 2.11" +( + set -e + + # noop if not testing against 2.11 + if [ "$GHE_VERSION_MAJOR" -le 1 ] || [ "$GHE_VERSION_MINOR" -ne 11 ]; then + exit 0 + fi + + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + echo "rsync" > "$GHE_DATA_DIR/current/strategy" + echo "v2.9.10" > "$GHE_DATA_DIR/current/version" + rm "$GHE_DATA_DIR/current/es-scan-complete" + + ! output=$(ghe-restore -v -f localhost 2>&1) + + echo $output | grep -q "Error: Snapshot must be from GitHub Enterprise v2.9 or v.2.10 after running the" + + echo "v2.10.5" > "$GHE_DATA_DIR/current/version" + ! output=$(ghe-restore -v -f localhost 2>&1) + + echo $output | grep -q "Error: Snapshot must be from GitHub Enterprise v2.9 or v.2.10 after running the" +) From c8b12f49428999e88c93be14105d962649b11f06 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 7 Sep 2017 17:24:24 +0100 Subject: [PATCH 0286/2421] Test against 2.11 too --- script/cibuild | 1 + 1 file changed, 1 insertion(+) diff --git a/script/cibuild b/script/cibuild index 413352f40..282e1bc2b 100755 --- a/script/cibuild +++ b/script/cibuild @@ -11,6 +11,7 @@ REMOTE_VERSIONS=" 2.0.0 2.2.0 2.5.0 + 2.11.0 " # Enable verbose logging of ssh commands From f5dffeb4c164f27442efa36a4328e95a077d08b9 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 9 Sep 2017 03:50:45 +0100 Subject: [PATCH 0287/2421] Make the criteria clearer ... and a force option and fix typo inconsistency --- bin/ghe-restore | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b11d2fa1a..523bb3d5b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -123,14 +123,19 @@ if ghe-ssh "$GHE_HOSTNAME" -- \ exit 1 fi -# Only allow restores of 2.9 and 2.10 to 2.11 and above, after running the audit log migration -if ! test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete && \ - ! echo $snapshot_instance_version | grep -Eq "v2\.[1-9][1-9]" && \ - echo $GHE_REMOTE_VERSION | grep -Eq "v2\.[1-9][1-9]"; then - echo "Error: Snapshot must be from GitHub Enterprise v2.9 or v.2.10 after running the" >&2 - echo " audit log migration, or from 2.11.0 or above." >&2 - echo "Please see https://git.io/v5rCE for the audit log migration procedure." >&2 - exit 1 +# Only allow restores of 2.9 and 2.10 snapshots that have run the audit log migration to 2.11 and above +if ! $force; then + snapshot_instance_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) + snapshot_version_major=$(echo "${snapshot_instance_version#v}" | cut -f 1 -d .) + snapshot_version_minor=$(echo "$snapshot_instance_version" | cut -f 2 -d .) + if ! test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete && \ + [ "$snapshot_version_major" -eq 2 ] && [ "$snapshot_version_minor" -lt 11 ] && \ + [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 11 ]; then + echo "Error: Snapshot must be from GitHub Enterprise v2.9 or v2.10 after running the" >&2 + echo " audit log migration, or from v2.11.0 or above." >&2 + echo "Please see https://git.io/v5rCE for the audit log migration procedure." >&2 + exit 1 + fi fi # Prompt to verify the restore host given is correct. Restoring overwrites From 0ae65cdfc84b2398db49208d06697a58d675310f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 9 Sep 2017 03:52:41 +0100 Subject: [PATCH 0288/2421] Update test and add test for forced behaviour --- test/test-ghe-restore.sh | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index f763619b7..273f038e5 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -83,6 +83,7 @@ echo "fake ghe-export-ssl-ca-certificates data" > "$GHE_DATA_DIR/current/ssl-ca- echo "fake license data" > "$GHE_DATA_DIR/current/enterprise.ghl" echo "fake manage password hash data" > "$GHE_DATA_DIR/current/manage-password" echo "rsync" > "$GHE_DATA_DIR/current/strategy" +echo "$GHE_REMOTE_VERSION" > "$GHE_DATA_DIR/current/version" if [ "$GHE_VERSION_MAJOR" -eq 2 ]; then touch "$GHE_DATA_DIR/current/es-scan-complete" fi @@ -668,12 +669,38 @@ begin_test "ghe-restore fails when restore 2.9/2.10 snapshot without audit log m echo "v2.9.10" > "$GHE_DATA_DIR/current/version" rm "$GHE_DATA_DIR/current/es-scan-complete" - ! output=$(ghe-restore -v -f localhost 2>&1) + ! output=$(ghe-restore -v localhost 2>&1) - echo $output | grep -q "Error: Snapshot must be from GitHub Enterprise v2.9 or v.2.10 after running the" + echo $output | grep -q "Error: Snapshot must be from GitHub Enterprise v2.9 or v2.10 after running the" echo "v2.10.5" > "$GHE_DATA_DIR/current/version" - ! output=$(ghe-restore -v -f localhost 2>&1) + ! output=$(ghe-restore -v localhost 2>&1) - echo $output | grep -q "Error: Snapshot must be from GitHub Enterprise v2.9 or v.2.10 after running the" + echo $output | grep -q "Error: Snapshot must be from GitHub Enterprise v2.9 or v2.10 after running the" ) +end_test + +begin_test "ghe-restore force restore of 2.9/2.10 snapshot without audit log migration sentinel file to 2.11" +( + set -e + + # noop if not testing against 2.11 + if [ "$GHE_VERSION_MAJOR" -le 1 ] || [ "$GHE_VERSION_MINOR" -ne 11 ]; then + exit 0 + fi + + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + echo "rsync" > "$GHE_DATA_DIR/current/strategy" + echo "v2.9.10" > "$GHE_DATA_DIR/current/version" + + # Create fake remote repositories dir + mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + + ghe-restore -v -f localhost + + echo "v2.10.5" > "$GHE_DATA_DIR/current/version" + ghe-restore -v -f localhost +) +end_test From b3972e2e466d3fcdd78619ea26c970565834c8b9 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Sep 2017 14:14:07 +0100 Subject: [PATCH 0289/2421] Add my working code --- script/release | 356 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 247 insertions(+), 109 deletions(-) diff --git a/script/release b/script/release index 910f32980..e87b9118e 100755 --- a/script/release +++ b/script/release @@ -21,6 +21,7 @@ # TODO: Build and upload the binaries to the release draft # TODO: Preflight check: make sure auth works and provide a friendly error otherwise # TODO: Preflight check: Make sure the target owner/repo exists +# TODO: Use the constants we define rather than passing variables. # require 'json' require 'net/http' @@ -34,14 +35,13 @@ GH_OWNER = ENV["GH_OWNER"] || "github" GH_AUTHOR = ENV["GH_AUTHOR"] || "Sergio Rubio " DEB_PKG_NAME = "github-backup-utils" -CHANGELOG_TMPL = """ -<%G= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium +CHANGELOG_TMPL = """<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium <%- changes.each do |ch| -%> * <%= ch.strip.chomp %> <% end -%> - -- <%= author %> <%= Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S %z') %> + -- <%= author %> <%= Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S %z') %> """ @@ -52,21 +52,14 @@ def warn(msg) end end -def client +def client(host = API_HOST, port = API_PORT) @http ||= begin - c = Net::HTTP.new(API_HOST, API_PORT) + c = Net::HTTP.new(host, port) c.use_ssl = true c end end -def release_token - token = ENV["GH_RELEASE_TOKEN"] - raise "GH_RELEASE_TOKEN not set" if token.nil? - - token -end - def get(path) req = Net::HTTP::Get.new(path) req['Authorization'] = "token #{release_token}" @@ -80,29 +73,39 @@ def post(path, body) client.request(req) end -# -# tag "v0.0.1", "foo tag", -# "e1d0d72078f7fbef653e705bfb0fe018bd9c772e", -# "foolano", "test", -# "Foolano Garcia", "foolano@garciagarcia.com" -def tag(name, message, sha, owner, repo, tagger_name, tagger_email) - r = { - "tag": name, - "message": "#{message}\n", - "object": sha, - "type": "commit", - "tagger": { - "name": tagger_name, - "email": tagger_email, - "date": Time.now.utc.iso8601.to_s - } - }.to_json - res = post("/repos/#{owner}/#{repo}/git/tags", r) +def post_file(path, body) + req = Net::HTTP::Post.new(path) + req['Authorization'] = "token #{release_token}" + req['Content-Type'] = path.match(/.*\.tar\.gz$/) ? "application/tar+gzip" : "application/vnd.debian.binary-package" + req.body = body + client.request(req) +end + +def put(path, body) + req = Net::HTTP::Put.new(path) + req['Authorization'] = "token #{release_token}" + req.body = body + client.request(req) +end - raise "Creating tag object failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess +def patch(path, body) + req = Net::HTTP::Patch.new(path) + req['Authorization'] = "token #{release_token}" + req.body = body + client.request(req) +end +def release_token + token = ENV["GH_RELEASE_TOKEN"] + raise "GH_RELEASE_TOKEN not set" if token.nil? + + token +end + +# Create a lightweight tag +def tag(name, sha, owner, repo) body = { - "ref": "refs/heads/#{name}", + "ref": "refs/tags/#{name}", "sha": sha }.to_json res = post("/repos/#{owner}/#{repo}/git/refs", body) @@ -111,12 +114,13 @@ def tag(name, message, sha, owner, repo, tagger_name, tagger_email) end def bug_or_feature?(issue_hash) - return true if issue_hash["labels"].find { |l| ["bug", "feature"].include?(l["name"]) } + return true + #return true if issue_hash["labels"].find { |l| ["bug", "feature", "enhancement"].include?(l["name"]) } false end def issue_from(owner, repo, issue) - res = get("/repos/#{owner}/#{repo}/issues/#{issue}") + res = get("/repos/github/#{repo}/issues/#{issue}") raise "Issue ##{issue} not found in #{owner}/#{repo}" unless res.kind_of? Net::HTTPSuccess JSON.parse(res.body) @@ -129,7 +133,7 @@ def beautify_changes(changes, owner, repo) begin j = issue_from(owner, repo, $1) if bug_or_feature?(j) - c << "#{j['title']} ##{$1}" + c << "#{j['title'].capitalize} ##{$1}" end rescue => e warn "Warning: #{e.message}" @@ -141,7 +145,7 @@ def beautify_changes(changes, owner, repo) end def changelog() - changes = `git log --pretty=oneline origin/stable...origin/master | grep "Merge pull request"`.lines + changes = `git log --pretty=oneline origin/stable...origin/master --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) raise "Building the changelog failed" if $? != 0 changes @@ -170,6 +174,19 @@ def create_release(tag_name, branch, owner, repo, rel_name, rel_body, draft = tr "prerelease": false }.to_json res = post("/repos/#{owner}/#{repo}/releases", body) + + raise "Failed to create release (#{res.code})" unless res.kind_of? Net::HTTPSuccess + + JSON.parse(res.body) +end + +def publish_release(owner, repo, release_id) + body = { + "draft": false + }.to_json + res = patch("/repos/#{owner}/#{repo}/releases/#{release_id}", body) + + raise "Failed to update release (#{res.code})" unless res.kind_of? Net::HTTPSuccess end def list_releases(owner, repo) @@ -198,16 +215,16 @@ def bump_version(new_version, path = "share/github-backup-utils/version") end def push_release_branch(version, changes) - if !system("git checkout --quiet -b release-#{version}") - raise "Creating release branch failed" + unless out = `git checkout --quiet -b release-#{version}` + raise "Creating release branch failed:\n\n#{out}" end - if !system("git commit --quiet -m 'Bump version: #{version}\n#{changes}' debian/changelog share/github-backup-utils/version") - raise "Error commiting changelog and version" + unless out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version` + raise "Error commiting changelog and version:\n\n#{out}" end - if !system("git push --quiet origin release-#{version}") - raise "Failed pushing the release branch" + unless out = `git push --quiet origin release-#{version}` + raise "Failed pushing the release branch:\n\n#{out}" end end @@ -220,6 +237,44 @@ def create_release_pr(version, owner, repo, release_body) }.to_json res = post("/repos/#{owner}/#{repo}/pulls", body) raise "Creating release PR failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess + + JSON.parse(res.body) +end + +def merge_pr(number, sha, owner, repo, version) + body = { + "commit_title": "Merge pull request ##{number} from github/release-#{version}", + "commit_message": "Bump version: #{version}", + "sha": sha, + "merge_method": "merge" + }.to_json + + pr_mergeable?(owner, repo, number) + + res = put("/repos/#{owner}/#{repo}/pulls/#{number}/merge", body) + + raise "Merging PR failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess + + JSON.parse(res.body) +end + +class RetryError < StandardError +end + +def pr_mergeable?(owner, repo, number) + mergeable = false + begin + retries ||= 5 + res = get("/repos/#{owner}/#{repo}/pulls/#{number}") + raise RetryError if JSON.parse(res.body)["mergeable"].nil? + mergeable = JSON.parse(res.body)["mergeable"] + rescue RetryError + sleep 1 + retry unless (retries -= 1).zero? + raise "PR is unmergable." + end + + mergeable end def can_auth? @@ -231,87 +286,170 @@ def repo_exists?(owner, repo) res.kind_of? Net::HTTPSuccess end -args = ARGV.dup -dry_run = false -if args.include?("--dry-run") - dry_run = true - args.delete '--dry-run' +def can_build_deb? + system("which debuild > /dev/null 2>&1") end -if args.include?("--no-warn") - $no_warn = true - args.delete '--no-warn' +def package_tarball + unless out = `script/package-tarball 2>&1` + raise "Failed to package tarball:\n\n#{out}" + end + out end -if args.size < 1 - $stderr.puts "Usage: release [--dry-run] " - exit 1 +def package_deb + unless out = `DEB_BUILD_OPTIONS=nocheck script/package-deb 2>&1` + raise "Failed to package Debian package:\n\n#{out}" + end + out end -begin - version = Gem::Version.new(args[0]) -rescue ArgumentError - $stderr.puts "Error parsing version #{args[0]}" - exit 1 +def attach_assets_to_release(upload_url, owner, repo, release_id, files) + @http = nil + client(URI(upload_url.gsub(/{.*}/, '')).host) + begin + files.each do |file| + raw_file = File.open(file).read + res = post_file("/repos/#{owner}/#{repo}/releases/#{release_id}/assets?name=#{File.basename(file)}", raw_file) + raise "Failed to attach #{file} to release (#{res.code})" unless res.kind_of? Net::HTTPSuccess + end + rescue => e + raise e + end + @http = nil end -if !repo_exists?(GH_OWNER, GH_REPO) - $stderr.puts "The repo #{GH_REPO} does not exist for #{GH_OWNER}" - exit 1 +def clean_up(version) + #`git checkout --quiet origin/release-automation` + `git checkout --quiet master` + `git fetch --quiet origin --prune` + `git pull --quiet origin master --prune` + `git branch --quiet -D release-#{version} >/dev/null 2>&1` + `git push --quiet origin :release-#{version} >/dev/null 2>&1` + `git branch --quiet -D tmp-packging >/dev/null 2>&1` end -release_changes = [] -release_a = false -if dry_run - if can_auth? - release_changes = beautify_changes(changelog, GH_OWNER, GH_REPO) +#### All the action starts #### +if $0 == __FILE__ + begin + args = ARGV.dup + dry_run = false + if args.include?("--dry-run") + dry_run = true + args.delete '--dry-run' + end + + if args.include?("--no-warn") + $no_warn = true + args.delete '--no-warn' + end + + if args.size < 1 + raise "Usage: release [--dry-run] " + end + + begin + version = Gem::Version.new(args[0]) + rescue ArgumentError + raise "Error parsing version #{args[0]}" + end + + unless repo_exists?(GH_OWNER, GH_REPO) + raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" + end + + unless can_build_deb? + raise "Unable to build Debian pkg: 'debuild' not found." + end + + release_changes = [] + release_a = false release_a = release_available?(GH_OWNER, GH_REPO, "v#{version}") - puts "Existing release: #{release_a}" - end - puts "New version: #{version}" - puts "Owner: #{GH_OWNER}" - puts "Repo: #{GH_REPO}" - puts "Author: #{GH_AUTHOR}" - puts "Token: #{ENV['GH_RELEASE_TOKEN'] && "set" || "unset"}" - if can_auth? - puts "Changelog:" - release_changes.each { |c| puts " * #{c}"} - else - $stderr.puts "Release Failed: Please set a GH_RELEASE_TOKEN" - exit 1 - end - exit -end + if can_auth? + release_changes = beautify_changes(changelog, GH_OWNER, GH_REPO) + end -if release_a - $stderr.puts "Release #{version} already exists." - exit 1 -end + if dry_run + puts "Existing release?: #{release_a}" + puts "New version: #{version}" + puts "Owner: #{GH_OWNER}" + puts "Repo: #{GH_REPO}" + puts "Author: #{GH_AUTHOR}" + puts "Token: #{ENV['GH_RELEASE_TOKEN'] && "set" || "unset"}" + if can_auth? + puts "Changelog:" + if release_changes.empty? + puts " => No new bug fixes, enhancements or features." + else + release_changes.each { |c| puts " * #{c}"} + end + else + raise "Release Failed: Please set a GH_RELEASE_TOKEN" + end + exit + end -`git fetch --quiet origin --prune` -branches = `git branch --all | grep release-#{version}$` -if !branches.empty? - $stderr.puts "Release branch release-#{version} already exists." - $stderr.puts "Branches found:" - branches.each_line { |l| puts "* #{l.strip.chomp}" } - exit 1 -end + if release_a + raise "Release #{version} already exists." + end + + `git fetch --quiet origin --prune` + branches = `git branch --all | grep release-#{version}$` + if !branches.empty? + out = "Release branch release-#{version} already exists. " + out += "Branches found:" + branches.each_line { |l| out += "\n* #{l.strip.chomp}" } + raise out + end -puts "Bumping version to #{version}" -bump_version(version) + puts "Bumping version to #{version}..." + bump_version(version) -puts "Updating changelog" -update_changelog release_changes, DEB_PKG_NAME, version, GH_AUTHOR, GH_OWNER, GH_REPO + puts "Updating changelog..." + update_changelog(release_changes, DEB_PKG_NAME, version, GH_AUTHOR, GH_OWNER, GH_REPO) + release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}" + release_changes.each do |c| + release_body += "\n* #{c}" + end -puts "Creating release" -release_title = "GitHub Enterprise Backup Utilities v#{version}" -release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}" -release_changes.each do |c| - release_body += "\n* #{c}" -end -create_release "v#{version}", "master", GH_OWNER, GH_REPO, release_title, release_body + puts "Creating and publishing the release branch..." + push_release_branch(version, release_changes) + res = create_release_pr(version, GH_OWNER, GH_REPO, "#{release_body}\n\n/cc github/backup-utils") -puts "Creating and publishing the release branch" -push_release_branch(version, release_changes) -create_release_pr(version, GH_OWNER, GH_REPO, release_body) -puts "Released!" + puts "Merging release PR..." + res = merge_pr(res['number'], res['head']['sha'], GH_OWNER, GH_REPO, version) + + puts "Tagging and publishing the release..." + res = tag("v#{version}", res['sha'], GH_OWNER, GH_REPO) + + puts "Creating release..." + release_title = "GitHub Enterprise Backup Utilities v#{version}" + res = create_release "v#{version}", "master", GH_OWNER, GH_REPO, release_title, release_body, true + + # Tidy up before building tarball and deb pkg + clean_up version + + puts "Building release tarball..." + package_tarball + + puts "Building Debian pkg..." + package_deb + + puts "Attaching Debian pkg and tarball to release..." + base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) + attach_assets_to_release(res['upload_url'], GH_OWNER, GH_REPO, res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"]) + attach_assets_to_release(res['upload_url'], GH_OWNER, GH_REPO, res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_amd64.deb"]) + + puts "Publishing release..." + publish_release(GH_OWNER, GH_REPO, res['id']) + + puts "Cleaning up..." + clean_up version + + puts "Released!" + rescue RuntimeError => e + clean_up version + $stderr.puts e + exit 1 + end +end From 9bea84a986581dbe84d2fe072abea884222e72c1 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Sep 2017 14:57:53 +0100 Subject: [PATCH 0290/2421] Use constants instead of passing around vars --- script/release | 87 +++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/script/release b/script/release index e87b9118e..0405797d7 100755 --- a/script/release +++ b/script/release @@ -41,7 +41,7 @@ CHANGELOG_TMPL = """<%= package_name %> (<%= package_version %>) UNRELEASED; urg * <%= ch.strip.chomp %> <% end -%> - -- <%= author %> <%= Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S %z') %> + -- <%= GH_AUTHOR %> <%= Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S %z') %> """ @@ -103,12 +103,12 @@ def release_token end # Create a lightweight tag -def tag(name, sha, owner, repo) +def tag(name, sha) body = { "ref": "refs/tags/#{name}", "sha": sha }.to_json - res = post("/repos/#{owner}/#{repo}/git/refs", body) + res = post("/repos/#{GH_OWNER}/#{GH_REPO}/git/refs", body) raise "Creating tag ref failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess end @@ -119,19 +119,19 @@ def bug_or_feature?(issue_hash) false end -def issue_from(owner, repo, issue) - res = get("/repos/github/#{repo}/issues/#{issue}") - raise "Issue ##{issue} not found in #{owner}/#{repo}" unless res.kind_of? Net::HTTPSuccess +def issue_from(issue) + res = get("/repos/github/#{GH_REPO}/issues/#{issue}") + raise "Issue ##{issue} not found in #{GH_OWNER}/#{GH_REPO}" unless res.kind_of? Net::HTTPSuccess JSON.parse(res.body) end -def beautify_changes(changes, owner, repo) +def beautify_changes(changes) c = [] changes.each do |ch| if ch =~ /#(\d+)/ begin - j = issue_from(owner, repo, $1) + j = issue_from($1) if bug_or_feature?(j) c << "#{j['title'].capitalize} ##{$1}" end @@ -151,20 +151,20 @@ def changelog() changes end -def build_changelog(changes, package_name, package_version, author, owner, repo) +def build_changelog(changes, package_name, package_version) ERB.new(CHANGELOG_TMPL, nil, "-").result(binding) end -def update_changelog(changes, name, version, author, owner, repo, path = "debian/changelog") +def update_changelog(changes, name, version, path = "debian/changelog") raise "debian/changelog not found" unless File.exist?(path) File.open("#{path}.new", 'w') do |f| - f.puts build_changelog changes, name, version, author, owner, repo + f.puts build_changelog changes, name, version f.puts(File.read(path)) end File.rename("#{path}.new", path) end -def create_release(tag_name, branch, owner, repo, rel_name, rel_body, draft = true) +def create_release(tag_name, branch, rel_name, rel_body, draft = true) body = { "tag_name": tag_name, "target_commitish": branch, @@ -173,32 +173,31 @@ def create_release(tag_name, branch, owner, repo, rel_name, rel_body, draft = tr "draft": draft, "prerelease": false }.to_json - res = post("/repos/#{owner}/#{repo}/releases", body) + res = post("/repos/#{GH_OWNER}/#{GH_REPO}/releases", body) raise "Failed to create release (#{res.code})" unless res.kind_of? Net::HTTPSuccess JSON.parse(res.body) end -def publish_release(owner, repo, release_id) +def publish_release(release_id) body = { "draft": false }.to_json - res = patch("/repos/#{owner}/#{repo}/releases/#{release_id}", body) + res = patch("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}", body) raise "Failed to update release (#{res.code})" unless res.kind_of? Net::HTTPSuccess end -def list_releases(owner, repo) - res = get("/repos/#{owner}/#{repo}/releases") +def list_releases + res = get("/repos/#{GH_OWNER}/#{GH_REPO}/releases") raise "Error retrieving releases" unless res.kind_of? Net::HTTPSuccess JSON.parse(res.body) end -def release_available?(owner, repo, tag_name) - releases = list_releases owner, repo - return true if releases.find { |r| r["tag_name"] == tag_name } +def release_available?(tag_name) + return true if list_releases.find { |r| r["tag_name"] == tag_name } false end @@ -228,20 +227,20 @@ def push_release_branch(version, changes) end end -def create_release_pr(version, owner, repo, release_body) +def create_release_pr(version, release_body) body = { "title": "Bump version: #{version}", "body": release_body, "head": "release-#{version}", "base": "master" }.to_json - res = post("/repos/#{owner}/#{repo}/pulls", body) + res = post("/repos/#{GH_OWNER}/#{GH_REPO}/pulls", body) raise "Creating release PR failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess JSON.parse(res.body) end -def merge_pr(number, sha, owner, repo, version) +def merge_pr(number, sha, version) body = { "commit_title": "Merge pull request ##{number} from github/release-#{version}", "commit_message": "Bump version: #{version}", @@ -249,9 +248,9 @@ def merge_pr(number, sha, owner, repo, version) "merge_method": "merge" }.to_json - pr_mergeable?(owner, repo, number) + pr_mergeable? number - res = put("/repos/#{owner}/#{repo}/pulls/#{number}/merge", body) + res = put("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}/merge", body) raise "Merging PR failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess @@ -261,11 +260,11 @@ end class RetryError < StandardError end -def pr_mergeable?(owner, repo, number) +def pr_mergeable?(number) mergeable = false begin retries ||= 5 - res = get("/repos/#{owner}/#{repo}/pulls/#{number}") + res = get("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}") raise RetryError if JSON.parse(res.body)["mergeable"].nil? mergeable = JSON.parse(res.body)["mergeable"] rescue RetryError @@ -281,8 +280,8 @@ def can_auth? !ENV["GH_RELEASE_TOKEN"].nil? end -def repo_exists?(owner, repo) - res = get("/repos/#{owner}/#{repo}") +def repo_exists? + res = get("/repos/#{GH_OWNER}/#{GH_REPO}") res.kind_of? Net::HTTPSuccess end @@ -304,13 +303,13 @@ def package_deb out end -def attach_assets_to_release(upload_url, owner, repo, release_id, files) +def attach_assets_to_release(upload_url, release_id, files) @http = nil client(URI(upload_url.gsub(/{.*}/, '')).host) begin files.each do |file| raw_file = File.open(file).read - res = post_file("/repos/#{owner}/#{repo}/releases/#{release_id}/assets?name=#{File.basename(file)}", raw_file) + res = post_file("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}/assets?name=#{File.basename(file)}", raw_file) raise "Failed to attach #{file} to release (#{res.code})" unless res.kind_of? Net::HTTPSuccess end rescue => e @@ -354,7 +353,7 @@ if $0 == __FILE__ raise "Error parsing version #{args[0]}" end - unless repo_exists?(GH_OWNER, GH_REPO) + unless repo_exists? raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" end @@ -364,9 +363,9 @@ if $0 == __FILE__ release_changes = [] release_a = false - release_a = release_available?(GH_OWNER, GH_REPO, "v#{version}") + release_a = release_available? "v#{version}" if can_auth? - release_changes = beautify_changes(changelog, GH_OWNER, GH_REPO) + release_changes = beautify_changes changelog end if dry_run @@ -403,28 +402,28 @@ if $0 == __FILE__ end puts "Bumping version to #{version}..." - bump_version(version) + bump_version version puts "Updating changelog..." - update_changelog(release_changes, DEB_PKG_NAME, version, GH_AUTHOR, GH_OWNER, GH_REPO) + update_changelog release_changes, DEB_PKG_NAME, version release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}" release_changes.each do |c| release_body += "\n* #{c}" end puts "Creating and publishing the release branch..." - push_release_branch(version, release_changes) - res = create_release_pr(version, GH_OWNER, GH_REPO, "#{release_body}\n\n/cc github/backup-utils") + push_release_branch version, release_changes + res = create_release_pr(version, "#{release_body}\n\n/cc github/backup-utils") puts "Merging release PR..." - res = merge_pr(res['number'], res['head']['sha'], GH_OWNER, GH_REPO, version) + res = merge_pr res['number'], res['head']['sha'], version puts "Tagging and publishing the release..." - res = tag("v#{version}", res['sha'], GH_OWNER, GH_REPO) + res = tag "v#{version}", res['sha'] puts "Creating release..." release_title = "GitHub Enterprise Backup Utilities v#{version}" - res = create_release "v#{version}", "master", GH_OWNER, GH_REPO, release_title, release_body, true + res = create_release "v#{version}", "master", release_title, release_body, true # Tidy up before building tarball and deb pkg clean_up version @@ -437,11 +436,11 @@ if $0 == __FILE__ puts "Attaching Debian pkg and tarball to release..." base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) - attach_assets_to_release(res['upload_url'], GH_OWNER, GH_REPO, res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"]) - attach_assets_to_release(res['upload_url'], GH_OWNER, GH_REPO, res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_amd64.deb"]) + attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] + attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_amd64.deb"] puts "Publishing release..." - publish_release(GH_OWNER, GH_REPO, res['id']) + publish_release res['id'] puts "Cleaning up..." clean_up version From ef0069c2b7b4da0410e20200b0ca4bcd06e60660 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Sep 2017 16:16:35 +0100 Subject: [PATCH 0291/2421] Refactor based on rubocop suggestions --- script/release | 226 ++++++++++++++++++++++--------------------------- 1 file changed, 100 insertions(+), 126 deletions(-) diff --git a/script/release b/script/release index 0405797d7..36df3db1f 100755 --- a/script/release +++ b/script/release @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + #/ Usage: release [--dry-run] #/ #/ Publish a backup-utils release: @@ -16,40 +18,34 @@ #/ * Only pull requests labeled with bug or feature will show up in the #/ release page and the changelog. #/ -# TODO: Auto-merge the release PR -# TODO: Tag the release -# TODO: Build and upload the binaries to the release draft -# TODO: Preflight check: make sure auth works and provide a friendly error otherwise -# TODO: Preflight check: Make sure the target owner/repo exists # TODO: Use the constants we define rather than passing variables. # require 'json' require 'net/http' require 'time' require 'erb' +require 'English' -API_HOST = ENV["GH_HOST"] || "api.github.com" +API_HOST = ENV['GH_HOST'] || 'api.github.com' API_PORT = 443 -GH_REPO = ENV["GH_REPO"] || "backup-utils" -GH_OWNER = ENV["GH_OWNER"] || "github" -GH_AUTHOR = ENV["GH_AUTHOR"] || "Sergio Rubio " -DEB_PKG_NAME = "github-backup-utils" +GH_REPO = ENV['GH_REPO'] || 'backup-utils' +GH_OWNER = ENV['GH_OWNER'] || 'github' +GH_AUTHOR = ENV['GH_AUTHOR'] || 'Sergio Rubio ' +DEB_PKG_NAME = 'github-backup-utils' -CHANGELOG_TMPL = """<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium +CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium <%- changes.each do |ch| -%> * <%= ch.strip.chomp %> <% end -%> - -- <%= GH_AUTHOR %> <%= Time.now.utc.strftime('%a, %d %b %Y %H:%M:%S %z') %> + -- <%= GH_AUTHOR %> <%= Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S %z") %> -""" +''' # Override Kernel.warn def warn(msg) - unless $no_warn - Kernel.warn msg - end + Kernel.warn msg unless @no_warn end def client(host = API_HOST, port = API_PORT) @@ -76,7 +72,7 @@ end def post_file(path, body) req = Net::HTTP::Post.new(path) req['Authorization'] = "token #{release_token}" - req['Content-Type'] = path.match(/.*\.tar\.gz$/) ? "application/tar+gzip" : "application/vnd.debian.binary-package" + req['Content-Type'] = path.match?(/.*\.tar\.gz$/) ? 'application/tar+gzip' : 'application/vnd.debian.binary-package' req.body = body client.request(req) end @@ -96,8 +92,8 @@ def patch(path, body) end def release_token - token = ENV["GH_RELEASE_TOKEN"] - raise "GH_RELEASE_TOKEN not set" if token.nil? + token = ENV['GH_RELEASE_TOKEN'] + raise 'GH_RELEASE_TOKEN not set' if token.nil? token end @@ -110,53 +106,50 @@ def tag(name, sha) }.to_json res = post("/repos/#{GH_OWNER}/#{GH_REPO}/git/refs", body) - raise "Creating tag ref failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess + raise "Creating tag ref failed (#{res.code})" unless res.is_a? Net::HTTPSuccess end def bug_or_feature?(issue_hash) - return true + true #return true if issue_hash["labels"].find { |l| ["bug", "feature", "enhancement"].include?(l["name"]) } - false + #false end def issue_from(issue) res = get("/repos/github/#{GH_REPO}/issues/#{issue}") - raise "Issue ##{issue} not found in #{GH_OWNER}/#{GH_REPO}" unless res.kind_of? Net::HTTPSuccess + raise "Issue ##{issue} not found in #{GH_OWNER}/#{GH_REPO}" unless res.is_a? Net::HTTPSuccess JSON.parse(res.body) end def beautify_changes(changes) - c = [] - changes.each do |ch| - if ch =~ /#(\d+)/ - begin - j = issue_from($1) - if bug_or_feature?(j) - c << "#{j['title'].capitalize} ##{$1}" - end - rescue => e - warn "Warning: #{e.message}" - end + out = [] + changes.each do |chg| + next unless chg =~ /#(\d+)/ + begin + issue = issue_from Regexp.last_match(1) + out << "#{issue['title'].capitalize} ##{Regexp.last_match(1)}" if bug_or_feature?(issue) + rescue => e + warn "Warning: #{e.message}" end end - c + out end -def changelog() +def changelog changes = `git log --pretty=oneline origin/stable...origin/master --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) - raise "Building the changelog failed" if $? != 0 + raise 'Building the changelog failed' if $CHILD_STATUS != 0 changes end def build_changelog(changes, package_name, package_version) - ERB.new(CHANGELOG_TMPL, nil, "-").result(binding) + ERB.new(CHANGELOG_TMPL, nil, '-').result(binding) end -def update_changelog(changes, name, version, path = "debian/changelog") - raise "debian/changelog not found" unless File.exist?(path) +def update_changelog(changes, name, version, path = 'debian/changelog') + raise 'debian/changelog not found' unless File.exist?(path) File.open("#{path}.new", 'w') do |f| f.puts build_changelog changes, name, version f.puts(File.read(path)) @@ -166,43 +159,43 @@ end def create_release(tag_name, branch, rel_name, rel_body, draft = true) body = { - "tag_name": tag_name, - "target_commitish": branch, - "name": rel_name, - "body": rel_body, - "draft": draft, - "prerelease": false + 'tag_name': tag_name, + 'target_commitish': branch, + 'name': rel_name, + 'body': rel_body, + 'draft': draft, + 'prerelease': false }.to_json res = post("/repos/#{GH_OWNER}/#{GH_REPO}/releases", body) - raise "Failed to create release (#{res.code})" unless res.kind_of? Net::HTTPSuccess + raise "Failed to create release (#{res.code})" unless res.is_a? Net::HTTPSuccess JSON.parse(res.body) end def publish_release(release_id) body = { - "draft": false + 'draft': false }.to_json res = patch("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}", body) - raise "Failed to update release (#{res.code})" unless res.kind_of? Net::HTTPSuccess + raise "Failed to update release (#{res.code})" unless res.is_a? Net::HTTPSuccess end def list_releases res = get("/repos/#{GH_OWNER}/#{GH_REPO}/releases") - raise "Error retrieving releases" unless res.kind_of? Net::HTTPSuccess + raise 'Error retrieving releases' unless res.is_a? Net::HTTPSuccess JSON.parse(res.body) end def release_available?(tag_name) - return true if list_releases.find { |r| r["tag_name"] == tag_name } + return true if list_releases.find { |r| r['tag_name'] == tag_name } - false + false end -def bump_version(new_version, path = "share/github-backup-utils/version") +def bump_version(new_version, path = 'share/github-backup-utils/version') current_version = Gem::Version.new(File.read(path).strip.chomp) if Gem::Version.new(new_version) < current_version raise "New version should be newer than #{current_version}" @@ -213,46 +206,43 @@ def bump_version(new_version, path = "share/github-backup-utils/version") File.rename("#{path}.new", path) end -def push_release_branch(version, changes) - unless out = `git checkout --quiet -b release-#{version}` +def push_release_branch(version) + unless (out = `git checkout --quiet -b release-#{version}`) raise "Creating release branch failed:\n\n#{out}" end - unless out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version` + unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version`) raise "Error commiting changelog and version:\n\n#{out}" end - unless out = `git push --quiet origin release-#{version}` + unless (out = `git push --quiet origin release-#{version}`) raise "Failed pushing the release branch:\n\n#{out}" end end def create_release_pr(version, release_body) body = { - "title": "Bump version: #{version}", - "body": release_body, - "head": "release-#{version}", - "base": "master" + 'title': "Bump version: #{version}", + 'body': release_body, + 'head': "release-#{version}", + 'base': 'master' }.to_json res = post("/repos/#{GH_OWNER}/#{GH_REPO}/pulls", body) - raise "Creating release PR failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess + raise "Creating release PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess JSON.parse(res.body) end def merge_pr(number, sha, version) body = { - "commit_title": "Merge pull request ##{number} from github/release-#{version}", - "commit_message": "Bump version: #{version}", - "sha": sha, - "merge_method": "merge" + 'commit_title': "Merge pull request ##{number} from github/release-#{version}", + 'commit_message': "Bump version: #{version}", + 'sha': sha, + 'merge_method': 'merge' }.to_json - pr_mergeable? number - res = put("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}/merge", body) - - raise "Merging PR failed (#{res.code})" unless res.kind_of? Net::HTTPSuccess + raise "Merging PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess JSON.parse(res.body) end @@ -261,43 +251,42 @@ class RetryError < StandardError end def pr_mergeable?(number) - mergeable = false begin retries ||= 5 res = get("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}") - raise RetryError if JSON.parse(res.body)["mergeable"].nil? - mergeable = JSON.parse(res.body)["mergeable"] + raise RetryError if JSON.parse(res.body)['mergeable'].nil? + mergeable = JSON.parse(res.body)['mergeable'] rescue RetryError sleep 1 retry unless (retries -= 1).zero? - raise "PR is unmergable." + raise 'PR is unmergable.' end - mergeable + mergeable || false end def can_auth? - !ENV["GH_RELEASE_TOKEN"].nil? + !ENV['GH_RELEASE_TOKEN'].nil? end def repo_exists? res = get("/repos/#{GH_OWNER}/#{GH_REPO}") - res.kind_of? Net::HTTPSuccess + res.is_a? Net::HTTPSuccess end def can_build_deb? - system("which debuild > /dev/null 2>&1") + system('which debuild > /dev/null 2>&1') end def package_tarball - unless out = `script/package-tarball 2>&1` + unless (out = `script/package-tarball 2>&1`) raise "Failed to package tarball:\n\n#{out}" end out end def package_deb - unless out = `DEB_BUILD_OPTIONS=nocheck script/package-deb 2>&1` + unless (out = `DEB_BUILD_OPTIONS=nocheck script/package-deb 2>&1`) raise "Failed to package Debian package:\n\n#{out}" end out @@ -310,7 +299,7 @@ def attach_assets_to_release(upload_url, release_id, files) files.each do |file| raw_file = File.open(file).read res = post_file("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}/assets?name=#{File.basename(file)}", raw_file) - raise "Failed to attach #{file} to release (#{res.code})" unless res.kind_of? Net::HTTPSuccess + raise "Failed to attach #{file} to release (#{res.code})" unless res.is_a? Net::HTTPSuccess end rescue => e raise e @@ -319,7 +308,6 @@ def attach_assets_to_release(upload_url, release_id, files) end def clean_up(version) - #`git checkout --quiet origin/release-automation` `git checkout --quiet master` `git fetch --quiet origin --prune` `git pull --quiet origin master --prune` @@ -329,23 +317,21 @@ def clean_up(version) end #### All the action starts #### -if $0 == __FILE__ +if $PROGRAM_NAME == __FILE__ begin args = ARGV.dup dry_run = false - if args.include?("--dry-run") + if args.include?('--dry-run') dry_run = true args.delete '--dry-run' end - if args.include?("--no-warn") - $no_warn = true + if args.include?('--no-warn') + @no_warn = true args.delete '--no-warn' end - if args.size < 1 - raise "Usage: release [--dry-run] " - end + raise 'Usage: release [--dry-run] ' if args.empty? begin version = Gem::Version.new(args[0]) @@ -353,20 +339,14 @@ if $0 == __FILE__ raise "Error parsing version #{args[0]}" end - unless repo_exists? - raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" - end + raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" unless repo_exists? - unless can_build_deb? - raise "Unable to build Debian pkg: 'debuild' not found." - end + raise 'Unable to build Debian pkg: "debuild" not found.' unless can_build_deb? release_changes = [] + release_changes = beautify_changes changelog if can_auth? release_a = false release_a = release_available? "v#{version}" - if can_auth? - release_changes = beautify_changes changelog - end if dry_run puts "Existing release?: #{release_a}" @@ -374,29 +354,23 @@ if $0 == __FILE__ puts "Owner: #{GH_OWNER}" puts "Repo: #{GH_REPO}" puts "Author: #{GH_AUTHOR}" - puts "Token: #{ENV['GH_RELEASE_TOKEN'] && "set" || "unset"}" - if can_auth? - puts "Changelog:" - if release_changes.empty? - puts " => No new bug fixes, enhancements or features." - else - release_changes.each { |c| puts " * #{c}"} - end + puts "Token: #{ENV['GH_RELEASE_TOKEN'] && 'set' || 'unset'}" + puts 'Changelog:' + if release_changes.empty? + puts ' => No new bug fixes, enhancements or features.' else - raise "Release Failed: Please set a GH_RELEASE_TOKEN" + release_changes.each { |c| puts " * #{c}" } end exit end - if release_a - raise "Release #{version} already exists." - end + raise "Release #{version} already exists." if release_a `git fetch --quiet origin --prune` branches = `git branch --all | grep release-#{version}$` - if !branches.empty? + unless branches.empty? out = "Release branch release-#{version} already exists. " - out += "Branches found:" + out += 'Branches found:' branches.each_line { |l| out += "\n* #{l.strip.chomp}" } raise out end @@ -404,48 +378,48 @@ if $0 == __FILE__ puts "Bumping version to #{version}..." bump_version version - puts "Updating changelog..." + puts 'Updating changelog...' update_changelog release_changes, DEB_PKG_NAME, version release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}" release_changes.each do |c| release_body += "\n* #{c}" end - puts "Creating and publishing the release branch..." - push_release_branch version, release_changes + puts 'Creating and publishing the release branch...' + push_release_branch version res = create_release_pr(version, "#{release_body}\n\n/cc github/backup-utils") - puts "Merging release PR..." + puts 'Merging release PR...' res = merge_pr res['number'], res['head']['sha'], version - puts "Tagging and publishing the release..." - res = tag "v#{version}", res['sha'] + puts 'Tagging and publishing the release...' + tag "v#{version}", res['sha'] - puts "Creating release..." + puts 'Creating release...' release_title = "GitHub Enterprise Backup Utilities v#{version}" - res = create_release "v#{version}", "master", release_title, release_body, true + res = create_release "v#{version}", 'master', release_title, release_body, true # Tidy up before building tarball and deb pkg clean_up version - puts "Building release tarball..." + puts 'Building release tarball...' package_tarball - puts "Building Debian pkg..." + puts 'Building Debian pkg...' package_deb - puts "Attaching Debian pkg and tarball to release..." + puts 'Attaching Debian pkg and tarball to release...' base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_amd64.deb"] - puts "Publishing release..." + puts 'Publishing release...' publish_release res['id'] - puts "Cleaning up..." + puts 'Cleaning up...' clean_up version - puts "Released!" + puts 'Released!' rescue RuntimeError => e clean_up version $stderr.puts e From f4724974c85481a954caf534f5895f8b2e0b2b1b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Sep 2017 16:16:53 +0100 Subject: [PATCH 0292/2421] Add .ruby-version for 2.4.0 --- .ruby-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 000000000..197c4d5c2 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.4.0 From 296970020da438902cc0997f3616c0707aa939ac Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Sep 2017 16:20:20 +0100 Subject: [PATCH 0293/2421] Replace explicit repo name with constant --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index 36df3db1f..b90335133 100755 --- a/script/release +++ b/script/release @@ -116,7 +116,7 @@ def bug_or_feature?(issue_hash) end def issue_from(issue) - res = get("/repos/github/#{GH_REPO}/issues/#{issue}") + res = get("/repos/#{GH_OWNER}/#{GH_REPO}/issues/#{issue}") raise "Issue ##{issue} not found in #{GH_OWNER}/#{GH_REPO}" unless res.is_a? Net::HTTPSuccess JSON.parse(res.body) From 3b27d492580d0495b082c63bde310cbfb50ff48c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Sep 2017 16:30:58 +0100 Subject: [PATCH 0294/2421] Bring back notes based on tags --- script/release | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/script/release b/script/release index b90335133..5fed30a8b 100755 --- a/script/release +++ b/script/release @@ -110,9 +110,8 @@ def tag(name, sha) end def bug_or_feature?(issue_hash) - true - #return true if issue_hash["labels"].find { |l| ["bug", "feature", "enhancement"].include?(l["name"]) } - #false + return true if issue_hash['labels'].find { |label| ['bug', 'feature', 'enhancement'].include?(label['name']) } + false end def issue_from(issue) From 76be7ab7bb4cd89478aeea7e3d82435697fe5150 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Sep 2017 16:31:16 +0100 Subject: [PATCH 0295/2421] Update comments --- script/release | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/script/release b/script/release index 5fed30a8b..b493a6146 100755 --- a/script/release +++ b/script/release @@ -7,6 +7,7 @@ #/ * Updates the package changelog #/ * Bumps the backup-utils version if required #/ * Creates the release pull request +#/ * Merges the release pull request #/ * Creates the release draft #/ * Tags the release #/ * Builds the release assets and uploads them @@ -15,11 +16,9 @@ #/ * Needs GH_RELEASE_TOKEN available in the environment. #/ * Export GH_OWNER, GH_AUTHOR and GH_REPO if you want to tweak the build #/ changelog or use a different owner/repo -#/ * Only pull requests labeled with bug or feature will show up in the +#/ * Only pull requests labeled with bug, feature or enhancement will show up in the #/ release page and the changelog. #/ -# TODO: Use the constants we define rather than passing variables. -# require 'json' require 'net/http' require 'time' From 370371cf5d602dbe2282b1161ce0a67d5ae95b4f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Sep 2017 16:42:39 +0100 Subject: [PATCH 0296/2421] Improve errors and docs --- script/release | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/script/release b/script/release index b493a6146..8c714e641 100755 --- a/script/release +++ b/script/release @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -#/ Usage: release [--dry-run] +#/ Usage: GH_RELEASE_TOKEN=your-amazing-secure-token release [--dry-run] #/ #/ Publish a backup-utils release: #/ * Updates the package changelog @@ -92,7 +92,7 @@ end def release_token token = ENV['GH_RELEASE_TOKEN'] - raise 'GH_RELEASE_TOKEN not set' if token.nil? + raise 'GH_RELEASE_TOKEN environment variable not set' if token.nil? token end @@ -182,7 +182,7 @@ end def list_releases res = get("/repos/#{GH_OWNER}/#{GH_REPO}/releases") - raise 'Error retrieving releases' unless res.is_a? Net::HTTPSuccess + raise 'Failed to retrieve releases' unless res.is_a? Net::HTTPSuccess JSON.parse(res.body) end @@ -198,9 +198,7 @@ def bump_version(new_version, path = 'share/github-backup-utils/version') if Gem::Version.new(new_version) < current_version raise "New version should be newer than #{current_version}" end - File.open("#{path}.new", 'w') do |f| - f.puts new_version - end + File.open("#{path}.new", 'w') { |f| f.puts new_version } File.rename("#{path}.new", path) end @@ -419,8 +417,7 @@ if $PROGRAM_NAME == __FILE__ puts 'Released!' rescue RuntimeError => e - clean_up version - $stderr.puts e + $stderr.puts "Error: #{e}" exit 1 end end From 25787cce0e23b3374fd57bfc9962c417da834961 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Sep 2017 16:58:17 +0100 Subject: [PATCH 0297/2421] Improve wording of output --- script/release | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/release b/script/release index 8c714e641..3c62b0584 100755 --- a/script/release +++ b/script/release @@ -381,14 +381,14 @@ if $PROGRAM_NAME == __FILE__ release_body += "\n* #{c}" end - puts 'Creating and publishing the release branch...' + puts 'Pushing release branch and creating release PR...' push_release_branch version res = create_release_pr(version, "#{release_body}\n\n/cc github/backup-utils") puts 'Merging release PR...' res = merge_pr res['number'], res['head']['sha'], version - puts 'Tagging and publishing the release...' + puts 'Tagging and publishing release...' tag "v#{version}", res['sha'] puts 'Creating release...' From 03a1cb2367ddb87171a38195b917cbf74b299fb6 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Sep 2017 10:54:13 +0100 Subject: [PATCH 0298/2421] Automatically update stable branch Only warn if the update and push fail as this can easily be rectified manually if need be. --- script/release | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/script/release b/script/release index 3c62b0584..7a6e7d532 100755 --- a/script/release +++ b/script/release @@ -216,6 +216,16 @@ def push_release_branch(version) end end +def update_stable_branch + `git checkout --quiet stable` + unless (out = `git merge --quiet --ff-only origin/master`) + warn "Merging master into stable failed:\n\n#{out}" + end + unless (out = `git push --quiet origin stable`) + warn "Failed pushing the stable branch:\n\n#{out}" + end +end + def create_release_pr(version, release_body) body = { 'title': "Bump version: #{version}", @@ -415,6 +425,9 @@ if $PROGRAM_NAME == __FILE__ puts 'Cleaning up...' clean_up version + puts 'Updating stable branch...' + update_stable_branch + puts 'Released!' rescue RuntimeError => e $stderr.puts "Error: #{e}" From 6cb7a7ea41c61d97241ad76e26d538162e8ff487 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Sep 2017 16:31:01 +0100 Subject: [PATCH 0299/2421] Use PR summary as-is --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index 7a6e7d532..1bac689d3 100755 --- a/script/release +++ b/script/release @@ -126,7 +126,7 @@ def beautify_changes(changes) next unless chg =~ /#(\d+)/ begin issue = issue_from Regexp.last_match(1) - out << "#{issue['title'].capitalize} ##{Regexp.last_match(1)}" if bug_or_feature?(issue) + out << "#{issue['title']} ##{Regexp.last_match(1)}" if bug_or_feature?(issue) rescue => e warn "Warning: #{e.message}" end From c576cf01a713aee07cfed2ee22f29285a2bbe3dc Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Sep 2017 09:31:20 -0700 Subject: [PATCH 0300/2421] Bump version: 2.11.0 [ci skip] --- debian/changelog | 9 +++++++++ share/github-backup-utils/version | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 144d736a3..7ab79eb1a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +github-backup-utils (2.11.0) UNRELEASED; urgency=medium + + * Use calculated routes when backing up storage data from a cluster #318 + * Add SSH multiplexing support #321 + * Optimise route generation and finalisation during cluster restores #322 + * Prefer the SSH port specified on the command line #324 + + -- Colin Seymour Wed, 13 Sep 2017 16:31:20 +0000 + github-backup-utils (2.10.0) UNRELEASED; urgency=medium * Include the user data directory in the benchmark name #311 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 10c2c0c3d..46b81d815 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.10.0 +2.11.0 From 8598874a53354711cbaae48a7a4fb4ec43865f58 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Sep 2017 09:38:27 -0700 Subject: [PATCH 0301/2421] Remove unrelated changes --- .ruby-version | 1 - script/release | 436 ------------------------------------------------- 2 files changed, 437 deletions(-) delete mode 100644 .ruby-version delete mode 100755 script/release diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 197c4d5c2..000000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.4.0 diff --git a/script/release b/script/release deleted file mode 100755 index 1bac689d3..000000000 --- a/script/release +++ /dev/null @@ -1,436 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -#/ Usage: GH_RELEASE_TOKEN=your-amazing-secure-token release [--dry-run] -#/ -#/ Publish a backup-utils release: -#/ * Updates the package changelog -#/ * Bumps the backup-utils version if required -#/ * Creates the release pull request -#/ * Merges the release pull request -#/ * Creates the release draft -#/ * Tags the release -#/ * Builds the release assets and uploads them -#/ -#/ Notes: -#/ * Needs GH_RELEASE_TOKEN available in the environment. -#/ * Export GH_OWNER, GH_AUTHOR and GH_REPO if you want to tweak the build -#/ changelog or use a different owner/repo -#/ * Only pull requests labeled with bug, feature or enhancement will show up in the -#/ release page and the changelog. -#/ -require 'json' -require 'net/http' -require 'time' -require 'erb' -require 'English' - -API_HOST = ENV['GH_HOST'] || 'api.github.com' -API_PORT = 443 -GH_REPO = ENV['GH_REPO'] || 'backup-utils' -GH_OWNER = ENV['GH_OWNER'] || 'github' -GH_AUTHOR = ENV['GH_AUTHOR'] || 'Sergio Rubio ' -DEB_PKG_NAME = 'github-backup-utils' - -CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium - -<%- changes.each do |ch| -%> - * <%= ch.strip.chomp %> -<% end -%> - - -- <%= GH_AUTHOR %> <%= Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S %z") %> - -''' - -# Override Kernel.warn -def warn(msg) - Kernel.warn msg unless @no_warn -end - -def client(host = API_HOST, port = API_PORT) - @http ||= begin - c = Net::HTTP.new(host, port) - c.use_ssl = true - c - end -end - -def get(path) - req = Net::HTTP::Get.new(path) - req['Authorization'] = "token #{release_token}" - client.request(req) -end - -def post(path, body) - req = Net::HTTP::Post.new(path) - req['Authorization'] = "token #{release_token}" - req.body = body - client.request(req) -end - -def post_file(path, body) - req = Net::HTTP::Post.new(path) - req['Authorization'] = "token #{release_token}" - req['Content-Type'] = path.match?(/.*\.tar\.gz$/) ? 'application/tar+gzip' : 'application/vnd.debian.binary-package' - req.body = body - client.request(req) -end - -def put(path, body) - req = Net::HTTP::Put.new(path) - req['Authorization'] = "token #{release_token}" - req.body = body - client.request(req) -end - -def patch(path, body) - req = Net::HTTP::Patch.new(path) - req['Authorization'] = "token #{release_token}" - req.body = body - client.request(req) -end - -def release_token - token = ENV['GH_RELEASE_TOKEN'] - raise 'GH_RELEASE_TOKEN environment variable not set' if token.nil? - - token -end - -# Create a lightweight tag -def tag(name, sha) - body = { - "ref": "refs/tags/#{name}", - "sha": sha - }.to_json - res = post("/repos/#{GH_OWNER}/#{GH_REPO}/git/refs", body) - - raise "Creating tag ref failed (#{res.code})" unless res.is_a? Net::HTTPSuccess -end - -def bug_or_feature?(issue_hash) - return true if issue_hash['labels'].find { |label| ['bug', 'feature', 'enhancement'].include?(label['name']) } - false -end - -def issue_from(issue) - res = get("/repos/#{GH_OWNER}/#{GH_REPO}/issues/#{issue}") - raise "Issue ##{issue} not found in #{GH_OWNER}/#{GH_REPO}" unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -def beautify_changes(changes) - out = [] - changes.each do |chg| - next unless chg =~ /#(\d+)/ - begin - issue = issue_from Regexp.last_match(1) - out << "#{issue['title']} ##{Regexp.last_match(1)}" if bug_or_feature?(issue) - rescue => e - warn "Warning: #{e.message}" - end - end - - out -end - -def changelog - changes = `git log --pretty=oneline origin/stable...origin/master --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) - raise 'Building the changelog failed' if $CHILD_STATUS != 0 - - changes -end - -def build_changelog(changes, package_name, package_version) - ERB.new(CHANGELOG_TMPL, nil, '-').result(binding) -end - -def update_changelog(changes, name, version, path = 'debian/changelog') - raise 'debian/changelog not found' unless File.exist?(path) - File.open("#{path}.new", 'w') do |f| - f.puts build_changelog changes, name, version - f.puts(File.read(path)) - end - File.rename("#{path}.new", path) -end - -def create_release(tag_name, branch, rel_name, rel_body, draft = true) - body = { - 'tag_name': tag_name, - 'target_commitish': branch, - 'name': rel_name, - 'body': rel_body, - 'draft': draft, - 'prerelease': false - }.to_json - res = post("/repos/#{GH_OWNER}/#{GH_REPO}/releases", body) - - raise "Failed to create release (#{res.code})" unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -def publish_release(release_id) - body = { - 'draft': false - }.to_json - res = patch("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}", body) - - raise "Failed to update release (#{res.code})" unless res.is_a? Net::HTTPSuccess -end - -def list_releases - res = get("/repos/#{GH_OWNER}/#{GH_REPO}/releases") - raise 'Failed to retrieve releases' unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -def release_available?(tag_name) - return true if list_releases.find { |r| r['tag_name'] == tag_name } - - false -end - -def bump_version(new_version, path = 'share/github-backup-utils/version') - current_version = Gem::Version.new(File.read(path).strip.chomp) - if Gem::Version.new(new_version) < current_version - raise "New version should be newer than #{current_version}" - end - File.open("#{path}.new", 'w') { |f| f.puts new_version } - File.rename("#{path}.new", path) -end - -def push_release_branch(version) - unless (out = `git checkout --quiet -b release-#{version}`) - raise "Creating release branch failed:\n\n#{out}" - end - - unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version`) - raise "Error commiting changelog and version:\n\n#{out}" - end - - unless (out = `git push --quiet origin release-#{version}`) - raise "Failed pushing the release branch:\n\n#{out}" - end -end - -def update_stable_branch - `git checkout --quiet stable` - unless (out = `git merge --quiet --ff-only origin/master`) - warn "Merging master into stable failed:\n\n#{out}" - end - unless (out = `git push --quiet origin stable`) - warn "Failed pushing the stable branch:\n\n#{out}" - end -end - -def create_release_pr(version, release_body) - body = { - 'title': "Bump version: #{version}", - 'body': release_body, - 'head': "release-#{version}", - 'base': 'master' - }.to_json - res = post("/repos/#{GH_OWNER}/#{GH_REPO}/pulls", body) - raise "Creating release PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -def merge_pr(number, sha, version) - body = { - 'commit_title': "Merge pull request ##{number} from github/release-#{version}", - 'commit_message': "Bump version: #{version}", - 'sha': sha, - 'merge_method': 'merge' - }.to_json - pr_mergeable? number - res = put("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}/merge", body) - raise "Merging PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -class RetryError < StandardError -end - -def pr_mergeable?(number) - begin - retries ||= 5 - res = get("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}") - raise RetryError if JSON.parse(res.body)['mergeable'].nil? - mergeable = JSON.parse(res.body)['mergeable'] - rescue RetryError - sleep 1 - retry unless (retries -= 1).zero? - raise 'PR is unmergable.' - end - - mergeable || false -end - -def can_auth? - !ENV['GH_RELEASE_TOKEN'].nil? -end - -def repo_exists? - res = get("/repos/#{GH_OWNER}/#{GH_REPO}") - res.is_a? Net::HTTPSuccess -end - -def can_build_deb? - system('which debuild > /dev/null 2>&1') -end - -def package_tarball - unless (out = `script/package-tarball 2>&1`) - raise "Failed to package tarball:\n\n#{out}" - end - out -end - -def package_deb - unless (out = `DEB_BUILD_OPTIONS=nocheck script/package-deb 2>&1`) - raise "Failed to package Debian package:\n\n#{out}" - end - out -end - -def attach_assets_to_release(upload_url, release_id, files) - @http = nil - client(URI(upload_url.gsub(/{.*}/, '')).host) - begin - files.each do |file| - raw_file = File.open(file).read - res = post_file("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}/assets?name=#{File.basename(file)}", raw_file) - raise "Failed to attach #{file} to release (#{res.code})" unless res.is_a? Net::HTTPSuccess - end - rescue => e - raise e - end - @http = nil -end - -def clean_up(version) - `git checkout --quiet master` - `git fetch --quiet origin --prune` - `git pull --quiet origin master --prune` - `git branch --quiet -D release-#{version} >/dev/null 2>&1` - `git push --quiet origin :release-#{version} >/dev/null 2>&1` - `git branch --quiet -D tmp-packging >/dev/null 2>&1` -end - -#### All the action starts #### -if $PROGRAM_NAME == __FILE__ - begin - args = ARGV.dup - dry_run = false - if args.include?('--dry-run') - dry_run = true - args.delete '--dry-run' - end - - if args.include?('--no-warn') - @no_warn = true - args.delete '--no-warn' - end - - raise 'Usage: release [--dry-run] ' if args.empty? - - begin - version = Gem::Version.new(args[0]) - rescue ArgumentError - raise "Error parsing version #{args[0]}" - end - - raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" unless repo_exists? - - raise 'Unable to build Debian pkg: "debuild" not found.' unless can_build_deb? - - release_changes = [] - release_changes = beautify_changes changelog if can_auth? - release_a = false - release_a = release_available? "v#{version}" - - if dry_run - puts "Existing release?: #{release_a}" - puts "New version: #{version}" - puts "Owner: #{GH_OWNER}" - puts "Repo: #{GH_REPO}" - puts "Author: #{GH_AUTHOR}" - puts "Token: #{ENV['GH_RELEASE_TOKEN'] && 'set' || 'unset'}" - puts 'Changelog:' - if release_changes.empty? - puts ' => No new bug fixes, enhancements or features.' - else - release_changes.each { |c| puts " * #{c}" } - end - exit - end - - raise "Release #{version} already exists." if release_a - - `git fetch --quiet origin --prune` - branches = `git branch --all | grep release-#{version}$` - unless branches.empty? - out = "Release branch release-#{version} already exists. " - out += 'Branches found:' - branches.each_line { |l| out += "\n* #{l.strip.chomp}" } - raise out - end - - puts "Bumping version to #{version}..." - bump_version version - - puts 'Updating changelog...' - update_changelog release_changes, DEB_PKG_NAME, version - release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}" - release_changes.each do |c| - release_body += "\n* #{c}" - end - - puts 'Pushing release branch and creating release PR...' - push_release_branch version - res = create_release_pr(version, "#{release_body}\n\n/cc github/backup-utils") - - puts 'Merging release PR...' - res = merge_pr res['number'], res['head']['sha'], version - - puts 'Tagging and publishing release...' - tag "v#{version}", res['sha'] - - puts 'Creating release...' - release_title = "GitHub Enterprise Backup Utilities v#{version}" - res = create_release "v#{version}", 'master', release_title, release_body, true - - # Tidy up before building tarball and deb pkg - clean_up version - - puts 'Building release tarball...' - package_tarball - - puts 'Building Debian pkg...' - package_deb - - puts 'Attaching Debian pkg and tarball to release...' - base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) - attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] - attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_amd64.deb"] - - puts 'Publishing release...' - publish_release res['id'] - - puts 'Cleaning up...' - clean_up version - - puts 'Updating stable branch...' - update_stable_branch - - puts 'Released!' - rescue RuntimeError => e - $stderr.puts "Error: #{e}" - exit 1 - end -end From 4c688467118b038d38230d91c937f93719f179dd Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 14 Sep 2017 09:15:58 +0100 Subject: [PATCH 0302/2421] Revert "Remove unrelated changes" This reverts commit 8598874a53354711cbaae48a7a4fb4ec43865f58. --- .ruby-version | 1 + script/release | 436 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 437 insertions(+) create mode 100644 .ruby-version create mode 100755 script/release diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 000000000..197c4d5c2 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.4.0 diff --git a/script/release b/script/release new file mode 100755 index 000000000..1bac689d3 --- /dev/null +++ b/script/release @@ -0,0 +1,436 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +#/ Usage: GH_RELEASE_TOKEN=your-amazing-secure-token release [--dry-run] +#/ +#/ Publish a backup-utils release: +#/ * Updates the package changelog +#/ * Bumps the backup-utils version if required +#/ * Creates the release pull request +#/ * Merges the release pull request +#/ * Creates the release draft +#/ * Tags the release +#/ * Builds the release assets and uploads them +#/ +#/ Notes: +#/ * Needs GH_RELEASE_TOKEN available in the environment. +#/ * Export GH_OWNER, GH_AUTHOR and GH_REPO if you want to tweak the build +#/ changelog or use a different owner/repo +#/ * Only pull requests labeled with bug, feature or enhancement will show up in the +#/ release page and the changelog. +#/ +require 'json' +require 'net/http' +require 'time' +require 'erb' +require 'English' + +API_HOST = ENV['GH_HOST'] || 'api.github.com' +API_PORT = 443 +GH_REPO = ENV['GH_REPO'] || 'backup-utils' +GH_OWNER = ENV['GH_OWNER'] || 'github' +GH_AUTHOR = ENV['GH_AUTHOR'] || 'Sergio Rubio ' +DEB_PKG_NAME = 'github-backup-utils' + +CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium + +<%- changes.each do |ch| -%> + * <%= ch.strip.chomp %> +<% end -%> + + -- <%= GH_AUTHOR %> <%= Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S %z") %> + +''' + +# Override Kernel.warn +def warn(msg) + Kernel.warn msg unless @no_warn +end + +def client(host = API_HOST, port = API_PORT) + @http ||= begin + c = Net::HTTP.new(host, port) + c.use_ssl = true + c + end +end + +def get(path) + req = Net::HTTP::Get.new(path) + req['Authorization'] = "token #{release_token}" + client.request(req) +end + +def post(path, body) + req = Net::HTTP::Post.new(path) + req['Authorization'] = "token #{release_token}" + req.body = body + client.request(req) +end + +def post_file(path, body) + req = Net::HTTP::Post.new(path) + req['Authorization'] = "token #{release_token}" + req['Content-Type'] = path.match?(/.*\.tar\.gz$/) ? 'application/tar+gzip' : 'application/vnd.debian.binary-package' + req.body = body + client.request(req) +end + +def put(path, body) + req = Net::HTTP::Put.new(path) + req['Authorization'] = "token #{release_token}" + req.body = body + client.request(req) +end + +def patch(path, body) + req = Net::HTTP::Patch.new(path) + req['Authorization'] = "token #{release_token}" + req.body = body + client.request(req) +end + +def release_token + token = ENV['GH_RELEASE_TOKEN'] + raise 'GH_RELEASE_TOKEN environment variable not set' if token.nil? + + token +end + +# Create a lightweight tag +def tag(name, sha) + body = { + "ref": "refs/tags/#{name}", + "sha": sha + }.to_json + res = post("/repos/#{GH_OWNER}/#{GH_REPO}/git/refs", body) + + raise "Creating tag ref failed (#{res.code})" unless res.is_a? Net::HTTPSuccess +end + +def bug_or_feature?(issue_hash) + return true if issue_hash['labels'].find { |label| ['bug', 'feature', 'enhancement'].include?(label['name']) } + false +end + +def issue_from(issue) + res = get("/repos/#{GH_OWNER}/#{GH_REPO}/issues/#{issue}") + raise "Issue ##{issue} not found in #{GH_OWNER}/#{GH_REPO}" unless res.is_a? Net::HTTPSuccess + + JSON.parse(res.body) +end + +def beautify_changes(changes) + out = [] + changes.each do |chg| + next unless chg =~ /#(\d+)/ + begin + issue = issue_from Regexp.last_match(1) + out << "#{issue['title']} ##{Regexp.last_match(1)}" if bug_or_feature?(issue) + rescue => e + warn "Warning: #{e.message}" + end + end + + out +end + +def changelog + changes = `git log --pretty=oneline origin/stable...origin/master --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) + raise 'Building the changelog failed' if $CHILD_STATUS != 0 + + changes +end + +def build_changelog(changes, package_name, package_version) + ERB.new(CHANGELOG_TMPL, nil, '-').result(binding) +end + +def update_changelog(changes, name, version, path = 'debian/changelog') + raise 'debian/changelog not found' unless File.exist?(path) + File.open("#{path}.new", 'w') do |f| + f.puts build_changelog changes, name, version + f.puts(File.read(path)) + end + File.rename("#{path}.new", path) +end + +def create_release(tag_name, branch, rel_name, rel_body, draft = true) + body = { + 'tag_name': tag_name, + 'target_commitish': branch, + 'name': rel_name, + 'body': rel_body, + 'draft': draft, + 'prerelease': false + }.to_json + res = post("/repos/#{GH_OWNER}/#{GH_REPO}/releases", body) + + raise "Failed to create release (#{res.code})" unless res.is_a? Net::HTTPSuccess + + JSON.parse(res.body) +end + +def publish_release(release_id) + body = { + 'draft': false + }.to_json + res = patch("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}", body) + + raise "Failed to update release (#{res.code})" unless res.is_a? Net::HTTPSuccess +end + +def list_releases + res = get("/repos/#{GH_OWNER}/#{GH_REPO}/releases") + raise 'Failed to retrieve releases' unless res.is_a? Net::HTTPSuccess + + JSON.parse(res.body) +end + +def release_available?(tag_name) + return true if list_releases.find { |r| r['tag_name'] == tag_name } + + false +end + +def bump_version(new_version, path = 'share/github-backup-utils/version') + current_version = Gem::Version.new(File.read(path).strip.chomp) + if Gem::Version.new(new_version) < current_version + raise "New version should be newer than #{current_version}" + end + File.open("#{path}.new", 'w') { |f| f.puts new_version } + File.rename("#{path}.new", path) +end + +def push_release_branch(version) + unless (out = `git checkout --quiet -b release-#{version}`) + raise "Creating release branch failed:\n\n#{out}" + end + + unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version`) + raise "Error commiting changelog and version:\n\n#{out}" + end + + unless (out = `git push --quiet origin release-#{version}`) + raise "Failed pushing the release branch:\n\n#{out}" + end +end + +def update_stable_branch + `git checkout --quiet stable` + unless (out = `git merge --quiet --ff-only origin/master`) + warn "Merging master into stable failed:\n\n#{out}" + end + unless (out = `git push --quiet origin stable`) + warn "Failed pushing the stable branch:\n\n#{out}" + end +end + +def create_release_pr(version, release_body) + body = { + 'title': "Bump version: #{version}", + 'body': release_body, + 'head': "release-#{version}", + 'base': 'master' + }.to_json + res = post("/repos/#{GH_OWNER}/#{GH_REPO}/pulls", body) + raise "Creating release PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess + + JSON.parse(res.body) +end + +def merge_pr(number, sha, version) + body = { + 'commit_title': "Merge pull request ##{number} from github/release-#{version}", + 'commit_message': "Bump version: #{version}", + 'sha': sha, + 'merge_method': 'merge' + }.to_json + pr_mergeable? number + res = put("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}/merge", body) + raise "Merging PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess + + JSON.parse(res.body) +end + +class RetryError < StandardError +end + +def pr_mergeable?(number) + begin + retries ||= 5 + res = get("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}") + raise RetryError if JSON.parse(res.body)['mergeable'].nil? + mergeable = JSON.parse(res.body)['mergeable'] + rescue RetryError + sleep 1 + retry unless (retries -= 1).zero? + raise 'PR is unmergable.' + end + + mergeable || false +end + +def can_auth? + !ENV['GH_RELEASE_TOKEN'].nil? +end + +def repo_exists? + res = get("/repos/#{GH_OWNER}/#{GH_REPO}") + res.is_a? Net::HTTPSuccess +end + +def can_build_deb? + system('which debuild > /dev/null 2>&1') +end + +def package_tarball + unless (out = `script/package-tarball 2>&1`) + raise "Failed to package tarball:\n\n#{out}" + end + out +end + +def package_deb + unless (out = `DEB_BUILD_OPTIONS=nocheck script/package-deb 2>&1`) + raise "Failed to package Debian package:\n\n#{out}" + end + out +end + +def attach_assets_to_release(upload_url, release_id, files) + @http = nil + client(URI(upload_url.gsub(/{.*}/, '')).host) + begin + files.each do |file| + raw_file = File.open(file).read + res = post_file("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}/assets?name=#{File.basename(file)}", raw_file) + raise "Failed to attach #{file} to release (#{res.code})" unless res.is_a? Net::HTTPSuccess + end + rescue => e + raise e + end + @http = nil +end + +def clean_up(version) + `git checkout --quiet master` + `git fetch --quiet origin --prune` + `git pull --quiet origin master --prune` + `git branch --quiet -D release-#{version} >/dev/null 2>&1` + `git push --quiet origin :release-#{version} >/dev/null 2>&1` + `git branch --quiet -D tmp-packging >/dev/null 2>&1` +end + +#### All the action starts #### +if $PROGRAM_NAME == __FILE__ + begin + args = ARGV.dup + dry_run = false + if args.include?('--dry-run') + dry_run = true + args.delete '--dry-run' + end + + if args.include?('--no-warn') + @no_warn = true + args.delete '--no-warn' + end + + raise 'Usage: release [--dry-run] ' if args.empty? + + begin + version = Gem::Version.new(args[0]) + rescue ArgumentError + raise "Error parsing version #{args[0]}" + end + + raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" unless repo_exists? + + raise 'Unable to build Debian pkg: "debuild" not found.' unless can_build_deb? + + release_changes = [] + release_changes = beautify_changes changelog if can_auth? + release_a = false + release_a = release_available? "v#{version}" + + if dry_run + puts "Existing release?: #{release_a}" + puts "New version: #{version}" + puts "Owner: #{GH_OWNER}" + puts "Repo: #{GH_REPO}" + puts "Author: #{GH_AUTHOR}" + puts "Token: #{ENV['GH_RELEASE_TOKEN'] && 'set' || 'unset'}" + puts 'Changelog:' + if release_changes.empty? + puts ' => No new bug fixes, enhancements or features.' + else + release_changes.each { |c| puts " * #{c}" } + end + exit + end + + raise "Release #{version} already exists." if release_a + + `git fetch --quiet origin --prune` + branches = `git branch --all | grep release-#{version}$` + unless branches.empty? + out = "Release branch release-#{version} already exists. " + out += 'Branches found:' + branches.each_line { |l| out += "\n* #{l.strip.chomp}" } + raise out + end + + puts "Bumping version to #{version}..." + bump_version version + + puts 'Updating changelog...' + update_changelog release_changes, DEB_PKG_NAME, version + release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}" + release_changes.each do |c| + release_body += "\n* #{c}" + end + + puts 'Pushing release branch and creating release PR...' + push_release_branch version + res = create_release_pr(version, "#{release_body}\n\n/cc github/backup-utils") + + puts 'Merging release PR...' + res = merge_pr res['number'], res['head']['sha'], version + + puts 'Tagging and publishing release...' + tag "v#{version}", res['sha'] + + puts 'Creating release...' + release_title = "GitHub Enterprise Backup Utilities v#{version}" + res = create_release "v#{version}", 'master', release_title, release_body, true + + # Tidy up before building tarball and deb pkg + clean_up version + + puts 'Building release tarball...' + package_tarball + + puts 'Building Debian pkg...' + package_deb + + puts 'Attaching Debian pkg and tarball to release...' + base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) + attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] + attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_amd64.deb"] + + puts 'Publishing release...' + publish_release res['id'] + + puts 'Cleaning up...' + clean_up version + + puts 'Updating stable branch...' + update_stable_branch + + puts 'Released!' + rescue RuntimeError => e + $stderr.puts "Error: #{e}" + exit 1 + end +end From 20d571b68f7e5b0839142653bd5f725c099aac20 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 14 Sep 2017 09:16:55 +0100 Subject: [PATCH 0303/2421] Add missing @ --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index 1bac689d3..e99de0390 100755 --- a/script/release +++ b/script/release @@ -393,7 +393,7 @@ if $PROGRAM_NAME == __FILE__ puts 'Pushing release branch and creating release PR...' push_release_branch version - res = create_release_pr(version, "#{release_body}\n\n/cc github/backup-utils") + res = create_release_pr(version, "#{release_body}\n\n/cc @github/backup-utils") puts 'Merging release PR...' res = merge_pr res['number'], res['head']['sha'], version From 65e6c70219390e14eb7c11c3ae9ac259cf6ab6d1 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 14 Sep 2017 09:30:13 +0100 Subject: [PATCH 0304/2421] Update releasing docs --- RELEASING.md | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index a1767ba24..4a8ce86b2 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,14 +1,28 @@ # Making a backup-utils release - 1. Install the debian devscripts package: - `sudo apt-get install devscripts` - 2. Add a new version and release notes to the `debian/changelog` file: - `dch --newversion 2.6.0 --release-heuristic log` - You can use `make pending-prs` to craft the release notes. - 3. Rev the `share/github-backup-utils/version` file. - 4. Tag the release: `git tag v2.0.2` - 5. Build that tarball package: `make dist` - 6. Build the deb package: `make deb`. All the tests should pass. - 7. Draft a new release at https://github.com/github/backup-utils/releases, including the release notes and attaching the tarball and deb packages. - The dist tarball you should upload has the git revision in the file name, i.e. something like `github-backup-utils-v2.5.0.tar.gz` - 8. Push the head of the release to the 'stable' branch. +## Automatic Process from chatops (internal to GitHub only) + +1. `.ghe backup-utils-release 2.12.0` + +## Automatic Process from CLI + +1. Install the Debian `devscripts` package: + `sudo apt-get install devscripts` +2. Run `script/release 2.12.0` + +## Manual Process + +In the event you can't perform the automatic process, or a problem is encountered with the automatic process, these are the manual steps you need to perform for a release. + +1. Install the Debian `devscripts` package: + `sudo apt-get install devscripts` +2. Add a new version and release notes to the `debian/changelog` file: + `dch --newversion 2.12.0 --release-heuristic log` + You can use `make pending-prs` to craft the release notes. +3. Rev the `share/github-backup-utils/version` file. +4. Tag the release: `git tag v2.12.0` +5. Build that tarball package: `make dist` +6. Build the deb package: `make deb`. All the tests should pass. +7. Draft a new release at https://github.com/github/backup-utils/releases, including the release notes and attaching the tarball and deb packages. + The dist tarball you should upload has the revision in the file name, i.e. something like `github-backup-utils-v2.12.0.tar.gz` +8. Push the head of the release to the 'stable' branch. From 40c424ac8dbd905588df79b46892bade130c1194 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 14 Sep 2017 12:25:06 +0100 Subject: [PATCH 0305/2421] Determine if audit log migration needs to take place as part of backup --- share/github-backup-utils/ghe-backup-es-audit-log | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index d3e84b838..f0fb276b5 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -31,6 +31,13 @@ if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:$es_port/_cat/indices/audit_ exit 1 fi +# Determine if the audit log migration has occurred or is needed. +if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test -f /usr/local/share/enterprise/run-audit-log-transitions.sh' | ghe-ssh "$host" /bin/bash; then + if echo 'set -o pipefail; echo n | /usr/local/share/enterprise/run-audit-log-transitions.sh > /dev/null 2>&1 && touch /data/user/common/es-scan-complete' | ghe-ssh "$host" /bin/bash; then + touch $GHE_SNAPSHOT_DIR/es-scan-complete + fi +fi + current_index=audit_log-$(ghe-ssh "$host" 'date +"%Y-%m"') for index in $indices; do From 29f7ebde43933f684e699b0b7a962b0ec6d98fcf Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 14 Sep 2017 12:42:14 +0100 Subject: [PATCH 0306/2421] Don't set default value for GH_AUTHOR --- script/release | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/release b/script/release index e99de0390..d7b379539 100755 --- a/script/release +++ b/script/release @@ -29,7 +29,7 @@ API_HOST = ENV['GH_HOST'] || 'api.github.com' API_PORT = 443 GH_REPO = ENV['GH_REPO'] || 'backup-utils' GH_OWNER = ENV['GH_OWNER'] || 'github' -GH_AUTHOR = ENV['GH_AUTHOR'] || 'Sergio Rubio ' +GH_AUTHOR = ENV['GH_AUTHOR'] DEB_PKG_NAME = 'github-backup-utils' CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium @@ -347,7 +347,7 @@ if $PROGRAM_NAME == __FILE__ raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" unless repo_exists? - raise 'Unable to build Debian pkg: "debuild" not found.' unless can_build_deb? + raise 'GH_AUTHOR environment variable is not set' if GH_AUTHOR.nil? release_changes = [] release_changes = beautify_changes changelog if can_auth? From 58c6c6f18d3eaf24995038a720423ff640204113 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 14 Sep 2017 12:42:29 +0100 Subject: [PATCH 0307/2421] Allow dry-run on non-Linux hosts --- script/release | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/release b/script/release index d7b379539..cb4f9deba 100755 --- a/script/release +++ b/script/release @@ -370,6 +370,8 @@ if $PROGRAM_NAME == __FILE__ exit end + raise 'Unable to build Debian pkg: "debuild" not found.' unless can_build_deb? + raise "Release #{version} already exists." if release_a `git fetch --quiet origin --prune` From 841eeff685dc2bbd3149471502510a5fd3885e09 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 14 Sep 2017 12:43:27 +0100 Subject: [PATCH 0308/2421] Demo required env vars --- RELEASING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index 4a8ce86b2..c6794468a 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -8,7 +8,7 @@ 1. Install the Debian `devscripts` package: `sudo apt-get install devscripts` -2. Run `script/release 2.12.0` +2. Run `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.12.0` ## Manual Process From 81f9dcd1020d0b131978b4e4ff1e485379c2ac80 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 14 Sep 2017 12:48:32 +0100 Subject: [PATCH 0309/2421] Update comments to match behaviour --- script/release | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/script/release b/script/release index cb4f9deba..a6784745f 100755 --- a/script/release +++ b/script/release @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -#/ Usage: GH_RELEASE_TOKEN=your-amazing-secure-token release [--dry-run] +#/ Usage: release [--dry-run] #/ #/ Publish a backup-utils release: #/ * Updates the package changelog @@ -13,9 +13,8 @@ #/ * Builds the release assets and uploads them #/ #/ Notes: -#/ * Needs GH_RELEASE_TOKEN available in the environment. -#/ * Export GH_OWNER, GH_AUTHOR and GH_REPO if you want to tweak the build -#/ changelog or use a different owner/repo +#/ * Needs GH_RELEASE_TOKEN and GH_AUTHOR set in the environment. +#/ * Export GH_OWNER and GH_REPO if you want to use a different owner/repo #/ * Only pull requests labeled with bug, feature or enhancement will show up in the #/ release page and the changelog. #/ From 10a393e913e19da27b7a8cd44166251ad9c78b96 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 15 Sep 2017 12:57:47 +0900 Subject: [PATCH 0310/2421] Use md5sum for greater compatibility --- share/github-backup-utils/ghe-ssh | 2 +- share/github-backup-utils/ghe-ssh-config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 28a002a39..c5df56d88 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -58,7 +58,7 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then fi if [ -z "$GHE_DISABLE_SSH_MUX" ]; then - controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | sha256sum | cut -c 1-8)" + controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | md5sum | cut -c 1-8)" opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 [ -S $controlpath ] || ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index fdccc20ba..1d195d90d 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -25,7 +25,7 @@ proxy_user="${proxy_host%@*}" opts="$GHE_EXTRA_SSH_OPTS" -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | sha256sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | md5sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" for host in $hosts; do cat < Date: Fri, 15 Sep 2017 13:37:59 +0900 Subject: [PATCH 0311/2421] Use git to generate the hash Credit to @jatoben for the idea! --- share/github-backup-utils/ghe-ssh | 2 +- share/github-backup-utils/ghe-ssh-config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index c5df56d88..f3c0fc2d5 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -58,7 +58,7 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then fi if [ -z "$GHE_DISABLE_SSH_MUX" ]; then - controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | md5sum | cut -c 1-8)" + controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | git hash-object --stdin --literally | cut -c 1-8)" opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 [ -S $controlpath ] || ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 1d195d90d..56670ff23 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -25,7 +25,7 @@ proxy_user="${proxy_host%@*}" opts="$GHE_EXTRA_SSH_OPTS" -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | md5sum | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | git hash-object --stdin --literally | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" for host in $hosts; do cat < Date: Wed, 20 Sep 2017 20:33:04 +1000 Subject: [PATCH 0312/2421] The --literally isn't required, as it defaults to blob type --- share/github-backup-utils/ghe-ssh | 2 +- share/github-backup-utils/ghe-ssh-config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index f3c0fc2d5..59cf3587a 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -58,7 +58,7 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then fi if [ -z "$GHE_DISABLE_SSH_MUX" ]; then - controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | git hash-object --stdin --literally | cut -c 1-8)" + controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | git hash-object --stdin | cut -c 1-8)" opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 [ -S $controlpath ] || ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 56670ff23..16872a259 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -25,7 +25,7 @@ proxy_user="${proxy_host%@*}" opts="$GHE_EXTRA_SSH_OPTS" -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | git hash-object --stdin --literally | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | git hash-object --stdin | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" for host in $hosts; do cat < Date: Thu, 28 Sep 2017 15:49:27 +0100 Subject: [PATCH 0313/2421] Ignore errors from ps --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index a2296b8d3..6059a36f3 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -69,7 +69,7 @@ if [ -f ../in-progress ]; then progress=$(cat ../in-progress) snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) - if ! ps -p $pid -o command= | grep ghe-backup; then + if ! ps -p $pid -o command= 2>/dev/null | grep ghe-backup; then # We can safely remove in-progress, ghe-prune-snapshots # will clean up the failed backup. unlink ../in-progress From fc2bdb4fec4cf20687f27a68e29f2265cd148118 Mon Sep 17 00:00:00 2001 From: Mike Griffin Date: Tue, 3 Oct 2017 10:36:42 +0100 Subject: [PATCH 0314/2421] Removes -o from the multiple backup check --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 6059a36f3..a8fed50f4 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -69,7 +69,7 @@ if [ -f ../in-progress ]; then progress=$(cat ../in-progress) snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) - if ! ps -p $pid -o command= 2>/dev/null | grep ghe-backup; then + if ! ps -p $pid | grep ghe-backup; then # We can safely remove in-progress, ghe-prune-snapshots # will clean up the failed backup. unlink ../in-progress From 84c352113e2820c8b41a28c98f08f426bd959a73 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 5 Oct 2017 07:47:56 -0700 Subject: [PATCH 0315/2421] Bump version: 2.11.1 [ci skip] --- debian/changelog | 10 ++++++++++ share/github-backup-utils/version | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 7ab79eb1a..e5c39692d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +github-backup-utils (2.11.1) UNRELEASED; urgency=medium + + * Refresh the existing indices when restoring Elasticsearch indices to cluster #328 + * Fix failure to restore 2.9/2.10 backups to 2.11 prevented by incorrect detection of the audit log migration #333 + * Use git to generate short name for SSH multiplex control path #335 + * Remove use of --literally when computing arbitrary shasum #338 + * Remove -o option from ps use #341 + + -- Colin Seymour Thu, 05 Oct 2017 14:47:56 +0000 + github-backup-utils (2.11.0) UNRELEASED; urgency=medium * Use calculated routes when backing up storage data from a cluster #318 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 46b81d815..6ceb272ee 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.11.0 +2.11.1 From a537d7351d2bd84c31a237bca85f416aedbbddba Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 12 Oct 2017 15:12:22 +1100 Subject: [PATCH 0316/2421] Use regex to match the month --- share/github-backup-utils/ghe-backup-es-audit-log | 6 +++--- share/github-backup-utils/ghe-restore-es-audit-log | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 66bd94240..1c56ec343 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -38,16 +38,16 @@ if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test - fi fi -current_index=audit_log-$(ghe-ssh "$host" 'date +"%Y-%m"') +current_index="audit_log(-[0-9]+)?-$(ghe-ssh "$host" 'date +"%Y-%m"')(-[0-9]+)?" for index in $indices; do - if [ -f $GHE_DATA_DIR/current/audit-log/$index.gz -a -f $GHE_DATA_DIR/current/audit-log/$index.gz.complete -a $index \< $current_index ]; then + if [[ -f $GHE_DATA_DIR/current/audit-log/$index.gz && -f $GHE_DATA_DIR/current/audit-log/$index.gz.complete && ! $index =~ $current_index ]]; then # Hard link any older indices that are complete, since these won't change ln $GHE_DATA_DIR/current/audit-log/$index.gz $GHE_SNAPSHOT_DIR/audit-log/$index.gz ln $GHE_DATA_DIR/current/audit-log/$index.gz.complete $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete else ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index.gz - if [ $index \< $current_index ]; then + if [[ ! $index =~ $current_index ]]; then touch $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete fi fi diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 811b270e2..acd8e8a86 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -19,12 +19,13 @@ GHE_HOSTNAME="$1" # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" -last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/audit_log*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1) - indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz) +last_month="audit_log(-[0-9]+)?-$(ghe-ssh "$GHE_HOSTNAME" 'date -d "1 month ago" +"%Y-%m"')(-[0-9]+)?" +current_month="audit_log(-[0-9]+)?-$(ghe-ssh "$GHE_HOSTNAME" 'date +"%Y-%m"')(-[0-9]+)?" + for index in $indices; do - if [ -z "$last_index" ] || ! [ $index \< $last_index ]; then + if ! ghe-ssh "$GHE_HOSTNAME" "curl -f -s -XGET http://localhost:9201/$index" || [[ $index =~ $last_month ]] || [[ $index =~ $current_month ]]; then ghe_verbose "* Restoring $index" gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 fi From eae402cd7a0d1331339ed86b70a93c6ad33d86b3 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 17 Oct 2017 00:09:41 -0700 Subject: [PATCH 0317/2421] Initial Dockerization --- Dockerfile | 16 ++++++++++++++++ share/github-backup-utils/ghe-docker-init | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Dockerfile create mode 100755 share/github-backup-utils/ghe-docker-init diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..910162cdc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM debian:jessie-slim +ARG bkup_version=2.11.1 +RUN DEBIAN_FRONTEND=noninteractive \ + apt-get update && \ + apt-get install -y wget rsync ssh git && \ + apt-get clean && apt-get autoremove -q && \ + rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/* +RUN wget https://github.com/github/backup-utils/releases/download/v${bkup_version}/github-backup-utils_${bkup_version}_amd64.deb +RUN export DEBIAN_FRONTEND=noninteractive && \ + export DEBIAN_PRIORITY=critical && \ + /usr/bin/dpkg -i github-backup-utils_${bkup_version}_amd64.deb && \ + rm github-backup-utils_${bkup_version}_amd64.deb +COPY share/github-backup-utils/ghe-docker-init /usr/share/github-backup-utils/ghe-docker-init +RUN chmod +x /usr/share/github-backup-utils/ghe-docker-init +ENTRYPOINT ["/usr/share/github-backup-utils/ghe-docker-init"] +CMD ["ghe-host-check"] diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init new file mode 100755 index 000000000..51819cfa9 --- /dev/null +++ b/share/github-backup-utils/ghe-docker-init @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +mkdir -p /etc/github-backup-utils + +touch /etc/github-backup-utils/backup.config + +for VAR in `env`; do + if [[ $VAR =~ ^GHE_ ]]; then + backuputils_name=`echo "$VAR" | sed -r "s/GHE_(.*)=.*/\1/g" | tr '[:upper:]' '[:lower:]'` + backuputils_value=`echo "$VAR" | sed -r "s/.*=(.*)/\1/g"` + echo "${backuputils_name}=${backuputils_value}" >> /etc/github-backup-utils/backup.config + fi +done + +exec $@ From 9fedc0f1f5bd3d1617ce4fecdc73a8a0e1bebfd0 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Wed, 18 Oct 2017 16:35:13 -0700 Subject: [PATCH 0318/2421] add quotes around array --- share/github-backup-utils/ghe-docker-init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init index 51819cfa9..59c2604a2 100755 --- a/share/github-backup-utils/ghe-docker-init +++ b/share/github-backup-utils/ghe-docker-init @@ -14,4 +14,4 @@ for VAR in `env`; do fi done -exec $@ +exec "$@" From 018d420141b620c3e8c80483a7344305d657ad95 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 24 Oct 2017 13:59:25 -0700 Subject: [PATCH 0319/2421] Refactor to use stable archive --- .dockerignore | 2 ++ Dockerfile | 35 ++++++++++++++--------- share/github-backup-utils/ghe-docker-init | 12 ++++---- 3 files changed, 30 insertions(+), 19 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..988d907c9 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +* +!share/github-backup-utils/ghe-docker-init diff --git a/Dockerfile b/Dockerfile index 910162cdc..190359659 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,23 @@ FROM debian:jessie-slim -ARG bkup_version=2.11.1 -RUN DEBIAN_FRONTEND=noninteractive \ - apt-get update && \ - apt-get install -y wget rsync ssh git && \ - apt-get clean && apt-get autoremove -q && \ - rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man /tmp/* -RUN wget https://github.com/github/backup-utils/releases/download/v${bkup_version}/github-backup-utils_${bkup_version}_amd64.deb -RUN export DEBIAN_FRONTEND=noninteractive && \ - export DEBIAN_PRIORITY=critical && \ - /usr/bin/dpkg -i github-backup-utils_${bkup_version}_amd64.deb && \ - rm github-backup-utils_${bkup_version}_amd64.deb -COPY share/github-backup-utils/ghe-docker-init /usr/share/github-backup-utils/ghe-docker-init -RUN chmod +x /usr/share/github-backup-utils/ghe-docker-init -ENTRYPOINT ["/usr/share/github-backup-utils/ghe-docker-init"] + +ARG bkup_version +ENV bkup_version stable + +RUN apt-get -q -y update && \ + apt-get install -y --no-install-recommends \ + tar \ + rsync \ + ca-certificates \ + ssh \ + git \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /backup-utils-stable +ADD https://github.com/github/backup-utils/archive/${bkup_version}.tar.gz / +RUN tar xzvf /${bkup_version}.tar.gz --strip-components=1 -C /backup-utils-stable + +COPY share/github-backup-utils/ghe-docker-init /backup-utils-stable/share/github-backup-utils/ghe-docker-init +RUN chmod +x /backup-utils-stable/share/github-backup-utils/ghe-docker-init + +ENTRYPOINT ["/backup-utils-stable/share/github-backup-utils/ghe-docker-init"] CMD ["ghe-host-check"] diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init index 59c2604a2..c0db07b83 100755 --- a/share/github-backup-utils/ghe-docker-init +++ b/share/github-backup-utils/ghe-docker-init @@ -2,16 +2,18 @@ set -e +PATH=$PATH:/backup-utils-stable/bin + mkdir -p /etc/github-backup-utils touch /etc/github-backup-utils/backup.config for VAR in `env`; do - if [[ $VAR =~ ^GHE_ ]]; then - backuputils_name=`echo "$VAR" | sed -r "s/GHE_(.*)=.*/\1/g" | tr '[:upper:]' '[:lower:]'` - backuputils_value=`echo "$VAR" | sed -r "s/.*=(.*)/\1/g"` - echo "${backuputils_name}=${backuputils_value}" >> /etc/github-backup-utils/backup.config - fi + if [[ $VAR =~ ^GHE_ ]]; then + backuputils_name=`echo "$VAR" | sed -r "s/GHE_(.*)=.*/\1/g" | tr '[:upper:]' '[:lower:]'` + backuputils_value=`echo "$VAR" | sed -r "s/.*=(.*)/\1/g"` + echo "${backuputils_name}=${backuputils_value}" >> /etc/github-backup-utils/backup.config + fi done exec "$@" From fb9653491bd1998bb595eaed1270d119244b3ed3 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 24 Oct 2017 14:02:41 -0700 Subject: [PATCH 0320/2421] No need for vaiables, and clean up the tar --- Dockerfile | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 190359659..e779026e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,5 @@ FROM debian:jessie-slim -ARG bkup_version -ENV bkup_version stable - RUN apt-get -q -y update && \ apt-get install -y --no-install-recommends \ tar \ @@ -13,8 +10,9 @@ RUN apt-get -q -y update && \ && rm -rf /var/lib/apt/lists/* WORKDIR /backup-utils-stable -ADD https://github.com/github/backup-utils/archive/${bkup_version}.tar.gz / -RUN tar xzvf /${bkup_version}.tar.gz --strip-components=1 -C /backup-utils-stable +ADD https://github.com/github/backup-utils/archive/stable.tar.gz / +RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils-stable && \ + rm -r /stable.tar.gz COPY share/github-backup-utils/ghe-docker-init /backup-utils-stable/share/github-backup-utils/ghe-docker-init RUN chmod +x /backup-utils-stable/share/github-backup-utils/ghe-docker-init From 5c9bb0492bed7430bd3ea23ca5fd2ce546244ed9 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 24 Oct 2017 17:40:18 -0700 Subject: [PATCH 0321/2421] Simplify path / use stretch base --- Dockerfile | 12 ++++++------ share/github-backup-utils/ghe-docker-init | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index e779026e4..0363e4254 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:jessie-slim +FROM debian:stretch-slim RUN apt-get -q -y update && \ apt-get install -y --no-install-recommends \ @@ -9,13 +9,13 @@ RUN apt-get -q -y update && \ git \ && rm -rf /var/lib/apt/lists/* -WORKDIR /backup-utils-stable +WORKDIR /backup-utils ADD https://github.com/github/backup-utils/archive/stable.tar.gz / -RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils-stable && \ +RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils && \ rm -r /stable.tar.gz -COPY share/github-backup-utils/ghe-docker-init /backup-utils-stable/share/github-backup-utils/ghe-docker-init -RUN chmod +x /backup-utils-stable/share/github-backup-utils/ghe-docker-init +COPY share/github-backup-utils/ghe-docker-init /backup-utils/share/github-backup-utils/ghe-docker-init +RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init -ENTRYPOINT ["/backup-utils-stable/share/github-backup-utils/ghe-docker-init"] +ENTRYPOINT ["/backup-utils/share/github-backup-utils/ghe-docker-init"] CMD ["ghe-host-check"] diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init index c0db07b83..d22b5d743 100755 --- a/share/github-backup-utils/ghe-docker-init +++ b/share/github-backup-utils/ghe-docker-init @@ -2,7 +2,7 @@ set -e -PATH=$PATH:/backup-utils-stable/bin +PATH=$PATH:/backup-utils/bin mkdir -p /etc/github-backup-utils From 4f28e1742852dc6be683f424119c0c7408f36fed Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 4 May 2017 16:55:28 +1000 Subject: [PATCH 0322/2421] Allow settings to be restored to cluster using -c --- bin/ghe-restore | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 25c78a8f8..1d575649c 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -94,7 +94,6 @@ if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then cluster=true instance_configured=true - restore_settings=false fi # Restoring a cluster backup to a standalone appliance is not supported From 922c86e892b25f6524a688ada37af0e9711aa034 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 4 May 2017 16:58:08 +1000 Subject: [PATCH 0323/2421] Remove redundunt instance_configured If the instance is a cluster, then it will be configured and the earlier check for /etc/github/configured will have set instance_configured to true. --- bin/ghe-restore | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 1d575649c..7055d7499 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -93,7 +93,6 @@ cluster=false if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then cluster=true - instance_configured=true fi # Restoring a cluster backup to a standalone appliance is not supported From 888c8ae296eb2a76a1a79d06b0b45f279b298b05 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 26 Oct 2017 10:11:42 +0100 Subject: [PATCH 0324/2421] Switch to TMPDIR when working around bug This prevents SSH multiplexing holding a lock on the backup directory which may be an NFS mount. --- share/github-backup-utils/ghe-ssh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 59cf3587a..c0332426d 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -61,7 +61,10 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | git hash-object --stdin | cut -c 1-8)" opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 - [ -S $controlpath ] || ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true + if ! [ -S $controlpath ]; then + cd "$TMPDIR" + ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true + fi fi # Turn on verbose SSH logging if needed From 7bacc2ccf41a2dc9714283d0ae33dc91dd012f72 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 26 Oct 2017 11:01:20 +0100 Subject: [PATCH 0325/2421] Use subshell to prevent active dir change --- share/github-backup-utils/ghe-ssh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index c0332426d..c7b836a9f 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -62,8 +62,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 if ! [ -S $controlpath ]; then - cd "$TMPDIR" - ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true + ( cd "$TMPDIR" && ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true ) fi fi From 6d565871e723218ea5eb4860f91c9c380dd8c04e Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 2 Nov 2017 09:52:44 -0700 Subject: [PATCH 0326/2421] Add docs directory and docker image doc --- docs/docker.md | 95 +++++++++++++++++++++++ share/github-backup-utils/ghe-docker-init | 4 +- 2 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 docs/docker.md diff --git a/docs/docker.md b/docs/docker.md new file mode 100644 index 000000000..0f871647f --- /dev/null +++ b/docs/docker.md @@ -0,0 +1,95 @@ +### Docker + +#### Setting backup configuration options for Docker +The `backup.config` file is dynamically populated at runtime with all `GHE_` environment variables that are part of the run command or Docker environment: + +``` +$ docker run -it -e "GHE_HOSTNAME=hostname" \ +-e "GHE_DATA_DIR=/data" \ +-e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/id_rsa -o UserKnownHostsFile=/ghe-ssh/known_hosts \ +-e "GHE_NUM_SNAPSHOTS=15" \ +-v ghe-backup-data:/data \ +-v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ +-v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ +--rm \ +backup-utils ghe-backup +``` + +It is also possible to specify a `-e GHE_BACKUP_CONFIG` flag and volume mount in a local `backup.config` file rather than specify the variables individually at run time: + +``` +$ docker run -it -e "GHE_BACKUP_CONFIG=/mnt/backup.config" \ +-v ghe-backup-data:/data \ +-v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ +-v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ +-v $HOME/backup-utils/backup.config:/mnt/backup.config \ +--rm \ +backup-utils ghe-backup +``` + +#### SSH Keys with Docker + +A SSH private key that has been added to the GitHub Enterprise [Management Console for administrative SSH access](https://help.github.com/enterprise/admin/guides/installation/administrative-shell-ssh-access/) needs to be mounted into the container from the host system. It is also recommended to mount a SSH `.ssh/known_hosts` file into the container. + +``` +$ docker run -it -e "GHE_HOSTNAME=hostname" \ +-e "GHE_DATA_DIR=/data" \ +-e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/id_rsa -o UserKnownHostsFile=/ghe-ssh/known_hosts \ +-v ghe-backup-data:/data \ +-v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ +-v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ +--rm \ +backup-utils ghe-backup +``` + +#### Managing backup data with Docker + +Data persistence is achieved by using [Docker volumes](https://docs.docker.com/engine/admin/volumes/volumes/), which are managed with [`docker volume` commands](https://docs.docker.com/engine/reference/commandline/volume/). Prior to running the container for the first time, a volume can be created if you need to specify additional options. The named volume will be automatically created at runtime if it does not exist: + +``` +docker volume create ghe-backup-data +``` + +The named Docker volume can be mounted and accessed from other containers, using any image you like: + +``` +# Accessing backups using the backup-utils image: + +$ docker run -it -v ghe-backup-data:/data --rm backup-utils ls -l /data/ +total 8 +drwxr-xr-x 11 root root 4096 Oct 24 19:46 20171024T194650 +drwxr-xr-x 11 root root 4096 Oct 24 19:49 20171024T194921 +lrwxrwxrwx 1 root root 15 Oct 24 19:49 current -> 20171024T194921 + +# Accessing backups using the busybox library image: + +$ docker run --rm -v ghe-backup-data:/data busybox ls -l /data +total 8 +drwxr-xr-x 11 root root 4096 Oct 24 19:46 20171024T194650 +drwxr-xr-x 11 root root 4096 Oct 24 19:49 20171024T194921 +lrwxrwxrwx 1 root root 15 Oct 24 19:49 current -> 20171024T194921 +``` + +The volume's filesystem must support hard links. This works fine on Docker for Mac with the default local driver in my testing so far. + +Bind mounting a volume is supported, as long as the Docker host supports them and allows hardlinks. + +#### Scheduling backups using backup-utils in Docker + +Designed to be a "one shot" type container, scheduling backup runs with the Docker image is similar to the non-Docker scheduling. Run the container with all the same variables options and volume mounts on `crontab`. This avoids needing to run `crond` or an init system inside the container, and allows for the container to be disposable (enabling the use of Docker's `--rm` flag). + +To schedule hourly backup snapshots with verbose informational output written to a log file and errors generating an email: + +``` +MAILTO=admin@example.com + +0 * * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v ghe-backup-data:/data -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +``` + +To schedule nightly backup snapshots instead, use: + +``` +MAILTO=admin@example.com + +0 0 * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v ghe-backup-data:/data -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +``` diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init index d22b5d743..0272fb909 100755 --- a/share/github-backup-utils/ghe-docker-init +++ b/share/github-backup-utils/ghe-docker-init @@ -1,6 +1,4 @@ -#!/bin/bash - -set -e +#!/usr/bin/env bash PATH=$PATH:/backup-utils/bin From 9109e0ad807a858aa32edf19d8f969881eccb307 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 2 Nov 2017 10:16:54 -0700 Subject: [PATCH 0327/2421] Add a basic Docker build test --- test/test-docker-build.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 test/test-docker-build.sh diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh new file mode 100755 index 000000000..a6434ac25 --- /dev/null +++ b/test/test-docker-build.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Docker image build tests + +# Bring in testlib +. $(dirname "$0")/testlib.sh + +# Setup backup snapshot data dir and remote repositories dir locations to use +# the per-test temp space. +GHE_DATA_DIR="$TRASHDIR/data" +GHE_REMOTE_DATA_DIR="$TRASHDIR/remote" +export GHE_DATA_DIR GHE_REMOTE_DATA_DIR + +# Source in the config script +cd "$ROOTDIR" +. "share/github-backup-utils/ghe-backup-config" + +begin_test "ghe-backup logs the benchmark" +( + set -e + + docker build -t github/backup-utils:test . | grep "Successfully built" +) +end_test + +docker build -t github/backup-utils:test . From d8615cda3b4e7b148bc525689d27816b4365158b Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 2 Nov 2017 10:19:53 -0700 Subject: [PATCH 0328/2421] Quiet test Docker build --- test/test-docker-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index a6434ac25..66032fce0 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -18,7 +18,7 @@ begin_test "ghe-backup logs the benchmark" ( set -e - docker build -t github/backup-utils:test . | grep "Successfully built" + docker build -q -t github/backup-utils:test . | grep "sha256:" ) end_test From f194ba707af2eb1fdd71b4dde47b3d0fd5ee590b Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 2 Nov 2017 10:43:56 -0700 Subject: [PATCH 0329/2421] Skip docker tests on OSX CI platforms --- .travis.yml | 2 ++ test/test-docker-build.sh | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c491f667..51546b155 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ matrix: - os: linux dist: precise sudo: required + services: + - docker addons: apt: packages: diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 66032fce0..868fcd618 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash # Docker image build tests +# If docker is not installed, skip the whole docker test +# Travis CI does not currently support docker on OSX (https://docs.travis-ci.com/user/docker/) +if [ ! $(which docker) ]; then + echo "Docker is not installed on this host" + exit 1 +fi + # Bring in testlib . $(dirname "$0")/testlib.sh @@ -14,12 +21,10 @@ export GHE_DATA_DIR GHE_REMOTE_DATA_DIR cd "$ROOTDIR" . "share/github-backup-utils/ghe-backup-config" -begin_test "ghe-backup logs the benchmark" +begin_test "docker build completes successfully" ( set -e docker build -q -t github/backup-utils:test . | grep "sha256:" ) end_test - -docker build -t github/backup-utils:test . From f9fd5d1a2c345262f915fc8faa97f36221336207 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 2 Nov 2017 10:56:45 -0700 Subject: [PATCH 0330/2421] simplify docker test skip --- test/test-docker-build.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 868fcd618..6249ae085 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -3,10 +3,7 @@ # If docker is not installed, skip the whole docker test # Travis CI does not currently support docker on OSX (https://docs.travis-ci.com/user/docker/) -if [ ! $(which docker) ]; then - echo "Docker is not installed on this host" - exit 1 -fi +docker -v || exit 0 # Bring in testlib . $(dirname "$0")/testlib.sh From a5d903dc105e4902042c5147d707e690bed77a57 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 2 Nov 2017 11:08:08 -0700 Subject: [PATCH 0331/2421] Bash function to check for docker --- test/test-docker-build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 6249ae085..1e073a92d 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -3,7 +3,10 @@ # If docker is not installed, skip the whole docker test # Travis CI does not currently support docker on OSX (https://docs.travis-ci.com/user/docker/) -docker -v || exit 0 +if ! hash docker 2>/dev/null; then + echo "Docker is not installed on this host" + exit 0 +fi # Bring in testlib . $(dirname "$0")/testlib.sh From 01226574fcf8dfedd206eddef77eeeb9f4ba7d57 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 2 Nov 2017 11:11:57 -0700 Subject: [PATCH 0332/2421] No docker on precise --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 51546b155..2c491f667 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,6 @@ matrix: - os: linux dist: precise sudo: required - services: - - docker addons: apt: packages: From 18bbfd8485f03969424ecca170118b6776b81f63 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 2 Nov 2017 12:10:07 -0700 Subject: [PATCH 0333/2421] Docker docs tweaks --- docs/docker.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/docker.md b/docs/docker.md index 0f871647f..b3bbfe4d2 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -1,6 +1,12 @@ ### Docker -#### Setting backup configuration options for Docker +#### Building the image + +``` +docker build -t github/backup-utils . +``` + +#### Setting configuration options at runtime The `backup.config` file is dynamically populated at runtime with all `GHE_` environment variables that are part of the run command or Docker environment: ``` @@ -12,7 +18,7 @@ $ docker run -it -e "GHE_HOSTNAME=hostname" \ -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ -v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ --rm \ -backup-utils ghe-backup +github/backup-utils ghe-backup ``` It is also possible to specify a `-e GHE_BACKUP_CONFIG` flag and volume mount in a local `backup.config` file rather than specify the variables individually at run time: @@ -24,10 +30,10 @@ $ docker run -it -e "GHE_BACKUP_CONFIG=/mnt/backup.config" \ -v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ -v $HOME/backup-utils/backup.config:/mnt/backup.config \ --rm \ -backup-utils ghe-backup +github/backup-utils ghe-backup ``` -#### SSH Keys with Docker +#### SSH Keys A SSH private key that has been added to the GitHub Enterprise [Management Console for administrative SSH access](https://help.github.com/enterprise/admin/guides/installation/administrative-shell-ssh-access/) needs to be mounted into the container from the host system. It is also recommended to mount a SSH `.ssh/known_hosts` file into the container. @@ -39,10 +45,10 @@ $ docker run -it -e "GHE_HOSTNAME=hostname" \ -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ -v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ --rm \ -backup-utils ghe-backup +github/backup-utils ghe-backup ``` -#### Managing backup data with Docker +#### Managing backup data Data persistence is achieved by using [Docker volumes](https://docs.docker.com/engine/admin/volumes/volumes/), which are managed with [`docker volume` commands](https://docs.docker.com/engine/reference/commandline/volume/). Prior to running the container for the first time, a volume can be created if you need to specify additional options. The named volume will be automatically created at runtime if it does not exist: @@ -55,7 +61,7 @@ The named Docker volume can be mounted and accessed from other containers, using ``` # Accessing backups using the backup-utils image: -$ docker run -it -v ghe-backup-data:/data --rm backup-utils ls -l /data/ +$ docker run -it -v ghe-backup-data:/data --rm github/backup-utils ls -l /data/ total 8 drwxr-xr-x 11 root root 4096 Oct 24 19:46 20171024T194650 drwxr-xr-x 11 root root 4096 Oct 24 19:49 20171024T194921 @@ -74,7 +80,7 @@ The volume's filesystem must support hard links. This works fine on Docker for M Bind mounting a volume is supported, as long as the Docker host supports them and allows hardlinks. -#### Scheduling backups using backup-utils in Docker +#### Scheduling backups using crontab with Docker Designed to be a "one shot" type container, scheduling backup runs with the Docker image is similar to the non-Docker scheduling. Run the container with all the same variables options and volume mounts on `crontab`. This avoids needing to run `crond` or an init system inside the container, and allows for the container to be disposable (enabling the use of Docker's `--rm` flag). @@ -83,7 +89,7 @@ To schedule hourly backup snapshots with verbose informational output written to ``` MAILTO=admin@example.com -0 * * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v ghe-backup-data:/data -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +0 * * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v ghe-backup-data:/data -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm github/backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 ``` To schedule nightly backup snapshots instead, use: @@ -91,5 +97,5 @@ To schedule nightly backup snapshots instead, use: ``` MAILTO=admin@example.com -0 0 * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v ghe-backup-data:/data -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +0 0 * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v ghe-backup-data:/data -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm github/backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 ``` From 845de5677737690923ba168042bbbee5e9003ed3 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 6 Nov 2017 03:22:53 +0000 Subject: [PATCH 0334/2421] spelling: committing --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index a6784745f..7e8333075 100755 --- a/script/release +++ b/script/release @@ -207,7 +207,7 @@ def push_release_branch(version) end unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version`) - raise "Error commiting changelog and version:\n\n#{out}" + raise "Error committing changelog and version:\n\n#{out}" end unless (out = `git push --quiet origin release-#{version}`) From d6d36de67e27b1f9df13e333ba883becafb39855 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 6 Nov 2017 03:23:14 +0000 Subject: [PATCH 0335/2421] spelling: displays --- test/test-ghe-detect-leaked-ssh-keys.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-detect-leaked-ssh-keys.sh b/test/test-ghe-detect-leaked-ssh-keys.sh index 15fc6a4a7..c151d36ee 100644 --- a/test/test-ghe-detect-leaked-ssh-keys.sh +++ b/test/test-ghe-detect-leaked-ssh-keys.sh @@ -21,7 +21,7 @@ EOF SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) -begin_test "ghe-detect-leaked-ssh-keys check -h dispays help message" +begin_test "ghe-detect-leaked-ssh-keys check -h displays help message" ( set -e From c74ca8c10a919ed15d0c682b2a96856f25a58a63 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 6 Nov 2017 03:23:24 +0000 Subject: [PATCH 0336/2421] spelling: enterprise --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e5c39692d..9e711e0cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -145,7 +145,7 @@ github-backup-utils (2.5.1) UNRELEASED; urgency=medium github-backup-utils (2.5.0) UNRELEASED; urgency=medium - * Adds GitHub Enterpise 2.5 support + * Adds GitHub Enterprise 2.5 support * Adds GitHub Enterprise Clustering support * Backups and restores SAML keypairs From 0e4438d66e2bb5988182307062f1145989aaaace Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 6 Nov 2017 03:24:14 +0000 Subject: [PATCH 0337/2421] spelling: network --- share/github-backup-utils/ghe-restore-repositories-dgit-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index de07161f7..8066b5660 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -107,7 +107,7 @@ bm_start "$(basename $0) - Building network list" OLDIFS=$IFS; IFS=$'\n' for path in $network_paths; do # Get the network ID - # The nework id from a repository is the last component of the path + # The network id from a repository is the last component of the path # i.e. /data/repositories/a/nw/a5/bf/c9/37 network ID would be 37 ghe_verbose "Adding network_path $path to the list of networks to send" echo $path From f6123b6f79eacce4b3361fc99f64b843ba4a33c2 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 6 Nov 2017 03:25:09 +0000 Subject: [PATCH 0338/2421] spelling: objects --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 50fafe22a..86206e042 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -22,7 +22,7 @@ GHE_HOSTNAME="$1" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} -# Find the objets to restore +# Find the objects to restore storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindepth 4 -maxdepth 4 -type f -exec wc -c {} \;) # No need to restore anything, early exit From 4ea9c6fda7178786678a2fa8a228d3859d720dbc Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 6 Nov 2017 03:25:47 +0000 Subject: [PATCH 0339/2421] spelling: output --- test/test-ghe-detect-leaked-ssh-keys.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-detect-leaked-ssh-keys.sh b/test/test-ghe-detect-leaked-ssh-keys.sh index c151d36ee..c7e868548 100644 --- a/test/test-ghe-detect-leaked-ssh-keys.sh +++ b/test/test-ghe-detect-leaked-ssh-keys.sh @@ -63,7 +63,7 @@ begin_test "ghe-detect-leaked-ssh-keys leaked keys in old snapshot" echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" output=$(ghe-detect-leaked-ssh-keys -s "$GHE_DATA_DIR/2") - ! echo $ouput | grep -q "Leaked key in current backup" + ! echo $output | grep -q "Leaked key in current backup" echo $output | grep -q "One or more older backup snapshots" ) end_test From 5679ca1161a7c43561406da6f6f46da9ffadaeaa Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 6 Nov 2017 03:26:35 +0000 Subject: [PATCH 0340/2421] spelling: retrieved --- test/bin/python | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bin/python b/test/bin/python index c79b0a433..5e2fc1275 100755 --- a/test/bin/python +++ b/test/bin/python @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Usage: python -c '...' # Fake python command stub for tests. Python is used on the remote side -# only to parse JSON data retreived from the maintenance status API and produce +# only to parse JSON data retrieved from the maintenance status API and produce # a number of active writing processes. Verify that python code passes syntax # checks and fake a 0 process count. set -e From b7e482f3d02c9738a1e5f174fbfdf981bc99910a Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 6 Nov 2017 03:27:37 +0000 Subject: [PATCH 0341/2421] spelling: utilities --- test/bin/chown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bin/chown b/test/bin/chown index b75d52c59..1906f79e4 100755 --- a/test/bin/chown +++ b/test/bin/chown @@ -1,4 +1,4 @@ #!/usr/bin/env bash # Fake chown command for tests. Avoids needing to creating special users for -# utlities that chown on the remote side. +# utilities that chown on the remote side. true From 7a79809e6044881e354ff0d6a7578caea30caf1b Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 6 Nov 2017 03:27:25 +0000 Subject: [PATCH 0342/2421] spelling: utility --- test/bin/redis-cli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bin/redis-cli b/test/bin/redis-cli index aae867cda..8428e47c0 100755 --- a/test/bin/redis-cli +++ b/test/bin/redis-cli @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Usage: redis-cli ... -# Fake redis-cli command stub for tests. The redis-cli utlity is run on the +# Fake redis-cli command stub for tests. The redis-cli utility is run on the # remote side by libexec/ghe-backup-redis to force a background save of redis # data and then wait until the dump file has been written. It uses the LASTSAVE # and BGSAVE commands. From 07c7d223982310399ec0d7ef0c5e9d322e8820f6 Mon Sep 17 00:00:00 2001 From: donal Date: Wed, 8 Nov 2017 15:15:49 +1100 Subject: [PATCH 0343/2421] next iteration if there isn't an *.rsync file --- share/github-backup-utils/ghe-backup-alambic-cluster-ng | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 6b90ca3e4..22ac5e43a 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -85,6 +85,7 @@ bm_end "$(basename $0) - Processing routes" # rsync all the repositories bm_start "$(basename $0) - Storage object sync" for file_list in $tempdir/*.rsync; do + [[ -f "$file_list" ]] || continue hostname=$(basename $file_list .rsync) object_num=$(cat $file_list | wc -l) From 83b6c96018581b953118945baa15176e66fd1cea Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 9 Nov 2017 04:16:23 -0800 Subject: [PATCH 0344/2421] Bump version: 2.11.2 [ci skip] --- debian/changelog | 7 +++++++ share/github-backup-utils/version | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 9e711e0cd..dab6cec11 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.11.2) UNRELEASED; urgency=medium + + * Allow the restoration of configuration to Cluster #347 + * Switch to TMPDIR before initiating SSH multiplexing workaround to prevent locking the destination filesystem #348 + + -- Colin Seymour Thu, 09 Nov 2017 12:16:23 +0000 + github-backup-utils (2.11.1) UNRELEASED; urgency=medium * Refresh the existing indices when restoring Elasticsearch indices to cluster #328 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 6ceb272ee..9e5bb77a3 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.11.1 +2.11.2 From bcc963c1402836ebce483d10dcec7eff4a58dfc8 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 9 Nov 2017 12:06:58 -0800 Subject: [PATCH 0345/2421] Add missing quotes --- docs/docker.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/docker.md b/docs/docker.md index b3bbfe4d2..7bea644b2 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -12,9 +12,9 @@ The `backup.config` file is dynamically populated at runtime with all `GHE_` env ``` $ docker run -it -e "GHE_HOSTNAME=hostname" \ -e "GHE_DATA_DIR=/data" \ --e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/id_rsa -o UserKnownHostsFile=/ghe-ssh/known_hosts \ +-e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/id_rsa -o UserKnownHostsFile=/ghe-ssh/known_hosts" \ -e "GHE_NUM_SNAPSHOTS=15" \ --v ghe-backup-data:/data \ +-v "ghe-backup-data:/data" \ -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ -v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ --rm \ @@ -25,10 +25,10 @@ It is also possible to specify a `-e GHE_BACKUP_CONFIG` flag and volume mount in ``` $ docker run -it -e "GHE_BACKUP_CONFIG=/mnt/backup.config" \ --v ghe-backup-data:/data \ +-v "ghe-backup-data:/data" \ -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ -v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ --v $HOME/backup-utils/backup.config:/mnt/backup.config \ +-v "$HOME/backup-utils/backup.config:/mnt/backup.config" \ --rm \ github/backup-utils ghe-backup ``` @@ -40,8 +40,8 @@ A SSH private key that has been added to the GitHub Enterprise [Management Conso ``` $ docker run -it -e "GHE_HOSTNAME=hostname" \ -e "GHE_DATA_DIR=/data" \ --e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/id_rsa -o UserKnownHostsFile=/ghe-ssh/known_hosts \ --v ghe-backup-data:/data \ +-e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/id_rsa -o UserKnownHostsFile=/ghe-ssh/known_hosts" \ +-v "ghe-backup-data:/data" \ -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ -v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ --rm \ @@ -76,9 +76,9 @@ drwxr-xr-x 11 root root 4096 Oct 24 19:49 20171024T194921 lrwxrwxrwx 1 root root 15 Oct 24 19:49 current -> 20171024T194921 ``` -The volume's filesystem must support hard links. This works fine on Docker for Mac with the default local driver in my testing so far. +* The volume's filesystem must support hard links. -Bind mounting a volume is supported, as long as the Docker host supports them and allows hardlinks. +* Bind mounting a volume is supported, as long as the Docker host supports them and allows hard links. #### Scheduling backups using crontab with Docker @@ -89,7 +89,7 @@ To schedule hourly backup snapshots with verbose informational output written to ``` MAILTO=admin@example.com -0 * * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v ghe-backup-data:/data -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm github/backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +0 * * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v "ghe-backup-data:/data" -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm github/backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 ``` To schedule nightly backup snapshots instead, use: @@ -97,5 +97,5 @@ To schedule nightly backup snapshots instead, use: ``` MAILTO=admin@example.com -0 0 * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v ghe-backup-data:/data -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm github/backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +0 0 * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v "ghe-backup-data:/data" -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm github/backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 ``` From eee3adc6042508174e081f95895dfd59a1fcff76 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 9 Nov 2017 14:28:10 -0800 Subject: [PATCH 0346/2421] Document using ssh-agent --- docs/docker.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/docker.md b/docs/docker.md index 7bea644b2..ea3ed628c 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -48,6 +48,39 @@ $ docker run -it -e "GHE_HOSTNAME=hostname" \ github/backup-utils ghe-backup ``` +##### Using ssh-agent + +If your SSH private key is protected with a passphrase, you can mount the `ssh-agent` socket from the Docker host into the GitHub Enterprise backup utilities image. + +1. Start the ssh-agent in the background. + + ``` + $ eval "$(ssh-agent -s)" + Agent pid 59566 + ``` + +2. Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace *id_rsa* in the command with the name of your private key file. + + ``` + $ ssh-add ~/.ssh/id_rsa + ``` + +3. Run the container setting the `SSH_AUTH_SOCK` environment variable, and mounting the socket into the container as a volume: + + ``` + docker run -it -e "GHE_HOSTNAME=hostname" \ + -e "GHE_DATA_DIR=/data" \ + -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/id_rsa -o UserKnownHostsFile=/ghe-ssh/known_hosts" \ + -e "GHE_NUM_SNAPSHOTS=15" \ + -v "ghe-backup-data:/data" \ + -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ + -v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ + -v "$(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK)" \ + -e "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" + --rm \ + github/backup-utils ghe-backup + ``` + #### Managing backup data Data persistence is achieved by using [Docker volumes](https://docs.docker.com/engine/admin/volumes/volumes/), which are managed with [`docker volume` commands](https://docs.docker.com/engine/reference/commandline/volume/). Prior to running the container for the first time, a volume can be created if you need to specify additional options. The named volume will be automatically created at runtime if it does not exist: From 69a5cf73054639cff60e7d7d96c9a7e0803af62c Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Fri, 10 Nov 2017 17:15:23 +1100 Subject: [PATCH 0347/2421] Cleaned up consistency for arguments and usage text --- bin/ghe-backup | 14 ++++++++------ bin/ghe-host-check | 16 ++++++++++------ bin/ghe-restore | 39 ++++++++++++++++++++++----------------- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 51b3a95c7..45714887b 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -1,12 +1,14 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup [-h] [-v] [--version] +#/ Usage: ghe-backup [-hv] [--version] +#/ #/ Take snapshots of all GitHub Enterprise data, including Git repository data, #/ the MySQL database, instance settings, GitHub Pages data, etc. #/ -#/ Options: -#/ -v Enable verbose output. -#/ --version Display version information. -#/ -h Show this message. +#/ OPTIONS: +#/ -v | --verbose Enable verbose output +#/ -h | --help Show this message +#/ --version Display version information +#/ set -e @@ -21,7 +23,7 @@ while true; do export GHE_SHOW_VERSION=true shift ;; - -v) + -v|--verbose) export GHE_VERBOSE=true shift ;; diff --git a/bin/ghe-host-check b/bin/ghe-host-check index ad29e7407..279e00700 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -1,11 +1,15 @@ #!/usr/bin/env bash -#/ Usage: ghe-host-check [-h] [--version] [] -#/ Verify connectivity with the GitHub Enterprise host. When no is -#/ provided, the $GHE_HOSTNAME configured in backup.config is assumed. +#/ Usage: ghe-host-check [-h] [--version] [] +#/ +#/ Verify connectivity with the GitHub Enterprise host. +#/ +#/ OPTIONS: +#/ -h | --help Show this message. +#/ --version Display version information. +#/ The GitHub Enterprise host to check. When no is +#/ provided, the $GHE_HOSTNAME configured in backup.config +#/ is assumed. #/ -#/ Options: -#/ --version Display version information. -#/ -h Show this message. set -e diff --git a/bin/ghe-restore b/bin/ghe-restore index 855cb09a8..d04183dba 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -1,26 +1,31 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore [-h] [-v] [--version] [-s ] [] -#/ Restores a GitHub instance from local backup snapshots. The is the -#/ hostname or IP of the GitHub instance. The may be omitted when -#/ the GHE_RESTORE_HOST config variable is set in backup.config. When a -#/ argument is provided, it always overrides the configured restore host. +#/ Usage: ghe-restore [-fchv] [--version] [-s ] [] #/ -#/ Options: -#/ -f Don't prompt for confirmation before restoring. -#/ -c Restore appliance settings and license in addition to +#/ Restores a GitHub instance from local backup snapshots. +#/ +#/ Note that the GitHub Enterprise host must be reachable and your SSH key must +#/ be setup asdescribed in the following help article: +#/ +#/ +#/ +#/ OPTIONS: +#/ -f | --force Don't prompt for confirmation before restoring. +#/ -c | --config Restore appliance settings and license in addition to #/ datastores. Settings are not restored by default to #/ prevent overwriting different configuration on the #/ restore host. +#/ -v | --verbose Enable verbose output. +#/ -h | --help Show this message. +#/ --version Display version information and exit. #/ -s Restore from the snapshot with the given id. Available #/ snapshots may be listed under the data directory. -#/ -v Enable verbose output. -#/ --version Display version information and exit. -#/ -h Show this message. +#/ The is the hostname or IP of the GitHub Enterprise +#/ instance. The may be omitted when the +#/ GHE_RESTORE_HOST config variable is set in backup.config. +#/ When a argument is provided, it always overrides +#/ the configured restore host. #/ -#/ Note that the host must be reachable and your SSH key must be setup as -#/ described in the following help article: -#/ -#/ + set -e # Parse arguments @@ -36,7 +41,7 @@ while true; do snapshot_id="$(basename "$2")" shift 2 ;; - -c) + -c|--config) restore_settings=true shift ;; @@ -48,7 +53,7 @@ while true; do export GHE_SHOW_VERSION=true shift ;; - -v) + -v|--verbose) export GHE_VERBOSE=true shift ;; From 8531a9deadfd904bcd938036bc107a5d8496af3e Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 13 Nov 2017 20:38:44 -0800 Subject: [PATCH 0348/2421] Fix failures variable --- bin/ghe-backup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index a8fed50f4..97680e1f2 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -156,7 +156,7 @@ echo "Backing up Git repositories ..." if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/dgit-cluster-backup-routes ; then echo "* Using calculated routes method..." - ghe-backup-repositories-cluster-ng || failures="$failure repositories" + ghe-backup-repositories-cluster-ng || failures="$failures repositories" else echo "* Using legacy method. A faster backup method is available on enterprise 2.7 and up." ghe-backup-repositories-cluster || failures="$failures repositories" @@ -174,7 +174,7 @@ if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "Backing up storage data ..." if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/storage-cluster-backup-routes; then - ghe-backup-alambic-cluster-ng || failures="$failure alambic" + ghe-backup-alambic-cluster-ng || failures="$failures alambic" else ghe-backup-alambic-cluster || failures="$failures alambic" fi From a1751e18a06fe48030ac52d6f454205b8d66d95d Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Nov 2017 11:00:03 -0800 Subject: [PATCH 0349/2421] add missing / --- docs/docker.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docker.md b/docs/docker.md index ea3ed628c..7f1ee5642 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -76,7 +76,7 @@ If your SSH private key is protected with a passphrase, you can mount the `ssh-a -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" \ -v "$HOME/.ssh/id_rsa:/ghe-ssh/id_rsa" \ -v "$(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK)" \ - -e "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" + -e "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" \ --rm \ github/backup-utils ghe-backup ``` From 49b3229e01b237aebd7d9d035067992e63357515 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 20 Nov 2017 11:04:29 -0800 Subject: [PATCH 0350/2421] prefer syntax --- share/github-backup-utils/ghe-docker-init | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init index 0272fb909..b26ba45f7 100755 --- a/share/github-backup-utils/ghe-docker-init +++ b/share/github-backup-utils/ghe-docker-init @@ -6,10 +6,10 @@ mkdir -p /etc/github-backup-utils touch /etc/github-backup-utils/backup.config -for VAR in `env`; do +for VAR in $(env); do if [[ $VAR =~ ^GHE_ ]]; then - backuputils_name=`echo "$VAR" | sed -r "s/GHE_(.*)=.*/\1/g" | tr '[:upper:]' '[:lower:]'` - backuputils_value=`echo "$VAR" | sed -r "s/.*=(.*)/\1/g"` + backuputils_name=$(echo "$VAR" | sed -r "s/GHE_(.*)=.*/\1/g" | tr '[:upper:]' '[:lower:]') + backuputils_value=$(echo "$VAR" | sed -r "s/.*=(.*)/\1/g") echo "${backuputils_name}=${backuputils_value}" >> /etc/github-backup-utils/backup.config fi done From ff8eb2285ab9923882b69a5662d8aa51a0af5260 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Tue, 21 Nov 2017 10:15:07 +1100 Subject: [PATCH 0351/2421] Minor typos and style changes --- bin/ghe-backup | 6 +++--- bin/ghe-restore | 2 +- test/test-ghe-backup.sh | 4 ++-- test/test-ghe-host-check.sh | 4 ++-- test/test-ghe-restore.sh | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 45714887b..745db0d6a 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -5,9 +5,9 @@ #/ the MySQL database, instance settings, GitHub Pages data, etc. #/ #/ OPTIONS: -#/ -v | --verbose Enable verbose output -#/ -h | --help Show this message -#/ --version Display version information +#/ -v | --verbose Enable verbose output. +#/ -h | --help Show this message. +#/ --version Display version information. #/ set -e diff --git a/bin/ghe-restore b/bin/ghe-restore index d04183dba..b6d1d3fc7 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -4,7 +4,7 @@ #/ Restores a GitHub instance from local backup snapshots. #/ #/ Note that the GitHub Enterprise host must be reachable and your SSH key must -#/ be setup asdescribed in the following help article: +#/ be setup as described in the following help article: #/ #/ #/ diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6ed42c8b9..a8de6911c 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -539,8 +539,8 @@ begin_test "ghe-backup honours --help and -h flags" ( set -e - arg_help=`ghe-backup --help | grep -o 'Usage: ghe-backup'` - arg_h=`ghe-backup -h | grep -o 'Usage: ghe-backup'` + arg_help=$(ghe-backup --help | grep -o 'Usage: ghe-backup') + arg_h=$(ghe-backup -h | grep -o 'Usage: ghe-backup') # Make sure a Usage: string is returned and that it's the same for -h and --help [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-backup" diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 6e260ab09..4e1e36770 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -39,8 +39,8 @@ begin_test "ghe-host-check honours --help and -h flags" ( set -e - arg_help=`ghe-host-check --help | grep -o 'Usage: ghe-host-check'` - arg_h=`ghe-host-check -h | grep -o 'Usage: ghe-host-check'` + arg_help=$(ghe-host-check --help | grep -o 'Usage: ghe-host-check') + arg_h=$(ghe-host-check -h | grep -o 'Usage: ghe-host-check') # Make sure a Usage: string is returned and that it's the same for -h and --help [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-host-check" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 1d4ca7fc3..9ba4ebeb3 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -667,8 +667,8 @@ begin_test "ghe-restore honours --help and -h flags" ( set -e - arg_help=`ghe-restore --help | grep -o 'Usage: ghe-restore'` - arg_h=`ghe-restore -h | grep -o 'Usage: ghe-restore'` + arg_help=$(ghe-restore --help | grep -o 'Usage: ghe-restore') + arg_h=$(ghe-restore -h | grep -o 'Usage: ghe-restore') # Make sure a Usage: string is returned and that it's the same for -h and --help [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-restore" From 972a1a60709d208cec2557c1e64d3459b28ee935 Mon Sep 17 00:00:00 2001 From: Austin English Date: Tue, 28 Nov 2017 17:13:08 -0600 Subject: [PATCH 0352/2421] test/bin/python: force python2.7 so it works on python3 systems compiler was deprecated in python2.6 and removed in python3+ --- test/bin/python | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bin/python b/test/bin/python index 5e2fc1275..3fbe8b163 100755 --- a/test/bin/python +++ b/test/bin/python @@ -18,7 +18,7 @@ cat >/dev/null # verify the python compiles at least. if this fails then the python code passed # to -c failed basic syntax checks. echo "$2" | -/usr/bin/python -c "import sys; __import__('compiler').parse(sys.stdin.read())" +/usr/bin/python2.7 -c "import sys; __import__('compiler').parse(sys.stdin.read())" # pretend we found zero processes. echo 0 From 7bc6e370c501043ecce8ac3696f7bf0473d7e0f9 Mon Sep 17 00:00:00 2001 From: Austin English Date: Tue, 28 Nov 2017 16:36:39 -0600 Subject: [PATCH 0353/2421] test/test-ghe-backup.sh: skip test if not in a git checkout --- test/test-ghe-backup.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 296429e09..08bced2ac 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -475,14 +475,20 @@ begin_test "ghe-backup stores version when not run from a clone" # Make sure this doesn't exist rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" - tmpdir=$(mktemp -d $TRASHDIR/foo.XXXXXX) - git clone $ROOTDIR $tmpdir/backup-utils - cd $tmpdir/backup-utils - rm -rf .git - ./bin/ghe-backup - - # verify that ghe-backup wrote its version information to the host - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] + tmpdir=$(mktemp -d "$TRASHDIR/foo.XXXXXX") + + # If user is running the tests extracted from a release tarball, git clone will fail. + if GIT_DIR="$ROOTDIR/.git" git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + git clone "$ROOTDIR" "$tmpdir/backup-utils" + cd "$tmpdir/backup-utils" + rm -rf .git + ./bin/ghe-backup + + # Verify that ghe-backup wrote its version information to the host + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] + else + echo ".git directory not found, skipping ghe-backup not from a clone test" + fi ) end_test From 30168901b22b50e505ea0d31379b2f52ae8b407c Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Sun, 3 Dec 2017 22:57:36 -0800 Subject: [PATCH 0354/2421] Docker image variable tests --- share/github-backup-utils/ghe-docker-init | 2 +- test/test-docker-build.sh | 24 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init index b26ba45f7..33017bc6e 100755 --- a/share/github-backup-utils/ghe-docker-init +++ b/share/github-backup-utils/ghe-docker-init @@ -8,7 +8,7 @@ touch /etc/github-backup-utils/backup.config for VAR in $(env); do if [[ $VAR =~ ^GHE_ ]]; then - backuputils_name=$(echo "$VAR" | sed -r "s/GHE_(.*)=.*/\1/g" | tr '[:upper:]' '[:lower:]') + backuputils_name=$(echo "$VAR" | sed -r "s/(.*)=.*/\1/g") backuputils_value=$(echo "$VAR" | sed -r "s/.*=(.*)/\1/g") echo "${backuputils_name}=${backuputils_value}" >> /etc/github-backup-utils/backup.config fi diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 1e073a92d..7e9b338e3 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -28,3 +28,27 @@ begin_test "docker build completes successfully" docker build -q -t github/backup-utils:test . | grep "sha256:" ) end_test + +begin_test "docker run completes successfully" +( + set -e + + docker run --rm -t github/backup-utils:test ghe-host-check --version | grep "GitHub backup-utils " +) +end_test + +begin_test "GHE_ env variables set in backup.config" +( + set -e + + docker run --rm -e "GHE_TEST_VAR=test" -t github/backup-utils:test grep "GHE_TEST_VAR=test" /etc/github-backup-utils/backup.config +) +end_test + +begin_test "Non GHE_ env variables not set in backup.config" +( + set -e + + docker run --rm -e "GHE_TEST_VAR=test" -e "NGHE_TEST_VAR=test" -t github/backup-utils:test grep -L "NGHE_TEST_VAR=test" /etc/github-backup-utils/backup.config | grep /etc/github-backup-utils/backup.config +) +end_test From 0e30ca56a3bb98f7af3b17a701256e3642d3cefa Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 4 Dec 2017 09:20:27 -0800 Subject: [PATCH 0355/2421] Change test to avoid false positive --- test/test-docker-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 7e9b338e3..2239b758b 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -41,7 +41,7 @@ begin_test "GHE_ env variables set in backup.config" ( set -e - docker run --rm -e "GHE_TEST_VAR=test" -t github/backup-utils:test grep "GHE_TEST_VAR=test" /etc/github-backup-utils/backup.config + docker run --rm -e "GHE_TEST_VAR=test" -t github/backup-utils:test cat /etc/github-backup-utils/backup.config | grep "GHE_TEST_VAR=test" ) end_test From 4e07394986f53a9446f83b165696aed17ac82e20 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Mon, 11 Dec 2017 22:40:54 -0500 Subject: [PATCH 0356/2421] Remove other snapshot contents before removing the "incomplete" file --- share/github-backup-utils/ghe-prune-snapshots | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index e6270539f..0a1a63705 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -6,13 +6,26 @@ set -e # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# Once we start pruning, this backup will no longer be valid. +# So create or preserve its `incomplete` file and remove the +# `incomplete` file last. +prune_snapshot() { + local prune_dir + while read prune_dir; do + [ -n $prune_dir ] || return + touch "$prune_dir/incomplete" + find "$prune_dir" -not -path "$prune_dir/incomplete" | xargs rm -rf + rm -rf "$prune_dir" + done +} + # First prune all incomplete / failed snapshot directories prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) if [ $prune_num -gt 0 ]; then echo Pruning $prune_num "failed snapshot(s) ..." - echo "$prune_dirs" | sed 's@/incomplete$@@' | xargs rm -rf + echo "$prune_dirs" | sed 's@/incomplete$@@' | prune_snapshot fi # Now prune all expired snapshots. Keep GHE_NUM_SNAPSHOTS around. @@ -22,5 +35,5 @@ if [ "$snapshot_count" -gt "$GHE_NUM_SNAPSHOTS" ]; then prune_dirs="$(ls -1d "$GHE_DATA_DIR"/[0-9]* | sort -r | awk "NR>$GHE_NUM_SNAPSHOTS")" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) echo Pruning $prune_num "expired snapshot(s) ..." - echo "$prune_dirs" | xargs rm -rf + echo "$prune_dirs" | prune_snapshot fi From 1eb9f3b39576b1eef168361d90e3c312a9af9828 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Tue, 12 Dec 2017 12:49:42 -0500 Subject: [PATCH 0357/2421] Quote the variable $prune_dir --- share/github-backup-utils/ghe-prune-snapshots | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index 0a1a63705..9c2ce99ce 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -12,7 +12,7 @@ set -e prune_snapshot() { local prune_dir while read prune_dir; do - [ -n $prune_dir ] || return + [ -n "$prune_dir" ] || return touch "$prune_dir/incomplete" find "$prune_dir" -not -path "$prune_dir/incomplete" | xargs rm -rf rm -rf "$prune_dir" From 9c1b0b1adee99929d39e5412dc217d5a766e67e0 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Tue, 12 Dec 2017 13:08:26 -0500 Subject: [PATCH 0358/2421] Add min and max depth 1 to `find "$prune_dir"` --- share/github-backup-utils/ghe-prune-snapshots | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index 9c2ce99ce..fd9addabf 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -14,7 +14,7 @@ prune_snapshot() { while read prune_dir; do [ -n "$prune_dir" ] || return touch "$prune_dir/incomplete" - find "$prune_dir" -not -path "$prune_dir/incomplete" | xargs rm -rf + find "$prune_dir" -mindepth 1 -maxdepth 1 -not -path "$prune_dir/incomplete" | xargs rm -rf rm -rf "$prune_dir" done } From 1be5cb46bbdb0285844672b89e8bd6b44b7ec2e1 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Tue, 12 Dec 2017 13:14:46 -0500 Subject: [PATCH 0359/2421] Pipe more safely to `xargs rm -rf` --- share/github-backup-utils/ghe-prune-snapshots | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index fd9addabf..ddc92d3da 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -14,7 +14,7 @@ prune_snapshot() { while read prune_dir; do [ -n "$prune_dir" ] || return touch "$prune_dir/incomplete" - find "$prune_dir" -mindepth 1 -maxdepth 1 -not -path "$prune_dir/incomplete" | xargs rm -rf + find "$prune_dir" -mindepth 1 -maxdepth 1 -not -path "$prune_dir/incomplete" -print0 | xargs -0 rm -rf rm -rf "$prune_dir" done } From f56a47132a68e523c878a6dafc5d8161a56d5543 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Dec 2017 15:52:07 +0000 Subject: [PATCH 0360/2421] Extract and quote env vars when writing to file --- share/github-backup-utils/ghe-docker-init | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init index 33017bc6e..a4219b2c4 100755 --- a/share/github-backup-utils/ghe-docker-init +++ b/share/github-backup-utils/ghe-docker-init @@ -6,12 +6,6 @@ mkdir -p /etc/github-backup-utils touch /etc/github-backup-utils/backup.config -for VAR in $(env); do - if [[ $VAR =~ ^GHE_ ]]; then - backuputils_name=$(echo "$VAR" | sed -r "s/(.*)=.*/\1/g") - backuputils_value=$(echo "$VAR" | sed -r "s/.*=(.*)/\1/g") - echo "${backuputils_name}=${backuputils_value}" >> /etc/github-backup-utils/backup.config - fi -done +env | grep ^GHE_ | sed -r "s/(.[^=]+)=(.*)/\1=\"\2\"/g" >> /etc/github-backup-utils/backup.config exec "$@" From 62016da69237d7f2a1bed78c89b7f3b3c9e2d9ed Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Dec 2017 15:55:03 +0000 Subject: [PATCH 0361/2421] Update and add new test --- test/test-docker-build.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 2239b758b..283708a67 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -41,7 +41,15 @@ begin_test "GHE_ env variables set in backup.config" ( set -e - docker run --rm -e "GHE_TEST_VAR=test" -t github/backup-utils:test cat /etc/github-backup-utils/backup.config | grep "GHE_TEST_VAR=test" + docker run --rm -e "GHE_TEST_VAR=test" -t github/backup-utils:test cat /etc/github-backup-utils/backup.config | grep "GHE_TEST_VAR=\"test\"" +) +end_test + +begin_test "GHE_ env variables with spaces set in backup.config" +( + set -e + + docker run --rm -e "GHE_TEST_VAR=test with a space" -t github/backup-utils:test cat /etc/github-backup-utils/backup.config | grep "GHE_TEST_VAR=\"test with a space\"" ) end_test @@ -49,6 +57,6 @@ begin_test "Non GHE_ env variables not set in backup.config" ( set -e - docker run --rm -e "GHE_TEST_VAR=test" -e "NGHE_TEST_VAR=test" -t github/backup-utils:test grep -L "NGHE_TEST_VAR=test" /etc/github-backup-utils/backup.config | grep /etc/github-backup-utils/backup.config + docker run --rm -e "GHE_TEST_VAR=test" -e "NGHE_TEST_VAR=test" -t github/backup-utils:test grep -L "NGHE_TEST_VAR=\"test\"" /etc/github-backup-utils/backup.config | grep /etc/github-backup-utils/backup.config ) end_test From 4c89cafbbb756574682209068c155de08aa97356 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Dec 2017 16:47:18 +0000 Subject: [PATCH 0362/2421] Make it clear tests are docker-related --- test/test-docker-build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 283708a67..11c62ed52 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -37,7 +37,7 @@ begin_test "docker run completes successfully" ) end_test -begin_test "GHE_ env variables set in backup.config" +begin_test "docker GHE_ env variables set in backup.config" ( set -e @@ -45,7 +45,7 @@ begin_test "GHE_ env variables set in backup.config" ) end_test -begin_test "GHE_ env variables with spaces set in backup.config" +begin_test "docker GHE_ env variables with spaces set in backup.config" ( set -e @@ -53,7 +53,7 @@ begin_test "GHE_ env variables with spaces set in backup.config" ) end_test -begin_test "Non GHE_ env variables not set in backup.config" +begin_test "docker Non GHE_ env variables not set in backup.config" ( set -e From c04dc90e53599c23b85bdc568a689712fdda56a7 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Dec 2017 17:38:07 +0000 Subject: [PATCH 0363/2421] Only sync storage objects if routes exist --- .../ghe-backup-alambic-cluster-ng | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 22ac5e43a..2f0452508 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -84,26 +84,27 @@ bm_end "$(basename $0) - Processing routes" # rsync all the repositories bm_start "$(basename $0) - Storage object sync" -for file_list in $tempdir/*.rsync; do - [[ -f "$file_list" ]] || continue - hostname=$(basename $file_list .rsync) - - object_num=$(cat $file_list | wc -l) - echo "* Transferring $object_num objects from $hostname" - - ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --files-from="$file_list" \ - --size-only \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ - "$backup_dir" 1>&3 & -done +if [ -s "$routes_list" ]; then + for file_list in $tempdir/*.rsync; do + hostname=$(basename $file_list .rsync) + + object_num=$(cat $file_list | wc -l) + echo "* Transferring $object_num objects from $hostname" + + ghe-rsync -avr \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --files-from="$file_list" \ + --size-only \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ + "$backup_dir" 1>&3 & + done -for pid in $(jobs -p); do - wait $pid -done + for pid in $(jobs -p); do + wait $pid + done +fi bm_end "$(basename $0) - Storage object sync" bm_end "$(basename $0)" From 9151d0fa08b964755a8b83ccbd53f28971029698 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 22 Dec 2017 15:44:00 +0000 Subject: [PATCH 0364/2421] Backup management console password --- share/github-backup-utils/ghe-backup-settings | 12 ++++-------- share/github-backup-utils/ghe-restore-settings | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index d9a67c747..b6bdc2dcf 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -28,15 +28,11 @@ ghe-ssh "$host" -- "$comm" > enterprise.ghl if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then echo "* Transferring management console password ..." 1>&3 - manage_password_file="$GHE_REMOTE_DATA_USER_DIR/common/manage-password" - if echo "sudo cat '$manage_password_file' 2>/dev/null || true" | - ghe-ssh "$host" -- /bin/sh > manage-password+ - then - if [ -n "$(cat manage-password+)" ]; then - mv manage-password+ manage-password - fi + ghe-ssh "$host" -- ghe-config secrets.manage > manage-password+ + if [ -n "$(cat manage-password+)" ]; then + mv manage-password+ manage-password else - unlink manage-password+ + unlink manage-password+ fi if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index bcb453c1f..fc664283c 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -47,8 +47,8 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/en # Restore management console password hash if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/manage-password" ]; then echo "Restoring management console password ..." - cat "$GHE_RESTORE_SNAPSHOT_PATH/manage-password" | - ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-passwords" + echo "ghe-config secrets.manage '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/manage-password")'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash fi # Restore SAML keys if present. From 16fd63c09116498c5360479aaddb93c2ae682d34 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 22 Dec 2017 15:46:00 +0000 Subject: [PATCH 0365/2421] Update tests --- test/test-ghe-backup.sh | 6 +++--- test/test-ghe-restore.sh | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 84a9c44fe..3b6cc65ee 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -15,7 +15,7 @@ touch alice/index.html bob/index.html # Create a fake manage password file mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" -echo "fake password hash data" > "$GHE_REMOTE_DATA_USER_DIR/common/manage-password" +git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "fake password hash data" if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then # Create some fake data in the remote data directory @@ -416,11 +416,11 @@ begin_test "ghe-backup cleans up stale in-progress file" ) end_test -begin_test "ghe-backup without manage-password file" +begin_test "ghe-backup without management console password" ( set -e - unlink "$GHE_REMOTE_DATA_USER_DIR/common/manage-password" + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "" ghe-backup [ ! -f "$GHE_DATA_DIR/current/manage-password" ] diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 9ba4ebeb3..8f3b01fde 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -19,6 +19,10 @@ mkdir -p gh-enterprise-es/node/0 touch gh-enterprise-es/node/0/stuff1 touch gh-enterprise-es/node/0/stuff2 +# Set a temporary management console password +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" +git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "foobar" + if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then # Create some fake hookshot data in the remote data directory mkdir -p "$GHE_DATA_DIR/1/hookshot" @@ -81,7 +85,7 @@ echo "fake ghe-export-repositories data" > "$GHE_DATA_DIR/current/repositories.t echo "fake ghe-export-settings data" > "$GHE_DATA_DIR/current/settings.json" echo "fake ghe-export-ssl-ca-certificates data" > "$GHE_DATA_DIR/current/ssl-ca-certificates.tar" echo "fake license data" > "$GHE_DATA_DIR/current/enterprise.ghl" -echo "fake manage password hash data" > "$GHE_DATA_DIR/current/manage-password" +echo "fake password hash data" > "$GHE_DATA_DIR/current/manage-password" echo "rsync" > "$GHE_DATA_DIR/current/strategy" echo "$GHE_REMOTE_VERSION" > "$GHE_DATA_DIR/current/version" if [ "$GHE_VERSION_MAJOR" -eq 2 ]; then @@ -143,6 +147,9 @@ begin_test "ghe-restore into configured vm" diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + # verify management console password was *not* restored + ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" + # verify all hookshot user data was transferred diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" @@ -285,6 +292,9 @@ begin_test "ghe-restore -c into unconfigured vm" diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then + # verify management console password + grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" + # verify all hookshot user data was transferred diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" From c0a79025a61b7db545b626c6c576b2fac149a84f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 22 Dec 2017 15:46:15 +0000 Subject: [PATCH 0366/2421] Add placeholder ghe-config cmd --- test/bin/ghe-config | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 test/bin/ghe-config diff --git a/test/bin/ghe-config b/test/bin/ghe-config new file mode 100755 index 000000000..a26123c37 --- /dev/null +++ b/test/bin/ghe-config @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# Usage: ghe-config +# Emulates the remote GitHub ghe-config secrets.manage command. Tests use this +# to assert that the command was executed. +set -e +if [ $# -eq 1 ]; then + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" "$1" +else + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" "$1" "$2" +fi From 63816062e87f1242817db7025576acf002f2635b Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Sat, 6 Jan 2018 00:08:30 -0800 Subject: [PATCH 0367/2421] check for git before we multiplex --- bin/ghe-backup | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index dc3c62f2f..b20cfb49f 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -113,6 +113,9 @@ echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress echo "Starting backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP" +# Warn if git is not installed, and set GHE_DISABLE_SSH_MUX=true +command -v git >/dev/null 2>&1 || echo "Warning: SSH multiplexing requires git but it's not installed." && export GHE_DISABLE_SSH_MUX=true + # Perform a host connection check and establish the remote appliance version. # The version is available in the GHE_REMOTE_VERSION variable and also written # to a version file in the snapshot directory itself. From eeaee5fc8ed83f1487486906c49497f69d039a86 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 8 Jan 2018 11:48:49 +0000 Subject: [PATCH 0368/2421] Cleanup SSH multiplexing on exit --- bin/ghe-backup | 3 +++ bin/ghe-restore | 13 +++++++++++-- share/github-backup-utils/ghe-ssh | 15 ++++++++++++++- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index dc3c62f2f..0d2a27b9a 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -82,6 +82,9 @@ cleanup () { if $GHE_MAINTENANCE_MODE_ENABLED; then ghe-maintenance-mode-disable "$GHE_HOSTNAME" fi + + # Cleanup SSH multiplexing + ghe-ssh --clean "$GHE_HOSTNAME" } # Setup exit traps diff --git a/bin/ghe-restore b/bin/ghe-restore index b6d1d3fc7..6026ca16a 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -67,6 +67,15 @@ while true; do esac done +cleanup () { + if [ -n "$1" ]; then + update_restore_status "$1" + fi + + # Cleanup SSH multiplexing + ghe-ssh --clean "$GHE_HOSTNAME" +} + # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config @@ -205,7 +214,7 @@ update_restore_status () { } # Update remote restore state file and setup failure trap -trap "update_restore_status failed" EXIT +trap "cleanup failed" EXIT update_restore_status "restoring" # Verify the host has been fully configured at least once if when running @@ -414,7 +423,7 @@ fi # Update the remote status to "complete". This has to happen before importing # ssh host keys because subsequent commands will fail due to the host key # changing otherwise. -trap "" EXIT +trap "cleanup" EXIT update_restore_status "complete" # Log restore complete message in /var/log/syslog on remote instance diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index c7b836a9f..f0686c359 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -20,6 +20,10 @@ while true; do opts="$opts $1 $2" shift 2 ;; + -c|--clean) + cleanup_mux=1 + shift + ;; --) echo "Error: illegal '--' in ssh invocation" exit 1 @@ -70,4 +74,13 @@ fi $GHE_VERBOSE_SSH && set -x # Exec ssh command with modified host / port args and add nice to command. -exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" +if [ -z "$cleanup_mux" ]; then + # Exec ssh command with modified host / port args and add nice to command. + exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" +else + if [ -z "$GHE_DISABLE_SSH_MUX" ]; then + while ssh -O check -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1; do + ssh -O stop -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1 + done + fi +fi From 6d78c8def4ee12e0e9edf82999aeec90bbf8707d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 8 Jan 2018 11:49:04 +0000 Subject: [PATCH 0369/2421] Start implementing ShellCheck recommendations --- bin/ghe-backup | 5 +++-- bin/ghe-restore | 3 ++- share/github-backup-utils/ghe-ssh | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 0d2a27b9a..a667ad103 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -38,7 +38,8 @@ while true; do done # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" # Used to record failed backup steps failures= @@ -74,7 +75,7 @@ cleanup () { progress=$(cat ../in-progress) snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) - if [ "$snapshot" = "$GHE_SNAPSHOT_TIMESTAMP" -a "$$" = $pid ]; then + if [ "$snapshot" = "$GHE_SNAPSHOT_TIMESTAMP" ] && [ "$$" = $pid ]; then unlink ../in-progress fi fi diff --git a/bin/ghe-restore b/bin/ghe-restore index 6026ca16a..bbb75d53f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -77,7 +77,8 @@ cleanup () { } # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" # Grab the host arg GHE_HOSTNAME="${1:-$GHE_RESTORE_HOST}" diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index f0686c359..5321429cc 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" opts="$GHE_EXTRA_SSH_OPTS" while true; do From c40fb8b5a1449b3f299b3520d81168fc61d7382f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 8 Jan 2018 13:16:19 +0000 Subject: [PATCH 0370/2421] Add skip_test functionality --- test/test-ghe-restore.sh | 6 +++--- test/testlib.sh | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 8f3b01fde..32ec387db 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -648,7 +648,7 @@ begin_test "ghe-restore fails when restore to an active HA pair" if [ "$GHE_VERSION_MAJOR" -le 1 ]; then # noop GHE < 2.0, does not support replication - exit 0 + skip_test fi rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -691,7 +691,7 @@ begin_test "ghe-restore fails when restore 2.9/2.10 snapshot without audit log m # noop if not testing against 2.11 if [ "$GHE_VERSION_MAJOR" -le 1 ] || [ "$GHE_VERSION_MINOR" -ne 11 ]; then - exit 0 + skip_test fi rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -718,7 +718,7 @@ begin_test "ghe-restore force restore of 2.9/2.10 snapshot without audit log mig # noop if not testing against 2.11 if [ "$GHE_VERSION_MAJOR" -le 1 ] || [ "$GHE_VERSION_MINOR" -ne 11 ]; then - exit 0 + skip_test fi rm -rf "$GHE_REMOTE_ROOT_DIR" diff --git a/test/testlib.sh b/test/testlib.sh index 28910e403..cb92ee22b 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -158,8 +158,15 @@ end_test () { if [ "$test_status" -eq 0 ]; then printf "test: %-60s OK\n" "$test_description ..." + elif [ "$test_status" -eq 254 ]; then + printf "test: %-60s SKIPPED\n" "$test_description ..." else report_failure "FAILED" "$test_description ..." fi + unset test_description } + +skip_test() { + exit 254 +} From 83ab9e3f0f1ddd1d4f76ec34b1d1c9ae8a958b6b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 8 Jan 2018 14:46:46 +0000 Subject: [PATCH 0371/2421] Display correct output on failure --- script/cibuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 282e1bc2b..1476c3ff9 100755 --- a/script/cibuild +++ b/script/cibuild @@ -60,7 +60,7 @@ if script/package-deb 1>package-deb-out.txt 2>package-deb-err.txt; then pkg_files="$pkg_files $(cat package-deb-out.txt)" else echo "Package build failed:" - cat package-tarball.txt | sed 's/^/ /' 1>&2 + cat package-deb-out.txt package-deb-err.txt 1>&2 exit 1 fi From 2eb90bf93158974e1d32367e6abc933c8c88b67d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 8 Jan 2018 15:04:02 +0000 Subject: [PATCH 0372/2421] Display the deb build log on failure --- script/cibuild | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 1476c3ff9..39256df61 100755 --- a/script/cibuild +++ b/script/cibuild @@ -60,7 +60,9 @@ if script/package-deb 1>package-deb-out.txt 2>package-deb-err.txt; then pkg_files="$pkg_files $(cat package-deb-out.txt)" else echo "Package build failed:" - cat package-deb-out.txt package-deb-err.txt 1>&2 + cat package-deb-out.txt package-deb-err.txt >&2 + echo >&2 + cat dist/debuild/github-backup-utils*.build >&2 exit 1 fi From 9e85df8c33c12ade451384d1da989203d8c43b26 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 9 Jan 2018 14:10:44 +0000 Subject: [PATCH 0373/2421] Fix flaky ghe-detect-leaked-ssh-keys tests ... and implement more ShellCheck recommendations --- .../ghe-detect-leaked-ssh-keys | 15 ++++++++------- test/test-ghe-detect-leaked-ssh-keys.sh | 13 +++---------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 4287885ab..75b65a98f 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -45,9 +45,10 @@ if (ssh-keygen -E 2>&1 | head -1 | grep -q 'option requires an argument'); then fi # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -fingerprint_blacklist=$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/ghe-ssh-leaked-host-keys-list.txt") +FINGERPRINT_BLACKLIST="${FINGERPRINT_BLACKLIST:-$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/ghe-ssh-leaked-host-keys-list.txt")}" keys="ssh_host_dsa_key.pub ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub ssh_host_rsa_key.pub" @@ -71,16 +72,16 @@ leaked_keys_found=false current_bkup=false for tar_file in $ssh_tars; do for key in $keys; do - if $(tar -tvf "$tar_file" $key &>/dev/null); then + if tar -tvf "$tar_file" $key &>/dev/null; then tar -C $TEMPDIR -xvf "$tar_file" $key &>/dev/null if $sshkeygen_multiple_hash_formats; then fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f2- -d':') else fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) fi - if echo "$fingerprint_blacklist" | grep -q "$fingerprint"; then + if echo "$FINGERPRINT_BLACKLIST" | grep -q "$fingerprint"; then leaked_keys_found=true - if [ "$current_dir" == $(dirname "$tar_file") ]; then + if [ "$current_dir" == "$(dirname "$tar_file")" ]; then current_bkup=true echo "* Leaked key found in current backup snapshot." else @@ -124,8 +125,8 @@ if $leaked_keys_found; then echo "* (An upgrade may be required)" echo fi -else - echo "* No leaked keys found" +else + echo "* No leaked keys found" fi # Cleanup temp dir diff --git a/test/test-ghe-detect-leaked-ssh-keys.sh b/test/test-ghe-detect-leaked-ssh-keys.sh index c7e868548..c83a7daae 100644 --- a/test/test-ghe-detect-leaked-ssh-keys.sh +++ b/test/test-ghe-detect-leaked-ssh-keys.sh @@ -3,6 +3,7 @@ # Bring in testlib ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +# shellcheck source=test/testlib.sh . $ROOTDIR/test/testlib.sh # Add some fake repositories to the snapshot @@ -19,8 +20,6 @@ cat < "$GHE_DATA_DIR/ssh_host_dsa_key.pub" ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils EOF -SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) - begin_test "ghe-detect-leaked-ssh-keys check -h displays help message" ( set -e @@ -45,10 +44,7 @@ begin_test "ghe-detect-leaked-ssh-keys leaked keys in current backup" # Add custom key to tar file tar -cf "$GHE_DATA_DIR/1/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub - # Inject the fingerprint into the blacklist - echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" - - ghe-detect-leaked-ssh-keys -s "$GHE_DATA_DIR/1" | grep "Leaked key found in current backup snapshot" + FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" ghe-detect-leaked-ssh-keys -s "$GHE_DATA_DIR/1" | grep "Leaked key found in current backup snapshot" ) end_test @@ -59,10 +55,7 @@ begin_test "ghe-detect-leaked-ssh-keys leaked keys in old snapshot" # Add custom key to tar file in the older snapshot directory tar -cf "$GHE_DATA_DIR/2/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub - # Inject the fingerprint into the blacklist - echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" - - output=$(ghe-detect-leaked-ssh-keys -s "$GHE_DATA_DIR/2") + output=$(FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" ghe-detect-leaked-ssh-keys -s "$GHE_DATA_DIR/2") ! echo $output | grep -q "Leaked key in current backup" echo $output | grep -q "One or more older backup snapshots" ) From 96203228b51d8bc745da408cfa4682ec26a3ee3b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 10:17:55 +0000 Subject: [PATCH 0374/2421] Simplify cmd to get hostnames I'm pretty sure this will work in all cases where we need it, and cuts down on the forks and sshs giving us a free perf boost --- share/github-backup-utils/ghe-cluster-nodes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index 6b10f0c11..e0fae4c01 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -32,7 +32,7 @@ if ghe-ssh "$GHE_HOSTNAME" test -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid"; then hostnames+="$prefix-$uuid " done else - hostnames=$(echo "ghe-config --get-regexp cluster.*.$role | egrep 'true$' | awk '{ print \$1; }' | awk 'BEGIN { FS=\".\" }; { print \$2 };' | xargs -I{} -n1 bash -c 'if [ \"\$(ghe-config cluster.{}.offline)\" != true ]; then ghe-config cluster.{}.hostname; fi'" | ghe-ssh "$GHE_HOSTNAME" /bin/bash) + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -p) fi echo "$hostnames" From 0b0b432266e7da3b53a6f00d07166d7250e4b82c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 10:18:18 +0000 Subject: [PATCH 0375/2421] Aesthetics and words --- share/github-backup-utils/ghe-cluster-nodes | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index e0fae4c01..ac44fbdce 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -7,11 +7,11 @@ #/ Also filters nodes based on the prefix role. #/ #/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore-* commands when restoring into a cluster. +#/ ghe-backup-* and ghe-restore-* commands in cluster environments. set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Check if the REMOTE DATA USER directory is set if [ -z $GHE_REMOTE_DATA_USER_DIR ]; then @@ -21,6 +21,7 @@ fi # Show usage and bail with no arguments [ -z "$*" ] && print_usage + GHE_HOSTNAME="$1" prefix="$2" role=$(echo "$prefix" | cut -d '-' -f1) From cc5833aa637d03054a0bb99b316da7405566e560 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 11:19:10 +0000 Subject: [PATCH 0376/2421] Test old hostname response --- test/bin/git-uuids | 8 +++++++- test/test-ghe-cluster-nodes.sh | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/test/bin/git-uuids b/test/bin/git-uuids index 3229d9970..8d4bfc25e 100755 --- a/test/bin/git-uuids +++ b/test/bin/git-uuids @@ -3,6 +3,12 @@ # Emulates the remote GitHub ghe-config command. Tests use this # to assert that the command was executed. set -e -echo "05cbcd42-f519-11e6-b6c9-002bd51dfa77 +if [[ "$*" =~ "-p" ]]; then + echo "ghe-test-ha-primary +ghe-test-ha-replica +" +else + echo "05cbcd42-f519-11e6-b6c9-002bd51dfa77 08d94884-f519-11e6-88a1-0063a7c33551 " +fi diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index b42c2ae37..36791ba59 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -22,3 +22,17 @@ begin_test "ghe-cluster-nodes should return both uuids for git-server" [ "git-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 git-server-08d94884-f519-11e6-88a1-0063a7c33551 " = "$output" ] ) end_test + +# Test behaviour for pre-2.8 nodes +# Remove when 2.8 has been deprecated. +begin_test "ghe-cluster-nodes should return both hostnames for git-server" +( + set -e + + output="$(GHE_REMOTE_DATA_USER_DIR="/foobar" ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + echo "$output" + expected="ghe-test-ha-primary +ghe-test-ha-replica" + [ "$expected" = "$output" ] +) +end_test From 8a811d2c552a38e4f5e8a6f3aec4ca39b3a14600 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 11:35:36 +0000 Subject: [PATCH 0377/2421] Use ghe-cluster-nodes for alambic-ng backup [ci only enterprise2-cluster-migration] --- share/github-backup-utils/ghe-backup-alambic-cluster-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 6b90ca3e4..04db70f5e 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -34,7 +34,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # storage server hostnames -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir From 7416480cf39940417d52a9977edf91c095f4c247 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 12:15:28 +0000 Subject: [PATCH 0378/2421] Pull in fix from github/backup-utils/pull/364 We're failing in building the pkg and I can't tell why cos the wrong output is returned on failure. --- script/cibuild | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 282e1bc2b..39256df61 100755 --- a/script/cibuild +++ b/script/cibuild @@ -60,7 +60,9 @@ if script/package-deb 1>package-deb-out.txt 2>package-deb-err.txt; then pkg_files="$pkg_files $(cat package-deb-out.txt)" else echo "Package build failed:" - cat package-tarball.txt | sed 's/^/ /' 1>&2 + cat package-deb-out.txt package-deb-err.txt >&2 + echo >&2 + cat dist/debuild/github-backup-utils*.build >&2 exit 1 fi From da9aae61f47c30870edd1ee40fd3f5232d795893 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 13:43:35 +0000 Subject: [PATCH 0379/2421] Remove older versions to speed up testing We're hitting the 600s timeout on this testsuite now. --- script/cibuild | 2 -- 1 file changed, 2 deletions(-) diff --git a/script/cibuild b/script/cibuild index 39256df61..b57613136 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,8 +7,6 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 11.10.344 - 2.0.0 2.2.0 2.5.0 2.11.0 From a247c6fce0035309916a144b53be9298dde019c4 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 13:55:19 +0000 Subject: [PATCH 0380/2421] Revert "Remove older versions to speed up testing" This reverts commit da9aae61f47c30870edd1ee40fd3f5232d795893. --- script/cibuild | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/cibuild b/script/cibuild index b57613136..39256df61 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,6 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" + 11.10.344 + 2.0.0 2.2.0 2.5.0 2.11.0 From 3de146367024974828873f27100557b0c946fa71 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 13:56:28 +0000 Subject: [PATCH 0381/2421] Don't run tests when testing building deb pkg We've run them already. It's a complete waste of time running them all again. It also leads to a timeout. --- script/cibuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 39256df61..8302dc2e2 100755 --- a/script/cibuild +++ b/script/cibuild @@ -56,7 +56,7 @@ fi # Build the deb related packages echo "Building deb package ..." -if script/package-deb 1>package-deb-out.txt 2>package-deb-err.txt; then +if DEB_BUILD_OPTIONS=nocheck script/package-deb 1>package-deb-out.txt 2>package-deb-err.txt; then pkg_files="$pkg_files $(cat package-deb-out.txt)" else echo "Package build failed:" From 740b6d029dda5b55a7aa90ae65883133d0534eaf Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 14:06:38 +0000 Subject: [PATCH 0382/2421] Revert "Pull in fix from github/backup-utils/pull/364" This reverts commit 7416480cf39940417d52a9977edf91c095f4c247. Not needed as it didn't help us as the timeout was the cause. --- script/cibuild | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/script/cibuild b/script/cibuild index 8302dc2e2..c55679873 100755 --- a/script/cibuild +++ b/script/cibuild @@ -60,9 +60,7 @@ if DEB_BUILD_OPTIONS=nocheck script/package-deb 1>package-deb-out.txt 2>package- pkg_files="$pkg_files $(cat package-deb-out.txt)" else echo "Package build failed:" - cat package-deb-out.txt package-deb-err.txt >&2 - echo >&2 - cat dist/debuild/github-backup-utils*.build >&2 + cat package-tarball.txt | sed 's/^/ /' 1>&2 exit 1 fi From c4793769e03110dc1da641699383f35604f7c7d2 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 14:08:41 +0000 Subject: [PATCH 0383/2421] Remove unused test script --- test/bin/ghe-config-cluster-values | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100755 test/bin/ghe-config-cluster-values diff --git a/test/bin/ghe-config-cluster-values b/test/bin/ghe-config-cluster-values deleted file mode 100755 index 9d6b90866..000000000 --- a/test/bin/ghe-config-cluster-values +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -# Usage: ghe-config -# Emulates the remote GitHub ghe-config command. Tests use this -# to assert that the command was executed. -set -e -echo "cluster.ghe-test-ha-primary.uuid 05cbcd42-f519-11e6-b6c9-002bd51dfa77 -cluster.ghe-test-ha-replica.uuid 08d94884-f519-11e6-88a1-0063a7c33551 -cluster.ghe-test-ha-primary.git-server true -cluster.ghe-test-ha-primary.web-server true -cluster.ghe-test-ha-replica.git-server true" From 9fcd9549f39e471a829b97d1c0572c018b608c7b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 14:09:17 +0000 Subject: [PATCH 0384/2421] Remove symlink --- test/bin/ghe-cluster-each | 1 - 1 file changed, 1 deletion(-) delete mode 120000 test/bin/ghe-cluster-each diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each deleted file mode 120000 index d7adc1af7..000000000 --- a/test/bin/ghe-cluster-each +++ /dev/null @@ -1 +0,0 @@ -git-uuids \ No newline at end of file From ad73fb00483f32b62551a8adaba4747f0c75485b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 14:09:30 +0000 Subject: [PATCH 0385/2421] Call directly --- test/bin/{git-uuids => ghe-cluster-each} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/bin/{git-uuids => ghe-cluster-each} (100%) diff --git a/test/bin/git-uuids b/test/bin/ghe-cluster-each similarity index 100% rename from test/bin/git-uuids rename to test/bin/ghe-cluster-each From 93456f8050065f52ab481ce30f5aab5d7c40d735 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 11 Jan 2018 14:10:40 +0000 Subject: [PATCH 0386/2421] Add comments --- test/bin/ghe-cluster-each | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 8d4bfc25e..91eeb883d 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -3,11 +3,13 @@ # Emulates the remote GitHub ghe-config command. Tests use this # to assert that the command was executed. set -e +# Mimic `ghe-cluster-each $role -p` if [[ "$*" =~ "-p" ]]; then echo "ghe-test-ha-primary ghe-test-ha-replica " else + # Mimic `ghe-cluster-each $role -u` echo "05cbcd42-f519-11e6-b6c9-002bd51dfa77 08d94884-f519-11e6-88a1-0063a7c33551 " From efec90e07b213bd8f48b271ce08b94e4b5b8b941 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 15 Jan 2018 10:49:56 +0000 Subject: [PATCH 0387/2421] Simplify if/else/if --- share/github-backup-utils/ghe-ssh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 5321429cc..0b4f5312a 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -78,10 +78,8 @@ $GHE_VERBOSE_SSH && set -x if [ -z "$cleanup_mux" ]; then # Exec ssh command with modified host / port args and add nice to command. exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" -else - if [ -z "$GHE_DISABLE_SSH_MUX" ]; then - while ssh -O check -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1; do - ssh -O stop -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1 - done - fi +elif [ -z "$GHE_DISABLE_SSH_MUX" ]; then + while ssh -O check -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1; do + ssh -O stop -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1 + done fi From eee01a535274971755f63e946caf5770ff76c6ff Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 15 Jan 2018 17:05:50 +0000 Subject: [PATCH 0388/2421] Remove macOS and precise builds macOS is not officially supported and can spend many hours queuing to run. Local dev should be sufficient testing. Precise is dead and no longer receiving security updates. --- .travis.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c491f667..a2c812b91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,6 @@ --- matrix: include: - - os: osx - before_install: - - brew update - - brew install gnu-tar - - brew install moreutils - script: make test - - os: linux - dist: precise - sudo: required - addons: - apt: - packages: - - devscripts - - debhelper - - moreutils - - fakeroot - before_script: git fetch --unshallow - script: debuild -uc -us - os: linux dist: trusty sudo: required From 1a4cae6ce4a5953d230e30c76a90e217890aeb12 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Jan 2018 09:24:31 +0000 Subject: [PATCH 0389/2421] Put back macOS builds --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index a2c812b91..c5f10c6d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,12 @@ --- matrix: include: + - os: osx + before_install: + - brew update + - brew install gnu-tar + - brew install moreutils + script: make test - os: linux dist: trusty sudo: required From d57bd9d7abe62f44884ac4e60734405f8407d2a0 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Jan 2018 13:16:30 +0000 Subject: [PATCH 0390/2421] Filter cluster nodes by role --- script/cibuild | 2 +- .../ghe-backup-alambic-cluster | 2 +- .../ghe-backup-alambic-cluster-ng | 2 +- share/github-backup-utils/ghe-backup-config | 7 ---- .../ghe-backup-git-hooks-cluster | 2 +- .../ghe-backup-pages-cluster | 2 +- .../ghe-backup-repositories-cluster | 2 +- .../ghe-backup-repositories-cluster-ng | 2 +- .../github-backup-utils/ghe-cluster-hostnames | 31 --------------- share/github-backup-utils/ghe-cluster-nodes | 39 +++++++++++++++++++ .../ghe-restore-alambic-cluster-ng | 2 +- .../ghe-restore-git-hooks-cluster | 2 +- .../ghe-restore-pages-dpages | 2 +- .../ghe-restore-repositories-dgit | 2 +- .../ghe-restore-repositories-dgit-ng | 2 +- .../ghe-restore-repositories-gist | 2 +- .../ghe-restore-repositories-gist-ng | 2 +- test/bin/ghe-cluster-each | 16 ++++++++ test/test-ghe-cluster-nodes.sh | 38 ++++++++++++++++++ 19 files changed, 107 insertions(+), 52 deletions(-) delete mode 100755 share/github-backup-utils/ghe-cluster-hostnames create mode 100755 share/github-backup-utils/ghe-cluster-nodes create mode 100755 test/bin/ghe-cluster-each create mode 100755 test/test-ghe-cluster-nodes.sh diff --git a/script/cibuild b/script/cibuild index 39256df61..8302dc2e2 100755 --- a/script/cibuild +++ b/script/cibuild @@ -56,7 +56,7 @@ fi # Build the deb related packages echo "Building deb package ..." -if script/package-deb 1>package-deb-out.txt 2>package-deb-err.txt; then +if DEB_BUILD_OPTIONS=nocheck script/package-deb 1>package-deb-out.txt 2>package-deb-err.txt; then pkg_files="$pkg_files $(cat package-deb-out.txt)" else echo "Package build failed:" diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster b/share/github-backup-utils/ghe-backup-alambic-cluster index d924d080f..368ba034b 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster +++ b/share/github-backup-utils/ghe-backup-alambic-cluster @@ -33,7 +33,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # Alambic server hostnames -hostnames=$(ghe_cluster_online_nodes "storage-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 2f0452508..057f4e6b4 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -34,7 +34,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # storage server hostnames -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 9271ff320..a223337e7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -286,13 +286,6 @@ ghe_remote_logger () { ghe-ssh "$GHE_HOSTNAME" -- logger -t backup-utils || true } -# Usage: ghe_cluster_online_nodes role -# Returns the online nodes with a certain role in cluster -ghe_cluster_online_nodes () { - role=$1 - echo "ghe-config --get-regexp cluster.*.$role | egrep 'true$' | awk '{ print \$1; }' | awk 'BEGIN { FS=\".\" }; { print \$2 };' | xargs -I{} -n1 bash -c 'if [ \"\$(ghe-config cluster.{}.offline)\" != true ]; then ghe-config cluster.{}.hostname; fi'" | ghe-ssh "$GHE_HOSTNAME" /bin/bash -} - # Usage: ghe_verbose # Log if verbose mode is enabled (GHE_VERBOSE or `-v`). ghe_verbose() { diff --git a/share/github-backup-utils/ghe-backup-git-hooks-cluster b/share/github-backup-utils/ghe-backup-git-hooks-cluster index 6054c99bf..b633ed0a3 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks-cluster +++ b/share/github-backup-utils/ghe-backup-git-hooks-cluster @@ -35,7 +35,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # git server hostnames -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-backup-pages-cluster b/share/github-backup-utils/ghe-backup-pages-cluster index d773c700c..dc60d9e4a 100755 --- a/share/github-backup-utils/ghe-backup-pages-cluster +++ b/share/github-backup-utils/ghe-backup-pages-cluster @@ -33,7 +33,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # Pages server hostnames -hostnames=$(ghe_cluster_online_nodes "pages-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster b/share/github-backup-utils/ghe-backup-repositories-cluster index 28ff49ed1..bb62b8a48 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster +++ b/share/github-backup-utils/ghe-backup-repositories-cluster @@ -67,7 +67,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # git server hostnames -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index e9132ef8e..8cf1237b1 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -70,7 +70,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" # git server hostnames -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-cluster-hostnames b/share/github-backup-utils/ghe-cluster-hostnames deleted file mode 100755 index 32643d976..000000000 --- a/share/github-backup-utils/ghe-cluster-hostnames +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-cluster-hostnames -#/ -#/ Finds all nodes of the cluster using the config on . -#/ If it is a 2.8 cluster the results are returned as prefix-uuid, -#/ otherwise the configured hostnames are returned. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore-* commands when restoring into a cluster. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -GHE_HOSTNAME="$1" -prefix="$2" - -if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then - node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.uuid | cut -d ' ' -f 2) - hostnames='' - for uuid in $node_uuids; do - hostnames+="$prefix-$uuid " - done -else - hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) -fi - -echo "$hostnames" diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes new file mode 100755 index 000000000..ac44fbdce --- /dev/null +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +#/ Usage: ghe-cluster-nodes +#/ +#/ Finds all nodes of the cluster using the config on . +#/ If it is a 2.8 and later cluster version the results are returned as +#/ prefix-uuid, otherwise the configured hostnames are returned. +#/ Also filters nodes based on the prefix role. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-backup-* and ghe-restore-* commands in cluster environments. +set -e + +# Bring in the backup configuration +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Check if the REMOTE DATA USER directory is set +if [ -z $GHE_REMOTE_DATA_USER_DIR ]; then + echo "Env variable GHE_REMOTE_DATA_USER_DIR is not set. Exiting" + exit 1 +fi + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +GHE_HOSTNAME="$1" +prefix="$2" +role=$(echo "$prefix" | cut -d '-' -f1) + +if ghe-ssh "$GHE_HOSTNAME" test -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid"; then + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -u) + hostnames='' + for uuid in $node_uuids; do + hostnames+="$prefix-$uuid " + done +else + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -p) +fi + +echo "$hostnames" diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 86206e042..1bac460d0 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -42,7 +42,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "storage-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index df5a20748..df7514523 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -32,7 +32,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-restore-pages-dpages b/share/github-backup-utils/ghe-restore-pages-dpages index c4e7ac834..fbf6142f9 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages +++ b/share/github-backup-utils/ghe-restore-pages-dpages @@ -41,7 +41,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "pages-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit b/share/github-backup-utils/ghe-restore-repositories-dgit index d7c451a1f..c790b4cd1 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit +++ b/share/github-backup-utils/ghe-restore-repositories-dgit @@ -39,7 +39,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 8066b5660..0f5dccf65 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -74,7 +74,7 @@ tmp_list=$tempdir/tmp_list routes_list=$tempdir/routes_list to_restore=$tempdir/to_restore -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 3e66fb5c9..0beaee5fc 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -41,7 +41,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe_cluster_online_nodes "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index f1eab54b3..3015fb031 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -50,7 +50,7 @@ tmp_list=$tempdir/tmp_list routes_list=$tempdir/routes_list to_restore=$tempdir/to_restore -hostnames=$(ghe-cluster-hostnames "$GHE_HOSTNAME" "git-server") +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each new file mode 100755 index 000000000..91eeb883d --- /dev/null +++ b/test/bin/ghe-cluster-each @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Usage: ghe-config +# Emulates the remote GitHub ghe-config command. Tests use this +# to assert that the command was executed. +set -e +# Mimic `ghe-cluster-each $role -p` +if [[ "$*" =~ "-p" ]]; then + echo "ghe-test-ha-primary +ghe-test-ha-replica +" +else + # Mimic `ghe-cluster-each $role -u` + echo "05cbcd42-f519-11e6-b6c9-002bd51dfa77 +08d94884-f519-11e6-88a1-0063a7c33551 +" +fi diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh new file mode 100755 index 000000000..36791ba59 --- /dev/null +++ b/test/test-ghe-cluster-nodes.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# ghe-cluster-nodes command tests + +# Bring in testlib +. $(dirname "$0")/testlib.sh +# Setup backup snapshot data dir and remote repositories dir locations to use +# the per-test temp space. +GHE_DATA_DIR="$TRASHDIR/data" +GHE_REMOTE_DATA_DIR="$TRASHDIR/remote" +export GHE_DATA_DIR GHE_REMOTE_DATA_DIR +# Create a uuid file +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" +echo "fake uuids" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + +begin_test "ghe-cluster-nodes should return both uuids for git-server" +( + set -e + + + output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + echo "$output" + [ "git-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 git-server-08d94884-f519-11e6-88a1-0063a7c33551 " = "$output" ] +) +end_test + +# Test behaviour for pre-2.8 nodes +# Remove when 2.8 has been deprecated. +begin_test "ghe-cluster-nodes should return both hostnames for git-server" +( + set -e + + output="$(GHE_REMOTE_DATA_USER_DIR="/foobar" ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + echo "$output" + expected="ghe-test-ha-primary +ghe-test-ha-replica" + [ "$expected" = "$output" ] +) +end_test From defb6a83b5728cbd33d87a24f8b13ab3fb8401a3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 17 Jan 2018 17:03:38 +0000 Subject: [PATCH 0391/2421] Remove all pre-2.0 conditionals --- bin/ghe-backup | 94 +++++---------- bin/ghe-host-check | 12 +- bin/ghe-restore | 113 ++++++------------ share/github-backup-utils/ghe-backup-config | 9 +- .../ghe-backup-es-audit-log | 10 +- share/github-backup-utils/ghe-backup-es-rsync | 25 +--- share/github-backup-utils/ghe-backup-redis | 4 +- .../ghe-backup-redis-cluster | 6 +- share/github-backup-utils/ghe-backup-settings | 30 ++--- share/github-backup-utils/ghe-backup-strategy | 7 +- share/github-backup-utils/ghe-backup-userdata | 6 +- .../github-backup-utils/ghe-restore-es-rsync | 25 +--- .../github-backup-utils/ghe-restore-settings | 19 +-- .../github-backup-utils/ghe-restore-userdata | 4 +- 14 files changed, 101 insertions(+), 263 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 6af66b256..a27d3073c 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -56,11 +56,6 @@ mkdir -p "$GHE_SNAPSHOT_DIR" cd "$GHE_SNAPSHOT_DIR" touch "incomplete" -# This is toggled true once we've successfully re-enabled maintenance mode -# on the remote appliance. This is used to avoid trying to re-enable in the exit -# trap again on successful backup runs. -GHE_MAINTENANCE_MODE_ENABLED=false - # To prevent multiple backup runs happening at the same time, we create a # in-progress file with the timestamp and pid of the backup process, # giving us a form of locking. @@ -80,10 +75,6 @@ cleanup () { fi fi - if $GHE_MAINTENANCE_MODE_ENABLED; then - ghe-maintenance-mode-disable "$GHE_HOSTNAME" - fi - # Cleanup SSH multiplexing ghe-ssh --clean "$GHE_HOSTNAME" } @@ -134,13 +125,6 @@ export GHE_BACKUP_STRATEGY=${GHE_BACKUP_STRATEGY:-$(ghe-backup-strategy)} # Record the strategy with the snapshot so we will know how to restore. echo "$GHE_BACKUP_STRATEGY" > strategy -# If we're using the tarball backup strategy, put the appliance in maintenance -# mode and wait for all writing processes to bleed out. -if [ "$GHE_BACKUP_STRATEGY" = "tarball" ]; then - ghe-maintenance-mode-enable "$GHE_HOSTNAME" - GHE_MAINTENANCE_MODE_ENABLED=true -fi - # Create benchmark file bm_init > /dev/null @@ -179,15 +163,13 @@ else failures="$failures redis" fi -if [ $GHE_VERSION_MAJOR -ge 2 ]; then - echo "Backing up audit log ..." - ghe-backup-es-audit-log || - failures="$failures audit-log" +echo "Backing up audit log ..." +ghe-backup-es-audit-log || +failures="$failures audit-log" - echo "Backing up hookshot logs ..." - ghe-backup-es-hookshot || - failures="$failures hookshot" -fi +echo "Backing up hookshot logs ..." +ghe-backup-es-hookshot || +failures="$failures hookshot" echo "Backing up Git repositories ..." if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then @@ -207,37 +189,35 @@ echo "Backing up GitHub Pages ..." ghe-backup-pages-${GHE_BACKUP_STRATEGY} || failures="$failures pages" -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - echo "Backing up storage data ..." - if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/storage-cluster-backup-routes; then - ghe-backup-alambic-cluster-ng || failures="$failures alambic" - else - ghe-backup-alambic-cluster || failures="$failures alambic" - fi - - echo "Backing up custom Git hooks ..." - ghe-backup-git-hooks-cluster || - failures="$failures git-hooks" +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + echo "Backing up storage data ..." + if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/storage-cluster-backup-routes; then + ghe-backup-alambic-cluster-ng || failures="$failures alambic" else - echo "Backing up asset attachments ..." - ghe-backup-userdata alambic_assets || - failures="$failures alambic_assets" - - echo "Backing up storage data ..." - ghe-backup-userdata storage || - failures="$failures storage" - - echo "Backing up hook deliveries ..." - ghe-backup-userdata hookshot || - failures="$failures hookshot" - - echo "Backing up custom Git hooks ..." - ghe-backup-userdata git-hooks/environments/tarballs || - failures="$failures git-hooks-environments" - ghe-backup-userdata git-hooks/repos || - failures="$failures git-hooks-repos" + ghe-backup-alambic-cluster || failures="$failures alambic" fi + + echo "Backing up custom Git hooks ..." + ghe-backup-git-hooks-cluster || + failures="$failures git-hooks" +else + echo "Backing up asset attachments ..." + ghe-backup-userdata alambic_assets || + failures="$failures alambic_assets" + + echo "Backing up storage data ..." + ghe-backup-userdata storage || + failures="$failures storage" + + echo "Backing up hook deliveries ..." + ghe-backup-userdata hookshot || + failures="$failures hookshot" + + echo "Backing up custom Git hooks ..." + ghe-backup-userdata git-hooks/environments/tarballs || + failures="$failures git-hooks-environments" + ghe-backup-userdata git-hooks/repos || + failures="$failures git-hooks-repos" fi if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then @@ -246,14 +226,6 @@ if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then failures="$failures elasticsearch" fi -# If we're using the tarball backup strategy, bring the appliance out of -# maintenance mode now instead of waiting until after pruning stale snapshots. -if $GHE_MAINTENANCE_MODE_ENABLED; then - ghe-maintenance-mode-disable "$GHE_HOSTNAME" || - echo "Warning: Disabling maintenance mode on $GHE_HOSTNAME failed." - GHE_MAINTENANCE_MODE_ENABLED=false -fi - # git fsck repositories after the backup if [ "$GHE_BACKUP_FSCK" = "yes" ]; then ghe-backup-fsck $GHE_SNAPSHOT_DIR || diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 279e00700..6c83ea3ff 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -54,12 +54,6 @@ hostname=$(ssh_host_part "$host") set +e output=$(echo "ghe-negotiate-version backup-utils $BACKUP_UTILS_VERSION" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1) rc=$? -if [ $rc = 127 ]; then - # ghe-negotiate-version not found, fallback to reading version file - legacy_version_output="1" - output=$(echo "cat \"$GHE_REMOTE_METADATA_FILE\" 2>/dev/null || exit 101" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1) - rc=$? -fi set -e if [ $rc -ne 0 ]; then @@ -89,11 +83,7 @@ if [ $rc -ne 0 ]; then exit $rc fi -if [ -z "$legacy_version_output" ]; then - version=$(echo "$output" | sed -n 's/GitHub Enterprise version \(.*\)/\1/p') -else - version=$(echo "$output" | grep version | cut -d'"' -f4) -fi +version=$(echo "$output" | sed -n 's/GitHub Enterprise version \(.*\)/\1/p') if [ -z "$version" ]; then echo "Error: failed to parse version on '$host' or this isn't a GitHub appliance." 1>&2 diff --git a/bin/ghe-restore b/bin/ghe-restore index bbb75d53f..abcc696ff 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -108,9 +108,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Figure out if this instance has been configured or is entirely new. instance_configured=false -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_DATA_DIR/enterprise/dna.json' -o \ - -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then +if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then instance_configured=true elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then restore_settings=true @@ -203,14 +201,12 @@ ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNA # "failed" - restore has failed # "complete" - restore has completed successfully update_restore_status () { - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - if $cluster; then - echo "ghe-cluster-each -- \"echo '$1' | sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | - ghe-ssh "$GHE_HOSTNAME" /bin/bash - else - echo "$1" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" - fi + if $cluster; then + echo "ghe-cluster-each -- \"echo '$1' | sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | + ghe-ssh "$GHE_HOSTNAME" /bin/bash + else + echo "$1" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" fi } @@ -218,24 +214,6 @@ update_restore_status () { trap "cleanup failed" EXIT update_restore_status "restoring" -# Verify the host has been fully configured at least once if when running -# against v11.10.x appliances and the -c option wasn't specified. -if [ "$GHE_VERSION_MAJOR" -le 1 ] && ! $restore_settings && ! $instance_configured; then - echo "Error: $hostname not configured." 1>&2 - echo "Please visit https://$hostname/setup/settings to configure base appliance settings before continuing." 1>&2 - exit 1 -fi - -# Restoring Elasticsearch to 11.10.3x via rsync requires GNU tar -if [ "$GHE_VERSION_MAJOR" -le 1 ] && [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then - if ! tar --version | grep GNU >/dev/null; then - if ! command -v gtar >/dev/null 2>&1; then - echo "GNU tar is required. Aborting." >&2 - exit 1 - fi - fi -fi - # Make sure the GitHub appliance is in maintenance mode. if $instance_configured; then if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then @@ -251,27 +229,26 @@ ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - echo "Stopping cron and github-timerd ..." - if $cluster; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then - ghe_verbose "* Warning: Failed to stop cron on one or more nodes" - fi +echo "Stopping cron and github-timerd ..." +if $cluster; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron on one or more nodes" + fi - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" - fi - else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then - ghe_verbose "* Warning: Failed to stop cron" - fi + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + fi +else + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron" + fi - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd" - fi + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd" fi fi + # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. if $restore_settings; then @@ -282,10 +259,8 @@ fi # appliances v2.x or greater. These services will not have been started on appliances # that have not been configured yet. if ! $cluster; then - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - echo "sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 - fi + echo "sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi # Restore UUID if present and not restoring to cluster. @@ -322,10 +297,6 @@ if $cluster; then ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 fi else - # Remove temporary 2.2 storage migration directory if it exists - echo "if [ -d /data/user/repositories-nw-backup ]; then sudo rm -rf /data/user/repositories-nw-backup; fi" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 - echo "Restoring Git repositories ..." ghe-restore-repositories-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 fi @@ -353,7 +324,7 @@ if $cluster; then fi echo "Restoring custom Git hooks ..." ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 -elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then +else echo "Restoring asset attachments ..." ghe-restore-userdata alambic_assets "$GHE_HOSTNAME" 1>&3 @@ -386,11 +357,9 @@ if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then fi # Restart an already running memcached to reset the cache after restore -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - echo "Restarting memcached ..." 1>&3 - echo "sudo restart -q memcached 2>/dev/null || true" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh -fi +echo "Restarting memcached ..." 1>&3 +echo "sudo restart -q memcached 2>/dev/null || true" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. @@ -399,28 +368,22 @@ if $cluster; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then echo "Configuring storage ..." - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply --full" 1>&3 2>&3 - else - echo " This will take several minutes to complete..." - ghe-ssh "$GHE_HOSTNAME" -- "sudo enterprise-configure" 1>&3 2>&3 - fi + ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply --full" 1>&3 2>&3 fi # Start cron. Timerd will start automatically as part of the config run. -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - echo "Starting cron ..." - if $cluster; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then - echo "* Warning: Failed to start cron on one or more nodes" - fi - else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then - echo "* Warning: Failed to start cron" - fi +echo "Starting cron ..." +if $cluster; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then + echo "* Warning: Failed to start cron on one or more nodes" + fi +else + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then + echo "* Warning: Failed to start cron" fi fi + # Update the remote status to "complete". This has to happen before importing # ssh host keys because subsequent commands will fail due to the host key # changing otherwise. diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index a223337e7..dbe0c6520 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -247,20 +247,13 @@ ghe_remote_version_required () { # ghe_remote_version_required so shouldn't be used directly. # # Scripts use these variables to alter behavior based on what's supported on the -# appliance version. The version parts are modified somewhat to make dealing -# with the 11.10.x version scheme more sane. The "11.10" part of the remote -# version is normalized to "1.0" so "11.10.340" would have parts "1.0.340". +# appliance version. ghe_parse_remote_version () { GHE_VERSION_MAJOR=$(echo "${1#v}" | cut -f 1 -d .) GHE_VERSION_MINOR=$(echo "$1" | cut -f 2 -d .) GHE_VERSION_PATCH=$(echo "$1" | cut -f 3 -d .) GHE_VERSION_PATCH=${GHE_VERSION_PATCH%%[a-zA-Z]*} - if [ "$GHE_VERSION_MAJOR.$GHE_VERSION_MINOR" = "11.10" ]; then - GHE_VERSION_MAJOR=1 - GHE_VERSION_MINOR=0 - fi - export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH } diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 1c56ec343..ddc1a18f9 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -20,13 +20,7 @@ ghe_remote_version_required "$host" # Make sure root backup dir exists if this is the first run mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" -if [ $GHE_VERSION_MAJOR -ge 2 ] && [ $GHE_VERSION_MINOR -ge 2 ]; then - es_port=9201 -else - es_port=9200 -fi - -if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:$es_port/_cat/indices/audit_log*?h=index"\"); then +if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:9201/_cat/indices/audit_log*?h=index"\"); then echo "Error: failed to retrieve audit log indices." 1>&2 exit 1 fi @@ -46,7 +40,7 @@ for index in $indices; do ln $GHE_DATA_DIR/current/audit-log/$index.gz $GHE_SNAPSHOT_DIR/audit-log/$index.gz ln $GHE_DATA_DIR/current/audit-log/$index.gz.complete $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index.gz + ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index.gz if [[ ! $index =~ $current_index ]]; then touch $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete fi diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index e0820d14b..e0d244b07 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -32,40 +32,19 @@ if ! ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' ]"; then exit 0 fi -# Grab the elasticsearch.yml file which is root owned and mode -rw------- so -# can't be read via rsync or cat. We use the root allowed grep -F as a cat -# replacement. This is necessary on v11.10.x appliances only. -if [ "$GHE_VERSION_MAJOR" -lt 2 ]; then - echo "* Retrieving elasticsearch.yml config file ..." 1>&3 - ghe-ssh "$host" -- "sudo grep -F '' '$GHE_REMOTE_DATA_USER_DIR/elasticsearch/elasticsearch.yml'" \ - > "$GHE_SNAPSHOT_DIR/elasticsearch/elasticsearch.yml" - chmod 0600 "$GHE_SNAPSHOT_DIR/elasticsearch/elasticsearch.yml" -fi - # If we have a previous increment, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$GHE_DATA_DIR/current/elasticsearch" ]; then link_dest="--link-dest=../../current/elasticsearch" fi -# Determine which user to run the rsync operation under. This is the git user on -# v11.10.34x appliances and the elasticsearch user under >= v2.x appliances. -if [ "$GHE_VERSION_MAJOR" -eq 1 ]; then - rsync_user=git -elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - rsync_user=elasticsearch -else - echo "Error: invalid remote version: $GHE_REMOTE_VERSION" 1>&2 - exit 1 -fi - # Transfer ES indices from a GitHub instance to the current snapshot # directory, using a previous snapshot to avoid transferring files that have # already been transferred. echo "* Performing initial sync of ES indices ..." 1>&3 ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ - --rsync-path="sudo -u $rsync_user rsync" \ + --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ --exclude='elasticsearch.yml' \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ @@ -90,7 +69,7 @@ ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null echo "* Performing follow-up sync of ES indices ..." 1>&3 ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ - --rsync-path="sudo -u $rsync_user rsync" \ + --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ --exclude='elasticsearch.yml' \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index a01f99aa2..eb49a8b47 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -17,8 +17,6 @@ bm_start "$(basename $0)" ghe_remote_version_required "$GHE_HOSTNAME" # Force a redis BGSAVE, and wait for it to complete. -sudo= -[ "$GHE_VERSION_MAJOR" -ge 2 ] && sudo="sudo" ghe-ssh "$GHE_HOSTNAME" /bin/bash <&3 ghe-ssh "$host" -- 'ghe-export-settings' > settings.json echo "* Transferring license data ..." 1>&3 -comm="cat '$GHE_REMOTE_LICENSE_FILE'" -[ "$GHE_VERSION_MAJOR" -ge 2 ] && comm="sudo $comm" -ghe-ssh "$host" -- "$comm" > enterprise.ghl - -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - echo "* Transferring management console password ..." 1>&3 - ghe-ssh "$host" -- ghe-config secrets.manage > manage-password+ - if [ -n "$(cat manage-password+)" ]; then - mv manage-password+ manage-password - else - unlink manage-password+ - fi - - if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then - echo "* Transferring SAML keys ..." 1>&3 - ghe-ssh $host -- sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -cf - "idp.crt saml-sp.p12" > saml-keys.tar - fi +ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl + +echo "* Transferring management console password ..." 1>&3 +ghe-ssh "$host" -- ghe-config secrets.manage > manage-password+ +if [ -n "$(cat manage-password+)" ]; then + mv manage-password+ manage-password +else + unlink manage-password+ +fi + +if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then + echo "* Transferring SAML keys ..." 1>&3 + ghe-ssh $host -- sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -cf - "idp.crt saml-sp.p12" > saml-keys.tar fi if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates 1>/dev/null"; then diff --git a/share/github-backup-utils/ghe-backup-strategy b/share/github-backup-utils/ghe-backup-strategy index 7ddab5167..22d1ba029 100755 --- a/share/github-backup-utils/ghe-backup-strategy +++ b/share/github-backup-utils/ghe-backup-strategy @@ -3,9 +3,6 @@ #/ #/ Determine the backup strategy that will be used. #/ -#/ The tarball strategy must be used with GitHub Enterprise versions prior to -#/ 11.10.340 since rsync is not available. -#/ #/ The rsync strategy should be used for single VMs and all HA configurations. #/ #/ The cluster strategy should be used to backup GHE clusters. @@ -14,9 +11,7 @@ set -e # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config -if [ $GHE_VERSION_MAJOR -eq 1 -a $GHE_VERSION_PATCH -lt 340 ]; then - echo "tarball" -elif ghe-ssh "$GHE_HOSTNAME" -- \ +if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then echo "rsync" elif ghe-ssh "$GHE_HOSTNAME" -- \ diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata index 9944e39dc..9a8b7e923 100755 --- a/share/github-backup-utils/ghe-backup-userdata +++ b/share/github-backup-utils/ghe-backup-userdata @@ -25,11 +25,7 @@ ghe_remote_version_required "$host" # Verify that the user data directory exists. Bail out if not, which may be due # to an older version of GHE or no data has been added to this directory yet. -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - ghe-ssh "$host" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0 -else - ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0 -fi +ghe-ssh "$host" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0 # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index 7e276f92b..dd2a377e2 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -32,19 +32,7 @@ if [ ! -d "$snapshot_dir/elasticsearch" ]; then echo "Warning: Elasticsearch backup missing. Skipping ..." exit 0 -# restoring v11.10.x ES snapshot into a v2.0 appliance -elif [ "$GHE_VERSION_MAJOR" -gt 1 -a -f "$snapshot_dir/elasticsearch/elasticsearch.yml" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-legacy'" 1>&3 - ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-legacy'" 1>&3 - - ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u elasticsearch rsync" \ - "$snapshot_dir/elasticsearch/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-legacy" 1>&3 - -# restoring v2.0 ES snapshot into a v2.0 appliance -elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then +else ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 @@ -54,17 +42,6 @@ elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then --copy-dest="$GHE_REMOTE_DATA_USER_DIR/elasticsearch" \ "$snapshot_dir/elasticsearch/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 - -# restoring v11.10.x ES snapshot into a v11.10.x appliance -else - # Use GNU tar on BSDs. - TAR=tar - if ! tar --version | grep GNU >/dev/null; then - TAR=gtar - fi - cd "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" - $TAR -cf - --owner=root --group=root elasticsearch | - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-es-indices' 1>&3 fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index fc664283c..425aed12c 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -25,21 +25,10 @@ ghe_remote_version_required "$GHE_HOSTNAME" GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" echo "Restoring settings ..." -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - # work around issue importing settings with bad storage mode values - ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | - sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | - ghe-ssh "$GHE_HOSTNAME" -- '/usr/bin/env GHEBUVER=2 ghe-import-settings' 1>&3 -else - ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | - ghe-ssh "$GHE_HOSTNAME" -- '/usr/bin/env GHEBUVER=2 ghe-import-settings' 1>&3 -fi - -# Bail out if we're restoring against a pre-2.x appliance. Everything below is -# supported by v2.0 appliances only. -if [ "$GHE_VERSION_MAJOR" -lt 2 ]; then - exit 0 -fi +# work around issue importing settings with bad storage mode values +( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | + sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | + ghe-ssh "$GHE_HOSTNAME" -- '/usr/bin/env GHEBUVER=2 ghe-import-settings' 1>&3 echo "Restoring license ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 diff --git a/share/github-backup-utils/ghe-restore-userdata b/share/github-backup-utils/ghe-restore-userdata index 3c35b5497..81d93a604 100755 --- a/share/github-backup-utils/ghe-restore-userdata +++ b/share/github-backup-utils/ghe-restore-userdata @@ -34,9 +34,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" # rsync invocation. if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname" ]; then # Create the remote user data directory - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - ghe-ssh "$GHE_HOSTNAME" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname" - fi + ghe-ssh "$GHE_HOSTNAME" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname" ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ From 0c5d21b7b5766bb4724cbadc268a9bcd3e5eb5a1 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 17 Jan 2018 17:04:06 +0000 Subject: [PATCH 0392/2421] Remove commands no longer needed --- .../github-backup-utils/ghe-backup-es-tarball | 24 ----- .../ghe-backup-pages-tarball | 23 ----- .../ghe-backup-repositories-tarball | 17 ---- .../ghe-maintenance-mode-disable | 18 ---- .../ghe-maintenance-mode-enable | 87 ------------------- .../ghe-restore-es-tarball | 28 ------ .../ghe-restore-pages-tarball | 28 ------ .../ghe-restore-repositories-tarball | 28 ------ test/bin/ghe-export-es-audit-log | 1 - test/bin/ghe-export-es-indices | 1 - test/bin/ghe-export-pages | 1 - test/bin/ghe-export-repositories | 1 - test/bin/ghe-import-es-indices | 1 - test/bin/ghe-import-pages | 1 - test/bin/ghe-import-passwords | 1 - test/bin/ghe-import-repositories | 1 - 16 files changed, 261 deletions(-) delete mode 100755 share/github-backup-utils/ghe-backup-es-tarball delete mode 100755 share/github-backup-utils/ghe-backup-pages-tarball delete mode 100755 share/github-backup-utils/ghe-backup-repositories-tarball delete mode 100755 share/github-backup-utils/ghe-maintenance-mode-disable delete mode 100755 share/github-backup-utils/ghe-maintenance-mode-enable delete mode 100755 share/github-backup-utils/ghe-restore-es-tarball delete mode 100755 share/github-backup-utils/ghe-restore-pages-tarball delete mode 100755 share/github-backup-utils/ghe-restore-repositories-tarball delete mode 120000 test/bin/ghe-export-es-audit-log delete mode 120000 test/bin/ghe-export-es-indices delete mode 120000 test/bin/ghe-export-pages delete mode 120000 test/bin/ghe-export-repositories delete mode 120000 test/bin/ghe-import-es-indices delete mode 120000 test/bin/ghe-import-pages delete mode 120000 test/bin/ghe-import-passwords delete mode 120000 test/bin/ghe-import-repositories diff --git a/share/github-backup-utils/ghe-backup-es-tarball b/share/github-backup-utils/ghe-backup-es-tarball deleted file mode 100755 index 430d7986a..000000000 --- a/share/github-backup-utils/ghe-backup-es-tarball +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-es-tarball -#/ Take a tarball snapshot of all Elasticsearch data. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup when the tarball strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -bm_start "$(basename $0)" - -# Snapshot all Elasticsearch data or fake it when no /data/elasticsearch -# directory exists. -echo " - if [ -d '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' ]; then - ghe-export-es-indices - else - tar cvf - --files-from /dev/null - fi -" | ghe-ssh "$GHE_HOSTNAME" /bin/sh > "$GHE_SNAPSHOT_DIR"/elasticsearch.tar - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-pages-tarball b/share/github-backup-utils/ghe-backup-pages-tarball deleted file mode 100755 index f48fd7e7f..000000000 --- a/share/github-backup-utils/ghe-backup-pages-tarball +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-pages-tarball -#/ Take a tarball snapshot of all Pages data. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup command when the tarball strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -bm_start "$(basename $0)" - -# Snapshot all Pages data or fake it when no /data/pages directory exists. -echo ' - if [ -d /data/pages ]; then - ghe-export-pages - else - tar cvf - --files-from /dev/null - fi -' | ghe-ssh "$GHE_HOSTNAME" /bin/sh > "$GHE_SNAPSHOT_DIR"/pages.tar - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-repositories-tarball b/share/github-backup-utils/ghe-backup-repositories-tarball deleted file mode 100755 index 17472aa93..000000000 --- a/share/github-backup-utils/ghe-backup-repositories-tarball +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-repositories-tarball -#/ Take a tarball snapshot of all Git repository data. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup command when the tarball strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -bm_start "$(basename $0)" - -# Snapshot all Git repository data -ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-repositories' > "$GHE_SNAPSHOT_DIR"/repositories.tar - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-maintenance-mode-disable b/share/github-backup-utils/ghe-maintenance-mode-disable deleted file mode 100755 index b624746aa..000000000 --- a/share/github-backup-utils/ghe-maintenance-mode-disable +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-maintenance-mode-disable -#/ Disable maintenance mode on GitHub appliance at . This opens up access -#/ to the appliance. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -# Grab host arg -host="$1" - -# SSH to the appliance and run the remote maintenance mode enable command -echo "Disabling maintenance mode on $host ..." -ghe-ssh "$host" -- "ghe-maintenance -u" diff --git a/share/github-backup-utils/ghe-maintenance-mode-enable b/share/github-backup-utils/ghe-maintenance-mode-enable deleted file mode 100755 index ab56a70ab..000000000 --- a/share/github-backup-utils/ghe-maintenance-mode-enable +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-maintenance-mode-enable [-w] -#/ Enable maintenance mode on GitHub appliance at . This locks down all -#/ access to the appliance to prevent writes to datastores and waits for all -#/ currently running processes to bleed out. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Parse args -wait_procs=true -while true; do - case "$1" in - -n|--no-wait) - wait_procs=false - shift - ;; - -*) - echo "ghe-maintenance-mode-enable: illegal argument: $1" 1>&2 - exit 1 - ;; - *) - break - ;; - esac -done - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -# Grab host arg -host="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Never wait on processes to complete under versions >= 2.x. -# TODO need wait procs support under versions >= 2.x. -if [ "$GHE_VERSION_MAJOR" -gt 1 ]; then - wait_procs=false -fi - -# SSH to the appliance and run the remote maintenance mode enable command -echo "Enabling maintenance mode on $host ..." -ghe-ssh "$host" -- "/usr/bin/env GHEBUVER=2 ghe-maintenance -s" - -# Bail out early if --no-wait was given. -$wait_procs || exit 0 - -# Wait for all writing processes to complete -ghe-ssh "$host" -- /bin/sh < -#/ Restore a tarball snapshot of all ES data to a GitHub instance. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when the tarball strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Grab the host arg -GHE_HOSTNAME="$1" - -# Show usage and bail with no -[ -z "$GHE_HOSTNAME" ] && print_usage - -bm_start "$(basename $0)" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Restore Elasticsearch indices from tarball snapshot. -ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-es-indices' \ - < "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/elasticsearch.tar" 1>&3 - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-pages-tarball b/share/github-backup-utils/ghe-restore-pages-tarball deleted file mode 100755 index 35b16bd5d..000000000 --- a/share/github-backup-utils/ghe-restore-pages-tarball +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-pages-tarball -#/ Restore a tarball snapshot of all Pages data to a GitHub instance. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when the tarball strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Grab the host arg -GHE_HOSTNAME="$1" - -# Show usage and bail with no -[ -z "$GHE_HOSTNAME" ] && print_usage - -bm_start "$(basename $0)" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Restore Pages data from tarball snapshot. -ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-pages' \ - < "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages.tar" 1>&3 - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-repositories-tarball b/share/github-backup-utils/ghe-restore-repositories-tarball deleted file mode 100755 index 1d277dfad..000000000 --- a/share/github-backup-utils/ghe-restore-repositories-tarball +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-repositories-tarball -#/ Restore a tarball snapshot of all Git repository data to a GitHub instance. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when the tarball strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -bm_start "$(basename $0)" - -# Grab the host arg -GHE_HOSTNAME="$1" - -# Show usage and bail with no -[ -z "$GHE_HOSTNAME" ] && print_usage - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Restore Git repository data from tarball snapshot. -ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-repositories' \ - < "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories.tar" 1>&3 - -bm_end "$(basename $0)" diff --git a/test/bin/ghe-export-es-audit-log b/test/bin/ghe-export-es-audit-log deleted file mode 120000 index a772e4ad9..000000000 --- a/test/bin/ghe-export-es-audit-log +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-export-command \ No newline at end of file diff --git a/test/bin/ghe-export-es-indices b/test/bin/ghe-export-es-indices deleted file mode 120000 index a772e4ad9..000000000 --- a/test/bin/ghe-export-es-indices +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-export-command \ No newline at end of file diff --git a/test/bin/ghe-export-pages b/test/bin/ghe-export-pages deleted file mode 120000 index a772e4ad9..000000000 --- a/test/bin/ghe-export-pages +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-export-command \ No newline at end of file diff --git a/test/bin/ghe-export-repositories b/test/bin/ghe-export-repositories deleted file mode 120000 index a772e4ad9..000000000 --- a/test/bin/ghe-export-repositories +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-export-command \ No newline at end of file diff --git a/test/bin/ghe-import-es-indices b/test/bin/ghe-import-es-indices deleted file mode 120000 index bc329368a..000000000 --- a/test/bin/ghe-import-es-indices +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-import-command \ No newline at end of file diff --git a/test/bin/ghe-import-pages b/test/bin/ghe-import-pages deleted file mode 120000 index bc329368a..000000000 --- a/test/bin/ghe-import-pages +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-import-command \ No newline at end of file diff --git a/test/bin/ghe-import-passwords b/test/bin/ghe-import-passwords deleted file mode 120000 index bc329368a..000000000 --- a/test/bin/ghe-import-passwords +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-import-command \ No newline at end of file diff --git a/test/bin/ghe-import-repositories b/test/bin/ghe-import-repositories deleted file mode 120000 index bc329368a..000000000 --- a/test/bin/ghe-import-repositories +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-import-command \ No newline at end of file From 48875d431b67c307d42e7506324be1fa04cc64f2 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 17 Jan 2018 17:05:31 +0000 Subject: [PATCH 0393/2421] Remove pre-2.0 tests --- test/bin/ghe-negotiate-version | 7 + test/test-ghe-backup-config.sh | 31 -- test/test-ghe-backup-repositories-rsync-nw.sh | 0 test/test-ghe-backup.sh | 197 ++++------- test/test-ghe-restore.sh | 328 +++++++----------- test/testlib.sh | 2 +- 6 files changed, 206 insertions(+), 359 deletions(-) create mode 100755 test/bin/ghe-negotiate-version mode change 100644 => 100755 test/test-ghe-backup-repositories-rsync-nw.sh diff --git a/test/bin/ghe-negotiate-version b/test/bin/ghe-negotiate-version new file mode 100755 index 000000000..1cdbe8612 --- /dev/null +++ b/test/bin/ghe-negotiate-version @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# Usage: ghe-negotiate-version +# Emulates the remote GitHub ghe-negotiate-version command. Tests use this +# to assert that the command was executed. +set -e +echo "GitHub Enterprise version $GHE_TEST_REMOTE_VERSION" +echo "backup-utils $2 is supported." diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 925e5333d..ef63a9b53 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -94,37 +94,6 @@ begin_test "ghe-backup-config ssh_port_part" ) end_test -begin_test "ghe-backup-config ghe_parse_remote_version v11.10.x series" -( - set -e - - ghe_parse_remote_version "v11.10.343" - [ "$GHE_VERSION_MAJOR" = "1" ] - [ "$GHE_VERSION_MINOR" = "0" ] - [ "$GHE_VERSION_PATCH" = "343" ] - - ghe_parse_remote_version "11.10.343" - [ "$GHE_VERSION_MAJOR" = "1" ] - [ "$GHE_VERSION_MINOR" = "0" ] - [ "$GHE_VERSION_PATCH" = "343" ] - - ghe_parse_remote_version "v11.10.340.ldapfix1" - [ "$GHE_VERSION_MAJOR" = "1" ] - [ "$GHE_VERSION_MINOR" = "0" ] - [ "$GHE_VERSION_PATCH" = "340" ] - - ghe_parse_remote_version "v11.10.340pre" - [ "$GHE_VERSION_MAJOR" = "1" ] - [ "$GHE_VERSION_MINOR" = "0" ] - [ "$GHE_VERSION_PATCH" = "340" ] - - ghe_parse_remote_version "v11.10.12" - [ "$GHE_VERSION_MAJOR" = "1" ] - [ "$GHE_VERSION_MINOR" = "0" ] - [ "$GHE_VERSION_PATCH" = "12" ] -) -end_test - begin_test "ghe-backup-config ghe_parse_remote_version v2.x series" ( set -e diff --git a/test/test-ghe-backup-repositories-rsync-nw.sh b/test/test-ghe-backup-repositories-rsync-nw.sh old mode 100644 new mode 100755 diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 3b6cc65ee..b219bbd6a 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -17,42 +17,40 @@ touch alice/index.html bob/index.html mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "fake password hash data" -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - # Create some fake data in the remote data directory - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/hookshot" - cd "$GHE_REMOTE_DATA_USER_DIR/hookshot" - mkdir -p repository-123 repository-456 - touch repository-123/test.bpack repository-456/test.bpack +# Create some fake data in the remote data directory +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/hookshot" +cd "$GHE_REMOTE_DATA_USER_DIR/hookshot" +mkdir -p repository-123 repository-456 +touch repository-123/test.bpack repository-456/test.bpack - # Create some fake hooks in the remote data directory - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" +# Create some fake hooks in the remote data directory +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - mkdir -p 123/abcdef 456/fed314 - touch 123/abcdef/script.sh 456/fed314/foo.sh +cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" +mkdir -p 123/abcdef 456/fed314 +touch 123/abcdef/script.sh 456/fed314/foo.sh - cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - mkdir -p 123/abcdef 456/fed314 - touch 123/abcdef/script.tar.gz 456/fed314/foo.tar.gz +cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" +mkdir -p 123/abcdef 456/fed314 +touch 123/abcdef/script.tar.gz 456/fed314/foo.tar.gz - cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - mkdir -p 321 654 - touch 321/script.sh 654/foo.sh +cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" +mkdir -p 321 654 +touch 321/script.sh 654/foo.sh - # Create some fake alambic data in the remote data directory - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-assets/0000" - touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-assets/0000/test.png" +# Create some fake alambic data in the remote data directory +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-assets/0000" +touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-assets/0000/test.png" - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001" - touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001" +touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" - # Create a fake UUID - echo "fake uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" +# Create a fake UUID +echo "fake uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - # Create fake audit log migration sentinel file - touch "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" -fi +# Create fake audit log migration sentinel file +touch "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" # Create some fake elasticsearch data in the remote data directory mkdir -p "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" @@ -61,10 +59,6 @@ mkdir -p gh-enterprise-es/node/0 touch gh-enterprise-es/node/0/stuff1 touch gh-enterprise-es/node/0/stuff2 -if [ "$GHE_VERSION_MAJOR" -eq 1 ]; then - echo "fake ES yml file" > elasticsearch.yml -fi - # Create some test repositories in the remote repositories dir mkdir "$GHE_REMOTE_DATA_USER_DIR/repositories" cd "$GHE_REMOTE_DATA_USER_DIR/repositories" @@ -134,33 +128,31 @@ begin_test "ghe-backup first snapshot" diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" # verify manage-password file was backed up under v2.x VMs - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] + [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - # verify all hookshot user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" + # verify all hookshot user data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" - # verify all git hooks tarballs were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" + # verify all git hooks tarballs were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" - # verify the extracted environments were not transferred - ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" + # verify the extracted environments were not transferred + ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" - # verify the extracted repositories were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" + # verify the extracted repositories were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" + # verify all alambic assets user data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" - # verify the UUID was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" - # check that ca certificates were backed up - [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] - # verify the audit log migration sentinel file has been created - [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] - fi + # verify the audit log migration sentinel file has been created + [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] # verify that ghe-backup wrote its version information to the host [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] @@ -224,33 +216,31 @@ begin_test "ghe-backup subsequent snapshot" diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" # verify manage-password file was backed up under v2.x VMs - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] + [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - # verify all hookshot user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" + # verify all hookshot user data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" - # verify all git hooks tarballs were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" + # verify all git hooks tarballs were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" - # verify the extracted environments were not transferred - ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" + # verify the extracted environments were not transferred + ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" - # verify the extracted repositories were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" + # verify the extracted repositories were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" + # verify all alambic assets user data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" - # verify the UUID was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" - # check that ca certificates were backed up - [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] - # verify the audit log migration sentinel file has been created - [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] - fi + # verify the audit log migration sentinel file has been created + [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] ) end_test @@ -330,70 +320,37 @@ begin_test "ghe-backup with relative data dir path" diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" # verify manage-password file was backed up under v2.x VMs - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] + [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - # verify all hookshot user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" + # verify all hookshot user data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" - # verify all git hooks tarballs were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" + # verify all git hooks tarballs were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" - # verify the extracted environments were not transferred - ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" + # verify the extracted environments were not transferred + ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" - # verify the extracted repositories were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" + # verify the extracted repositories were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" + # verify all alambic assets user data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" - # verify the UUID was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" - # check that ca certificates were backed up - [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] - # verify the audit log migration sentinel file has been created - [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] - fi + # verify the audit log migration sentinel file has been created + [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] # verify that ghe-backup wrote its version information to the host [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] ) end_test -begin_test "ghe-backup tarball strategy" -( - set -e - - # wait a second for snapshot timestamp - sleep 1 - - # run backup with tarball strategy - GHE_BACKUP_STRATEGY="tarball" ghe-backup - - # check that the strategy file was written - [ -f "$GHE_DATA_DIR/current/strategy" ] - [ $(cat "$GHE_DATA_DIR/current/strategy") = "tarball" ] - - # check that repositories tarball exists - [ -f "$GHE_DATA_DIR/current/repositories.tar" ] - - # check repositories tarball data - [ "$(cat "$GHE_DATA_DIR/current/repositories.tar")" = "fake ghe-export-repositories data" ] - - # check ES tarball data. Supported under v1.x VMs only. - if [ "$GHE_VERSION_MAJOR" -eq 1 ]; then - [ "$(cat "$GHE_DATA_DIR/current/elasticsearch.tar")" = "fake ghe-export-es-indices data" ] - fi - - # check that repositories directory doesnt exist - [ ! -d "$GHE_DATA_DIR/current/repositories" ] - -) -end_test - begin_test "ghe-backup fails fast when old style run in progress" ( set -e diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 32ec387db..3f447b062 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -23,41 +23,39 @@ touch gh-enterprise-es/node/0/stuff2 mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "foobar" -if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - # Create some fake hookshot data in the remote data directory - mkdir -p "$GHE_DATA_DIR/1/hookshot" - cd "$GHE_DATA_DIR/1/hookshot" - mkdir -p repository-123 repository-456 - touch repository-123/test.bpack repository-456/test.bpack - - # Create some fake environments - mkdir -p "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" - cd "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" - mkdir -p 123 456 - touch 123/script.sh 456/foo.sh - cd 123 - tar -czf script.tar.gz script.sh - cd ../456 - tar -czf foo.tar.gz foo.sh - cd .. - rm 123/script.sh 456/foo.sh - mkdir -p "$GHE_DATA_DIR/1/git-hooks/repos/1" - touch "$GHE_DATA_DIR/1/git-hooks/repos/1/bar.sh" - - cd "$GHE_DATA_DIR/1/git-hooks/environments" - mkdir -p 123 456 - touch 123/script.sh 456/foo.sh - - # Create some fake alambic data in the remote data directory - mkdir -p "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-assets/0000" - touch "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-assets/0000/test.png" - - mkdir -p "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001" - touch "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" - - # Create a fake uuid - echo "fake uuid" > "$GHE_DATA_DIR/1/uuid" -fi +# Create some fake hookshot data in the remote data directory +mkdir -p "$GHE_DATA_DIR/1/hookshot" +cd "$GHE_DATA_DIR/1/hookshot" +mkdir -p repository-123 repository-456 +touch repository-123/test.bpack repository-456/test.bpack + +# Create some fake environments +mkdir -p "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" +cd "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" +mkdir -p 123 456 +touch 123/script.sh 456/foo.sh +cd 123 +tar -czf script.tar.gz script.sh +cd ../456 +tar -czf foo.tar.gz foo.sh +cd .. +rm 123/script.sh 456/foo.sh +mkdir -p "$GHE_DATA_DIR/1/git-hooks/repos/1" +touch "$GHE_DATA_DIR/1/git-hooks/repos/1/bar.sh" + +cd "$GHE_DATA_DIR/1/git-hooks/environments" +mkdir -p 123 456 +touch 123/script.sh 456/foo.sh + +# Create some fake alambic data in the remote data directory +mkdir -p "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-assets/0000" +touch "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-assets/0000/test.png" + +mkdir -p "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001" +touch "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" + +# Create a fake uuid +echo "fake uuid" > "$GHE_DATA_DIR/1/uuid" # Add some fake repositories to the snapshot mkdir -p "$GHE_DATA_DIR/1/repositories" @@ -75,22 +73,17 @@ done ln -s 1 "$GHE_DATA_DIR/current" # create a fake backups for each datastore -echo "fake ghe-export-pages data" > "$GHE_DATA_DIR/current/pages.tar" echo "fake ghe-export-mysql data" | gzip > "$GHE_DATA_DIR/current/mysql.sql.gz" echo "fake ghe-export-redis data" > "$GHE_DATA_DIR/current/redis.rdb" echo "fake ghe-export-authorized-keys data" > "$GHE_DATA_DIR/current/authorized-keys.json" -echo "fake ghe-export-es-indices data" > "$GHE_DATA_DIR/current/elasticsearch.tar" echo "fake ghe-export-ssh-host-keys data" > "$GHE_DATA_DIR/current/ssh-host-keys.tar" -echo "fake ghe-export-repositories data" > "$GHE_DATA_DIR/current/repositories.tar" echo "fake ghe-export-settings data" > "$GHE_DATA_DIR/current/settings.json" echo "fake ghe-export-ssl-ca-certificates data" > "$GHE_DATA_DIR/current/ssl-ca-certificates.tar" echo "fake license data" > "$GHE_DATA_DIR/current/enterprise.ghl" echo "fake password hash data" > "$GHE_DATA_DIR/current/manage-password" echo "rsync" > "$GHE_DATA_DIR/current/strategy" echo "$GHE_REMOTE_VERSION" > "$GHE_DATA_DIR/current/version" -if [ "$GHE_VERSION_MAJOR" -eq 2 ]; then - touch "$GHE_DATA_DIR/current/es-scan-complete" -fi +touch "$GHE_DATA_DIR/current/es-scan-complete" begin_test "ghe-restore into configured vm" ( @@ -99,11 +92,7 @@ begin_test "ghe-restore into configured vm" setup_remote_metadata # create file used to determine if instance has been configured. - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - touch "$GHE_REMOTE_DATA_DIR/enterprise/dna.json" - else - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - fi + touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" # create file used to determine if instance is in maintenance mode. mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" @@ -146,28 +135,26 @@ begin_test "ghe-restore into configured vm" # verify all pages data was transferred to the restore location diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - # verify management console password was *not* restored - ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" + # verify management console password was *not* restored + ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" - # verify all hookshot user data was transferred - diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" + # verify all hookshot user data was transferred + diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" - # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" + # verify all git hooks data was transferred + diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + # verify all alambic assets user data was transferred + diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" - # verify the UUID was transferred - diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] - fi + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] fi ) end_test @@ -190,11 +177,7 @@ begin_test "ghe-restore aborts without user verification" setup_remote_metadata # create file used to determine if instance has been configured. - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - touch "$GHE_REMOTE_DATA_DIR/enterprise/dna.json" - else - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - fi + touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" # create file used to determine if instance is in maintenance mode. mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" @@ -224,11 +207,7 @@ begin_test "ghe-restore accepts user verification" setup_remote_metadata # create file used to determine if instance has been configured. - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - touch "$GHE_REMOTE_DATA_DIR/enterprise/dna.json" - else - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - fi + touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" # create file used to determine if instance is in maintenance mode. mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" @@ -291,31 +270,29 @@ begin_test "ghe-restore -c into unconfigured vm" # verify all pages data was transferred to the restore location diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - # verify management console password - grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" + # verify management console password + grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" - # verify all hookshot user data was transferred - diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" + # verify all hookshot user data was transferred + diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" - # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" + # verify all git hooks data was transferred + diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + # verify all alambic assets user data was transferred + diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" - # verify the UUID was transferred - diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - # verify ghe-export-ssl-ca-certificates was run - grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" + # verify ghe-export-ssl-ca-certificates was run + grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] - fi + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] fi ) end_test @@ -337,63 +314,52 @@ begin_test "ghe-restore into unconfigured vm" # Create fake remote repositories dir mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - # run ghe-restore and write output to file for asserting against - # this should fail due to the appliance being in an unconfigured state - ! ghe-restore -v > "$TRASHDIR/restore-out" 2>&1 - - cat $TRASHDIR/restore-out - - # verify that ghe-restore failed due to the appliance not being configured - grep -q -e "Error: $GHE_RESTORE_HOST not configured" "$TRASHDIR/restore-out" - else - # under version >= 2.0, ghe-restore into an unconfigured vm implies -c - ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 - cat "$TRASHDIR/restore-out" + # ghe-restore into an unconfigured vm implies -c + ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 + cat "$TRASHDIR/restore-out" - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # verify all import scripts were run - grep -q "alice/index.html" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" + # verify all import scripts were run + grep -q "alice/index.html" "$TRASHDIR/restore-out" + grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" + grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" + grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" + grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" - # verify settings were imported - grep -q "fake ghe-export-settings data" "$TRASHDIR/restore-out" + # verify settings were imported + grep -q "fake ghe-export-settings data" "$TRASHDIR/restore-out" - # verify all repository data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/repositories" "$GHE_REMOTE_DATA_USER_DIR/repositories" + # verify all repository data was transferred to the restore location + diff -ru "$GHE_DATA_DIR/current/repositories" "$GHE_REMOTE_DATA_USER_DIR/repositories" - # verify all pages data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" + # verify all pages data was transferred to the restore location + diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - # verify all hookshot user data was transferred - diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" + # verify all hookshot user data was transferred + diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" - # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" + # verify all git hooks data was transferred + diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + # verify all alambic assets user data was transferred + diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" - # verify the UUID was transferred - diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - # verify ghe-export-ssl-ca-certificates was run - grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" + # verify ghe-export-ssl-ca-certificates was run + grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" - # verify no config run after restore on unconfigured instance - ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" + # verify no config run after restore on unconfigured instance + ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] - fi + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] fi ) end_test @@ -405,11 +371,7 @@ begin_test "ghe-restore with host arg" setup_remote_metadata # create file used to determine if instance has been configured. - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - touch "$GHE_REMOTE_DATA_DIR/enterprise/dna.json" - else - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - fi + touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" # create file used to determine if instance is in maintenance mode. mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" @@ -434,24 +396,22 @@ begin_test "ghe-restore with host arg" # verify all pages data was transferred to the restore location diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - # verify all hookshot user data was transferred - diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" + # verify all hookshot user data was transferred + diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" + diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" + # verify all alambic assets user data was transferred + diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" - # verify the UUID was transferred - diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] - fi + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] fi ) end_test @@ -463,11 +423,7 @@ begin_test "ghe-restore no host arg or configured restore host" setup_remote_metadata # create file used to determine if instance has been configured. - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - touch "$GHE_REMOTE_DATA_DIR/enterprise/dna.json" - else - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - fi + touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" # create file used to determine if instance is in maintenance mode. mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" @@ -491,11 +447,7 @@ begin_test "ghe-restore with no pages backup" setup_remote_metadata # create file used to determine if instance has been configured. - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - touch "$GHE_REMOTE_DATA_DIR/enterprise/dna.json" - else - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - fi + touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" # create file used to determine if instance is in maintenance mode. mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" @@ -512,35 +464,6 @@ begin_test "ghe-restore with no pages backup" ) end_test -begin_test "ghe-restore with tarball strategy" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # create file used to determine if instance has been configured. - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - touch "$GHE_REMOTE_DATA_DIR/enterprise/dna.json" - else - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - fi - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" - - # run it - echo "tarball" > "$GHE_DATA_DIR/current/strategy" - output=$(ghe-restore -v -f localhost) - - # verify ghe-import-repositories was run on remote side with fake tarball - echo "$output" | grep -q 'fake ghe-export-repositories data' -) -end_test - begin_test "ghe-restore with empty uuid file" ( set -e @@ -585,11 +508,7 @@ begin_test "ghe-restore cluster backup to non-cluster appliance" setup_remote_metadata # create file used to determine if instance has been configured. - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - touch "$GHE_REMOTE_DATA_DIR/enterprise/dna.json" - else - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - fi + touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" # create file used to determine if instance is in maintenance mode. mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" @@ -646,11 +565,6 @@ begin_test "ghe-restore fails when restore to an active HA pair" ( set -e - if [ "$GHE_VERSION_MAJOR" -le 1 ]; then - # noop GHE < 2.0, does not support replication - skip_test - fi - rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata @@ -690,7 +604,7 @@ begin_test "ghe-restore fails when restore 2.9/2.10 snapshot without audit log m set -e # noop if not testing against 2.11 - if [ "$GHE_VERSION_MAJOR" -le 1 ] || [ "$GHE_VERSION_MINOR" -ne 11 ]; then + if [ "$GHE_VERSION_MAJOR" -ne 2 ] && [ "$GHE_VERSION_MINOR" -ne 11 ]; then skip_test fi @@ -717,7 +631,7 @@ begin_test "ghe-restore force restore of 2.9/2.10 snapshot without audit log mig set -e # noop if not testing against 2.11 - if [ "$GHE_VERSION_MAJOR" -le 1 ] || [ "$GHE_VERSION_MINOR" -ne 11 ]; then + if [ "$GHE_VERSION_MAJOR" -ne 2 ] && [ "$GHE_VERSION_MINOR" -ne 11 ]; then skip_test fi diff --git a/test/testlib.sh b/test/testlib.sh index cb92ee22b..50e1bab6e 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=11.10.344} +: ${GHE_TEST_REMOTE_VERSION:=2.11.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 9a331345cb670abcff1fec2ddd2b00d47dab54b5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 17 Jan 2018 17:05:47 +0000 Subject: [PATCH 0394/2421] Fix sudo stripping in testing --- test/bin/ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bin/ssh b/test/bin/ssh index b31d730c2..efef37448 100755 --- a/test/bin/ssh +++ b/test/bin/ssh @@ -35,7 +35,7 @@ sh="$(echo "$@" | sed 's/sudo -u [a-z]* //g' | sed 's/sudo //g')" # Also scrub sudo commands from stdin if just executing /bin/sh or /bin/bash and # piping commands in on standard input. -if echo "$*" | grep -q "/bin/sh$\|/bin/bash$"; then +if echo "$*" | grep -Eq "/bin/(ba)?sh$"; then sed 's/sudo -u [a-z]* //g' | sed 's/sudo //g' | /bin/sh -c "$sh" else /bin/sh -c "$sh" From ffe537cf59d67cf3ddd2ba2af05bdc3b5618b769 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 17 Jan 2018 17:17:45 +0000 Subject: [PATCH 0395/2421] Remove tests for old repo layout ... and merge nw tests into remaining tests. --- test/test-ghe-backup-repositories-rsync-nw.sh | 132 ------------------ test/test-ghe-backup-repositories-rsync.sh | 52 +++---- 2 files changed, 28 insertions(+), 156 deletions(-) delete mode 100755 test/test-ghe-backup-repositories-rsync-nw.sh diff --git a/test/test-ghe-backup-repositories-rsync-nw.sh b/test/test-ghe-backup-repositories-rsync-nw.sh deleted file mode 100755 index 989c411e1..000000000 --- a/test/test-ghe-backup-repositories-rsync-nw.sh +++ /dev/null @@ -1,132 +0,0 @@ -#!/usr/bin/env bash -# ghe-backup-repositories-rsync-nw command tests -# uses the net-shard filesystem layout - -# Bring in testlib -. $(dirname "$0")/testlib.sh - -# Create the backup data dir and fake remote repositories dirs -mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR/repositories" -mkdir -p "$TRASHDIR/hooks" - -# Run under the remote repositories directory -cd "$GHE_REMOTE_DATA_USER_DIR/repositories" - -# Create some test repositories in the remote repositories dir - -repo1="0/nw/01/aa/3f/1234/1234.git" -repo2="0/nw/01/aa/3f/1234/1235.git" -repo3="1/nw/23/bb/4c/2345/2345.git" -mkdir -p "$repo1" "$repo2" "$repo3" - -wiki1="0/nw/01/aa/3f/1234/1234.wiki.git" -mkdir -p "$wiki1" - -gist1="0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git" -gist2="1/23/bb/4c/gist/1234.git" -mkdir -p "$gist1" "$gist2" - -# Initialize test repositories with a fake commit -for repo in $(find . -type d -name '*.git' -prune); do - git init -q --bare "$repo" - git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' - rm -rf "$repo/hooks" - ln -s "$TRASHDIR/hooks" "$repo/hooks" -done - -# Generate a packed-refs file in repo1 -git --git-dir="$repo1" pack-refs - -# Generate a pack in repo2 -git --git-dir="$repo2" repack -q - -# Add some fake svn data to repo3 -echo "fake svn history data" > "$repo3/svn.history.msgpack" -mkdir "$repo3/svn_data" -echo "fake property history data" > "$repo3/svn_data/property_history.msgpack" - -# Touch the info/nw-layout file, marking this as a net-shard fs -mkdir -p "info" -date "+%s" > info/nw-layout - -begin_test "ghe-backup-repositories-rsync first snapshot (nw)" -( - set -e - - # force snapshot number instead of generating a timestamp - GHE_SNAPSHOT_TIMESTAMP=1 - export GHE_SNAPSHOT_TIMESTAMP - - # run it - ghe-backup-repositories-rsync - - # check that repositories directory was created - [ -d "$GHE_DATA_DIR/1/repositories" ] - - # check that packed-refs file was transferred - [ -f "$GHE_DATA_DIR/1/repositories/$repo1/packed-refs" ] - - # check that a pack file was transferred - [ -f "$GHE_DATA_DIR"/1/repositories/$repo2/objects/pack/*.pack ] - - # check that svn data was transferred - [ -f "$GHE_DATA_DIR"/1/repositories/$repo3/svn.history.msgpack ] - [ -f "$GHE_DATA_DIR"/1/repositories/$repo3/svn_data/property_history.msgpack ] - - # verify all repository data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/1/repositories" -) -end_test - - -begin_test "ghe-backup-repositories-rsync subsequent snapshot (nw)" -( - set -e - - # force snapshot number instead of generating a timestamp - GHE_SNAPSHOT_TIMESTAMP=2 - export GHE_SNAPSHOT_TIMESTAMP - - # make current symlink point to previous increment - ln -s 1 "$GHE_DATA_DIR/current" - - # run it - ghe-backup-repositories-rsync - - # check that repositories directory was created - snapshot="$GHE_DATA_DIR/2/repositories" - [ -d "$snapshot" ] - - # verify hard links used for existing files - inode1=$(ls -i "$GHE_DATA_DIR/1/repositories/$repo1/packed-refs" | awk '{ print $1; }') - inode2=$(ls -i "$GHE_DATA_DIR/2/repositories/$repo1/packed-refs" | awk '{ print $1; }') - [ "$inode1" = "$inode2" ] - - # verify all repository data exists in the increment - diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/2/repositories" -) -end_test - - -begin_test "ghe-backup-repositories-rsync temp files (nw)" -( - set -e - - # force snapshot number instead of generating a timestamp - GHE_SNAPSHOT_TIMESTAMP=4 - export GHE_SNAPSHOT_TIMESTAMP - - # create a tmp pack to emulate a pack being written to - touch "$GHE_REMOTE_DATA_USER_DIR/repositories/$repo1/objects/pack/tmp_pack_1234" - - # run it - ghe-backup-repositories-rsync - - # check that repositories directory was created - snapshot="$GHE_DATA_DIR/4/repositories" - [ -d "$snapshot" ] - - # check that tmp pack was not transferred - [ ! -d "$snapshot/$repo1/objects/pack/tmp_pack_1234" ] -) -end_test diff --git a/test/test-ghe-backup-repositories-rsync.sh b/test/test-ghe-backup-repositories-rsync.sh index 8199dbbf5..5906ee5bf 100755 --- a/test/test-ghe-backup-repositories-rsync.sh +++ b/test/test-ghe-backup-repositories-rsync.sh @@ -8,13 +8,24 @@ mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR/repositories" mkdir -p "$TRASHDIR/hooks" -# Create some test repositories in the remote repositories dir +# Run under the remote repositories directory cd "$GHE_REMOTE_DATA_USER_DIR/repositories" -mkdir alice bob -mkdir alice/repo1.git alice/repo2.git bob/repo3.git + +# Create some test repositories in the remote repositories dir +repo1="0/nw/01/aa/3f/1234/1234.git" +repo2="0/nw/01/aa/3f/1234/1235.git" +repo3="1/nw/23/bb/4c/2345/2345.git" +mkdir -p "$repo1" "$repo2" "$repo3" + +wiki1="0/nw/01/aa/3f/1234/1234.wiki.git" +mkdir -p "$wiki1" + +gist1="0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git" +gist2="1/23/bb/4c/gist/1234.git" +mkdir -p "$gist1" "$gist2" # Initialize test repositories with a fake commit -for repo in */*.git; do +for repo in $(find . -type d -name '*.git' -prune); do git init -q --bare "$repo" git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' rm -rf "$repo/hooks" @@ -22,15 +33,15 @@ for repo in */*.git; do done # Generate a packed-refs file in repo1 -git --git-dir="alice/repo1.git" pack-refs +git --git-dir="$repo1" pack-refs # Generate a pack in repo2 -git --git-dir="alice/repo2.git" repack -q +git --git-dir="$repo2" repack -q # Add some fake svn data to repo3 -echo "fake svn history data" > bob/repo3.git/svn.history.msgpack -mkdir bob/repo3.git/svn_data -echo "fake property history data" > bob/repo3.git/svn_data/property_history.msgpack +echo "fake svn history data" > "$repo3/svn.history.msgpack" +mkdir "$repo3/svn_data" +echo "fake property history data" > "$repo3/svn_data/property_history.msgpack" begin_test "ghe-backup-repositories-rsync first snapshot" ( @@ -47,14 +58,14 @@ begin_test "ghe-backup-repositories-rsync first snapshot" [ -d "$GHE_DATA_DIR/1/repositories" ] # check that packed-refs file was transferred - [ -f "$GHE_DATA_DIR/1/repositories/alice/repo1.git/packed-refs" ] + [ -f "$GHE_DATA_DIR/1/repositories/$repo1/packed-refs" ] # check that a pack file was transferred - [ -f "$GHE_DATA_DIR"/1/repositories/alice/repo2.git/objects/pack/*.pack ] + [ -f "$GHE_DATA_DIR"/1/repositories/$repo2/objects/pack/*.pack ] # check that svn data was transferred - [ -f "$GHE_DATA_DIR"/1/repositories/bob/repo3.git/svn.history.msgpack ] - [ -f "$GHE_DATA_DIR"/1/repositories/bob/repo3.git/svn_data/property_history.msgpack ] + [ -f "$GHE_DATA_DIR"/1/repositories/$repo3/svn.history.msgpack ] + [ -f "$GHE_DATA_DIR"/1/repositories/$repo3/svn_data/property_history.msgpack ] # verify all repository data was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/1/repositories" @@ -81,8 +92,8 @@ begin_test "ghe-backup-repositories-rsync subsequent snapshot" [ -d "$snapshot" ] # verify hard links used for existing files - inode1=$(ls -i "$GHE_DATA_DIR/1/repositories/alice/repo1.git/packed-refs" | awk '{ print $1; }') - inode2=$(ls -i "$GHE_DATA_DIR/2/repositories/alice/repo1.git/packed-refs" | awk '{ print $1; }') + inode1=$(ls -i "$GHE_DATA_DIR/1/repositories/$repo1/packed-refs" | awk '{ print $1; }') + inode2=$(ls -i "$GHE_DATA_DIR/2/repositories/$repo1/packed-refs" | awk '{ print $1; }') [ "$inode1" = "$inode2" ] # verify all repository data exists in the increment @@ -99,10 +110,6 @@ begin_test "ghe-backup-repositories-rsync __special__ dirs" GHE_SNAPSHOT_TIMESTAMP=3 export GHE_SNAPSHOT_TIMESTAMP - # create the excluded __nodeload_archives__ dir on the remote side - mkdir "$GHE_REMOTE_DATA_USER_DIR/repositories/__nodeload_archives__" - touch "$GHE_REMOTE_DATA_USER_DIR/repositories/__nodeload_archives__/something.tar.gz" - # create the included __purgatory__ dir on the remote side mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories/__purgatory__/123.git" git init --bare -q "$GHE_REMOTE_DATA_USER_DIR/repositories/__purgatory__/123.git" @@ -116,9 +123,6 @@ begin_test "ghe-backup-repositories-rsync __special__ dirs" snapshot="$GHE_DATA_DIR/3/repositories" [ -d "$snapshot" ] - # check that excluded special dir was not transferred - [ ! -d "$snapshot/__nodeload_archives__" ] - # check that included special dir was not transferred [ -d "$snapshot/__purgatory__" ] @@ -139,7 +143,7 @@ begin_test "ghe-backup-repositories-rsync temp files" export GHE_SNAPSHOT_TIMESTAMP # create a tmp pack to emulate a pack being written to - touch "$GHE_REMOTE_DATA_USER_DIR/repositories/alice/repo1.git/objects/pack/tmp_pack_1234" + touch "$GHE_REMOTE_DATA_USER_DIR/repositories/$repo1/objects/pack/tmp_pack_1234" # run it ghe-backup-repositories-rsync @@ -149,6 +153,6 @@ begin_test "ghe-backup-repositories-rsync temp files" [ -d "$snapshot" ] # check that tmp pack was not transferred - [ ! -d "$snapshot/alice/repo1.git/objects/pack/tmp_pack_1234" ] + [ ! -d "$snapshot/$repo1/objects/pack/tmp_pack_1234" ] ) end_test From 78ce66f449551795b4929a3e295dbe67c8c00aa7 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 17 Jan 2018 17:41:46 +0000 Subject: [PATCH 0396/2421] Update tests for modern layouts --- test/test-ghe-restore.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 3f447b062..8876b1cca 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -8,13 +8,14 @@ ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" # Add some fake pages data to the snapshot mkdir -p "$GHE_DATA_DIR/1/pages" cd "$GHE_DATA_DIR/1/pages" -mkdir -p alice bob -touch alice/index.html bob/index.html +pages1="4/c8/1e/72/2/legacy" +pages2="4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96" +mkdir -p "$pages1" "$pages2" +touch "$pages1/index.html" "$pages2/index.html" # Add some fake elasticsearch data to the snapshot mkdir -p "$GHE_DATA_DIR/1/elasticsearch" cd "$GHE_DATA_DIR/1/elasticsearch" -echo "fake ES yml file" > elasticsearch.yml mkdir -p gh-enterprise-es/node/0 touch gh-enterprise-es/node/0/stuff1 touch gh-enterprise-es/node/0/stuff2 @@ -59,16 +60,33 @@ echo "fake uuid" > "$GHE_DATA_DIR/1/uuid" # Add some fake repositories to the snapshot mkdir -p "$GHE_DATA_DIR/1/repositories" +mkdir -p "$TRASHDIR/hooks" cd "$GHE_DATA_DIR/1/repositories" -mkdir alice bob -mkdir alice/repo1.git alice/repo2.git bob/repo3.git +repo1="0/nw/01/aa/3f/1234/1234.git" +repo2="0/nw/01/aa/3f/1234/1235.git" +repo3="1/nw/23/bb/4c/2345/2345.git" +mkdir -p "$repo1" "$repo2" "$repo3" + +wiki1="0/nw/01/aa/3f/1234/1234.wiki.git" +mkdir -p "$wiki1" + +gist1="0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git" +gist2="1/23/bb/4c/gist/1234.git" +mkdir -p "$gist1" "$gist2" # Initialize test repositories with a fake commit -for repo in */*.git; do +for repo in $(find . -type d -name '*.git' -prune); do git init -q --bare "$repo" git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' + rm -rf "$repo/hooks" + ln -s "$TRASHDIR/hooks" "$repo/hooks" done +# Add some fake svn data to repo3 +echo "fake svn history data" > "$repo3/svn.history.msgpack" +mkdir "$repo3/svn_data" +echo "fake property history data" > "$repo3/svn_data/property_history.msgpack" + # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" @@ -119,7 +137,7 @@ begin_test "ghe-restore into configured vm" grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" # verify all import scripts were run - grep -q "alice/index.html" "$TRASHDIR/restore-out" + grep -q "$pages1/index.html" "$TRASHDIR/restore-out" grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" @@ -255,7 +273,7 @@ begin_test "ghe-restore -c into unconfigured vm" grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" # verify all import scripts were run - grep -q "alice/index.html" "$TRASHDIR/restore-out" + grep -q "$pages1/index.html" "$TRASHDIR/restore-out" grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" @@ -322,7 +340,7 @@ begin_test "ghe-restore into unconfigured vm" grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" # verify all import scripts were run - grep -q "alice/index.html" "$TRASHDIR/restore-out" + grep -q "$pages1/index.html" "$TRASHDIR/restore-out" grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" From dc590124951be9399856dfee5b9024d8cf57144c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 17 Jan 2018 17:47:32 +0000 Subject: [PATCH 0397/2421] Cleanly handle if docker is installed but not running --- test/test-docker-build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 11c62ed52..54a057025 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -3,8 +3,8 @@ # If docker is not installed, skip the whole docker test # Travis CI does not currently support docker on OSX (https://docs.travis-ci.com/user/docker/) -if ! hash docker 2>/dev/null; then - echo "Docker is not installed on this host" +if ! docker ps >/dev/null 2>&1; then + echo "Docker is not installed or running on this host" exit 0 fi From 5a7797580df7353c4bf0d0bd4670dac7efced481 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 17 Jan 2018 17:48:10 +0000 Subject: [PATCH 0398/2421] Set exec perms --- test/test-ghe-detect-leaked-ssh-keys.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/test-ghe-detect-leaked-ssh-keys.sh diff --git a/test/test-ghe-detect-leaked-ssh-keys.sh b/test/test-ghe-detect-leaked-ssh-keys.sh old mode 100644 new mode 100755 From d8239969e290516f61389b27cf62de987a01c81f Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Wed, 17 Jan 2018 15:20:27 -0700 Subject: [PATCH 0399/2421] Note requirement for OpenSSH 4.2+ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99313f0a2..be52b8061 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ storage and must have network connectivity with the GitHub Enterprise appliance. ##### Backup host requirements Backup host software requirements are modest: Linux or other modern Unix -operating system with [bash][13], [git][14], [OpenSSH][15], and [rsync][4] v2.6.4 or newer. +operating system with [bash][13], [git][14], [OpenSSH][15] 4.2 or newer, and [rsync][4] v2.6.4 or newer. The backup host must be able to establish network connections outbound to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise 2.0 From 728e91c779d680b8f27b3aabd6f1ff3d7875f4ea Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 18 Jan 2018 10:56:13 +0000 Subject: [PATCH 0400/2421] Resolve ShellCheck errors in tests Info/warnings are ignored for the moment. --- test/test-docker-build.sh | 3 ++- test/test-ghe-backup-config.sh | 23 ++++++++++++---------- test/test-ghe-backup-repositories-rsync.sh | 19 ++++++++++-------- test/test-ghe-backup.sh | 20 ++++++++++--------- test/test-ghe-cluster-nodes.sh | 4 +++- test/test-ghe-detect-leaked-ssh-keys.sh | 3 +-- test/test-ghe-host-check.sh | 3 ++- test/test-ghe-prune-snapshots.sh | 15 +++++++------- test/test-ghe-restore.sh | 20 +++++++++---------- test/test-ghe-ssh.sh | 5 +++-- test/testlib.sh | 12 ++++++----- 11 files changed, 71 insertions(+), 56 deletions(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 54a057025..4d2e3a0cb 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -9,7 +9,8 @@ if ! docker ps >/dev/null 2>&1; then fi # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index ef63a9b53..0e2ab258a 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -2,7 +2,8 @@ # ghe-backup-config lib tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Setup backup snapshot data dir and remote repositories dir locations to use @@ -18,7 +19,9 @@ cd "$ROOTDIR" begin_test "ghe-backup-config GHE_DATA_DIR defined" ( set +e - GHE_DATA_DIR= error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + # shellcheck disable=SC2030 + GHE_DATA_DIR= + error=$(. share/github-backup-utils/ghe-backup-config 2>&1) # should exit 2 if [ $? != 2 ]; then exit 1 @@ -77,20 +80,20 @@ end_test begin_test "ghe-backup-config ssh_host_part" ( set -e - [ $(ssh_host_part "github.example.com") = "github.example.com" ] - [ $(ssh_host_part "github.example.com:22") = "github.example.com" ] - [ $(ssh_host_part "github.example.com:5000") = "github.example.com" ] - [ $(ssh_host_part "git@github.example.com:5000") = "git@github.example.com" ] + [ "$(ssh_host_part "github.example.com")" = "github.example.com" ] + [ "$(ssh_host_part "github.example.com:22")" = "github.example.com" ] + [ "$(ssh_host_part "github.example.com:5000")" = "github.example.com" ] + [ "$(ssh_host_part "git@github.example.com:5000")" = "git@github.example.com" ] ) end_test begin_test "ghe-backup-config ssh_port_part" ( set -e - [ $(ssh_port_part "github.example.com") = "22" ] - [ $(ssh_port_part "github.example.com:22") = "22" ] - [ $(ssh_port_part "github.example.com:5000") = "5000" ] - [ $(ssh_port_part "git@github.example.com:5000") = "5000" ] + [ "$(ssh_port_part "github.example.com")" = "22" ] + [ "$(ssh_port_part "github.example.com:22")" = "22" ] + [ "$(ssh_port_part "github.example.com:5000")" = "5000" ] + [ "$(ssh_port_part "git@github.example.com:5000")" = "5000" ] ) end_test diff --git a/test/test-ghe-backup-repositories-rsync.sh b/test/test-ghe-backup-repositories-rsync.sh index 5906ee5bf..acfa8067a 100755 --- a/test/test-ghe-backup-repositories-rsync.sh +++ b/test/test-ghe-backup-repositories-rsync.sh @@ -2,7 +2,8 @@ # ghe-backup-repositories-rsync command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Create the backup data dir and fake remote repositories dirs mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR/repositories" @@ -25,12 +26,12 @@ gist2="1/23/bb/4c/gist/1234.git" mkdir -p "$gist1" "$gist2" # Initialize test repositories with a fake commit -for repo in $(find . -type d -name '*.git' -prune); do - git init -q --bare "$repo" - git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' - rm -rf "$repo/hooks" - ln -s "$TRASHDIR/hooks" "$repo/hooks" -done +while IFS= read -r -d '' repo; do + git init -q --bare "$repo" + git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' + rm -rf "$repo/hooks" + ln -s "$TRASHDIR/hooks" "$repo/hooks" +done < <(find . -type d -name '*.git' -prune -print0) # Generate a packed-refs file in repo1 git --git-dir="$repo1" pack-refs @@ -61,7 +62,9 @@ begin_test "ghe-backup-repositories-rsync first snapshot" [ -f "$GHE_DATA_DIR/1/repositories/$repo1/packed-refs" ] # check that a pack file was transferred - [ -f "$GHE_DATA_DIR"/1/repositories/$repo2/objects/pack/*.pack ] + for packfile in $GHE_DATA_DIR/1/repositories/$repo2/objects/pack/*.pack; do + [ -f "$packfile" ] + done # check that svn data was transferred [ -f "$GHE_DATA_DIR"/1/repositories/$repo3/svn.history.msgpack ] diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index b219bbd6a..b50e4e8f5 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -2,7 +2,8 @@ # ghe-backup command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Create the backup data dir and fake remote repositories dirs mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" @@ -88,11 +89,11 @@ begin_test "ghe-backup first snapshot" # check that the version file was written [ -f "$GHE_DATA_DIR/current/version" ] - [ $(cat "$GHE_DATA_DIR/current/version") = "v$GHE_TEST_REMOTE_VERSION" ] + [ "$(cat "$GHE_DATA_DIR/current/version")" = "v$GHE_TEST_REMOTE_VERSION" ] # check that the strategy file was written [ -f "$GHE_DATA_DIR/current/strategy" ] - [ $(cat "$GHE_DATA_DIR/current/strategy") = "rsync" ] + [ "$(cat "$GHE_DATA_DIR/current/strategy")" = "rsync" ] # check that settings were backed up [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] @@ -255,7 +256,7 @@ begin_test "ghe-backup logs the benchmark" ghe-backup - [ $(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l) -gt 1 ] + [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] ) end_test @@ -267,7 +268,8 @@ begin_test "ghe-backup with relative data dir path" sleep 1 # generate a timestamp - export GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" + GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" + export GHE_SNAPSHOT_TIMESTAMP # change working directory to the root directory cd $ROOTDIR @@ -276,15 +278,15 @@ begin_test "ghe-backup with relative data dir path" GHE_DATA_DIR=$(echo $GHE_DATA_DIR | sed 's|'$ROOTDIR'/||') ghe-backup # check that current symlink points to new snapshot - ls -ld "$GHE_DATA_DIR/current" | grep -q "$GHE_SNAPSHOT_TIMESTAMP" + [ "$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.*-> //')" = "$GHE_SNAPSHOT_TIMESTAMP" ] # check that the version file was written [ -f "$GHE_DATA_DIR/current/version" ] - [ $(cat "$GHE_DATA_DIR/current/version") = "v$GHE_TEST_REMOTE_VERSION" ] + [ "$(cat "$GHE_DATA_DIR/current/version")" = "v$GHE_TEST_REMOTE_VERSION" ] # check that the strategy file was written [ -f "$GHE_DATA_DIR/current/strategy" ] - [ $(cat "$GHE_DATA_DIR/current/strategy") = "rsync" ] + [ "$(cat "$GHE_DATA_DIR/current/strategy")" = "rsync" ] # check that settings were backed up [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] @@ -453,7 +455,7 @@ begin_test "ghe-backup with leaked SSH host key detection for current backup" ( set -e - SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) + SHARED_UTILS_PATH=$(dirname "$(which ghe-detect-leaked-ssh-keys)") # Inject the fingerprint into the blacklist echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index 36791ba59..7b7a2c141 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -2,7 +2,9 @@ # ghe-cluster-nodes command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" + # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. GHE_DATA_DIR="$TRASHDIR/data" diff --git a/test/test-ghe-detect-leaked-ssh-keys.sh b/test/test-ghe-detect-leaked-ssh-keys.sh index c83a7daae..c5f02e711 100755 --- a/test/test-ghe-detect-leaked-ssh-keys.sh +++ b/test/test-ghe-detect-leaked-ssh-keys.sh @@ -2,9 +2,8 @@ # ghe-detect-leaked-ssh-keys command tests # Bring in testlib -ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" # shellcheck source=test/testlib.sh -. $ROOTDIR/test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Add some fake repositories to the snapshot mkdir -p "$GHE_DATA_DIR/1" diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 4e1e36770..8ced6b09b 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -2,7 +2,8 @@ # ghe-host-check command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" begin_test "ghe-host-check" ( diff --git a/test/test-ghe-prune-snapshots.sh b/test/test-ghe-prune-snapshots.sh index 0194504c9..50e07e350 100755 --- a/test/test-ghe-prune-snapshots.sh +++ b/test/test-ghe-prune-snapshots.sh @@ -2,11 +2,12 @@ # ghe-prune-snapshots command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # helper for generating dirs to clean up generate_prune_files() { - rm -rf "$GHE_DATA_DIR"/* + rm -rf "${GHE_DATA_DIR:?}"/* prune_file_num=${1:-10} for i in $(seq -f '%02g' 1 $prune_file_num); do mkdir -p "$GHE_DATA_DIR/$i" @@ -25,8 +26,8 @@ begin_test "ghe-prune-snapshots using default GHE_NUM_SNAPSHOTS" set -e generate_prune_files 12 ghe-prune-snapshots - [ $(ls -1d "$GHE_DATA_DIR"/[0-9]* | wc -l) -eq 10 ] - [ ! -d "$GHE_DATA_DIR/01" -a ! -d "$GHE_DATA_DIR/02" ] + [ "$(ls -1d "$GHE_DATA_DIR"/[0-9]* | wc -l)" -eq 10 ] + [ ! -d "$GHE_DATA_DIR/01" ] && [ ! -d "$GHE_DATA_DIR/02" ] ) end_test @@ -67,7 +68,7 @@ begin_test "ghe-prune-snapshots with expired snapshots" post_num_files=$(file_count_no_current) # make sure we have right number of files and right file is deleted - [ $post_num_files -eq 2 -a ! -f "$GHE_DATA_DIR/01" -a ! -f "$GHE_DATA_DIR/02" ] + [ $post_num_files -eq 2 ] && [ ! -f "$GHE_DATA_DIR/01" ] && [ ! -f "$GHE_DATA_DIR/02" ] ) end_test @@ -78,13 +79,13 @@ begin_test "ghe-prune-snapshots incomplete snapshot pruning" generate_prune_files 5 - [ $(file_count_no_current) -eq 5 ] + [ "$(file_count_no_current)" -eq 5 ] touch "$GHE_DATA_DIR/04/incomplete" GHE_NUM_SNAPSHOTS=5 ghe-prune-snapshots - [ $(file_count_no_current) -eq 4 ] + [ "$(file_count_no_current)" -eq 4 ] [ ! -d "$GHE_DATA_DIR/04" ] ) end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 8876b1cca..88e222ec4 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -2,8 +2,8 @@ # ghe-restore command tests # Bring in testlib -ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" -. $ROOTDIR/test/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Add some fake pages data to the snapshot mkdir -p "$GHE_DATA_DIR/1/pages" @@ -75,12 +75,12 @@ gist2="1/23/bb/4c/gist/1234.git" mkdir -p "$gist1" "$gist2" # Initialize test repositories with a fake commit -for repo in $(find . -type d -name '*.git' -prune); do - git init -q --bare "$repo" - git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' - rm -rf "$repo/hooks" - ln -s "$TRASHDIR/hooks" "$repo/hooks" -done +while IFS= read -r -d '' repo; do + git init -q --bare "$repo" + git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' + rm -rf "$repo/hooks" + ln -s "$TRASHDIR/hooks" "$repo/hooks" +done < <(find . -type d -name '*.git' -prune -print0) # Add some fake svn data to repo3 echo "fake svn history data" > "$repo3/svn.history.msgpack" @@ -184,7 +184,7 @@ begin_test "ghe-restore logs the benchmark" export BM_TIMESTAMP=foo export GHE_RESTORE_HOST=127.0.0.1 ghe-restore -v -f - [ $(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l) -gt 1 ] + [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] ) end_test @@ -563,7 +563,7 @@ EOF # Add custom key to tar file tar -cf "$GHE_DATA_DIR/current/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub - SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) + SHARED_UTILS_PATH=$(dirname "$(which ghe-detect-leaked-ssh-keys)") # Inject the fingerprint into the blacklist echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" diff --git a/test/test-ghe-ssh.sh b/test/test-ghe-ssh.sh index 2bdb274ca..a0d73809f 100755 --- a/test/test-ghe-ssh.sh +++ b/test/test-ghe-ssh.sh @@ -2,7 +2,8 @@ # ghe-ssh command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. @@ -33,7 +34,7 @@ begin_test "ghe-ssh complex command works" " output="$(echo "$comm" | ghe-ssh "$GHE_HOSTNAME" /bin/sh)" - [ $(echo "$output" | wc -l) -eq 2 ] + [ "$(echo "$output" | wc -l)" -eq 2 ] ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index 50e1bab6e..ef7f89dbe 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -47,7 +47,8 @@ export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the # remote version established above or in the environment. -. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" ghe_parse_remote_version "$GHE_TEST_REMOTE_VERSION" ghe_remote_version_config "$GHE_TEST_REMOTE_VERSION" @@ -64,7 +65,7 @@ atexit () { res=$? # cleanup injected test key - shared_path=$(dirname $(which ghe-detect-leaked-ssh-keys)) + shared_path=$(dirname "$(which ghe-detect-leaked-ssh-keys)") sed -i.bak '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" rm -f "$shared_path/ghe-ssh-leaked-host-keys-list.txt.bak" @@ -85,6 +86,7 @@ cd "$TRASHDIR" # Put remote metadata file in place for ghe-host-check which runs with pretty # much everything. You can pass a version number in the first argument to test # with different remote versions. +# shellcheck disable=SC2120 setup_remote_metadata () { mkdir -p "$GHE_REMOTE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" mkdir -p "$(dirname "$GHE_REMOTE_METADATA_FILE")" @@ -141,7 +143,7 @@ report_failure () { msg=$1 desc=$2 failures=$(( failures + 1 )) - printf "test: %-73s $msg\n" "$desc ..." + printf "test: %-73s $msg\\n" "$desc ..." ( sed 's/^/ /' <"$TRASHDIR/out" | grep -a -v -e '^\+ end_test' -e '^+ set +x' <"$TRASHDIR/out" | @@ -157,9 +159,9 @@ end_test () { exec 1>&3 2>&4 if [ "$test_status" -eq 0 ]; then - printf "test: %-60s OK\n" "$test_description ..." + printf "test: %-60s OK\\n" "$test_description ..." elif [ "$test_status" -eq 254 ]; then - printf "test: %-60s SKIPPED\n" "$test_description ..." + printf "test: %-60s SKIPPED\\n" "$test_description ..." else report_failure "FAILED" "$test_description ..." fi From effb4bd3ff664649aae085e2b19f083be25176d0 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 18 Jan 2018 14:08:47 +0000 Subject: [PATCH 0401/2421] Only test against 2.11.0 --- script/cibuild | 4 ---- 1 file changed, 4 deletions(-) diff --git a/script/cibuild b/script/cibuild index 8302dc2e2..843e45649 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,10 +7,6 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 11.10.344 - 2.0.0 - 2.2.0 - 2.5.0 2.11.0 " From de93530e5c40a21c08d851e05800596a16f9ae49 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 18 Jan 2018 15:56:51 +0000 Subject: [PATCH 0402/2421] Conditional not needed anymore --- share/github-backup-utils/ghe-backup-config | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index dbe0c6520..b3c9a9770 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -195,9 +195,7 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP" # called immediately after the remote version is obtained by # ghe_remote_version_required(). Child processes inherit the values set here. ghe_remote_version_config () { - if [ "$GHE_VERSION_MAJOR" -gt 1 ]; then - GHE_REMOTE_DATA_USER_DIR="$GHE_REMOTE_DATA_DIR/user" - fi + GHE_REMOTE_DATA_USER_DIR="$GHE_REMOTE_DATA_DIR/user" export GHE_REMOTE_DATA_DIR GHE_REMOTE_DATA_USER_DIR export GHE_REMOTE_LICENSE_FILE GHE_REMOTE_METADATA_FILE } From 12b6cc8cd84e5f74c05962af55589eafaedf798d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 18 Jan 2018 16:24:27 +0000 Subject: [PATCH 0403/2421] Remove support for 2.8 and earlier clusters --- bin/ghe-backup | 14 +- bin/ghe-restore | 24 +- .../ghe-backup-alambic-cluster | 90 ------ .../ghe-backup-repositories-cluster | 283 ------------------ share/github-backup-utils/ghe-cluster-nodes | 14 +- .../ghe-restore-alambic-cluster | 111 ------- .../ghe-restore-repositories-dgit | 135 --------- .../ghe-restore-repositories-gist | 128 -------- test/test-ghe-cluster-nodes.sh | 15 - test/testlib.sh | 5 - 10 files changed, 11 insertions(+), 808 deletions(-) delete mode 100755 share/github-backup-utils/ghe-backup-alambic-cluster delete mode 100755 share/github-backup-utils/ghe-backup-repositories-cluster delete mode 100755 share/github-backup-utils/ghe-restore-alambic-cluster delete mode 100755 share/github-backup-utils/ghe-restore-repositories-dgit delete mode 100755 share/github-backup-utils/ghe-restore-repositories-gist diff --git a/bin/ghe-backup b/bin/ghe-backup index a27d3073c..df7a2bc9d 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -173,13 +173,7 @@ failures="$failures hookshot" echo "Backing up Git repositories ..." if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/dgit-cluster-backup-routes ; then - echo "* Using calculated routes method..." - ghe-backup-repositories-cluster-ng || failures="$failures repositories" - else - echo "* Using legacy method. A faster backup method is available on enterprise 2.7 and up." - ghe-backup-repositories-cluster || failures="$failures repositories" - fi + ghe-backup-repositories-cluster-ng || failures="$failures repositories" else ghe-backup-repositories-${GHE_BACKUP_STRATEGY} || failures="$failures repositories" @@ -191,11 +185,7 @@ failures="$failures pages" if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "Backing up storage data ..." - if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/bin/storage-cluster-backup-routes; then - ghe-backup-alambic-cluster-ng || failures="$failures alambic" - else - ghe-backup-alambic-cluster || failures="$failures alambic" - fi + ghe-backup-alambic-cluster-ng || failures="$failures alambic" echo "Backing up custom Git hooks ..." ghe-backup-git-hooks-cluster || diff --git a/bin/ghe-restore b/bin/ghe-restore index abcc696ff..7c9780f87 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -282,20 +282,10 @@ bm_end "ghe-import-redis" if $cluster; then echo "Restoring Git repositories into cluster ..." - if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/dgit-cluster-restore-routes; then - ghe_verbose "* Using ghe-restore-repositories-dgit-ng to restore" - ghe-restore-repositories-dgit-ng "$GHE_HOSTNAME" 1>&3 - else - ghe-restore-repositories-dgit "$GHE_HOSTNAME" 1>&3 - fi + ghe-restore-repositories-dgit-ng "$GHE_HOSTNAME" 1>&3 echo "Restoring Gists into cluster ..." - if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/gist-cluster-restore-routes; then - ghe_verbose "* Using ghe-restore-repositories-gist-ng to restore" - ghe-restore-repositories-gist-ng "$GHE_HOSTNAME" 1>&3 - else - ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 - fi + ghe-restore-repositories-gist-ng "$GHE_HOSTNAME" 1>&3 else echo "Restoring Git repositories ..." ghe-restore-repositories-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 @@ -314,14 +304,8 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT if $cluster; then echo "Restoring storage data ..." - if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/storage-cluster-restore-routes; then - ghe_verbose "* Using ghe-restore-alambic-cluster-ng to restore" - # This restore script is faster but only available in - # GHE >= 2.6.3 - ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 - else - ghe-restore-alambic-cluster "$GHE_HOSTNAME" 1>&3 - fi + ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 + echo "Restoring custom Git hooks ..." ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 else diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster b/share/github-backup-utils/ghe-backup-alambic-cluster deleted file mode 100755 index 368ba034b..000000000 --- a/share/github-backup-utils/ghe-backup-alambic-cluster +++ /dev/null @@ -1,90 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-alambic-cluster -#/ Take an online, incremental snapshot of all Alambic Storage data -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup when the cluster strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -bm_start "$(basename $0)" - -# Set up remote host and root backup snapshot directory based on config -host="$GHE_HOSTNAME" -backup_dir="$GHE_SNAPSHOT_DIR/storage" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -# Alambic server hostnames -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - -# Make sure root backup dir exists if this is the first run -mkdir -p "$backup_dir" - -# Removes the remote sync-in-progress file on exit, re-enabling GC operations -# on the remote instance. -cleanup() { - # Enable remote maintenance operations - for hostname in $hostnames; do - ghe-gc-enable -F $ssh_config_file $hostname:$port - done - - rm -f $ssh_config_file -} -trap 'cleanup' EXIT INT - -# Disable remote maintenance operations -for hostname in $hostnames; do - ghe-gc-disable -F $ssh_config_file $hostname:$port -done - -# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$GHE_DATA_DIR/current/storage" ] && [ "$(ls -A $GHE_DATA_DIR/current/storage)" ]; then - link_dest="--link-dest=../../current/storage" -fi - -for hostname in $hostnames; do - bm_start "$(basename $0) - $hostname" - echo 1>&3 - echo "* Starting backup for host: $hostname" - # Sync all auxiliary repository data. This includes files and directories like - # HEAD, audit_log, config, description, info/, etc. No refs or object data - # should be transferred here. - echo 1>&3 - echo "* Transferring storage files ..." 1>&3 - - # Transfer all data from the user data directory using rsync. - ghe-rsync -avz \ - -e "ssh -q $opts -p 122 -F $ssh_config_file -l $user" \ - --rsync-path='sudo -u git rsync' \ - $link_dest \ - --size-only \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ - "$GHE_SNAPSHOT_DIR/storage" 1>&3 - bm_end "$(basename $0) - $hostname" -done - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster b/share/github-backup-utils/ghe-backup-repositories-cluster deleted file mode 100755 index bb62b8a48..000000000 --- a/share/github-backup-utils/ghe-backup-repositories-cluster +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-repositories-cluster -#/ Take an online, incremental snapshot of all Git repository data. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup when the cluster strategy is used. -set -e - -# This command is designed to allow for transferring active Git repository data -# from a GitHub instance to a backup site in a way that ensures data is -# captured in a consistent state even when being written to. -# -# - All Git GC operations are disabled on the GitHub instance for the duration of -# the backup. This removes the possibly of objects or packs being removed -# while the backup is in progress. -# -# - In progress Git GC operations are given a cooldown window to complete. The -# script will sleep for up to 60 seconds waiting for GC operations to finish. -# -# - Git repository data is transferred in a specific order: auxiliary files, -# packed refs, loose refs, reflogs, and finally objects and pack files in that -# order. This ensures that all referenced objects are captured. -# -# - Git GC operations are re-enabled on the GitHub instance. -# -# The script uses multiple runs of rsync to transfer repository files. Each run -# includes a list of filter rules that ensure only specific types of files are -# transferred. -# -# See the "FILTER RULES" and "INCLUDE/EXCLUDE PATTERN RULES" sections of the -# rsync(1) manual for more information: -# - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -bm_start "$(basename $0)" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -backup_dir="$GHE_SNAPSHOT_DIR/repositories" - -# Location of last good backup for rsync --link-dest -backup_current="$GHE_DATA_DIR/current/repositories" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -# git server hostnames -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - -# Make sure root backup dir exists if this is the first run -mkdir -p "$backup_dir" - -# Removes the remote sync-in-progress file on exit, re-enabling GC operations -# on the remote instance. -cleanup() { - # Enable remote GC operations - for hostname in $hostnames; do - ghe-gc-enable -F $ssh_config_file $hostname:$port - done - rm -f $ssh_config_file -} -trap 'cleanup' EXIT -trap 'exit $?' INT # ^C always terminate - -# Disable remote GC operations -for hostname in $hostnames; do - ghe-gc-disable -F $ssh_config_file $hostname:$port -done - -# If we have a previous increment, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$backup_current" ]; then - link_dest="--link-dest=../../current/repositories" -fi - -# Transfer repository data from a GitHub instance to the current snapshot -# directory, using a previous snapshot to avoid transferring files that have -# already been transferred. A set of rsync filter rules are provided on stdin -# for each invocation. -rsync_repository_data () { - port=$(ssh_port_part "$1") - host=$(ssh_host_part "$1") - - shift - ghe-rsync -av \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --include-from=- --exclude=\* \ - "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 -} - -for hostname in $hostnames; do - bm_start "$(basename $0) - $hostname" - echo 1>&3 - echo "* Starting backup for host: $hostname" - # Sync all auxiliary repository data. This includes files and directories like - # HEAD, audit_log, config, description, info/, etc. No refs or object data - # should be transferred here. - echo 1>&3 - echo "* Transferring auxiliary files ..." 1>&3 - rsync_repository_data $hostname:122 -z <&3 - echo "* Transferring packed-refs files ..." 1>&3 - rsync_repository_data $hostname:122 -z <&3 - echo "* Transferring refs and reflogs ..." 1>&3 - rsync_repository_data $hostname:122 -z <&3 - echo "* Transferring objects and packs ..." 1>&3 - rsync_repository_data $hostname:122 -H <&3 - echo "* Transferring special data directories ..." 1>&3 - rsync_repository_data $hostname:122 <&3 - bm_end "$(basename $0) - $hostname" -done - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index ac44fbdce..6835d999b 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -26,14 +26,10 @@ GHE_HOSTNAME="$1" prefix="$2" role=$(echo "$prefix" | cut -d '-' -f1) -if ghe-ssh "$GHE_HOSTNAME" test -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid"; then - node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -u) - hostnames='' - for uuid in $node_uuids; do - hostnames+="$prefix-$uuid " - done -else - hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -p) -fi +node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -u) +hostnames='' +for uuid in $node_uuids; do + hostnames+="$prefix-$uuid " +done echo "$hostnames" diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster b/share/github-backup-utils/ghe-restore-alambic-cluster deleted file mode 100755 index be4e8434d..000000000 --- a/share/github-backup-utils/ghe-restore-alambic-cluster +++ /dev/null @@ -1,111 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-alambic-cluster -#/ Restore Alambic assets from an rsync snapshot of all assets to a GitHub cluster. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when restoring into a cluster. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Find the binary blobs to restore -storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindepth 4 -maxdepth 4 | cut -d / -f2-) - -# No need to restore anything, early exit -if [ -z "$storage_paths" ]; then - echo "Warning: Storage backup missing. Skipping ..." - exit 0 -fi - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-config --get-regexp cluster.*.hostname | cut -d ' ' -f 2) - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - -cleanup() { - for pid in $(jobs -p); do - kill -KILL $pid > /dev/null 1>&2 || true - done - rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_out -} - -trap 'cleanup' INT TERM EXIT - -rm -rf ssh_routes_in ssh_routes_out ssh_finalize_out -mkfifo ssh_routes_in -mkfifo ssh_routes_out -mkfifo ssh_finalize_out - -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-import-routes - < ssh_routes_out > ssh_routes_in & -ssh_routes_pid=$! -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-import-finalize - < ssh_finalize_out & -ssh_finalize_pid=$! - -exec 4> ssh_routes_out -exec 5> ssh_finalize_out - -for storage_path in $storage_paths; do - oid=$(echo $storage_path | awk -F/ '{print $(NF)}') - echo "$oid" >&4 - read routes < ssh_routes_in - - for route in $routes; do - ghe-rsync -aHR --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - --rsync-path="sudo -u git rsync" \ - --size-only \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./$storage_path" \ - "$route:$GHE_REMOTE_DATA_USER_DIR/storage" & - done - - for pid in $(jobs -p); do - if [ $pid = $ssh_routes_pid -o $pid = $ssh_finalize_pid ]; then - continue - fi - wait $pid - ret_code=$? - if [ "$ret_code" != "0" ]; then - echo "$pid exited $ret_code" - exit $ret_code - fi - done - - echo "$oid $routes" >&5 -done - -exec 4>&- -exec 5>&- - -# Ensure to flush these and close the pipes -cat ssh_routes_in > /dev/null & - -wait $ssh_routes_pid > /dev/null 2>&1 || true -wait $ssh_finalize_pid > /dev/null 2>&1 || true - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit b/share/github-backup-utils/ghe-restore-repositories-dgit deleted file mode 100755 index c790b4cd1..000000000 --- a/share/github-backup-utils/ghe-restore-repositories-dgit +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-repositories-dgit -#/ Restore repositories from an rsync snapshot of all Git repository data to a GitHub cluster. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when restoring into a cluster. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -network_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mindepth 6 -maxdepth 7 -name \*.git -exec dirname {} \; | uniq | grep nw | cut -d / -f2-) - -if [ -z "$network_paths" ]; then - echo "Warning: Repositories backup missing. Skipping ..." - exit 0 -fi - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - -cleanup() { - for pid in $(jobs -p); do - kill -KILL $pid > /dev/null 2>&1 || true - done - # Enable remote GC operations - for hostname in $hostnames; do - ghe-gc-enable -F $ssh_config_file $hostname:$port - done - rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out -} - -trap 'cleanup' INT TERM EXIT - -# Disable remote GC operations -for hostname in $hostnames; do - ghe-gc-disable -F $ssh_config_file $hostname:$port -done - -rm -rf ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out -mkfifo ssh_routes_in -mkfifo ssh_routes_out -mkfifo ssh_finalize_in -mkfifo ssh_finalize_out - -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-import-routes - < ssh_routes_out > ssh_routes_in & -ssh_routes_pid=$! -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-import-finalize - < ssh_finalize_out > ssh_finalize_in & -ssh_finalize_pid=$! - -exec 4> ssh_routes_out -exec 5> ssh_finalize_out - -for network_path in $network_paths; do - network_id=$(echo $network_path | awk -F/ '{print $(NF)}') - echo "$network_id" >&4 - read routes < ssh_routes_in - - for route in $routes; do - ghe-rsync -aHR --delete \ - --exclude ".sync_in_progress" \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./$network_path" \ - "$route:$GHE_REMOTE_DATA_USER_DIR/repositories" & - done - - for pid in $(jobs -p); do - if [ $pid = $ssh_routes_pid -o $pid = $ssh_finalize_pid ]; then - continue - fi - wait $pid - ret_code=$? - if [ "$ret_code" != "0" ]; then - echo "$pid exited $ret_code" - exit $ret_code - fi - done - - echo "$network_id /data/repositories/$network_path $routes" >&5 - read output < ssh_finalize_in -done - -exec 4>&- -exec 5>&- - -# Ensure to flush output and close pipes -cat ssh_routes_in > /dev/null & -cat ssh_finalize_in > /dev/null & - -wait $ssh_routes_pid > /dev/null 2>&1 || true -wait $ssh_finalize_pid > /dev/null 2>&1 || true - -if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then - for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do - if ! ghe-rsync -a --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info"; then - echo "Error restoring /data/repositories/info to $route" - fi - done -else - ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -- rm -f /data/repositories/info/* -fi - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist deleted file mode 100755 index 0beaee5fc..000000000 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-repositories-gist -#/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when restoring into a cluster. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Find the gists to restore -gist_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mindepth 6 -maxdepth 7 -name \*.git | grep gist | cut -d / -f2-) - -# No need to restore anything, early exit -if [ -z "$gist_paths" ]; then - echo "Warning: Gist backup missing. Skipping ..." - exit 0 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - -cleanup() { - for pid in $(jobs -p); do - kill -KILL $pid > /dev/null 2>&1 || true - done - # Enable remote GC operations - for hostname in $hostnames; do - ghe-gc-enable -F $ssh_config_file $hostname:$port - done - rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out -} - -trap 'cleanup' INT TERM EXIT - -# Disable remote GC operations -for hostname in $hostnames; do - ghe-gc-disable -F $ssh_config_file $hostname:$port -done - -rm -rf ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out -mkfifo ssh_routes_in -mkfifo ssh_routes_out -mkfifo ssh_finalize_in -mkfifo ssh_finalize_out - -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-import-routes - < ssh_routes_out > ssh_routes_in & -ssh_routes_pid=$! -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/gist-cluster-import-finalize - < ssh_finalize_out > ssh_finalize_in & -ssh_finalize_pid=$! - -exec 4> ssh_routes_out -exec 5> ssh_finalize_out - -for gist_path in $gist_paths; do - gist_id=$(basename $(echo $gist_path | awk -F/ '{print $(NF)}') .git) - echo "$gist_id" >&4 - read routes < ssh_routes_in - - if [ "$routes" = 'gist-not-found' ]; then - echo " Warning: gist ID $gist_id not found in the database, ignoring." - continue - fi - - for route in $routes; do - ghe-rsync -aHR --delete \ - --exclude ".sync_in_progress" \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./$gist_path" \ - "$route:$GHE_REMOTE_DATA_USER_DIR/repositories" & - done - - for pid in $(jobs -p); do - if [ $pid = $ssh_routes_pid -o $pid = $ssh_finalize_pid ]; then - continue - fi - wait $pid - ret_code=$? - if [ "$ret_code" != "0" ]; then - echo "$pid exited $ret_code" - exit $ret_code - fi - done - - echo "$gist_id /data/repositories/$gist_path $routes" >&5 - read output < ssh_finalize_in -done - -exec 4>&- -exec 5>&- - -# Ensure to flush these and close the pipes -cat ssh_routes_in > /dev/null & -cat ssh_finalize_in > /dev/null & - -wait $ssh_routes_pid > /dev/null 2>&1 || true -wait $ssh_finalize_pid > /dev/null 2>&1 || true - -bm_start "$(basename $0)" diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index 7b7a2c141..161e0ded5 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -18,23 +18,8 @@ begin_test "ghe-cluster-nodes should return both uuids for git-server" ( set -e - output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" echo "$output" [ "git-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 git-server-08d94884-f519-11e6-88a1-0063a7c33551 " = "$output" ] ) end_test - -# Test behaviour for pre-2.8 nodes -# Remove when 2.8 has been deprecated. -begin_test "ghe-cluster-nodes should return both hostnames for git-server" -( - set -e - - output="$(GHE_REMOTE_DATA_USER_DIR="/foobar" ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" - echo "$output" - expected="ghe-test-ha-primary -ghe-test-ha-replica" - [ "$expected" = "$output" ] -) -end_test diff --git a/test/testlib.sh b/test/testlib.sh index ef7f89dbe..6e65ebe4f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -112,11 +112,6 @@ setup_remote_license () { setup_remote_license setup_remote_cluster () { - if [ "$GHE_VERSION_MAJOR" -lt 2 ] || \ - ([ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -le 4 ]); then - return 1 - fi - mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" touch "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" } From 758d095b4cca9cc48202f0ab39bde8acc1819cf9 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 18 Jan 2018 17:20:44 +0000 Subject: [PATCH 0404/2421] Add support for standalone nodes ... and update tests --- share/github-backup-utils/ghe-cluster-nodes | 15 ++++++++++----- test/bin/ghe-cluster-each | 6 +----- test/test-ghe-cluster-nodes.sh | 16 +++++++++++++++- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index 6835d999b..75f6c0b4a 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -26,10 +26,15 @@ GHE_HOSTNAME="$1" prefix="$2" role=$(echo "$prefix" | cut -d '-' -f1) -node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -u) -hostnames='' -for uuid in $node_uuids; do - hostnames+="$prefix-$uuid " -done +if ghe-ssh "$GHE_HOSTNAME" test -f $GHE_REMOTE_ROOT_DIR/etc/github/cluster; then + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -u) + hostnames='' + for uuid in $node_uuids; do + hostnames+="$prefix-$uuid " + done +else + uuid=$(ghe-ssh "$GHE_HOSTNAME" cat $GHE_REMOTE_DATA_USER_DIR/common/uuid) + hostnames="$prefix-$uuid" +fi echo "$hostnames" diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 91eeb883d..b7b74ee6b 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -4,11 +4,7 @@ # to assert that the command was executed. set -e # Mimic `ghe-cluster-each $role -p` -if [[ "$*" =~ "-p" ]]; then - echo "ghe-test-ha-primary -ghe-test-ha-replica -" -else +if [[ "$*" =~ "-u" ]]; then # Mimic `ghe-cluster-each $role -u` echo "05cbcd42-f519-11e6-b6c9-002bd51dfa77 08d94884-f519-11e6-88a1-0063a7c33551 diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index 161e0ded5..d0bdd70fd 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -12,14 +12,28 @@ GHE_REMOTE_DATA_DIR="$TRASHDIR/remote" export GHE_DATA_DIR GHE_REMOTE_DATA_DIR # Create a uuid file mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" -echo "fake uuids" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" +echo "fake-uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" begin_test "ghe-cluster-nodes should return both uuids for git-server" ( set -e + setup_remote_cluster output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" echo "$output" [ "git-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 git-server-08d94884-f519-11e6-88a1-0063a7c33551 " = "$output" ] ) end_test + +begin_test "ghe-cluster-nodes should return one uuid for a single node" +( + set -e + + # Ensure not a cluster + rm -rf "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" + + output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + echo "$output" + [ "git-server-fake-uuid" = "$output" ] +) +end_test From ccb37531a8aa16da2c666779050f3288609281b2 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 19 Jan 2018 12:00:28 +0000 Subject: [PATCH 0405/2421] Update tests env for new layout --- test/test-ghe-backup.sh | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index b50e4e8f5..70c9dab9d 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -9,10 +9,12 @@ mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" # Create some fake pages data in the remote data directory -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/pages" -cd "$GHE_REMOTE_DATA_USER_DIR/pages" -mkdir -p alice bob -touch alice/index.html bob/index.html +mkdir -p "$GHE_DATA_DIR/pages" +cd "$GHE_DATA_DIR/pages" +pages1="4/c8/1e/72/2/legacy" +pages2="4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96" +mkdir -p "$pages1" "$pages2" +touch "$pages1/index.html" "$pages2/index.html" # Create a fake manage password file mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" @@ -48,7 +50,7 @@ mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/00 touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" # Create a fake UUID -echo "fake uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" +echo "fake-uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" # Create fake audit log migration sentinel file touch "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" @@ -62,17 +64,30 @@ touch gh-enterprise-es/node/0/stuff2 # Create some test repositories in the remote repositories dir mkdir "$GHE_REMOTE_DATA_USER_DIR/repositories" +mkdir -p "$TRASHDIR/hooks" cd "$GHE_REMOTE_DATA_USER_DIR/repositories" -mkdir alice bob -mkdir alice/repo1.git alice/repo2.git bob/repo3.git alice/broken.git +repo1="0/nw/01/aa/3f/1234/1234.git" +repo2="0/nw/01/aa/3f/1234/1235.git" +repo3="1/nw/23/bb/4c/2345/broken.git" +mkdir -p "$repo1" "$repo2" "$repo3" + +wiki1="0/nw/01/aa/3f/1234/1234.wiki.git" +mkdir -p "$wiki1" + +gist1="0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git" +gist2="1/23/bb/4c/gist/1234.git" +mkdir -p "$gist1" "$gist2" # Initialize test repositories with a fake commit -for repo in */*.git; do - git init -q --bare "$repo" - git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' -done +while IFS= read -r -d '' repo; do + git init -q --bare "$repo" + git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' + rm -rf "$repo/hooks" + ln -s "$TRASHDIR/hooks" "$repo/hooks" +done < <(find . -type d -name '*.git' -prune -print0) + # Break a repo to test fsck -rm -f alice/broken.git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +rm -f $repo3/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 begin_test "ghe-backup first snapshot" ( From a4ff5c926aa1e113979054b2c101b0679d8bc945 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 19 Jan 2018 12:00:28 +0000 Subject: [PATCH 0406/2421] Update tests env for modern layout --- test/test-ghe-backup.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 70c9dab9d..7b733e6cc 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -9,8 +9,8 @@ mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" # Create some fake pages data in the remote data directory -mkdir -p "$GHE_DATA_DIR/pages" -cd "$GHE_DATA_DIR/pages" +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/pages" +cd "$GHE_REMOTE_DATA_USER_DIR/pages" pages1="4/c8/1e/72/2/legacy" pages2="4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96" mkdir -p "$pages1" "$pages2" @@ -120,7 +120,8 @@ begin_test "ghe-backup first snapshot" [ -d "$GHE_DATA_DIR/current/repositories" ] # check that pages data was backed up - [ -f "$GHE_DATA_DIR/current/pages/alice/index.html" ] + [ -f "$GHE_DATA_DIR/current/pages/4/c8/1e/72/2/legacy/index.html" ] + [ -f "$GHE_DATA_DIR/current/pages/4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" ] # check that mysql data was backed up [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] @@ -208,7 +209,8 @@ begin_test "ghe-backup subsequent snapshot" [ -d "$GHE_DATA_DIR/current/repositories" ] # check that pages data was backed up - [ -f "$GHE_DATA_DIR/current/pages/alice/index.html" ] + [ -f "$GHE_DATA_DIR/current/pages/4/c8/1e/72/2/legacy/index.html" ] + [ -f "$GHE_DATA_DIR/current/pages/4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" ] # check that mysql data was backed up [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] @@ -313,7 +315,8 @@ begin_test "ghe-backup with relative data dir path" [ -d "$GHE_DATA_DIR/current/repositories" ] # check that pages data was backed up - [ -f "$GHE_DATA_DIR/current/pages/alice/index.html" ] + [ -f "$GHE_DATA_DIR/current/pages/4/c8/1e/72/2/legacy/index.html" ] + [ -f "$GHE_DATA_DIR/current/pages/4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" ] # check that mysql data was backed up [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] @@ -432,7 +435,7 @@ begin_test "ghe-backup fsck" set -e export GHE_BACKUP_FSCK=yes - ghe-backup | grep -q "Repos verified: 4, Errors: 1, Took:" + ghe-backup | grep -q "Repos verified: 6, Errors: 1, Took:" # Verbose mode disabled by default ! ghe-backup | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" ghe-backup -v | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" From 11f519ed29b8ea043d5c42ed30168ae0f20fc7b3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 15:42:09 +0000 Subject: [PATCH 0407/2421] /data/user/[hookshot|alambic_assets] are no longer used --- bin/ghe-backup | 8 -------- bin/ghe-restore | 6 ------ test/test-ghe-backup.sh | 31 ------------------------------- test/test-ghe-restore.sh | 37 ------------------------------------- 4 files changed, 82 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index df7a2bc9d..54e6a9ef8 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -191,18 +191,10 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-backup-git-hooks-cluster || failures="$failures git-hooks" else - echo "Backing up asset attachments ..." - ghe-backup-userdata alambic_assets || - failures="$failures alambic_assets" - echo "Backing up storage data ..." ghe-backup-userdata storage || failures="$failures storage" - echo "Backing up hook deliveries ..." - ghe-backup-userdata hookshot || - failures="$failures hookshot" - echo "Backing up custom Git hooks ..." ghe-backup-userdata git-hooks/environments/tarballs || failures="$failures git-hooks-environments" diff --git a/bin/ghe-restore b/bin/ghe-restore index 7c9780f87..67bd30e6e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -309,15 +309,9 @@ if $cluster; then echo "Restoring custom Git hooks ..." ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 else - echo "Restoring asset attachments ..." - ghe-restore-userdata alambic_assets "$GHE_HOSTNAME" 1>&3 - echo "Restoring storage data ..." ghe-restore-userdata storage "$GHE_HOSTNAME" 1>&3 - echo "Restoring hook deliveries ..." - ghe-restore-userdata hookshot "$GHE_HOSTNAME" 1>&3 - echo "Restoring custom Git hooks ..." ghe-restore-userdata git-hooks/environments/tarballs "$GHE_HOSTNAME" 1>&3 ghe-restore-userdata git-hooks/repos "$GHE_HOSTNAME" 1>&3 diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 7b733e6cc..34571fc00 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -20,12 +20,6 @@ touch "$pages1/index.html" "$pages2/index.html" mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "fake password hash data" -# Create some fake data in the remote data directory -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/hookshot" -cd "$GHE_REMOTE_DATA_USER_DIR/hookshot" -mkdir -p repository-123 repository-456 -touch repository-123/test.bpack repository-456/test.bpack - # Create some fake hooks in the remote data directory mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" @@ -42,13 +36,6 @@ cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" mkdir -p 321 654 touch 321/script.sh 654/foo.sh -# Create some fake alambic data in the remote data directory -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-assets/0000" -touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-assets/0000/test.png" - -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001" -touch "$GHE_REMOTE_DATA_USER_DIR/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" - # Create a fake UUID echo "fake-uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" @@ -147,9 +134,6 @@ begin_test "ghe-backup first snapshot" # verify manage-password file was backed up under v2.x VMs [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - # verify all hookshot user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" - # verify all git hooks tarballs were transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" @@ -159,9 +143,6 @@ begin_test "ghe-backup first snapshot" # verify the extracted repositories were transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" - # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" @@ -236,9 +217,6 @@ begin_test "ghe-backup subsequent snapshot" # verify manage-password file was backed up under v2.x VMs [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - # verify all hookshot user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" - # verify all git hooks tarballs were transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" @@ -248,9 +226,6 @@ begin_test "ghe-backup subsequent snapshot" # verify the extracted repositories were transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" - # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" @@ -342,9 +317,6 @@ begin_test "ghe-backup with relative data dir path" # verify manage-password file was backed up under v2.x VMs [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - # verify all hookshot user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/hookshot" "$GHE_DATA_DIR/current/hookshot" - # verify all git hooks tarballs were transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" @@ -354,9 +326,6 @@ begin_test "ghe-backup with relative data dir path" # verify the extracted repositories were transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" "$GHE_DATA_DIR/current/alambic_assets" - # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 88e222ec4..5167efc14 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -24,12 +24,6 @@ touch gh-enterprise-es/node/0/stuff2 mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "foobar" -# Create some fake hookshot data in the remote data directory -mkdir -p "$GHE_DATA_DIR/1/hookshot" -cd "$GHE_DATA_DIR/1/hookshot" -mkdir -p repository-123 repository-456 -touch repository-123/test.bpack repository-456/test.bpack - # Create some fake environments mkdir -p "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" cd "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" @@ -48,13 +42,6 @@ cd "$GHE_DATA_DIR/1/git-hooks/environments" mkdir -p 123 456 touch 123/script.sh 456/foo.sh -# Create some fake alambic data in the remote data directory -mkdir -p "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-assets/0000" -touch "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-assets/0000/test.png" - -mkdir -p "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001" -touch "$GHE_DATA_DIR/1/alambic_assets/github-enterprise-releases/0001/1ed78298-522b-11e3-9dc0-22eed1f8132d" - # Create a fake uuid echo "fake uuid" > "$GHE_DATA_DIR/1/uuid" @@ -156,17 +143,11 @@ begin_test "ghe-restore into configured vm" # verify management console password was *not* restored ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" - # verify all hookshot user data was transferred - diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" - # verify all git hooks data was transferred diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" - # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" @@ -291,17 +272,11 @@ begin_test "ghe-restore -c into unconfigured vm" # verify management console password grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" - # verify all hookshot user data was transferred - diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" - # verify all git hooks data was transferred diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" - # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" @@ -355,17 +330,11 @@ begin_test "ghe-restore into unconfigured vm" # verify all pages data was transferred to the restore location diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - # verify all hookshot user data was transferred - diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" - # verify all git hooks data was transferred diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" - # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" @@ -414,16 +383,10 @@ begin_test "ghe-restore with host arg" # verify all pages data was transferred to the restore location diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - # verify all hookshot user data was transferred - diff -ru "$GHE_DATA_DIR/current/hookshot" "$GHE_REMOTE_DATA_USER_DIR/hookshot" - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - # verify all alambic assets user data was transferred - diff -ru "$GHE_DATA_DIR/current/alambic_assets" "$GHE_REMOTE_DATA_USER_DIR/alambic_assets" - # verify the UUID was transferred diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" From b427cf262f6d58e6fbf865e9f5bf8cd25ae3b1f5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 15:42:48 +0000 Subject: [PATCH 0408/2421] Remove references to special dirs that haven't existed for a while --- share/github-backup-utils/ghe-backup-repositories-rsync | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-rsync b/share/github-backup-utils/ghe-backup-repositories-rsync index dd84157c1..bc944e620 100755 --- a/share/github-backup-utils/ghe-backup-repositories-rsync +++ b/share/github-backup-utils/ghe-backup-repositories-rsync @@ -221,20 +221,13 @@ rsync_repository_data -H <&3 echo "* Transferring special data directories ..." 1>&3 rsync_repository_data < Date: Wed, 24 Jan 2018 15:53:10 +0000 Subject: [PATCH 0409/2421] Don't create tempdir on host This will create a path using the temp dir structure of the backup host which, if a different OS, may not match the filesystem structure on GHE. --- share/github-backup-utils/ghe-backup-alambic-cluster-ng | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 057f4e6b4..427861052 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -37,11 +37,9 @@ user="${host%@*}" hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$tempdir/ssh_config ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" -routes_list=$tempdir/routes_list # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" From d2f7ea9f73f97a368aef53cc61f176cfc588e1cb Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 15:54:09 +0000 Subject: [PATCH 0410/2421] Use consistent method to backup storage objects --- .../ghe-backup-alambic-cluster-ng | 73 +++++++++++-------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 427861052..8c05ef6f8 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -68,41 +68,52 @@ if [ -d "$GHE_DATA_DIR/current/storage" ] && [ "$(ls -A $GHE_DATA_DIR/current/st link_dest="--link-dest=../../current/storage" fi -bm_start "$(basename $0) - Generating routes" -echo "github-env ./bin/storage-cluster-backup-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -bm_end "$(basename $0) - Generating routes" - -bm_start "$(basename $0) - Transferring routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list -bm_end "$(basename $0) - Transferring routes" +# Calculate sync routes. This will store the healthy object paths for each node +# +# This gets a repo path and stores the path in the $node.sync file +# a/nw/a8/3f/02/100000855 storage-server-node1 >> storage-server-node1.sync +# a/nw/a8/bc/8d/100000880 storage-server-node3 >> storage-server-node3.sync +# a/nw/a5/06/81/100000659 storage-server-node2 >> storage-server-node2.sync +# ... +#one route per line. +# +bm_start "$(basename $0) - Calculating sync routes" +ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-backup-routes \ + | while read route; do + ghe_verbose "Got backup route $route" + server=$(echo $route | cut -d ' ' -f2-) + network_path=$(echo $route | cut -d ' ' -f1) + ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync +done +bm_end "$(basename $0) - Calculating sync routes" -bm_start "$(basename $0) - Processing routes" -cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' -bm_end "$(basename $0) - Processing routes" +if ! ls $tempdir/*.rsync >/dev/null 2>&1; then + echo "Warning: no routes found, skipping storage backup ..." + exit 0 +fi -# rsync all the repositories +# rsync all the storage objects bm_start "$(basename $0) - Storage object sync" -if [ -s "$routes_list" ]; then - for file_list in $tempdir/*.rsync; do - hostname=$(basename $file_list .rsync) - - object_num=$(cat $file_list | wc -l) - echo "* Transferring $object_num objects from $hostname" - - ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --files-from="$file_list" \ - --size-only \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ - "$backup_dir" 1>&3 & - done +for file_list in $tempdir/*.rsync; do + hostname=$(basename $file_list .rsync) + + object_num=$(cat $file_list | wc -l) + echo "* Transferring $object_num objects from $hostname" + + ghe-rsync -avr \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + $link_dest "$@" \ + --rsync-path='sudo -u git rsync' \ + --files-from="$file_list" \ + --size-only \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ + "$backup_dir" 1>&3 & +done - for pid in $(jobs -p); do - wait $pid - done -fi +for pid in $(jobs -p); do + wait $pid +done bm_end "$(basename $0) - Storage object sync" bm_end "$(basename $0)" From a51ed4e3852e50fc5e1be0c8df7d120a2e0011e6 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 15:54:36 +0000 Subject: [PATCH 0411/2421] Don't enabled/disable gc when testing --- .../ghe-backup-alambic-cluster-ng | 20 +++++++++++-------- .../ghe-backup-repositories-cluster-ng | 20 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 8c05ef6f8..660252166 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -47,20 +47,24 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - # Enable remote maintenance operations - for hostname in $hostnames; do - ghe-gc-enable -F $ssh_config_file $hostname:$port - done + # Enable remote maintenance operations, unless testing + if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then + for hostname in $hostnames; do + ghe-gc-enable -F $ssh_config_file $hostname:$port + done + fi ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir rm -rf $tempdir } trap 'cleanup' EXIT INT -# Disable remote maintenance operations -for hostname in $hostnames; do - ghe-gc-disable -F $ssh_config_file $hostname:$port -done +# Disable remote maintenance operations, unless testing +if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then + for hostname in $hostnames; do + ghe-gc-disable -F $ssh_config_file $hostname:$port + done +fi # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 8cf1237b1..041075671 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -87,10 +87,12 @@ cleanup() { kill -KILL $pid > /dev/null 2>&1 || true done - # Enable remote GC operations - for hostname in $hostnames; do - ghe-gc-enable -F $ssh_config_file $hostname:$port - done + # Enable remote GC operations, unless testing + if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then + for hostname in $hostnames; do + ghe-gc-enable -F $ssh_config_file $hostname:$port + done + fi rm -f $ssh_config_file rm -rf $tempdir @@ -98,10 +100,12 @@ cleanup() { trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate -# Disable remote GC operations -for hostname in $hostnames; do - ghe-gc-disable -F $ssh_config_file $hostname:$port -done +# Disable remote GC operations, unless testing +if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then + for hostname in $hostnames; do + ghe-gc-disable -F $ssh_config_file $hostname:$port + done +fi # If we have a previous increment, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. From 7682bd94bd21f2ab59f528bf93675147526ce2e8 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 15:54:49 +0000 Subject: [PATCH 0412/2421] Remove unused var --- share/github-backup-utils/ghe-backup-repositories-cluster-ng | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 041075671..a77753c5b 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -50,7 +50,6 @@ backup_dir="$GHE_SNAPSHOT_DIR/repositories" backup_current="$GHE_DATA_DIR/current/repositories" tempdir=$(mktemp -d) -to_backup=$tempdir/to_backup # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then From 734e9be8dcf36f38c47ffbc2fa74a30e02c3c294 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 15:55:24 +0000 Subject: [PATCH 0413/2421] Add new storage structure for testing --- test/test-ghe-backup.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 34571fc00..46bbc4ea5 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -36,6 +36,16 @@ cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" mkdir -p 321 654 touch 321/script.sh 654/foo.sh +mkdir -p "$GHE_REMOTE_DATA_USER_DIR/storage/" +cd "$GHE_REMOTE_DATA_USER_DIR/storage/" +object1="2/20/e1" +object2="8/80/76" +object3="e/ed/1a" +mkdir -p "$object1" "$object2" "$object3" +touch "$object1/20e1b33c19d81f490716c470c0583772b05a153831d55441cc5e7711eda5a241" +touch "$object2/80766a2b18a96b9a5927ebdd980dc8d0820bea7ff0897b1b119af4bf20974d32" +touch "$object3/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" + # Create a fake UUID echo "fake-uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" From 309854a718d5955dc2b2e71b426ab9b4fa3b1fbc Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 16:09:22 +0000 Subject: [PATCH 0414/2421] Add dummy scripts for testing --- test/bin/dgit-cluster-backup-routes | 11 +++++++++++ test/bin/github-env | 1 + test/bin/storage-cluster-backup-routes | 10 ++++++++++ 3 files changed, 22 insertions(+) create mode 100755 test/bin/dgit-cluster-backup-routes create mode 120000 test/bin/github-env create mode 100755 test/bin/storage-cluster-backup-routes diff --git a/test/bin/dgit-cluster-backup-routes b/test/bin/dgit-cluster-backup-routes new file mode 100755 index 000000000..85155f355 --- /dev/null +++ b/test/bin/dgit-cluster-backup-routes @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Usage: dgit-cluster-backup-routes +# Emulates the remote GitHub enterprise-configure command. Tests use this +# to assert that the command was executed. +set -e +cat < Date: Wed, 24 Jan 2018 16:09:35 +0000 Subject: [PATCH 0415/2421] Strip more args from ssh cmds during testing --- test/bin/ssh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/bin/ssh b/test/bin/ssh index efef37448..9218f696d 100755 --- a/test/bin/ssh +++ b/test/bin/ssh @@ -33,6 +33,12 @@ cd "$(dirname "$0")"/.. # Scrub sudo commands from command arguments. sh="$(echo "$@" | sed 's/sudo -u [a-z]* //g' | sed 's/sudo //g')" +# Scrub SSH arguments passed to rsync +sh="$(echo "$sh" | sed 's/^\-F \/.* \(rsync\)/\1/g')" + +# Scrub SSH -F argument for ghe-ssh commands +sh="$(echo "$sh" | sed 's/^\/.* --//g')" + # Also scrub sudo commands from stdin if just executing /bin/sh or /bin/bash and # piping commands in on standard input. if echo "$*" | grep -Eq "/bin/(ba)?sh$"; then From 723b5784544c3e1713a3b12e1a065db54139071d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 16:09:51 +0000 Subject: [PATCH 0416/2421] Use unified backup strategy --- bin/ghe-backup | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 54e6a9ef8..fcd8e63fb 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -155,13 +155,7 @@ failures="$failures mysql" bm_end "ghe-export-mysql" echo "Backing up Redis database ..." -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ghe-backup-redis-cluster > redis.rdb || - failures="$failures redis" -else - ghe-backup-redis > redis.rdb || - failures="$failures redis" -fi +ghe-backup-redis-cluster > redis.rdb || failures="$failures redis" echo "Backing up audit log ..." ghe-backup-es-audit-log || @@ -172,35 +166,16 @@ ghe-backup-es-hookshot || failures="$failures hookshot" echo "Backing up Git repositories ..." -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ghe-backup-repositories-cluster-ng || failures="$failures repositories" -else - ghe-backup-repositories-${GHE_BACKUP_STRATEGY} || - failures="$failures repositories" -fi +ghe-backup-repositories-cluster-ng || failures="$failures repositories" echo "Backing up GitHub Pages ..." -ghe-backup-pages-${GHE_BACKUP_STRATEGY} || -failures="$failures pages" +ghe-backup-pages-cluster || failures="$failures pages" -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - echo "Backing up storage data ..." - ghe-backup-alambic-cluster-ng || failures="$failures alambic" +echo "Backing up storage data ..." +ghe-backup-alambic-cluster-ng || failures="$failures alambic" - echo "Backing up custom Git hooks ..." - ghe-backup-git-hooks-cluster || - failures="$failures git-hooks" -else - echo "Backing up storage data ..." - ghe-backup-userdata storage || - failures="$failures storage" - - echo "Backing up custom Git hooks ..." - ghe-backup-userdata git-hooks/environments/tarballs || - failures="$failures git-hooks-environments" - ghe-backup-userdata git-hooks/repos || - failures="$failures git-hooks-repos" -fi +echo "Backing up custom Git hooks ..." +ghe-backup-git-hooks-cluster || failures="$failures git-hooks" if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then echo "Backing up Elasticsearch indices ..." From 0d9a68df7c59f514720a8630b0003a271226ea5e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 16:32:05 +0000 Subject: [PATCH 0417/2421] Remove unused commands --- .../ghe-backup-pages-rsync | 20 -- share/github-backup-utils/ghe-backup-redis | 39 --- .../ghe-backup-repositories-rsync | 239 ------------------ 3 files changed, 298 deletions(-) delete mode 100755 share/github-backup-utils/ghe-backup-pages-rsync delete mode 100755 share/github-backup-utils/ghe-backup-redis delete mode 100755 share/github-backup-utils/ghe-backup-repositories-rsync diff --git a/share/github-backup-utils/ghe-backup-pages-rsync b/share/github-backup-utils/ghe-backup-pages-rsync deleted file mode 100755 index 39770e828..000000000 --- a/share/github-backup-utils/ghe-backup-pages-rsync +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-pages-rsync -#/ Take an online, incremental snapshot of all Pages data. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup when the rsync strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -bm_start "$(basename $0)" - -# Make sure root backup dir exists if this is the first run -mkdir -p "$GHE_SNAPSHOT_DIR/pages" - -# Use the common user data rsync backup utility. -ghe-backup-userdata pages - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis deleted file mode 100755 index eb49a8b47..000000000 --- a/share/github-backup-utils/ghe-backup-redis +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-redis -#/ Take a snapshot of all Redis data. This is needed because older versions of -#/ the remote side ghe-export-redis command use a blocking SAVE instead of a -#/ non-blocking BGSAVE. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup command. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -bm_start "$(basename $0)" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# Force a redis BGSAVE, and wait for it to complete. -ghe-ssh "$GHE_HOSTNAME" /bin/bash < - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -bm_start "$(basename $0)" - -# Set up remote host and root backup snapshot directory based on config -host="$GHE_HOSTNAME" -backup_dir="$GHE_SNAPSHOT_DIR/repositories" - -# Location of last good backup for rsync --link-dest -backup_current="$GHE_DATA_DIR/current/repositories" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Make sure root backup dir exists if this is the first run -mkdir -p "$backup_dir" - -# Removes the remote sync-in-progress file on exit, re-enabling GC operations -# on the remote instance. -cleanup() { - # Enable remote GC operations - ghe-gc-enable $host -} -trap 'cleanup' EXIT -trap 'exit $?' INT # ^C always terminate - -# Disable remote GC operations -ghe-gc-disable $host - -# Transfer repository data from a GitHub instance to the current snapshot -# directory, using a previous snapshot to avoid transferring files that have -# already been transferred. A set of rsync filter rules are provided on stdin -# for each invocation. -rsync_repository_data () { - ghe-rsync -av \ - -e "ghe-ssh -p $(ssh_port_part "$host")" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --include-from=- --exclude=\* \ - "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 -} - -# If we have a previous increment, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$backup_current" ]; then - link_dest="--link-dest=../../current/repositories" -fi - -# Sync all auxiliary repository data. This includes files and directories like -# HEAD, audit_log, config, description, info/, etc. No refs or object data -# should be transferred here. -echo 1>&3 -echo "* Transferring auxiliary files ..." 1>&3 -rsync_repository_data -z <&3 -echo "* Transferring packed-refs files ..." 1>&3 -rsync_repository_data -z <&3 -echo "* Transferring refs and reflogs ..." 1>&3 -rsync_repository_data -z <&3 -echo "* Transferring objects and packs ..." 1>&3 -rsync_repository_data -H <&3 -echo "* Transferring special data directories ..." 1>&3 -rsync_repository_data <&3 - -bm_end "$(basename $0)" From 47300fa69e4409d8addde0527ca437a92310ed09 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 16:32:19 +0000 Subject: [PATCH 0418/2421] Accept -h hostname arg in testing --- test/bin/redis-cli | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/bin/redis-cli b/test/bin/redis-cli index 8428e47c0..761d87204 100755 --- a/test/bin/redis-cli +++ b/test/bin/redis-cli @@ -6,19 +6,27 @@ # and BGSAVE commands. set -e -case "$1" in +while true; do + case "$1" in LASTSAVE) # fake change last save timestamp every 1s date +%s + break ;; BGSAVE) mkdir -p "$GHE_REMOTE_DATA_USER_DIR/redis" echo "fake redis data" > "$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb" + break + ;; + -h) + # Fake accepting hostname argument + shift 2 ;; *) echo "unexpected redis-cli command: $1" 1>&2 exit 1 ;; -esac + esac +done true From 5e3965643ecd8987c4c77f3b8cc898d569e1e337 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 17:53:17 +0000 Subject: [PATCH 0419/2421] Remove old hostname/uuid method --- .../ghe-restore-repositories-dgit-ng | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 0f5dccf65..f4ab2d445 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -7,29 +7,15 @@ set -e sync_repo_info() { - # node names changed in 2.8 and `ghe-cluster-each -u` isn't available - # on GHE <= 2.7.X. We need to be backwards compatible. - if ghe-ssh "$GHE_HOSTNAME" test -f /data/user/common/uuid; then - for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do - if ! ghe-rsync -av --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to git-server-$uuid" 1>&2 - fi - done - else - for route in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -p`; do - if ! ghe-rsync -av --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "$route:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to $route" 1>&2 - fi - done - fi + for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do + if ! ghe-rsync -av --delete \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ + "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to git-server-$uuid" 1>&2 + fi + done } # Bring in the backup configuration From 08b22733d8086e0ad341286a5a3a1450f53e743d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 24 Jan 2018 18:02:30 +0000 Subject: [PATCH 0420/2421] Remove old metadata refs --- share/github-backup-utils/ghe-backup-config | 8 +------- test/testlib.sh | 15 ++------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b3c9a9770..ad386a038 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -163,12 +163,6 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP" # allows the location to be overridden in tests. : ${GHE_REMOTE_LICENSE_FILE:="$GHE_REMOTE_DATA_DIR/enterprise/enterprise.ghl"} -# The legacy location of the metadata file on the remote side. Only used if -# the newer "ghe-negotiate-version" script cannot be found or fails. This was -# "/data/enterprise/metadata.json" for GitHub instances. Use of this variable -# allows the location to be overridden in tests. -: ${GHE_REMOTE_METADATA_FILE:="$GHE_REMOTE_DATA_DIR/enterprise/chef_metadata.json"} - # The number of seconds to wait for in progress git-gc processes to complete # before starting the sync of git data. See share/github-backup-utils/ghe-backup-repositories-rsync # for more information. Default: 10 minutes. @@ -197,7 +191,7 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP" ghe_remote_version_config () { GHE_REMOTE_DATA_USER_DIR="$GHE_REMOTE_DATA_DIR/user" export GHE_REMOTE_DATA_DIR GHE_REMOTE_DATA_USER_DIR - export GHE_REMOTE_LICENSE_FILE GHE_REMOTE_METADATA_FILE + export GHE_REMOTE_LICENSE_FILE } ############################################################################### diff --git a/test/testlib.sh b/test/testlib.sh index 6e65ebe4f..5cbe3501b 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -89,19 +89,8 @@ cd "$TRASHDIR" # shellcheck disable=SC2120 setup_remote_metadata () { mkdir -p "$GHE_REMOTE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" - mkdir -p "$(dirname "$GHE_REMOTE_METADATA_FILE")" - - if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" - mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" - fi - - echo ' - { - "timestamp": "Wed Jul 30 13:48:52 +0000 2014", - "version": "'${1:-$GHE_TEST_REMOTE_VERSION}'" - } - ' > "$GHE_REMOTE_METADATA_FILE" + mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" + mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" } setup_remote_metadata From 6aedd63fc9d8e7b8f56e1883b49647c65ecb0dd3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 7 Feb 2018 14:40:41 +0000 Subject: [PATCH 0421/2421] Switch to using a single fake cmd for true --- test/bin/chown | 5 +---- test/bin/ghe-fake-true | 4 ++++ test/bin/ghe-maintenance | 5 +---- test/bin/service | 4 +--- 4 files changed, 7 insertions(+), 11 deletions(-) mode change 100755 => 120000 test/bin/chown create mode 100755 test/bin/ghe-fake-true mode change 100755 => 120000 test/bin/ghe-maintenance mode change 100755 => 120000 test/bin/service diff --git a/test/bin/chown b/test/bin/chown deleted file mode 100755 index 1906f79e4..000000000 --- a/test/bin/chown +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -# Fake chown command for tests. Avoids needing to creating special users for -# utilities that chown on the remote side. -true diff --git a/test/bin/chown b/test/bin/chown new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/chown @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file diff --git a/test/bin/ghe-fake-true b/test/bin/ghe-fake-true new file mode 100755 index 000000000..21cdd6b8e --- /dev/null +++ b/test/bin/ghe-fake-true @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +# Emulates a remote GitHub command that doesn't return any output. Tests use this to assert +# that a command was executed. +true diff --git a/test/bin/ghe-maintenance b/test/bin/ghe-maintenance deleted file mode 100755 index b8d83bee5..000000000 --- a/test/bin/ghe-maintenance +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -# Emulates a remote GitHub ghe-maintenance command. Tests use this to assert -# that a command was executed. -true diff --git a/test/bin/ghe-maintenance b/test/bin/ghe-maintenance new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/ghe-maintenance @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file diff --git a/test/bin/service b/test/bin/service deleted file mode 100755 index 12c98b95f..000000000 --- a/test/bin/service +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -# Fake service command for tests. -true diff --git a/test/bin/service b/test/bin/service new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/service @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From a137ffee01bb162a33c2800488ab01b5118cf9e3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sun, 11 Feb 2018 10:45:11 +0000 Subject: [PATCH 0422/2421] Add consistent and more optimised Pages cluster restore method --- .../ghe-restore-pages-dpages-ng | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100755 share/github-backup-utils/ghe-restore-pages-dpages-ng diff --git a/share/github-backup-utils/ghe-restore-pages-dpages-ng b/share/github-backup-utils/ghe-restore-pages-dpages-ng new file mode 100755 index 000000000..b748aacb5 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-pages-dpages-ng @@ -0,0 +1,129 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-pages-dpages-ng +#/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when restoring into a cluster. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# Find the pages to restore +pages_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 -maxdepth 5 | cut -d / -f2-) + +# No need to restore anything, early exit +if [ -z "$pages_paths" ]; then + echo "Warning: Pages backup missing. Skipping ..." + exit 0 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") + +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +tmp_list=$tempdir/tmp_list +routes_list=$tempdir/routes_list + +cleanup() { + rm -rf $tempdir + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir + true +} + +trap 'cleanup' EXIT + +# Build a list of pages paths to send to the server to calculate +# the restore routes, something like: +# +# 5/d3/d9/44/10 +# 0/02/e7/4f/27 +# 4/c1/6a/53/31 +# 3/34/17/3c/30 +# 6/6e/a9/ab/29 +# ... +# +# One pages path per line. +bm_start "$(basename $0) - Building pages list" +OLDIFS=$IFS; IFS=$'\n' +for path in $pages_paths; do + ghe_verbose "Adding path $path to the list of pages to send" + echo $path +done > $tmp_list +IFS=$OLDIFS +bm_end "$(basename $0) - Building pages list" + +bm_start "$(basename $0) - Transferring pages list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +bm_end "$(basename $0) - Transferring pages list" + +# The server returns a list of routes: +# +# 5/d3/d9/44/10 pages-server-1 pages-server-2 pages-server-3 +# 0/02/e7/4f/27 pages-server-1 pages-server-3 pages-server-4 +# 4/c1/6a/53/31 pages-server-2 pages-server-3 pages-server-4 +# 3/34/17/3c/30 pages-server-4 pages-server-2 pages-server-1 +# 6/6e/a9/ab/29 pages-server-3 pages-server-2 pages-server-1 +# ... +# +# One route per line. +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/dpages-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Transferring routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list +bm_end "$(basename $0) - Transferring routes" + +bm_start "$(basename $0) - Processing routes" +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +bm_end "$(basename $0) - Processing routes" + +bm_start "$(basename $0) - Restoring pages" +for file_list in $tempdir/*.rsync; do + server=$(basename $file_list .rsync) + ghe_verbose "* Transferring Pages to $server" + ghe-rsync -avrHR --delete \ + -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + --rsync-path="sudo -u git rsync" \ + --files-from=$file_list \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/./" \ + "$server:$GHE_REMOTE_DATA_USER_DIR/pages/" 1>&3 + done +bm_end "$(basename $0) - Restoring pages" + +bm_start "$(basename $0) - Finalizing routes" +ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Sun, 11 Feb 2018 10:45:35 +0000 Subject: [PATCH 0423/2421] Use optimised Pages cluster restore method, if available --- bin/ghe-restore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index bbb75d53f..ceef64f41 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -332,7 +332,12 @@ fi if $cluster; then echo "Restoring GitHub Pages into DPages..." - ghe-restore-pages-dpages "$GHE_HOSTNAME" 1>&3 + if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/dpages-cluster-restore-routes; then + ghe_verbose "* Using ghe-restore-pages-dpages-ng to restore" + ghe-restore-pages-dpages-ng "$GHE_HOSTNAME" 1>&3 + else + ghe-restore-pages-dpages "$GHE_HOSTNAME" 1>&3 + fi else echo "Restoring GitHub Pages ..." ghe-restore-pages-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 From 93266c191a66b091d5c93a6dca43cda2d05f2b1d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Feb 2018 14:38:41 +0000 Subject: [PATCH 0424/2421] Discard output from index check And add a comment to clarify which indices are restored. --- share/github-backup-utils/ghe-restore-es-audit-log | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index acd8e8a86..18d54b32c 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -24,8 +24,9 @@ indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.gz 2>/dev/null | last_month="audit_log(-[0-9]+)?-$(ghe-ssh "$GHE_HOSTNAME" 'date -d "1 month ago" +"%Y-%m"')(-[0-9]+)?" current_month="audit_log(-[0-9]+)?-$(ghe-ssh "$GHE_HOSTNAME" 'date +"%Y-%m"')(-[0-9]+)?" +# Only restore indices that don't exist and the last two months' indices. for index in $indices; do - if ! ghe-ssh "$GHE_HOSTNAME" "curl -f -s -XGET http://localhost:9201/$index" || [[ $index =~ $last_month ]] || [[ $index =~ $current_month ]]; then + if ! ghe-ssh "$GHE_HOSTNAME" "curl -f -s -XGET http://localhost:9201/$index > /dev/null" || [[ $index =~ $last_month ]] || [[ $index =~ $current_month ]]; then ghe_verbose "* Restoring $index" gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 fi From e5393a13812e849f7129201bb8dc4e733fb80556 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Feb 2018 18:30:56 +0000 Subject: [PATCH 0425/2421] Use a common function for initial restore env configured and maint mode --- test/test-ghe-restore.sh | 93 ++++++++-------------------------------- test/testlib.sh | 19 ++++++++ 2 files changed, 37 insertions(+), 75 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 5167efc14..7df08cedc 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -96,15 +96,8 @@ begin_test "ghe-restore into configured vm" rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata - # create file used to determine if instance has been configured. - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" # set restore host environ var GHE_RESTORE_HOST=127.0.0.1 @@ -175,15 +168,8 @@ begin_test "ghe-restore aborts without user verification" rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata - # create file used to determine if instance has been configured. - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" # set restore host environ var GHE_RESTORE_HOST=127.0.0.1 @@ -205,15 +191,8 @@ begin_test "ghe-restore accepts user verification" rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata - # create file used to determine if instance has been configured. - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" # set restore host environ var GHE_RESTORE_HOST=127.0.0.1 @@ -237,12 +216,8 @@ begin_test "ghe-restore -c into unconfigured vm" GHE_RESTORE_HOST=127.0.0.1 export GHE_RESTORE_HOST - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + # leave unconfigured, enable maintenance mode and create required directories + setup_maintenance_mode # run ghe-restore and write output to file for asserting against if ! ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then @@ -300,12 +275,8 @@ begin_test "ghe-restore into unconfigured vm" GHE_RESTORE_HOST=127.0.0.1 export GHE_RESTORE_HOST - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + # leave unconfigured, enable maintenance mode and create required directories + setup_maintenance_mode # ghe-restore into an unconfigured vm implies -c ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 @@ -357,15 +328,8 @@ begin_test "ghe-restore with host arg" rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata - # create file used to determine if instance has been configured. - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" # set restore host environ var GHE_RESTORE_HOST=127.0.0.1 @@ -403,15 +367,8 @@ begin_test "ghe-restore no host arg or configured restore host" rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata - # create file used to determine if instance has been configured. - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" # unset configured restore host unset GHE_RESTORE_HOST @@ -427,15 +384,8 @@ begin_test "ghe-restore with no pages backup" rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata - # create file used to determine if instance has been configured. - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" # remove pages data rm -rf "$GHE_DATA_DIR/1/pages" @@ -488,15 +438,8 @@ begin_test "ghe-restore cluster backup to non-cluster appliance" rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata - # create file used to determine if instance has been configured. - touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" - - # create file used to determine if instance is in maintenance mode. - mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" - touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" echo "cluster" > "$GHE_DATA_DIR/current/strategy" ! output=$(ghe-restore -v -f localhost 2>&1) diff --git a/test/testlib.sh b/test/testlib.sh index 5cbe3501b..c6b272b99 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -105,6 +105,25 @@ setup_remote_cluster () { touch "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" } +# Put the necessary files in place to mimic a configured, or not, instance into +# maintenance mode. +# +# Pass anything as the first argument to "configure" the instance +setup_maintenance_mode () { + configured=$1 + if [ -n "$configured" ]; then + # create file used to determine if instance has been configured. + touch "$GHE_REMOTE_ROOT_DIR/etc/github/configured" + fi + + # create file used to determine if instance is in maintenance mode. + mkdir -p "$GHE_REMOTE_DATA_DIR/github/current/public/system" + touch "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" + + # Create fake remote repositories dir + mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" +} + # Mark the beginning of a test. A subshell should immediately follow this # statement. begin_test () { From b8e2e01dfc8cd5b0bdaae460d91cbcba90184f99 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Feb 2018 18:39:48 +0000 Subject: [PATCH 0426/2421] Use a single function to create test data for backups and restores --- test/test-ghe-backup.sh | 78 +--------------------------- test/test-ghe-restore.sh | 82 +---------------------------- test/testlib.sh | 109 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 158 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 46bbc4ea5..11eeb2adc 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -8,83 +8,7 @@ # Create the backup data dir and fake remote repositories dirs mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" -# Create some fake pages data in the remote data directory -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/pages" -cd "$GHE_REMOTE_DATA_USER_DIR/pages" -pages1="4/c8/1e/72/2/legacy" -pages2="4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96" -mkdir -p "$pages1" "$pages2" -touch "$pages1/index.html" "$pages2/index.html" - -# Create a fake manage password file -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" -git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "fake password hash data" - -# Create some fake hooks in the remote data directory -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - -cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" -mkdir -p 123/abcdef 456/fed314 -touch 123/abcdef/script.sh 456/fed314/foo.sh - -cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" -mkdir -p 123/abcdef 456/fed314 -touch 123/abcdef/script.tar.gz 456/fed314/foo.tar.gz - -cd "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" -mkdir -p 321 654 -touch 321/script.sh 654/foo.sh - -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/storage/" -cd "$GHE_REMOTE_DATA_USER_DIR/storage/" -object1="2/20/e1" -object2="8/80/76" -object3="e/ed/1a" -mkdir -p "$object1" "$object2" "$object3" -touch "$object1/20e1b33c19d81f490716c470c0583772b05a153831d55441cc5e7711eda5a241" -touch "$object2/80766a2b18a96b9a5927ebdd980dc8d0820bea7ff0897b1b119af4bf20974d32" -touch "$object3/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" - -# Create a fake UUID -echo "fake-uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - -# Create fake audit log migration sentinel file -touch "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" - -# Create some fake elasticsearch data in the remote data directory -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" -cd "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" -mkdir -p gh-enterprise-es/node/0 -touch gh-enterprise-es/node/0/stuff1 -touch gh-enterprise-es/node/0/stuff2 - -# Create some test repositories in the remote repositories dir -mkdir "$GHE_REMOTE_DATA_USER_DIR/repositories" -mkdir -p "$TRASHDIR/hooks" -cd "$GHE_REMOTE_DATA_USER_DIR/repositories" -repo1="0/nw/01/aa/3f/1234/1234.git" -repo2="0/nw/01/aa/3f/1234/1235.git" -repo3="1/nw/23/bb/4c/2345/broken.git" -mkdir -p "$repo1" "$repo2" "$repo3" - -wiki1="0/nw/01/aa/3f/1234/1234.wiki.git" -mkdir -p "$wiki1" - -gist1="0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git" -gist2="1/23/bb/4c/gist/1234.git" -mkdir -p "$gist1" "$gist2" - -# Initialize test repositories with a fake commit -while IFS= read -r -d '' repo; do - git init -q --bare "$repo" - git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' - rm -rf "$repo/hooks" - ln -s "$TRASHDIR/hooks" "$repo/hooks" -done < <(find . -type d -name '*.git' -prune -print0) - -# Break a repo to test fsck -rm -f $repo3/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +setup_test_data $GHE_REMOTE_DATA_USER_DIR begin_test "ghe-backup first snapshot" ( diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 7df08cedc..8e9867b17 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -5,91 +5,11 @@ # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" -# Add some fake pages data to the snapshot -mkdir -p "$GHE_DATA_DIR/1/pages" -cd "$GHE_DATA_DIR/1/pages" -pages1="4/c8/1e/72/2/legacy" -pages2="4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96" -mkdir -p "$pages1" "$pages2" -touch "$pages1/index.html" "$pages2/index.html" - -# Add some fake elasticsearch data to the snapshot -mkdir -p "$GHE_DATA_DIR/1/elasticsearch" -cd "$GHE_DATA_DIR/1/elasticsearch" -mkdir -p gh-enterprise-es/node/0 -touch gh-enterprise-es/node/0/stuff1 -touch gh-enterprise-es/node/0/stuff2 - -# Set a temporary management console password -mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" -git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "foobar" - -# Create some fake environments -mkdir -p "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" -cd "$GHE_DATA_DIR/1/git-hooks/environments/tarballs" -mkdir -p 123 456 -touch 123/script.sh 456/foo.sh -cd 123 -tar -czf script.tar.gz script.sh -cd ../456 -tar -czf foo.tar.gz foo.sh -cd .. -rm 123/script.sh 456/foo.sh -mkdir -p "$GHE_DATA_DIR/1/git-hooks/repos/1" -touch "$GHE_DATA_DIR/1/git-hooks/repos/1/bar.sh" - -cd "$GHE_DATA_DIR/1/git-hooks/environments" -mkdir -p 123 456 -touch 123/script.sh 456/foo.sh - -# Create a fake uuid -echo "fake uuid" > "$GHE_DATA_DIR/1/uuid" - -# Add some fake repositories to the snapshot -mkdir -p "$GHE_DATA_DIR/1/repositories" -mkdir -p "$TRASHDIR/hooks" -cd "$GHE_DATA_DIR/1/repositories" -repo1="0/nw/01/aa/3f/1234/1234.git" -repo2="0/nw/01/aa/3f/1234/1235.git" -repo3="1/nw/23/bb/4c/2345/2345.git" -mkdir -p "$repo1" "$repo2" "$repo3" - -wiki1="0/nw/01/aa/3f/1234/1234.wiki.git" -mkdir -p "$wiki1" - -gist1="0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git" -gist2="1/23/bb/4c/gist/1234.git" -mkdir -p "$gist1" "$gist2" - -# Initialize test repositories with a fake commit -while IFS= read -r -d '' repo; do - git init -q --bare "$repo" - git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' - rm -rf "$repo/hooks" - ln -s "$TRASHDIR/hooks" "$repo/hooks" -done < <(find . -type d -name '*.git' -prune -print0) - -# Add some fake svn data to repo3 -echo "fake svn history data" > "$repo3/svn.history.msgpack" -mkdir "$repo3/svn_data" -echo "fake property history data" > "$repo3/svn_data/property_history.msgpack" +setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" -# create a fake backups for each datastore -echo "fake ghe-export-mysql data" | gzip > "$GHE_DATA_DIR/current/mysql.sql.gz" -echo "fake ghe-export-redis data" > "$GHE_DATA_DIR/current/redis.rdb" -echo "fake ghe-export-authorized-keys data" > "$GHE_DATA_DIR/current/authorized-keys.json" -echo "fake ghe-export-ssh-host-keys data" > "$GHE_DATA_DIR/current/ssh-host-keys.tar" -echo "fake ghe-export-settings data" > "$GHE_DATA_DIR/current/settings.json" -echo "fake ghe-export-ssl-ca-certificates data" > "$GHE_DATA_DIR/current/ssl-ca-certificates.tar" -echo "fake license data" > "$GHE_DATA_DIR/current/enterprise.ghl" -echo "fake password hash data" > "$GHE_DATA_DIR/current/manage-password" -echo "rsync" > "$GHE_DATA_DIR/current/strategy" -echo "$GHE_REMOTE_VERSION" > "$GHE_DATA_DIR/current/version" -touch "$GHE_DATA_DIR/current/es-scan-complete" - begin_test "ghe-restore into configured vm" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index c6b272b99..c485fb9f6 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -175,3 +175,112 @@ end_test () { skip_test() { exit 254 } + +# Create dummy data used for testing +# This same method can be used to generate the data used for testing backups +# and restores by passing in the appropriate location. +# +# +setup_test_data () { + local loc=$1 + + # Create some fake pages data in the remote data directory + mkdir -p "$loc/pages" + cd "$loc/pages" + export pages1="4/c8/1e/72/2/legacy" + export pages2="4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96" + mkdir -p "$pages1" "$pages2" + touch "$pages1/index.html" "$pages2/index.html" + + # Create a fake manage password file§ + mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "fake password hash data" + + # Create some fake hooks in the remote data directory + mkdir -p "$loc/git-hooks/environments/tarballs" + mkdir -p "$loc/git-hooks/repos" + + cd "$loc/git-hooks/environments" + mkdir -p 123/abcdef 456/fed314 + touch 123/abcdef/script.sh 456/fed314/foo.sh + + cd "$loc/git-hooks/environments/tarballs" + mkdir -p 123/abcdef 456/fed314 + touch 123/abcdef/script.tar.gz 456/fed314/foo.tar.gz + + cd "$loc/git-hooks/repos" + mkdir -p 321 654 + touch 321/script.sh 654/foo.sh + + mkdir -p "$loc/storage/" + cd "$loc/storage/" + object1="2/20/e1" + object2="8/80/76" + object3="e/ed/1a" + mkdir -p "$object1" "$object2" "$object3" + touch "$object1/20e1b33c19d81f490716c470c0583772b05a153831d55441cc5e7711eda5a241" + touch "$object2/80766a2b18a96b9a5927ebdd980dc8d0820bea7ff0897b1b119af4bf20974d32" + touch "$object3/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" + + common= + if [ "$loc" = "$GHE_REMOTE_DATA_USER_DIR" ]; then + common="common" + fi + # Create a fake UUID + echo "fake-uuid" > "$loc/$common/uuid" + + # Create fake audit log migration sentinel file + touch "$loc/$common/es-scan-complete" + + # Create some fake elasticsearch data in the remote data directory + mkdir -p "$loc/elasticsearch/gh-enterprise-es/node/0" + cd "$loc/elasticsearch" + touch gh-enterprise-es/node/0/stuff1 + touch gh-enterprise-es/node/0/stuff2 + + # Create some test repositories in the remote repositories dir + mkdir "$loc/repositories" + mkdir -p "$TRASHDIR/hooks" + cd "$loc/repositories" + repo1="0/nw/01/aa/3f/1234/1234.git" + repo2="0/nw/01/aa/3f/1234/1235.git" + repo3="1/nw/23/bb/4c/2345/broken.git" + mkdir -p "$repo1" "$repo2" "$repo3" + + wiki1="0/nw/01/aa/3f/1234/1234.wiki.git" + mkdir -p "$wiki1" + + gist1="0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git" + gist2="1/23/bb/4c/gist/1234.git" + mkdir -p "$gist1" "$gist2" + + # Initialize test repositories with a fake commit + while IFS= read -r -d '' repo; do + git init -q --bare "$repo" + git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' + rm -rf "$repo/hooks" + ln -s "$TRASHDIR/hooks" "$repo/hooks" + done < <(find . -type d -name '*.git' -prune -print0) + + # Add some fake svn data to repo2 + echo "fake svn history data" > "$repo2/svn.history.msgpack" + mkdir "$repo2/svn_data" + echo "fake property history data" > "$repo2/svn_data/property_history.msgpack" + + # Break a repo to test fsck + rm -f $repo3/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 + + if [ "$loc" != "$GHE_REMOTE_DATA_USER_DIR" ]; then + # create a fake backups for each datastore + echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" + echo "fake ghe-export-redis data" > "$loc/redis.rdb" + echo "fake ghe-export-authorized-keys data" > "$loc/authorized-keys.json" + echo "fake ghe-export-ssh-host-keys data" > "$loc/ssh-host-keys.tar" + echo "fake ghe-export-settings data" > "$loc/settings.json" + echo "fake ghe-export-ssl-ca-certificates data" > "$loc/ssl-ca-certificates.tar" + echo "fake license data" > "$loc/enterprise.ghl" + echo "fake password hash data" > "$loc/manage-password" + echo "rsync" > "$loc/strategy" + echo "$GHE_REMOTE_VERSION" > "$loc/version" + fi +} From b88f9f378a6613b7eb7abdfa5b6415f46cfae861 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Feb 2018 18:41:44 +0000 Subject: [PATCH 0427/2421] Use a single function to verify all restored data in tests --- test/test-ghe-restore.sh | 125 +++------------------------------------ test/testlib.sh | 41 +++++++++++++ 2 files changed, 49 insertions(+), 117 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 8e9867b17..9c6c30fcd 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -36,38 +36,8 @@ begin_test "ghe-restore into configured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # verify all import scripts were run - grep -q "$pages1/index.html" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" - - # verify settings import was *not* run due to instance already being - # configured. - ! grep -q "fake ghe-export-settings data" "$TRASHDIR/restore-out" - - # verify all repository data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/repositories" "$GHE_REMOTE_DATA_USER_DIR/repositories" - - # verify all pages data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - - # verify management console password was *not* restored - ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" - - # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - - # verify the UUID was transferred - diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] - fi + # Verify all the data we've restored is as expected + verify_all_restored_data ) end_test @@ -148,40 +118,8 @@ begin_test "ghe-restore -c into unconfigured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # verify all import scripts were run - grep -q "$pages1/index.html" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" - - # verify settings were imported - grep -q "fake ghe-export-settings data" "$TRASHDIR/restore-out" - - # verify all repository data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/repositories" "$GHE_REMOTE_DATA_USER_DIR/repositories" - - # verify all pages data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - - # verify management console password - grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" - - # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - - # verify the UUID was transferred - diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - - # verify ghe-export-ssl-ca-certificates was run - grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" - - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] - fi + # Verify all the data we've restored is as expected + verify_all_restored_data ) end_test @@ -205,40 +143,8 @@ begin_test "ghe-restore into unconfigured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # verify all import scripts were run - grep -q "$pages1/index.html" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" - - # verify settings were imported - grep -q "fake ghe-export-settings data" "$TRASHDIR/restore-out" - - # verify all repository data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/repositories" "$GHE_REMOTE_DATA_USER_DIR/repositories" - - # verify all pages data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - - # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - - # verify the UUID was transferred - diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - - # verify ghe-export-ssl-ca-certificates was run - grep -q "fake ghe-export-ssl-ca-certificates data" "$TRASHDIR/restore-out" - - # verify no config run after restore on unconfigured instance - ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" - - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] - fi + # Verify all the data we've restored is as expected + verify_all_restored_data ) end_test @@ -261,23 +167,8 @@ begin_test "ghe-restore with host arg" # verify host arg overrides configured restore host echo "$output" | grep -q 'Connect localhost:22 OK' - # verify repository data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/repositories" "$GHE_REMOTE_DATA_USER_DIR/repositories" - - # verify all pages data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - - # verify the UUID was transferred - diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] - fi + # Verify all the data we've restored is as expected + verify_all_restored_data ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index c485fb9f6..2a4b7b9c8 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -284,3 +284,44 @@ setup_test_data () { echo "$GHE_REMOTE_VERSION" > "$loc/version" fi } + +verify_all_restored_data() { + set -e + + # verify all import scripts were run + #grep -q "4/c8/1e/72/2/legacy/index.html" "$TRASHDIR/restore-out" + #grep -q "4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" "$TRASHDIR/restore-out" + grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" + grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" + grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" + grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" + + # verify settings import was *not* run due to instance already being + # configured. + ! grep -q "fake ghe-export-settings data" "$TRASHDIR/restore-out" + + # verify all repository data was transferred to the restore location + diff -ru "$GHE_DATA_DIR/current/repositories" "$GHE_REMOTE_DATA_USER_DIR/repositories" + + # verify all pages data was transferred to the restore location + #diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" + + # verify all ES data was transferred from live directory to the temporary restore directory + diff -ru "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" + + # verify management console password was *not* restored + ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" + + # verify all git hooks data was transferred + diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" + diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" + + # verify the UUID was transferred + diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" + + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] + fi +} From f755c06fc67e6bd35455afd4bee354b6f113bcb4 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 15 Feb 2018 10:38:30 +0000 Subject: [PATCH 0428/2421] Unify backup verification in testing --- test/test-ghe-backup.sh | 193 +--------------------------------------- test/testlib.sh | 76 ++++++++++++++++ 2 files changed, 79 insertions(+), 190 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 11eeb2adc..2d004d542 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -20,74 +20,7 @@ begin_test "ghe-backup first snapshot" # run it ghe-backup -v - # check that current symlink was created - [ -d "$GHE_DATA_DIR/current" ] - - # check that the version file was written - [ -f "$GHE_DATA_DIR/current/version" ] - [ "$(cat "$GHE_DATA_DIR/current/version")" = "v$GHE_TEST_REMOTE_VERSION" ] - - # check that the strategy file was written - [ -f "$GHE_DATA_DIR/current/strategy" ] - [ "$(cat "$GHE_DATA_DIR/current/strategy")" = "rsync" ] - - # check that settings were backed up - [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] - - # check that license was backed up - [ "$(cat "$GHE_DATA_DIR/current/enterprise.ghl")" = "fake license data" ] - - # check that repositories directory was created - [ -d "$GHE_DATA_DIR/current/repositories" ] - - # check that pages data was backed up - [ -f "$GHE_DATA_DIR/current/pages/4/c8/1e/72/2/legacy/index.html" ] - [ -f "$GHE_DATA_DIR/current/pages/4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" ] - - # check that mysql data was backed up - [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] - - # check that redis data was backed up - [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] - - # check that ssh public keys were backed up - [ "$(cat "$GHE_DATA_DIR/current/authorized-keys.json")" = "fake ghe-export-authorized-keys data" ] - - # check that ssh host key was backed up - [ "$(cat "$GHE_DATA_DIR/current/ssh-host-keys.tar")" = "fake ghe-export-ssh-host-keys data" ] - - # verify all repository data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/current/repositories" - - # verify all pages data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/pages" "$GHE_DATA_DIR/current/pages" - - # verify all ES data was transferred from live directory - diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" - - # verify manage-password file was backed up under v2.x VMs - [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - - # verify all git hooks tarballs were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" - - # verify the extracted environments were not transferred - ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" - - # verify the extracted repositories were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - - # verify the UUID was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" - - # check that ca certificates were backed up - [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] - - # verify the audit log migration sentinel file has been created - [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] - - # verify that ghe-backup wrote its version information to the host - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] + verify_all_backedup_data ) end_test @@ -111,63 +44,7 @@ begin_test "ghe-backup subsequent snapshot" this_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') [ "$first_snapshot" != "$this_snapshot" ] - # check that current symlink was created - [ -d "$GHE_DATA_DIR/current" ] - - # check that settings were backed up - [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] - - # check that license was backed up - [ "$(cat "$GHE_DATA_DIR/current/enterprise.ghl")" = "fake license data" ] - - # check that repositories directory was created - [ -d "$GHE_DATA_DIR/current/repositories" ] - - # check that pages data was backed up - [ -f "$GHE_DATA_DIR/current/pages/4/c8/1e/72/2/legacy/index.html" ] - [ -f "$GHE_DATA_DIR/current/pages/4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" ] - - # check that mysql data was backed up - [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] - - # check that redis data was backed up - [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] - - # check that ssh public keys were backed up - [ "$(cat "$GHE_DATA_DIR/current/authorized-keys.json")" = "fake ghe-export-authorized-keys data" ] - - # check that ssh host key was backed up - [ "$(cat "$GHE_DATA_DIR/current/ssh-host-keys.tar")" = "fake ghe-export-ssh-host-keys data" ] - - # verify all repository data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/current/repositories" - - # verify all pages data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/pages" "$GHE_DATA_DIR/current/pages" - - # verify all ES data was transferred from live directory - diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" - - # verify manage-password file was backed up under v2.x VMs - [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - - # verify all git hooks tarballs were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" - - # verify the extracted environments were not transferred - ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" - - # verify the extracted repositories were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - - # verify the UUID was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" - - # check that ca certificates were backed up - [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] - - # verify the audit log migration sentinel file has been created - [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] + verify_all_backedup_data ) end_test @@ -206,71 +83,7 @@ begin_test "ghe-backup with relative data dir path" # check that current symlink points to new snapshot [ "$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.*-> //')" = "$GHE_SNAPSHOT_TIMESTAMP" ] - # check that the version file was written - [ -f "$GHE_DATA_DIR/current/version" ] - [ "$(cat "$GHE_DATA_DIR/current/version")" = "v$GHE_TEST_REMOTE_VERSION" ] - - # check that the strategy file was written - [ -f "$GHE_DATA_DIR/current/strategy" ] - [ "$(cat "$GHE_DATA_DIR/current/strategy")" = "rsync" ] - - # check that settings were backed up - [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] - - # check that license was backed up - [ "$(cat "$GHE_DATA_DIR/current/enterprise.ghl")" = "fake license data" ] - - # check that repositories directory was created - [ -d "$GHE_DATA_DIR/current/repositories" ] - - # check that pages data was backed up - [ -f "$GHE_DATA_DIR/current/pages/4/c8/1e/72/2/legacy/index.html" ] - [ -f "$GHE_DATA_DIR/current/pages/4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" ] - - # check that mysql data was backed up - [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] - - # check that redis data was backed up - [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] - - # check that ssh public keys were backed up - [ "$(cat "$GHE_DATA_DIR/current/authorized-keys.json")" = "fake ghe-export-authorized-keys data" ] - - # check that ssh host key was backed up - [ "$(cat "$GHE_DATA_DIR/current/ssh-host-keys.tar")" = "fake ghe-export-ssh-host-keys data" ] - - # verify all repository data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/current/repositories" - - # verify all pages data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/pages" "$GHE_DATA_DIR/current/pages" - - # verify all ES data was transferred from live directory - diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" - - # verify manage-password file was backed up under v2.x VMs - [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - - # verify all git hooks tarballs were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" - - # verify the extracted environments were not transferred - ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" - - # verify the extracted repositories were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - - # verify the UUID was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" - - # check that ca certificates were backed up - [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] - - # verify the audit log migration sentinel file has been created - [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] - - # verify that ghe-backup wrote its version information to the host - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] + verify_all_backedup_data ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index 2a4b7b9c8..140da22c8 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -285,6 +285,82 @@ setup_test_data () { fi } +# A unified method to check everything backed up when performing a full backup +# during testing. +verify_all_backedup_data() { + set -e + # check that current symlink was created + [ -d "$GHE_DATA_DIR/current" ] + + # check that the version file was written + [ -f "$GHE_DATA_DIR/current/version" ] + [ "$(cat "$GHE_DATA_DIR/current/version")" = "v$GHE_TEST_REMOTE_VERSION" ] + + # check that the strategy file was written + [ -f "$GHE_DATA_DIR/current/strategy" ] + [ "$(cat "$GHE_DATA_DIR/current/strategy")" = "rsync" ] + + # check that settings were backed up + [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] + + # check that license was backed up + [ "$(cat "$GHE_DATA_DIR/current/enterprise.ghl")" = "fake license data" ] + + # check that repositories directory was created + [ -d "$GHE_DATA_DIR/current/repositories" ] + + # check that pages data was backed up + [ -f "$GHE_DATA_DIR/current/pages/4/c8/1e/72/2/legacy/index.html" ] + [ -f "$GHE_DATA_DIR/current/pages/4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" ] + + # check that mysql data was backed up + [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] + + # check that redis data was backed up + [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] + + # check that ssh public keys were backed up + [ "$(cat "$GHE_DATA_DIR/current/authorized-keys.json")" = "fake ghe-export-authorized-keys data" ] + + # check that ssh host key was backed up + [ "$(cat "$GHE_DATA_DIR/current/ssh-host-keys.tar")" = "fake ghe-export-ssh-host-keys data" ] + + # verify all repository data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/current/repositories" + + # verify all pages data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/pages" "$GHE_DATA_DIR/current/pages" + + # verify all ES data was transferred from live directory + diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" + + # verify manage-password file was backed up under v2.x VMs + [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] + + # verify all git hooks tarballs were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" + + # verify the extracted environments were not transferred + ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" + + # verify the extracted repositories were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" + + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + + # check that ca certificates were backed up + [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] + + # verify the audit log migration sentinel file has been created + [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] + + # verify that ghe-backup wrote its version information to the host + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] +} + +# A unified method to check everything restored when performing a full restore +# during testing. verify_all_restored_data() { set -e From e15c69df17552685ea857a9c324696a54869d7d3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 09:48:00 +0000 Subject: [PATCH 0429/2421] rsync and cluster are the only strategies --- bin/ghe-backup | 4 ++-- share/github-backup-utils/ghe-backup-strategy | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index fcd8e63fb..e8ca183fb 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -177,9 +177,9 @@ ghe-backup-alambic-cluster-ng || failures="$failures alambic" echo "Backing up custom Git hooks ..." ghe-backup-git-hooks-cluster || failures="$failures git-hooks" -if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then +if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then echo "Backing up Elasticsearch indices ..." - ghe-backup-es-${GHE_BACKUP_STRATEGY} || + ghe-backup-es-rsync || failures="$failures elasticsearch" fi diff --git a/share/github-backup-utils/ghe-backup-strategy b/share/github-backup-utils/ghe-backup-strategy index 22d1ba029..5efcdfb34 100755 --- a/share/github-backup-utils/ghe-backup-strategy +++ b/share/github-backup-utils/ghe-backup-strategy @@ -9,12 +9,10 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - echo "rsync" -elif ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then echo "cluster" else From 5af47868461b87e60b545a19ecc470d592e0face Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 10:30:55 +0000 Subject: [PATCH 0430/2421] Block on pre-2.11 instances --- bin/ghe-host-check | 8 ++++++++ test/test-ghe-backup.sh | 7 +++++++ test/test-ghe-host-check.sh | 10 ++++++++++ test/test-ghe-restore.sh | 10 ++++++++++ 4 files changed, 35 insertions(+) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 6c83ea3ff..53a13f0c4 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -90,4 +90,12 @@ if [ -z "$version" ]; then exit 2 fi +# backup-utils 2.13 onwards only has support for 2.11 and newer versions. +if ! echo "v$version" | grep -Eq "v2\.1[1-9]|v[3-9]"; then + echo "Error: old release of GitHub Enterprise detected." 1>&2 + echo "Backup Utilities $BACKUP_UTILS_VERSION requires GitHub Enterprise v2.11 or newer." 1>&2 + echo "Please update your GitHub Enterprise appliance of use backup-utils v2.11.4." 1>&2 + exit 1 +fi + echo "Connect $hostname:$port OK (v$version)" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 2d004d542..37b57b515 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -246,3 +246,10 @@ begin_test "ghe-backup honours --help and -h flags" ) end_test + +begin_test "ghe-backup exits early on unsupported version" +( + set -e + ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-backup -v +) +end_test diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 8ced6b09b..a54d099f7 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -48,3 +48,13 @@ begin_test "ghe-host-check honours --help and -h flags" ) end_test + +begin_test "ghe-host-check detects unsupported GitHub Enterprise versions" +( + set -e + ! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.13.999 ghe-host-check + GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check +) +end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 9c6c30fcd..66546bcc7 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -385,3 +385,13 @@ begin_test "ghe-restore force restore of 2.9/2.10 snapshot without audit log mig ghe-restore -v -f localhost ) end_test + +begin_test "ghe-backup exits early on unsupported version" +( + set -e + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-restore -v +) +end_test From 59c5c3ffa0bc6a74e4d3d8ff4abb4cdb5cc886c6 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 11:10:30 +0000 Subject: [PATCH 0431/2421] Standardize storage restore methods --- .../ghe-restore-alambic-cluster-ng | 65 ++++++++++--------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 1bac460d0..9a05dcc98 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -8,6 +8,7 @@ set -e # Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config # Show usage and bail with no arguments @@ -42,15 +43,16 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") - tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$tempdir/ssh_config -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list -routes_list=$tempdir/routes_list +to_restore=$tempdir/to_restore + +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") + +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" cleanup() { rm -rf $tempdir @@ -73,49 +75,54 @@ bm_start "$(basename $0) - Building object list" echo "$storage_paths" | awk '{print $2 " " $1}' | awk -F/ '{print $NF }' > $tmp_list bm_end "$(basename $0) - Building object list" -ghe_verbose "* Sending the object list to the server..." - -# The server receives the list of objects and returns the list servers where the objects will be sent. -# The format of the list returned by the server: +# The server returns the list of servers where the objects will be sent: # # # OID SERVER1 SERVER2 SERVER2 # b8a48b6b122b4ef8175348d1d6fbd846d3b3ccc8fd7552b79f91125c4958e43b server1 server2 server3 # bc4cdd292e6b5387df2a42a907fcd5f3b6804a5d5ab427184faea5ef118d635e server1 server2 server3 +# ... +# +# One route per line. +# +bm_start "$(basename $0) - Calculating sync routes" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/storage-cluster-restore-routes \ + | while read route; do + ghe_verbose "Got restore route $route" + servers=$(echo $route | cut -d ' ' -f2-) + object=$(echo $route | cut -d ' ' -f1) + for server in $servers; do + ghe_verbose "Adding $object to $tempdir/$server.rsync" + echo "$object" | awk '{ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1}' >> $tempdir/$server.rsync + echo "$route" >> $to_restore + done +done +bm_end "$(basename $0) - Calculating sync routes" -bm_start "$(basename $0) - Transferring object list" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list -bm_end "$(basename $0) - Transferring object list" - -bm_start "$(basename $0) - Generating routes" -echo "cat $tmp_list | github-env ./bin/storage-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash -bm_end "$(basename $0) - Generating routes" - -bm_start "$(basename $0) - Transferring routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list -bm_end "$(basename $0) - Transferring routes" - -bm_start "$(basename $0) - Processing routes" -cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' -bm_end "$(basename $0) - Processing routes" +if ! ls $tempdir/*.rsync >/dev/null 2>&1; then + echo "Warning: no routes found, skipping storage restore ..." + exit 0 +fi # rsync all the objects to the storage server where they belong. # One rsync invocation per server available. bm_start "$(basename $0) - Restoring objects" -for route in $tempdir/*.rsync; do - ghe_verbose "* rsync data to $(basename $route .rsync) ..." - ghe-rsync -arHR --delete \ +for file_list in $tempdir/*.rsync; do + server=$(basename $file_list .rsync) + ghe_verbose "* Transferring data to $server ..." + ghe-rsync -arvHR --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ - --files-from=$route \ + --files-from=$file_list \ --size-only \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ - "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/storage/" + "$server:$GHE_REMOTE_DATA_USER_DIR/storage/" 1>&3 done bm_end "$(basename $0) - Restoring objects" bm_start "$(basename $0) - Finalizing routes" +cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Sat, 17 Feb 2018 11:10:52 +0000 Subject: [PATCH 0432/2421] Standardize pages restore methods --- .../ghe-restore-pages-dpages-ng | 47 +++++++++++-------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-pages-dpages-ng b/share/github-backup-utils/ghe-restore-pages-dpages-ng index b748aacb5..bc2effd7c 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages-ng +++ b/share/github-backup-utils/ghe-restore-pages-dpages-ng @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage @@ -41,15 +42,16 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") - tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list -routes_list=$tempdir/routes_list +to_restore=$tempdir/to_restore + +hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") + +ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" cleanup() { rm -rf $tempdir @@ -79,10 +81,6 @@ done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building pages list" -bm_start "$(basename $0) - Transferring pages list" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list -bm_end "$(basename $0) - Transferring pages list" - # The server returns a list of routes: # # 5/d3/d9/44/10 pages-server-1 pages-server-2 pages-server-3 @@ -93,17 +91,25 @@ bm_end "$(basename $0) - Transferring pages list" # ... # # One route per line. -bm_start "$(basename $0) - Generating routes" -echo "cat $tmp_list | github-env ./bin/dpages-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -bm_end "$(basename $0) - Generating routes" - -bm_start "$(basename $0) - Transferring routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list -bm_end "$(basename $0) - Transferring routes" +# +bm_start "$(basename $0) - Calculating sync routes" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/dpages-cluster-restore-routes \ + | while read route; do + ghe_verbose "Got restore route $route" + servers=$(echo $route | cut -d ' ' -f2-) + page=$(echo $route | cut -d ' ' -f1) + for server in $servers; do + ghe_verbose "Adding $page to $tempdir/$server.rsync" + echo "$page" >> $tempdir/$server.rsync + echo "$route" >> $to_restore + done +done +bm_end "$(basename $0) - Calculating sync routes" -bm_start "$(basename $0) - Processing routes" -cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' -bm_end "$(basename $0) - Processing routes" +if ! ls $tempdir/*.rsync >/dev/null 2>&1; then + echo "Warning: no routes found, skipping storage restore ..." + exit 0 +fi bm_start "$(basename $0) - Restoring pages" for file_list in $tempdir/*.rsync; do @@ -119,8 +125,9 @@ for file_list in $tempdir/*.rsync; do bm_end "$(basename $0) - Restoring pages" bm_start "$(basename $0) - Finalizing routes" +cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Sat, 17 Feb 2018 11:11:26 +0000 Subject: [PATCH 0433/2421] Standardize repos restore methods --- .../ghe-restore-repositories-dgit-ng | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index f4ab2d445..122038097 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -19,7 +19,8 @@ sync_repo_info() { } # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage @@ -57,7 +58,6 @@ ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$tempdir/ssh_config opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list -routes_list=$tempdir/routes_list to_restore=$tempdir/to_restore hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") @@ -101,10 +101,6 @@ done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building network list" -bm_start "$(basename $0) - Transferring network list" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list -bm_end "$(basename $0) - Transferring network list" - # The server returns a list of routes: # # a/nw/a8/3f/02/100000855 dgit-node1 dgit-node2 dgit-node3 @@ -113,24 +109,31 @@ bm_end "$(basename $0) - Transferring network list" # ... # # One route per line. -bm_start "$(basename $0) - Generating routes" -echo "cat $tmp_list | github-env ./bin/dgit-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -bm_end "$(basename $0) - Generating routes" - -bm_start "$(basename $0) - Transferring routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list -bm_end "$(basename $0) - Transferring routes" +# +bm_start "$(basename $0) - Calculating sync routes" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/dgit-cluster-restore-routes \ + | while read route; do + ghe_verbose "Got restore route $route" + servers=$(echo $route | cut -d ' ' -f2-) + network_path=$(echo $route | cut -d ' ' -f1) + for server in $servers; do + ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync + echo "$route" | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' >> $to_restore + done +done +bm_end "$(basename $0) - Calculating sync routes" -bm_start "$(basename $0) - Processing routes" -cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' -cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore -bm_end "$(basename $0) - Processing routes" +if ! ls $tempdir/*.rsync >/dev/null 2>&1; then + echo "Warning: no routes found, skipping repositories restore ..." + exit 0 +fi bm_start "$(basename $0) - Restoring repository networks" # rsync all the repositories for file_list in $tempdir/*.rsync; do server=$(basename $file_list .rsync) - ghe_verbose "* Transferring repository networks to $server" + ghe_verbose "* Transferring repository networks to $server ..." ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ @@ -144,7 +147,7 @@ bm_end "$(basename $0) - Restoring repository networks" bm_start "$(basename $0) - Finalizing routes" cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Sat, 17 Feb 2018 11:15:55 +0000 Subject: [PATCH 0434/2421] Don't toggle gc when testing --- share/github-backup-utils/ghe-gc-disable | 6 +++++- share/github-backup-utils/ghe-gc-enable | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-gc-disable b/share/github-backup-utils/ghe-gc-disable index fd3065007..561520d8f 100755 --- a/share/github-backup-utils/ghe-gc-disable +++ b/share/github-backup-utils/ghe-gc-disable @@ -9,7 +9,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" while true; do case "$1" in @@ -28,6 +29,9 @@ done # Show usage with no host [ -z "$host" ] && print_usage +# Exit early when testing +[ -n "$GHE_TEST_REMOTE_VERSION" ] && exit 0 + # Touch the sync-in-progress file, disabling GC operations, and wait for all # active GC processes to finish on the remote side. echo " diff --git a/share/github-backup-utils/ghe-gc-enable b/share/github-backup-utils/ghe-gc-enable index 5ecf4e1bc..b08747519 100755 --- a/share/github-backup-utils/ghe-gc-enable +++ b/share/github-backup-utils/ghe-gc-enable @@ -9,7 +9,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" while true; do case "$1" in @@ -28,4 +29,7 @@ done # Show usage with no host [ -z "$host" ] && print_usage +# Exit early when testing +[ -n "$GHE_TEST_REMOTE_VERSION" ] && exit 0 + ghe-ssh $opts "$host" -- "sudo rm -f '$SYNC_IN_PROGRESS_FILE'" From 3277dd612e3f6000ae38f693903e89f4e2d93600 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 11:19:55 +0000 Subject: [PATCH 0435/2421] Standardize gists restore methods --- .../ghe-restore-repositories-gist-ng | 69 +++++++++++++------ 1 file changed, 47 insertions(+), 22 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 3015fb031..0629fbcb3 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -47,7 +47,6 @@ ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file=$tempdir/ssh_config opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" tmp_list=$tempdir/tmp_list -routes_list=$tempdir/routes_list to_restore=$tempdir/to_restore hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") @@ -60,48 +59,74 @@ cleanup() { } trap cleanup EXIT -# Find the routes (servers) for each gist available locally +# Build a list of gist paths to send to the server to calculate +# the restore routes, something like: +# +# a/a8/3f/02/gist +# a/a8/bc/8d/gist +# a/a5/06/81/gist +# a/a5/84/6f/gist +# a/a5/e0/01/gist +# ... +# +# One network path per line. bm_start "$(basename $0) - Building gist list" OLDIFS=$IFS; IFS=$'\n' for path in $gist_paths; do - echo $path + ghe_verbose "Adding gist $path to the list of networks to send" + echo $path done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building gist list" -bm_start "$(basename $0) - Transferring gist list" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list -bm_end "$(basename $0) - Transferring gist list" - -bm_start "$(basename $0) - Generating routes" -echo "cat $tmp_list | github-env ./bin/gist-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -bm_end "$(basename $0) - Generating routes" - -bm_start "$(basename $0) - Transferring routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $routes_list -bm_end "$(basename $0) - Transferring routes" +# The server returns a list of routes: +# +# a/a8/3f/02/gist dgit-node3 dgit-node2 dgit-node4 +# a/a8/bc/8d/gist dgit-node3 dgit-node2 dgit-node4 +# a/a5/06/81/gist dgit-node3 dgit-node2 dgit-node4 +# a/a5/84/6f/gist dgit-node1 dgit-node2 dgit-node4 +# a/a5/e0/01/gist dgit-node1 dgit-node2 dgit-node3 +# ... +# +# One route per line. +# +bm_start "$(basename $0) - Calculating Sync Routes" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/gist-cluster-restore-routes \ + | while read route; do + ghe_verbose "Got restore route $route" + servers=$(echo $route | cut -d ' ' -f2-) + network_path=$(echo $route | cut -d ' ' -f1) + for server in $servers; do + ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync + echo "$route" | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' >> $to_restore + done +done +bm_end "$(basename $0) - Calculating Sync Routes" -bm_start "$(basename $0) - Processing routes" -cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' -cat $routes_list | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore -bm_end "$(basename $0) - Processing routes" +if ! ls $tempdir/*.rsync >/dev/null 2>&1; then + echo "Warning: no routes found, skipping gists restore ..." + exit 0 +fi # rsync all the gist repositories bm_start "$(basename $0) - Restoring gists" -for route in $tempdir/*.rsync; do +for file_list in $tempdir/*.rsync; do + server=$(basename $file_list .rsync) + ghe_verbose "* Transferring gists to $server" ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ - --files-from=$route \ + --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$(basename $route .rsync):$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 done bm_end "$(basename $0) - Restoring gists" bm_start "$(basename $0) - Finalizing routes" cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Sat, 17 Feb 2018 11:21:08 +0000 Subject: [PATCH 0436/2421] Ensure tarballs and repos dirs exist --- share/github-backup-utils/ghe-restore-git-hooks-cluster | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index df7514523..241530396 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -52,6 +52,7 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; hostname=$(echo $hostnames | awk '{ print $1; }') if [ -n "$hostname" ]; then + ghe-ssh "$hostname" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" ghe-rsync -avH --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ @@ -67,6 +68,7 @@ fi if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos" ]; then for hostname in $hostnames; do + ghe-ssh "$hostname" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" ghe-rsync -avH --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ From fb08823f8f95bd39b6d23be45f911712af45be55 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 11:21:29 +0000 Subject: [PATCH 0437/2421] Use ghe-ssh --- share/github-backup-utils/ghe-restore-git-hooks-cluster | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index 241530396..df0ee75b2 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -61,7 +61,7 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; for tarball in $tarballs; do env_id=$(echo $tarball | cut -d '/' -f 2) - ssh -q $opts -p $port -F $ssh_config_file -l $user $hostname "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" 1>&3 2>&3 + ghe-ssh -F $ssh_config_file -l $user "$hostname:122" -- "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" 1>&3 2>&3 done fi fi From bab9ca96014827fccdff82c58192209e881238a7 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 11:22:07 +0000 Subject: [PATCH 0438/2421] Mimic no index during testing --- test/bin/curl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/bin/curl b/test/bin/curl index 273512f80..30767c84f 100755 --- a/test/bin/curl +++ b/test/bin/curl @@ -6,6 +6,9 @@ set -e # Return empty list of indexes for ghe-backup-es-audit-log if echo "$@" | grep -q '_cat/indices/audit_log\*?h=index$'; then exit 0 +# Exit with non-zero code to mimic a non-existant index +elif echo "$@" | grep -q 'localhost:9201/audit_log'; then + exit 1 fi # Write args to stdout From 00e428c5359c9dfe8fb8d36c7961bb72d8157921 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 11:22:35 +0000 Subject: [PATCH 0439/2421] Scrub more cmds --- test/bin/ssh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/bin/ssh b/test/bin/ssh index 9218f696d..afd1c5fac 100755 --- a/test/bin/ssh +++ b/test/bin/ssh @@ -33,12 +33,15 @@ cd "$(dirname "$0")"/.. # Scrub sudo commands from command arguments. sh="$(echo "$@" | sed 's/sudo -u [a-z]* //g' | sed 's/sudo //g')" -# Scrub SSH arguments passed to rsync +# Scrub SSH -F argument passed to rsync sh="$(echo "$sh" | sed 's/^\-F \/.* \(rsync\)/\1/g')" # Scrub SSH -F argument for ghe-ssh commands sh="$(echo "$sh" | sed 's/^\/.* --//g')" +# Scrub /usr/local/share/enterprise/ from paths of commands +sh=$(echo "$sh" | sed 's|/usr/local/share/enterprise/ghe-|ghe-|g') + # Also scrub sudo commands from stdin if just executing /bin/sh or /bin/bash and # piping commands in on standard input. if echo "$*" | grep -Eq "/bin/(ba)?sh$"; then From 0972252daff37667429dff7580044e12ac20f7b2 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 11:24:19 +0000 Subject: [PATCH 0440/2421] More fake cmds for use during testing --- test/bin/dgit-cluster-restore-finalize | 1 + test/bin/dgit-cluster-restore-routes | 11 +++++++++++ test/bin/dpages-cluster-restore-finalize | 1 + test/bin/dpages-cluster-restore-routes | 9 +++++++++ test/bin/ghe-es-load-json | 1 + test/bin/gist-cluster-restore-finalize | 1 + test/bin/gist-cluster-restore-routes | 1 + test/bin/storage-cluster-restore-finalize | 1 + test/bin/storage-cluster-restore-routes | 10 ++++++++++ test/test-ghe-backup-es-audit-log | 1 + test/test-ghe-backup-es-hookshot | 0 test/test-ghe-restore-es-audit-log | 9 +++++++++ test/test-ghe-restore-es-hookshot | 9 +++++++++ 13 files changed, 55 insertions(+) create mode 120000 test/bin/dgit-cluster-restore-finalize create mode 100755 test/bin/dgit-cluster-restore-routes create mode 120000 test/bin/dpages-cluster-restore-finalize create mode 100755 test/bin/dpages-cluster-restore-routes create mode 120000 test/bin/ghe-es-load-json create mode 120000 test/bin/gist-cluster-restore-finalize create mode 120000 test/bin/gist-cluster-restore-routes create mode 120000 test/bin/storage-cluster-restore-finalize create mode 100755 test/bin/storage-cluster-restore-routes create mode 100644 test/test-ghe-backup-es-audit-log create mode 100644 test/test-ghe-backup-es-hookshot create mode 100644 test/test-ghe-restore-es-audit-log create mode 100644 test/test-ghe-restore-es-hookshot diff --git a/test/bin/dgit-cluster-restore-finalize b/test/bin/dgit-cluster-restore-finalize new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/dgit-cluster-restore-finalize @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file diff --git a/test/bin/dgit-cluster-restore-routes b/test/bin/dgit-cluster-restore-routes new file mode 100755 index 000000000..bc96902a4 --- /dev/null +++ b/test/bin/dgit-cluster-restore-routes @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Usage: dgit-cluster-restore-routes / gist-cluster-restore-routes +# Emulates the remote GitHub [dgit|gist]-cluster-restore-routes commands. Tests use this +# to assert that the command was executed. +set -e +cat < audit_log-1-$log-1.gz +done diff --git a/test/test-ghe-restore-es-hookshot b/test/test-ghe-restore-es-hookshot new file mode 100644 index 000000000..e58ae181e --- /dev/null +++ b/test/test-ghe-restore-es-hookshot @@ -0,0 +1,9 @@ +# Create fake hookshot logs +mkdir -p "$loc/hookshot" +cd "$loc/hookshot" +ano_day="2017-01-20" +yest_day=$(date -v-1d +"%Y-%m-%d") +today=$(date +"%Y-%m-%d") +for log in $ano_day $yest_day $today; do + echo "fake-hookshot-log-$log" | gzip > hookshot-logs-$log.gz +done From 3727e31210e785f2d291d23843b71889fe12e34b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 11:34:39 +0000 Subject: [PATCH 0441/2421] Remove empty and missing UUID tests Supported versions will always have a UUID now. Backups and restores will fail without it. --- test/test-ghe-restore.sh | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 66546bcc7..4d3ee8798 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -206,43 +206,6 @@ begin_test "ghe-restore with no pages backup" ) end_test -begin_test "ghe-restore with empty uuid file" -( - set -e - - # Remove the UUID from the remote instance - rm -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - - # Zero-length the UUID file - cat /dev/null > "$GHE_DATA_DIR/current/uuid" - - # Run a restore - ghe-restore -v -f localhost - - # Verify no uuid is restored - [ ! -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" ] - -) -end_test - -begin_test "ghe-restore with no uuid file" -( set -e - - # Remove the UUID from the remote instance - rm -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - - # Remove the UUID file - rm -f "$GHE_DATA_DIR/current/uuid" - - # Run a restore - ghe-restore -v -f localhost - - # Verify no uuid is restored - [ ! -f "$GHE_REMOTE_DATA_USER_DIR/common/uuid" ] - -) -end_test - begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e From 28ffd3b432f0c8cdc520717275cedc22b0673aca Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 12:19:16 +0000 Subject: [PATCH 0442/2421] Remove accidentally added files --- test/test-ghe-backup-es-audit-log | 1 - test/test-ghe-backup-es-hookshot | 0 test/test-ghe-restore-es-audit-log | 9 --------- test/test-ghe-restore-es-hookshot | 9 --------- 4 files changed, 19 deletions(-) delete mode 100644 test/test-ghe-backup-es-audit-log delete mode 100644 test/test-ghe-backup-es-hookshot delete mode 100644 test/test-ghe-restore-es-audit-log delete mode 100644 test/test-ghe-restore-es-hookshot diff --git a/test/test-ghe-backup-es-audit-log b/test/test-ghe-backup-es-audit-log deleted file mode 100644 index 8b1378917..000000000 --- a/test/test-ghe-backup-es-audit-log +++ /dev/null @@ -1 +0,0 @@ - diff --git a/test/test-ghe-backup-es-hookshot b/test/test-ghe-backup-es-hookshot deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/test-ghe-restore-es-audit-log b/test/test-ghe-restore-es-audit-log deleted file mode 100644 index 6f7250705..000000000 --- a/test/test-ghe-restore-es-audit-log +++ /dev/null @@ -1,9 +0,0 @@ -# Create fake audit logs -mkdir "$loc/audit-log" -cd "$loc/audit-log" -ano_month="2017-01" -last_month=$(date -v-1m +"%Y-%m") -this_month=$(date +"%Y-%m") -for log in $this_month $last_month $ano_month; do - echo "fake-audit-log-$log" | gzip > audit_log-1-$log-1.gz -done diff --git a/test/test-ghe-restore-es-hookshot b/test/test-ghe-restore-es-hookshot deleted file mode 100644 index e58ae181e..000000000 --- a/test/test-ghe-restore-es-hookshot +++ /dev/null @@ -1,9 +0,0 @@ -# Create fake hookshot logs -mkdir -p "$loc/hookshot" -cd "$loc/hookshot" -ano_day="2017-01-20" -yest_day=$(date -v-1d +"%Y-%m-%d") -today=$(date +"%Y-%m-%d") -for log in $ano_day $yest_day $today; do - echo "fake-hookshot-log-$log" | gzip > hookshot-logs-$log.gz -done From 21a84534d61ed88e6b77c16a103a67fdb2383a53 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 13:34:30 +0000 Subject: [PATCH 0443/2421] Use platform-neutral method of determining last month This removes two unnecessary SSH calls and plays nicely with testing on macOS whose date doesn't support the `-d` arg --- .../ghe-restore-es-audit-log | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 18d54b32c..77493389f 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ $# -lt 1 ] && print_usage @@ -21,8 +22,18 @@ ghe_remote_version_required "$GHE_HOSTNAME" indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz) -last_month="audit_log(-[0-9]+)?-$(ghe-ssh "$GHE_HOSTNAME" 'date -d "1 month ago" +"%Y-%m"')(-[0-9]+)?" -current_month="audit_log(-[0-9]+)?-$(ghe-ssh "$GHE_HOSTNAME" 'date +"%Y-%m"')(-[0-9]+)?" +# Platform neutral and robust method of determining last month +this_yr=$(date +"%Y") +this_mth=$(date +"%-m") +last_mth=$(( $this_mth - 1 )) +last_yr=$this_yr +if [ "$last_mth" = 0 ]; then + last_mth=12 + last_yr=$(( $this_yr - 1 )) +fi + +last_month=$(printf "audit_log(-[0-9]+)?-%4d-%02d(-[0-9]+)?" $last_yr $last_mth) +current_month=$(printf "audit_log(-[0-9]+)?-%4d-%02d(-[0-9]+)?" $this_yr $this_mth) # Only restore indices that don't exist and the last two months' indices. for index in $indices; do From 009ab15c4acb6a9beae4ab818e7d804280edb38c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Feb 2018 14:05:16 +0000 Subject: [PATCH 0444/2421] Remove cluster/non-cluster logic We're all the same now for the most parts. --- bin/ghe-restore | 53 +++++++++++++------------------------------------ 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 2957f8ba9..ad9d00b3c 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -280,58 +280,33 @@ bm_start "ghe-import-redis" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3 bm_end "ghe-import-redis" -if $cluster; then - echo "Restoring Git repositories into cluster ..." - ghe-restore-repositories-dgit-ng "$GHE_HOSTNAME" 1>&3 +echo "Restoring Git repositories ..." +ghe-restore-repositories-dgit-ng "$GHE_HOSTNAME" 1>&3 - echo "Restoring Gists into cluster ..." - ghe-restore-repositories-gist-ng "$GHE_HOSTNAME" 1>&3 -else - echo "Restoring Git repositories ..." - ghe-restore-repositories-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 -fi +echo "Restoring Gists ..." +ghe-restore-repositories-gist-ng "$GHE_HOSTNAME" 1>&3 -if $cluster; then - echo "Restoring GitHub Pages into DPages..." - if ghe-ssh "$GHE_HOSTNAME" test -f /data/github/current/script/dpages-cluster-restore-routes; then - ghe_verbose "* Using ghe-restore-pages-dpages-ng to restore" - ghe-restore-pages-dpages-ng "$GHE_HOSTNAME" 1>&3 - else - ghe-restore-pages-dpages "$GHE_HOSTNAME" 1>&3 - fi -else - echo "Restoring GitHub Pages ..." - ghe-restore-pages-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 -fi +echo "Restoring GitHub Pages ..." +ghe-restore-pages-dpages-ng "$GHE_HOSTNAME" 1>&3 echo "Restoring SSH authorized keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json" 1>&3 -if $cluster; then - echo "Restoring storage data ..." - ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 - - echo "Restoring custom Git hooks ..." - ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 -else - echo "Restoring storage data ..." - ghe-restore-userdata storage "$GHE_HOSTNAME" 1>&3 +echo "Restoring storage data ..." +ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 - echo "Restoring custom Git hooks ..." - ghe-restore-userdata git-hooks/environments/tarballs "$GHE_HOSTNAME" 1>&3 - ghe-restore-userdata git-hooks/repos "$GHE_HOSTNAME" 1>&3 - ghe-restore-git-hooks-extract "$GHE_HOSTNAME" 1>&3 -fi +echo "Restoring custom Git hooks ..." +ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 -if $cluster; then +if ! $cluster && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then + echo "Restoring Elasticsearch indices ..." + ghe-restore-es-rsync "$GHE_HOSTNAME" 1>&3 +else echo "Restoring Elasticsearch Audit logs" ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 echo "Restoring hookshot logs ..." ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 -else - echo "Restoring Elasticsearch indices ..." - ghe-restore-es-${GHE_BACKUP_STRATEGY} "$GHE_HOSTNAME" 1>&3 fi # Restore the audit log migration sentinel file, if it exists in the snapshot From 002041264b42b73820d5f4c44d4606987902b968 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sun, 18 Feb 2018 12:38:46 +0000 Subject: [PATCH 0445/2421] Use temp SSH config file --- share/github-backup-utils/ghe-restore-git-hooks-cluster | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index df0ee75b2..e064220da 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -52,7 +52,7 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; hostname=$(echo $hostnames | awk '{ print $1; }') if [ -n "$hostname" ]; then - ghe-ssh "$hostname" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ghe-ssh -F $ssh_config_file -l $user "$hostname:122" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" ghe-rsync -avH --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ @@ -68,7 +68,7 @@ fi if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos" ]; then for hostname in $hostnames; do - ghe-ssh "$hostname" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" + ghe-ssh -F $ssh_config_file -l $user "$hostname:122" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" ghe-rsync -avH --delete \ -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ From 7250657f659e3c1ccef03fdd9446df72c31f32dd Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sun, 18 Feb 2018 12:39:54 +0000 Subject: [PATCH 0446/2421] Create tmp SSH config for single node restores too We need this as the UUID in the DB isn't effective everywhere until the config has been applied. --- share/github-backup-utils/ghe-ssh-config | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 16872a259..5fac4d562 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -27,10 +27,20 @@ opts="$GHE_EXTRA_SSH_OPTS" [ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | git hash-object --stdin | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" -for host in $hosts; do +if [ "${#hosts[@]}" = 1 ]; then + #opts=$(echo "$opts" | sed -e $'s/\-o //g;s/ /\\\n /g;s/=/ /g') cat < Date: Fri, 23 Feb 2018 12:22:44 +1100 Subject: [PATCH 0447/2421] Fix custom options being overridden on execution If one sets an option that will be later overriden by `-a` (for instance `--no-p` ), the current behaviour dismiss that option. Since the options manually added to the configuration file are meant to be overrides, this change adds them a=fter the defaults instead of before. --- share/github-backup-utils/ghe-rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index f1abefb39..de4f71c7c 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -14,7 +14,7 @@ set -o pipefail # stderr (rsync versions >= 3.x). The complex redirections are necessary to # filter stderr while also keeping stdout and stderr separated. IGNOREOUT='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -(rsync $GHE_EXTRA_RSYNC_OPTS "${@}" 3>&1 1>&2 2>&3 3>&- | +(rsync "${@}" $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | (egrep -v "$IGNOREOUT" || true)) 3>&1 1>&2 2>&3 3>&- | (egrep -v "$IGNOREOUT" || true) res=$? From db5f40f64a24a0fca3a5af2b31ff17c036c2c6c4 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 28 Feb 2018 08:32:07 -0800 Subject: [PATCH 0448/2421] Bump version: 2.11.3 [ci skip] --- debian/changelog | 14 ++++++++++++++ share/github-backup-utils/version | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index dab6cec11..15d9c87af 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,17 @@ +github-backup-utils (2.11.3) UNRELEASED; urgency=medium + + * Update argument parsing and help/usage consistency #320 + * Fix failures variable #353 + * Remove other snapshot contents before removing the "incomplete" file #358 + * Backup and restore the management console password #361 + * Check for git before allowing SSH multiplex #362 + * Cleanup SSH multiplexing on exit #363 + * Filter cluster nodes by role during backup and restore #367 + * Optimise route generation and finalisation during cluster restores of pages #369 + * Allow extra rsync options to override default options #370 + + -- Colin Seymour Wed, 28 Feb 2018 16:32:07 +0000 + github-backup-utils (2.11.2) UNRELEASED; urgency=medium * Allow the restoration of configuration to Cluster #347 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 9e5bb77a3..22e3b6b01 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.11.2 +2.11.3 From 66cad33686e4ff3cc08ba29d30d77c463ce82dfd Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 31 Jan 2018 22:42:37 +0100 Subject: [PATCH 0449/2421] remove indices created with ES 1.x --- share/github-backup-utils/ghe-restore-es-rsync | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index 7e276f92b..83c2f4c41 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -55,6 +55,11 @@ elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then "$snapshot_dir/elasticsearch/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 + # restoring in 2.14 will remove incompatible indices created with 1.x. + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -eq 14 ]; then + ghe-ssh "$GHE_HOSTNAME" -- "sudo /usr/local/share/enterprise/ghe-es-remove-1x-indices" + fi + # restoring v11.10.x ES snapshot into a v11.10.x appliance else # Use GNU tar on BSDs. From 561e9984556f2e652e1702fd761073666b25c1ab Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 1 Mar 2018 15:15:02 +0100 Subject: [PATCH 0450/2421] remove ES 1.x indices in >=2.14 --- share/github-backup-utils/ghe-restore-es-rsync | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index 83c2f4c41..f1dd30bc5 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -55,8 +55,8 @@ elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then "$snapshot_dir/elasticsearch/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 - # restoring in 2.14 will remove incompatible indices created with 1.x. - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -eq 14 ]; then + # restoring in >=2.14 will remove incompatible indices created with 1.x. + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 14 ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo /usr/local/share/enterprise/ghe-es-remove-1x-indices" fi From 61bee7002a88108912b7e23758328ac44d6e9fbf Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 31 Jan 2018 22:42:37 +0100 Subject: [PATCH 0451/2421] remove indices created with ES 1.x --- share/github-backup-utils/ghe-restore-es-rsync | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index 7e276f92b..83c2f4c41 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -55,6 +55,11 @@ elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then "$snapshot_dir/elasticsearch/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 + # restoring in 2.14 will remove incompatible indices created with 1.x. + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -eq 14 ]; then + ghe-ssh "$GHE_HOSTNAME" -- "sudo /usr/local/share/enterprise/ghe-es-remove-1x-indices" + fi + # restoring v11.10.x ES snapshot into a v11.10.x appliance else # Use GNU tar on BSDs. From 247318d9c0ab6f760eab513a87d2fd37df338d7c Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 1 Mar 2018 15:15:02 +0100 Subject: [PATCH 0452/2421] remove ES 1.x indices in >=2.14 --- share/github-backup-utils/ghe-restore-es-rsync | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index 83c2f4c41..f1dd30bc5 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -55,8 +55,8 @@ elif [ "$GHE_VERSION_MAJOR" -gt 1 ]; then "$snapshot_dir/elasticsearch/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 - # restoring in 2.14 will remove incompatible indices created with 1.x. - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -eq 14 ]; then + # restoring in >=2.14 will remove incompatible indices created with 1.x. + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 14 ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo /usr/local/share/enterprise/ghe-es-remove-1x-indices" fi From 2a995f4f7bbd9895121f71b74a448c3028d3b351 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 5 Mar 2018 14:20:52 +0000 Subject: [PATCH 0453/2421] Improve appearance of output --- share/github-backup-utils/ghe-backup-config | 14 +++++++++++++ .../ghe-restore-alambic-cluster-ng | 6 +++--- .../github-backup-utils/ghe-restore-es-rsync | 2 +- .../ghe-restore-git-hooks-cluster | 4 ++-- .../ghe-restore-pages-dpages-ng | 8 +++---- .../ghe-restore-repositories-dgit-ng | 9 ++++---- .../ghe-restore-repositories-gist-ng | 21 +++++++++++-------- 7 files changed, 40 insertions(+), 24 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index ad386a038..17351bd91 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -278,3 +278,17 @@ ghe_verbose() { echo "$@" 1>&3 fi } + +# Usage: ghe_debug +# Log if debug mode is enabled (GHE_DEBUG). +ghe_debug() { + if [ -n "$GHE_DEBUG" ]; then + echo "Debug: $*" | ghe_indent 1>&3 + fi +} + +# Usage: cmd_with_output | ghe_indent +# Indent output +ghe_indent() { + sed 's/^/ /'; +} diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 9a05dcc98..2d8c9b094 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -87,11 +87,11 @@ bm_end "$(basename $0) - Building object list" bm_start "$(basename $0) - Calculating sync routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/storage-cluster-restore-routes \ | while read route; do - ghe_verbose "Got restore route $route" + ghe_debug "Got restore route $route" servers=$(echo $route | cut -d ' ' -f2-) object=$(echo $route | cut -d ' ' -f1) for server in $servers; do - ghe_verbose "Adding $object to $tempdir/$server.rsync" + ghe_debug "Adding $object to $tempdir/$server.rsync" echo "$object" | awk '{ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1}' >> $tempdir/$server.rsync echo "$route" >> $to_restore done @@ -115,7 +115,7 @@ for file_list in $tempdir/*.rsync; do --files-from=$file_list \ --size-only \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/storage/" 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/storage/" | ghe_indent 1>&3 done bm_end "$(basename $0) - Restoring objects" diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index dd2a377e2..43fb5c769 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -41,7 +41,7 @@ else --rsync-path="sudo -u elasticsearch rsync" \ --copy-dest="$GHE_REMOTE_DATA_USER_DIR/elasticsearch" \ "$snapshot_dir/elasticsearch/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" | ghe_indent 1>&3 fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index e064220da..4309fcf84 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -57,7 +57,7 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" 1>&3 + "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" | ghe_indent 1>&3 for tarball in $tarballs; do env_id=$(echo $tarball | cut -d '/' -f 2) @@ -73,7 +73,7 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos" ]; then -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" 1>&3 & + "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" | ghe_indent 1>&3 & done for pid in $(jobs -p); do diff --git a/share/github-backup-utils/ghe-restore-pages-dpages-ng b/share/github-backup-utils/ghe-restore-pages-dpages-ng index bc2effd7c..2e5842d85 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages-ng +++ b/share/github-backup-utils/ghe-restore-pages-dpages-ng @@ -75,7 +75,7 @@ trap 'cleanup' EXIT bm_start "$(basename $0) - Building pages list" OLDIFS=$IFS; IFS=$'\n' for path in $pages_paths; do - ghe_verbose "Adding path $path to the list of pages to send" + ghe_verbose "* Adding path $path to the list of pages to send" echo $path done > $tmp_list IFS=$OLDIFS @@ -95,11 +95,11 @@ bm_end "$(basename $0) - Building pages list" bm_start "$(basename $0) - Calculating sync routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/dpages-cluster-restore-routes \ | while read route; do - ghe_verbose "Got restore route $route" + ghe_debug "Got restore route $route" servers=$(echo $route | cut -d ' ' -f2-) page=$(echo $route | cut -d ' ' -f1) for server in $servers; do - ghe_verbose "Adding $page to $tempdir/$server.rsync" + ghe_debug "Adding $page to $tempdir/$server.rsync" echo "$page" >> $tempdir/$server.rsync echo "$route" >> $to_restore done @@ -120,7 +120,7 @@ for file_list in $tempdir/*.rsync; do --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/pages/" 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/pages/" | ghe_indent 1>&3 done bm_end "$(basename $0) - Restoring pages" diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 122038097..2a3c008e1 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -61,7 +61,6 @@ tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") - ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" cleanup() { @@ -95,7 +94,7 @@ for path in $network_paths; do # Get the network ID # The network id from a repository is the last component of the path # i.e. /data/repositories/a/nw/a5/bf/c9/37 network ID would be 37 - ghe_verbose "Adding network_path $path to the list of networks to send" + ghe_verbose "* Adding network_path $path to the list of networks to send" echo $path done > $tmp_list IFS=$OLDIFS @@ -113,11 +112,11 @@ bm_end "$(basename $0) - Building network list" bm_start "$(basename $0) - Calculating sync routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/dgit-cluster-restore-routes \ | while read route; do - ghe_verbose "Got restore route $route" + ghe_debug "Got restore route $route" servers=$(echo $route | cut -d ' ' -f2-) network_path=$(echo $route | cut -d ' ' -f1) for server in $servers; do - ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + ghe_debug "Adding $network_path to $tempdir/$server.rsync" echo "$network_path" >> $tempdir/$server.rsync echo "$route" | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' >> $to_restore done @@ -139,7 +138,7 @@ for file_list in $tempdir/*.rsync; do --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" | ghe_indent 1>&3 done bm_end "$(basename $0) - Restoring repository networks" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 0629fbcb3..ae0005076 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -73,7 +73,7 @@ trap cleanup EXIT bm_start "$(basename $0) - Building gist list" OLDIFS=$IFS; IFS=$'\n' for path in $gist_paths; do - ghe_verbose "Adding gist $path to the list of networks to send" + ghe_verbose "* Adding gist $path to the list of networks to send" echo $path done > $tmp_list IFS=$OLDIFS @@ -81,11 +81,11 @@ bm_end "$(basename $0) - Building gist list" # The server returns a list of routes: # -# a/a8/3f/02/gist dgit-node3 dgit-node2 dgit-node4 -# a/a8/bc/8d/gist dgit-node3 dgit-node2 dgit-node4 -# a/a5/06/81/gist dgit-node3 dgit-node2 dgit-node4 -# a/a5/84/6f/gist dgit-node1 dgit-node2 dgit-node4 -# a/a5/e0/01/gist dgit-node1 dgit-node2 dgit-node3 +# a/a8/3f/02/gist/gist_id.git dgit-node3 dgit-node2 dgit-node4 +# a/a8/bc/8d/gist/gist_id.git dgit-node3 dgit-node2 dgit-node4 +# a/a5/06/81/gist/gist_id.git dgit-node3 dgit-node2 dgit-node4 +# a/a5/84/6f/gist/gist_id.git dgit-node1 dgit-node2 dgit-node4 +# a/a5/e0/01/gist/gist_id.git dgit-node1 dgit-node2 dgit-node3 # ... # # One route per line. @@ -93,11 +93,11 @@ bm_end "$(basename $0) - Building gist list" bm_start "$(basename $0) - Calculating Sync Routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/gist-cluster-restore-routes \ | while read route; do - ghe_verbose "Got restore route $route" + ghe_debug "Got restore route $route" servers=$(echo $route | cut -d ' ' -f2-) network_path=$(echo $route | cut -d ' ' -f1) for server in $servers; do - ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + ghe_debug "Adding $network_path to $tempdir/$server.rsync" echo "$network_path" >> $tempdir/$server.rsync echo "$route" | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' >> $to_restore done @@ -119,11 +119,14 @@ for file_list in $tempdir/*.rsync; do --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" | ghe_indent 1>&3 done bm_end "$(basename $0) - Restoring gists" + bm_start "$(basename $0) - Finalizing routes" +# Exit early on single nodes +ghe_debug "Number of hosts: ${#hostnames[@]}" cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Mon, 5 Mar 2018 14:21:19 +0000 Subject: [PATCH 0454/2421] Correctly process routes --- share/github-backup-utils/ghe-restore-repositories-gist-ng | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index ae0005076..0c2256338 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -99,8 +99,11 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/gist-cluster-restore for server in $servers; do ghe_debug "Adding $network_path to $tempdir/$server.rsync" echo "$network_path" >> $tempdir/$server.rsync - echo "$route" | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' >> $to_restore done + # Add entries to the to_restore in the form: + # + # 5cd6fbdd8930209faf5f.git /data/repositories/b/b6/86/01/gist/5cd6fbdd8930209faf5f.git git-server-1 git-server-2 git-server-3 + echo "$route" | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' >> $to_restore done bm_end "$(basename $0) - Calculating Sync Routes" From 97aeeb91745db24b02a198c8c4e980db3433619f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 5 Mar 2018 14:44:15 +0000 Subject: [PATCH 0455/2421] Remove unused test --- test/test-ghe-backup-repositories-rsync.sh | 161 --------------------- 1 file changed, 161 deletions(-) delete mode 100755 test/test-ghe-backup-repositories-rsync.sh diff --git a/test/test-ghe-backup-repositories-rsync.sh b/test/test-ghe-backup-repositories-rsync.sh deleted file mode 100755 index acfa8067a..000000000 --- a/test/test-ghe-backup-repositories-rsync.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash -# ghe-backup-repositories-rsync command tests - -# Bring in testlib -# shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" - -# Create the backup data dir and fake remote repositories dirs -mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR/repositories" -mkdir -p "$TRASHDIR/hooks" - -# Run under the remote repositories directory -cd "$GHE_REMOTE_DATA_USER_DIR/repositories" - -# Create some test repositories in the remote repositories dir -repo1="0/nw/01/aa/3f/1234/1234.git" -repo2="0/nw/01/aa/3f/1234/1235.git" -repo3="1/nw/23/bb/4c/2345/2345.git" -mkdir -p "$repo1" "$repo2" "$repo3" - -wiki1="0/nw/01/aa/3f/1234/1234.wiki.git" -mkdir -p "$wiki1" - -gist1="0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git" -gist2="1/23/bb/4c/gist/1234.git" -mkdir -p "$gist1" "$gist2" - -# Initialize test repositories with a fake commit -while IFS= read -r -d '' repo; do - git init -q --bare "$repo" - git --git-dir="$repo" --work-tree=. commit -q --allow-empty -m 'test commit' - rm -rf "$repo/hooks" - ln -s "$TRASHDIR/hooks" "$repo/hooks" -done < <(find . -type d -name '*.git' -prune -print0) - -# Generate a packed-refs file in repo1 -git --git-dir="$repo1" pack-refs - -# Generate a pack in repo2 -git --git-dir="$repo2" repack -q - -# Add some fake svn data to repo3 -echo "fake svn history data" > "$repo3/svn.history.msgpack" -mkdir "$repo3/svn_data" -echo "fake property history data" > "$repo3/svn_data/property_history.msgpack" - -begin_test "ghe-backup-repositories-rsync first snapshot" -( - set -e - - # force snapshot number instead of generating a timestamp - GHE_SNAPSHOT_TIMESTAMP=1 - export GHE_SNAPSHOT_TIMESTAMP - - # run it - ghe-backup-repositories-rsync - - # check that repositories directory was created - [ -d "$GHE_DATA_DIR/1/repositories" ] - - # check that packed-refs file was transferred - [ -f "$GHE_DATA_DIR/1/repositories/$repo1/packed-refs" ] - - # check that a pack file was transferred - for packfile in $GHE_DATA_DIR/1/repositories/$repo2/objects/pack/*.pack; do - [ -f "$packfile" ] - done - - # check that svn data was transferred - [ -f "$GHE_DATA_DIR"/1/repositories/$repo3/svn.history.msgpack ] - [ -f "$GHE_DATA_DIR"/1/repositories/$repo3/svn_data/property_history.msgpack ] - - # verify all repository data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/1/repositories" -) -end_test - - -begin_test "ghe-backup-repositories-rsync subsequent snapshot" -( - set -e - - # force snapshot number instead of generating a timestamp - GHE_SNAPSHOT_TIMESTAMP=2 - export GHE_SNAPSHOT_TIMESTAMP - - # make current symlink point to previous increment - ln -s 1 "$GHE_DATA_DIR/current" - - # run it - ghe-backup-repositories-rsync - - # check that repositories directory was created - snapshot="$GHE_DATA_DIR/2/repositories" - [ -d "$snapshot" ] - - # verify hard links used for existing files - inode1=$(ls -i "$GHE_DATA_DIR/1/repositories/$repo1/packed-refs" | awk '{ print $1; }') - inode2=$(ls -i "$GHE_DATA_DIR/2/repositories/$repo1/packed-refs" | awk '{ print $1; }') - [ "$inode1" = "$inode2" ] - - # verify all repository data exists in the increment - diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/2/repositories" -) -end_test - - -begin_test "ghe-backup-repositories-rsync __special__ dirs" -( - set -e - - # force snapshot number instead of generating a timestamp - GHE_SNAPSHOT_TIMESTAMP=3 - export GHE_SNAPSHOT_TIMESTAMP - - # create the included __purgatory__ dir on the remote side - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories/__purgatory__/123.git" - git init --bare -q "$GHE_REMOTE_DATA_USER_DIR/repositories/__purgatory__/123.git" - git --git-dir="$GHE_REMOTE_DATA_USER_DIR/repositories/__purgatory__/123.git" --work-tree=. \ - commit --allow-empty -m 'test commit' - - # run it - ghe-backup-repositories-rsync - - # check that repositories directory was created - snapshot="$GHE_DATA_DIR/3/repositories" - [ -d "$snapshot" ] - - # check that included special dir was not transferred - [ -d "$snapshot/__purgatory__" ] - - # check that all files were transferred under included dir - [ -f "$snapshot/__purgatory__/123.git/description" ] - - # fsck the repo to make sure everything was transferred - git --git-dir="$snapshot/__purgatory__/123.git" fsck -) -end_test - -begin_test "ghe-backup-repositories-rsync temp files" -( - set -e - - # force snapshot number instead of generating a timestamp - GHE_SNAPSHOT_TIMESTAMP=4 - export GHE_SNAPSHOT_TIMESTAMP - - # create a tmp pack to emulate a pack being written to - touch "$GHE_REMOTE_DATA_USER_DIR/repositories/$repo1/objects/pack/tmp_pack_1234" - - # run it - ghe-backup-repositories-rsync - - # check that repositories directory was created - snapshot="$GHE_DATA_DIR/4/repositories" - [ -d "$snapshot" ] - - # check that tmp pack was not transferred - [ ! -d "$snapshot/$repo1/objects/pack/tmp_pack_1234" ] -) -end_test From 8a6f7f83d6fb93a817d060a145c89ffea2e3fabc Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 5 Mar 2018 15:14:20 +0000 Subject: [PATCH 0456/2421] Split dgit/gist restore dummy scripts to prevent confusion --- test/bin/dgit-cluster-restore-routes | 6 ++---- test/bin/gist-cluster-restore-routes | 10 +++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) mode change 120000 => 100755 test/bin/gist-cluster-restore-routes diff --git a/test/bin/dgit-cluster-restore-routes b/test/bin/dgit-cluster-restore-routes index bc96902a4..65b4fc93f 100755 --- a/test/bin/dgit-cluster-restore-routes +++ b/test/bin/dgit-cluster-restore-routes @@ -1,11 +1,9 @@ #!/usr/bin/env bash -# Usage: dgit-cluster-restore-routes / gist-cluster-restore-routes -# Emulates the remote GitHub [dgit|gist]-cluster-restore-routes commands. Tests use this +# Usage: dgit-cluster-restore-routes +# Emulates the remote GitHub dgit-cluster-restore-routes commands. Tests use this # to assert that the command was executed. set -e cat < Date: Mon, 5 Mar 2018 16:14:24 +0000 Subject: [PATCH 0457/2421] Update tests --- test/bin/ghe-hook-env-update | 7 +++---- test/testlib.sh | 11 ++++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/bin/ghe-hook-env-update b/test/bin/ghe-hook-env-update index 77bcd3580..61cf1e265 100755 --- a/test/bin/ghe-hook-env-update +++ b/test/bin/ghe-hook-env-update @@ -6,7 +6,6 @@ env_id=$1 tarball=$2 -path=$(dirname $tarball)/../../ -mkdir -p $path/$1 -cd $path/$i -tar -zxf $tarball +path=$(dirname $tarball)/../../../ +mkdir -p $path/$env_id +tar -zxf $tarball -C "$path/$env_id" diff --git a/test/testlib.sh b/test/testlib.sh index 140da22c8..f6c9a57fb 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -205,8 +205,9 @@ setup_test_data () { touch 123/abcdef/script.sh 456/fed314/foo.sh cd "$loc/git-hooks/environments/tarballs" - mkdir -p 123/abcdef 456/fed314 - touch 123/abcdef/script.tar.gz 456/fed314/foo.tar.gz + mkdir -p 987/qwert 765/frodo + tar -C "$loc/git-hooks/environments/123/abcdef/" -zcf "$loc/git-hooks/environments/tarballs/987/qwert/script.tar.gz" ./ + tar -C "$loc/git-hooks/environments/456/fed314/" -zcf "$loc/git-hooks/environments/tarballs/765/frodo/foo.tar.gz" ./ cd "$loc/git-hooks/repos" mkdir -p 321 654 @@ -365,8 +366,8 @@ verify_all_restored_data() { set -e # verify all import scripts were run - #grep -q "4/c8/1e/72/2/legacy/index.html" "$TRASHDIR/restore-out" - #grep -q "4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" "$TRASHDIR/restore-out" + grep -q "4/c8/1e/72/2/legacy/index.html" "$TRASHDIR/restore-out" + grep -q "4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" "$TRASHDIR/restore-out" grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" @@ -380,7 +381,7 @@ verify_all_restored_data() { diff -ru "$GHE_DATA_DIR/current/repositories" "$GHE_REMOTE_DATA_USER_DIR/repositories" # verify all pages data was transferred to the restore location - #diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" + diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" # verify all ES data was transferred from live directory to the temporary restore directory diff -ru "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" From 7041f23b8eba36bf93d8cf6d683b813d952baa31 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 5 Mar 2018 16:25:18 +0000 Subject: [PATCH 0458/2421] Fix indentation --- bin/ghe-restore | 70 ++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index ad9d00b3c..32a34af48 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -109,9 +109,9 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Figure out if this instance has been configured or is entirely new. instance_configured=false if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then - instance_configured=true + instance_configured=true elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then - restore_settings=true + restore_settings=true fi # Figure out if we're restoring into cluster @@ -167,27 +167,27 @@ fi # mostly to prevent accidents where the backup host is given to restore instead # of a separate restore host since they're used in such close proximity. if $instance_configured && ! $force; then - echo - echo "WARNING: All data on GitHub Enterprise appliance $hostname ($GHE_REMOTE_VERSION)" - echo " will be overwritten with data from snapshot ${GHE_RESTORE_SNAPSHOT}." - echo "Please verify that this is the correct restore host before continuing." - printf "Type 'yes' to continue: " - - while read -r response; do - case $response in - yes|Yes|YES) - break - ;; - '') - printf "Type 'yes' to continue: " - ;; - *) - echo "Restore aborted." 1>&2 - exit 1 - ;; - esac - done - echo + echo + echo "WARNING: All data on GitHub Enterprise appliance $hostname ($GHE_REMOTE_VERSION)" + echo " will be overwritten with data from snapshot ${GHE_RESTORE_SNAPSHOT}." + echo "Please verify that this is the correct restore host before continuing." + printf "Type 'yes' to continue: " + + while read -r response; do + case $response in + yes|Yes|YES) + break + ;; + '') + printf "Type 'yes' to continue: " + ;; + *) + echo "Restore aborted." 1>&2 + exit 1 + ;; + esac + done + echo fi # Log restore start message locally and in /var/log/syslog on remote instance @@ -201,13 +201,13 @@ ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNA # "failed" - restore has failed # "complete" - restore has completed successfully update_restore_status () { - if $cluster; then - echo "ghe-cluster-each -- \"echo '$1' | sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | - ghe-ssh "$GHE_HOSTNAME" /bin/bash - else - echo "$1" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" - fi + if $cluster; then + echo "ghe-cluster-each -- \"echo '$1' | sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | + ghe-ssh "$GHE_HOSTNAME" /bin/bash + else + echo "$1" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" + fi } # Update remote restore state file and setup failure trap @@ -216,10 +216,10 @@ update_restore_status "restoring" # Make sure the GitHub appliance is in maintenance mode. if $instance_configured; then - if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then - echo "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 - exit 1 - fi + if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then + echo "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 + exit 1 + fi fi # Create benchmark file @@ -252,7 +252,7 @@ fi # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. if $restore_settings; then - ghe-restore-settings "$GHE_HOSTNAME" + ghe-restore-settings "$GHE_HOSTNAME" fi # Make sure mysql and elasticsearch are prep'd and running before restoring into From 385223e7065d7b3024e2a731f961d7075a03a924 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 5 Mar 2018 16:25:45 +0000 Subject: [PATCH 0459/2421] Use same method for single and cluster --- bin/ghe-restore | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 32a34af48..7205e4efc 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -230,24 +230,13 @@ echo "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. echo "Stopping cron and github-timerd ..." -if $cluster; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then - ghe_verbose "* Warning: Failed to stop cron on one or more nodes" - fi - - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" - fi -else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then - ghe_verbose "* Warning: Failed to stop cron" - fi - - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd" - fi +if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron on one or more nodes" fi +if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" +fi # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. From c1d4c881b28f66cfc44eedd85ca9d14776c9b0a0 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 5 Mar 2018 16:54:35 +0000 Subject: [PATCH 0460/2421] Format to_restore correctly --- share/github-backup-utils/ghe-restore-repositories-gist-ng | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 0c2256338..22671e254 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -102,8 +102,9 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/gist-cluster-restore done # Add entries to the to_restore in the form: # - # 5cd6fbdd8930209faf5f.git /data/repositories/b/b6/86/01/gist/5cd6fbdd8930209faf5f.git git-server-1 git-server-2 git-server-3 - echo "$route" | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' >> $to_restore + # gist_id /data/repositories/a/a8/3f/02/gist/gist_id.git dgit-node3 dgit-node2 dgit-node4 + echo "$route" | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore + done bm_end "$(basename $0) - Calculating Sync Routes" From 71959467cb2ac6b88303985f82bbbff8125b8134 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 5 Mar 2018 17:19:40 +0000 Subject: [PATCH 0461/2421] Fix typo so we append to routes file --- .../github-backup-utils/ghe-restore-repositories-gist-ng | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 22671e254..b245e5c45 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -103,8 +103,7 @@ cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/gist-cluster-restore # Add entries to the to_restore in the form: # # gist_id /data/repositories/a/a8/3f/02/gist/gist_id.git dgit-node3 dgit-node2 dgit-node4 - echo "$route" | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore - + echo "$route" | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' >> $to_restore done bm_end "$(basename $0) - Calculating Sync Routes" @@ -129,8 +128,10 @@ bm_end "$(basename $0) - Restoring gists" bm_start "$(basename $0) - Finalizing routes" -# Exit early on single nodes -ghe_debug "Number of hosts: ${#hostnames[@]}" +#[ "${#hostnames[@]}" = "1" ] && exit + +ghe_verbose "Finalizing routes" +ghe_verbose "$(cat $to_restore)" cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Mon, 5 Mar 2018 17:56:49 +0000 Subject: [PATCH 0462/2421] Revert "Use same method for single and cluster" This reverts commit 385223e7065d7b3024e2a731f961d7075a03a924. --- bin/ghe-restore | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7205e4efc..32a34af48 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -230,14 +230,25 @@ echo "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. echo "Stopping cron and github-timerd ..." -if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then - ghe_verbose "* Warning: Failed to stop cron on one or more nodes" -fi +if $cluster; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron on one or more nodes" + fi -if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + fi +else + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron" + fi + + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd" + fi fi + # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. if $restore_settings; then From 58f85a1d23c74afb5e5eefce7114e5f723ba7123 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 5 Mar 2018 18:31:38 +0000 Subject: [PATCH 0463/2421] Route finalize not needed on single nodes --- .../ghe-restore-alambic-cluster-ng | 16 +++++++------ .../ghe-restore-pages-dpages-ng | 16 +++++++------ .../ghe-restore-repositories-dgit-ng | 16 +++++++------ .../ghe-restore-repositories-gist-ng | 23 +++++++++---------- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 2d8c9b094..1b3caa714 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -119,13 +119,15 @@ for file_list in $tempdir/*.rsync; do done bm_end "$(basename $0) - Restoring objects" -bm_start "$(basename $0) - Finalizing routes" -cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore -ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <&3 <&3 <&3 <&3 <&3 <&3 <&3 < Date: Tue, 6 Mar 2018 14:27:17 +0000 Subject: [PATCH 0464/2421] Remove unused commands --- .../ghe-restore-git-hooks-extract | 35 ------ .../ghe-restore-pages-dpages | 118 ------------------ .../ghe-restore-pages-rsync | 20 --- .../ghe-restore-repositories-rsync | 46 ------- 4 files changed, 219 deletions(-) delete mode 100755 share/github-backup-utils/ghe-restore-git-hooks-extract delete mode 100755 share/github-backup-utils/ghe-restore-pages-dpages delete mode 100755 share/github-backup-utils/ghe-restore-pages-rsync delete mode 100755 share/github-backup-utils/ghe-restore-repositories-rsync diff --git a/share/github-backup-utils/ghe-restore-git-hooks-extract b/share/github-backup-utils/ghe-restore-git-hooks-extract deleted file mode 100755 index 9b19f23a6..000000000 --- a/share/github-backup-utils/ghe-restore-git-hooks-extract +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-git-hooks-extract -#/ Restore custom Git hooks environments from tarballs -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-restore -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -# Grab host arg -GHE_HOSTNAME="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -if [ ! -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs ]; then - echo "Warning: No pre-receive hook environments. Skipping ..." - exit 0 -fi - -tarballs=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs && find . -type f) - -for tarball in $tarballs; do - env_id=$(echo $tarball | cut -d '/' -f 2) - ghe-ssh "$GHE_HOSTNAME" "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" -done diff --git a/share/github-backup-utils/ghe-restore-pages-dpages b/share/github-backup-utils/ghe-restore-pages-dpages deleted file mode 100755 index fbf6142f9..000000000 --- a/share/github-backup-utils/ghe-restore-pages-dpages +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-pages-dpages -#/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when restoring into a cluster. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Find the pages to restore -pages_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 -maxdepth 5 | cut -d / -f2-) - -# No need to restore anything, early exit -if [ -z "$pages_paths" ]; then - echo "Warning: Pages backup missing. Skipping ..." - exit 0 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - -cleanup() { - for pid in $(jobs -p); do - kill -KILL $pid > /dev/null 2>&1 || true - done - rm -rf $ssh_config_file ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out -} - -trap 'cleanup' INT TERM EXIT - -rm -rf ssh_routes_in ssh_routes_out ssh_finalize_in ssh_finalize_out -mkfifo ssh_routes_in -mkfifo ssh_routes_out -mkfifo ssh_finalize_in -mkfifo ssh_finalize_out - -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dpages-cluster-import-routes - < ssh_routes_out > ssh_routes_in & -ssh_routes_pid=$! -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dpages-cluster-import-finalize - < ssh_finalize_out > ssh_finalize_in & -ssh_finalize_pid=$! - -exec 4> ssh_routes_out -exec 5> ssh_finalize_out - -for pages_path in $pages_paths; do - page_id=$(echo $pages_path | awk -F/ '{print $(NF)}') - echo "$page_id" >&4 - read routes < ssh_routes_in - - if [ "$routes" = 'page-id-not-found' ]; then - echo " Warning: page ID $page_id not found in the database, ignoring." - continue - fi - - for route in $routes; do - ghe-rsync -aHR --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/./$pages_path" \ - "$route:$GHE_REMOTE_DATA_USER_DIR/pages" & - done - - for pid in $(jobs -p); do - if [ $pid = $ssh_routes_pid -o $pid = $ssh_finalize_pid ]; then - continue - fi - wait $pid - ret_code=$? - if [ "$ret_code" != "0" ]; then - echo "$pid exited $ret_code" - exit $ret_code - fi - done - - echo "$page_id $routes" >&5 - read output < ssh_finalize_in -done - -exec 4>&- -exec 5>&- - -# Ensure to flush these and close the pipes -cat ssh_routes_in > /dev/null & -cat ssh_finalize_in > /dev/null & - -wait $ssh_routes_pid > /dev/null 2>&1 || true -wait $ssh_finalize_pid > /dev/null 2>&1 || true - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-pages-rsync b/share/github-backup-utils/ghe-restore-pages-rsync deleted file mode 100755 index 2c1c3e171..000000000 --- a/share/github-backup-utils/ghe-restore-pages-rsync +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-pages-rsync -#/ Restore an rsync snapshot of all Pages data to a GitHub instance. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when the rsync strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Restore all pages data via rsync -ghe-restore-userdata pages "$1" - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-repositories-rsync b/share/github-backup-utils/ghe-restore-repositories-rsync deleted file mode 100755 index 9dccda6c8..000000000 --- a/share/github-backup-utils/ghe-restore-repositories-rsync +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-repositories-rsync -#/ Restore an rsync snapshot of all Git repository data to a GitHub instance. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when the rsync strategy is used. -set -e - -# Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -cleanup() { - # Enable remote GC operations - ghe-gc-enable $GHE_HOSTNAME -} - -trap 'cleanup' INT TERM EXIT - -# Disable remote GC operations -ghe-gc-disable $GHE_HOSTNAME - -# Transfer all git repository data from the latest snapshot to the GitHub -# instance in a single rsync invocation. -ghe-rsync -avH --delete \ - --exclude ".sync_in_progress" \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/repositories" 1>&3 - -bm_end "$(basename $0)" From 6344635b55fbcc2f68ed327cf1f26ef295d8bae7 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 6 Mar 2018 14:33:19 +0000 Subject: [PATCH 0465/2421] Use consistent formatting for short lines --- bin/ghe-backup | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index e8ca183fb..985373186 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -132,8 +132,7 @@ ghe-backup-store-version || echo "Warning: storing backup-utils version remotely failed." echo "Backing up GitHub settings ..." -ghe-backup-settings || -failures="$failures settings" +ghe-backup-settings || failures="$failures settings" echo "Backing up SSH authorized keys ..." bm_start "ghe-export-authorized-keys" @@ -150,20 +149,17 @@ bm_end "ghe-export-ssh-host-keys" echo "Backing up MySQL database ..." bm_start "ghe-export-mysql" echo 'set -o pipefail; ghe-export-mysql | gzip' | -ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || -failures="$failures mysql" +ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql" bm_end "ghe-export-mysql" echo "Backing up Redis database ..." ghe-backup-redis-cluster > redis.rdb || failures="$failures redis" echo "Backing up audit log ..." -ghe-backup-es-audit-log || -failures="$failures audit-log" +ghe-backup-es-audit-log || failures="$failures audit-log" echo "Backing up hookshot logs ..." -ghe-backup-es-hookshot || -failures="$failures hookshot" +ghe-backup-es-hookshot || failures="$failures hookshot" echo "Backing up Git repositories ..." ghe-backup-repositories-cluster-ng || failures="$failures repositories" @@ -179,14 +175,12 @@ ghe-backup-git-hooks-cluster || failures="$failures git-hooks" if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then echo "Backing up Elasticsearch indices ..." - ghe-backup-es-rsync || - failures="$failures elasticsearch" + ghe-backup-es-rsync || failures="$failures elasticsearch" fi # git fsck repositories after the backup if [ "$GHE_BACKUP_FSCK" = "yes" ]; then - ghe-backup-fsck $GHE_SNAPSHOT_DIR || - failures="$failures fsck" + ghe-backup-fsck $GHE_SNAPSHOT_DIR || failures="$failures fsck" fi # If everything was successful, mark the snapshot as complete, update the From b270261507810abe98877db870d83dd0cee44e57 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 6 Mar 2018 14:33:54 +0000 Subject: [PATCH 0466/2421] Typo and update version --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 53a13f0c4..d99a929bc 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -94,7 +94,7 @@ fi if ! echo "v$version" | grep -Eq "v2\.1[1-9]|v[3-9]"; then echo "Error: old release of GitHub Enterprise detected." 1>&2 echo "Backup Utilities $BACKUP_UTILS_VERSION requires GitHub Enterprise v2.11 or newer." 1>&2 - echo "Please update your GitHub Enterprise appliance of use backup-utils v2.11.4." 1>&2 + echo "Please update your GitHub Enterprise appliance or use backup-utils v2.11.3." 1>&2 exit 1 fi From e4efead7af60d30d4a8069cd26d7ae921926f6bd Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 6 Mar 2018 14:42:42 +0000 Subject: [PATCH 0467/2421] This will always be the case from now on --- bin/ghe-restore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 32a34af48..7f9c03921 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -110,7 +110,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" instance_configured=false if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then instance_configured=true -elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then +else restore_settings=true fi @@ -255,9 +255,9 @@ if $restore_settings; then ghe-restore-settings "$GHE_HOSTNAME" fi -# Make sure mysql and elasticsearch are prep'd and running before restoring into -# appliances v2.x or greater. These services will not have been started on appliances -# that have not been configured yet. +# Make sure mysql and elasticsearch are prep'd and running before restoring. +# These services will not have been started on appliances that have not been +# configured yet. if ! $cluster; then echo "sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 From 1b609c7c6cfe781c38f02a405b1ea5765bbec78a Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 6 Mar 2018 14:44:16 +0000 Subject: [PATCH 0468/2421] Remove unneeded cluster snapshot version check Cluster snapshots will always be from post 2.5.0 now. --- bin/ghe-restore | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7f9c03921..7c0accf0f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -128,17 +128,6 @@ if ! $cluster && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then exit 1 fi -# Figure out if we're restoring into a cluster with an unsupported snapshot -if $cluster; then - snapshot_instance_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) - if ! echo $snapshot_instance_version | \ - grep -Eq "v2\.[5-9]|v2\.[1-9][0-9]|v[3-9]|v[1-9][0-9]"; then - echo "Error: Snapshot must be from GitHub Enterprise v2.5.0 or above to be restored" >&2 - echo " into a cluster (detected $snapshot_instance_version). Aborting." >&2 - exit 1 - fi -fi - # Figure out if this appliance is in a replication pair if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then From 65ee181b0abb624648bd66fb22fa01d22a5e1b54 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 7 Mar 2018 17:00:25 +0000 Subject: [PATCH 0469/2421] Remove shellcheck suggested changes for now I'll redo these in another PR to keep this already large PR free of unnecessary changes. --- .../ghe-restore-pages-dpages-ng | 3 +-- .../ghe-restore-repositories-dgit-ng | 3 +-- test/test-ghe-backup-config.sh | 19 +++++++++---------- test/test-ghe-backup.sh | 10 ++++------ test/test-ghe-cluster-nodes.sh | 3 +-- test/test-ghe-host-check.sh | 3 +-- test/test-ghe-prune-snapshots.sh | 15 +++++++-------- test/test-ghe-restore.sh | 9 ++++----- test/test-ghe-ssh.sh | 5 ++--- test/testlib.sh | 6 ++---- 10 files changed, 32 insertions(+), 44 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-pages-dpages-ng b/share/github-backup-utils/ghe-restore-pages-dpages-ng index 0f6a18de6..7743d8285 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages-ng +++ b/share/github-backup-utils/ghe-restore-pages-dpages-ng @@ -7,8 +7,7 @@ set -e # Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 8b71c9a72..51f7a2b47 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -19,8 +19,7 @@ sync_repo_info() { } # Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 0e2ab258a..65cfa1974 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -2,8 +2,7 @@ # ghe-backup-config lib tests # Bring in testlib -# shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. $(dirname "$0")/testlib.sh # Setup backup snapshot data dir and remote repositories dir locations to use @@ -80,20 +79,20 @@ end_test begin_test "ghe-backup-config ssh_host_part" ( set -e - [ "$(ssh_host_part "github.example.com")" = "github.example.com" ] - [ "$(ssh_host_part "github.example.com:22")" = "github.example.com" ] - [ "$(ssh_host_part "github.example.com:5000")" = "github.example.com" ] - [ "$(ssh_host_part "git@github.example.com:5000")" = "git@github.example.com" ] + [ $(ssh_host_part "github.example.com") = "github.example.com" ] + [ $(ssh_host_part "github.example.com:22") = "github.example.com" ] + [ $(ssh_host_part "github.example.com:5000") = "github.example.com" ] + [ $(ssh_host_part "git@github.example.com:5000") = "git@github.example.com" ] ) end_test begin_test "ghe-backup-config ssh_port_part" ( set -e - [ "$(ssh_port_part "github.example.com")" = "22" ] - [ "$(ssh_port_part "github.example.com:22")" = "22" ] - [ "$(ssh_port_part "github.example.com:5000")" = "5000" ] - [ "$(ssh_port_part "git@github.example.com:5000")" = "5000" ] + [ $(ssh_port_part "github.example.com") = "22" ] + [ $(ssh_port_part "github.example.com:22") = "22" ] + [ $(ssh_port_part "github.example.com:5000") = "5000" ] + [ $(ssh_port_part "git@github.example.com:5000") = "5000" ] ) end_test diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 37b57b515..e69d1d37c 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -2,8 +2,7 @@ # ghe-backup command tests # Bring in testlib -# shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. $(dirname "$0")/testlib.sh # Create the backup data dir and fake remote repositories dirs mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" @@ -59,7 +58,7 @@ begin_test "ghe-backup logs the benchmark" ghe-backup - [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] + [ $(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l) -gt 1 ] ) end_test @@ -71,8 +70,7 @@ begin_test "ghe-backup with relative data dir path" sleep 1 # generate a timestamp - GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" - export GHE_SNAPSHOT_TIMESTAMP + export GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" # change working directory to the root directory cd $ROOTDIR @@ -189,7 +187,7 @@ begin_test "ghe-backup with leaked SSH host key detection for current backup" ( set -e - SHARED_UTILS_PATH=$(dirname "$(which ghe-detect-leaked-ssh-keys)") + SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) # Inject the fingerprint into the blacklist echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index d0bdd70fd..2812e5c16 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -2,8 +2,7 @@ # ghe-cluster-nodes command tests # Bring in testlib -# shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. $(dirname "$0")/testlib.sh # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index a54d099f7..386a5ef51 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -2,8 +2,7 @@ # ghe-host-check command tests # Bring in testlib -# shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. $(dirname "$0")/testlib.sh begin_test "ghe-host-check" ( diff --git a/test/test-ghe-prune-snapshots.sh b/test/test-ghe-prune-snapshots.sh index 50e07e350..0194504c9 100755 --- a/test/test-ghe-prune-snapshots.sh +++ b/test/test-ghe-prune-snapshots.sh @@ -2,12 +2,11 @@ # ghe-prune-snapshots command tests # Bring in testlib -# shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. $(dirname "$0")/testlib.sh # helper for generating dirs to clean up generate_prune_files() { - rm -rf "${GHE_DATA_DIR:?}"/* + rm -rf "$GHE_DATA_DIR"/* prune_file_num=${1:-10} for i in $(seq -f '%02g' 1 $prune_file_num); do mkdir -p "$GHE_DATA_DIR/$i" @@ -26,8 +25,8 @@ begin_test "ghe-prune-snapshots using default GHE_NUM_SNAPSHOTS" set -e generate_prune_files 12 ghe-prune-snapshots - [ "$(ls -1d "$GHE_DATA_DIR"/[0-9]* | wc -l)" -eq 10 ] - [ ! -d "$GHE_DATA_DIR/01" ] && [ ! -d "$GHE_DATA_DIR/02" ] + [ $(ls -1d "$GHE_DATA_DIR"/[0-9]* | wc -l) -eq 10 ] + [ ! -d "$GHE_DATA_DIR/01" -a ! -d "$GHE_DATA_DIR/02" ] ) end_test @@ -68,7 +67,7 @@ begin_test "ghe-prune-snapshots with expired snapshots" post_num_files=$(file_count_no_current) # make sure we have right number of files and right file is deleted - [ $post_num_files -eq 2 ] && [ ! -f "$GHE_DATA_DIR/01" ] && [ ! -f "$GHE_DATA_DIR/02" ] + [ $post_num_files -eq 2 -a ! -f "$GHE_DATA_DIR/01" -a ! -f "$GHE_DATA_DIR/02" ] ) end_test @@ -79,13 +78,13 @@ begin_test "ghe-prune-snapshots incomplete snapshot pruning" generate_prune_files 5 - [ "$(file_count_no_current)" -eq 5 ] + [ $(file_count_no_current) -eq 5 ] touch "$GHE_DATA_DIR/04/incomplete" GHE_NUM_SNAPSHOTS=5 ghe-prune-snapshots - [ "$(file_count_no_current)" -eq 4 ] + [ $(file_count_no_current) -eq 4 ] [ ! -d "$GHE_DATA_DIR/04" ] ) end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 4d3ee8798..3be5e6238 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -2,8 +2,7 @@ # ghe-restore command tests # Bring in testlib -# shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. $(dirname "$0")/testlib.sh setup_test_data "$GHE_DATA_DIR/1" @@ -48,7 +47,7 @@ begin_test "ghe-restore logs the benchmark" export BM_TIMESTAMP=foo export GHE_RESTORE_HOST=127.0.0.1 ghe-restore -v -f - [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] + [ $(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l) -gt 1 ] ) end_test @@ -243,7 +242,7 @@ EOF # Add custom key to tar file tar -cf "$GHE_DATA_DIR/current/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub - SHARED_UTILS_PATH=$(dirname "$(which ghe-detect-leaked-ssh-keys)") + SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) # Inject the fingerprint into the blacklist echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" @@ -349,7 +348,7 @@ begin_test "ghe-restore force restore of 2.9/2.10 snapshot without audit log mig ) end_test -begin_test "ghe-backup exits early on unsupported version" +begin_test "ghe-restore exits early on unsupported version" ( set -e GHE_RESTORE_HOST=127.0.0.1 diff --git a/test/test-ghe-ssh.sh b/test/test-ghe-ssh.sh index a0d73809f..2bdb274ca 100755 --- a/test/test-ghe-ssh.sh +++ b/test/test-ghe-ssh.sh @@ -2,8 +2,7 @@ # ghe-ssh command tests # Bring in testlib -# shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. $(dirname "$0")/testlib.sh # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. @@ -34,7 +33,7 @@ begin_test "ghe-ssh complex command works" " output="$(echo "$comm" | ghe-ssh "$GHE_HOSTNAME" /bin/sh)" - [ "$(echo "$output" | wc -l)" -eq 2 ] + [ $(echo "$output" | wc -l) -eq 2 ] ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index f6c9a57fb..544e70828 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -47,8 +47,7 @@ export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the # remote version established above or in the environment. -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" +. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config ghe_parse_remote_version "$GHE_TEST_REMOTE_VERSION" ghe_remote_version_config "$GHE_TEST_REMOTE_VERSION" @@ -65,7 +64,7 @@ atexit () { res=$? # cleanup injected test key - shared_path=$(dirname "$(which ghe-detect-leaked-ssh-keys)") + shared_path=$(dirname $(which ghe-detect-leaked-ssh-keys)) sed -i.bak '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" rm -f "$shared_path/ghe-ssh-leaked-host-keys-list.txt.bak" @@ -86,7 +85,6 @@ cd "$TRASHDIR" # Put remote metadata file in place for ghe-host-check which runs with pretty # much everything. You can pass a version number in the first argument to test # with different remote versions. -# shellcheck disable=SC2120 setup_remote_metadata () { mkdir -p "$GHE_REMOTE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" From ec4668a4dbfecce284ae839a6193599efb965aec Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 28 Feb 2018 15:55:18 +1100 Subject: [PATCH 0470/2421] Use primary index size to determine if an index has changed --- .../ghe-backup-es-audit-log | 27 +++++++------ .../ghe-backup-es-hookshot | 40 ++++++++++++------- 2 files changed, 41 insertions(+), 26 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 1c56ec343..71d388818 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -26,11 +26,14 @@ else es_port=9200 fi -if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:$es_port/_cat/indices/audit_log*?h=index"\"); then +if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:$es_port/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b\""); then echo "Error: failed to retrieve audit log indices." 1>&2 exit 1 fi +# Exit if no indices were found +[ -z "$indices" ] && exit + # Determine if the audit log migration has occurred or is needed. if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test -f /usr/local/share/enterprise/run-audit-log-transitions.sh' | ghe-ssh "$host" /bin/bash; then if echo 'set -o pipefail; echo n | /usr/local/share/enterprise/run-audit-log-transitions.sh > /dev/null 2>&1 && touch /data/user/common/es-scan-complete' | ghe-ssh "$host" /bin/bash; then @@ -38,19 +41,19 @@ if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test - fi fi -current_index="audit_log(-[0-9]+)?-$(ghe-ssh "$host" 'date +"%Y-%m"')(-[0-9]+)?" +while read index; do + set $index + index_name=$1 + index_size=$2 -for index in $indices; do - if [[ -f $GHE_DATA_DIR/current/audit-log/$index.gz && -f $GHE_DATA_DIR/current/audit-log/$index.gz.complete && ! $index =~ $current_index ]]; then - # Hard link any older indices that are complete, since these won't change - ln $GHE_DATA_DIR/current/audit-log/$index.gz $GHE_SNAPSHOT_DIR/audit-log/$index.gz - ln $GHE_DATA_DIR/current/audit-log/$index.gz.complete $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete + if [[ -f $GHE_DATA_DIR/current/audit-log/$index_name.gz && $(cat $GHE_DATA_DIR/current/audit-log/$index_name.gz.size 2>/dev/null || true) -eq $index_size ]]; then + # Hard link any indices that have not changed since the last backup + ln $GHE_DATA_DIR/current/audit-log/$index_name.gz $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz + ln $GHE_DATA_DIR/current/audit-log/$index_name.gz.size $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index.gz - if [[ ! $index =~ $current_index ]]; then - touch $GHE_SNAPSHOT_DIR/audit-log/$index.gz.complete - fi + ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz + echo $index_size > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size fi -done +done <<< "$indices" bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index 86d5a3e0d..bd91a890e 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -20,21 +20,33 @@ ghe_remote_version_required "$host" # Make sure root backup dir exists if this is the first run mkdir -p "$GHE_SNAPSHOT_DIR/hookshot" -indices=$(ghe-ssh "$host" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3) - -current_index=hookshot-logs-$(ghe-ssh "$host" 'date +"%Y-%m-%d"') - -for index in $indices; do - if [ -f $GHE_DATA_DIR/current/hookshot/$index.gz -a -f $GHE_DATA_DIR/current/hookshot/$index.gz.complete -a $index \< $current_index ]; then - # Hard link any older indices that are complete, since these won't change - ln $GHE_DATA_DIR/current/hookshot/$index.gz $GHE_SNAPSHOT_DIR/hookshot/$index.gz - ln $GHE_DATA_DIR/current/hookshot/$index.gz.complete $GHE_SNAPSHOT_DIR/hookshot/$index.gz.complete +if [ $GHE_VERSION_MAJOR -ge 2 ] && [ $GHE_VERSION_MINOR -ge 2 ]; then + es_port=9201 +else + es_port=9200 +fi + +if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:$es_port/_cat/indices/hookshot-logs-*?h=index,pri.store.size&bytes=b\""); then + echo "Error: failed to retrieve hookshot log indices." 1>&2 + exit 1 +fi + +# Hookshot indices may not exist if no recent webhook deliveries have occured. +[ -z "$indices" ] && exit + +while read index; do + set $index + index_name=$1 + index_size=$2 + + if [[ -f $GHE_DATA_DIR/current/hookshot/$index_name.gz && $(cat $GHE_DATA_DIR/current/hookshot/$index_name.gz.size 2>/dev/null || true) -eq $index_size ]]; then + # Hard link any indices that have not changed since the last backup + ln $GHE_DATA_DIR/current/hookshot/$index_name.gz $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz + ln $GHE_DATA_DIR/current/hookshot/$index_name.gz.size $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index.gz - if [ $index \< $current_index ]; then - touch $GHE_SNAPSHOT_DIR/hookshot/$index.gz.complete - fi + ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz + echo $index_size > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size fi -done +done <<< "$indices" bm_end "$(basename $0)" From 1bad3aadd8c7824971f05a52083898c4f56d0187 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Thu, 8 Mar 2018 16:53:54 +1100 Subject: [PATCH 0471/2421] Update path in curl test stub --- test/bin/curl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bin/curl b/test/bin/curl index 273512f80..fb1a80700 100755 --- a/test/bin/curl +++ b/test/bin/curl @@ -3,8 +3,8 @@ # Fake curl command stub for tests. set -e -# Return empty list of indexes for ghe-backup-es-audit-log -if echo "$@" | grep -q '_cat/indices/audit_log\*?h=index$'; then +# Return empty list of indexes for ghe-backup-es-audit-log and ghe-backup-es-hookshot +if echo "$@" | grep -q '_cat/indices/'; then exit 0 fi From 6edc3d26c1c96dadf3b801c67d715c76f2913ec5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 8 Mar 2018 17:33:25 +0000 Subject: [PATCH 0472/2421] Always restore audit and hookshot logs --- bin/ghe-restore | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7c0accf0f..2897b2b60 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -290,12 +290,6 @@ ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 if ! $cluster && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then echo "Restoring Elasticsearch indices ..." ghe-restore-es-rsync "$GHE_HOSTNAME" 1>&3 -else - echo "Restoring Elasticsearch Audit logs" - ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 - - echo "Restoring hookshot logs ..." - ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 fi # Restore the audit log migration sentinel file, if it exists in the snapshot @@ -303,6 +297,12 @@ if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" fi +echo "Restoring Elasticsearch Audit logs ..." +ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 + +echo "Restoring hookshot logs ..." +ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 + # Restart an already running memcached to reset the cache after restore echo "Restarting memcached ..." 1>&3 echo "sudo restart -q memcached 2>/dev/null || true" | From 261eb855ad7dba4f4824a3d233187d280f92bd1e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 8 Mar 2018 17:38:08 +0000 Subject: [PATCH 0473/2421] Implement better SSH strategy My previous method didn't play nice with single nodes when custom options were used. --- bin/ghe-restore | 25 ++++++------ .../ghe-backup-alambic-cluster-ng | 30 +++++++++----- .../ghe-backup-git-hooks-cluster | 28 +++++++------ .../ghe-backup-pages-cluster | 24 +++++++----- .../ghe-backup-repositories-cluster-ng | 39 ++++++++++++------- .../ghe-restore-alambic-cluster-ng | 23 +++++++---- .../ghe-restore-git-hooks-cluster | 30 ++++++++------ .../ghe-restore-pages-dpages-ng | 23 +++++++---- .../ghe-restore-repositories-dgit-ng | 28 ++++++++----- .../ghe-restore-repositories-gist-ng | 23 +++++++---- share/github-backup-utils/ghe-ssh-config | 16 ++------ test/bin/ssh | 3 ++ 12 files changed, 180 insertions(+), 112 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 2897b2b60..0c9e1824f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -115,14 +115,15 @@ else fi # Figure out if we're restoring into cluster -cluster=false +CLUSTER=false if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then - cluster=true + CLUSTER=true fi +export CLUSTER # Restoring a cluster backup to a standalone appliance is not supported -if ! $cluster && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then +if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \ "to a standalone appliance. Aborting." >&2 exit 1 @@ -190,7 +191,7 @@ ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNA # "failed" - restore has failed # "complete" - restore has completed successfully update_restore_status () { - if $cluster; then + if $CLUSTER; then echo "ghe-cluster-each -- \"echo '$1' | sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | ghe-ssh "$GHE_HOSTNAME" /bin/bash else @@ -219,7 +220,7 @@ echo "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. echo "Stopping cron and github-timerd ..." -if $cluster; then +if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then ghe_verbose "* Warning: Failed to stop cron on one or more nodes" fi @@ -247,13 +248,13 @@ fi # Make sure mysql and elasticsearch are prep'd and running before restoring. # These services will not have been started on appliances that have not been # configured yet. -if ! $cluster; then +if ! $CLUSTER; then echo "sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi # Restore UUID if present and not restoring to cluster. -if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $cluster; then +if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then echo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" @@ -287,7 +288,7 @@ ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 echo "Restoring custom Git hooks ..." ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 -if ! $cluster && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then +if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then echo "Restoring Elasticsearch indices ..." ghe-restore-es-rsync "$GHE_HOSTNAME" 1>&3 fi @@ -310,7 +311,7 @@ echo "sudo restart -q memcached 2>/dev/null || true" | # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. -if $cluster; then +if $CLUSTER; then echo "Configuring cluster ..." ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then @@ -320,7 +321,7 @@ fi # Start cron. Timerd will start automatically as part of the config run. echo "Starting cron ..." -if $cluster; then +if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then echo "* Warning: Failed to start cron on one or more nodes" fi @@ -340,7 +341,7 @@ update_restore_status "complete" # Log restore complete message in /var/log/syslog on remote instance ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." -if ! $cluster; then +if ! $CLUSTER; then echo "Restoring SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 else @@ -355,6 +356,6 @@ fi echo "Completed restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" -if ! $cluster; then +if ! $CLUSTER; then echo "Visit https://$hostname/setup/settings to review appliance configuration." fi diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 660252166..1a543b11c 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -33,13 +33,19 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# storage server hostnames -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") - +hostnames=$host +ssh_config_file_opt= tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -ssh_config_file=$tempdir/ssh_config -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +opts="$GHE_EXTRA_SSH_OPTS" + +# storage server hostnames under cluster +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" @@ -50,7 +56,7 @@ cleanup() { # Enable remote maintenance operations, unless testing if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then for hostname in $hostnames; do - ghe-gc-enable -F $ssh_config_file $hostname:$port + ghe-gc-enable $ssh_config_file_opt $hostname:$port done fi @@ -62,7 +68,7 @@ trap 'cleanup' EXIT INT # Disable remote maintenance operations, unless testing if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then for hostname in $hostnames; do - ghe-gc-disable -F $ssh_config_file $hostname:$port + ghe-gc-disable $ssh_config_file_opt $hostname:$port done fi @@ -85,7 +91,11 @@ bm_start "$(basename $0) - Calculating sync routes" ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-backup-routes \ | while read route; do ghe_verbose "Got backup route $route" - server=$(echo $route | cut -d ' ' -f2-) + if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + server=$(echo $route | cut -d ' ' -f2-) + else + server=$host + fi network_path=$(echo $route | cut -d ' ' -f1) ghe_verbose "Adding $network_path to $tempdir/$server.rsync" echo "$network_path" >> $tempdir/$server.rsync @@ -106,7 +116,7 @@ for file_list in $tempdir/*.rsync; do echo "* Transferring $object_num objects from $hostname" ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --files-from="$file_list" \ diff --git a/share/github-backup-utils/ghe-backup-git-hooks-cluster b/share/github-backup-utils/ghe-backup-git-hooks-cluster index b633ed0a3..830b61834 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks-cluster +++ b/share/github-backup-utils/ghe-backup-git-hooks-cluster @@ -34,18 +34,24 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# git server hostnames -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +hostnames=$host +ssh_config_file_opt= +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +opts="$GHE_EXTRA_SSH_OPTS" + +# git server hostnames under cluster +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - rm -f $ssh_config_file + rm -rf $tempdir } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate @@ -87,20 +93,20 @@ rsync_git_hooks_data () { mkdir -p "$backup_dir/$subpath" ghe-rsync -av \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" $link_dest \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" $link_dest \ --rsync-path='sudo -u git rsync' \ "$host:$GHE_REMOTE_DATA_USER_DIR/git-hooks/$subpath/" \ "$backup_dir/$subpath" 1>&3 } hostname=$(echo $hostnames | awk '{ print $1; }') -if ghe-ssh -F $ssh_config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs' ]"; then +if ghe-ssh $ssh_config_file_opt "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs' ]"; then rsync_git_hooks_data $hostname:122 environments/tarballs else ghe_verbose "git-hooks environment tarballs not found. Skipping ..." fi -if ghe-ssh -F $ssh_config_file "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos' ]"; then +if ghe-ssh $ssh_config_file_opt "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos' ]"; then rsync_git_hooks_data $hostname:122 repos else ghe_verbose "git-hooks repositories not found. Skipping ..." diff --git a/share/github-backup-utils/ghe-backup-pages-cluster b/share/github-backup-utils/ghe-backup-pages-cluster index dc60d9e4a..295e06df4 100755 --- a/share/github-backup-utils/ghe-backup-pages-cluster +++ b/share/github-backup-utils/ghe-backup-pages-cluster @@ -32,13 +32,19 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# Pages server hostnames -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +hostnames=$host +ssh_config_file_opt= +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +opts="$GHE_EXTRA_SSH_OPTS" + +# Pages server hostnames under cluster +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" @@ -46,7 +52,7 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - rm -f $ssh_config_file + rm -rf $tempdir } trap 'cleanup' EXIT INT @@ -68,7 +74,7 @@ for hostname in $hostnames; do # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ - -e "ssh -q $opts -p 122 -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p 122 $ssh_config_file_opt -l $user" \ --rsync-path='sudo -u git rsync' \ $link_dest \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/pages/" \ diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index a77753c5b..98e995f1a 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -44,13 +44,13 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" +# Set up remote host and root backup snapshot directory based on config +host="$GHE_HOSTNAME" backup_dir="$GHE_SNAPSHOT_DIR/repositories" # Location of last good backup for rsync --link-dest backup_current="$GHE_DATA_DIR/current/repositories" -tempdir=$(mktemp -d) - # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then echo "Error: rsync not found." 1>&2 @@ -68,13 +68,19 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -# git server hostnames -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +hostnames=$host +ssh_config_file_opt= +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +opts="$GHE_EXTRA_SSH_OPTS" + +# git server hostnames under cluster +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" @@ -89,11 +95,10 @@ cleanup() { # Enable remote GC operations, unless testing if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then for hostname in $hostnames; do - ghe-gc-enable -F $ssh_config_file $hostname:$port + ghe-gc-enable $ssh_config_file_opt $hostname:$port done fi - rm -f $ssh_config_file rm -rf $tempdir } trap 'cleanup' EXIT @@ -102,7 +107,7 @@ trap 'exit $?' INT # ^C always terminate # Disable remote GC operations, unless testing if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then for hostname in $hostnames; do - ghe-gc-disable -F $ssh_config_file $hostname:$port + ghe-gc-disable $ssh_config_file_opt $hostname:$port done fi @@ -125,7 +130,11 @@ bm_start "$(basename $0) - Calculating Sync Routes" ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-routes \ | while read route; do ghe_verbose "Got backup route $route" - server=$(echo $route | cut -d ' ' -f2-) + if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + server=$(echo $route | cut -d ' ' -f2-) + else + server=$host + fi network_path=$(echo $route | cut -d ' ' -f1) ghe_verbose "Adding $network_path to $tempdir/$server.rsync" echo "$network_path" >> $tempdir/$server.rsync @@ -151,7 +160,7 @@ rsync_repository_data () { shift shift ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ @@ -161,7 +170,7 @@ rsync_repository_data () { else shift ghe-rsync -avr \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 1b3caa714..1288852ff 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -43,16 +43,21 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" +hostnames=$host tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir -ssh_config_file=$tempdir/ssh_config -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +ssh_config_file_opt= +opts="$GHE_EXTRA_SSH_OPTS" tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") - -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +if $CLUSTER; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $tempdir/ssh_config" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi cleanup() { rm -rf $tempdir @@ -88,7 +93,11 @@ bm_start "$(basename $0) - Calculating sync routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/storage-cluster-restore-routes \ | while read route; do ghe_debug "Got restore route $route" - servers=$(echo $route | cut -d ' ' -f2-) + if $CLUSTER; then + servers=$(echo $route | cut -d ' ' -f2-) + else + servers=$host + fi object=$(echo $route | cut -d ' ' -f1) for server in $servers; do ghe_debug "Adding $object to $tempdir/$server.rsync" @@ -110,7 +119,7 @@ for file_list in $tempdir/*.rsync; do server=$(basename $file_list .rsync) ghe_verbose "* Transferring data to $server ..." ghe-rsync -arvHR --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -v $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ --size-only \ diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index 4309fcf84..45202c0e2 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -32,18 +32,24 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") - -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" - -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +hostnames=$host +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ssh_config_file_opt= +opts="$GHE_EXTRA_SSH_OPTS" + +if $CLUSTER; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi cleanup() { for pid in $(jobs -p); do kill -KILL $pid > /dev/null 2>&1 || true done - rm -f $ssh_config_file + rm -rf $tempdir } trap 'cleanup' INT TERM EXIT @@ -52,25 +58,25 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; hostname=$(echo $hostnames | awk '{ print $1; }') if [ -n "$hostname" ]; then - ghe-ssh -F $ssh_config_file -l $user "$hostname:122" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + ghe-ssh $ssh_config_file_opt -l $user "$hostname:122" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" ghe-rsync -avH --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs/" \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" | ghe_indent 1>&3 for tarball in $tarballs; do env_id=$(echo $tarball | cut -d '/' -f 2) - ghe-ssh -F $ssh_config_file -l $user "$hostname:122" -- "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" 1>&3 2>&3 + ghe-ssh $ssh_config_file_opt -l $user "$hostname:122" -- "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" 1>&3 2>&3 done fi fi if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos" ]; then for hostname in $hostnames; do - ghe-ssh -F $ssh_config_file -l $user "$hostname:122" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" + ghe-ssh $ssh_config_file_opt -l $user "$hostname:122" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" ghe-rsync -avH --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos/" \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" | ghe_indent 1>&3 & diff --git a/share/github-backup-utils/ghe-restore-pages-dpages-ng b/share/github-backup-utils/ghe-restore-pages-dpages-ng index 7743d8285..084e3a5ee 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages-ng +++ b/share/github-backup-utils/ghe-restore-pages-dpages-ng @@ -41,16 +41,21 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" +hostnames=$host tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir -ssh_config_file=$(mktemp -t cluster-backup-restore-XXXXXX) -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +opts="$GHE_EXTRA_SSH_OPTS" +ssh_config_file_opt= tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") - -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +if $CLUSTER; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi cleanup() { rm -rf $tempdir @@ -95,7 +100,11 @@ bm_start "$(basename $0) - Calculating sync routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/dpages-cluster-restore-routes \ | while read route; do ghe_debug "Got restore route $route" - servers=$(echo $route | cut -d ' ' -f2-) + if $CLUSTER; then + servers=$(echo $route | cut -d ' ' -f2-) + else + servers=$host + fi page=$(echo $route | cut -d ' ' -f1) for server in $servers; do ghe_debug "Adding $page to $tempdir/$server.rsync" @@ -115,7 +124,7 @@ for file_list in $tempdir/*.rsync; do server=$(basename $file_list .rsync) ghe_verbose "* Transferring Pages to $server" ghe-rsync -avrHR --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/./" \ diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 51f7a2b47..ae2f594f6 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -9,7 +9,7 @@ set -e sync_repo_info() { for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do if ! ghe-rsync -av --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then @@ -52,19 +52,25 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" +hostnames=$host tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir -ssh_config_file=$tempdir/ssh_config -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +ssh_config_file_opt= +opts="$GHE_EXTRA_SSH_OPTS" tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +if $CLUSTER; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi cleanup() { for hostname in $hostnames; do - ghe-gc-enable -F $ssh_config_file $hostname:$port + ghe-gc-enable $ssh_config_file_opt $hostname:$port done ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir rm -rf $tempdir @@ -73,7 +79,7 @@ trap cleanup EXIT # Disable remote GC operations for hostname in $hostnames; do - ghe-gc-disable -F $ssh_config_file $hostname:$port + ghe-gc-disable $ssh_config_file_opt $hostname:$port done # Build a list of network paths to send to the server to calculate @@ -112,7 +118,11 @@ bm_start "$(basename $0) - Calculating sync routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/dgit-cluster-restore-routes \ | while read route; do ghe_debug "Got restore route $route" - servers=$(echo $route | cut -d ' ' -f2-) + if $CLUSTER; then + servers=$(echo $route | cut -d ' ' -f2-) + else + servers=$host + fi network_path=$(echo $route | cut -d ' ' -f1) for server in $servers; do ghe_debug "Adding $network_path to $tempdir/$server.rsync" @@ -133,7 +143,7 @@ for file_list in $tempdir/*.rsync; do server=$(basename $file_list .rsync) ghe_verbose "* Transferring repository networks to $server ..." ghe-rsync -avrHR --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 32abd3923..ad1af7f6c 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -42,16 +42,21 @@ host=$(ssh_host_part "$GHE_HOSTNAME") user="${host%@*}" [ "$user" = "$host" ] && user="admin" +hostnames=$host tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir -ssh_config_file=$tempdir/ssh_config -opts="$GHE_EXTRA_SSH_OPTS -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" +ssh_config_file_opt= +opts="$GHE_EXTRA_SSH_OPTS" tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore -hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") - -ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +if $CLUSTER; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi cleanup() { ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir @@ -94,7 +99,11 @@ bm_start "$(basename $0) - Calculating Sync Routes" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/gist-cluster-restore-routes \ | while read route; do ghe_debug "Got restore route $route" - servers=$(echo $route | cut -d ' ' -f2-) + if $CLUSTER; then + servers=$(echo $route | cut -d ' ' -f2-) + else + servers=$host + fi network_path=$(echo $route | cut -d ' ' -f1) for server in $servers; do ghe_debug "Adding $network_path to $tempdir/$server.rsync" @@ -118,7 +127,7 @@ for file_list in $tempdir/*.rsync; do server=$(basename $file_list .rsync) ghe_verbose "* Transferring gists to $server" ghe-rsync -avrHR --delete \ - -e "ssh -q $opts -p $port -F $ssh_config_file -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 5fac4d562..16872a259 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -27,20 +27,10 @@ opts="$GHE_EXTRA_SSH_OPTS" [ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | git hash-object --stdin | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" -if [ "${#hosts[@]}" = 1 ]; then - #opts=$(echo "$opts" | sed -e $'s/\-o //g;s/ /\\\n /g;s/=/ /g') +for host in $hosts; do cat < Date: Thu, 8 Mar 2018 17:38:26 +0000 Subject: [PATCH 0474/2421] Remove duplication --- .../ghe-backup-repositories-cluster-ng | 8 -------- 1 file changed, 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 98e995f1a..3afa8b1b1 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -36,14 +36,6 @@ set -e bm_start "$(basename $0)" -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - # Set up remote host and root backup snapshot directory based on config host="$GHE_HOSTNAME" backup_dir="$GHE_SNAPSHOT_DIR/repositories" From 46ce031ba52cb02673e70871111287222516f0fd Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 8 Mar 2018 17:38:58 +0000 Subject: [PATCH 0475/2421] Add back verification accidentally removed --- test/test-ghe-restore.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 3be5e6238..fa99a87f2 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -139,6 +139,9 @@ begin_test "ghe-restore into unconfigured vm" ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 cat "$TRASHDIR/restore-out" + # verify no config run after restore on unconfigured instance + ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" + # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" From fa15377f47a38338d97abc4eb95b96a4b169a415 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 8 Mar 2018 17:39:30 +0000 Subject: [PATCH 0476/2421] Create fake audit and hookshot logs --- test/testlib.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/testlib.sh b/test/testlib.sh index 544e70828..86ca3109f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -237,6 +237,26 @@ setup_test_data () { touch gh-enterprise-es/node/0/stuff1 touch gh-enterprise-es/node/0/stuff2 + # Create fake audit-logs + this_yr=$(date +"%Y") + this_mth=$(date +"%-m") + last_mth=$(( $this_mth - 1 )) + last_yr=$this_yr + if [ "$last_mth" = 0 ]; then + last_mth=12 + last_yr=$(( $this_yr - 1 )) + fi + + mkdir -p "$loc/audit-log/" + cd "$loc/audit-log/" + touch audit_log-1-$last_yr-$last_mth-1.gz + touch audit_log-1-$this_yr-$this_mth-1.gz + + # Create hookshot logs + mkdir -p "$loc/hookshot/" + cd "$loc/hookshot/" + touch hookshot-logs-2018-03-05.gz + # Create some test repositories in the remote repositories dir mkdir "$loc/repositories" mkdir -p "$TRASHDIR/hooks" From 990261608f84f905927dc20ba76ab5289207f72e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 8 Mar 2018 17:45:00 +0000 Subject: [PATCH 0477/2421] Route finalisation not required on single nodes --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 +- share/github-backup-utils/ghe-restore-pages-dpages-ng | 2 +- share/github-backup-utils/ghe-restore-repositories-dgit-ng | 2 +- share/github-backup-utils/ghe-restore-repositories-gist-ng | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 1288852ff..2123e06d8 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -128,7 +128,7 @@ for file_list in $tempdir/*.rsync; do done bm_end "$(basename $0) - Restoring objects" -if [ "$(wc -w <<< $hostnames)" != "1" ]; then +if [ "$(wc -w <<< $hostnames | awk '{print $1}')" != "1" ]; then bm_start "$(basename $0) - Finalizing routes" cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <&3 <&3 < Date: Thu, 8 Mar 2018 17:48:14 +0000 Subject: [PATCH 0478/2421] Remove indenting Nice idea, but not apt for this PR. --- share/github-backup-utils/ghe-backup-config | 8 +------- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 +- share/github-backup-utils/ghe-restore-es-rsync | 2 +- share/github-backup-utils/ghe-restore-git-hooks-cluster | 4 ++-- share/github-backup-utils/ghe-restore-pages-dpages-ng | 2 +- .../github-backup-utils/ghe-restore-repositories-dgit-ng | 2 +- .../github-backup-utils/ghe-restore-repositories-gist-ng | 2 +- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 17351bd91..16025aed6 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -283,12 +283,6 @@ ghe_verbose() { # Log if debug mode is enabled (GHE_DEBUG). ghe_debug() { if [ -n "$GHE_DEBUG" ]; then - echo "Debug: $*" | ghe_indent 1>&3 + echo "Debug: $*" 1>&3 fi } - -# Usage: cmd_with_output | ghe_indent -# Indent output -ghe_indent() { - sed 's/^/ /'; -} diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 2123e06d8..230d18099 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -124,7 +124,7 @@ for file_list in $tempdir/*.rsync; do --files-from=$file_list \ --size-only \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/storage/" | ghe_indent 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/storage/" 1>&3 done bm_end "$(basename $0) - Restoring objects" diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index 01e397375..3d7e14287 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -41,7 +41,7 @@ else --rsync-path="sudo -u elasticsearch rsync" \ --copy-dest="$GHE_REMOTE_DATA_USER_DIR/elasticsearch" \ "$snapshot_dir/elasticsearch/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" | ghe_indent 1>&3 + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 # restoring in >=2.14 will remove incompatible indices created with 1.x. if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 14 ]; then diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks-cluster index 45202c0e2..75d889fea 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks-cluster @@ -63,7 +63,7 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" | ghe_indent 1>&3 + "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" 1>&3 for tarball in $tarballs; do env_id=$(echo $tarball | cut -d '/' -f 2) @@ -79,7 +79,7 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos" ]; then -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" | ghe_indent 1>&3 & + "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" 1>&3 & done for pid in $(jobs -p); do diff --git a/share/github-backup-utils/ghe-restore-pages-dpages-ng b/share/github-backup-utils/ghe-restore-pages-dpages-ng index db475e4fd..42b633794 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages-ng +++ b/share/github-backup-utils/ghe-restore-pages-dpages-ng @@ -128,7 +128,7 @@ for file_list in $tempdir/*.rsync; do --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/pages/" | ghe_indent 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/pages/" 1>&3 done bm_end "$(basename $0) - Restoring pages" diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 69a61d155..8f79af5d7 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -147,7 +147,7 @@ for file_list in $tempdir/*.rsync; do --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" | ghe_indent 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 done bm_end "$(basename $0) - Restoring repository networks" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist-ng index 8a5029eeb..f1175679d 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist-ng @@ -131,7 +131,7 @@ for file_list in $tempdir/*.rsync; do --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" | ghe_indent 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 done bm_end "$(basename $0) - Restoring gists" From 059ff7761547375ec8b8dac6f492963a3d8b9b23 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 8 Mar 2018 17:59:03 +0000 Subject: [PATCH 0479/2421] Switch back to quiet --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 230d18099..a5f9724ff 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -119,7 +119,7 @@ for file_list in $tempdir/*.rsync; do server=$(basename $file_list .rsync) ghe_verbose "* Transferring data to $server ..." ghe-rsync -arvHR --delete \ - -e "ssh -v $opts -p $port $ssh_config_file_opt -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ --size-only \ From 950d7126d45fc5136cbf00a0d2ac6fc54ea0e0ac Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 9 Mar 2018 10:12:34 +0000 Subject: [PATCH 0480/2421] Manually revert a51ed4e We don't need this in testing anymore --- .../ghe-backup-alambic-cluster-ng | 20 ++++++++----------- .../ghe-backup-repositories-cluster-ng | 20 ++++++++----------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-alambic-cluster-ng index 1a543b11c..34addbb44 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-alambic-cluster-ng @@ -53,24 +53,20 @@ mkdir -p "$backup_dir" # Removes the remote sync-in-progress file on exit, re-enabling GC operations # on the remote instance. cleanup() { - # Enable remote maintenance operations, unless testing - if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port - done - fi + # Enable remote maintenance operations + for hostname in $hostnames; do + ghe-gc-enable $ssh_config_file_opt $hostname:$port + done ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir rm -rf $tempdir } trap 'cleanup' EXIT INT -# Disable remote maintenance operations, unless testing -if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - for hostname in $hostnames; do - ghe-gc-disable $ssh_config_file_opt $hostname:$port - done -fi +# Disable remote maintenance operations +for hostname in $hostnames; do + ghe-gc-disable $ssh_config_file_opt $hostname:$port +done # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories-cluster-ng index 3afa8b1b1..4faa87ea2 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories-cluster-ng @@ -84,24 +84,20 @@ cleanup() { kill -KILL $pid > /dev/null 2>&1 || true done - # Enable remote GC operations, unless testing - if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port - done - fi + # Enable remote GC operations + for hostname in $hostnames; do + ghe-gc-enable $ssh_config_file_opt $hostname:$port + done rm -rf $tempdir } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate -# Disable remote GC operations, unless testing -if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - for hostname in $hostnames; do - ghe-gc-disable $ssh_config_file_opt $hostname:$port - done -fi +# Disable remote GC operations +for hostname in $hostnames; do + ghe-gc-disable $ssh_config_file_opt $hostname:$port +done # If we have a previous increment, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. From 659401e71d3616e8d2921a4acc8f921b40785c68 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 9 Mar 2018 10:23:16 +0000 Subject: [PATCH 0481/2421] Remove another shellcheck change We'll do this in a new PR --- share/github-backup-utils/ghe-backup-strategy | 3 +-- share/github-backup-utils/ghe-gc-disable | 3 +-- share/github-backup-utils/ghe-gc-enable | 3 +-- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 1 - share/github-backup-utils/ghe-restore-es-audit-log | 3 +-- test/test-docker-build.sh | 3 +-- test/test-ghe-backup-config.sh | 4 +--- 7 files changed, 6 insertions(+), 14 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-strategy b/share/github-backup-utils/ghe-backup-strategy index 5efcdfb34..8f2055627 100755 --- a/share/github-backup-utils/ghe-backup-strategy +++ b/share/github-backup-utils/ghe-backup-strategy @@ -9,8 +9,7 @@ set -e # Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then diff --git a/share/github-backup-utils/ghe-gc-disable b/share/github-backup-utils/ghe-gc-disable index 561520d8f..da49f108c 100755 --- a/share/github-backup-utils/ghe-gc-disable +++ b/share/github-backup-utils/ghe-gc-disable @@ -9,8 +9,7 @@ set -e # Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config while true; do case "$1" in diff --git a/share/github-backup-utils/ghe-gc-enable b/share/github-backup-utils/ghe-gc-enable index b08747519..2506d1995 100755 --- a/share/github-backup-utils/ghe-gc-enable +++ b/share/github-backup-utils/ghe-gc-enable @@ -9,8 +9,7 @@ set -e # Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config while true; do case "$1" in diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index a5f9724ff..8765d0f0c 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -8,7 +8,6 @@ set -e # Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config # Show usage and bail with no arguments diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 77493389f..45da1e83a 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -7,8 +7,7 @@ set -e # Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config # Show usage and bail with no arguments [ $# -lt 1 ] && print_usage diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 4d2e3a0cb..54a057025 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -9,8 +9,7 @@ if ! docker ps >/dev/null 2>&1; then fi # Bring in testlib -# shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. $(dirname "$0")/testlib.sh # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 65cfa1974..ef63a9b53 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -18,9 +18,7 @@ cd "$ROOTDIR" begin_test "ghe-backup-config GHE_DATA_DIR defined" ( set +e - # shellcheck disable=SC2030 - GHE_DATA_DIR= - error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + GHE_DATA_DIR= error=$(. share/github-backup-utils/ghe-backup-config 2>&1) # should exit 2 if [ $? != 2 ]; then exit 1 From 2f3bda5d88b4b8ca618b5e580e9fff612b765898 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 9 Mar 2018 21:58:51 +1100 Subject: [PATCH 0482/2421] Use a for loop instead of a while loop --- share/github-backup-utils/ghe-backup-es-audit-log | 6 ++++-- share/github-backup-utils/ghe-backup-es-hookshot | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 71d388818..8014eaded 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -41,7 +41,9 @@ if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test - fi fi -while read index; do +IFS=$'\n' +for index in $indices; do + IFS=' ' set $index index_name=$1 index_size=$2 @@ -54,6 +56,6 @@ while read index; do ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz echo $index_size > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size fi -done <<< "$indices" +done bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index bd91a890e..61004afc4 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -34,7 +34,9 @@ fi # Hookshot indices may not exist if no recent webhook deliveries have occured. [ -z "$indices" ] && exit -while read index; do +IFS=$'\n' +for index in $indices; do + IFS=' ' set $index index_name=$1 index_size=$2 @@ -47,6 +49,6 @@ while read index; do ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz echo $index_size > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size fi -done <<< "$indices" +done bm_end "$(basename $0)" From 9a075fcaaf7e2fb7caed25a2c6a8ff00b96209dd Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 9 Mar 2018 11:20:11 +0000 Subject: [PATCH 0483/2421] Correctly sync repository/info and add to tests --- .../ghe-restore-repositories-dgit-ng | 30 +++++++++---------- test/testlib.sh | 10 +++++-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories-dgit-ng index 8f79af5d7..3c8900041 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories-dgit-ng @@ -1,23 +1,11 @@ #!/usr/bin/env bash #/ Usage: ghe-restore-repositories-dgit-ng -#/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. +#/ Restore repositories from an rsync snapshot of all Git repository data. #/ #/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-restore command when restoring into a cluster. set -e -sync_repo_info() { - for uuid in `ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -u`; do - if ! ghe-rsync -av --delete \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "git-server-$uuid:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to git-server-$uuid" 1>&2 - fi - done -} - # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config @@ -166,10 +154,22 @@ fi bm_start "$(basename $0) - Updating repository info data" if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" - sync_repo_info + for hostname in $hostnames; do + if ! ghe-rsync -av --delete \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to $hostname" 1>&2 + fi + done else ghe_verbose "* Removing repository info data" - ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -- rm -f /data/repositories/info/* + if $CLUSTER; then + ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r git -- rm -f /data/repositories/info/* + else + ghe-ssh "$GHE_HOSTNAME" -- sudo -u git rm -f /data/repositories/info/* + fi fi bm_end "$(basename $0) - Updating repository info data" diff --git a/test/testlib.sh b/test/testlib.sh index 86ca3109f..7604b0543 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -176,8 +176,10 @@ skip_test() { # Create dummy data used for testing # This same method can be used to generate the data used for testing backups -# and restores by passing in the appropriate location. +# and restores by passing in the appropriate location, for example: # +# Testing backups: setup_test_data $GHE_REMOTE_DATA_USER_DIR +# Testing restores: setup_test_data "$GHE_DATA_DIR/1" # setup_test_data () { local loc=$1 @@ -258,9 +260,13 @@ setup_test_data () { touch hookshot-logs-2018-03-05.gz # Create some test repositories in the remote repositories dir - mkdir "$loc/repositories" + mkdir -p "$loc/repositories/info" mkdir -p "$TRASHDIR/hooks" + cd "$loc/repositories" + echo "fake nw-layout" > info/nw-layout + echo "fake svn-v4-upgrade" > info/svn-v4-upgraded + repo1="0/nw/01/aa/3f/1234/1234.git" repo2="0/nw/01/aa/3f/1234/1235.git" repo3="1/nw/23/bb/4c/2345/broken.git" From b7cfb4c1ee02128393883bba775a00a20b0aa01e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 9 Mar 2018 11:59:49 +0000 Subject: [PATCH 0484/2421] Use $CLUSTER rather than potentially confusing node count --- share/github-backup-utils/ghe-restore-alambic-cluster-ng | 2 +- share/github-backup-utils/ghe-restore-pages-dpages-ng | 2 +- share/github-backup-utils/ghe-restore-repositories-dgit-ng | 2 +- share/github-backup-utils/ghe-restore-repositories-gist-ng | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-alambic-cluster-ng index 8765d0f0c..e4066e7f5 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-alambic-cluster-ng @@ -127,7 +127,7 @@ for file_list in $tempdir/*.rsync; do done bm_end "$(basename $0) - Restoring objects" -if [ "$(wc -w <<< $hostnames | awk '{print $1}')" != "1" ]; then +if $CLUSTER; then bm_start "$(basename $0) - Finalizing routes" cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <&3 <&3 < Date: Fri, 9 Mar 2018 15:01:31 +0000 Subject: [PATCH 0485/2421] Perform a minimal config on unconfigured single nodes during restore This ensures the DB is ready for repos etc and ES is configured and running ready for the audit and hookshot logs. --- bin/ghe-restore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 0c9e1824f..fa21cdffe 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -265,6 +265,11 @@ bm_start "ghe-import-mysql" gzip -dc "$GHE_RESTORE_SNAPSHOT_PATH/mysql.sql.gz" | ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-mysql' bm_end "ghe-import-mysql" +if ! $CLUSTER && ! $instance_configured; then + echo "Configuring storage and system services ..." + ghe-ssh "$GHE_HOSTNAME" -- "ghe-single-config-apply --phase-1 && ghe-single-config-apply --phase-2" 1>&3 2>&3 +fi + echo "Restoring Redis database ..." bm_start "ghe-import-redis" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3 @@ -315,7 +320,7 @@ if $CLUSTER; then echo "Configuring cluster ..." ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then - echo "Configuring storage ..." + echo "Configuring appliance ..." ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply --full" 1>&3 2>&3 fi From 541c6f752d37ea16c3a8c0b4e5affb6f6ec04f83 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 10 Mar 2018 09:10:15 +0000 Subject: [PATCH 0486/2421] Add tests for ghe-ssh-config --- test/test-ghe-ssh-config.sh | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 test/test-ghe-ssh-config.sh diff --git a/test/test-ghe-ssh-config.sh b/test/test-ghe-ssh-config.sh new file mode 100755 index 000000000..a4d1a6949 --- /dev/null +++ b/test/test-ghe-ssh-config.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# ghe-ssh command tests + +# Bring in testlib +. "$(dirname "$0")/testlib.sh" + +begin_test "ghe-ssh-config returns config for multiple nodes" +( + set -e + + output=$(ghe-ssh-config host1 git-server1 git-server2) + # Confirm we don't have a host1 entry as this is the proxy host + echo "$output" | grep -Evq "^Host host1" + # Confirm we have a host2 and host3 entry + echo "$output" | grep -Eq "^Host git-server[12]" + [ $(echo "$output" | grep -E "^Host git-server[12]" | wc -l) = 2 ] + # Confirm the host2 and host3 entries proxy though host1 + echo "$output" | grep -q "admin@host1 nc.openbsd" + # Confirm multiplexing enabled + echo "$output" | grep -q "ControlMaster=auto" + # Confirm ControlPath returns correct hash for admin@host1:122 + echo "$output" | grep -q "test/tmp/.ghe-sshmux-84f6bdcf" +) +end_test + +begin_test "ghe-ssh-config multiplexing disabled" +( + set -e + + output=$(GHE_DISABLE_SSH_MUX=1 ghe-ssh-config host1 git-server1) + echo "$output" | grep -vq "ControlMaster=auto" + + output=$(GHE_DISABLE_SSH_MUX=1 ghe-ssh-config host1 git-server1 git-server2) + echo "$output" | grep -vq "ControlMaster=auto" +) +end_test + +begin_test "ghe-ssh-config with extra SSH opts" +( + set -e + + output=$(GHE_EXTRA_SSH_OPTS="-o foo=bar" ghe-ssh-config host1 git-server1) + echo "$output" | grep -q "foo=bar" + + output=$(GHE_EXTRA_SSH_OPTS="-o foo=bar" ghe-ssh-config host1 git-server1 git-server2) + echo "$output" | grep -q "foo=bar" +) +end_test From 40ce66b3014f71cbf625ae1a40dbbd7d16042f0d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 10 Mar 2018 12:33:46 +0000 Subject: [PATCH 0487/2421] Add test fake ghe-single-config-apply --- test/bin/ghe-single-config-apply | 1 + 1 file changed, 1 insertion(+) create mode 120000 test/bin/ghe-single-config-apply diff --git a/test/bin/ghe-single-config-apply b/test/bin/ghe-single-config-apply new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/ghe-single-config-apply @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From 0e998f7503c79e4dba7898ee25628e479a096719 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 10 Mar 2018 12:39:26 +0000 Subject: [PATCH 0488/2421] Loosen grep --- test/test-ghe-ssh-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-ssh-config.sh b/test/test-ghe-ssh-config.sh index a4d1a6949..bfb22b6f4 100755 --- a/test/test-ghe-ssh-config.sh +++ b/test/test-ghe-ssh-config.sh @@ -19,7 +19,7 @@ begin_test "ghe-ssh-config returns config for multiple nodes" # Confirm multiplexing enabled echo "$output" | grep -q "ControlMaster=auto" # Confirm ControlPath returns correct hash for admin@host1:122 - echo "$output" | grep -q "test/tmp/.ghe-sshmux-84f6bdcf" + echo "$output" | grep -q ".ghe-sshmux-84f6bdcf" ) end_test From 038081046fe14e92a1d533b5fb392b4fafdce97b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 10 Mar 2018 13:27:24 +0000 Subject: [PATCH 0489/2421] Rename files to use more generic function-based names --- bin/ghe-backup | 10 +++++----- bin/ghe-restore | 10 +++++----- ...e-backup-git-hooks-cluster => ghe-backup-git-hooks} | 4 ++-- .../{ghe-backup-pages-cluster => ghe-backup-pages} | 4 ++-- .../{ghe-backup-redis-cluster => ghe-backup-redis} | 2 +- ...repositories-cluster-ng => ghe-backup-repositories} | 4 ++-- ...he-backup-alambic-cluster-ng => ghe-backup-storage} | 4 ++-- ...restore-git-hooks-cluster => ghe-restore-git-hooks} | 4 ++-- .../{ghe-restore-pages-dpages-ng => ghe-restore-pages} | 6 +++--- ...e-repositories-dgit-ng => ghe-restore-repositories} | 4 ++-- ...ositories-gist-ng => ghe-restore-repositories-gist} | 6 +++--- ...-restore-alambic-cluster-ng => ghe-restore-storage} | 6 +++--- 12 files changed, 32 insertions(+), 32 deletions(-) rename share/github-backup-utils/{ghe-backup-git-hooks-cluster => ghe-backup-git-hooks} (97%) rename share/github-backup-utils/{ghe-backup-pages-cluster => ghe-backup-pages} (96%) rename share/github-backup-utils/{ghe-backup-redis-cluster => ghe-backup-redis} (97%) rename share/github-backup-utils/{ghe-backup-repositories-cluster-ng => ghe-backup-repositories} (99%) rename share/github-backup-utils/{ghe-backup-alambic-cluster-ng => ghe-backup-storage} (97%) rename share/github-backup-utils/{ghe-restore-git-hooks-cluster => ghe-restore-git-hooks} (97%) rename share/github-backup-utils/{ghe-restore-pages-dpages-ng => ghe-restore-pages} (95%) rename share/github-backup-utils/{ghe-restore-repositories-dgit-ng => ghe-restore-repositories} (98%) rename share/github-backup-utils/{ghe-restore-repositories-gist-ng => ghe-restore-repositories-gist} (95%) rename share/github-backup-utils/{ghe-restore-alambic-cluster-ng => ghe-restore-storage} (96%) diff --git a/bin/ghe-backup b/bin/ghe-backup index 985373186..d398202cc 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -153,7 +153,7 @@ ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql bm_end "ghe-export-mysql" echo "Backing up Redis database ..." -ghe-backup-redis-cluster > redis.rdb || failures="$failures redis" +ghe-backup-redis > redis.rdb || failures="$failures redis" echo "Backing up audit log ..." ghe-backup-es-audit-log || failures="$failures audit-log" @@ -162,16 +162,16 @@ echo "Backing up hookshot logs ..." ghe-backup-es-hookshot || failures="$failures hookshot" echo "Backing up Git repositories ..." -ghe-backup-repositories-cluster-ng || failures="$failures repositories" +ghe-backup-repositories || failures="$failures repositories" echo "Backing up GitHub Pages ..." -ghe-backup-pages-cluster || failures="$failures pages" +ghe-backup-pages || failures="$failures pages" echo "Backing up storage data ..." -ghe-backup-alambic-cluster-ng || failures="$failures alambic" +ghe-backup-storage || failures="$failures storage" echo "Backing up custom Git hooks ..." -ghe-backup-git-hooks-cluster || failures="$failures git-hooks" +ghe-backup-git-hooks || failures="$failures git-hooks" if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then echo "Backing up Elasticsearch indices ..." diff --git a/bin/ghe-restore b/bin/ghe-restore index fa21cdffe..fe3558598 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -276,22 +276,22 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redi bm_end "ghe-import-redis" echo "Restoring Git repositories ..." -ghe-restore-repositories-dgit-ng "$GHE_HOSTNAME" 1>&3 +ghe-restore-repositories "$GHE_HOSTNAME" 1>&3 echo "Restoring Gists ..." -ghe-restore-repositories-gist-ng "$GHE_HOSTNAME" 1>&3 +ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 echo "Restoring GitHub Pages ..." -ghe-restore-pages-dpages-ng "$GHE_HOSTNAME" 1>&3 +ghe-restore-pages "$GHE_HOSTNAME" 1>&3 echo "Restoring SSH authorized keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json" 1>&3 echo "Restoring storage data ..." -ghe-restore-alambic-cluster-ng "$GHE_HOSTNAME" 1>&3 +ghe-restore-storage "$GHE_HOSTNAME" 1>&3 echo "Restoring custom Git hooks ..." -ghe-restore-git-hooks-cluster "$GHE_HOSTNAME" 1>&3 +ghe-restore-git-hooks "$GHE_HOSTNAME" 1>&3 if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then echo "Restoring Elasticsearch indices ..." diff --git a/share/github-backup-utils/ghe-backup-git-hooks-cluster b/share/github-backup-utils/ghe-backup-git-hooks similarity index 97% rename from share/github-backup-utils/ghe-backup-git-hooks-cluster rename to share/github-backup-utils/ghe-backup-git-hooks index 830b61834..32f9e9146 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks-cluster +++ b/share/github-backup-utils/ghe-backup-git-hooks @@ -1,9 +1,9 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup-git-hooks-cluster +#/ Usage: ghe-backup-git-hooks #/ Take an online, incremental snapshot of custom Git hooks configuration. #/ #/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup when the cluster strategy is used. +#/ ghe-backup. set -e # Bring in the backup configuration diff --git a/share/github-backup-utils/ghe-backup-pages-cluster b/share/github-backup-utils/ghe-backup-pages similarity index 96% rename from share/github-backup-utils/ghe-backup-pages-cluster rename to share/github-backup-utils/ghe-backup-pages index 295e06df4..badfb65ab 100755 --- a/share/github-backup-utils/ghe-backup-pages-cluster +++ b/share/github-backup-utils/ghe-backup-pages @@ -1,9 +1,9 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup-pages-cluster +#/ Usage: ghe-backup-pages #/ Take an online, incremental snapshot of all Pages data #/ #/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup when the cluster strategy is used. +#/ ghe-backup. set -e # Bring in the backup configuration diff --git a/share/github-backup-utils/ghe-backup-redis-cluster b/share/github-backup-utils/ghe-backup-redis similarity index 97% rename from share/github-backup-utils/ghe-backup-redis-cluster rename to share/github-backup-utils/ghe-backup-redis index 3b00bb4f7..19eb310e9 100755 --- a/share/github-backup-utils/ghe-backup-redis-cluster +++ b/share/github-backup-utils/ghe-backup-redis @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup-redis-cluster +#/ Usage: ghe-backup-redis #/ Take a snapshot of all Redis data. This is needed because older versions of #/ the remote side ghe-export-redis command use a blocking SAVE instead of a #/ non-blocking BGSAVE. diff --git a/share/github-backup-utils/ghe-backup-repositories-cluster-ng b/share/github-backup-utils/ghe-backup-repositories similarity index 99% rename from share/github-backup-utils/ghe-backup-repositories-cluster-ng rename to share/github-backup-utils/ghe-backup-repositories index 4faa87ea2..75c2fe8c8 100755 --- a/share/github-backup-utils/ghe-backup-repositories-cluster-ng +++ b/share/github-backup-utils/ghe-backup-repositories @@ -1,9 +1,9 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup-repositories-cluster-ng +#/ Usage: ghe-backup-repositories #/ Take an online, incremental snapshot of all Git repository data. #/ #/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup when the cluster strategy is used. +#/ ghe-backup. set -e # This command is designed to allow for transferring active Git repository data diff --git a/share/github-backup-utils/ghe-backup-alambic-cluster-ng b/share/github-backup-utils/ghe-backup-storage similarity index 97% rename from share/github-backup-utils/ghe-backup-alambic-cluster-ng rename to share/github-backup-utils/ghe-backup-storage index 34addbb44..bbc2e7262 100755 --- a/share/github-backup-utils/ghe-backup-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-backup-storage @@ -1,10 +1,10 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup-alambic-cluster-ng +#/ Usage: ghe-backup-storage #/ Take an online, incremental snapshot of all Alambic Storage data using the #/ calculated routes method. #/ #/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup when the cluster strategy is used. +#/ ghe-backup. set -e # Bring in the backup configuration diff --git a/share/github-backup-utils/ghe-restore-git-hooks-cluster b/share/github-backup-utils/ghe-restore-git-hooks similarity index 97% rename from share/github-backup-utils/ghe-restore-git-hooks-cluster rename to share/github-backup-utils/ghe-restore-git-hooks index 75d889fea..eb28d48fd 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks-cluster +++ b/share/github-backup-utils/ghe-restore-git-hooks @@ -1,9 +1,9 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-git-hooks-cluster +#/ Usage: ghe-restore-git-hooks #/ Restore custom Git hooks data from an rsync snapshot #/ #/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-restore when the cluster strategy is used. +#/ ghe-restore. set -e # Bring in the backup configuration diff --git a/share/github-backup-utils/ghe-restore-pages-dpages-ng b/share/github-backup-utils/ghe-restore-pages similarity index 95% rename from share/github-backup-utils/ghe-restore-pages-dpages-ng rename to share/github-backup-utils/ghe-restore-pages index 35abbfdbd..175ff5cbc 100755 --- a/share/github-backup-utils/ghe-restore-pages-dpages-ng +++ b/share/github-backup-utils/ghe-restore-pages @@ -1,9 +1,9 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-pages-dpages-ng -#/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. +#/ Usage: ghe-restore-pages +#/ Restore repositories from an rsync snapshot of all Git repository data. #/ #/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when restoring into a cluster. +#/ ghe-restore command. set -e # Bring in the backup configuration diff --git a/share/github-backup-utils/ghe-restore-repositories-dgit-ng b/share/github-backup-utils/ghe-restore-repositories similarity index 98% rename from share/github-backup-utils/ghe-restore-repositories-dgit-ng rename to share/github-backup-utils/ghe-restore-repositories index 52194277a..64d34b289 100755 --- a/share/github-backup-utils/ghe-restore-repositories-dgit-ng +++ b/share/github-backup-utils/ghe-restore-repositories @@ -1,9 +1,9 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-repositories-dgit-ng +#/ Usage: ghe-restore-repositories #/ Restore repositories from an rsync snapshot of all Git repository data. #/ #/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when restoring into a cluster. +#/ ghe-restore command. set -e # Bring in the backup configuration diff --git a/share/github-backup-utils/ghe-restore-repositories-gist-ng b/share/github-backup-utils/ghe-restore-repositories-gist similarity index 95% rename from share/github-backup-utils/ghe-restore-repositories-gist-ng rename to share/github-backup-utils/ghe-restore-repositories-gist index 578d1e307..c5795ea87 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist-ng +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -1,9 +1,9 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-repositories-gist-ng -#/ Restore repositories fron an rsync snapshot of all Git repository data to a GitHub cluster. +#/ Usage: ghe-restore-repositories-gist +#/ Restore repositories from an rsync snapshot of all Git repository data. #/ #/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when restoring into a cluster. +#/ ghe-restore command. set -e # Bring in the backup configuration diff --git a/share/github-backup-utils/ghe-restore-alambic-cluster-ng b/share/github-backup-utils/ghe-restore-storage similarity index 96% rename from share/github-backup-utils/ghe-restore-alambic-cluster-ng rename to share/github-backup-utils/ghe-restore-storage index e4066e7f5..36fab2ce5 100755 --- a/share/github-backup-utils/ghe-restore-alambic-cluster-ng +++ b/share/github-backup-utils/ghe-restore-storage @@ -1,10 +1,10 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-alambic-cluster-ng +#/ Usage: ghe-restore-storage #/ -#/ Restore storage objects from an rsync snapshot to a GitHub Cluster. +#/ Restore storage objects from an rsync snapshot. #/ #/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when restoring into a cluster. +#/ ghe-restore command. set -e # Bring in the backup configuration From 82f0f24d78b896c6941b49f7e40b8b1b5ce1be84 Mon Sep 17 00:00:00 2001 From: Matthias Wiesen Date: Tue, 13 Mar 2018 13:24:58 +1100 Subject: [PATCH 0490/2421] Add SSH version 5.6 requirement --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index be52b8061..40961b420 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ storage and must have network connectivity with the GitHub Enterprise appliance. ##### Backup host requirements Backup host software requirements are modest: Linux or other modern Unix -operating system with [bash][13], [git][14], [OpenSSH][15] 4.2 or newer, and [rsync][4] v2.6.4 or newer. +operating system with [bash][13], [git][14], [OpenSSH][15] 5.6 or newer, and [rsync][4] v2.6.4 or newer. The backup host must be able to establish network connections outbound to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise 2.0 From 5e0f3821d4aae86fb807bb6c64051cda405ea0e6 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 13 Mar 2018 09:45:52 +0000 Subject: [PATCH 0491/2421] Remove unused opt to ghe-config-apply --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index fe3558598..d8a8c3964 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -321,7 +321,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then echo "Configuring appliance ..." - ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply --full" 1>&3 2>&3 + ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 fi # Start cron. Timerd will start automatically as part of the config run. From d1a8ffbb036493749d92dbb96a37389a80be478d Mon Sep 17 00:00:00 2001 From: Ben Lovett Date: Tue, 13 Mar 2018 12:14:49 -0700 Subject: [PATCH 0492/2421] Retry with the admin ssh port on network unreachable too. --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 279e00700..7ab2198b7 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -65,7 +65,7 @@ set -e if [ $rc -ne 0 ]; then case $rc in 255) - if echo "$output" | grep -i "port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then + if echo "$output" | grep -i "port 22: Network is unreachable\|port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then exec "$(basename $0)" "$hostname:122" fi From debfbc9281a25d7d1eb3dab657908014072496ef Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Mar 2018 12:43:49 +0000 Subject: [PATCH 0493/2421] Revert "Add test fake ghe-single-config-apply" This reverts commit 40ce66b3014f71cbf625ae1a40dbbd7d16042f0d. --- test/bin/ghe-single-config-apply | 1 - 1 file changed, 1 deletion(-) delete mode 120000 test/bin/ghe-single-config-apply diff --git a/test/bin/ghe-single-config-apply b/test/bin/ghe-single-config-apply deleted file mode 120000 index a5ed742f4..000000000 --- a/test/bin/ghe-single-config-apply +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-true \ No newline at end of file From b568c45ffb360b7cd3f9b35e4e752e70c14eef0f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Mar 2018 15:32:15 +0000 Subject: [PATCH 0494/2421] Use alt method of restoring audit and hookshot logs without pre-config --- bin/ghe-restore | 5 ----- .../ghe-restore-es-audit-log | 22 +++++++++++++++++-- .../ghe-restore-es-hookshot | 22 +++++++++++++++++-- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d8a8c3964..eac53bf86 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -265,11 +265,6 @@ bm_start "ghe-import-mysql" gzip -dc "$GHE_RESTORE_SNAPSHOT_PATH/mysql.sql.gz" | ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-mysql' bm_end "ghe-import-mysql" -if ! $CLUSTER && ! $instance_configured; then - echo "Configuring storage and system services ..." - ghe-ssh "$GHE_HOSTNAME" -- "ghe-single-config-apply --phase-1 && ghe-single-config-apply --phase-2" 1>&3 2>&3 -fi - echo "Restoring Redis database ..." bm_start "ghe-import-redis" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3 diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 45da1e83a..94ba7bd41 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -34,12 +34,30 @@ fi last_month=$(printf "audit_log(-[0-9]+)?-%4d-%02d(-[0-9]+)?" $last_yr $last_mth) current_month=$(printf "audit_log(-[0-9]+)?-%4d-%02d(-[0-9]+)?" $this_yr $this_mth) +tmp_list="$(mktemp -t backup-utils-restore-XXXXXX)" +if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then + configured=true +fi + # Only restore indices that don't exist and the last two months' indices. for index in $indices; do if ! ghe-ssh "$GHE_HOSTNAME" "curl -f -s -XGET http://localhost:9201/$index > /dev/null" || [[ $index =~ $last_month ]] || [[ $index =~ $current_month ]]; then - ghe_verbose "* Restoring $index" - gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 + if $CLUSTER || [ -n "$configured" ]; then + ghe_verbose "* Restoring $index" + gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 + else + echo "$index.gz" >> $tmp_list + fi fi done +if [ -s "$tmp_list" ]; then + ghe-rsync -avz --delete \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + --rsync-path="sudo -u elasticsearch rsync" \ + --files-from=$tmp_list \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 + rm $tmp_list +fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index 3cccf4b56..d61b6678c 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -22,12 +22,30 @@ ghe_remote_version_required "$GHE_HOSTNAME" last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1) indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz) +tmp_list="$(mktemp -t backup-utils-restore-XXXXXX)" +if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then + configured=true +fi for index in $indices; do if [ -z "$last_index" ] || ! [ $index \< $last_index ]; then - ghe_verbose "* Restoring $index" - gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 + if $CLUSTER || [ -n "$configured" ]; then + ghe_verbose "* Restoring $index" + gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 + else + echo "$index.gz" >> $tmp_list + fi fi done +if [ -s "$tmp_list" ]; then + ghe-rsync -avz --delete \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + --rsync-path="sudo -u elasticsearch rsync" \ + --files-from=$tmp_list \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 + rm $tmp_list +fi + bm_end "$(basename $0)" From ac9563b368d91f25ec8fda65b82583863f06172d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Mar 2018 15:34:05 +0000 Subject: [PATCH 0495/2421] Use consistent messaging for backups --- share/github-backup-utils/ghe-backup-es-rsync | 10 +++++----- share/github-backup-utils/ghe-backup-pages | 4 ++-- share/github-backup-utils/ghe-backup-repositories | 6 +++--- share/github-backup-utils/ghe-backup-storage | 6 +++--- share/github-backup-utils/ghe-restore-pages | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index e0d244b07..c4ed47a36 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -28,7 +28,7 @@ mkdir -p "$GHE_SNAPSHOT_DIR/elasticsearch" # Verify that the /data/elasticsearch directory exists. if ! ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' ]"; then - echo "* The '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' directory doesn't exist." 1>&3 + ghe_verbose "* The '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' directory doesn't exist." exit 0 fi @@ -41,7 +41,7 @@ fi # Transfer ES indices from a GitHub instance to the current snapshot # directory, using a previous snapshot to avoid transferring files that have # already been transferred. -echo "* Performing initial sync of ES indices ..." 1>&3 +ghe_verbose "* Performing initial sync of ES indices ..." ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ @@ -52,7 +52,7 @@ ghe-rsync -avz \ # Set up a trap to re-enable flushing on exit cleanup () { - echo "* Enabling ES index flushing ..." 1>&3 + ghe_verbose "* Enabling ES index flushing ..." echo '{"index":{"translog.disable_flush":false}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null } @@ -60,13 +60,13 @@ trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate # Disable ES flushing and force a flush right now -echo "* Disabling ES index flushing ..." 1>&3 +ghe_verbose "* Disabling ES index flushing ..." echo '{"index":{"translog.disable_flush":true}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null # Transfer all ES indices again -echo "* Performing follow-up sync of ES indices ..." 1>&3 +ghe_verbose "* Performing follow-up sync of ES indices ..." ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index badfb65ab..e4e1e5d2d 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -65,12 +65,12 @@ fi for hostname in $hostnames; do bm_start "$(basename $0) - $hostname" echo 1>&3 - echo "* Starting backup for host: $hostname" + ghe_verbose "* Starting backup for host: $hostname" # Sync all auxiliary repository data. This includes files and directories like # HEAD, audit_log, config, description, info/, etc. No refs or object data # should be transferred here. echo 1>&3 - echo "* Transferring pages files ..." 1>&3 + ghe_verbose "* Transferring pages files ..." # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 75c2fe8c8..29060d021 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -117,14 +117,14 @@ fi bm_start "$(basename $0) - Calculating Sync Routes" ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-routes \ | while read route; do - ghe_verbose "Got backup route $route" + ghe_debug "Got backup route $route" if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then server=$(echo $route | cut -d ' ' -f2-) else server=$host fi network_path=$(echo $route | cut -d ' ' -f1) - ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + ghe_debug "Adding $network_path to $tempdir/$server.rsync" echo "$network_path" >> $tempdir/$server.rsync done bm_end "$(basename $0) - Calculating Sync Routes" @@ -312,7 +312,7 @@ for file_list in $tempdir/*.rsync; do hostname=$(basename $file_list .rsync) repo_num=$(cat $file_list | wc -l) - echo "* Transferring $repo_num repositories from $hostname" + ghe_verbose "* Transferring $repo_num repositories from $hostname" sync_data $hostname $file_list & done diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index bbc2e7262..4a8da6647 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -86,14 +86,14 @@ fi bm_start "$(basename $0) - Calculating sync routes" ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-backup-routes \ | while read route; do - ghe_verbose "Got backup route $route" + ghe_debug "Got backup route $route" if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then server=$(echo $route | cut -d ' ' -f2-) else server=$host fi network_path=$(echo $route | cut -d ' ' -f1) - ghe_verbose "Adding $network_path to $tempdir/$server.rsync" + ghe_debug "Adding $network_path to $tempdir/$server.rsync" echo "$network_path" >> $tempdir/$server.rsync done bm_end "$(basename $0) - Calculating sync routes" @@ -109,7 +109,7 @@ for file_list in $tempdir/*.rsync; do hostname=$(basename $file_list .rsync) object_num=$(cat $file_list | wc -l) - echo "* Transferring $object_num objects from $hostname" + ghe_verbose "* Transferring $object_num objects from $hostname" ghe-rsync -avr \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 175ff5cbc..88d0870ae 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -115,7 +115,7 @@ done bm_end "$(basename $0) - Calculating sync routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then - echo "Warning: no routes found, skipping storage restore ..." + echo "Warning: no routes found, skipping pages restore ..." exit 0 fi From de0f22f4a2bf031a005dad9680aad3c8068ef87e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Mar 2018 16:58:18 +0000 Subject: [PATCH 0496/2421] Exclude tmp audit and hookshot logs --- test/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 7604b0543..9597458c5 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -408,7 +408,7 @@ verify_all_restored_data() { diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" # verify all ES data was transferred from live directory to the temporary restore directory - diff -ru "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" + diff -ru --exclude="*.gz" "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" # verify management console password was *not* restored ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" From 0d6fd39d3f39716eacc2546abd6a71e654bcb081 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Mar 2018 18:46:28 +0000 Subject: [PATCH 0497/2421] Use consistent two-space indentation --- bin/ghe-backup | 18 +- bin/ghe-host-check | 54 ++-- bin/ghe-restore | 2 +- script/cibuild | 43 +-- script/package-tarball | 8 +- share/github-backup-utils/ghe-backup-config | 108 ++++---- share/github-backup-utils/ghe-backup-es-rsync | 40 +-- .../github-backup-utils/ghe-backup-git-hooks | 75 +++-- share/github-backup-utils/ghe-backup-pages | 14 +- share/github-backup-utils/ghe-backup-redis | 46 +-- share/github-backup-utils/ghe-backup-storage | 4 +- share/github-backup-utils/ghe-backup-userdata | 14 +- share/github-backup-utils/ghe-gc-disable | 56 ++-- share/github-backup-utils/ghe-gc-enable | 22 +- .../ghe-maintenance-mode-status | 18 +- share/github-backup-utils/ghe-prune-snapshots | 12 +- .../ghe-restore-es-audit-log | 10 +- .../ghe-restore-es-hookshot | 10 +- .../github-backup-utils/ghe-restore-es-rsync | 32 +-- share/github-backup-utils/ghe-restore-pages | 4 +- .../ghe-restore-repositories | 18 +- .../github-backup-utils/ghe-restore-settings | 18 +- .../ghe-restore-snapshot-path | 6 +- .../github-backup-utils/ghe-restore-userdata | 12 +- share/github-backup-utils/ghe-rsync | 2 +- share/github-backup-utils/ghe-ssh | 54 ++-- test/test-ghe-backup-config.sh | 160 +++++------ test/test-ghe-backup.sh | 100 +++---- test/test-ghe-cluster-nodes.sh | 22 +- test/test-ghe-host-check.sh | 16 +- test/test-ghe-prune-snapshots.sh | 24 +- test/test-ghe-restore.sh | 262 +++++++++--------- test/test-ghe-ssh.sh | 36 +-- test/testlib.sh | 103 +++---- 34 files changed, 713 insertions(+), 710 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index d398202cc..941832bad 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -187,24 +187,24 @@ fi # current symlink to point to the new snapshot and prune expired and failed # snapshots. if [ -z "$failures" ]; then - rm "incomplete" + rm "incomplete" - rm -f "../current" - ln -s "$GHE_SNAPSHOT_TIMESTAMP" "../current" + rm -f "../current" + ln -s "$GHE_SNAPSHOT_TIMESTAMP" "../current" - ghe-prune-snapshots + ghe-prune-snapshots fi echo "Completed backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP at $(date +"%H:%M:%S")" # Exit non-zero and list the steps that failed. if [ -z "$failures" ]; then - ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP successfully." + ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP successfully." else - steps="$(echo $failures | sed 's/ /, /g')" - ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP with failures: ${steps}." - echo "Error: Snapshot incomplete. Some steps failed: ${steps}. " - exit 1 + steps="$(echo $failures | sed 's/ /, /g')" + ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP with failures: ${steps}." + echo "Error: Snapshot incomplete. Some steps failed: ${steps}. " + exit 1 fi # Detect if the created backup contains any leaked ssh keys diff --git a/bin/ghe-host-check b/bin/ghe-host-check index d99a929bc..02bd5e4e4 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -42,9 +42,9 @@ host="${1:-$GHE_HOSTNAME}" # Options to pass to SSH during connection check options=" - -o PasswordAuthentication=no - -o ConnectTimeout=5 - -o ConnectionAttempts=1 + -o PasswordAuthentication=no + -o ConnectTimeout=5 + -o ConnectionAttempts=1 " # Split host:port into parts @@ -57,37 +57,37 @@ rc=$? set -e if [ $rc -ne 0 ]; then - case $rc in - 255) - if echo "$output" | grep -i "port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then - exec "$(basename $0)" "$hostname:122" - fi + case $rc in + 255) + if echo "$output" | grep -i "port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then + exec "$(basename $0)" "$hostname:122" + fi - echo "$output" 1>&2 - echo "Error: ssh connection with '$host' failed" 1>&2 - echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2 - echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2 - ;; - 101) - echo "Error: couldn't read GitHub Enterprise fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 - ;; - 1) - if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then - exec "$(basename $0)" "$hostname:122" - else - echo "$output" 1>&2 - fi - ;; + echo "$output" 1>&2 + echo "Error: ssh connection with '$host' failed" 1>&2 + echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2 + echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2 + ;; + 101) + echo "Error: couldn't read GitHub Enterprise fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 + ;; + 1) + if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then + exec "$(basename $0)" "$hostname:122" + else + echo "$output" 1>&2 + fi + ;; - esac - exit $rc + esac + exit $rc fi version=$(echo "$output" | sed -n 's/GitHub Enterprise version \(.*\)/\1/p') if [ -z "$version" ]; then - echo "Error: failed to parse version on '$host' or this isn't a GitHub appliance." 1>&2 - exit 2 + echo "Error: failed to parse version on '$host' or this isn't a GitHub appliance." 1>&2 + exit 2 fi # backup-utils 2.13 onwards only has support for 2.11 and newer versions. diff --git a/bin/ghe-restore b/bin/ghe-restore index eac53bf86..5f48a6798 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -307,7 +307,7 @@ ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 # Restart an already running memcached to reset the cache after restore echo "Restarting memcached ..." 1>&3 echo "sudo restart -q memcached 2>/dev/null || true" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. diff --git a/script/cibuild b/script/cibuild index 843e45649..c5709c627 100755 --- a/script/cibuild +++ b/script/cibuild @@ -17,12 +17,12 @@ export GHE_VERBOSE_SSH=true res=true for version in $REMOTE_VERSIONS do - echo "==> Running testsuite with GHE_TEST_REMOTE_VERSION=$version" - export GHE_TEST_REMOTE_VERSION="$version" - if ! ls -1 test/test-*.sh | xargs -P 4 -n 1 /bin/bash; then - res=false - fi - echo + echo "==> Running testsuite with GHE_TEST_REMOTE_VERSION=$version" + export GHE_TEST_REMOTE_VERSION="$version" + if ! ls -1 test/test-*.sh | xargs -P 4 -n 1 /bin/bash; then + res=false + fi + echo done # If any of the version tests failed, exit non-zero @@ -35,31 +35,34 @@ $res pkg_files= # Build the tarball +ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +TMPDIR="$ROOTDIR/test/tmp" + echo "Building tar.gz package ..." -if script/package-tarball 1>package-tarball.txt 2>&1; then - pkg_files=$(grep '^Package ' < package-tarball.txt | cut -f 2 -d ' ') +if script/package-tarball 1>$TMPDIR/package-tarball.txt 2>&1; then + pkg_files=$(grep '^Package ' < $TMPDIR/package-tarball.txt | cut -f 2 -d ' ') else - echo "Packaging tar.gz failed:" - cat package-tarball.txt | sed 's/^/ /' 1>&2 - exit 1 + echo "Packaging tar.gz failed:" + cat $TMPDIR/package-tarball.txt | sed 's/^/ /' 1>&2 + exit 1 fi # Skip deb packaging if debuild not installed if ! type debuild 1>/dev/null 2>&1; then - echo "debuild not installed, skipping deb packaging ..." - exit 0 + echo "debuild not installed, skipping deb packaging ..." + exit 0 fi # Build the deb related packages echo "Building deb package ..." -if DEB_BUILD_OPTIONS=nocheck script/package-deb 1>package-deb-out.txt 2>package-deb-err.txt; then - pkg_files="$pkg_files $(cat package-deb-out.txt)" +if DEB_BUILD_OPTIONS=nocheck script/package-deb 1>$TMPDIR/package-deb-out.txt 2>$TMPDIR/package-deb-err.txt; then + pkg_files="$pkg_files $(cat $TMPDIR/package-deb-out.txt)" else - echo "Package build failed:" - cat package-deb-out.txt package-deb-err.txt >&2 - echo >&2 - cat dist/debuild/github-backup-utils*.build >&2 - exit 1 + echo "Package build failed:" + cat $TMPDIR/package-deb-out.txt $TMPDIR/package-deb-err.txt >&2 + echo >&2 + cat dist/debuild/github-backup-utils*.build >&2 + exit 1 fi # Generate md5sums diff --git a/script/package-tarball b/script/package-tarball index 65f4ed51d..be653b77a 100755 --- a/script/package-tarball +++ b/script/package-tarball @@ -17,10 +17,10 @@ PKG_NAME="${PKG_BASE}-${PKG_VERS}" echo "Creating ${PKG_NAME}.tar.gz ..." mkdir -p dist git archive \ - --format=tar.gz \ - --prefix="$PKG_NAME/" \ - --output="dist/${PKG_NAME}.tar.gz" \ - HEAD + --format=tar.gz \ + --prefix="$PKG_NAME/" \ + --output="dist/${PKG_NAME}.tar.gz" \ + HEAD # List archive contents for review gzip -dc < "dist/${PKG_NAME}.tar.gz" | tar tf - diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 16025aed6..1c1a0b5b7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -36,8 +36,8 @@ fi # Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage print_usage () { - grep '^#/' <"$0" | cut -c 4- - exit ${1:-1} + grep '^#/' <"$0" | cut -c 4- + exit ${1:-1} } if [ -n "$GHE_SHOW_HELP" ]; then @@ -64,22 +64,22 @@ GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" config_found=false for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ "$HOME/.github-backup-utils/backup.config" "/etc/github-backup-utils/backup.config"; do - if [ -f "$f" ]; then - GHE_BACKUP_CONFIG="$f" - . "$GHE_BACKUP_CONFIG" - config_found=true - break - fi + if [ -f "$f" ]; then + GHE_BACKUP_CONFIG="$f" + . "$GHE_BACKUP_CONFIG" + config_found=true + break + fi done # Check that the config file exists before we source it in. if ! $config_found; then - echo "Error: No backup configuration file found. Tried:" 1>&2 - [ -n "$GHE_BACKUP_CONFIG" ] && echo " - $GHE_BACKUP_CONFIG" 1>&2 - echo " - $GHE_BACKUP_ROOT/backup.config" 1>&2 - echo " - $HOME/.github-backup-utils/backup.config" 1>&2 - echo " - /etc/github-backup-utils/backup.config" 1>&2 - exit 2 + echo "Error: No backup configuration file found. Tried:" 1>&2 + [ -n "$GHE_BACKUP_CONFIG" ] && echo " - $GHE_BACKUP_CONFIG" 1>&2 + echo " - $GHE_BACKUP_ROOT/backup.config" 1>&2 + echo " - $HOME/.github-backup-utils/backup.config" 1>&2 + echo " - /etc/github-backup-utils/backup.config" 1>&2 + exit 2 fi # Restore saved off hostname. @@ -87,14 +87,14 @@ fi # Check that the GHE hostname is set. if [ -z "$GHE_HOSTNAME" ]; then - echo "Error: GHE_HOSTNAME not set in config file." 1>&2 - exit 2 + echo "Error: GHE_HOSTNAME not set in config file." 1>&2 + exit 2 fi # Check that the GHE data directory is set. if [ -z "$GHE_DATA_DIR" ]; then - echo "Error: GHE_DATA_DIR not set in config file." 1>&2 - exit 2 + echo "Error: GHE_DATA_DIR not set in config file." 1>&2 + exit 2 fi # Convert the data directory path to an absolute path, basing any relative @@ -120,13 +120,13 @@ GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} # Check that the data directory is set and create it if it doesn't exist. if [ ! -d "$GHE_DATA_DIR" ] && [ "$GHE_CREATE_DATA_DIR" = "yes" ]; then - echo "Creating the backup data directory ..." 1>&3 - mkdir -p "$GHE_DATA_DIR" + echo "Creating the backup data directory ..." 1>&3 + mkdir -p "$GHE_DATA_DIR" fi if [ ! -d "$GHE_DATA_DIR" ]; then - echo "Error: GHE_DATA_DIR $GHE_DATA_DIR does not exist." >&2 - exit 8 + echo "Error: GHE_DATA_DIR $GHE_DATA_DIR does not exist." >&2 + exit 8 fi # Set some defaults if needed. @@ -189,9 +189,9 @@ GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP" # called immediately after the remote version is obtained by # ghe_remote_version_required(). Child processes inherit the values set here. ghe_remote_version_config () { - GHE_REMOTE_DATA_USER_DIR="$GHE_REMOTE_DATA_DIR/user" - export GHE_REMOTE_DATA_DIR GHE_REMOTE_DATA_USER_DIR - export GHE_REMOTE_LICENSE_FILE + GHE_REMOTE_DATA_USER_DIR="$GHE_REMOTE_DATA_DIR/user" + export GHE_REMOTE_DATA_DIR GHE_REMOTE_DATA_USER_DIR + export GHE_REMOTE_LICENSE_FILE } ############################################################################### @@ -199,13 +199,13 @@ ghe_remote_version_config () { # If we don't have a readlink command, parse ls -l output. if ! type readlink 1>/dev/null 2>&1; then - readlink () { - if [ -x "$1" ]; then - ls -ld "$1" | sed 's/.*-> //' - else - return 1 - fi - } + readlink () { + if [ -x "$1" ]; then + ls -ld "$1" | sed 's/.*-> //' + else + return 1 + fi + } fi # Run ghe-host-check and establish the version of the remote GitHub instance in @@ -215,22 +215,22 @@ fi # ghe-host-check directly to reduce ssh roundtrips. The top-level ghe-backup and # ghe-restore commands establish the version for all subcommands. ghe_remote_version_required () { - if [ -z "$GHE_REMOTE_VERSION" ]; then - _out=$(ghe-host-check "$@") - echo "$_out" + if [ -z "$GHE_REMOTE_VERSION" ]; then + _out=$(ghe-host-check "$@") + echo "$_out" - # override hostname w/ ghe-host-check output because the port could have - # been autodetected to 122. - GHE_HOSTNAME=$(echo "$_out" | sed 's/Connect \(.*:[0-9]*\) OK.*/\1/') - export GHE_HOSTNAME + # override hostname w/ ghe-host-check output because the port could have + # been autodetected to 122. + GHE_HOSTNAME=$(echo "$_out" | sed 's/Connect \(.*:[0-9]*\) OK.*/\1/') + export GHE_HOSTNAME - GHE_REMOTE_VERSION=$(echo "$_out" | sed 's/.*(\(.*\))/\1/') - export GHE_REMOTE_VERSION + GHE_REMOTE_VERSION=$(echo "$_out" | sed 's/.*(\(.*\))/\1/') + export GHE_REMOTE_VERSION - ghe_parse_remote_version "$GHE_REMOTE_VERSION" - ghe_remote_version_config "$GHE_REMOTE_VERSION" - fi - true + ghe_parse_remote_version "$GHE_REMOTE_VERSION" + ghe_remote_version_config "$GHE_REMOTE_VERSION" + fi + true } # Parse major, minor, and patch parts of the remote appliance version and store @@ -241,34 +241,34 @@ ghe_remote_version_required () { # Scripts use these variables to alter behavior based on what's supported on the # appliance version. ghe_parse_remote_version () { - GHE_VERSION_MAJOR=$(echo "${1#v}" | cut -f 1 -d .) - GHE_VERSION_MINOR=$(echo "$1" | cut -f 2 -d .) - GHE_VERSION_PATCH=$(echo "$1" | cut -f 3 -d .) - GHE_VERSION_PATCH=${GHE_VERSION_PATCH%%[a-zA-Z]*} + GHE_VERSION_MAJOR=$(echo "${1#v}" | cut -f 1 -d .) + GHE_VERSION_MINOR=$(echo "$1" | cut -f 2 -d .) + GHE_VERSION_PATCH=$(echo "$1" | cut -f 3 -d .) + GHE_VERSION_PATCH=${GHE_VERSION_PATCH%%[a-zA-Z]*} - export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH + export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH } # Parses the part out of a ":" or just "" string. # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. ssh_host_part () { - [ "${1##*:}" = "$1" ] && echo "$1" || echo "${1%:*}" + [ "${1##*:}" = "$1" ] && echo "$1" || echo "${1%:*}" } # Parses the part out of a ":" or just "" string. # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. ssh_port_part () { - [ "${1##*:}" = "$1" ] && echo 22 || echo "${1##*:}" + [ "${1##*:}" = "$1" ] && echo 22 || echo "${1##*:}" } # Usage: ghe_remote_logger ... # Log a message to /var/log/syslog on the remote instance. # Note: Use sparingly. Remote logging requires an ssh connection per invocation. ghe_remote_logger () { - echo "$@" | - ghe-ssh "$GHE_HOSTNAME" -- logger -t backup-utils || true + echo "$@" | + ghe-ssh "$GHE_HOSTNAME" -- logger -t backup-utils || true } # Usage: ghe_verbose diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index c4ed47a36..b50c6859a 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -19,8 +19,8 @@ ghe_remote_version_required "$host" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 + echo "Error: rsync not found." 1>&2 + exit 1 fi # Make sure root backup dir exists if this is the first run @@ -28,14 +28,14 @@ mkdir -p "$GHE_SNAPSHOT_DIR/elasticsearch" # Verify that the /data/elasticsearch directory exists. if ! ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' ]"; then - ghe_verbose "* The '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' directory doesn't exist." - exit 0 + ghe_verbose "* The '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' directory doesn't exist." + exit 0 fi # If we have a previous increment, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$GHE_DATA_DIR/current/elasticsearch" ]; then - link_dest="--link-dest=../../current/elasticsearch" + link_dest="--link-dest=../../current/elasticsearch" fi # Transfer ES indices from a GitHub instance to the current snapshot @@ -43,18 +43,18 @@ fi # already been transferred. ghe_verbose "* Performing initial sync of ES indices ..." ghe-rsync -avz \ - -e "ghe-ssh -p $(ssh_port_part "$host")" \ - --rsync-path="sudo -u elasticsearch rsync" \ - $link_dest \ - --exclude='elasticsearch.yml' \ - "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ - "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 + -e "ghe-ssh -p $(ssh_port_part "$host")" \ + --rsync-path="sudo -u elasticsearch rsync" \ + $link_dest \ + --exclude='elasticsearch.yml' \ + "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ + "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 # Set up a trap to re-enable flushing on exit cleanup () { - ghe_verbose "* Enabling ES index flushing ..." - echo '{"index":{"translog.disable_flush":false}}' | - ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null + ghe_verbose "* Enabling ES index flushing ..." + echo '{"index":{"translog.disable_flush":false}}' | + ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate @@ -68,12 +68,12 @@ ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null # Transfer all ES indices again ghe_verbose "* Performing follow-up sync of ES indices ..." ghe-rsync -avz \ - -e "ghe-ssh -p $(ssh_port_part "$host")" \ - --rsync-path="sudo -u elasticsearch rsync" \ - $link_dest \ - --exclude='elasticsearch.yml' \ - "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ - "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 + -e "ghe-ssh -p $(ssh_port_part "$host")" \ + --rsync-path="sudo -u elasticsearch rsync" \ + $link_dest \ + --exclude='elasticsearch.yml' \ + "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ + "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 # "Backup" audit log migration sentinel file if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then diff --git a/share/github-backup-utils/ghe-backup-git-hooks b/share/github-backup-utils/ghe-backup-git-hooks index 32f9e9146..5e9024590 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks +++ b/share/github-backup-utils/ghe-backup-git-hooks @@ -13,8 +13,8 @@ bm_start "$(basename $0)" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 + echo "Error: rsync not found." 1>&2 + exit 1 fi bm_start "$(basename $0)" @@ -61,42 +61,41 @@ trap 'exit $?' INT # ^C always terminate # already been transferred. A set of rsync filter rules are provided on stdin # for each invocation. rsync_git_hooks_data () { - port=$(ssh_port_part "$1") - host=$(ssh_host_part "$1") - - subpath=$2 - shift 2 - - # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's - # --link-dest support. This also decreases physical space usage considerably. - if [ -d "$backup_current/$subpath" ] && [ "$(ls -A $backup_current/$subpath)" ]; then - - subdir="git-hooks/$subpath" - link_path=".." - while true; do - if [ $(dirname $subdir) = "." ]; then - break - fi - - if [ $(dirname $subdir) = "/" ]; then - break - fi - - link_path="../$link_path" - subdir=$(dirname $subdir) - done - - local link_dest="--link-dest=../${link_path}/current/git-hooks/$subpath" - fi - - # Ensure target directory exists, is needed with subdirectories - mkdir -p "$backup_dir/$subpath" - - ghe-rsync -av \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" $link_dest \ - --rsync-path='sudo -u git rsync' \ - "$host:$GHE_REMOTE_DATA_USER_DIR/git-hooks/$subpath/" \ - "$backup_dir/$subpath" 1>&3 + port=$(ssh_port_part "$1") + host=$(ssh_host_part "$1") + + subpath=$2 + shift 2 + + # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's + # --link-dest support. This also decreases physical space usage considerably. + if [ -d "$backup_current/$subpath" ] && [ "$(ls -A $backup_current/$subpath)" ]; then + subdir="git-hooks/$subpath" + link_path=".." + while true; do + if [ $(dirname $subdir) = "." ]; then + break + fi + + if [ $(dirname $subdir) = "/" ]; then + break + fi + + link_path="../$link_path" + subdir=$(dirname $subdir) + done + + local link_dest="--link-dest=../${link_path}/current/git-hooks/$subpath" + fi + + # Ensure target directory exists, is needed with subdirectories + mkdir -p "$backup_dir/$subpath" + + ghe-rsync -av \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" $link_dest \ + --rsync-path='sudo -u git rsync' \ + "$host:$GHE_REMOTE_DATA_USER_DIR/git-hooks/$subpath/" \ + "$backup_dir/$subpath" 1>&3 } hostname=$(echo $hostnames | awk '{ print $1; }') diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index e4e1e5d2d..d3124408f 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -17,8 +17,8 @@ backup_dir="$GHE_SNAPSHOT_DIR/pages" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 + echo "Error: rsync not found." 1>&2 + exit 1 fi # Perform a host-check and establish GHE_REMOTE_XXX variables. @@ -74,11 +74,11 @@ for hostname in $hostnames; do # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ - -e "ssh -q $opts -p 122 $ssh_config_file_opt -l $user" \ - --rsync-path='sudo -u git rsync' \ - $link_dest \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/pages/" \ - "$GHE_SNAPSHOT_DIR/pages" 1>&3 + -e "ssh -q $opts -p 122 $ssh_config_file_opt -l $user" \ + --rsync-path='sudo -u git rsync' \ + $link_dest \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/pages/" \ + "$GHE_SNAPSHOT_DIR/pages" 1>&3 bm_end "$(basename $0) - $hostname" done diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index 19eb310e9..a16d89908 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -18,30 +18,30 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Force a redis BGSAVE, and wait for it to complete. ghe-ssh "$GHE_HOSTNAME" /bin/bash </dev/null || echo "localhost") - timestamp=\$(redis-cli -h \$redis_host LASTSAVE) - - for i in \$(seq 10); do - if ! redis-cli -h \$redis_host BGSAVE | grep -q ERR; then - break - fi - sleep 15 - done - for n in \$(seq 3600); do - if [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then - break - fi - sleep 1 - done - [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work - - if [ "\$redis_host" != "localhost" ]; then - ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' - else - sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' + set -e + + redis_host=\$(ghe-config cluster.redis-master 2>/dev/null || echo "localhost") + timestamp=\$(redis-cli -h \$redis_host LASTSAVE) + + for i in \$(seq 10); do + if ! redis-cli -h \$redis_host BGSAVE | grep -q ERR; then + break + fi + sleep 15 + done + for n in \$(seq 3600); do + if [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then + break fi + sleep 1 + done + [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work + + if [ "\$redis_host" != "localhost" ]; then + ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' + else + sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' + fi EOF bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 4a8da6647..01778a495 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -18,8 +18,8 @@ backup_dir="$GHE_SNAPSHOT_DIR/storage" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 + echo "Error: rsync not found." 1>&2 + exit 1 fi # Perform a host-check and establish GHE_REMOTE_XXX variables. diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata index 9a8b7e923..1f10bf209 100755 --- a/share/github-backup-utils/ghe-backup-userdata +++ b/share/github-backup-utils/ghe-backup-userdata @@ -12,8 +12,8 @@ bm_start "$(basename $0) - $1" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 + echo "Error: rsync not found." 1>&2 + exit 1 fi # Grab the host and /data/user directory name. @@ -54,10 +54,10 @@ mkdir -p "$GHE_SNAPSHOT_DIR/$dirname" # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ - -e "ghe-ssh -p $(ssh_port_part "$host")" \ - --rsync-path='sudo -u git rsync' \ - $link_dest \ - "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/$dirname/" \ - "$GHE_SNAPSHOT_DIR/$dirname" 1>&3 + -e "ghe-ssh -p $(ssh_port_part "$host")" \ + --rsync-path='sudo -u git rsync' \ + $link_dest \ + "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/$dirname/" \ + "$GHE_SNAPSHOT_DIR/$dirname" 1>&3 bm_end "$(basename $0) - $1" diff --git a/share/github-backup-utils/ghe-gc-disable b/share/github-backup-utils/ghe-gc-disable index da49f108c..c233c4228 100755 --- a/share/github-backup-utils/ghe-gc-disable +++ b/share/github-backup-utils/ghe-gc-disable @@ -12,17 +12,17 @@ set -e . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config while true; do - case "$1" in - -F) - opts="$1 $2" - shift 2 - ;; - *) - host="$1" - shift - break - ;; - esac + case "$1" in + -F) + opts="$1 $2" + shift 2 + ;; + *) + host="$1" + shift + break + ;; + esac done # Show usage with no host @@ -34,22 +34,22 @@ done # Touch the sync-in-progress file, disabling GC operations, and wait for all # active GC processes to finish on the remote side. echo " - set -e - sudo -u git touch '$SYNC_IN_PROGRESS_FILE' - for i in \$(seq $GHE_GIT_COOLDOWN_PERIOD); do - # note: the bracket synta[x] below is to prevent matches against the - # grep process itself. - if ps axo args | grep -E -e '^git( -.*)? nw-repac[k]( |$)' -e '^git( -.*)? g[c]( |$)' >/dev/null; then - sleep 1 - else - exit 0 - fi - done - exit 7 -" | ghe-ssh $opts "$host" -- /bin/bash || { - res=$? - if [ $res = 7 ]; then - echo "Error: Git GC processes remain after $GHE_GIT_COOLDOWN_PERIOD seconds. Aborting..." 1>&2 + set -e + sudo -u git touch '$SYNC_IN_PROGRESS_FILE' + for i in \$(seq $GHE_GIT_COOLDOWN_PERIOD); do + # note: the bracket synta[x] below is to prevent matches against the + # grep process itself. + if ps axo args | grep -E -e '^git( -.*)? nw-repac[k]( |$)' -e '^git( -.*)? g[c]( |$)' >/dev/null; then + sleep 1 + else + exit 0 fi - exit $res + done + exit 7 +" | ghe-ssh $opts "$host" -- /bin/bash || { + res=$? + if [ $res = 7 ]; then + echo "Error: Git GC processes remain after $GHE_GIT_COOLDOWN_PERIOD seconds. Aborting..." 1>&2 + fi + exit $res } diff --git a/share/github-backup-utils/ghe-gc-enable b/share/github-backup-utils/ghe-gc-enable index 2506d1995..6dd3b6e48 100755 --- a/share/github-backup-utils/ghe-gc-enable +++ b/share/github-backup-utils/ghe-gc-enable @@ -12,17 +12,17 @@ set -e . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config while true; do - case "$1" in - -F) - opts="$1 $2" - shift 2 - ;; - *) - host="$1" - shift - break - ;; - esac + case "$1" in + -F) + opts="$1 $2" + shift 2 + ;; + *) + host="$1" + shift + break + ;; + esac done # Show usage with no host diff --git a/share/github-backup-utils/ghe-maintenance-mode-status b/share/github-backup-utils/ghe-maintenance-mode-status index aa76f6a9b..46f4c9a5a 100755 --- a/share/github-backup-utils/ghe-maintenance-mode-status +++ b/share/github-backup-utils/ghe-maintenance-mode-status @@ -8,15 +8,15 @@ set -e # Parse args while true; do - case "$1" in - -*) - echo "ghe-maintenance-mode-enable: illegal argument: $1" 1>&2 - exit 1 - ;; - *) - break - ;; - esac + case "$1" in + -*) + echo "ghe-maintenance-mode-enable: illegal argument: $1" 1>&2 + exit 1 + ;; + *) + break + ;; + esac done # Show usage and bail with no arguments diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index ddc92d3da..366db8b4e 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -24,16 +24,16 @@ prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) if [ $prune_num -gt 0 ]; then - echo Pruning $prune_num "failed snapshot(s) ..." - echo "$prune_dirs" | sed 's@/incomplete$@@' | prune_snapshot + echo Pruning $prune_num "failed snapshot(s) ..." + echo "$prune_dirs" | sed 's@/incomplete$@@' | prune_snapshot fi # Now prune all expired snapshots. Keep GHE_NUM_SNAPSHOTS around. snapshot_count=$(ls -1d "$GHE_DATA_DIR"/[0-9]* 2>/dev/null | wc -l) if [ "$snapshot_count" -gt "$GHE_NUM_SNAPSHOTS" ]; then - prune_dirs="$(ls -1d "$GHE_DATA_DIR"/[0-9]* | sort -r | awk "NR>$GHE_NUM_SNAPSHOTS")" - prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) - echo Pruning $prune_num "expired snapshot(s) ..." - echo "$prune_dirs" | prune_snapshot + prune_dirs="$(ls -1d "$GHE_DATA_DIR"/[0-9]* | sort -r | awk "NR>$GHE_NUM_SNAPSHOTS")" + prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) + echo Pruning $prune_num "expired snapshot(s) ..." + echo "$prune_dirs" | prune_snapshot fi diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 94ba7bd41..db460a4d0 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -53,11 +53,11 @@ done if [ -s "$tmp_list" ]; then ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u elasticsearch rsync" \ - --files-from=$tmp_list \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + --rsync-path="sudo -u elasticsearch rsync" \ + --files-from=$tmp_list \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 rm $tmp_list fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index d61b6678c..4d8a1b0fe 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -40,11 +40,11 @@ done if [ -s "$tmp_list" ]; then ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u elasticsearch rsync" \ - --files-from=$tmp_list \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + --rsync-path="sudo -u elasticsearch rsync" \ + --files-from=$tmp_list \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 rm $tmp_list fi diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index 3d7e14287..da121f2d2 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -29,24 +29,24 @@ snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" # Transfer all ES data from the latest snapshot to the GitHub instance. if [ ! -d "$snapshot_dir/elasticsearch" ]; then - echo "Warning: Elasticsearch backup missing. Skipping ..." - exit 0 + echo "Warning: Elasticsearch backup missing. Skipping ..." + exit 0 else - ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 - ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 - - ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u elasticsearch rsync" \ - --copy-dest="$GHE_REMOTE_DATA_USER_DIR/elasticsearch" \ - "$snapshot_dir/elasticsearch/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 - - # restoring in >=2.14 will remove incompatible indices created with 1.x. - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 14 ]; then - ghe-ssh "$GHE_HOSTNAME" -- "sudo /usr/local/share/enterprise/ghe-es-remove-1x-indices" - fi + ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 + + ghe-rsync -avz --delete \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + --rsync-path="sudo -u elasticsearch rsync" \ + --copy-dest="$GHE_REMOTE_DATA_USER_DIR/elasticsearch" \ + "$snapshot_dir/elasticsearch/" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 + + # restoring in >=2.14 will remove incompatible indices created with 1.x. + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 14 ]; then + ghe-ssh "$GHE_HOSTNAME" -- "sudo /usr/local/share/enterprise/ghe-es-remove-1x-indices" + fi fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 88d0870ae..6ca35a11d 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -79,8 +79,8 @@ trap 'cleanup' EXIT bm_start "$(basename $0) - Building pages list" OLDIFS=$IFS; IFS=$'\n' for path in $pages_paths; do - ghe_verbose "* Adding path $path to the list of pages to send" - echo $path + ghe_verbose "* Adding path $path to the list of pages to send" + echo $path done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building pages list" diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 64d34b289..270745412 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -84,11 +84,11 @@ done bm_start "$(basename $0) - Building network list" OLDIFS=$IFS; IFS=$'\n' for path in $network_paths; do - # Get the network ID - # The network id from a repository is the last component of the path - # i.e. /data/repositories/a/nw/a5/bf/c9/37 network ID would be 37 - ghe_verbose "* Adding network_path $path to the list of networks to send" - echo $path + # Get the network ID + # The network id from a repository is the last component of the path + # i.e. /data/repositories/a/nw/a5/bf/c9/37 network ID would be 37 + ghe_verbose "* Adding network_path $path to the list of networks to send" + echo $path done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building network list" @@ -156,10 +156,10 @@ if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" for hostname in $hostnames; do if ! ghe-rsync -av --delete \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then echo "Error restoring /data/repositories/info to $hostname" 1>&2 fi done diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 425aed12c..fa6ccbc47 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -35,23 +35,23 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/en # Restore management console password hash if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/manage-password" ]; then - echo "Restoring management console password ..." - echo "ghe-config secrets.manage '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/manage-password")'" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash + echo "Restoring management console password ..." + echo "ghe-config secrets.manage '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/manage-password")'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash fi # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then - echo "Restoring SAML keys ..." - cat "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -xf -" + echo "Restoring SAML keys ..." + cat "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -xf -" fi # Restore CA certificates if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" ]; then - echo "Restoring CA certificates ..." - cat "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" | - ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates" + echo "Restoring CA certificates ..." + cat "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" | + ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates" fi bm_start "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-snapshot-path b/share/github-backup-utils/ghe-restore-snapshot-path index a82e57bf5..c860a0c64 100755 --- a/share/github-backup-utils/ghe-restore-snapshot-path +++ b/share/github-backup-utils/ghe-restore-snapshot-path @@ -18,13 +18,13 @@ fi # Resolve the snapshot id if we're restoring from current. This is mostly # just for logging. if [ "$GHE_RESTORE_SNAPSHOT" = "current" ]; then - GHE_RESTORE_SNAPSHOT=$(readlink "$GHE_DATA_DIR"/current || true) + GHE_RESTORE_SNAPSHOT=$(readlink "$GHE_DATA_DIR"/current || true) fi # Bail out if we don't have a good snapshot. if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" ]; then - echo "Error: Snapshot '$GHE_RESTORE_SNAPSHOT' doesn't exist." 1>&2 - exit 1 + echo "Error: Snapshot '$GHE_RESTORE_SNAPSHOT' doesn't exist." 1>&2 + exit 1 fi echo "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" diff --git a/share/github-backup-utils/ghe-restore-userdata b/share/github-backup-utils/ghe-restore-userdata index 81d93a604..5d302e144 100755 --- a/share/github-backup-utils/ghe-restore-userdata +++ b/share/github-backup-utils/ghe-restore-userdata @@ -19,8 +19,8 @@ GHE_HOSTNAME="$2" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 + echo "Error: rsync not found." 1>&2 + exit 1 fi # Perform a host-check and establish GHE_REMOTE_XXX variables. @@ -37,10 +37,10 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname" ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname" ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/$dirname" 1>&3 + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname/" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/$dirname" 1>&3 fi bm_end "$(basename $0) - $1" diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index de4f71c7c..402581a55 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -21,7 +21,7 @@ res=$? # rsync exits with 24 when vanished files are detected. if [ $res = 24 ]; then - res=0 + res=0 fi exit $res diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 0b4f5312a..3bc312df8 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -12,29 +12,29 @@ set -e opts="$GHE_EXTRA_SSH_OPTS" while true; do - case "$1" in - -p) - port="$2" - shift 2 - ;; - -l|-o|-F) - opts="$opts $1 $2" - shift 2 - ;; - -c|--clean) - cleanup_mux=1 - shift - ;; - --) - echo "Error: illegal '--' in ssh invocation" - exit 1 - ;; - *) - host="$1" - shift - break - ;; - esac + case "$1" in + -p) + port="$2" + shift 2 + ;; + -l|-o|-F) + opts="$opts $1 $2" + shift 2 + ;; + -c|--clean) + cleanup_mux=1 + shift + ;; + --) + echo "Error: illegal '--' in ssh invocation" + exit 1 + ;; + *) + host="$1" + shift + break + ;; + esac done # Show usage with no host @@ -42,7 +42,7 @@ done # Shift off '--' if given immediately after host. if [ "$1" = "--" ]; then - shift + shift fi # Split host:port into parts. The port is only used if not specified earlier. @@ -57,9 +57,9 @@ opts="-l $user $opts" # Bail out with error if the simple command form is used with complex commands. # Complex if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then - echo "fatal: ghe-ssh: Attempt to invoke complex command with simple command form." 1>&2 - echo "See ghe-ssh --help for more on correcting." 1>&2 - exit 1 + echo "fatal: ghe-ssh: Attempt to invoke complex command with simple command form." 1>&2 + echo "See ghe-ssh --help for more on correcting." 1>&2 + exit 1 fi if [ -z "$GHE_DISABLE_SSH_MUX" ]; then diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index ef63a9b53..4288cd941 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -17,110 +17,110 @@ cd "$ROOTDIR" begin_test "ghe-backup-config GHE_DATA_DIR defined" ( - set +e - GHE_DATA_DIR= error=$(. share/github-backup-utils/ghe-backup-config 2>&1) - # should exit 2 - if [ $? != 2 ]; then - exit 1 - fi - set -e - echo $error | grep -q "Error: GHE_DATA_DIR not set in config file." + set +e + GHE_DATA_DIR= error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + # should exit 2 + if [ $? != 2 ]; then + exit 1 + fi + set -e + echo $error | grep -q "Error: GHE_DATA_DIR not set in config file." ) end_test begin_test "ghe-backup-config GHE_CREATE_DATA_DIR disabled" ( - set -e - - export GHE_DATA_DIR="$TRASHDIR/create-enabled-data" - export GHE_VERBOSE=1 - . share/github-backup-utils/ghe-backup-config | - grep -q "Creating the backup data directory ..." - test -d $GHE_DATA_DIR - rm -rf $GHE_DATA_DIR - - export GHE_DATA_DIR="$TRASHDIR/create-disabled-data" - export GHE_CREATE_DATA_DIR=no - set +e - error=$(. share/github-backup-utils/ghe-backup-config 2>&1) - # should exit 8 - if [ $? != 8 ]; then - exit 1 - fi - set -e - echo $error | grep -q "Error: GHE_DATA_DIR .* does not exist" - - rm -rf $GHE_DATA_DIR + set -e + + export GHE_DATA_DIR="$TRASHDIR/create-enabled-data" + export GHE_VERBOSE=1 + . share/github-backup-utils/ghe-backup-config | + grep -q "Creating the backup data directory ..." + test -d $GHE_DATA_DIR + rm -rf $GHE_DATA_DIR + + export GHE_DATA_DIR="$TRASHDIR/create-disabled-data" + export GHE_CREATE_DATA_DIR=no + set +e + error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + # should exit 8 + if [ $? != 8 ]; then + exit 1 + fi + set -e + echo $error | grep -q "Error: GHE_DATA_DIR .* does not exist" + + rm -rf $GHE_DATA_DIR ) end_test begin_test "ghe-backup-config run on GHE appliance" ( - set -e - - export GHE_RELEASE_FILE="$TRASHDIR/enterprise-release" - touch "$GHE_RELEASE_FILE" - set +e - error=$(. share/github-backup-utils/ghe-backup-config 2>&1) - # should exit 1 - if [ $? != 1 ]; then - exit 1 - fi - set -e - echo "$error" | grep -q "Error: Backup Utils cannot be run on the GitHub Enterprise host." - - test -f "$GHE_RELEASE_FILE" - rm -rf "$GHE_RELEASE_FILE" + set -e + + export GHE_RELEASE_FILE="$TRASHDIR/enterprise-release" + touch "$GHE_RELEASE_FILE" + set +e + error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + # should exit 1 + if [ $? != 1 ]; then + exit 1 + fi + set -e + echo "$error" | grep -q "Error: Backup Utils cannot be run on the GitHub Enterprise host." + + test -f "$GHE_RELEASE_FILE" + rm -rf "$GHE_RELEASE_FILE" ) end_test begin_test "ghe-backup-config ssh_host_part" ( - set -e - [ $(ssh_host_part "github.example.com") = "github.example.com" ] - [ $(ssh_host_part "github.example.com:22") = "github.example.com" ] - [ $(ssh_host_part "github.example.com:5000") = "github.example.com" ] - [ $(ssh_host_part "git@github.example.com:5000") = "git@github.example.com" ] + set -e + [ $(ssh_host_part "github.example.com") = "github.example.com" ] + [ $(ssh_host_part "github.example.com:22") = "github.example.com" ] + [ $(ssh_host_part "github.example.com:5000") = "github.example.com" ] + [ $(ssh_host_part "git@github.example.com:5000") = "git@github.example.com" ] ) end_test begin_test "ghe-backup-config ssh_port_part" ( - set -e - [ $(ssh_port_part "github.example.com") = "22" ] - [ $(ssh_port_part "github.example.com:22") = "22" ] - [ $(ssh_port_part "github.example.com:5000") = "5000" ] - [ $(ssh_port_part "git@github.example.com:5000") = "5000" ] + set -e + [ $(ssh_port_part "github.example.com") = "22" ] + [ $(ssh_port_part "github.example.com:22") = "22" ] + [ $(ssh_port_part "github.example.com:5000") = "5000" ] + [ $(ssh_port_part "git@github.example.com:5000") = "5000" ] ) end_test begin_test "ghe-backup-config ghe_parse_remote_version v2.x series" ( - set -e - - ghe_parse_remote_version "v2.0.0" - [ "$GHE_VERSION_MAJOR" = "2" ] - [ "$GHE_VERSION_MINOR" = "0" ] - [ "$GHE_VERSION_PATCH" = "0" ] - - ghe_parse_remote_version "2.0.0" - [ "$GHE_VERSION_MAJOR" = "2" ] - [ "$GHE_VERSION_MINOR" = "0" ] - [ "$GHE_VERSION_PATCH" = "0" ] - - ghe_parse_remote_version "v2.1.5" - [ "$GHE_VERSION_MAJOR" = "2" ] - [ "$GHE_VERSION_MINOR" = "1" ] - [ "$GHE_VERSION_PATCH" = "5" ] - - ghe_parse_remote_version "v2.1.5.ldapfix1" - [ "$GHE_VERSION_MAJOR" = "2" ] - [ "$GHE_VERSION_MINOR" = "1" ] - [ "$GHE_VERSION_PATCH" = "5" ] - - ghe_parse_remote_version "v2.1.5pre" - [ "$GHE_VERSION_MAJOR" = "2" ] - [ "$GHE_VERSION_MINOR" = "1" ] - [ "$GHE_VERSION_PATCH" = "5" ] + set -e + + ghe_parse_remote_version "v2.0.0" + [ "$GHE_VERSION_MAJOR" = "2" ] + [ "$GHE_VERSION_MINOR" = "0" ] + [ "$GHE_VERSION_PATCH" = "0" ] + + ghe_parse_remote_version "2.0.0" + [ "$GHE_VERSION_MAJOR" = "2" ] + [ "$GHE_VERSION_MINOR" = "0" ] + [ "$GHE_VERSION_PATCH" = "0" ] + + ghe_parse_remote_version "v2.1.5" + [ "$GHE_VERSION_MAJOR" = "2" ] + [ "$GHE_VERSION_MINOR" = "1" ] + [ "$GHE_VERSION_PATCH" = "5" ] + + ghe_parse_remote_version "v2.1.5.ldapfix1" + [ "$GHE_VERSION_MAJOR" = "2" ] + [ "$GHE_VERSION_MINOR" = "1" ] + [ "$GHE_VERSION_PATCH" = "5" ] + + ghe_parse_remote_version "v2.1.5pre" + [ "$GHE_VERSION_MAJOR" = "2" ] + [ "$GHE_VERSION_MINOR" = "1" ] + [ "$GHE_VERSION_PATCH" = "5" ] ) end_test diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index e69d1d37c..597b30efb 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -11,39 +11,39 @@ setup_test_data $GHE_REMOTE_DATA_USER_DIR begin_test "ghe-backup first snapshot" ( - set -e + set -e - # check that no current symlink exists yet - [ ! -d "$GHE_DATA_DIR/current" ] + # check that no current symlink exists yet + [ ! -d "$GHE_DATA_DIR/current" ] - # run it - ghe-backup -v + # run it + ghe-backup -v - verify_all_backedup_data + verify_all_backedup_data ) end_test begin_test "ghe-backup subsequent snapshot" ( - set -e + set -e - # wait a second for snapshot timestamp - sleep 1 + # wait a second for snapshot timestamp + sleep 1 - # check that no current symlink exists yet - [ -d "$GHE_DATA_DIR/current" ] + # check that no current symlink exists yet + [ -d "$GHE_DATA_DIR/current" ] - # grab the first snapshot number so we can compare after - first_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') + # grab the first snapshot number so we can compare after + first_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') - # run it - ghe-backup + # run it + ghe-backup - # check that current symlink points to new snapshot - this_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') - [ "$first_snapshot" != "$this_snapshot" ] + # check that current symlink points to new snapshot + this_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') + [ "$first_snapshot" != "$this_snapshot" ] - verify_all_backedup_data + verify_all_backedup_data ) end_test @@ -64,57 +64,57 @@ end_test begin_test "ghe-backup with relative data dir path" ( - set -e + set -e - # wait a second for snapshot timestamp - sleep 1 + # wait a second for snapshot timestamp + sleep 1 - # generate a timestamp - export GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" + # generate a timestamp + export GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" - # change working directory to the root directory - cd $ROOTDIR + # change working directory to the root directory + cd $ROOTDIR - # run it - GHE_DATA_DIR=$(echo $GHE_DATA_DIR | sed 's|'$ROOTDIR'/||') ghe-backup + # run it + GHE_DATA_DIR=$(echo $GHE_DATA_DIR | sed 's|'$ROOTDIR'/||') ghe-backup - # check that current symlink points to new snapshot - [ "$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.*-> //')" = "$GHE_SNAPSHOT_TIMESTAMP" ] + # check that current symlink points to new snapshot + [ "$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.*-> //')" = "$GHE_SNAPSHOT_TIMESTAMP" ] - verify_all_backedup_data + verify_all_backedup_data ) end_test begin_test "ghe-backup fails fast when old style run in progress" ( - set -e + set -e - ln -s 1 "$GHE_DATA_DIR/in-progress" - ! ghe-backup + ln -s 1 "$GHE_DATA_DIR/in-progress" + ! ghe-backup - unlink "$GHE_DATA_DIR/in-progress" + unlink "$GHE_DATA_DIR/in-progress" ) end_test begin_test "ghe-backup cleans up stale in-progress file" ( - set -e + set -e - echo "20150928T153353 99999" > "$GHE_DATA_DIR/in-progress" - ghe-backup + echo "20150928T153353 99999" > "$GHE_DATA_DIR/in-progress" + ghe-backup - [ ! -f "$GHE_DATA_DIR/in-progress" ] + [ ! -f "$GHE_DATA_DIR/in-progress" ] ) end_test begin_test "ghe-backup without management console password" ( - set -e + set -e - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "" - ghe-backup + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "" + ghe-backup - [ ! -f "$GHE_DATA_DIR/current/manage-password" ] + [ ! -f "$GHE_DATA_DIR/current/manage-password" ] ) end_test @@ -170,15 +170,15 @@ begin_test "ghe-backup stores version when not run from a clone" # If user is running the tests extracted from a release tarball, git clone will fail. if GIT_DIR="$ROOTDIR/.git" git rev-parse --is-inside-work-tree > /dev/null 2>&1; then - git clone "$ROOTDIR" "$tmpdir/backup-utils" - cd "$tmpdir/backup-utils" - rm -rf .git - ./bin/ghe-backup + git clone "$ROOTDIR" "$tmpdir/backup-utils" + cd "$tmpdir/backup-utils" + rm -rf .git + ./bin/ghe-backup - # Verify that ghe-backup wrote its version information to the host - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] + # Verify that ghe-backup wrote its version information to the host + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] else - echo ".git directory not found, skipping ghe-backup not from a clone test" + echo ".git directory not found, skipping ghe-backup not from a clone test" fi ) end_test diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index 2812e5c16..345774345 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -15,24 +15,24 @@ echo "fake-uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" begin_test "ghe-cluster-nodes should return both uuids for git-server" ( - set -e - setup_remote_cluster + set -e + setup_remote_cluster - output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" - echo "$output" - [ "git-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 git-server-08d94884-f519-11e6-88a1-0063a7c33551 " = "$output" ] + output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + echo "$output" + [ "git-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 git-server-08d94884-f519-11e6-88a1-0063a7c33551 " = "$output" ] ) end_test begin_test "ghe-cluster-nodes should return one uuid for a single node" ( - set -e + set -e - # Ensure not a cluster - rm -rf "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" + # Ensure not a cluster + rm -rf "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" - output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" - echo "$output" - [ "git-server-fake-uuid" = "$output" ] + output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + echo "$output" + [ "git-server-fake-uuid" = "$output" ] ) end_test diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 386a5ef51..55e2b8d3e 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -6,22 +6,22 @@ begin_test "ghe-host-check" ( - set -e - ghe-host-check + set -e + ghe-host-check - ghe-host-check | grep OK - ghe-host-check | grep localhost + ghe-host-check | grep OK + ghe-host-check | grep localhost ) end_test begin_test "ghe-host-check with host arg" ( - set -e - ghe-host-check example.com + set -e + ghe-host-check example.com - ghe-host-check example.com | grep OK - ghe-host-check example.com | grep example.com + ghe-host-check example.com | grep OK + ghe-host-check example.com | grep example.com ) end_test diff --git a/test/test-ghe-prune-snapshots.sh b/test/test-ghe-prune-snapshots.sh index 0194504c9..8a5c49481 100755 --- a/test/test-ghe-prune-snapshots.sh +++ b/test/test-ghe-prune-snapshots.sh @@ -22,11 +22,11 @@ generate_prune_files 3 begin_test "ghe-prune-snapshots using default GHE_NUM_SNAPSHOTS" ( - set -e - generate_prune_files 12 - ghe-prune-snapshots - [ $(ls -1d "$GHE_DATA_DIR"/[0-9]* | wc -l) -eq 10 ] - [ ! -d "$GHE_DATA_DIR/01" -a ! -d "$GHE_DATA_DIR/02" ] + set -e + generate_prune_files 12 + ghe-prune-snapshots + [ $(ls -1d "$GHE_DATA_DIR"/[0-9]* | wc -l) -eq 10 ] + [ ! -d "$GHE_DATA_DIR/01" -a ! -d "$GHE_DATA_DIR/02" ] ) end_test @@ -74,17 +74,17 @@ end_test begin_test "ghe-prune-snapshots incomplete snapshot pruning" ( - set -e + set -e - generate_prune_files 5 + generate_prune_files 5 - [ $(file_count_no_current) -eq 5 ] + [ $(file_count_no_current) -eq 5 ] - touch "$GHE_DATA_DIR/04/incomplete" + touch "$GHE_DATA_DIR/04/incomplete" - GHE_NUM_SNAPSHOTS=5 ghe-prune-snapshots + GHE_NUM_SNAPSHOTS=5 ghe-prune-snapshots - [ $(file_count_no_current) -eq 4 ] - [ ! -d "$GHE_DATA_DIR/04" ] + [ $(file_count_no_current) -eq 4 ] + [ ! -d "$GHE_DATA_DIR/04" ] ) end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index fa99a87f2..cf082f041 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -11,32 +11,32 @@ ln -s 1 "$GHE_DATA_DIR/current" begin_test "ghe-restore into configured vm" ( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi - # for debugging - cat "$TRASHDIR/restore-out" + # for debugging + cat "$TRASHDIR/restore-out" - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # Verify all the data we've restored is as expected - verify_all_restored_data + # Verify all the data we've restored is as expected + verify_all_restored_data ) end_test @@ -53,174 +53,174 @@ end_test begin_test "ghe-restore aborts without user verification" ( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST - # run ghe-restore and write output to file for asserting against - if echo "no" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - false # ghe-restore should have exited non-zero - fi + # run ghe-restore and write output to file for asserting against + if echo "no" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + false # ghe-restore should have exited non-zero + fi - grep -q "Restore aborted" "$TRASHDIR/restore-out" + grep -q "Restore aborted" "$TRASHDIR/restore-out" ) end_test begin_test "ghe-restore accepts user verification" ( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # run ghe-restore and write output to file for asserting against - if ! echo "yes" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - false # ghe-restore should have accepted the input - fi + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # run ghe-restore and write output to file for asserting against + if ! echo "yes" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + false # ghe-restore should have accepted the input + fi ) end_test begin_test "ghe-restore -c into unconfigured vm" ( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST - # leave unconfigured, enable maintenance mode and create required directories - setup_maintenance_mode + # leave unconfigured, enable maintenance mode and create required directories + setup_maintenance_mode - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - false - fi + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + false + fi - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # Verify all the data we've restored is as expected - verify_all_restored_data + # Verify all the data we've restored is as expected + verify_all_restored_data ) end_test begin_test "ghe-restore into unconfigured vm" ( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST - # leave unconfigured, enable maintenance mode and create required directories - setup_maintenance_mode + # leave unconfigured, enable maintenance mode and create required directories + setup_maintenance_mode - # ghe-restore into an unconfigured vm implies -c - ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 - cat "$TRASHDIR/restore-out" + # ghe-restore into an unconfigured vm implies -c + ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 + cat "$TRASHDIR/restore-out" - # verify no config run after restore on unconfigured instance - ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" + # verify no config run after restore on unconfigured instance + ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # Verify all the data we've restored is as expected - verify_all_restored_data + # Verify all the data we've restored is as expected + verify_all_restored_data ) end_test begin_test "ghe-restore with host arg" ( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST - # run it - output="$(ghe-restore -f localhost)" || false + # run it + output="$(ghe-restore -f localhost)" || false - # verify host arg overrides configured restore host - echo "$output" | grep -q 'Connect localhost:22 OK' + # verify host arg overrides configured restore host + echo "$output" | grep -q 'Connect localhost:22 OK' - # Verify all the data we've restored is as expected - verify_all_restored_data + # Verify all the data we've restored is as expected + verify_all_restored_data ) end_test begin_test "ghe-restore no host arg or configured restore host" ( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" - # unset configured restore host - unset GHE_RESTORE_HOST + # unset configured restore host + unset GHE_RESTORE_HOST - # verify running ghe-restore fails - ! ghe-restore -f + # verify running ghe-restore fails + ! ghe-restore -f ) end_test begin_test "ghe-restore with no pages backup" ( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" - # remove pages data - rm -rf "$GHE_DATA_DIR/1/pages" + # remove pages data + rm -rf "$GHE_DATA_DIR/1/pages" - # run it - ghe-restore -v -f localhost + # run it + ghe-restore -v -f localhost ) end_test begin_test "ghe-restore cluster backup to non-cluster appliance" ( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" - echo "cluster" > "$GHE_DATA_DIR/current/strategy" - ! output=$(ghe-restore -v -f localhost 2>&1) + echo "cluster" > "$GHE_DATA_DIR/current/strategy" + ! output=$(ghe-restore -v -f localhost 2>&1) - echo $output | grep -q "Snapshot from a GitHub Enterprise cluster cannot be restored" + echo $output | grep -q "Snapshot from a GitHub Enterprise cluster cannot be restored" ) end_test @@ -263,17 +263,17 @@ end_test begin_test "ghe-restore fails when restore to an active HA pair" ( - set -e + set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata - echo "rsync" > "$GHE_DATA_DIR/current/strategy" - touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + echo "rsync" > "$GHE_DATA_DIR/current/strategy" + touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" - ! output=$(ghe-restore -v -f localhost 2>&1) + ! output=$(ghe-restore -v -f localhost 2>&1) - echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." + echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." ) end_test diff --git a/test/test-ghe-ssh.sh b/test/test-ghe-ssh.sh index 2bdb274ca..3a74f7558 100755 --- a/test/test-ghe-ssh.sh +++ b/test/test-ghe-ssh.sh @@ -15,38 +15,38 @@ export GHE_DATA_DIR GHE_REMOTE_DATA_DIR begin_test "ghe-ssh simple command works" ( - set -e + set -e - output="$(ghe-ssh "$GHE_HOSTNAME" "echo hello there")" - [ "hello there" = "$output" ] + output="$(ghe-ssh "$GHE_HOSTNAME" "echo hello there")" + [ "hello there" = "$output" ] ) end_test begin_test "ghe-ssh complex command works" ( - set -e + set -e - comm=" - echo hello - echo there - " + comm=" + echo hello + echo there + " - output="$(echo "$comm" | ghe-ssh "$GHE_HOSTNAME" /bin/sh)" - [ $(echo "$output" | wc -l) -eq 2 ] + output="$(echo "$comm" | ghe-ssh "$GHE_HOSTNAME" /bin/sh)" + [ $(echo "$output" | wc -l) -eq 2 ] ) end_test begin_test "ghe-ssh when complex command given to simple form" ( - set -e - - ! ghe-ssh "$GHE_HOSTNAME" "echo hello | wc -l" - ! ghe-ssh "$GHE_HOSTNAME" "echo hello ; wc -l" - ! ghe-ssh "$GHE_HOSTNAME" " - echo hello - echo goodbye - " + set -e + + ! ghe-ssh "$GHE_HOSTNAME" "echo hello | wc -l" + ! ghe-ssh "$GHE_HOSTNAME" "echo hello ; wc -l" + ! ghe-ssh "$GHE_HOSTNAME" " + echo hello + echo goodbye + " ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index 9597458c5..cc68c9a0b 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -6,9 +6,9 @@ # # begin_test "the thing" # ( -# set -e -# echo "hello" -# false +# set -e +# echo "hello" +# false # ) # end_test # @@ -61,20 +61,21 @@ failures=0 # this runs at process exit atexit () { - res=$? - - # cleanup injected test key - shared_path=$(dirname $(which ghe-detect-leaked-ssh-keys)) - sed -i.bak '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" - rm -f "$shared_path/ghe-ssh-leaked-host-keys-list.txt.bak" - - [ -z "$KEEPTRASH" ] && rm -rf "$TRASHDIR" - if [ $failures -gt 0 ] - then exit 1 - elif [ $res -ne 0 ] - then exit $res - else exit 0 - fi + res=$? + + # cleanup injected test key + shared_path=$(dirname $(which ghe-detect-leaked-ssh-keys)) + sed -i.bak '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" + rm -f "$shared_path/ghe-ssh-leaked-host-keys-list.txt.bak" + + [ -z "$KEEPTRASH" ] && rm -rf "$TRASHDIR" + if [ $failures -gt 0 ]; then + exit 1 + elif [ $res -ne 0 ]; then + exit $res + else + exit 0 + fi } # create the trash dir and data dirs @@ -86,21 +87,21 @@ cd "$TRASHDIR" # much everything. You can pass a version number in the first argument to test # with different remote versions. setup_remote_metadata () { - mkdir -p "$GHE_REMOTE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" - mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" + mkdir -p "$GHE_REMOTE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" + mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" + mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" } setup_remote_metadata setup_remote_license () { - mkdir -p "$(dirname "$GHE_REMOTE_LICENSE_FILE")" - echo "fake license data" > "$GHE_REMOTE_LICENSE_FILE" + mkdir -p "$(dirname "$GHE_REMOTE_LICENSE_FILE")" + echo "fake license data" > "$GHE_REMOTE_LICENSE_FILE" } setup_remote_license setup_remote_cluster () { - mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" - touch "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" + mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" + touch "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" } # Put the necessary files in place to mimic a configured, or not, instance into @@ -125,19 +126,19 @@ setup_maintenance_mode () { # Mark the beginning of a test. A subshell should immediately follow this # statement. begin_test () { - test_status=$? - [ -n "$test_description" ] && end_test $test_status - unset test_status + test_status=$? + [ -n "$test_description" ] && end_test $test_status + unset test_status - tests=$(( tests + 1 )) - test_description="$1" + tests=$(( tests + 1 )) + test_description="$1" - exec 3>&1 4>&2 - out="$TRASHDIR/out" - exec 1>"$out" 2>&1 + exec 3>&1 4>&2 + out="$TRASHDIR/out" + exec 1>"$out" 2>&1 - # allow the subshell to exit non-zero without exiting this process - set -x +e + # allow the subshell to exit non-zero without exiting this process + set -x +e } report_failure () { @@ -146,28 +147,28 @@ report_failure () { failures=$(( failures + 1 )) printf "test: %-73s $msg\\n" "$desc ..." ( - sed 's/^/ /' <"$TRASHDIR/out" | - grep -a -v -e '^\+ end_test' -e '^+ set +x' <"$TRASHDIR/out" | - sed 's/[+] test_status=/test failed. last command exited with /' | - sed 's/^/ /' + sed 's/^/ /' <"$TRASHDIR/out" | + grep -a -v -e '^\+ end_test' -e '^+ set +x' <"$TRASHDIR/out" | + sed 's/[+] test_status=/test failed. last command exited with /' | + sed 's/^/ /' ) 1>&2 } # Mark the end of a test. end_test () { - test_status="${1:-$?}" - set +x -e - exec 1>&3 2>&4 - - if [ "$test_status" -eq 0 ]; then - printf "test: %-60s OK\\n" "$test_description ..." - elif [ "$test_status" -eq 254 ]; then - printf "test: %-60s SKIPPED\\n" "$test_description ..." - else - report_failure "FAILED" "$test_description ..." - fi - - unset test_description + test_status="${1:-$?}" + set +x -e + exec 1>&3 2>&4 + + if [ "$test_status" -eq 0 ]; then + printf "test: %-60s OK\\n" "$test_description ..." + elif [ "$test_status" -eq 254 ]; then + printf "test: %-60s SKIPPED\\n" "$test_description ..." + else + report_failure "FAILED" "$test_description ..." + fi + + unset test_description } skip_test() { From 652e8ab05c0b63f32bdc59da01d1c69f529cc117 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 14 Mar 2018 18:59:00 +0000 Subject: [PATCH 0498/2421] Ensure a single ghe-gc-enable failure doesn't stop cleanup --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- share/github-backup-utils/ghe-restore-repositories | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 29060d021..1b16d468e 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -86,7 +86,7 @@ cleanup() { # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port + ghe-gc-enable $ssh_config_file_opt $hostname:$port || true done rm -rf $tempdir diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 4a8da6647..efdf9faf6 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -55,7 +55,7 @@ mkdir -p "$backup_dir" cleanup() { # Enable remote maintenance operations for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port + ghe-gc-enable $ssh_config_file_opt $hostname:$port || true done ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 64d34b289..4831c399a 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -58,7 +58,7 @@ fi cleanup() { for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port + ghe-gc-enable $ssh_config_file_opt $hostname:$port || true done ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir rm -rf $tempdir From 36a3c4b80e1ffcbed35d1441495f2b985b5035bc Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 15 Mar 2018 11:04:09 +0000 Subject: [PATCH 0499/2421] Use non-racy method to testing leaked SSH keys --- test/test-ghe-backup.sh | 7 +++---- test/test-ghe-restore.sh | 3 +-- test/testlib.sh | 5 ----- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index e69d1d37c..c7711d428 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -187,16 +187,15 @@ begin_test "ghe-backup with leaked SSH host key detection for current backup" ( set -e - SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) - # Inject the fingerprint into the blacklist - echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" - # Re-link ghe-export-ssh-keys to generate a fake ssh unlink "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" cd "$ROOTDIR/test/bin" ln -s ghe-gen-fake-ssh-tar ghe-export-ssh-host-keys cd - + # Inject the fingerprint into the blacklist + export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" + # Run it output=$(ghe-backup -v) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index fa99a87f2..4a7058acd 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -245,9 +245,8 @@ EOF # Add custom key to tar file tar -cf "$GHE_DATA_DIR/current/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub - SHARED_UTILS_PATH=$(dirname $(which ghe-detect-leaked-ssh-keys)) # Inject the fingerprint into the blacklist - echo 98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60 >> "$SHARED_UTILS_PATH/ghe-ssh-leaked-host-keys-list.txt" + export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" # Running it and ignoring the actual script status but testing that the ssh host detection still happens output=$(ghe-restore -v -f localhost) || true diff --git a/test/testlib.sh b/test/testlib.sh index 9597458c5..36d36124b 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -63,11 +63,6 @@ failures=0 atexit () { res=$? - # cleanup injected test key - shared_path=$(dirname $(which ghe-detect-leaked-ssh-keys)) - sed -i.bak '/98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60/d' "$shared_path/ghe-ssh-leaked-host-keys-list.txt" - rm -f "$shared_path/ghe-ssh-leaked-host-keys-list.txt.bak" - [ -z "$KEEPTRASH" ] && rm -rf "$TRASHDIR" if [ $failures -gt 0 ] then exit 1 From 5c5e850755f81f1aca31df7deae72fa629b5a0f2 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 15 Mar 2018 18:06:55 +0000 Subject: [PATCH 0500/2421] Unify test coverage --- test/testlib.sh | 86 +++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 52 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index 36d36124b..4ba6f277a 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -305,6 +305,34 @@ setup_test_data () { fi } +# A unified method to check everything backed up or restored during testing. +# Everything tested here should pass regardless of whether we're testing a backup +# or a restore. +verify_common_data() { + # verify all repository data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/current/repositories" + + # verify all pages data was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/pages" "$GHE_DATA_DIR/current/pages" + + # verify all git hooks tarballs were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" + + # verify the extracted environments were not transferred + ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" + + # verify the extracted repositories were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" + + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" "$GHE_DATA_DIR/current/es-scan-complete" + fi +} + # A unified method to check everything backed up when performing a full backup # during testing. verify_all_backedup_data() { @@ -323,16 +351,6 @@ verify_all_backedup_data() { # check that settings were backed up [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] - # check that license was backed up - [ "$(cat "$GHE_DATA_DIR/current/enterprise.ghl")" = "fake license data" ] - - # check that repositories directory was created - [ -d "$GHE_DATA_DIR/current/repositories" ] - - # check that pages data was backed up - [ -f "$GHE_DATA_DIR/current/pages/4/c8/1e/72/2/legacy/index.html" ] - [ -f "$GHE_DATA_DIR/current/pages/4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" ] - # check that mysql data was backed up [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] @@ -345,38 +363,20 @@ verify_all_backedup_data() { # check that ssh host key was backed up [ "$(cat "$GHE_DATA_DIR/current/ssh-host-keys.tar")" = "fake ghe-export-ssh-host-keys data" ] - # verify all repository data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/repositories" "$GHE_DATA_DIR/current/repositories" - - # verify all pages data was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/pages" "$GHE_DATA_DIR/current/pages" - # verify all ES data was transferred from live directory diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" - # verify manage-password file was backed up under v2.x VMs + # verify manage-password file was backed up [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] - # verify all git hooks tarballs were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" - - # verify the extracted environments were not transferred - ! diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" "$GHE_DATA_DIR/current/git-hooks/environments" - - # verify the extracted repositories were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - - # verify the UUID was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" - # check that ca certificates were backed up [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] - # verify the audit log migration sentinel file has been created - [ -f "$GHE_DATA_DIR/current/es-scan-complete" ] - # verify that ghe-backup wrote its version information to the host [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] + + # verify common data + verify_common_data } # A unified method to check everything restored when performing a full restore @@ -385,8 +385,6 @@ verify_all_restored_data() { set -e # verify all import scripts were run - grep -q "4/c8/1e/72/2/legacy/index.html" "$TRASHDIR/restore-out" - grep -q "4/c1/6a/53/31/dd3a9a0faa88c714ef2dd638b67587f92f109f96/index.html" "$TRASHDIR/restore-out" grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" @@ -396,28 +394,12 @@ verify_all_restored_data() { # configured. ! grep -q "fake ghe-export-settings data" "$TRASHDIR/restore-out" - # verify all repository data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/repositories" "$GHE_REMOTE_DATA_USER_DIR/repositories" - - # verify all pages data was transferred to the restore location - diff -ru "$GHE_DATA_DIR/current/pages" "$GHE_REMOTE_DATA_USER_DIR/pages" - # verify all ES data was transferred from live directory to the temporary restore directory diff -ru --exclude="*.gz" "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" # verify management console password was *not* restored ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" - # verify all git hooks data was transferred - diff -ru "$GHE_DATA_DIR/current/git-hooks/environments/tarballs" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - ! diff -ru "$GHE_DATA_DIR/current/git-hooks/environments" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments" - diff -ru "$GHE_DATA_DIR/current/git-hooks/repos" "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" - - # verify the UUID was transferred - diff -ru "$GHE_DATA_DIR/current/uuid" "$GHE_REMOTE_DATA_USER_DIR/common/uuid" - - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ] - fi + # verify common data + verify_common_data } From 6e2d1420b8700ce464ef4594d6aac274719b807a Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 16 Mar 2018 16:48:20 +0000 Subject: [PATCH 0501/2421] Iterate over servers returned --- share/github-backup-utils/ghe-backup-repositories | 10 ++++++---- share/github-backup-utils/ghe-backup-storage | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 1b16d468e..bbc78e2cf 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -119,13 +119,15 @@ ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-routes \ | while read route; do ghe_debug "Got backup route $route" if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - server=$(echo $route | cut -d ' ' -f2-) + servers=$(echo $route | cut -d ' ' -f2-) else - server=$host + servers=$host fi network_path=$(echo $route | cut -d ' ' -f1) - ghe_debug "Adding $network_path to $tempdir/$server.rsync" - echo "$network_path" >> $tempdir/$server.rsync + for server in $servers; do + ghe_debug "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync + done done bm_end "$(basename $0) - Calculating Sync Routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index efdf9faf6..3be968aaa 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -88,13 +88,15 @@ ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-backup-routes \ | while read route; do ghe_debug "Got backup route $route" if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - server=$(echo $route | cut -d ' ' -f2-) + servers=$(echo $route | cut -d ' ' -f2-) else - server=$host + servers=$host fi network_path=$(echo $route | cut -d ' ' -f1) - ghe_debug "Adding $network_path to $tempdir/$server.rsync" - echo "$network_path" >> $tempdir/$server.rsync + for server in $servers; do + ghe_debug "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync + done done bm_end "$(basename $0) - Calculating sync routes" From 16ee232dade65f0ba349afdaac43c01f73b82d26 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 16 Mar 2018 16:51:43 +0000 Subject: [PATCH 0502/2421] Add backup test for cluster ... and update dependent tests and supporting scripts --- test/bin/dgit-cluster-backup-routes | 8 +++--- test/bin/ghe-cluster-each | 6 ++--- test/bin/storage-cluster-backup-routes | 6 ++--- test/test-ghe-backup.sh | 37 ++++++++++++++++++++++++++ test/test-ghe-cluster-nodes.sh | 2 +- test/testlib.sh | 35 +++++++++++++++++------- 6 files changed, 73 insertions(+), 21 deletions(-) diff --git a/test/bin/dgit-cluster-backup-routes b/test/bin/dgit-cluster-backup-routes index 85155f355..62b42a86b 100755 --- a/test/bin/dgit-cluster-backup-routes +++ b/test/bin/dgit-cluster-backup-routes @@ -4,8 +4,8 @@ # to assert that the command was executed. set -e cat < "$TRASHDIR/backup-out" 2>&1; then + cat "$TRASHDIR/backup-out" + : ghe-restore should have exited successfully + false + fi + + cat "$TRASHDIR/backup-out" + + # verify data was copied from multiple nodes + # repositories + grep -q "repositories from git-server-fake-uuid" "$TRASHDIR/backup-out" + grep -q "repositories from git-server-fake-uuid1" "$TRASHDIR/backup-out" + grep -q "repositories from git-server-fake-uuid2" "$TRASHDIR/backup-out" + + # storage + grep -q "objects from storage-server-fake-uuid" "$TRASHDIR/backup-out" + grep -q "objects from storage-server-fake-uuid1" "$TRASHDIR/backup-out" + grep -q "objects from storage-server-fake-uuid2" "$TRASHDIR/backup-out" + + # pages + grep -q "Starting backup for host: pages-server-fake-uuid" "$TRASHDIR/backup-out" + grep -q "Starting backup for host: pages-server-fake-uuid1" "$TRASHDIR/backup-out" + grep -q "Starting backup for host: pages-server-fake-uuid2" "$TRASHDIR/backup-out" + + # verify cluster.conf backed up + [ -f "$GHE_DATA_DIR/current/cluster.conf" ] + grep -q "fake cluster config" "$GHE_DATA_DIR/current/cluster.conf" + + verify_all_backedup_data +) +end_test diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index 2812e5c16..e1c0f163a 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -20,7 +20,7 @@ begin_test "ghe-cluster-nodes should return both uuids for git-server" output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" echo "$output" - [ "git-server-05cbcd42-f519-11e6-b6c9-002bd51dfa77 git-server-08d94884-f519-11e6-88a1-0063a7c33551 " = "$output" ] + [ "git-server-fake-uuid git-server-fake-uuid1 git-server-fake-uuid2 " = "$output" ] ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index 4ba6f277a..a01ea8f72 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -96,6 +96,7 @@ setup_remote_license setup_remote_cluster () { mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" touch "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" + echo "fake cluster config" > "$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" } # Put the necessary files in place to mimic a configured, or not, instance into @@ -324,12 +325,18 @@ verify_common_data() { # verify the extracted repositories were transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - # verify the UUID was transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" - - # verify the audit log migration sentinel file has been created on 2.9 and above - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then - diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" "$GHE_DATA_DIR/current/es-scan-complete" + # tests that differ for cluster and single node backups and restores + if [ -f "$GHE_DATA_DIR/current/cluster.conf" ]; then + [ -f "$GHE_DATA_DIR/current/cluster.conf" ] + grep -q "fake cluster config" "$GHE_DATA_DIR/current/cluster.conf" + else + # verify the UUID was transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" + + # verify the audit log migration sentinel file has been created on 2.9 and above + if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 9 ]; then + diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" "$GHE_DATA_DIR/current/es-scan-complete" + fi fi } @@ -346,7 +353,6 @@ verify_all_backedup_data() { # check that the strategy file was written [ -f "$GHE_DATA_DIR/current/strategy" ] - [ "$(cat "$GHE_DATA_DIR/current/strategy")" = "rsync" ] # check that settings were backed up [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] @@ -363,9 +369,6 @@ verify_all_backedup_data() { # check that ssh host key was backed up [ "$(cat "$GHE_DATA_DIR/current/ssh-host-keys.tar")" = "fake ghe-export-ssh-host-keys data" ] - # verify all ES data was transferred from live directory - diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" - # verify manage-password file was backed up [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] @@ -375,6 +378,18 @@ verify_all_backedup_data() { # verify that ghe-backup wrote its version information to the host [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] + # tests that differ for cluster and single node backups + if [ -f "$GHE_DATA_DIR/current/cluster.conf" ]; then + # verify strategy used + [ "$(cat "$GHE_DATA_DIR/current/strategy")" = "cluster" ] + else + # verify strategy used + [ "$(cat "$GHE_DATA_DIR/current/strategy")" = "rsync" ] + + # verify all ES data was transferred from live directory - not for cluster backups + diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch" + fi + # verify common data verify_common_data } From 465d752254c93888eee04c88e6d8b9a0e7ffd19f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 16 Mar 2018 16:52:11 +0000 Subject: [PATCH 0503/2421] Better handle -F arg --- test/bin/ssh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/bin/ssh b/test/bin/ssh index 4adb77f05..1e44a725e 100755 --- a/test/bin/ssh +++ b/test/bin/ssh @@ -15,6 +15,9 @@ while true; do -q) shift ;; + -F) + shift 2 + ;; --) shift break @@ -36,9 +39,6 @@ cd "$(dirname "$0")"/.. # Scrub sudo commands from command arguments. sh="$(echo "$@" | sed 's/sudo -u [a-z]* //g' | sed 's/sudo //g')" -# Scrub SSH -F argument passed to rsync -sh="$(echo "$sh" | sed 's/^\-F \/.* \(rsync\)/\1/g')" - # Scrub SSH -F argument for ghe-ssh commands sh="$(echo "$sh" | sed 's/^\/.* --//g')" From ba19645f9e2d42ce227c28b8c3b50691f5c88f28 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Mar 2018 12:31:30 +0000 Subject: [PATCH 0504/2421] Reset before running cluster-specific test --- test/test-ghe-backup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 06f434bae..6e5fb058c 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -251,7 +251,11 @@ begin_test "ghe-backup exits early on unsupported version" ) end_test -begin_test "ghe-backup backup cluster" +# Reset data for sub-subsequent tests +rm -rf $GHE_REMOTE_DATA_USER_DIR +setup_test_data $GHE_REMOTE_DATA_USER_DIR + +begin_test "ghe-backup cluster" ( set -e setup_remote_cluster From e62383140b5a12bb5d017a68926fd914e986904e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Mar 2018 13:09:40 +0000 Subject: [PATCH 0505/2421] Split version parsing into reusable function --- share/github-backup-utils/ghe-backup-config | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 16025aed6..5d57ab282 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -233,6 +233,15 @@ ghe_remote_version_required () { true } +# Parse a version string into major, minor and patch parts and echo. +ghe_parse_version() { + version_major=$(echo "${1#v}" | cut -f 1 -d .) + version_minor=$(echo "$1" | cut -f 2 -d .) + version_patch=$(echo "$1" | cut -f 3 -d .) + version_patch=${version_patch%%[a-zA-Z]*} + + echo "$version_major $version_minor $version_patch" +} # Parse major, minor, and patch parts of the remote appliance version and store # in GHE_VERSION_MAJOR, GHE_VERSION_MINOR, and GHE_VERSION_PATCH variables. All # parts are numeric. This is called automatically from @@ -241,11 +250,7 @@ ghe_remote_version_required () { # Scripts use these variables to alter behavior based on what's supported on the # appliance version. ghe_parse_remote_version () { - GHE_VERSION_MAJOR=$(echo "${1#v}" | cut -f 1 -d .) - GHE_VERSION_MINOR=$(echo "$1" | cut -f 2 -d .) - GHE_VERSION_PATCH=$(echo "$1" | cut -f 3 -d .) - GHE_VERSION_PATCH=${GHE_VERSION_PATCH%%[a-zA-Z]*} - + read -r GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH <<<$(ghe_parse_version $1) export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH } From e3c131bbf35be5b503f035e0696fec878ffd5684 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 17 Mar 2018 13:11:02 +0000 Subject: [PATCH 0506/2421] Limit support to three most recent releases of GHE We need to be quite specfic the first time as some of the required functionality is only available on later patch releases. --- bin/ghe-host-check | 21 ++++++++++++++++----- script/cibuild | 2 +- test/test-ghe-host-check.sh | 7 ++++++- test/testlib.sh | 2 +- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index d99a929bc..5224d8aac 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -90,11 +90,22 @@ if [ -z "$version" ]; then exit 2 fi -# backup-utils 2.13 onwards only has support for 2.11 and newer versions. -if ! echo "v$version" | grep -Eq "v2\.1[1-9]|v[3-9]"; then - echo "Error: old release of GitHub Enterprise detected." 1>&2 - echo "Backup Utilities $BACKUP_UTILS_VERSION requires GitHub Enterprise v2.11 or newer." 1>&2 - echo "Please update your GitHub Enterprise appliance or use backup-utils v2.11.3." 1>&2 +# backup-utils 2.13 onwards limits support to the current and previous two releases +# of GitHub Enterprise. +supported_minimum_versions="v2.11.15, v2.12.9, v2.13.0" + +read -r ghe_version_major ghe_version_minor ghe_version_patch <<<$(ghe_parse_version $version) +if ver=$(echo "$supported_minimum_versions" | tr ", " "\n" | grep -Eo $ghe_version_major\.$ghe_version_minor\..+); then + read -r _ _ patch <<<$(ghe_parse_version $ver) + if [ "$ghe_version_patch" -ge $patch ]; then + supported=1 + fi +fi + +if [ -z "$supported" ]; then + echo "Error: unsupported release of GitHub Enterprise detected." 1>&2 + echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise $supported_minimum_versions or newer patch revisions." 1>&2 + echo "Please update your GitHub Enterprise appliance or use an older version of Backup Utilities." 1>&2 exit 1 fi diff --git a/script/cibuild b/script/cibuild index 843e45649..d0070da4e 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,7 +7,7 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.11.0 + 2.11.15 " # Enable verbose logging of ssh commands diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 386a5ef51..2f4345294 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -53,7 +53,12 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise versions" set -e ! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=2.11.14 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=2.12.8 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.11.15 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.12.9 ghe-host-check GHE_TEST_REMOTE_VERSION=2.13.999 ghe-host-check - GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.13.999gm1 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index a01ea8f72..6e6caa3b3 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.11.0} +: ${GHE_TEST_REMOTE_VERSION:=2.11.15} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 1368a57cfc17fb66189cd95afa3c103201173f37 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sun, 18 Mar 2018 12:03:33 +0000 Subject: [PATCH 0507/2421] Revert "Iterate over servers returned" This reverts commit 6e2d1420b8700ce464ef4594d6aac274719b807a. --- share/github-backup-utils/ghe-backup-repositories | 10 ++++------ share/github-backup-utils/ghe-backup-storage | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index bbc78e2cf..1b16d468e 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -119,15 +119,13 @@ ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-routes \ | while read route; do ghe_debug "Got backup route $route" if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - servers=$(echo $route | cut -d ' ' -f2-) + server=$(echo $route | cut -d ' ' -f2-) else - servers=$host + server=$host fi network_path=$(echo $route | cut -d ' ' -f1) - for server in $servers; do - ghe_debug "Adding $network_path to $tempdir/$server.rsync" - echo "$network_path" >> $tempdir/$server.rsync - done + ghe_debug "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync done bm_end "$(basename $0) - Calculating Sync Routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 3be968aaa..efdf9faf6 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -88,15 +88,13 @@ ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-backup-routes \ | while read route; do ghe_debug "Got backup route $route" if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - servers=$(echo $route | cut -d ' ' -f2-) + server=$(echo $route | cut -d ' ' -f2-) else - servers=$host + server=$host fi network_path=$(echo $route | cut -d ' ' -f1) - for server in $servers; do - ghe_debug "Adding $network_path to $tempdir/$server.rsync" - echo "$network_path" >> $tempdir/$server.rsync - done + ghe_debug "Adding $network_path to $tempdir/$server.rsync" + echo "$network_path" >> $tempdir/$server.rsync done bm_end "$(basename $0) - Calculating sync routes" From ace6a8fae9e41dda2fac2ae0533ceebe70594c3b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sun, 18 Mar 2018 12:07:13 +0000 Subject: [PATCH 0508/2421] Correct backup routes output --- test/bin/dgit-cluster-backup-routes | 8 ++++---- test/bin/storage-cluster-backup-routes | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/bin/dgit-cluster-backup-routes b/test/bin/dgit-cluster-backup-routes index 62b42a86b..cef8c7d27 100755 --- a/test/bin/dgit-cluster-backup-routes +++ b/test/bin/dgit-cluster-backup-routes @@ -4,8 +4,8 @@ # to assert that the command was executed. set -e cat < Date: Mon, 19 Mar 2018 09:51:17 +0000 Subject: [PATCH 0509/2421] Ensure rsync strategy used for HA backup --- share/github-backup-utils/ghe-backup-strategy | 2 +- test/test-ghe-backup.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-strategy b/share/github-backup-utils/ghe-backup-strategy index 8f2055627..f43918535 100755 --- a/share/github-backup-utils/ghe-backup-strategy +++ b/share/github-backup-utils/ghe-backup-strategy @@ -12,7 +12,7 @@ set -e . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ ! -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then echo "cluster" else echo "rsync" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6e5fb058c..6289ba010 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -251,6 +251,16 @@ begin_test "ghe-backup exits early on unsupported version" ) end_test +begin_test "ghe-backup-strategy returns rsync for HA backup" +( + set -e + touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + output="$(ghe-backup-strategy)" + rm "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + [ "$output" = "rsync" ] +) +end_test + # Reset data for sub-subsequent tests rm -rf $GHE_REMOTE_DATA_USER_DIR setup_test_data $GHE_REMOTE_DATA_USER_DIR From bad1c340d54e6a75f623cc733a4165d158b5945e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 19 Mar 2018 16:37:02 +0000 Subject: [PATCH 0510/2421] Add fake finalize command and switch symlinks --- test/bin/dgit-cluster-restore-finalize | 2 +- test/bin/dpages-cluster-restore-finalize | 2 +- test/bin/ghe-fake-finalize-command | 5 +++++ test/bin/gist-cluster-restore-finalize | 2 +- test/bin/storage-cluster-restore-finalize | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) create mode 100755 test/bin/ghe-fake-finalize-command diff --git a/test/bin/dgit-cluster-restore-finalize b/test/bin/dgit-cluster-restore-finalize index a5ed742f4..9a9fbee29 120000 --- a/test/bin/dgit-cluster-restore-finalize +++ b/test/bin/dgit-cluster-restore-finalize @@ -1 +1 @@ -ghe-fake-true \ No newline at end of file +ghe-fake-finalize-command \ No newline at end of file diff --git a/test/bin/dpages-cluster-restore-finalize b/test/bin/dpages-cluster-restore-finalize index a5ed742f4..9a9fbee29 120000 --- a/test/bin/dpages-cluster-restore-finalize +++ b/test/bin/dpages-cluster-restore-finalize @@ -1 +1 @@ -ghe-fake-true \ No newline at end of file +ghe-fake-finalize-command \ No newline at end of file diff --git a/test/bin/ghe-fake-finalize-command b/test/bin/ghe-fake-finalize-command new file mode 100755 index 000000000..22f266be2 --- /dev/null +++ b/test/bin/ghe-fake-finalize-command @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Emulates a remote GitHub restore finalize command. Each of the *-finalize utilities +# that are run on the remote side have corresponding commands in this directory +# that symlink to this file. The command just writes a simple success message. +echo "$(basename $0) OK" diff --git a/test/bin/gist-cluster-restore-finalize b/test/bin/gist-cluster-restore-finalize index a5ed742f4..9a9fbee29 120000 --- a/test/bin/gist-cluster-restore-finalize +++ b/test/bin/gist-cluster-restore-finalize @@ -1 +1 @@ -ghe-fake-true \ No newline at end of file +ghe-fake-finalize-command \ No newline at end of file diff --git a/test/bin/storage-cluster-restore-finalize b/test/bin/storage-cluster-restore-finalize index a5ed742f4..9a9fbee29 120000 --- a/test/bin/storage-cluster-restore-finalize +++ b/test/bin/storage-cluster-restore-finalize @@ -1 +1 @@ -ghe-fake-true \ No newline at end of file +ghe-fake-finalize-command \ No newline at end of file From d853efb1c4ba6e9e5387f3b5f355dbfd1db7dbd5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 19 Mar 2018 17:12:58 +0000 Subject: [PATCH 0511/2421] Use testable paths --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index eac53bf86..536e51e23 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -348,9 +348,9 @@ else # This will make sure that Git over SSH host keys (babeld) are # copied to all the cluster nodes so babeld uses the same keys. echo "Restoring Git over SSH host keys ..." - ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C /data/user/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 - ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld /data/user/common/ssh_host_*" 1>&3 - echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else /usr/local/bin/ghe-cluster-config-update -s; fi" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 + echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi From 3c2fc55cd98a29df7a2dbc7aa231365fa9aecbcb Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 19 Mar 2018 17:20:09 +0000 Subject: [PATCH 0512/2421] Use actual tarball for testing This is needed so we can test cluster restores. --- test/bin/ghe-export-ssh-host-keys | 5 ++++- test/test-ghe-backup.sh | 11 ++++------- test/testlib.sh | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) mode change 120000 => 100755 test/bin/ghe-export-ssh-host-keys diff --git a/test/bin/ghe-export-ssh-host-keys b/test/bin/ghe-export-ssh-host-keys deleted file mode 120000 index a772e4ad9..000000000 --- a/test/bin/ghe-export-ssh-host-keys +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-export-command \ No newline at end of file diff --git a/test/bin/ghe-export-ssh-host-keys b/test/bin/ghe-export-ssh-host-keys new file mode 100755 index 000000000..919af4767 --- /dev/null +++ b/test/bin/ghe-export-ssh-host-keys @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +echo "fake ghe-export-ssh-host-keys data" > tmp/ssh-host-keys +tar -C tmp -cf - ssh-host-keys +rm -f tmp/ssh-host-keys diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6289ba010..14c1f1ca7 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -187,9 +187,9 @@ begin_test "ghe-backup with leaked SSH host key detection for current backup" ( set -e - # Re-link ghe-export-ssh-keys to generate a fake ssh - unlink "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" + # Rename ghe-export-ssh-keys to generate a fake ssh cd "$ROOTDIR/test/bin" + mv "ghe-export-ssh-host-keys" "ghe-export-ssh-host-keys.orig" ln -s ghe-gen-fake-ssh-tar ghe-export-ssh-host-keys cd - @@ -199,11 +199,8 @@ begin_test "ghe-backup with leaked SSH host key detection for current backup" # Run it output=$(ghe-backup -v) - # Set the export ssh link back - unlink "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" - cd "$ROOTDIR/test/bin" - ln -s ghe-fake-export-command ghe-export-ssh-host-keys - cd - + # Set the export ssh back + mv "$ROOTDIR/test/bin/ghe-export-ssh-host-keys.orig" "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" # Test the output for leaked key detection echo $output| grep "The current backup contains leaked SSH host keys" diff --git a/test/testlib.sh b/test/testlib.sh index 6e6caa3b3..4c950a7b7 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -296,7 +296,8 @@ setup_test_data () { echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" echo "fake ghe-export-redis data" > "$loc/redis.rdb" echo "fake ghe-export-authorized-keys data" > "$loc/authorized-keys.json" - echo "fake ghe-export-ssh-host-keys data" > "$loc/ssh-host-keys.tar" + echo "fake ghe-export-ssh-host-keys data" > "$TRASHDIR/ssh-host-keys" + tar -C $TRASHDIR -cf "$loc/ssh-host-keys.tar" ssh-host-keys echo "fake ghe-export-settings data" > "$loc/settings.json" echo "fake ghe-export-ssl-ca-certificates data" > "$loc/ssl-ca-certificates.tar" echo "fake license data" > "$loc/enterprise.ghl" @@ -367,7 +368,7 @@ verify_all_backedup_data() { [ "$(cat "$GHE_DATA_DIR/current/authorized-keys.json")" = "fake ghe-export-authorized-keys data" ] # check that ssh host key was backed up - [ "$(cat "$GHE_DATA_DIR/current/ssh-host-keys.tar")" = "fake ghe-export-ssh-host-keys data" ] + [ "$(tar xfO "$GHE_DATA_DIR/current/ssh-host-keys.tar" ssh-host-keys)" = "fake ghe-export-ssh-host-keys data" ] # verify manage-password file was backed up [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] From f8a72b4ba04efeff548736c366374a54765120b5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 19 Mar 2018 17:20:48 +0000 Subject: [PATCH 0513/2421] Add cluster restore test --- test/bin/dgit-cluster-restore-routes | 4 +- test/bin/dpages-cluster-restore-routes | 2 +- test/bin/ghe-cluster-config-update | 6 +++ test/bin/gist-cluster-restore-routes | 2 +- test/bin/storage-cluster-restore-routes | 2 +- test/test-ghe-restore.sh | 65 +++++++++++++++++++++++++ test/testlib.sh | 19 ++++---- 7 files changed, 86 insertions(+), 14 deletions(-) create mode 100755 test/bin/ghe-cluster-config-update diff --git a/test/bin/dgit-cluster-restore-routes b/test/bin/dgit-cluster-restore-routes index 65b4fc93f..60cc70b8e 100755 --- a/test/bin/dgit-cluster-restore-routes +++ b/test/bin/dgit-cluster-restore-routes @@ -4,6 +4,6 @@ # to assert that the command was executed. set -e cat < "$GHE_DATA_DIR/current/strategy" + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + # for debugging + cat "$TRASHDIR/restore-out" + + # verify data was copied from multiple nodes + # repositories + grep -q "networks to git-server-fake-uuid" "$TRASHDIR/restore-out" + grep -q "networks to git-server-fake-uuid1" "$TRASHDIR/restore-out" + grep -q "networks to git-server-fake-uuid2" "$TRASHDIR/restore-out" + grep -q "dgit-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + + # gists + grep -q "gists to git-server-fake-uuid" "$TRASHDIR/restore-out" + grep -q "gists to git-server-fake-uuid1" "$TRASHDIR/restore-out" + grep -q "gists to git-server-fake-uuid2" "$TRASHDIR/restore-out" + grep -q "gist-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + + + # storage + grep -q "data to git-server-fake-uuid" "$TRASHDIR/restore-out" + grep -q "data to git-server-fake-uuid1" "$TRASHDIR/restore-out" + grep -q "data to git-server-fake-uuid2" "$TRASHDIR/restore-out" + grep -q "storage-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + + + # pages + grep -q "Pages to git-server-fake-uuid" "$TRASHDIR/restore-out" + grep -q "Pages to git-server-fake-uuid1" "$TRASHDIR/restore-out" + grep -q "Pages to git-server-fake-uuid2" "$TRASHDIR/restore-out" + grep -q "dpages-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + + + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test diff --git a/test/testlib.sh b/test/testlib.sh index 4c950a7b7..ce1490226 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -327,10 +327,7 @@ verify_common_data() { diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" # tests that differ for cluster and single node backups and restores - if [ -f "$GHE_DATA_DIR/current/cluster.conf" ]; then - [ -f "$GHE_DATA_DIR/current/cluster.conf" ] - grep -q "fake cluster config" "$GHE_DATA_DIR/current/cluster.conf" - else + if [ "$(cat $GHE_DATA_DIR/current/strategy)" = "rsync" ]; then # verify the UUID was transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/common/uuid" "$GHE_DATA_DIR/current/uuid" @@ -380,7 +377,8 @@ verify_all_backedup_data() { [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] # tests that differ for cluster and single node backups - if [ -f "$GHE_DATA_DIR/current/cluster.conf" ]; then + if [ -f "$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" ]; then + grep -q "fake cluster config" "$GHE_DATA_DIR/current/cluster.conf" # verify strategy used [ "$(cat "$GHE_DATA_DIR/current/strategy")" = "cluster" ] else @@ -404,15 +402,18 @@ verify_all_restored_data() { grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" - grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" + + # tests that differ for cluster and single node backups + if [ "$(cat $GHE_DATA_DIR/current/strategy)" = "rsync" ]; then + grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" + # verify all ES data was transferred from live directory to the temporary restore directory + diff -ru --exclude="*.gz" "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" + fi # verify settings import was *not* run due to instance already being # configured. ! grep -q "fake ghe-export-settings data" "$TRASHDIR/restore-out" - # verify all ES data was transferred from live directory to the temporary restore directory - diff -ru --exclude="*.gz" "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" - # verify management console password was *not* restored ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" From 5917bb02696e47df3ea9a771097db4722867de18 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 20 Mar 2018 16:59:26 +0000 Subject: [PATCH 0514/2421] Use xargs instead of parallel This makes it easier to test and removes a dependency. --- share/github-backup-utils/ghe-restore-pages | 2 +- share/github-backup-utils/ghe-restore-repositories | 2 +- share/github-backup-utils/ghe-restore-repositories-gist | 2 +- share/github-backup-utils/ghe-restore-storage | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 88d0870ae..d83bd1efb 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -138,7 +138,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <&3 <&3 <&3 < Date: Tue, 20 Mar 2018 17:16:27 +0000 Subject: [PATCH 0515/2421] Remove debug line and make messaging consistent --- share/github-backup-utils/ghe-restore-pages | 1 + share/github-backup-utils/ghe-restore-repositories | 1 + share/github-backup-utils/ghe-restore-repositories-gist | 1 - share/github-backup-utils/ghe-restore-storage | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index d83bd1efb..cedf30f0a 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -134,6 +134,7 @@ bm_end "$(basename $0) - Restoring pages" if $CLUSTER; then bm_start "$(basename $0) - Finalizing routes" + ghe_verbose "Finalizing routes" cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <&3 <&3 <&3 < Date: Wed, 21 Mar 2018 14:38:15 +0000 Subject: [PATCH 0516/2421] Split README up into individual docs --- README.md | 264 +------------------------ docs/README.md | 12 ++ docs/backup-snapshot-file-structure.md | 37 ++++ docs/faq.md | 12 ++ docs/getting-started.md | 36 ++++ docs/requirements.md | 42 ++++ docs/scheduling-backups.md | 34 ++++ docs/usage.md | 58 ++++++ 8 files changed, 240 insertions(+), 255 deletions(-) create mode 100644 docs/README.md create mode 100644 docs/backup-snapshot-file-structure.md create mode 100644 docs/faq.md create mode 100644 docs/getting-started.md create mode 100644 docs/requirements.md create mode 100644 docs/scheduling-backups.md create mode 100644 docs/usage.md diff --git a/README.md b/README.md index 40961b420..dfe55e9f5 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,7 @@ -GitHub Enterprise Backup Utilities -================================== +# GitHub Enterprise Backup Utilities This repository includes backup and recovery utilities for [GitHub Enterprise][1]. -- **[Features](#features)** -- **[Requirements](#requirements)** - - **[Backup host requirements](#backup-host-requirements)** - - **[Storage requirements](#storage-requirements)** - - **[GitHub Enterprise version requirements](#github-enterprise-version-requirements)** -- **[Getting started](#getting-started)** -- **[Migrating from GitHub Enterprise v11.10.34x to v2.0](#migrating-from-github-enterprise-v111034x-to-v20-or-v21)** -- **[Using the backup and restore commands](#using-the-backup-and-restore-commands)** -- **[Scheduling backups](#scheduling-backups)** -- **[Backup snapshot file structure](#backup-snapshot-file-structure)** -- **[How does backup utilities differ from a High Availability replica?](#how-does-backup-utilities-differ-from-a-high-availability-replica)** -- **[Support](#support)** - ### Features The backup utilities implement a number of advanced capabilities for backup @@ -37,260 +23,28 @@ GitHub Enterprise. - Runs under most Linux/Unix environments. - MIT licensed, open source software maintained by GitHub, Inc. -### Requirements - -The backup utilities should be run on a host dedicated to long-term permanent -storage and must have network connectivity with the GitHub Enterprise appliance. - -##### Backup host requirements - -Backup host software requirements are modest: Linux or other modern Unix -operating system with [bash][13], [git][14], [OpenSSH][15] 5.6 or newer, and [rsync][4] v2.6.4 or newer. - -The backup host must be able to establish network connections outbound to the -GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise 2.0 -or newer instances, and TCP port 22 is used for older versions (11.10.34X). - -##### Storage requirements - -Storage requirements vary based on current Git repository disk usage and growth -patterns of the GitHub appliance. We recommend allocating at least 5x the amount -of storage allocated to the primary GitHub appliance for historical snapshots -and growth over time. - -The backup utilities use [hard links][12] to store data efficiently, so the backup -snapshots must be written to a filesystem with support for hard links. - -Using a [case sensitive][16] file system is strongly recommended to avoid conflicts. - -##### GitHub Enterprise version requirements - -The backup utilities are fully supported under GitHub Enterprise 2.0 or -greater. - -The previous release series (11.10.34x) is also supported but must meet minimum -version requirements. For online and incremental backup support, the GitHub -Enterprise instance must be running version 11.10.342 or above. - -Earlier versions are supported, but online and incremental backups are not -supported. We strongly recommend upgrading to the latest release if you're -running a version prior to 11.10.342. Visit [enterprise.github.com][5] to -download the most recent GitHub Enterprise version. - -Note: You can restore a snapshot that's at most two feature releases behind the restore target's version of GitHub Enterprise. For example, to restore a snapshot of GitHub Enterprise 2.4, the target GitHub Enterprise appliance must be running GitHub Enterprise 2.5.x or 2.6.x. You can't restore a snapshot from 2.4 to 2.7, because that's three releases ahead. - - -### Getting started - - 1. [Download the latest release version][release] and extract the repository using `tar`: - - `tar -xzvf /path/to/github-backup-utils-vMAJOR.MINOR.PATCH.tar.gz` - - *or* clone the repository using Git: - - `git clone -b stable https://github.com/github/backup-utils.git` - - 2. Copy the [`backup.config-example`][2] file to `backup.config` and modify as - necessary. The `GHE_HOSTNAME` value must be set to the GitHub Enterprise - host name. Additional options are available and documented in the - configuration file but none are required for basic backup functionality. - - * backup-utils will attempt to load the backup configuration from the following locations, in this order: - - ``` - $GHE_BACKUP_CONFIG (User configurable environment variable) - $GHE_BACKUP_ROOT/backup.config (Root directory of backup-utils install) - $HOME/.github-backup-utils/backup.config - /etc/github-backup-utils/backup.config - ``` - * In a clustering environment, the `GHE_EXTRA_SSH_OPTS` key must be configured with the `-i ` SSH option. - - 3. Add the backup host's SSH key to the GitHub appliance as an *Authorized SSH - key*. See [Adding an SSH key for shell access][3] for instructions. - - 4. Run `bin/ghe-host-check` to verify SSH connectivity with the GitHub - appliance. - - 5. Run `bin/ghe-backup` to perform an initial full backup. - -[release]: https://github.com/github/backup-utils/releases - -### Migrating from GitHub Enterprise v11.10.34x to v2.0, or v2.1 - -If you are migrating from GitHub Enterprise version 11.10.34x to 2.0 or 2.1 -(note, migrations to versions greater than 2.1 are not officially supported), -please see the [Migrating from GitHub Enterprise v11.10.34x][10] documentation -in the [GitHub Enterprise System Administrator's Guide][11]. It includes -important information on using the backup utilities to migrate data from your -v11.10.34x instance to v2.0 or v2.1. - -### Using the backup and restore commands - -After the initial backup, use the following commands: - - - The `ghe-backup` command creates incremental snapshots of repository data, - along with full snapshots of all other pertinent data stores. - - The `ghe-restore` command restores snapshots to the same or separate GitHub - Enterprise appliance. You must add the backup host's SSH key to the target - GitHub Enterprise appliance before using this command. - -##### Example backup and restore usage - -The following assumes that `GHE_HOSTNAME` is set to "github.example.com" in -`backup.config`. +### Documentation -Creating a backup snapshot: - $ ghe-backup - Starting backup of github.example.com in snapshot 20140727T224148 - Connect github.example.com OK (v11.10.343) - Backing up GitHub settings ... - Backing up SSH authorized keys ... - Backing up SSH host keys ... - Backing up MySQL database ... - Backing up Redis database ... - Backing up Git repositories ... - Backing up GitHub Pages ... - Backing up Elasticsearch indices ... - Completed backup of github.example.com in snapshot 20140727T224148 at 23:01:58 - -Restoring from last successful snapshot to a newly provisioned GitHub Enterprise -appliance at IP "5.5.5.5": - - $ ghe-restore 5.5.5.5 - Starting rsync restore of 5.5.5.5 from snapshot 20140727T224148 - Connect 5.5.5.5 OK (v11.10.343) - Enabling maintenance mode on 5.5.5.5 ... - Restoring Git repositories ... - Restoring GitHub Pages ... - Restoring MySQL database ... - Restoring Redis database ... - Restoring SSH authorized keys ... - Restoring Elasticsearch indices ... - Restoring SSH host keys ... - Completed restore of 5.5.5.5 from snapshot 20140817T174152 - Visit https://5.5.5.5/setup/settings to configure the recovered appliance. - -A different backup snapshot may be selected by passing the `-s` argument and the -datestamp-named directory from the backup location. - -The `ghe-backup` and `ghe-restore` commands also have a verbose output mode -(`-v`) that lists files as they're being transferred. It's often useful to -enable when output is logged to a file. - -When restoring to an already configured GHE instance, settings, certificate, and license data -are *not* restored to prevent overwriting manual configuration on the restore -host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`, -forcing settings, certificate, and license data to be overwritten with the backup copy's data. - -### Scheduling backups - -Regular backups should be scheduled using `cron(8)` or similar command -scheduling service on the backup host. The backup frequency will dictate the -worst case recovery point objective (RPO) in your backup plan. We recommend the -following: - - - **Hourly backups** for GitHub Enterprise versions 11.10.342 or greater (due to - improved online and incremental backup support) - - **Daily backups** for versions prior to 11.10.342. - -Note: the time required to do full offline backups of large datasets under -GitHub Enterprise versions prior to 11.10.342 may prohibit the use of daily -backups. We strongly recommend upgrading to 11.10.342 or greater in that case. - -##### Example scheduling usage - -The following examples assume the backup utilities are installed under -`/opt/backup-utils`. The crontab entry should be made under the same user that -manual backup/recovery commands will be issued under and must have write access -to the configured `GHE_DATA_DIR` directory. - -Note that the `GHE_NUM_SNAPSHOTS` option in `backup.config` should be tuned -based on the frequency of backups. The ten most recent snapshots are retained by -default. The number should be adjusted based on backup frequency and available -storage. - -To schedule hourly backup snapshots with verbose informational output written to -a log file and errors generating an email: - - MAILTO=admin@example.com - - 0 * * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 - -To schedule nightly backup snapshots instead, use: - - MAILTO=admin@example.com - - 0 0 * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 - -### Backup snapshot file structure - -Backup snapshots are stored in rotating increment directories named after the -date and time the snapshot was taken. Each snapshot directory contains a full -backup snapshot of all relevant data stores. Repository, Search, and Pages data -is stored efficiently via hard links. - -*Please note* Symlinks must be maintained when archiving backup snapshots. -Dereferencing or excluding symlinks, or storing the snapshot contents on a -filesystem which does not support symlinks will result in operational -problems when the data is restored. +### Support -The following example shows a snapshot file hierarchy for hourly frequency. -There are five snapshot directories, with the `current` symlink pointing to the -most recent successful snapshot: +If you find a bug or would like to request a feature in backup-utils, please +open an issue or pull request on this repository. If you have a question related +to your specific GitHub Enterprise setup or would like assistance with backup +site setup or recovery, please contact our [Enterprise support team][2] instead. - ./data - |- 20140724T010000 - |- 20140725T010000 - |- 20140726T010000 - |- 20140727T010000 - |- 20140728T010000 - |- authorized-keys.json - |- elasticsearch/ - |- enterprise.ghl - |- mysql.sql.gz - |- pages/ - |- redis.rdb - |- repositories/ - |- settings.json - |- ssh-host-keys.tar - |- strategy - |- version - |- current -> 20140728T010000 +[1]: https://enterprise.github.com +[2]: https://enterprise.github.com/support/ -Note: the `GHE_DATA_DIR` variable set in `backup.config` can be used to change -the disk location where snapshots are written. -### How does backup utilities differ from a High Availability replica? -It is recommended that both backup utilities and an [High Availability replica](https://help.github.com/enterprise/admin/guides/installation/high-availability-cluster-configuration/) are used as part of a GitHub Enterprise deployment but they serve different roles. -##### The purpose of the High Availability replica -The High Availability replica is a fully redundant secondary GitHub Enterprise instance, kept in sync with the primary instance via replication of all major datastores. This active/passive cluster configuration is designed to minimize service disruption in the event of hardware failure or major network outage affecting the primary instance. Because some forms of data corruption or loss may be replicated immediately from primary to replica, it is not a replacement for the backup utilities as part of your disaster recovery plan. -##### The purpose of the backup utilities -Backup utilities are a disaster recovery tool. This tool takes date-stamped snapshots of all major datastores. These snapshots are used to restore an instance to a prior state or set up a new instance without having another always-on GitHub Enterprise instance (like the High Availability replica). -### Support -If you find a bug or would like to request a feature in backup-utils, please -open an issue or pull request on this repository. If you have a question related -to your specific GitHub Enterprise setup or would like assistance with backup -site setup or recovery, please contact our [Enterprise support team][7] instead. -[1]: https://enterprise.github.com -[2]: https://github.com/github/enterprise-backup-site/blob/master/backup.config-example -[3]: https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access -[4]: http://rsync.samba.org/ -[5]: https://enterprise.github.com/download [6]: https://enterprise.github.com/help/articles/upgrading-to-a-newer-release -[7]: https://enterprise.github.com/support/ [8]: https://enterprise.github.com/help/articles/backing-up-enterprise-data [9]: https://enterprise.github.com/help/articles/restoring-enterprise-data [10]: https://help.github.com/enterprise/2.0/admin-guide/migrating-to-a-different-platform-or-from-github-enterprise-11-10-34x/ [11]: https://help.github.com/enterprise/2.0/admin-guide/ -[12]: https://en.wikipedia.org/wiki/Hard_link -[13]: https://www.gnu.org/software/bash/ -[14]: https://git-scm.com/ -[15]: https://www.openssh.com/ -[16]: https://en.wikipedia.org/wiki/Case_sensitivity diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 000000000..98ea4f750 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,12 @@ +# GitHub Enterprise Backup Utilities Documentation + +- **[Requirements](requirements.md)** + - **[Backup host requirements](requirements.md#backup-host-requirements)** + - **[Storage requirements](requirements.md#storage-requirements)** + - **[GitHub Enterprise version requirements](requirements.md#github-enterprise-version-requirements)** +- **[Getting started](getting-started.md)** +- **[Using the backup and restore commands](usage.md)** +- **[Scheduling backups](scheduling-backups.md)** +- **[Backup snapshot file structure](backup-snapshot-file-structure.md)** +- **[How does backup utilities differ from a High Availability replica?](faq.md)** +- **[Docker]()** diff --git a/docs/backup-snapshot-file-structure.md b/docs/backup-snapshot-file-structure.md new file mode 100644 index 000000000..98eacd1e1 --- /dev/null +++ b/docs/backup-snapshot-file-structure.md @@ -0,0 +1,37 @@ +### Backup snapshot file structure + +Backup snapshots are stored in rotating increment directories named after the +date and time the snapshot was taken. Each snapshot directory contains a full +backup snapshot of all relevant data stores. Repository, Search, and Pages data +is stored efficiently via hard links. + +*Please note* Symlinks must be maintained when archiving backup snapshots. +Dereferencing or excluding symlinks, or storing the snapshot contents on a +filesystem which does not support symlinks will result in operational +problems when the data is restored. + +The following example shows a snapshot file hierarchy for hourly frequency. +There are five snapshot directories, with the `current` symlink pointing to the +most recent successful snapshot: + + ./data + |- 20140724T010000 + |- 20140725T010000 + |- 20140726T010000 + |- 20140727T010000 + |- 20140728T010000 + |- authorized-keys.json + |- elasticsearch/ + |- enterprise.ghl + |- mysql.sql.gz + |- pages/ + |- redis.rdb + |- repositories/ + |- settings.json + |- ssh-host-keys.tar + |- strategy + |- version + |- current -> 20140728T010000 + +Note: the `GHE_DATA_DIR` variable set in `backup.config` can be used to change +the disk location where snapshots are written. diff --git a/docs/faq.md b/docs/faq.md new file mode 100644 index 000000000..09acd171b --- /dev/null +++ b/docs/faq.md @@ -0,0 +1,12 @@ +# Frequently Asked Questions + +### How does backup utilities differ from a High Availability replica? +It is recommended that both backup utilities and an [High Availability replica][1] are used as part of a GitHub Enterprise deployment but they serve different roles. + +##### The purpose of the High Availability replica +The High Availability replica is a fully redundant secondary GitHub Enterprise instance, kept in sync with the primary instance via replication of all major datastores. This active/passive cluster configuration is designed to minimize service disruption in the event of hardware failure or major network outage affecting the primary instance. Because some forms of data corruption or loss may be replicated immediately from primary to replica, it is not a replacement for the backup utilities as part of your disaster recovery plan. + +##### The purpose of the backup utilities +Backup utilities are a disaster recovery tool. This tool takes date-stamped snapshots of all major datastores. These snapshots are used to restore an instance to a prior state or set up a new instance without having another always-on GitHub Enterprise instance (like the High Availability replica). + +[1]: https://help.github.com/enterprise/admin/guides/installation/high-availability-cluster-configuration/ diff --git a/docs/getting-started.md b/docs/getting-started.md new file mode 100644 index 000000000..11c357160 --- /dev/null +++ b/docs/getting-started.md @@ -0,0 +1,36 @@ +### Getting started + + 1. [Download the latest release version][1] and extract the repository using `tar`: + + `tar -xzvf /path/to/github-backup-utils-vMAJOR.MINOR.PATCH.tar.gz` + + *or* clone the repository using Git: + + `git clone -b stable https://github.com/github/backup-utils.git` + + 2. Copy the [`backup.config-example`][2] file to `backup.config` and modify as + necessary. The `GHE_HOSTNAME` value must be set to the GitHub Enterprise + host name. Additional options are available and documented in the + configuration file but none are required for basic backup functionality. + + * backup-utils will attempt to load the backup configuration from the following locations, in this order: + + ``` + $GHE_BACKUP_CONFIG (User configurable environment variable) + $GHE_BACKUP_ROOT/backup.config (Root directory of backup-utils install) + $HOME/.github-backup-utils/backup.config + /etc/github-backup-utils/backup.config + ``` + * In a clustering environment, the `GHE_EXTRA_SSH_OPTS` key must be configured with the `-i ` SSH option. + + 3. Add the backup host's SSH key to the GitHub appliance as an *Authorized SSH + key*. See [Adding an SSH key for shell access][3] for instructions. + + 4. Run `bin/ghe-host-check` to verify SSH connectivity with the GitHub + appliance. + + 5. Run `bin/ghe-backup` to perform an initial full backup. + +[1]: https://github.com/github/backup-utils/releases +[2]: https://github.com/github/enterprise-backup-site/blob/master/backup.config-example +[3]: https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access diff --git a/docs/requirements.md b/docs/requirements.md new file mode 100644 index 000000000..db8c399c5 --- /dev/null +++ b/docs/requirements.md @@ -0,0 +1,42 @@ +### Requirements + +The backup utilities should be run on a host dedicated to long-term permanent +storage and must have network connectivity with the GitHub Enterprise appliance. + +##### Backup host requirements + +Backup host software requirements are modest: Linux or other modern Unix +operating system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. + +The backup host must be able to establish outbound network connections to the +GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise. + +##### Storage requirements + +Storage requirements vary based on current Git repository disk usage and growth +patterns of the GitHub appliance. We recommend allocating at least 5x the amount +of storage allocated to the primary GitHub appliance for historical snapshots +and growth over time. + +The backup utilities use [hard links][5] to store data efficiently, and the repositories +on GitHub Enterprise use [symbolic links][6] so the backup snapshots must be +written to a filesystem with support for symbolic and hard links. + +Using a [case sensitive][7] file system is also required to avoid conflicts. + +##### GitHub Enterprise version requirements + +The backup utilities are fully supported under GitHub Enterprise 2.0 or +greater. + + +Note: You can restore a snapshot that's at most two feature releases behind the restore target's version of GitHub Enterprise. For example, to restore a snapshot of GitHub Enterprise 2.4, the target GitHub Enterprise appliance must be running GitHub Enterprise 2.5.x or 2.6.x. You can't restore a snapshot from 2.4 to 2.7, because that's three releases ahead. + + +[1]: https://www.gnu.org/software/bash/ +[2]: https://git-scm.com/ +[3]: https://www.openssh.com/ +[4]: http://rsync.samba.org/ +[5]: https://en.wikipedia.org/wiki/Hard_link +[6]: https://en.wikipedia.org/wiki/Symbolic_link +[7]: https://en.wikipedia.org/wiki/Case_sensitivity diff --git a/docs/scheduling-backups.md b/docs/scheduling-backups.md new file mode 100644 index 000000000..8272a7913 --- /dev/null +++ b/docs/scheduling-backups.md @@ -0,0 +1,34 @@ +# Scheduling backups + +Regular backups should be scheduled using `cron(8)` or similar command +scheduling service on the backup host. The backup frequency will dictate the +worst case [recovery point objective (RPO)][1] in your backup plan. We recommend +hourly backups at the least. + +## Example scheduling usage + +The following examples assume the backup utilities are installed under +`/opt/backup-utils`. The crontab entry should be made under the same user that +manual backup/recovery commands will be issued under and must have write access +to the configured `GHE_DATA_DIR` directory. + +Note that the `GHE_NUM_SNAPSHOTS` option in `backup.config` should be tuned +based on the frequency of backups. The ten most recent snapshots are retained by +default. The number should be adjusted based on backup frequency and available +storage. + +To schedule hourly backup snapshots with verbose informational output written to +a log file and errors generating an email: + + MAILTO=admin@example.com + + 0 * * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 + +To schedule nightly backup snapshots instead, use: + + MAILTO=admin@example.com + + 0 0 * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 + + +[1]: https://en.wikipedia.org/wiki/Recovery_point_objective diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 000000000..fb6fb4cc5 --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,58 @@ +### Using the backup and restore commands + +After the initial backup, use the following commands: + + - The `ghe-backup` command creates incremental snapshots of repository data, + along with full snapshots of all other pertinent data stores. + - The `ghe-restore` command restores snapshots to the same or separate GitHub + Enterprise appliance. You must add the backup host's SSH key to the target + GitHub Enterprise appliance before using this command. + +##### Example backup and restore usage + +The following assumes that `GHE_HOSTNAME` is set to "github.example.com" in +`backup.config`. + +Creating a backup snapshot: + + $ ghe-backup + Starting backup of github.example.com in snapshot 20140727T224148 + Connect github.example.com OK (v11.10.343) + Backing up GitHub settings ... + Backing up SSH authorized keys ... + Backing up SSH host keys ... + Backing up MySQL database ... + Backing up Redis database ... + Backing up Git repositories ... + Backing up GitHub Pages ... + Backing up Elasticsearch indices ... + Completed backup of github.example.com in snapshot 20140727T224148 at 23:01:58 + +Restoring from last successful snapshot to a newly provisioned GitHub Enterprise +appliance at IP "5.5.5.5": + + $ ghe-restore 5.5.5.5 + Starting rsync restore of 5.5.5.5 from snapshot 20140727T224148 + Connect 5.5.5.5 OK (v11.10.343) + Enabling maintenance mode on 5.5.5.5 ... + Restoring Git repositories ... + Restoring GitHub Pages ... + Restoring MySQL database ... + Restoring Redis database ... + Restoring SSH authorized keys ... + Restoring Elasticsearch indices ... + Restoring SSH host keys ... + Completed restore of 5.5.5.5 from snapshot 20140817T174152 + Visit https://5.5.5.5/setup/settings to configure the recovered appliance. + +A different backup snapshot may be selected by passing the `-s` argument and the +datestamp-named directory from the backup location. + +The `ghe-backup` and `ghe-restore` commands also have a verbose output mode +(`-v`) that lists files as they're being transferred. It's often useful to +enable when output is logged to a file. + +When restoring to an already configured GHE instance, settings, certificate, and license data +are *not* restored to prevent overwriting manual configuration on the restore +host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`, +forcing settings, certificate, and license data to be overwritten with the backup copy's data. From 64ab870cf4739aebd820f420ef0a534b7c926cea Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 21 Mar 2018 14:44:49 +0000 Subject: [PATCH 0517/2421] No need for version differentiation --- share/github-backup-utils/ghe-backup-es-hookshot | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index 61004afc4..034d336a3 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -20,13 +20,7 @@ ghe_remote_version_required "$host" # Make sure root backup dir exists if this is the first run mkdir -p "$GHE_SNAPSHOT_DIR/hookshot" -if [ $GHE_VERSION_MAJOR -ge 2 ] && [ $GHE_VERSION_MINOR -ge 2 ]; then - es_port=9201 -else - es_port=9200 -fi - -if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:$es_port/_cat/indices/hookshot-logs-*?h=index,pri.store.size&bytes=b\""); then +if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:9201/_cat/indices/hookshot-logs-*?h=index,pri.store.size&bytes=b\""); then echo "Error: failed to retrieve hookshot log indices." 1>&2 exit 1 fi @@ -46,7 +40,7 @@ for index in $indices; do ln $GHE_DATA_DIR/current/hookshot/$index_name.gz $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz ln $GHE_DATA_DIR/current/hookshot/$index_name.gz.size $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz + ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz echo $index_size > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size fi done From 302d6c756e8ef8fe750a9880c0891aa8c938e78b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 21 Mar 2018 14:47:06 +0000 Subject: [PATCH 0518/2421] Use local variables --- share/github-backup-utils/ghe-backup-config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 5d57ab282..91c36f57e 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -235,10 +235,10 @@ ghe_remote_version_required () { # Parse a version string into major, minor and patch parts and echo. ghe_parse_version() { - version_major=$(echo "${1#v}" | cut -f 1 -d .) - version_minor=$(echo "$1" | cut -f 2 -d .) - version_patch=$(echo "$1" | cut -f 3 -d .) - version_patch=${version_patch%%[a-zA-Z]*} + local version_major=$(echo "${1#v}" | cut -f 1 -d .) + local version_minor=$(echo "$1" | cut -f 2 -d .) + local version_patch=$(echo "$1" | cut -f 3 -d .) + local version_patch=${version_patch%%[a-zA-Z]*} echo "$version_major $version_minor $version_patch" } From a18040dab6ee09d4b7e0719a0e17f37ab7056bd8 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 21 Mar 2018 14:44:49 +0000 Subject: [PATCH 0519/2421] No need for version differentiation --- share/github-backup-utils/ghe-backup-es-hookshot | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index 61004afc4..034d336a3 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -20,13 +20,7 @@ ghe_remote_version_required "$host" # Make sure root backup dir exists if this is the first run mkdir -p "$GHE_SNAPSHOT_DIR/hookshot" -if [ $GHE_VERSION_MAJOR -ge 2 ] && [ $GHE_VERSION_MINOR -ge 2 ]; then - es_port=9201 -else - es_port=9200 -fi - -if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:$es_port/_cat/indices/hookshot-logs-*?h=index,pri.store.size&bytes=b\""); then +if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:9201/_cat/indices/hookshot-logs-*?h=index,pri.store.size&bytes=b\""); then echo "Error: failed to retrieve hookshot log indices." 1>&2 exit 1 fi @@ -46,7 +40,7 @@ for index in $indices; do ln $GHE_DATA_DIR/current/hookshot/$index_name.gz $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz ln $GHE_DATA_DIR/current/hookshot/$index_name.gz.size $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:$es_port/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz + ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz echo $index_size > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size fi done From 5cbc8fbe495e56de6607655512786807f51ebb4f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 21 Mar 2018 14:47:06 +0000 Subject: [PATCH 0520/2421] Use local variables --- share/github-backup-utils/ghe-backup-config | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 5d57ab282..91c36f57e 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -235,10 +235,10 @@ ghe_remote_version_required () { # Parse a version string into major, minor and patch parts and echo. ghe_parse_version() { - version_major=$(echo "${1#v}" | cut -f 1 -d .) - version_minor=$(echo "$1" | cut -f 2 -d .) - version_patch=$(echo "$1" | cut -f 3 -d .) - version_patch=${version_patch%%[a-zA-Z]*} + local version_major=$(echo "${1#v}" | cut -f 1 -d .) + local version_minor=$(echo "$1" | cut -f 2 -d .) + local version_patch=$(echo "$1" | cut -f 3 -d .) + local version_patch=${version_patch%%[a-zA-Z]*} echo "$version_major $version_minor $version_patch" } From 93359f50e56b895be48d099ca5326f1e8dd20f3e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 21 Mar 2018 15:06:58 +0000 Subject: [PATCH 0521/2421] Bump version to 2.13.0 --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 22e3b6b01..fb2c0766b 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.11.3 +2.13.0 From f9d2f6e32335281ea6be77cf6f153c4e00273cb7 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Wed, 21 Mar 2018 14:20:57 -0700 Subject: [PATCH 0522/2421] Move check for `git` for ssh muxing into ghe-ssh --- bin/ghe-backup | 3 --- share/github-backup-utils/ghe-ssh | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 6af66b256..a667ad103 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -117,9 +117,6 @@ echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress echo "Starting backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP" -# Warn if git is not installed, and set GHE_DISABLE_SSH_MUX=true -command -v git >/dev/null 2>&1 || echo "Warning: SSH multiplexing requires git but it's not installed." && export GHE_DISABLE_SSH_MUX=true - # Perform a host connection check and establish the remote appliance version. # The version is available in the GHE_REMOTE_VERSION variable and also written # to a version file in the snapshot directory itself. diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 0b4f5312a..46fe3f22e 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -62,6 +62,9 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then exit 1 fi +# Warn if git is not installed, and set GHE_DISABLE_SSH_MUX=true +command -v git >/dev/null 2>&1 || echo "Warning: SSH multiplexing requires git but it's not installed." && export GHE_DISABLE_SSH_MUX=true + if [ -z "$GHE_DISABLE_SSH_MUX" ]; then controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | git hash-object --stdin | cut -c 1-8)" opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" From 66a67ae0386becfa5e103e4f43c2f13f883ca7d6 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Wed, 21 Mar 2018 14:30:02 -0700 Subject: [PATCH 0523/2421] wrap check in an if to make it less spammy --- share/github-backup-utils/ghe-ssh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 46fe3f22e..fa117d9c0 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -63,7 +63,10 @@ if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then fi # Warn if git is not installed, and set GHE_DISABLE_SSH_MUX=true -command -v git >/dev/null 2>&1 || echo "Warning: SSH multiplexing requires git but it's not installed." && export GHE_DISABLE_SSH_MUX=true +if [ -z "$GHE_DISABLE_SSH_MUX" ]; then + command -v git >/dev/null 2>&1 || echo "Warning: SSH multiplexing requires git but it's not installed." + export GHE_DISABLE_SSH_MUX=true +fi if [ -z "$GHE_DISABLE_SSH_MUX" ]; then controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | git hash-object --stdin | cut -c 1-8)" From 1c874eb0f010ae87f6cce3d903b0c90d727efdd5 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Wed, 21 Mar 2018 14:30:58 -0700 Subject: [PATCH 0524/2421] still needs the && for the check --- share/github-backup-utils/ghe-ssh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index fa117d9c0..6756f9bf7 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -64,8 +64,7 @@ fi # Warn if git is not installed, and set GHE_DISABLE_SSH_MUX=true if [ -z "$GHE_DISABLE_SSH_MUX" ]; then - command -v git >/dev/null 2>&1 || echo "Warning: SSH multiplexing requires git but it's not installed." - export GHE_DISABLE_SSH_MUX=true + command -v git >/dev/null 2>&1 || echo "Warning: SSH multiplexing requires git but it's not installed." && export GHE_DISABLE_SSH_MUX=true fi if [ -z "$GHE_DISABLE_SSH_MUX" ]; then From a2b46f6ccc6a1708166d58aca4667783fceb5282 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:42:51 +0000 Subject: [PATCH 0525/2421] Add a version helper function This is useful for version comparison. --- share/github-backup-utils/ghe-backup-config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 91c36f57e..c01baa5c7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -291,3 +291,7 @@ ghe_debug() { echo "Debug: $*" 1>&3 fi } + +version() { + echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; +} From d4d27d4f74ad21b68e6585f890760c1294981e7b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:43:23 +0000 Subject: [PATCH 0526/2421] Relax min version req for 2.11 and 2.12 --- bin/ghe-host-check | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 5224d8aac..578476c99 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -92,12 +92,11 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_versions="v2.11.15, v2.12.9, v2.13.0" +supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0" -read -r ghe_version_major ghe_version_minor ghe_version_patch <<<$(ghe_parse_version $version) +read -r ghe_version_major ghe_version_minor _ <<<$(ghe_parse_version $version) if ver=$(echo "$supported_minimum_versions" | tr ", " "\n" | grep -Eo $ghe_version_major\.$ghe_version_minor\..+); then - read -r _ _ patch <<<$(ghe_parse_version $ver) - if [ "$ghe_version_patch" -ge $patch ]; then + if [ "$(version $version)" -ge "$(version $ver)" ]; then supported=1 fi fi From 01678d69fdde4861f77384a5211fb55b59c7589b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:44:42 +0000 Subject: [PATCH 0527/2421] Still use old rsync method prior to 2.13 on single nodes --- bin/ghe-restore | 14 ++++-- .../ghe-restore-repositories-rsync | 46 +++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) create mode 100755 share/github-backup-utils/ghe-restore-repositories-rsync diff --git a/bin/ghe-restore b/bin/ghe-restore index 536e51e23..69238ecde 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -270,11 +270,17 @@ bm_start "ghe-import-redis" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3 bm_end "ghe-import-redis" -echo "Restoring Git repositories ..." -ghe-restore-repositories "$GHE_HOSTNAME" 1>&3 +# Unified and enhanced restore method to 2.13.0 and newer +if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; then + echo "Restoring Git repositories ..." + ghe-restore-repositories "$GHE_HOSTNAME" 1>&3 -echo "Restoring Gists ..." -ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 + echo "Restoring Gists ..." + ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 +else + echo "Restoring Git repositories and Gists ..." + ghe-restore-repositories-rsync "$GHE_HOSTNAME" 1>&3 +fi echo "Restoring GitHub Pages ..." ghe-restore-pages "$GHE_HOSTNAME" 1>&3 diff --git a/share/github-backup-utils/ghe-restore-repositories-rsync b/share/github-backup-utils/ghe-restore-repositories-rsync new file mode 100755 index 000000000..9dccda6c8 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-repositories-rsync @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-repositories-rsync +#/ Restore an rsync snapshot of all Git repository data to a GitHub instance. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when the rsync strategy is used. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +cleanup() { + # Enable remote GC operations + ghe-gc-enable $GHE_HOSTNAME +} + +trap 'cleanup' INT TERM EXIT + +# Disable remote GC operations +ghe-gc-disable $GHE_HOSTNAME + +# Transfer all git repository data from the latest snapshot to the GitHub +# instance in a single rsync invocation. +ghe-rsync -avH --delete \ + --exclude ".sync_in_progress" \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/repositories" 1>&3 + +bm_end "$(basename $0)" From cb2c062f7c41fcdcf61a69c224bfb75b6f4beaa6 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:45:09 +0000 Subject: [PATCH 0528/2421] Restore exported JSON audit and hookshot logs to 2.12.9 onwards --- bin/ghe-restore | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 69238ecde..aad3dab5e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -304,11 +304,15 @@ if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" fi -echo "Restoring Elasticsearch Audit logs ..." -ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 - -echo "Restoring hookshot logs ..." -ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 +# Restore exported audit and hookshot logs to 2.12.9 and newer single nodes and +# all releases of cluster +if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then + echo "Restoring Elasticsearch Audit logs ..." + ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 + + echo "Restoring hookshot logs ..." + ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 +fi # Restart an already running memcached to reset the cache after restore echo "Restarting memcached ..." 1>&3 From 2d92a155bd5f515567af1201e55c30c69ecfc852 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:45:26 +0000 Subject: [PATCH 0529/2421] Test 2.11 and 2.13 --- script/cibuild | 3 ++- test/testlib.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/script/cibuild b/script/cibuild index d0070da4e..dd445b618 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,7 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.11.15 + 2.11.0 + 2.13.0 " # Enable verbose logging of ssh commands diff --git a/test/testlib.sh b/test/testlib.sh index ce1490226..d60e6ba47 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.11.15} +: ${GHE_TEST_REMOTE_VERSION:=2.11.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 66249ffee1625301b20152d11ce25a2e5f3cdb08 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 11:28:24 +0000 Subject: [PATCH 0530/2421] Add 2.14 for future release testing --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 578476c99..73efad3f9 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -92,7 +92,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0" +supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0, v2.14.0" read -r ghe_version_major ghe_version_minor _ <<<$(ghe_parse_version $version) if ver=$(echo "$supported_minimum_versions" | tr ", " "\n" | grep -Eo $ghe_version_major\.$ghe_version_minor\..+); then From dd02c3c9b90476a084d6e152bb27573886b19aa2 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 12:17:50 +0000 Subject: [PATCH 0531/2421] Revert "Use xargs instead of parallel" This reverts commit 5917bb02696e47df3ea9a771097db4722867de18. --- share/github-backup-utils/ghe-restore-pages | 2 +- share/github-backup-utils/ghe-restore-repositories | 2 +- share/github-backup-utils/ghe-restore-repositories-gist | 2 +- share/github-backup-utils/ghe-restore-storage | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index cedf30f0a..7bcfe801e 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -139,7 +139,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <&3 <&3 <&3 < Date: Thu, 22 Mar 2018 13:03:45 +0000 Subject: [PATCH 0532/2421] Use moreutils parallel under CI --- test/test-ghe-restore.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index c525e34c2..6918becc7 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -374,7 +374,7 @@ begin_test "ghe-restore cluster" setup_remote_metadata setup_remote_cluster echo "cluster" > "$GHE_DATA_DIR/current/strategy" - + # set as configured, enable maintenance mode and create required directories setup_maintenance_mode "configured" @@ -382,6 +382,11 @@ begin_test "ghe-restore cluster" GHE_RESTORE_HOST=127.0.0.1 export GHE_RESTORE_HOST + # CI servers may have moreutils parallel and GNU parallel installed. We need moreutils parallel. + if [ -x "/usr/bin/parallel.moreutils" ]; then + ln -s /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel" + fi + # run ghe-restore and write output to file for asserting against if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then cat "$TRASHDIR/restore-out" @@ -389,6 +394,10 @@ begin_test "ghe-restore cluster" false fi + if [ -h "$ROOTDIR/test/bin/parallel" ]; then + unlink "$ROOTDIR/test/bin/parallel" + fi + # for debugging cat "$TRASHDIR/restore-out" From 7da27a3b1c43ba9a37272529a9dfa9e77359542c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:42:51 +0000 Subject: [PATCH 0533/2421] Add a version helper function This is useful for version comparison. --- share/github-backup-utils/ghe-backup-config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 91c36f57e..c01baa5c7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -291,3 +291,7 @@ ghe_debug() { echo "Debug: $*" 1>&3 fi } + +version() { + echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; +} From 5ca0b08677dca10d7e0bad9164e9226c728aabab Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:43:23 +0000 Subject: [PATCH 0534/2421] Relax min version req for 2.11 and 2.12 --- bin/ghe-host-check | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 5224d8aac..578476c99 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -92,12 +92,11 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_versions="v2.11.15, v2.12.9, v2.13.0" +supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0" -read -r ghe_version_major ghe_version_minor ghe_version_patch <<<$(ghe_parse_version $version) +read -r ghe_version_major ghe_version_minor _ <<<$(ghe_parse_version $version) if ver=$(echo "$supported_minimum_versions" | tr ", " "\n" | grep -Eo $ghe_version_major\.$ghe_version_minor\..+); then - read -r _ _ patch <<<$(ghe_parse_version $ver) - if [ "$ghe_version_patch" -ge $patch ]; then + if [ "$(version $version)" -ge "$(version $ver)" ]; then supported=1 fi fi From 024cb1f659b670b1e6638fcd438f879e1fabbbf7 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:44:42 +0000 Subject: [PATCH 0535/2421] Still use old rsync method prior to 2.13 on single nodes --- bin/ghe-restore | 14 ++++-- .../ghe-restore-repositories-rsync | 46 +++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) create mode 100755 share/github-backup-utils/ghe-restore-repositories-rsync diff --git a/bin/ghe-restore b/bin/ghe-restore index 536e51e23..69238ecde 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -270,11 +270,17 @@ bm_start "ghe-import-redis" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3 bm_end "ghe-import-redis" -echo "Restoring Git repositories ..." -ghe-restore-repositories "$GHE_HOSTNAME" 1>&3 +# Unified and enhanced restore method to 2.13.0 and newer +if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; then + echo "Restoring Git repositories ..." + ghe-restore-repositories "$GHE_HOSTNAME" 1>&3 -echo "Restoring Gists ..." -ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 + echo "Restoring Gists ..." + ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 +else + echo "Restoring Git repositories and Gists ..." + ghe-restore-repositories-rsync "$GHE_HOSTNAME" 1>&3 +fi echo "Restoring GitHub Pages ..." ghe-restore-pages "$GHE_HOSTNAME" 1>&3 diff --git a/share/github-backup-utils/ghe-restore-repositories-rsync b/share/github-backup-utils/ghe-restore-repositories-rsync new file mode 100755 index 000000000..9dccda6c8 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-repositories-rsync @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-repositories-rsync +#/ Restore an rsync snapshot of all Git repository data to a GitHub instance. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when the rsync strategy is used. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +cleanup() { + # Enable remote GC operations + ghe-gc-enable $GHE_HOSTNAME +} + +trap 'cleanup' INT TERM EXIT + +# Disable remote GC operations +ghe-gc-disable $GHE_HOSTNAME + +# Transfer all git repository data from the latest snapshot to the GitHub +# instance in a single rsync invocation. +ghe-rsync -avH --delete \ + --exclude ".sync_in_progress" \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + --rsync-path="sudo -u git rsync" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/repositories" 1>&3 + +bm_end "$(basename $0)" From 829f552a7c7d0663073020548af30942311f2b83 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:45:09 +0000 Subject: [PATCH 0536/2421] Restore exported JSON audit and hookshot logs to 2.12.9 onwards --- bin/ghe-restore | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 69238ecde..aad3dab5e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -304,11 +304,15 @@ if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" fi -echo "Restoring Elasticsearch Audit logs ..." -ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 - -echo "Restoring hookshot logs ..." -ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 +# Restore exported audit and hookshot logs to 2.12.9 and newer single nodes and +# all releases of cluster +if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then + echo "Restoring Elasticsearch Audit logs ..." + ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 + + echo "Restoring hookshot logs ..." + ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 +fi # Restart an already running memcached to reset the cache after restore echo "Restarting memcached ..." 1>&3 From 02434b600b84dbf9941696de3d2d614dc8e674fe Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 10:45:26 +0000 Subject: [PATCH 0537/2421] Test 2.11 and 2.13 --- script/cibuild | 3 ++- test/testlib.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/script/cibuild b/script/cibuild index d0070da4e..dd445b618 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,7 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.11.15 + 2.11.0 + 2.13.0 " # Enable verbose logging of ssh commands diff --git a/test/testlib.sh b/test/testlib.sh index ce1490226..d60e6ba47 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.11.15} +: ${GHE_TEST_REMOTE_VERSION:=2.11.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 7267bd8ddfa2fed776cae3ca81a9fc5e23c47644 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 22 Mar 2018 11:28:24 +0000 Subject: [PATCH 0538/2421] Add 2.14 for future release testing --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 578476c99..73efad3f9 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -92,7 +92,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0" +supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0, v2.14.0" read -r ghe_version_major ghe_version_minor _ <<<$(ghe_parse_version $version) if ver=$(echo "$supported_minimum_versions" | tr ", " "\n" | grep -Eo $ghe_version_major\.$ghe_version_minor\..+); then From 53eeaf7be0fc3d93d81b019399a7812832a2260c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 23 Mar 2018 08:32:04 +0000 Subject: [PATCH 0539/2421] Handle dev and test GHE versions --- bin/ghe-host-check | 5 +++-- test/test-ghe-host-check.sh | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 73efad3f9..0c27d503d 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -92,10 +92,11 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0, v2.14.0" +supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0" +dev_test_versions="v2.14.0, v2.9999.0" read -r ghe_version_major ghe_version_minor _ <<<$(ghe_parse_version $version) -if ver=$(echo "$supported_minimum_versions" | tr ", " "\n" | grep -Eo $ghe_version_major\.$ghe_version_minor\..+); then +if ver=$(echo "$supported_minimum_versions $dev_test_versions" | tr ", " "\n" | grep -Eo $ghe_version_major\.$ghe_version_minor\..+); then if [ "$(version $version)" -ge "$(version $ver)" ]; then supported=1 fi diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 2f4345294..6dafca45e 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -53,12 +53,11 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise versions" set -e ! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=2.11.14 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=2.12.8 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.11.15 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.12.9 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.11.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.12.0 ghe-host-check GHE_TEST_REMOTE_VERSION=2.13.999 ghe-host-check GHE_TEST_REMOTE_VERSION=2.13.999gm1 ghe-host-check ! GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.9999.1521793591.performancetest ghe-host-check ) end_test From d0e1e39e50bb322848fadbfa47b91f234e690bd4 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 23 Mar 2018 09:00:31 +0000 Subject: [PATCH 0540/2421] Allow for any version above minimum This will rely on the version enforcement on the appliance side of things too. --- bin/ghe-host-check | 14 +++++--------- test/test-ghe-host-check.sh | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 0c27d503d..7a5e4d277 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -92,19 +92,15 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0" -dev_test_versions="v2.14.0, v2.9999.0" - -read -r ghe_version_major ghe_version_minor _ <<<$(ghe_parse_version $version) -if ver=$(echo "$supported_minimum_versions $dev_test_versions" | tr ", " "\n" | grep -Eo $ghe_version_major\.$ghe_version_minor\..+); then - if [ "$(version $version)" -ge "$(version $ver)" ]; then - supported=1 - fi +supported_minimum_version="2.11.0" + +if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then + supported=1 fi if [ -z "$supported" ]; then echo "Error: unsupported release of GitHub Enterprise detected." 1>&2 - echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise $supported_minimum_versions or newer patch revisions." 1>&2 + echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise v$supported_minimum_version or newer." 1>&2 echo "Please update your GitHub Enterprise appliance or use an older version of Backup Utilities." 1>&2 exit 1 fi diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 6dafca45e..5f6711c5b 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -57,7 +57,7 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise versions" GHE_TEST_REMOTE_VERSION=2.12.0 ghe-host-check GHE_TEST_REMOTE_VERSION=2.13.999 ghe-host-check GHE_TEST_REMOTE_VERSION=2.13.999gm1 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.9999.1521793591.performancetest ghe-host-check + ! GHE_TEST_REMOTE_VERSION=2.9999.1521793591.performancetest ghe-host-check + GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check ) end_test From 3ccceb81aa04f720707f9e2133a4388be30fa472 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 23 Mar 2018 09:05:23 +0000 Subject: [PATCH 0541/2421] Simplify host version check and allow for newer releases by default Additional enforcement will occur on the GHE side of things. --- bin/ghe-host-check | 11 ++++------- test/test-ghe-host-check.sh | 9 ++++----- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 73efad3f9..7a5e4d277 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -92,18 +92,15 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_versions="v2.11.0, v2.12.0, v2.13.0, v2.14.0" +supported_minimum_version="2.11.0" -read -r ghe_version_major ghe_version_minor _ <<<$(ghe_parse_version $version) -if ver=$(echo "$supported_minimum_versions" | tr ", " "\n" | grep -Eo $ghe_version_major\.$ghe_version_minor\..+); then - if [ "$(version $version)" -ge "$(version $ver)" ]; then - supported=1 - fi +if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then + supported=1 fi if [ -z "$supported" ]; then echo "Error: unsupported release of GitHub Enterprise detected." 1>&2 - echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise $supported_minimum_versions or newer patch revisions." 1>&2 + echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise v$supported_minimum_version or newer." 1>&2 echo "Please update your GitHub Enterprise appliance or use an older version of Backup Utilities." 1>&2 exit 1 fi diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 2f4345294..5f6711c5b 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -53,12 +53,11 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise versions" set -e ! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=2.11.14 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=2.12.8 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.11.15 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.12.9 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.11.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.12.0 ghe-host-check GHE_TEST_REMOTE_VERSION=2.13.999 ghe-host-check GHE_TEST_REMOTE_VERSION=2.13.999gm1 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=2.9999.1521793591.performancetest ghe-host-check + GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check ) end_test From 5382ca52465987e6a68cc01ccac23f421f60b805 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 10:44:34 +0100 Subject: [PATCH 0542/2421] Add note and documentation links --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index dfe55e9f5..95d44d582 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ This repository includes backup and recovery utilities for [GitHub Enterprise][1]. +**Note**: the [GitHub Enterprise version requirements](docs/requirements.md#github-enterprise-version-requirements) have +changed starting with backup utilities (backup-utils) v2.13.0. + ### Features The backup utilities implement a number of advanced capabilities for backup @@ -25,6 +28,16 @@ GitHub Enterprise. ### Documentation +- **[Requirements](docs/requirements.md)** + - **[Backup host requirements](docs/requirements.md#backup-host-requirements)** + - **[Storage requirements](docs/requirements.md#storage-requirements)** + - **[GitHub Enterprise version requirements](docs/requirements.md#github-enterprise-version-requirements)** +- **[Getting started](docs/getting-started.md)** +- **[Using the backup and restore commands](docs/usage.md)** +- **[Scheduling backups](docs/scheduling-backups.md)** +- **[Backup snapshot file structure](docs/backup-snapshot-file-structure.md)** +- **[How does backup utilities differ from a High Availability replica?](docs/faq.md)** +- **[Docker](docs/docker.md)** ### Support From 9b9be430a191c7ae2c3c5db4d1ae5ce58b15c477 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 10:44:48 +0100 Subject: [PATCH 0543/2421] Update docker link --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 98ea4f750..f126dea5c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -9,4 +9,4 @@ - **[Scheduling backups](scheduling-backups.md)** - **[Backup snapshot file structure](backup-snapshot-file-structure.md)** - **[How does backup utilities differ from a High Availability replica?](faq.md)** -- **[Docker]()** +- **[Docker](docker.md)** From fd2749687634a9815d07c16b16a7fe6e479b2d04 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 10:45:05 +0100 Subject: [PATCH 0544/2421] Update structure output --- docs/backup-snapshot-file-structure.md | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/backup-snapshot-file-structure.md b/docs/backup-snapshot-file-structure.md index 98eacd1e1..55ab3637f 100644 --- a/docs/backup-snapshot-file-structure.md +++ b/docs/backup-snapshot-file-structure.md @@ -20,16 +20,25 @@ most recent successful snapshot: |- 20140726T010000 |- 20140727T010000 |- 20140728T010000 + |- audit-log + |- benchmarks + |- elasticsearch + |- git-hooks + |- hookshot + |- pages + |- repositories + |- storage |- authorized-keys.json - |- elasticsearch/ |- enterprise.ghl + |- es-scan-complete + |- manage-password |- mysql.sql.gz - |- pages/ |- redis.rdb - |- repositories/ |- settings.json |- ssh-host-keys.tar + |- ssl-ca-certificates.tar |- strategy + |- uuid |- version |- current -> 20140728T010000 From 4bc68ed6707cc80d502b36fc6ad47101780966c3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 10:45:34 +0100 Subject: [PATCH 0545/2421] Wrap to ~80 chars --- docs/docker.md | 46 +++++++++++++++++++++++++++++++---------- docs/faq.md | 16 +++++++++++--- docs/getting-started.md | 6 ++++-- 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/docs/docker.md b/docs/docker.md index 7f1ee5642..17b853bef 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -7,7 +7,8 @@ docker build -t github/backup-utils . ``` #### Setting configuration options at runtime -The `backup.config` file is dynamically populated at runtime with all `GHE_` environment variables that are part of the run command or Docker environment: +The `backup.config` file is dynamically populated at runtime with all `GHE_` +environment variables that are part of the run command or Docker environment: ``` $ docker run -it -e "GHE_HOSTNAME=hostname" \ @@ -21,7 +22,9 @@ $ docker run -it -e "GHE_HOSTNAME=hostname" \ github/backup-utils ghe-backup ``` -It is also possible to specify a `-e GHE_BACKUP_CONFIG` flag and volume mount in a local `backup.config` file rather than specify the variables individually at run time: +It is also possible to specify a `-e GHE_BACKUP_CONFIG` flag and volume mount in +a local `backup.config` file rather than specify the variables individually at +run time: ``` $ docker run -it -e "GHE_BACKUP_CONFIG=/mnt/backup.config" \ @@ -35,7 +38,10 @@ github/backup-utils ghe-backup #### SSH Keys -A SSH private key that has been added to the GitHub Enterprise [Management Console for administrative SSH access](https://help.github.com/enterprise/admin/guides/installation/administrative-shell-ssh-access/) needs to be mounted into the container from the host system. It is also recommended to mount a SSH `.ssh/known_hosts` file into the container. +A SSH private key that has been added to the GitHub Enterprise [Management Console +for administrative SSH access][1] needs to be mounted into the container from the +host system. It is also recommended to mount a SSH `.ssh/known_hosts` file into +the container. ``` $ docker run -it -e "GHE_HOSTNAME=hostname" \ @@ -50,7 +56,8 @@ github/backup-utils ghe-backup ##### Using ssh-agent -If your SSH private key is protected with a passphrase, you can mount the `ssh-agent` socket from the Docker host into the GitHub Enterprise backup utilities image. +If your SSH private key is protected with a passphrase, you can mount the `ssh-agent` +socket from the Docker host into the GitHub Enterprise backup utilities image. 1. Start the ssh-agent in the background. @@ -59,13 +66,16 @@ If your SSH private key is protected with a passphrase, you can mount the `ssh-a Agent pid 59566 ``` -2. Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace *id_rsa* in the command with the name of your private key file. +2. Add your SSH private key to the ssh-agent. If you created your key with a + different name, or if you are adding an existing key that has a different name, + replace *id_rsa* in the command with the name of your private key file. ``` $ ssh-add ~/.ssh/id_rsa ``` -3. Run the container setting the `SSH_AUTH_SOCK` environment variable, and mounting the socket into the container as a volume: +3. Run the container setting the `SSH_AUTH_SOCK` environment variable, and + mounting the socket into the container as a volume: ``` docker run -it -e "GHE_HOSTNAME=hostname" \ @@ -83,13 +93,17 @@ If your SSH private key is protected with a passphrase, you can mount the `ssh-a #### Managing backup data -Data persistence is achieved by using [Docker volumes](https://docs.docker.com/engine/admin/volumes/volumes/), which are managed with [`docker volume` commands](https://docs.docker.com/engine/reference/commandline/volume/). Prior to running the container for the first time, a volume can be created if you need to specify additional options. The named volume will be automatically created at runtime if it does not exist: +Data persistence is achieved by using [Docker volumes][2], which are managed with +[`docker volume` commands][3]. Prior to running the container for the first time, +a volume can be created if you need to specify additional options. The named +volume will be automatically created at runtime if it does not exist: ``` docker volume create ghe-backup-data ``` -The named Docker volume can be mounted and accessed from other containers, using any image you like: +The named Docker volume can be mounted and accessed from other containers, using +any image you like: ``` # Accessing backups using the backup-utils image: @@ -111,13 +125,19 @@ lrwxrwxrwx 1 root root 15 Oct 24 19:49 current -> 20171024T194 * The volume's filesystem must support hard links. -* Bind mounting a volume is supported, as long as the Docker host supports them and allows hard links. +* Bind mounting a volume is supported, as long as the Docker host supports them + and allows hard links. #### Scheduling backups using crontab with Docker -Designed to be a "one shot" type container, scheduling backup runs with the Docker image is similar to the non-Docker scheduling. Run the container with all the same variables options and volume mounts on `crontab`. This avoids needing to run `crond` or an init system inside the container, and allows for the container to be disposable (enabling the use of Docker's `--rm` flag). +Designed to be a "one shot" type container, scheduling backup runs with the Docker +image is similar to the non-Docker scheduling. Run the container with all the same +variables options and volume mounts on `crontab`. This avoids needing to run +`crond` or an init system inside the container, and allows for the container to +be disposable (enabling the use of Docker's `--rm` flag). -To schedule hourly backup snapshots with verbose informational output written to a log file and errors generating an email: +To schedule hourly backup snapshots with verbose informational output written to +a log file and errors generating an email: ``` MAILTO=admin@example.com @@ -132,3 +152,7 @@ MAILTO=admin@example.com 0 0 * * * /usr/local/bin/docker run -i -e "GHE_HOSTNAME=hostname" -e "GHE_DATA_DIR=/data" -e "GHE_EXTRA_SSH_OPTS=-i /ghe-ssh/ghelocal -o UserKnownHostsFile=/ghe-ssh/known_hosts" -v "ghe-backup-data:/data" -v "$HOME/.ssh/ghelocal:/ghe-ssh/ghelocal" -v "$HOME/.ssh/known_hosts:/ghe-ssh/known_hosts" --rm github/backup-utils ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 ``` + +[1]: https://help.github.com/enterprise/admin/guides/installation/administrative-shell-ssh-access/ +[2]: https://docs.docker.com/engine/admin/volumes/volumes/ +[3]: https://docs.docker.com/engine/reference/commandline/volume/ diff --git a/docs/faq.md b/docs/faq.md index 09acd171b..9110c46fc 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,12 +1,22 @@ # Frequently Asked Questions ### How does backup utilities differ from a High Availability replica? -It is recommended that both backup utilities and an [High Availability replica][1] are used as part of a GitHub Enterprise deployment but they serve different roles. +It is recommended that both backup utilities and an [High Availability replica][1] +are used as part of a GitHub Enterprise deployment but they serve different roles. ##### The purpose of the High Availability replica -The High Availability replica is a fully redundant secondary GitHub Enterprise instance, kept in sync with the primary instance via replication of all major datastores. This active/passive cluster configuration is designed to minimize service disruption in the event of hardware failure or major network outage affecting the primary instance. Because some forms of data corruption or loss may be replicated immediately from primary to replica, it is not a replacement for the backup utilities as part of your disaster recovery plan. +The High Availability replica is a fully redundant secondary GitHub Enterprise +instance, kept in sync with the primary instance via replication of all major +datastores. This active/passive cluster configuration is designed to minimize +service disruption in the event of hardware failure or major network outage +affecting the primary instance. Because some forms of data corruption or loss may +be replicated immediately from primary to replica, it is not a replacement for +the backup utilities as part of your disaster recovery plan. ##### The purpose of the backup utilities -Backup utilities are a disaster recovery tool. This tool takes date-stamped snapshots of all major datastores. These snapshots are used to restore an instance to a prior state or set up a new instance without having another always-on GitHub Enterprise instance (like the High Availability replica). +Backup utilities are a disaster recovery tool. This tool takes date-stamped +snapshots of all major datastores. These snapshots are used to restore an instance +to a prior state or set up a new instance without having another always-on GitHub +Enterprise instance (like the High Availability replica). [1]: https://help.github.com/enterprise/admin/guides/installation/high-availability-cluster-configuration/ diff --git a/docs/getting-started.md b/docs/getting-started.md index 11c357160..6d3d80b65 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -13,7 +13,8 @@ host name. Additional options are available and documented in the configuration file but none are required for basic backup functionality. - * backup-utils will attempt to load the backup configuration from the following locations, in this order: + * backup-utils will attempt to load the backup configuration from the following + locations, in this order: ``` $GHE_BACKUP_CONFIG (User configurable environment variable) @@ -21,7 +22,8 @@ $HOME/.github-backup-utils/backup.config /etc/github-backup-utils/backup.config ``` - * In a clustering environment, the `GHE_EXTRA_SSH_OPTS` key must be configured with the `-i ` SSH option. + * In a clustering environment, the `GHE_EXTRA_SSH_OPTS` key must be configured + with the `-i ` SSH option. 3. Add the backup host's SSH key to the GitHub appliance as an *Authorized SSH key*. See [Adding an SSH key for shell access][3] for instructions. From f9233a94870d7d0dda58703c11d883642eddebcd Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 10:45:50 +0100 Subject: [PATCH 0546/2421] Update requirements and wrap to ~80 chars --- docs/requirements.md | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index db8c399c5..fcd8b7ac6 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,8 +5,11 @@ storage and must have network connectivity with the GitHub Enterprise appliance. ##### Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix -operating system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. +Backup host software requirements are modest: Linux or other modern Unix operating +system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. + +We encourage the use of [Docker](docker.md) if your backup host doesn't meet these +requirements, or if Docker is your preferred platform. The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise. @@ -18,20 +21,33 @@ patterns of the GitHub appliance. We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time. -The backup utilities use [hard links][5] to store data efficiently, and the repositories -on GitHub Enterprise use [symbolic links][6] so the backup snapshots must be -written to a filesystem with support for symbolic and hard links. +The backup utilities use [hard links][5] to store data efficiently, and the +repositories on GitHub Enterprise use [symbolic links][6] so the backup snapshots +must be written to a filesystem with support for symbolic and hard links. Using a [case sensitive][7] file system is also required to avoid conflicts. ##### GitHub Enterprise version requirements -The backup utilities are fully supported under GitHub Enterprise 2.0 or -greater. +Starting with backup utilities v2.13.0, version support is inline with that of the +[GitHub Enterprise upgrade requirements][8] and as such, support is limited to +three versions of GitHub Enterprise: the version that corresponds with the version +of backup utilities, and the two releases prior to it. +For example, backup utilities v2.13.0 can be used to backup and restore all patch +releases from 2.11.0 to the latest patch release of GitHub Enterprise 2.13. +Backup utilities v2.14.0 will be released when GitHub Enterprise 2.14.0 is release +and will then be used to backup all releases of GitHub Enterprise from 2.12.0 +to the latest patch release of GitHub Enterprise 2.14. -Note: You can restore a snapshot that's at most two feature releases behind the restore target's version of GitHub Enterprise. For example, to restore a snapshot of GitHub Enterprise 2.4, the target GitHub Enterprise appliance must be running GitHub Enterprise 2.5.x or 2.6.x. You can't restore a snapshot from 2.4 to 2.7, because that's three releases ahead. +Backup utilities v2.11.4 and earlier offer support for GitHub Enterprise 2.10 +and earlier releases. +**Note**: You can restore a snapshot that's at most two feature releases behind +the restore target's version of GitHub Enterprise. For example, to restore a +snapshot of GitHub Enterprise 2.11, the target GitHub Enterprise appliance must +be running GitHub Enterprise 2.12.x or 2.13.x. You can't restore a snapshot from +2.10 to 2.13, because that's three releases ahead. [1]: https://www.gnu.org/software/bash/ [2]: https://git-scm.com/ @@ -40,3 +56,4 @@ Note: You can restore a snapshot that's at most two feature releases behind the [5]: https://en.wikipedia.org/wiki/Hard_link [6]: https://en.wikipedia.org/wiki/Symbolic_link [7]: https://en.wikipedia.org/wiki/Case_sensitivity +[8]: https://help.github.com/enterprise/admin/guides/installation/about-upgrade-requirements/ From 6bf275f734b7edf6f134086c6defe7419dca079f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 10:46:06 +0100 Subject: [PATCH 0547/2421] Update sample usage output --- docs/usage.md | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index fb6fb4cc5..cf502966e 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -16,34 +16,52 @@ The following assumes that `GHE_HOSTNAME` is set to "github.example.com" in Creating a backup snapshot: $ ghe-backup - Starting backup of github.example.com in snapshot 20140727T224148 - Connect github.example.com OK (v11.10.343) + Starting backup of github.example.com in snapshot 20180326T020444 + Connect github.example.com:122 OK (v2.13.0) Backing up GitHub settings ... Backing up SSH authorized keys ... Backing up SSH host keys ... Backing up MySQL database ... Backing up Redis database ... + Backing up audit log ... + Backing up hookshot logs ... Backing up Git repositories ... Backing up GitHub Pages ... + Backing up storage data ... + Backing up custom Git hooks ... Backing up Elasticsearch indices ... - Completed backup of github.example.com in snapshot 20140727T224148 at 23:01:58 + Completed backup of github.example.com:122 in snapshot 20180326T020444 at 02:05:12 + Checking for leaked ssh keys ... + * No leaked keys found Restoring from last successful snapshot to a newly provisioned GitHub Enterprise appliance at IP "5.5.5.5": $ ghe-restore 5.5.5.5 - Starting rsync restore of 5.5.5.5 from snapshot 20140727T224148 - Connect 5.5.5.5 OK (v11.10.343) - Enabling maintenance mode on 5.5.5.5 ... - Restoring Git repositories ... - Restoring GitHub Pages ... + Checking for leaked keys in the backup snapshot that is being restored ... + * No leaked keys found + Connect 5.5.5.5:122 OK (v2.13.0) + Starting restore of 5.5.5.5:122 from snapshot 20180326T020444 + Stopping cron and github-timerd ... + Restoring settings ... + Restoring license ... + Restoring management console password ... + Restoring CA certificates ... + --> Importing custom CA certificates... + Restoring UUID ... Restoring MySQL database ... + --> Importing MySQL data... Restoring Redis database ... + Restoring Git repositories and Gists ... + Restoring GitHub Pages ... Restoring SSH authorized keys ... + Restoring storage data ... + Restoring custom Git hooks ... Restoring Elasticsearch indices ... + Starting cron ... Restoring SSH host keys ... - Completed restore of 5.5.5.5 from snapshot 20140817T174152 - Visit https://5.5.5.5/setup/settings to configure the recovered appliance. + Completed restore of 5.5.5.5:122 from snapshot 20180326T020444 + Visit https://5.5.5.5/setup/settings to review appliance configuration. A different backup snapshot may be selected by passing the `-s` argument and the datestamp-named directory from the backup location. From 18bfe9a2228f046502b27f048a7438b9c7bd4a2d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 10:57:38 +0100 Subject: [PATCH 0548/2421] Use consistent and higher level headings --- docs/backup-snapshot-file-structure.md | 2 +- docs/docker.md | 14 +++++++------- docs/faq.md | 6 +++--- docs/getting-started.md | 2 +- docs/requirements.md | 8 ++++---- docs/usage.md | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/backup-snapshot-file-structure.md b/docs/backup-snapshot-file-structure.md index 55ab3637f..c4e90a508 100644 --- a/docs/backup-snapshot-file-structure.md +++ b/docs/backup-snapshot-file-structure.md @@ -1,4 +1,4 @@ -### Backup snapshot file structure +# Backup snapshot file structure Backup snapshots are stored in rotating increment directories named after the date and time the snapshot was taken. Each snapshot directory contains a full diff --git a/docs/docker.md b/docs/docker.md index 17b853bef..acfb354d6 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -1,12 +1,12 @@ -### Docker +# Docker -#### Building the image +## Building the image ``` docker build -t github/backup-utils . ``` -#### Setting configuration options at runtime +## Setting configuration options at runtime The `backup.config` file is dynamically populated at runtime with all `GHE_` environment variables that are part of the run command or Docker environment: @@ -36,7 +36,7 @@ $ docker run -it -e "GHE_BACKUP_CONFIG=/mnt/backup.config" \ github/backup-utils ghe-backup ``` -#### SSH Keys +## SSH Keys A SSH private key that has been added to the GitHub Enterprise [Management Console for administrative SSH access][1] needs to be mounted into the container from the @@ -54,7 +54,7 @@ $ docker run -it -e "GHE_HOSTNAME=hostname" \ github/backup-utils ghe-backup ``` -##### Using ssh-agent +### Using ssh-agent If your SSH private key is protected with a passphrase, you can mount the `ssh-agent` socket from the Docker host into the GitHub Enterprise backup utilities image. @@ -91,7 +91,7 @@ socket from the Docker host into the GitHub Enterprise backup utilities image. github/backup-utils ghe-backup ``` -#### Managing backup data +## Managing backup data Data persistence is achieved by using [Docker volumes][2], which are managed with [`docker volume` commands][3]. Prior to running the container for the first time, @@ -128,7 +128,7 @@ lrwxrwxrwx 1 root root 15 Oct 24 19:49 current -> 20171024T194 * Bind mounting a volume is supported, as long as the Docker host supports them and allows hard links. -#### Scheduling backups using crontab with Docker +## Scheduling backups using crontab with Docker Designed to be a "one shot" type container, scheduling backup runs with the Docker image is similar to the non-Docker scheduling. Run the container with all the same diff --git a/docs/faq.md b/docs/faq.md index 9110c46fc..cb70c5855 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,10 +1,10 @@ # Frequently Asked Questions -### How does backup utilities differ from a High Availability replica? +## How does backup utilities differ from a High Availability replica? It is recommended that both backup utilities and an [High Availability replica][1] are used as part of a GitHub Enterprise deployment but they serve different roles. -##### The purpose of the High Availability replica +### The purpose of the High Availability replica The High Availability replica is a fully redundant secondary GitHub Enterprise instance, kept in sync with the primary instance via replication of all major datastores. This active/passive cluster configuration is designed to minimize @@ -13,7 +13,7 @@ affecting the primary instance. Because some forms of data corruption or loss ma be replicated immediately from primary to replica, it is not a replacement for the backup utilities as part of your disaster recovery plan. -##### The purpose of the backup utilities +### The purpose of the backup utilities Backup utilities are a disaster recovery tool. This tool takes date-stamped snapshots of all major datastores. These snapshots are used to restore an instance to a prior state or set up a new instance without having another always-on GitHub diff --git a/docs/getting-started.md b/docs/getting-started.md index 6d3d80b65..00b953aa5 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,4 +1,4 @@ -### Getting started +# Getting started 1. [Download the latest release version][1] and extract the repository using `tar`: diff --git a/docs/requirements.md b/docs/requirements.md index fcd8b7ac6..7ad1534d4 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -1,9 +1,9 @@ -### Requirements +# Requirements The backup utilities should be run on a host dedicated to long-term permanent storage and must have network connectivity with the GitHub Enterprise appliance. -##### Backup host requirements +## Backup host requirements Backup host software requirements are modest: Linux or other modern Unix operating system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. @@ -14,7 +14,7 @@ requirements, or if Docker is your preferred platform. The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise. -##### Storage requirements +## Storage requirements Storage requirements vary based on current Git repository disk usage and growth patterns of the GitHub appliance. We recommend allocating at least 5x the amount @@ -27,7 +27,7 @@ must be written to a filesystem with support for symbolic and hard links. Using a [case sensitive][7] file system is also required to avoid conflicts. -##### GitHub Enterprise version requirements +## GitHub Enterprise version requirements Starting with backup utilities v2.13.0, version support is inline with that of the [GitHub Enterprise upgrade requirements][8] and as such, support is limited to diff --git a/docs/usage.md b/docs/usage.md index cf502966e..a247d124b 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -1,4 +1,4 @@ -### Using the backup and restore commands +# Using the backup and restore commands After the initial backup, use the following commands: @@ -8,7 +8,7 @@ After the initial backup, use the following commands: Enterprise appliance. You must add the backup host's SSH key to the target GitHub Enterprise appliance before using this command. -##### Example backup and restore usage +### Example backup and restore usage The following assumes that `GHE_HOSTNAME` is set to "github.example.com" in `backup.config`. From bd64469538ce2be7eb2743e62a66a681c2dccb72 Mon Sep 17 00:00:00 2001 From: Keeran Raj Hawoldar Date: Mon, 26 Mar 2018 13:49:43 +0100 Subject: [PATCH 0549/2421] Update post-restore messaging --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index ceef64f41..7d751b9e7 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -451,5 +451,5 @@ fi echo "Completed restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" if ! $cluster; then - echo "Visit https://$hostname/setup/settings to review appliance configuration." + echo "Visit https://$hostname/setup/settings to review appliance configuration. Settings must be applied to complete any necessary migrations." fi From d0a6ed1fed25c4de4535c22a81c2fbf1f13ef5cb Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 14:19:12 +0100 Subject: [PATCH 0550/2421] Add note to say saving settings is required --- docs/usage.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index a247d124b..7062f4325 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -70,7 +70,10 @@ The `ghe-backup` and `ghe-restore` commands also have a verbose output mode (`-v`) that lists files as they're being transferred. It's often useful to enable when output is logged to a file. -When restoring to an already configured GHE instance, settings, certificate, and license data +When restoring to a new GitHub Enterprise instance, settings, certificate, and license data +*are* restored. These settings must be reviewed and saved before using the GitHub Enterprise to ensure all migrations have taken place and all required services are started. + +When restoring to an already configured GitHub Enterprise instance, settings, certificate, and license data are *not* restored to prevent overwriting manual configuration on the restore host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`, forcing settings, certificate, and license data to be overwritten with the backup copy's data. From 1d76d63712d3c6a85aa1eb1d5596745b6ba33787 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 14:30:56 +0100 Subject: [PATCH 0551/2421] Use present tense --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 7062f4325..26f223ec7 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -71,7 +71,7 @@ The `ghe-backup` and `ghe-restore` commands also have a verbose output mode enable when output is logged to a file. When restoring to a new GitHub Enterprise instance, settings, certificate, and license data -*are* restored. These settings must be reviewed and saved before using the GitHub Enterprise to ensure all migrations have taken place and all required services are started. +*are* restored. These settings must be reviewed and saved before using the GitHub Enterprise to ensure all migrations take place and all required services are started. When restoring to an already configured GitHub Enterprise instance, settings, certificate, and license data are *not* restored to prevent overwriting manual configuration on the restore From faf0e0c02acd829c9e7f9c53149b96e12c73df60 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 14:31:47 +0100 Subject: [PATCH 0552/2421] Use recent timestamp --- docs/backup-snapshot-file-structure.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/backup-snapshot-file-structure.md b/docs/backup-snapshot-file-structure.md index c4e90a508..983c688c6 100644 --- a/docs/backup-snapshot-file-structure.md +++ b/docs/backup-snapshot-file-structure.md @@ -15,11 +15,11 @@ There are five snapshot directories, with the `current` symlink pointing to the most recent successful snapshot: ./data - |- 20140724T010000 - |- 20140725T010000 - |- 20140726T010000 - |- 20140727T010000 - |- 20140728T010000 + |- 20180124T010000 + |- 20180125T010000 + |- 20180126T010000 + |- 20180127T010000 + |- 20180128T010000 |- audit-log |- benchmarks |- elasticsearch @@ -40,7 +40,7 @@ most recent successful snapshot: |- strategy |- uuid |- version - |- current -> 20140728T010000 + |- current -> 20180128T010000 Note: the `GHE_DATA_DIR` variable set in `backup.config` can be used to change the disk location where snapshots are written. From e444a57690b32fbb5f04d028da2ebcb0da547e78 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 14:32:47 +0100 Subject: [PATCH 0553/2421] Wrap to ~80 chars --- docs/usage.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 26f223ec7..595075d2b 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -70,8 +70,10 @@ The `ghe-backup` and `ghe-restore` commands also have a verbose output mode (`-v`) that lists files as they're being transferred. It's often useful to enable when output is logged to a file. -When restoring to a new GitHub Enterprise instance, settings, certificate, and license data -*are* restored. These settings must be reviewed and saved before using the GitHub Enterprise to ensure all migrations take place and all required services are started. +When restoring to a new GitHub Enterprise instance, settings, certificate, and +license data *are* restored. These settings must be reviewed and saved before +using the GitHub Enterprise to ensure all migrations take place and all required +services are started. When restoring to an already configured GitHub Enterprise instance, settings, certificate, and license data are *not* restored to prevent overwriting manual configuration on the restore From 3ccea8130201acb96692cacd6c077e801d0a660f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 16:36:50 +0100 Subject: [PATCH 0554/2421] Update styleguides --- STYLEGUIDE.md | 59 +++++++++++++++++++++++++++++----------------- test/STYLEGUIDE.md | 9 ++++--- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index 9dd420bec..1bc669756 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -2,26 +2,26 @@ If you've not done much Bash development before you may find these debugging tips useful: http://wiki.bash-hackers.org/scripting/debuggingtips. --- +--- ##### Scripts must start with `#!/usr/bin/env bash` --- -##### Scripts must use `set -e` +--- +##### Scripts must use `set -o errexit -o nounset -o pipefail` If the return value of a command can be ignored, suffix it with `|| true`: ```bash -set -e +set -o errexit -o nounset -o pipefail command_that_might_fail || true command_that_should_not_fail ``` Note that ignoring an exit status with `|| true` is not a good practice though. Generally speaking, it's better to handle the error. --- +--- ##### Scripts should not check exit status via `$?` manually -Rely on `set -e` instead: +Rely on `set -o errexit` instead: ```bash cmd @@ -33,13 +33,13 @@ fi should be written as: ```bash -set -e +set -o errexit if cmd; then echo worked fi ``` --- +--- ##### Scripts must include a usage, description and optional examples Use this format: @@ -60,12 +60,12 @@ Use this format: #/ This will do foo and bar: #/ $ ghe-this-is-my-script --longopt foobar -c 2 #/ -set -e +set -o errexit -o nounset -o pipefail ``` If there are no options or required arguments, the `OPTIONS` section can be ignored. --- +--- ##### Customer-facing scripts must accept both -h and --help arguments They should also print the usage information and exit 2. @@ -77,7 +77,7 @@ For example: #/ Usage: ghe-this-is-my-script [options] #/ #/ This is a brief description of the script's purpose. -set -e +set -o errexit -o nounset -o pipefail if [ "$1" = "--help" -o "$1" = "-h" ]; then grep '^#/' <"$0" | cut -c 4- @@ -86,7 +86,7 @@ fi ``` --- +--- ##### Scripts should not use Bash arrays Main issues: @@ -94,7 +94,7 @@ Main issues: * Portability * Important bugs in Bash versions < 4.3 --- +--- ##### Scripts should use `test` or `[` whenever possible ```bash @@ -105,7 +105,7 @@ if [ "string" = "string" ]; then fi ``` --- +--- ##### Scripts may use `[[` for advanced bash features ```bash @@ -114,7 +114,7 @@ if [[ "$(hostname)" = *.iad.github.net ]]; then fi ``` --- +--- ##### Scripts may use Bash for loops Preferred: @@ -131,7 +131,7 @@ for ((n=0; n<10; n++)); do done ``` --- +--- ##### Scripts should use `$[x+y*z]` for mathematical expressions ```bash @@ -143,7 +143,7 @@ n=$((n+1)) n=$(($n+1)) ``` --- +--- ##### Scripts should use variables sparingly Short paths and other constants should be repeated liberally throughout code since they @@ -162,7 +162,7 @@ mkdir -p /data/user/db rsync /data/user/db remote:/data/user/db ``` --- +--- ##### Scripts should use lowercase variables for locals, and uppercase for variables inherited or exported via the environment ```bash @@ -175,7 +175,7 @@ export GIT_DIR=/data/repos/$nwo.git git rev-list ``` --- +--- ##### Scripts should use `${var}` for interpolation only when required ```bash @@ -184,7 +184,7 @@ echo $greeting echo ${greeting}world ``` --- +--- ##### Scripts should use functions sparingly, opting for small/simple/sequential scripts instead whenever possible When defining functions, use the following style: @@ -197,7 +197,7 @@ my_function() { } ``` --- +--- ##### Scripts should use `< Date: Mon, 26 Mar 2018 17:28:38 +0100 Subject: [PATCH 0555/2421] Implement shellcheck suggestions and overrides --- STYLEGUIDE.md | 2 +- bin/ghe-host-check | 3 ++- share/github-backup-utils/ghe-backup-config | 15 ++++++++----- .../ghe-backup-es-audit-log | 3 ++- .../ghe-backup-es-hookshot | 3 ++- share/github-backup-utils/ghe-backup-es-rsync | 3 ++- share/github-backup-utils/ghe-backup-fsck | 4 +++- .../github-backup-utils/ghe-backup-git-hooks | 7 +++--- share/github-backup-utils/ghe-backup-pages | 5 +++-- share/github-backup-utils/ghe-backup-redis | 3 ++- .../ghe-backup-repositories | 3 ++- share/github-backup-utils/ghe-backup-settings | 3 ++- share/github-backup-utils/ghe-backup-storage | 3 ++- .../ghe-backup-store-version | 3 ++- share/github-backup-utils/ghe-backup-strategy | 3 ++- share/github-backup-utils/ghe-backup-userdata | 7 +++--- share/github-backup-utils/ghe-cluster-nodes | 1 + share/github-backup-utils/ghe-gc-disable | 3 ++- share/github-backup-utils/ghe-gc-enable | 3 ++- .../ghe-maintenance-mode-status | 3 ++- share/github-backup-utils/ghe-prune-snapshots | 3 ++- .../ghe-restore-es-audit-log | 5 +++-- .../ghe-restore-es-hookshot | 5 +++-- .../github-backup-utils/ghe-restore-es-rsync | 3 ++- .../github-backup-utils/ghe-restore-git-hooks | 3 ++- share/github-backup-utils/ghe-restore-pages | 3 ++- .../ghe-restore-repositories | 3 ++- .../ghe-restore-repositories-gist | 3 ++- .../ghe-restore-repositories-rsync | 3 ++- .../github-backup-utils/ghe-restore-settings | 3 ++- .../ghe-restore-snapshot-path | 3 ++- share/github-backup-utils/ghe-restore-storage | 3 ++- .../github-backup-utils/ghe-restore-userdata | 3 ++- share/github-backup-utils/ghe-rsync | 3 ++- share/github-backup-utils/ghe-ssh-config | 5 +++-- test/test-docker-build.sh | 3 ++- test/test-ghe-backup-config.sh | 22 ++++++++++--------- test/test-ghe-backup.sh | 8 ++++--- test/test-ghe-cluster-nodes.sh | 3 ++- test/test-ghe-host-check.sh | 3 ++- test/test-ghe-prune-snapshots.sh | 15 +++++++------ test/test-ghe-restore.sh | 5 +++-- test/test-ghe-ssh-config.sh | 3 ++- test/test-ghe-ssh.sh | 5 +++-- test/testlib.sh | 3 ++- 45 files changed, 126 insertions(+), 75 deletions(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index 1bc669756..d1cadd66d 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -238,7 +238,7 @@ Use inline comments to disable specific tests, and explain why the test has been ```bash hexToAscii() { - # shellcheck disable=SC2059 - we need to interpret $1 as a formatted string + # shellcheck disable=SC2059 # $1 needs to be interpretted as a formatted string printf "\x$1" } ``` diff --git a/bin/ghe-host-check b/bin/ghe-host-check index e8c6557b4..d8f91a234 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -34,7 +34,8 @@ while true; do done # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" # Use the host provided on the command line if provided, or fallback on the # $GHE_HOSTNAME configured in backup.config when not present. diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 60fc39c63..b5e264980 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -35,6 +35,7 @@ else fi # Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage +# shellcheck disable=SC2120 # the script name is always referenced print_usage () { grep '^#/' <"$0" | cut -c 4- exit ${1:-1} @@ -52,7 +53,7 @@ fi # Add the bin and share/github-backup-utils dirs to PATH PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" - +# shellcheck source=share/github-backup-utils/bm.sh . $GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh # Save off GHE_HOSTNAME from the environment since we want it to override the @@ -66,6 +67,7 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ "$HOME/.github-backup-utils/backup.config" "/etc/github-backup-utils/backup.config"; do if [ -f "$f" ]; then GHE_BACKUP_CONFIG="$f" + # shellcheck disable=SC1090 # This is a user-supplied value that can't be predicted . "$GHE_BACKUP_CONFIG" config_found=true break @@ -140,6 +142,7 @@ export GHE_SNAPSHOT_TIMESTAMP # Set the current snapshot directory to /. This is where # all backups should be written for the current invocation. GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP" +export GHE_SNAPSHOT_DIR # The root filesystem location. This must be used so that tests can override # the root as a local directory location. @@ -235,10 +238,11 @@ ghe_remote_version_required () { # Parse a version string into major, minor and patch parts and echo. ghe_parse_version() { - local version_major=$(echo "${1#v}" | cut -f 1 -d .) - local version_minor=$(echo "$1" | cut -f 2 -d .) - local version_patch=$(echo "$1" | cut -f 3 -d .) - local version_patch=${version_patch%%[a-zA-Z]*} + local version_major version_minor version_patch + version_major=$(echo "${1#v}" | cut -f 1 -d .) + version_minor=$(echo "$1" | cut -f 2 -d .) + version_patch=$(echo "$1" | cut -f 3 -d .) + version_patch=${version_patch%%[a-zA-Z]*} echo "$version_major $version_minor $version_patch" } @@ -250,6 +254,7 @@ ghe_parse_version() { # Scripts use these variables to alter behavior based on what's supported on the # appliance version. ghe_parse_remote_version () { + # shellcheck disable=SC2046 # Word splitting is required to populate the variables read -r GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH <<<$(ghe_parse_version $1) export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH } diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 816ce960b..8bc942454 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index 034d336a3..eb54e5e45 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index b50c6859a..c73509584 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-fsck b/share/github-backup-utils/ghe-backup-fsck index 4f699a9b8..004abe412 100755 --- a/share/github-backup-utils/ghe-backup-fsck +++ b/share/github-backup-utils/ghe-backup-fsck @@ -5,7 +5,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" @@ -38,6 +39,7 @@ if [ ! -d "$sdir/repositories" ]; then exit 1 fi +# shellcheck disable=SC2044 # Snapshot and repository directory names are safe for find iteration. for repo in $(find $sdir/repositories/ -type d -name \*.git); do repos=$(($repos+1)) before_time=$(date +%s) diff --git a/share/github-backup-utils/ghe-backup-git-hooks b/share/github-backup-utils/ghe-backup-git-hooks index 5e9024590..d481c2426 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks +++ b/share/github-backup-utils/ghe-backup-git-hooks @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" @@ -73,11 +74,11 @@ rsync_git_hooks_data () { subdir="git-hooks/$subpath" link_path=".." while true; do - if [ $(dirname $subdir) = "." ]; then + if [ "$(dirname $subdir)" = "." ]; then break fi - if [ $(dirname $subdir) = "/" ]; then + if [ "$(dirname $subdir)" = "/" ]; then break fi diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index d3124408f..e6445c812 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" @@ -74,7 +75,7 @@ for hostname in $hostnames; do # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ - -e "ssh -q $opts -p 122 $ssh_config_file_opt -l $user" \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path='sudo -u git rsync' \ $link_dest \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/pages/" \ diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index a16d89908..2e7d7dfd4 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -9,7 +9,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 1b16d468e..c1b7f7833 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -32,7 +32,8 @@ set -e # # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index ffdd2e9af..859ad1f0a 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -4,7 +4,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 66a9eb215..7e32964f3 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -8,7 +8,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-store-version b/share/github-backup-utils/ghe-backup-store-version index 6148012c5..6faffff99 100755 --- a/share/github-backup-utils/ghe-backup-store-version +++ b/share/github-backup-utils/ghe-backup-store-version @@ -4,7 +4,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-strategy b/share/github-backup-utils/ghe-backup-strategy index f43918535..b9a919f3c 100755 --- a/share/github-backup-utils/ghe-backup-strategy +++ b/share/github-backup-utils/ghe-backup-strategy @@ -9,7 +9,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ ! -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata index 1f10bf209..97f71c1a9 100755 --- a/share/github-backup-utils/ghe-backup-userdata +++ b/share/github-backup-utils/ghe-backup-userdata @@ -6,7 +6,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" bm_start "$(basename $0) - $1" @@ -34,11 +35,11 @@ if [ -d "$GHE_DATA_DIR/current/$dirname" ] && [ "$(ls -A $GHE_DATA_DIR/current/$ subdir=$dirname link_path=".." while true; do - if [ $(dirname $subdir) = "." ]; then + if [ "$(dirname $subdir)" = "." ]; then break fi - if [ $(dirname $subdir) = "/" ]; then + if [ "$(dirname $subdir)" = "/" ]; then break fi diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index 75f6c0b4a..a4d29247b 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -11,6 +11,7 @@ set -e # Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Check if the REMOTE DATA USER directory is set diff --git a/share/github-backup-utils/ghe-gc-disable b/share/github-backup-utils/ghe-gc-disable index c233c4228..bf37572ca 100755 --- a/share/github-backup-utils/ghe-gc-disable +++ b/share/github-backup-utils/ghe-gc-disable @@ -9,7 +9,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" while true; do case "$1" in diff --git a/share/github-backup-utils/ghe-gc-enable b/share/github-backup-utils/ghe-gc-enable index 6dd3b6e48..ab705007a 100755 --- a/share/github-backup-utils/ghe-gc-enable +++ b/share/github-backup-utils/ghe-gc-enable @@ -9,7 +9,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" while true; do case "$1" in diff --git a/share/github-backup-utils/ghe-maintenance-mode-status b/share/github-backup-utils/ghe-maintenance-mode-status index 46f4c9a5a..4344dc916 100755 --- a/share/github-backup-utils/ghe-maintenance-mode-status +++ b/share/github-backup-utils/ghe-maintenance-mode-status @@ -4,7 +4,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Parse args while true; do diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index 366db8b4e..475f6b36e 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -4,7 +4,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Once we start pruning, this backup will no longer be valid. # So create or preserve its `incomplete` file and remove the diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index db460a4d0..03f0162f8 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ $# -lt 1 ] && print_usage @@ -19,7 +20,7 @@ GHE_HOSTNAME="$1" # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" -indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz) +indices=$(find -print0 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.gz 2>/dev/null | xargs -0 -I{} -n1 basename {} .gz) # Platform neutral and robust method of determining last month this_yr=$(date +"%Y") diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index 4d8a1b0fe..0c4c80b04 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ $# -lt 1 ] && print_usage @@ -21,7 +22,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1) -indices=$(ls -1 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz 2>/dev/null | xargs -I{} -n1 basename {} .gz) +indices=$(find -print0 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz 2>/dev/null | xargs -0 -I{} -n1 basename {} .gz) tmp_list="$(mktemp -t backup-utils-restore-XXXXXX)" if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then configured=true diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index da121f2d2..0c29beb0a 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/share/github-backup-utils/ghe-restore-git-hooks b/share/github-backup-utils/ghe-restore-git-hooks index eb28d48fd..b9c9555f0 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks +++ b/share/github-backup-utils/ghe-restore-git-hooks @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index e00731e65..40568af6e 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 3061fce8a..9dc22bd87 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index a27c13581..998dedbff 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/share/github-backup-utils/ghe-restore-repositories-rsync b/share/github-backup-utils/ghe-restore-repositories-rsync index 9dccda6c8..af758f95f 100755 --- a/share/github-backup-utils/ghe-restore-repositories-rsync +++ b/share/github-backup-utils/ghe-restore-repositories-rsync @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index fa6ccbc47..624a21f46 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -4,7 +4,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/share/github-backup-utils/ghe-restore-snapshot-path b/share/github-backup-utils/ghe-restore-snapshot-path index c860a0c64..b07594350 100755 --- a/share/github-backup-utils/ghe-restore-snapshot-path +++ b/share/github-backup-utils/ghe-restore-snapshot-path @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" if [ -n "$1" ]; then GHE_RESTORE_SNAPSHOT="$(basename "$1")" diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 6f9df40de..f7e9eecd8 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -8,7 +8,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage diff --git a/share/github-backup-utils/ghe-restore-userdata b/share/github-backup-utils/ghe-restore-userdata index 5d302e144..cfb8834d3 100755 --- a/share/github-backup-utils/ghe-restore-userdata +++ b/share/github-backup-utils/ghe-restore-userdata @@ -6,7 +6,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ $# -lt 2 ] && print_usage diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 402581a55..45cadda5e 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -8,7 +8,8 @@ set -o pipefail # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Filter vanished file warnings from both stdout (rsync versions < 3.x) and # stderr (rsync versions >= 3.x). The complex redirections are necessary to diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 16872a259..39247682a 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -8,7 +8,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage @@ -16,7 +17,7 @@ set -e GHE_HOSTNAME="$1" shift -hosts="$@" +hosts="$*" proxy_host=$(ssh_host_part "$GHE_HOSTNAME") proxy_port=$(ssh_port_part "$GHE_HOSTNAME") diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 54a057025..4d2e3a0cb 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -9,7 +9,8 @@ if ! docker ps >/dev/null 2>&1; then fi # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 4288cd941..21afceee7 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -2,7 +2,8 @@ # ghe-backup-config lib tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Setup backup snapshot data dir and remote repositories dir locations to use @@ -18,7 +19,8 @@ cd "$ROOTDIR" begin_test "ghe-backup-config GHE_DATA_DIR defined" ( set +e - GHE_DATA_DIR= error=$(. share/github-backup-utils/ghe-backup-config 2>&1) + GHE_DATA_DIR= + error=$(. share/github-backup-utils/ghe-backup-config 2>&1) # should exit 2 if [ $? != 2 ]; then exit 1 @@ -77,20 +79,20 @@ end_test begin_test "ghe-backup-config ssh_host_part" ( set -e - [ $(ssh_host_part "github.example.com") = "github.example.com" ] - [ $(ssh_host_part "github.example.com:22") = "github.example.com" ] - [ $(ssh_host_part "github.example.com:5000") = "github.example.com" ] - [ $(ssh_host_part "git@github.example.com:5000") = "git@github.example.com" ] + [ "$(ssh_host_part 'github.example.com')" = "github.example.com" ] + [ "$(ssh_host_part 'github.example.com:22')" = "github.example.com" ] + [ "$(ssh_host_part 'github.example.com:5000')" = "github.example.com" ] + [ "$(ssh_host_part 'git@github.example.com:5000')" = "git@github.example.com" ] ) end_test begin_test "ghe-backup-config ssh_port_part" ( set -e - [ $(ssh_port_part "github.example.com") = "22" ] - [ $(ssh_port_part "github.example.com:22") = "22" ] - [ $(ssh_port_part "github.example.com:5000") = "5000" ] - [ $(ssh_port_part "git@github.example.com:5000") = "5000" ] + [ "$(ssh_port_part 'github.example.com')" = "22" ] + [ "$(ssh_port_part 'github.example.com:22')" = "22" ] + [ "$(ssh_port_part 'github.example.com:5000')" = "5000" ] + [ "$(ssh_port_part 'git@github.example.com:5000')" = "5000" ] ) end_test diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index f31b44991..0a979a414 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -2,7 +2,8 @@ # ghe-backup command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Create the backup data dir and fake remote repositories dirs mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" @@ -58,7 +59,7 @@ begin_test "ghe-backup logs the benchmark" ghe-backup - [ $(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l) -gt 1 ] + [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] ) end_test @@ -70,7 +71,8 @@ begin_test "ghe-backup with relative data dir path" sleep 1 # generate a timestamp - export GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" + GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" + export GHE_SNAPSHOT_TIMESTAMP # change working directory to the root directory cd $ROOTDIR diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-nodes.sh index ea1ff568c..cdff8ad1e 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-nodes.sh @@ -2,7 +2,8 @@ # ghe-cluster-nodes command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index bfdeda1d2..eb95b8594 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -2,7 +2,8 @@ # ghe-host-check command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" begin_test "ghe-host-check" ( diff --git a/test/test-ghe-prune-snapshots.sh b/test/test-ghe-prune-snapshots.sh index 8a5c49481..a736134ae 100755 --- a/test/test-ghe-prune-snapshots.sh +++ b/test/test-ghe-prune-snapshots.sh @@ -2,11 +2,12 @@ # ghe-prune-snapshots command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # helper for generating dirs to clean up generate_prune_files() { - rm -rf "$GHE_DATA_DIR"/* + rm -rf "${GHE_DATA_DIR:?}"/* prune_file_num=${1:-10} for i in $(seq -f '%02g' 1 $prune_file_num); do mkdir -p "$GHE_DATA_DIR/$i" @@ -25,8 +26,8 @@ begin_test "ghe-prune-snapshots using default GHE_NUM_SNAPSHOTS" set -e generate_prune_files 12 ghe-prune-snapshots - [ $(ls -1d "$GHE_DATA_DIR"/[0-9]* | wc -l) -eq 10 ] - [ ! -d "$GHE_DATA_DIR/01" -a ! -d "$GHE_DATA_DIR/02" ] + [ "$(ls -1d "$GHE_DATA_DIR"/[0-9]* | wc -l)" -eq 10 ] + [ ! -d "$GHE_DATA_DIR/01" ] && [ ! -d "$GHE_DATA_DIR/02" ] ) end_test @@ -67,7 +68,7 @@ begin_test "ghe-prune-snapshots with expired snapshots" post_num_files=$(file_count_no_current) # make sure we have right number of files and right file is deleted - [ $post_num_files -eq 2 -a ! -f "$GHE_DATA_DIR/01" -a ! -f "$GHE_DATA_DIR/02" ] + [ $post_num_files -eq 2 ] && [ ! -f "$GHE_DATA_DIR/01" ] && [ ! -f "$GHE_DATA_DIR/02" ] ) end_test @@ -78,13 +79,13 @@ begin_test "ghe-prune-snapshots incomplete snapshot pruning" generate_prune_files 5 - [ $(file_count_no_current) -eq 5 ] + [ "$(file_count_no_current)" -eq 5 ] touch "$GHE_DATA_DIR/04/incomplete" GHE_NUM_SNAPSHOTS=5 ghe-prune-snapshots - [ $(file_count_no_current) -eq 4 ] + [ "$(file_count_no_current)" -eq 4 ] [ ! -d "$GHE_DATA_DIR/04" ] ) end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index ba7963b4f..dbe8f41de 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -2,7 +2,8 @@ # ghe-restore command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" setup_test_data "$GHE_DATA_DIR/1" @@ -47,7 +48,7 @@ begin_test "ghe-restore logs the benchmark" export BM_TIMESTAMP=foo export GHE_RESTORE_HOST=127.0.0.1 ghe-restore -v -f - [ $(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l) -gt 1 ] + [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] ) end_test diff --git a/test/test-ghe-ssh-config.sh b/test/test-ghe-ssh-config.sh index bfb22b6f4..7b0fc5bb6 100755 --- a/test/test-ghe-ssh-config.sh +++ b/test/test-ghe-ssh-config.sh @@ -2,6 +2,7 @@ # ghe-ssh command tests # Bring in testlib +# shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" begin_test "ghe-ssh-config returns config for multiple nodes" @@ -13,7 +14,7 @@ begin_test "ghe-ssh-config returns config for multiple nodes" echo "$output" | grep -Evq "^Host host1" # Confirm we have a host2 and host3 entry echo "$output" | grep -Eq "^Host git-server[12]" - [ $(echo "$output" | grep -E "^Host git-server[12]" | wc -l) = 2 ] + [ "$(echo "$output" | grep -E "^Host git-server[12]" | wc -l)" -eq 2 ] # Confirm the host2 and host3 entries proxy though host1 echo "$output" | grep -q "admin@host1 nc.openbsd" # Confirm multiplexing enabled diff --git a/test/test-ghe-ssh.sh b/test/test-ghe-ssh.sh index 3a74f7558..3122da949 100755 --- a/test/test-ghe-ssh.sh +++ b/test/test-ghe-ssh.sh @@ -2,7 +2,8 @@ # ghe-ssh command tests # Bring in testlib -. $(dirname "$0")/testlib.sh +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. @@ -33,7 +34,7 @@ begin_test "ghe-ssh complex command works" " output="$(echo "$comm" | ghe-ssh "$GHE_HOSTNAME" /bin/sh)" - [ $(echo "$output" | wc -l) -eq 2 ] + [ "$(echo "$output" | wc -l)" -eq 2 ] ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index 551b07851..1d0c8f2bb 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -47,7 +47,8 @@ export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the # remote version established above or in the environment. -. $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" ghe_parse_remote_version "$GHE_TEST_REMOTE_VERSION" ghe_remote_version_config "$GHE_TEST_REMOTE_VERSION" From 7d0ca70cd3df6d1d0f3dd5d6ff6ded81a6db5c08 Mon Sep 17 00:00:00 2001 From: Keeran Raj Hawoldar Date: Mon, 26 Mar 2018 17:33:55 +0100 Subject: [PATCH 0556/2421] Updated copy --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7d751b9e7..91f4ce226 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -448,8 +448,8 @@ else ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi -echo "Completed restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" +echo "Finished restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" if ! $cluster; then - echo "Visit https://$hostname/setup/settings to review appliance configuration. Settings must be applied to complete any necessary migrations." + echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." fi From 38719eccfc207e6a4d74fd35c1b9957b0fb96eb5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 26 Mar 2018 15:31:34 +0100 Subject: [PATCH 0557/2421] Update completion line --- docs/usage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 595075d2b..cc35f4ab7 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -60,8 +60,8 @@ appliance at IP "5.5.5.5": Restoring Elasticsearch indices ... Starting cron ... Restoring SSH host keys ... - Completed restore of 5.5.5.5:122 from snapshot 20180326T020444 - Visit https://5.5.5.5/setup/settings to review appliance configuration. + Restore of 5.5.5.5:122 from snapshot 20180326T020444 finished. + To complete the restore process, please visit https://5.5.5.5/setup/settings to review and save the appliance configuration. A different backup snapshot may be selected by passing the `-s` argument and the datestamp-named directory from the backup location. From ea67939142a674ee6c5979748529da2db0bc1ebe Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 27 Mar 2018 09:15:15 +0100 Subject: [PATCH 0558/2421] Clarify version req for 2.10 and earlier --- docs/getting-started.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 00b953aa5..a384d62d0 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -8,7 +8,10 @@ `git clone -b stable https://github.com/github/backup-utils.git` - 2. Copy the [`backup.config-example`][2] file to `backup.config` and modify as + **Note**: you will need to use [backup-utils v2.11.x][2] or the `legacy` branch to + backup and restore GitHub Enterprise 2.10 and earlier. + + 2. Copy the [`backup.config-example`][3] file to `backup.config` and modify as necessary. The `GHE_HOSTNAME` value must be set to the GitHub Enterprise host name. Additional options are available and documented in the configuration file but none are required for basic backup functionality. @@ -26,7 +29,7 @@ with the `-i ` SSH option. 3. Add the backup host's SSH key to the GitHub appliance as an *Authorized SSH - key*. See [Adding an SSH key for shell access][3] for instructions. + key*. See [Adding an SSH key for shell access][4] for instructions. 4. Run `bin/ghe-host-check` to verify SSH connectivity with the GitHub appliance. @@ -34,5 +37,6 @@ 5. Run `bin/ghe-backup` to perform an initial full backup. [1]: https://github.com/github/backup-utils/releases -[2]: https://github.com/github/enterprise-backup-site/blob/master/backup.config-example -[3]: https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access +[2]: https://github.com/github/backup-utils/releases/tag/v2.11.4 +[3]: https://github.com/github/enterprise-backup-site/blob/master/backup.config-example +[4]: https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access From 66b4262ac50cc7e70b69a5757d50a96767d44a1b Mon Sep 17 00:00:00 2001 From: Keeran Raj Hawoldar Date: Tue, 27 Mar 2018 09:35:48 +0100 Subject: [PATCH 0559/2421] Update copy --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 91f4ce226..a1f135139 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -448,7 +448,7 @@ else ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi -echo "Finished restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" +echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." if ! $cluster; then echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." From b1962eaaae5b4662ea246ab9fd34a9f74af3a59c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 27 Mar 2018 09:53:03 +0100 Subject: [PATCH 0560/2421] Capitalisation --- README.md | 8 ++++---- docs/README.md | 2 +- docs/docker.md | 2 +- docs/faq.md | 10 +++++----- docs/getting-started.md | 4 ++-- docs/requirements.md | 12 ++++++------ docs/scheduling-backups.md | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 95d44d582..227c22048 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ This repository includes backup and recovery utilities for [GitHub Enterprise][1]. **Note**: the [GitHub Enterprise version requirements](docs/requirements.md#github-enterprise-version-requirements) have -changed starting with backup utilities (backup-utils) v2.13.0. +changed starting with Backup Utilities (backup-utils) v2.13.0. ### Features -The backup utilities implement a number of advanced capabilities for backup +The Backup Utilities implement a number of advanced capabilities for backup hosts, built on top of the backup and restore features already included in GitHub Enterprise. @@ -36,12 +36,12 @@ GitHub Enterprise. - **[Using the backup and restore commands](docs/usage.md)** - **[Scheduling backups](docs/scheduling-backups.md)** - **[Backup snapshot file structure](docs/backup-snapshot-file-structure.md)** -- **[How does backup utilities differ from a High Availability replica?](docs/faq.md)** +- **[How does Backup Utilities differ from a High Availability replica?](docs/faq.md)** - **[Docker](docs/docker.md)** ### Support -If you find a bug or would like to request a feature in backup-utils, please +If you find a bug or would like to request a feature in Backup Utilities, please open an issue or pull request on this repository. If you have a question related to your specific GitHub Enterprise setup or would like assistance with backup site setup or recovery, please contact our [Enterprise support team][2] instead. diff --git a/docs/README.md b/docs/README.md index f126dea5c..db1d8a085 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,5 +8,5 @@ - **[Using the backup and restore commands](usage.md)** - **[Scheduling backups](scheduling-backups.md)** - **[Backup snapshot file structure](backup-snapshot-file-structure.md)** -- **[How does backup utilities differ from a High Availability replica?](faq.md)** +- **[How does Backup Utilities differ from a High Availability replica?](faq.md)** - **[Docker](docker.md)** diff --git a/docs/docker.md b/docs/docker.md index acfb354d6..ad3f11d77 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -57,7 +57,7 @@ github/backup-utils ghe-backup ### Using ssh-agent If your SSH private key is protected with a passphrase, you can mount the `ssh-agent` -socket from the Docker host into the GitHub Enterprise backup utilities image. +socket from the Docker host into the GitHub Enterprise Backup Utilities image. 1. Start the ssh-agent in the background. diff --git a/docs/faq.md b/docs/faq.md index cb70c5855..09bc3ebf7 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,7 +1,7 @@ # Frequently Asked Questions -## How does backup utilities differ from a High Availability replica? -It is recommended that both backup utilities and an [High Availability replica][1] +## How does Backup Utilities differ from a High Availability replica? +It is recommended that both Backup Utilities and an [High Availability replica][1] are used as part of a GitHub Enterprise deployment but they serve different roles. ### The purpose of the High Availability replica @@ -11,10 +11,10 @@ datastores. This active/passive cluster configuration is designed to minimize service disruption in the event of hardware failure or major network outage affecting the primary instance. Because some forms of data corruption or loss may be replicated immediately from primary to replica, it is not a replacement for -the backup utilities as part of your disaster recovery plan. +the Backup Utilities as part of your disaster recovery plan. -### The purpose of the backup utilities -Backup utilities are a disaster recovery tool. This tool takes date-stamped +### The purpose of the Backup Utilities +Backup Utilities are a disaster recovery tool. This tool takes date-stamped snapshots of all major datastores. These snapshots are used to restore an instance to a prior state or set up a new instance without having another always-on GitHub Enterprise instance (like the High Availability replica). diff --git a/docs/getting-started.md b/docs/getting-started.md index a384d62d0..d972b3df7 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -8,7 +8,7 @@ `git clone -b stable https://github.com/github/backup-utils.git` - **Note**: you will need to use [backup-utils v2.11.x][2] or the `legacy` branch to + **Note**: you will need to use [Backup Utilities v2.11.x][2] or the `legacy` branch to backup and restore GitHub Enterprise 2.10 and earlier. 2. Copy the [`backup.config-example`][3] file to `backup.config` and modify as @@ -16,7 +16,7 @@ host name. Additional options are available and documented in the configuration file but none are required for basic backup functionality. - * backup-utils will attempt to load the backup configuration from the following + * Backup Utilities will attempt to load the backup configuration from the following locations, in this order: ``` diff --git a/docs/requirements.md b/docs/requirements.md index 7ad1534d4..4d8bba62b 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -1,6 +1,6 @@ # Requirements -The backup utilities should be run on a host dedicated to long-term permanent +The Backup Utilities should be run on a host dedicated to long-term permanent storage and must have network connectivity with the GitHub Enterprise appliance. ## Backup host requirements @@ -29,18 +29,18 @@ Using a [case sensitive][7] file system is also required to avoid conflicts. ## GitHub Enterprise version requirements -Starting with backup utilities v2.13.0, version support is inline with that of the +Starting with Backup Utilities v2.13.0, version support is inline with that of the [GitHub Enterprise upgrade requirements][8] and as such, support is limited to three versions of GitHub Enterprise: the version that corresponds with the version -of backup utilities, and the two releases prior to it. +of Backup Utilities, and the two releases prior to it. -For example, backup utilities v2.13.0 can be used to backup and restore all patch +For example, Backup Utilities v2.13.0 can be used to backup and restore all patch releases from 2.11.0 to the latest patch release of GitHub Enterprise 2.13. -Backup utilities v2.14.0 will be released when GitHub Enterprise 2.14.0 is release +Backup Utilities v2.14.0 will be released when GitHub Enterprise 2.14.0 is released and will then be used to backup all releases of GitHub Enterprise from 2.12.0 to the latest patch release of GitHub Enterprise 2.14. -Backup utilities v2.11.4 and earlier offer support for GitHub Enterprise 2.10 +Backup Utilities v2.11.4 and earlier offer support for GitHub Enterprise 2.10 and earlier releases. **Note**: You can restore a snapshot that's at most two feature releases behind diff --git a/docs/scheduling-backups.md b/docs/scheduling-backups.md index 8272a7913..8d291021a 100644 --- a/docs/scheduling-backups.md +++ b/docs/scheduling-backups.md @@ -7,7 +7,7 @@ hourly backups at the least. ## Example scheduling usage -The following examples assume the backup utilities are installed under +The following examples assume the Backup Utilities are installed under `/opt/backup-utils`. The crontab entry should be made under the same user that manual backup/recovery commands will be issued under and must have write access to the configured `GHE_DATA_DIR` directory. From 9432a3de77141a20173664f9e8e299f048ea9da1 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 27 Mar 2018 10:06:11 +0100 Subject: [PATCH 0561/2421] =?UTF-8?q?Words=20and=20=F0=9F=92=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 17 ++--------------- docs/faq.md | 4 ++-- docs/requirements.md | 4 ++-- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 227c22048..1db2f5a6c 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ This repository includes backup and recovery utilities for [GitHub Enterprise][1]. **Note**: the [GitHub Enterprise version requirements](docs/requirements.md#github-enterprise-version-requirements) have -changed starting with Backup Utilities (backup-utils) v2.13.0. +changed starting with Backup Utilities v2.13.0. ### Features -The Backup Utilities implement a number of advanced capabilities for backup +Backup Utilities implement a number of advanced capabilities for backup hosts, built on top of the backup and restore features already included in GitHub Enterprise. @@ -48,16 +48,3 @@ site setup or recovery, please contact our [Enterprise support team][2] instead. [1]: https://enterprise.github.com [2]: https://enterprise.github.com/support/ - - - - - - - - -[6]: https://enterprise.github.com/help/articles/upgrading-to-a-newer-release -[8]: https://enterprise.github.com/help/articles/backing-up-enterprise-data -[9]: https://enterprise.github.com/help/articles/restoring-enterprise-data -[10]: https://help.github.com/enterprise/2.0/admin-guide/migrating-to-a-different-platform-or-from-github-enterprise-11-10-34x/ -[11]: https://help.github.com/enterprise/2.0/admin-guide/ diff --git a/docs/faq.md b/docs/faq.md index 09bc3ebf7..7fa7f7e0d 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -11,9 +11,9 @@ datastores. This active/passive cluster configuration is designed to minimize service disruption in the event of hardware failure or major network outage affecting the primary instance. Because some forms of data corruption or loss may be replicated immediately from primary to replica, it is not a replacement for -the Backup Utilities as part of your disaster recovery plan. +Backup Utilities as part of your disaster recovery plan. -### The purpose of the Backup Utilities +### The purpose of Backup Utilities Backup Utilities are a disaster recovery tool. This tool takes date-stamped snapshots of all major datastores. These snapshots are used to restore an instance to a prior state or set up a new instance without having another always-on GitHub diff --git a/docs/requirements.md b/docs/requirements.md index 4d8bba62b..9bce50087 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -1,6 +1,6 @@ # Requirements -The Backup Utilities should be run on a host dedicated to long-term permanent +Backup Utilities should be run on a host dedicated to long-term permanent storage and must have network connectivity with the GitHub Enterprise appliance. ## Backup host requirements @@ -21,7 +21,7 @@ patterns of the GitHub appliance. We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time. -The backup utilities use [hard links][5] to store data efficiently, and the +Backup Utilities use [hard links][5] to store data efficiently, and the repositories on GitHub Enterprise use [symbolic links][6] so the backup snapshots must be written to a filesystem with support for symbolic and hard links. From 56eca521a1bc94a3981592dfadc1fa27d96e182b Mon Sep 17 00:00:00 2001 From: Keeran Raj Hawoldar Date: Tue, 27 Mar 2018 10:41:42 +0100 Subject: [PATCH 0562/2421] Prompt to save settings on fresh instances --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index a1f135139..54a52b5e5 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -450,6 +450,6 @@ fi echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." -if ! $cluster; then +if ! $instance_configured; then echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." fi From 9e4a1a27e833ac0662497169abe2e7d7536206e4 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 27 Mar 2018 19:39:33 +1100 Subject: [PATCH 0563/2421] Test the missing directories case Simulates an appliance with a network, gist, and storage object that exists in the database, but not on disk. --- test/test-ghe-backup.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 14c1f1ca7..6ae3aa851 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -298,3 +298,23 @@ begin_test "ghe-backup cluster" verify_all_backedup_data ) end_test + +begin_test "ghe-backup missing directories or files on source appliance" +( + # Tests the scenario where something exists in the database, but not on disk. + set -e + + rm -rf $GHE_REMOTE_DATA_USER_DIR/repositories/1 + rm -rf $GHE_REMOTE_DATA_USER_DIR/storage/e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244 + + if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then + cat "$TRASHDIR/backup-out" + : ghe-backup should have completed successfully + false + fi + + cat "$TRASHDIR/backup-out" + + verify_all_backedup_data +) +end_test From f540496754c0f7353bcba32aac8b306a6c47c7a0 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 27 Mar 2018 06:20:18 -0700 Subject: [PATCH 0564/2421] Bump version: 2.11.4 [ci skip] --- debian/changelog | 7 +++++++ share/github-backup-utils/version | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 15d9c87af..4a70609f2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.11.4) UNRELEASED; urgency=medium + + * Move check for git for ssh muxing into ghe-ssh #378 + * Make it clear the settings need to be applied after restoring to an unconfigured instance #381 + + -- Colin Seymour Tue, 27 Mar 2018 13:20:18 +0000 + github-backup-utils (2.11.3) UNRELEASED; urgency=medium * Update argument parsing and help/usage consistency #320 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 22e3b6b01..7cd5929f9 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.11.3 +2.11.4 From 18492f0a9e0ba5cc64f7bca51b52f9dca7a6a842 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 27 Mar 2018 15:28:28 +0100 Subject: [PATCH 0565/2421] Add date --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1db2f5a6c..7a52da634 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository includes backup and recovery utilities for [GitHub Enterprise][1]. **Note**: the [GitHub Enterprise version requirements](docs/requirements.md#github-enterprise-version-requirements) have -changed starting with Backup Utilities v2.13.0. +changed starting with Backup Utilities v2.13.0, released on 27 March 2018. ### Features From 791cb21dbf27e9fb7b470c1ee42fa7486f4f2524 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 27 Mar 2018 16:51:07 +0100 Subject: [PATCH 0566/2421] Require a min version if a .0 release --- script/release | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/script/release b/script/release index 7e8333075..d2b72fee6 100755 --- a/script/release +++ b/script/release @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -#/ Usage: release [--dry-run] +#/ Usage: release [--dry-run] [min_version] #/ #/ Publish a backup-utils release: #/ * Updates the package changelog @@ -17,6 +17,7 @@ #/ * Export GH_OWNER and GH_REPO if you want to use a different owner/repo #/ * Only pull requests labeled with bug, feature or enhancement will show up in the #/ release page and the changelog. +#/ * If this is a X.Y.0 release, a minimum supported version needs to be supplied too. #/ require 'json' require 'net/http' @@ -192,13 +193,19 @@ def release_available?(tag_name) false end -def bump_version(new_version, path = 'share/github-backup-utils/version') +def bump_version(new_version, min_version = nil, path = 'share/github-backup-utils/version') current_version = Gem::Version.new(File.read(path).strip.chomp) if Gem::Version.new(new_version) < current_version raise "New version should be newer than #{current_version}" end File.open("#{path}.new", 'w') { |f| f.puts new_version } File.rename("#{path}.new", path) + + unless min_version.nil? + content = File.read('bin/ghe-host-check') + new_content = content.gsub(/supported_minimum_version="[0-9]\.[0-9]+\.0"/, "supported_minimum_version=\"#{min_version}\"") + File.open('bin/ghe-host-check', 'w') {|file| file.puts new_content } + end end def push_release_branch(version) @@ -336,14 +343,17 @@ if $PROGRAM_NAME == __FILE__ args.delete '--no-warn' end - raise 'Usage: release [--dry-run] ' if args.empty? + raise 'Usage: release [--dry-run] [min_version]' if args.empty? begin version = Gem::Version.new(args[0]) + min_version = args[1] ? args[1] : nil rescue ArgumentError raise "Error parsing version #{args[0]}" end + raise "Minimum supported version is required for X.Y.0 releases\n\nUsage: release [--dry-run] [min_version]" if /[0-9]\.[0-9]+\.0/ =~ version.to_s && min_version.nil? + raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" unless repo_exists? raise 'GH_AUTHOR environment variable is not set' if GH_AUTHOR.nil? @@ -356,6 +366,7 @@ if $PROGRAM_NAME == __FILE__ if dry_run puts "Existing release?: #{release_a}" puts "New version: #{version}" + puts "Min version: #{min_version}" unless min_version.nil? puts "Owner: #{GH_OWNER}" puts "Repo: #{GH_REPO}" puts "Author: #{GH_AUTHOR}" From 7633bf7f8caba837878b8dee608e6abc9f09f1a2 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 27 Mar 2018 16:51:49 +0100 Subject: [PATCH 0567/2421] Move bump_version earlier and add diff to dry run This allows use to check and ensure the only files changed during the release are those we expect. --- script/release | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/script/release b/script/release index d2b72fee6..5af7570ed 100755 --- a/script/release +++ b/script/release @@ -363,6 +363,9 @@ if $PROGRAM_NAME == __FILE__ release_a = false release_a = release_available? "v#{version}" + puts "Bumping version to #{version}..." + bump_version version, min_version + if dry_run puts "Existing release?: #{release_a}" puts "New version: #{version}" @@ -377,6 +380,10 @@ if $PROGRAM_NAME == __FILE__ else release_changes.each { |c| puts " * #{c}" } end + puts "Changes:" + puts `git diff` + `git checkout -- share/github-backup-utils/version` + `git checkout -- bin/ghe-host-check` exit end @@ -393,9 +400,6 @@ if $PROGRAM_NAME == __FILE__ raise out end - puts "Bumping version to #{version}..." - bump_version version - puts 'Updating changelog...' update_changelog release_changes, DEB_PKG_NAME, version release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}" From c988bf17642562fab49214cc1f6e3b8e769f30d5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 27 Mar 2018 16:53:49 +0100 Subject: [PATCH 0568/2421] Use colour to highlight changes --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index 5af7570ed..c8421121b 100755 --- a/script/release +++ b/script/release @@ -381,7 +381,7 @@ if $PROGRAM_NAME == __FILE__ release_changes.each { |c| puts " * #{c}" } end puts "Changes:" - puts `git diff` + puts `git diff --color` `git checkout -- share/github-backup-utils/version` `git checkout -- bin/ghe-host-check` exit From a067ff8fd000477b66c30ca52a90b98a40fc6036 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 27 Mar 2018 09:01:43 -0700 Subject: [PATCH 0569/2421] Bump version: 2.13.0 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 4a70609f2..e982511da 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.13.0) UNRELEASED; urgency=medium + + * Unify the backup & restore process #375 + + -- Colin Seymour Tue, 27 Mar 2018 16:01:43 +0000 + github-backup-utils (2.11.4) UNRELEASED; urgency=medium * Move check for git for ssh muxing into ghe-ssh #378 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 7cd5929f9..fb2c0766b 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.11.4 +2.13.0 From fcdc8207c2594cea89be4ed116220714daddb6ae Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Wed, 28 Mar 2018 10:51:12 -0700 Subject: [PATCH 0570/2421] Output backup utils version on backup and restore --- bin/ghe-backup | 4 ++-- bin/ghe-restore | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index ba980262e..0236b7181 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -106,7 +106,7 @@ fi echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress -echo "Starting backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP" +echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" # Perform a host connection check and establish the remote appliance version. # The version is available in the GHE_REMOTE_VERSION variable and also written @@ -115,7 +115,7 @@ ghe_remote_version_required echo "$GHE_REMOTE_VERSION" > version # Log backup start message in /var/log/syslog on remote instance -ghe_remote_logger "Starting backup from $(hostname) in snapshot $GHE_SNAPSHOT_TIMESTAMP ..." +ghe_remote_logger "Starting backup from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP ..." export GHE_BACKUP_STRATEGY=${GHE_BACKUP_STRATEGY:-$(ghe-backup-strategy)} diff --git a/bin/ghe-restore b/bin/ghe-restore index ed757942f..4ca86fe70 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -181,8 +181,8 @@ if $instance_configured && ! $force; then fi # Log restore start message locally and in /var/log/syslog on remote instance -echo "Starting restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT" -ghe_remote_logger "Starting restore from $(hostname) / snapshot $GHE_RESTORE_SNAPSHOT ..." +echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" +ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Keep other processes on the VM or cluster in the loop about the restore status. # From cceee89833eb5168b26a4b638d2ec011088fc839 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 29 Mar 2018 15:49:39 +0100 Subject: [PATCH 0571/2421] Update releasing process --- RELEASING.md | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index c6794468a..9cf13bce4 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,14 +1,32 @@ -# Making a backup-utils release +# Making a Backup Utilities release -## Automatic Process from chatops (internal to GitHub only) +Starting with Backup Utilities v2.13.0, all major releases will follow GitHub Enterprise releases and the version support is inline with that of the [GitHub Enterprise upgrade requirements](https://help.github.com/enterprise/admin/guides/installation/about-upgrade-requirements/) and as such, support is limited to three versions of GitHub Enterprise: the version that corresponds with the version of Backup Utilities, and the two releases prior to it. -1. `.ghe backup-utils-release 2.12.0` +For example, Backup Utilities 2.13.0 can be used to backup and restore all patch releases from 2.11.0 to the latest patch release of GitHub Enterprise 2.13. Backup utilities 2.14.0 will be released when GitHub Enterprise 2.14.0 is released and will then be used to backup all releases of GitHub Enterprise from 2.12.0 to the latest patch release of GitHub Enterprise 2.14. + +There is no need to align Backup Utilities patch releases with GitHub Enterprise patch releases. + +When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise that that release supports. + +## Automatic Process from chatops (internal to GitHub only) - Coming :soon: + +### Feature release: + +1. `.ghe backup-utils-release 2.13.0 2.11.0` + +### Patch release: + +1. `.ghe backup-utils-release 2.13.1` ## Automatic Process from CLI 1. Install the Debian `devscripts` package: `sudo apt-get install devscripts` -2. Run `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.12.0` +2. Run... + - Feature release: + `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.0 2.11.0` + - Patch release: + `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.1` ## Manual Process @@ -17,12 +35,13 @@ In the event you can't perform the automatic process, or a problem is encountere 1. Install the Debian `devscripts` package: `sudo apt-get install devscripts` 2. Add a new version and release notes to the `debian/changelog` file: - `dch --newversion 2.12.0 --release-heuristic log` + `dch --newversion 2.13.0 --release-heuristic log` You can use `make pending-prs` to craft the release notes. -3. Rev the `share/github-backup-utils/version` file. -4. Tag the release: `git tag v2.12.0` -5. Build that tarball package: `make dist` -6. Build the deb package: `make deb`. All the tests should pass. -7. Draft a new release at https://github.com/github/backup-utils/releases, including the release notes and attaching the tarball and deb packages. - The dist tarball you should upload has the revision in the file name, i.e. something like `github-backup-utils-v2.12.0.tar.gz` -8. Push the head of the release to the 'stable' branch. +3. Rev the `share/github-backup-utils/version` file. If this is a feature release, update `supported_minimum_version=` in `bin/ghe-host-check` too. +4. Commit your changes. +5. Tag the release: `git tag v2.13.0` +6. Build that tarball package: `make dist` +7. Build the deb package: `make deb`. All the tests should pass. +8. Draft a new release at https://github.com/github/backup-utils/releases, including the release notes and attaching the tarball and deb packages. + The dist tarball you should upload has the revision in the file name, i.e. something like `github-backup-utils-v2.13.0.tar.gz` +9. Push the head of the release to the 'stable' branch. From 405e6af67e0d1eb74a0a7916c4298e9803551e9a Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 29 Mar 2018 15:53:22 +0100 Subject: [PATCH 0572/2421] Formatting --- RELEASING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 9cf13bce4..da56aff57 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -12,20 +12,20 @@ When making a `.0` release, you will need to specify the minimum supported versi ### Feature release: -1. `.ghe backup-utils-release 2.13.0 2.11.0` +`.ghe backup-utils-release 2.13.0 2.11.0` ### Patch release: -1. `.ghe backup-utils-release 2.13.1` +`.ghe backup-utils-release 2.13.1` ## Automatic Process from CLI 1. Install the Debian `devscripts` package: `sudo apt-get install devscripts` 2. Run... - - Feature release: + - Feature release: `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.0 2.11.0` - - Patch release: + - Patch release: `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.1` ## Manual Process From 9c4ec0a99b7aa1ef9ac5203dd841fc774bddcf7a Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 29 Mar 2018 18:06:29 +0100 Subject: [PATCH 0573/2421] More shellcheck improvements --- script/cibuild | 2 +- share/github-backup-utils/bm.sh | 11 ++++++----- share/github-backup-utils/ghe-ssh | 5 ++++- test/bin/curl | 2 +- test/bin/ssh | 3 --- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/script/cibuild b/script/cibuild index e0e1e6ead..8351c9c60 100755 --- a/script/cibuild +++ b/script/cibuild @@ -20,7 +20,7 @@ for version in $REMOTE_VERSIONS do echo "==> Running testsuite with GHE_TEST_REMOTE_VERSION=$version" export GHE_TEST_REMOTE_VERSION="$version" - if ! ls -1 test/test-*.sh | xargs -P 4 -n 1 /bin/bash; then + if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then res=false fi echo diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 554d338a9..a47241c71 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -11,12 +11,12 @@ # wget request took 2s bm_desc_to_varname(){ - echo "__bm$(echo $@ | tr -cd '[[:alnum:]]')" + echo "__bm$(echo "$@" | tr -cd '[[:alnum:]]')" } bm_start() { - eval "$(bm_desc_to_varname $@)_start=$(date +%s)" + eval "$(bm_desc_to_varname "$@")_start=$(date +%s)" bm_init > /dev/null } @@ -34,7 +34,7 @@ bm_init() { export BM_FILE_PATH=$GHE_SNAPSHOT_DIR/benchmarks/$logfile fi - mkdir -p $(dirname $BM_FILE_PATH) + mkdir -p "$(dirname $BM_FILE_PATH)" echo $BM_FILE_PATH } @@ -44,8 +44,9 @@ bm_end() { exit 1 fi - local tend=$(date +%s) - local tstart=$(eval "echo \$$(bm_desc_to_varname $@)_start") + local tend tstart + tend=$(date +%s) + tstart=$(eval "echo \$$(bm_desc_to_varname "$@")_start") echo "$1 took $(($tend - $tstart))s" >> $BM_FILE_PATH } diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 7bca36519..5e63777bb 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -56,7 +56,7 @@ opts="-l $user $opts" # Bail out with error if the simple command form is used with complex commands. # Complex -if echo "$*" | grep "[|;]" >/dev/null || [ $(echo "$*" | wc -l) -gt 1 ]; then +if echo "$*" | grep "[|;]" >/dev/null || [ "$(echo "$*" | wc -l)" -gt 1 ]; then echo "fatal: ghe-ssh: Attempt to invoke complex command with simple command form." 1>&2 echo "See ghe-ssh --help for more on correcting." 1>&2 exit 1 @@ -69,9 +69,11 @@ fi if [ -z "$GHE_DISABLE_SSH_MUX" ]; then controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | git hash-object --stdin | cut -c 1-8)" + # shellcheck disable=SC2089 # We don't use bash arrays opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 if ! [ -S $controlpath ]; then + # shellcheck disable=SC2090 # We don't need the quote/backslashes respected ( cd "$TMPDIR" && ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true ) fi fi @@ -82,6 +84,7 @@ $GHE_VERBOSE_SSH && set -x # Exec ssh command with modified host / port args and add nice to command. if [ -z "$cleanup_mux" ]; then # Exec ssh command with modified host / port args and add nice to command. + # shellcheck disable=SC2090 # We don't need the quote/backslashes respected exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" elif [ -z "$GHE_DISABLE_SSH_MUX" ]; then while ssh -O check -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1; do diff --git a/test/bin/curl b/test/bin/curl index 9cc74bb4f..9d52f6fe7 100755 --- a/test/bin/curl +++ b/test/bin/curl @@ -15,7 +15,7 @@ fi echo "$@" # Read from stdin and write to stdout when "-d @-" given. -for a in "$@"; do +for _ in "$@"; do if [ "$1" = "@-" ]; then cat fi diff --git a/test/bin/ssh b/test/bin/ssh index 1e44a725e..28e95ea49 100755 --- a/test/bin/ssh +++ b/test/bin/ssh @@ -27,9 +27,6 @@ while true; do host="$1" shift ;; - '') - break - ;; esac done From fdf8e4cd04232e05a6912c46461bc2ac0ba66cba Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 29 Mar 2018 18:21:01 +0100 Subject: [PATCH 0574/2421] Add a shellcheck test --- test/test-shellcheck.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 test/test-shellcheck.sh diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh new file mode 100755 index 000000000..969bbee50 --- /dev/null +++ b/test/test-shellcheck.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +BASE_PATH=$(cd "$(dirname "$0")/../" && pwd) + +# Bring in testlib +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" + +begin_test "shellcheck: reports no errors or warnings" +( + set -e + if ! type shellcheck 1>/dev/null 2>&1; then + echo "ShellCheck not installed." + skip_test + fi + + results=$(mktemp $TRASHDIR/shellcheck.XXXXXX) + + # Check all executable scripts checked into the repo + cd $BASE_PATH + git ls-tree -r HEAD | grep -E '^1007|.*\..*sh$' | awk '{print $4}' | while read -r script; do + if head -n1 "$script" | grep -E -w "sh|bash" >/dev/null 2>&1; then + shellcheck -a -f gcc $script 2>&1 | grep -v ": note:" >> $results || true + fi + done + cd - + + [ "$(cat $results | wc -l)" -eq 0 ] || { + echo "ShellCheck errors found: " + cat $results + exit 1 + } +) +end_test From e5eab87e1065a53361d9081b75c2c27a973c47a6 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 29 Mar 2018 18:26:31 +0100 Subject: [PATCH 0575/2421] Add elapsed time to test results --- test/testlib.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index 1d0c8f2bb..c3eac6ac0 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -135,6 +135,7 @@ begin_test () { # allow the subshell to exit non-zero without exiting this process set -x +e + before_time=$(date '+%s') } report_failure () { @@ -153,15 +154,17 @@ report_failure () { # Mark the end of a test. end_test () { test_status="${1:-$?}" + after_time=$(date '+%s') + elapsed_time=$((after_time - before_time)) set +x -e exec 1>&3 2>&4 if [ "$test_status" -eq 0 ]; then - printf "test: %-60s OK\\n" "$test_description ..." + printf "test: %-65s OK (${elapsed_time}s)\\n" "$test_description ..." elif [ "$test_status" -eq 254 ]; then - printf "test: %-60s SKIPPED\\n" "$test_description ..." + printf "test: %-65s SKIPPED\\n" "$test_description ..." else - report_failure "FAILED" "$test_description ..." + report_failure "FAILED (${elapsed_time}s)" "$test_description ..." fi unset test_description From 0f7393f719863c641839e60e131050770f033e34 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 29 Mar 2018 18:37:12 +0100 Subject: [PATCH 0576/2421] Don't worry about unset for the mo --- STYLEGUIDE.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index d1cadd66d..6b007af2c 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -6,12 +6,12 @@ If you've not done much Bash development before you may find these debugging tip ##### Scripts must start with `#!/usr/bin/env bash` --- -##### Scripts must use `set -o errexit -o nounset -o pipefail` +##### Scripts must use `set -o errexit -o pipefail` If the return value of a command can be ignored, suffix it with `|| true`: ```bash -set -o errexit -o nounset -o pipefail +set -o errexit -o pipefail command_that_might_fail || true command_that_should_not_fail ``` @@ -60,7 +60,7 @@ Use this format: #/ This will do foo and bar: #/ $ ghe-this-is-my-script --longopt foobar -c 2 #/ -set -o errexit -o nounset -o pipefail +set -o errexit -o pipefail ``` If there are no options or required arguments, the `OPTIONS` section can be ignored. @@ -77,7 +77,7 @@ For example: #/ Usage: ghe-this-is-my-script [options] #/ #/ This is a brief description of the script's purpose. -set -o errexit -o nounset -o pipefail +set -o errexit -o pipefail if [ "$1" = "--help" -o "$1" = "-h" ]; then grep '^#/' <"$0" | cut -c 4- From 1e6570c4e59b379dc5446e0c4b4f656564266bf8 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 27 Mar 2018 19:38:42 +1100 Subject: [PATCH 0577/2421] Ignore missing files and directories on source --- .../github-backup-utils/ghe-backup-repositories | 2 ++ share/github-backup-utils/ghe-backup-storage | 1 + share/github-backup-utils/ghe-rsync | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 1b16d468e..79b253202 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -153,6 +153,7 @@ rsync_repository_data () { --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ --files-from="$files_list" \ + --ignore-missing-args \ "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ "$backup_dir" 1>&3 else @@ -162,6 +163,7 @@ rsync_repository_data () { $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --include-from=- --exclude=\* \ + --ignore-missing-args \ "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ "$backup_dir" 1>&3 fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index efdf9faf6..813827c25 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -116,6 +116,7 @@ for file_list in $tempdir/*.rsync; do $link_dest "$@" \ --rsync-path='sudo -u git rsync' \ --files-from="$file_list" \ + --ignore-missing-args \ --size-only \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ "$backup_dir" 1>&3 & diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index de4f71c7c..c194fcb1a 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -14,14 +14,26 @@ set -o pipefail # stderr (rsync versions >= 3.x). The complex redirections are necessary to # filter stderr while also keeping stdout and stderr separated. IGNOREOUT='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' + +# Remove --ignore-missing-args argument if using an earlier version of rsync. +if [[ $GHE_EXTRA_RSYNC_OPTS == *"--ignore-missing-args"* ]] && ! rsync -h | grep -q '\-\-ignore-missing-args'; then + GHE_EXTRA_RSYNC_OPTS=${GHE_EXTRA_RSYNC_OPTS//--ignore-missing-args/} + ignore23=1 +fi + (rsync "${@}" $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | (egrep -v "$IGNOREOUT" || true)) 3>&1 1>&2 2>&3 3>&- | (egrep -v "$IGNOREOUT" || true) res=$? -# rsync exits with 24 when vanished files are detected. +# Suppress exits with 24. if [ $res = 24 ]; then - res=0 + res=0 +fi + +# Suppress exits with 23 if --ignore-missing-args was unavailable. +if [ $res = 23 ] && [ -n "$ignore23" ]; then + res=0 fi exit $res From 3c9be94c63b2bb771f16a4ceed3ea0c88a5722d0 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 27 Mar 2018 19:45:16 +1100 Subject: [PATCH 0578/2421] Test for the warnings --- test/test-ghe-backup.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6ae3aa851..6d3a4d6e3 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -313,7 +313,9 @@ begin_test "ghe-backup missing directories or files on source appliance" false fi - cat "$TRASHDIR/backup-out" + # Check the output for the warnings + cat "$TRASHDIR/backup-out" | grep "Warning: One or more repository networks and/or gists were not found on the source appliance." + cat "$TRASHDIR/backup-out" | grep "Warning: One or more storage objects were not found on the source appliance." verify_all_backedup_data ) From 78a00ad0d1d5b5e273cab44df8b8f6143322df29 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 27 Mar 2018 19:45:28 +1100 Subject: [PATCH 0579/2421] Display a warning if routes were missing from disk --- share/github-backup-utils/ghe-backup-repositories | 9 +++++++++ share/github-backup-utils/ghe-backup-storage | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 79b253202..8104df513 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -353,4 +353,13 @@ RULES done bm_end "$(basename $0) - Special Data Directories Sync" +bm_start "$(basename $0) - Verifying Routes" + +cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes +(cd $backup_dir/ && find * -mindepth 6 -maxdepth 7 -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes + +diff $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + +bm_end "$(basename $0) - Verifying Routes" + bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 813827c25..a9cf436f4 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -127,4 +127,13 @@ for pid in $(jobs -p); do done bm_end "$(basename $0) - Storage object sync" +bm_start "$(basename $0) - Verifying Routes" + +cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes +(cd $backup_dir/ && find * -mindepth 4 -maxdepth 4 -type f -exec wc -c {} \; | sort | uniq) > $tempdir/destination_routes + +diff $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + +bm_end "$(basename $0) - Verifying Routes" + bm_end "$(basename $0)" From 91408839169e5452b08c423a444c75fe3b8d5617 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 3 Apr 2018 11:34:31 +1000 Subject: [PATCH 0580/2421] Check parameters instead of extra options --ignore-missing-args is being passed through as a parameter, and not as part of $GHE_EXTRA_RSYNC_OPTS. --- share/github-backup-utils/ghe-rsync | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index c194fcb1a..33911d9b7 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -10,20 +10,22 @@ set -o pipefail # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +parameters=$* + # Filter vanished file warnings from both stdout (rsync versions < 3.x) and # stderr (rsync versions >= 3.x). The complex redirections are necessary to # filter stderr while also keeping stdout and stderr separated. IGNOREOUT='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -# Remove --ignore-missing-args argument if using an earlier version of rsync. -if [[ $GHE_EXTRA_RSYNC_OPTS == *"--ignore-missing-args"* ]] && ! rsync -h | grep -q '\-\-ignore-missing-args'; then - GHE_EXTRA_RSYNC_OPTS=${GHE_EXTRA_RSYNC_OPTS//--ignore-missing-args/} +# Remove --ignore-missing-args option if using an earlier version of rsync. +if [[ $parameters == *"--ignore-missing-args"* ]] && ! rsync -h | grep -q '\-\-ignore-missing-args'; then + parameters=${parameters//--ignore-missing-args/} ignore23=1 fi -(rsync "${@}" $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | (egrep -v "$IGNOREOUT" || true)) 3>&1 1>&2 2>&3 3>&- | (egrep -v "$IGNOREOUT" || true) +(rsync $parameters $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | res=$? # Suppress exits with 24. From 799b06005e72f92e606947ccd6b469bc78e69a74 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 3 Apr 2018 11:35:19 +1000 Subject: [PATCH 0581/2421] Local variables should use lowercase --- share/github-backup-utils/ghe-rsync | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 33911d9b7..5096a8ca2 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -15,7 +15,7 @@ parameters=$* # Filter vanished file warnings from both stdout (rsync versions < 3.x) and # stderr (rsync versions >= 3.x). The complex redirections are necessary to # filter stderr while also keeping stdout and stderr separated. -IGNOREOUT='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' +ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' # Remove --ignore-missing-args option if using an earlier version of rsync. if [[ $parameters == *"--ignore-missing-args"* ]] && ! rsync -h | grep -q '\-\-ignore-missing-args'; then @@ -23,9 +23,9 @@ if [[ $parameters == *"--ignore-missing-args"* ]] && ! rsync -h | grep -q '\-\-i ignore23=1 fi - (egrep -v "$IGNOREOUT" || true)) 3>&1 1>&2 2>&3 3>&- | - (egrep -v "$IGNOREOUT" || true) (rsync $parameters $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | + (egrep -v "$ignoreout" || true)) 3>&1 1>&2 2>&3 3>&- | + (egrep -v "$ignoreout" || true) res=$? # Suppress exits with 24. From c89824405eaa5499e2cc5508e34f49d171528dfe Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 3 Apr 2018 12:03:13 +1000 Subject: [PATCH 0582/2421] Keep as an array --- share/github-backup-utils/ghe-rsync | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 5096a8ca2..a4cd06fb8 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -10,20 +10,21 @@ set -o pipefail # Bring in the backup configuration . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config -parameters=$* - # Filter vanished file warnings from both stdout (rsync versions < 3.x) and # stderr (rsync versions >= 3.x). The complex redirections are necessary to # filter stderr while also keeping stdout and stderr separated. ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -# Remove --ignore-missing-args option if using an earlier version of rsync. -if [[ $parameters == *"--ignore-missing-args"* ]] && ! rsync -h | grep -q '\-\-ignore-missing-args'; then - parameters=${parameters//--ignore-missing-args/} - ignore23=1 +# Remove --ignore-missing-args parameter if using an earlier version of rsync. +if ! rsync -h | grep -q '\-\-ignore-missing-args'; then + for parameter; do + [[ ! $parameter == "--ignore-missing-args" ]] && parameters+=("$parameter") || ignore23=1 + done +else + parameters=("$@") fi -(rsync $parameters $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | +(rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | (egrep -v "$ignoreout" || true)) 3>&1 1>&2 2>&3 3>&- | (egrep -v "$ignoreout" || true) res=$? From 33b1ca885c0a3efd255245ff9c89deb04a9203ea Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 3 Apr 2018 12:09:42 +1000 Subject: [PATCH 0583/2421] Parallel symlink might already exist The symlink may already be there from a previous run. --- test/test-ghe-restore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 6918becc7..a102bf793 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -384,7 +384,7 @@ begin_test "ghe-restore cluster" # CI servers may have moreutils parallel and GNU parallel installed. We need moreutils parallel. if [ -x "/usr/bin/parallel.moreutils" ]; then - ln -s /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel" + ln -sf /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel" fi # run ghe-restore and write output to file for asserting against From def8cbf6ce41148b703de5c65c99222044109f6d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 15:30:26 +0100 Subject: [PATCH 0584/2421] Add set -e --- share/github-backup-utils/ghe-docker-init | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init index a4219b2c4..76e6086b8 100755 --- a/share/github-backup-utils/ghe-docker-init +++ b/share/github-backup-utils/ghe-docker-init @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -e PATH=$PATH:/backup-utils/bin From 3712867004521b8a040d38a8ec7845f465ea8bfd Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 15:30:47 +0100 Subject: [PATCH 0585/2421] Add test for set -e on shell scripts --- test/test-shellcheck.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh index 969bbee50..ebd2f709e 100755 --- a/test/test-shellcheck.sh +++ b/test/test-shellcheck.sh @@ -17,6 +17,7 @@ begin_test "shellcheck: reports no errors or warnings" results=$(mktemp $TRASHDIR/shellcheck.XXXXXX) # Check all executable scripts checked into the repo + set +x cd $BASE_PATH git ls-tree -r HEAD | grep -E '^1007|.*\..*sh$' | awk '{print $4}' | while read -r script; do if head -n1 "$script" | grep -E -w "sh|bash" >/dev/null 2>&1; then @@ -24,6 +25,7 @@ begin_test "shellcheck: reports no errors or warnings" fi done cd - + set -x [ "$(cat $results | wc -l)" -eq 0 ] || { echo "ShellCheck errors found: " @@ -32,3 +34,27 @@ begin_test "shellcheck: reports no errors or warnings" } ) end_test + +begin_test "shellopts: set -e set on all scripts" +( + set -e + results=$(mktemp $TRASHDIR/shellopts.XXXXXX) + + # Check all executable scripts checked into the repo, except bm.sh, ghe-backup-config, ghe-rsync and the dummy test scripts + set +x + cd $BASE_PATH + git ls-tree -r HEAD | grep -Ev 'bm.sh|ghe-backup-config|ghe-rsync|test/bin' | grep -E '^1007|.*\..*sh$' | awk '{print $4}' | while read -r script; do + if head -n1 "$script" | grep -E -w "sh|bash" >/dev/null 2>&1; then + grep -q "set -e" $script || echo $script >> $results || true + fi + done + cd - + set -x + + [ "$(cat $results | wc -l)" -eq 0 ] || { + echo "The following scripts don't have 'set -e'" + cat $results + exit 1 + } +) +end_test From 63425bdc2b0ad40df8ff0cf275f054db25f0d2df Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 15:32:45 +0100 Subject: [PATCH 0586/2421] Don't worry about pipefail for the mo either --- STYLEGUIDE.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index 6b007af2c..030e85e74 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -6,12 +6,12 @@ If you've not done much Bash development before you may find these debugging tip ##### Scripts must start with `#!/usr/bin/env bash` --- -##### Scripts must use `set -o errexit -o pipefail` +##### Scripts must use `set -e` If the return value of a command can be ignored, suffix it with `|| true`: ```bash -set -o errexit -o pipefail +set -e command_that_might_fail || true command_that_should_not_fail ``` @@ -21,7 +21,7 @@ Note that ignoring an exit status with `|| true` is not a good practice though. --- ##### Scripts should not check exit status via `$?` manually -Rely on `set -o errexit` instead: +Rely on `set -e` instead: ```bash cmd @@ -33,7 +33,7 @@ fi should be written as: ```bash -set -o errexit +set -e if cmd; then echo worked fi @@ -60,7 +60,7 @@ Use this format: #/ This will do foo and bar: #/ $ ghe-this-is-my-script --longopt foobar -c 2 #/ -set -o errexit -o pipefail +set -e ``` If there are no options or required arguments, the `OPTIONS` section can be ignored. @@ -77,7 +77,7 @@ For example: #/ Usage: ghe-this-is-my-script [options] #/ #/ This is a brief description of the script's purpose. -set -o errexit -o pipefail +set -e if [ "$1" = "--help" -o "$1" = "-h" ]; then grep '^#/' <"$0" | cut -c 4- From f99c1378210c8f22e01d985a3a8bf0d68b249d2f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 15:42:52 +0100 Subject: [PATCH 0587/2421] Consistency --- test/testlib.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index c3eac6ac0..bff0de188 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -65,11 +65,12 @@ atexit () { res=$? [ -z "$KEEPTRASH" ] && rm -rf "$TRASHDIR" - if [ $failures -gt 0 ] - then exit 1 - elif [ $res -ne 0 ] - then exit $res - else exit 0 + if [ $failures -gt 0 ]; then + exit 1 + elif [ $res -ne 0 ]; then + exit $res + else + exit 0 fi } From 7d4f0315b2b528ac2f991e8b6d146f3dd957cf4c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 17:47:26 +0100 Subject: [PATCH 0588/2421] Install shellcheck for testing --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c5f10c6d8..a2aa2e48d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ matrix: - brew update - brew install gnu-tar - brew install moreutils + - brew install shellcheck script: make test - os: linux dist: trusty @@ -17,4 +18,5 @@ matrix: - debhelper - moreutils - fakeroot + - shellcheck script: debuild -uc -us From 2b5baf04a461d05c2dc0693b8ec9ffe67c7072eb Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 18:06:49 +0100 Subject: [PATCH 0589/2421] Exit early if filesystem doesn't support hardlinks --- bin/ghe-backup | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 0236b7181..95e7b3c1e 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -56,6 +56,14 @@ mkdir -p "$GHE_SNAPSHOT_DIR" cd "$GHE_SNAPSHOT_DIR" touch "incomplete" +# Exit early if the snapshot filesystem doesn't support hard links +if ln $0 test_link >/dev/null 2>&1; then + rm -f test_link +else + echo "Error: the filesystem containing $GHE_SNAPSHOT_DIR does not support hard links." 1>&2 + exit 1 +fi + # To prevent multiple backup runs happening at the same time, we create a # in-progress file with the timestamp and pid of the backup process, # giving us a form of locking. @@ -86,7 +94,7 @@ trap 'exit $?' INT # ^C always terminate if [ -h ../in-progress ]; then echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 echo "If there is no backup in progress anymore, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress symlink." 1>&2 + echo "the $GHE_DATA_DIR/in-progress file." 1>&2 exit 1 fi From 6c47ca191ba6afb91c986b9759cb3bb49310de50 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 18:26:17 +0100 Subject: [PATCH 0590/2421] No need for -a --- test/test-shellcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh index ebd2f709e..9d73e5684 100755 --- a/test/test-shellcheck.sh +++ b/test/test-shellcheck.sh @@ -21,7 +21,7 @@ begin_test "shellcheck: reports no errors or warnings" cd $BASE_PATH git ls-tree -r HEAD | grep -E '^1007|.*\..*sh$' | awk '{print $4}' | while read -r script; do if head -n1 "$script" | grep -E -w "sh|bash" >/dev/null 2>&1; then - shellcheck -a -f gcc $script 2>&1 | grep -v ": note:" >> $results || true + shellcheck -f gcc $script 2>&1 | grep -v ": note:" >> $results || true fi done cd - From ecb1eab7f800b32bbe00d8bf6ce5700f19299d55 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 18:46:55 +0100 Subject: [PATCH 0591/2421] Use incomplete file for testing ln --- bin/ghe-backup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 95e7b3c1e..9eeaf4807 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -57,10 +57,10 @@ cd "$GHE_SNAPSHOT_DIR" touch "incomplete" # Exit early if the snapshot filesystem doesn't support hard links -if ln $0 test_link >/dev/null 2>&1; then +if ln incomplete test_link >/dev/null 2>&1; then rm -f test_link else - echo "Error: the filesystem containing $GHE_SNAPSHOT_DIR does not support hard links." 1>&2 + echo "Error: the filesystem containing $GHE_DATA_DIR does not support hard links." 1>&2 exit 1 fi From 16c066c1f1b7603681dd8dc83767e9c0201cf16c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 18:56:39 +0100 Subject: [PATCH 0592/2421] Check shellcheck version --- script/cibuild | 1 + 1 file changed, 1 insertion(+) diff --git a/script/cibuild b/script/cibuild index 8351c9c60..525e3e399 100755 --- a/script/cibuild +++ b/script/cibuild @@ -11,6 +11,7 @@ REMOTE_VERSIONS=" 2.13.0 " +shellcheck -V # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true From d04a2b99dc4c96b461f97d94b2fd7a395bb0d7ce Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 3 Apr 2018 19:04:04 +0100 Subject: [PATCH 0593/2421] Manually install latest stable shellcheck version on travis This is because Trusty comes with a really really old version. --- .travis.yml | 6 +++++- script/cibuild | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a2aa2e48d..de0d94a26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,11 @@ matrix: - os: linux dist: trusty sudo: required + install: + - wget "https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz" + - tar --xz -xvf "shellcheck-stable.linux.x86_64.tar.xz" + - shellcheck() { "shellcheck-stable/shellcheck" "$@"; } + - shellcheck --version addons: apt: packages: @@ -18,5 +23,4 @@ matrix: - debhelper - moreutils - fakeroot - - shellcheck script: debuild -uc -us diff --git a/script/cibuild b/script/cibuild index 525e3e399..8351c9c60 100755 --- a/script/cibuild +++ b/script/cibuild @@ -11,7 +11,6 @@ REMOTE_VERSIONS=" 2.13.0 " -shellcheck -V # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true From 9fdacbf52a52837d5b12a8b5c3e11802b1de24e3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 4 Apr 2018 10:03:30 +0100 Subject: [PATCH 0594/2421] Add substantiation --- bin/ghe-backup | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index 9eeaf4807..bffbc48e8 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -61,6 +61,7 @@ if ln incomplete test_link >/dev/null 2>&1; then rm -f test_link else echo "Error: the filesystem containing $GHE_DATA_DIR does not support hard links." 1>&2 + echo "Backup Utilities use hard links to store backup data efficiently." 1>&2 exit 1 fi From e6593e7aad9f2677c9ffd6dfd76a44089f201100 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 4 Apr 2018 11:18:06 +0100 Subject: [PATCH 0595/2421] Cater for more filesystem and rsync known problems --- bin/ghe-backup | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index bffbc48e8..336186acc 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -56,14 +56,30 @@ mkdir -p "$GHE_SNAPSHOT_DIR" cd "$GHE_SNAPSHOT_DIR" touch "incomplete" -# Exit early if the snapshot filesystem doesn't support hard links -if ln incomplete test_link >/dev/null 2>&1; then - rm -f test_link -else +# Exit early if the snapshot filesystem doesn't support hard links, symlinks and +# if rsync doesn't support hardlinking of dangling symlinks +trap 'rm -rf src dest1 dest2' EXIT +mkdir src +touch src/testfile +if ! ln -s /data/does/not/exist/hooks/ src/ >/dev/null 2>&1; then + echo "Error: the filesystem containing $GHE_DATA_DIR does not support symbolic links." 1>&2 + echo "Git repositories contain symbolic links that need to be preserved during a backup." 1>&2 + exit 1 +fi + +if ! output=$(rsync -a src/ dest1 2>&1 && rsync -av src/ --link-dest=../dest1 dest2 2>&1); then + echo "Error: rsync encountered an error that could indicate a problem with permissions," 1>&2 + echo "hard links, symbolic links, or another issue that may affect backups." 1>&2 + echo "$output" + exit 1 +fi + +if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile | awk '{ print $1 }')" ]; then echo "Error: the filesystem containing $GHE_DATA_DIR does not support hard links." 1>&2 echo "Backup Utilities use hard links to store backup data efficiently." 1>&2 exit 1 fi +rm -rf src dest1 dest2 # To prevent multiple backup runs happening at the same time, we create a # in-progress file with the timestamp and pid of the backup process, From ef28e63be14abd548f25dbc7f7c5872298e5f129 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 4 Apr 2018 14:03:26 +0100 Subject: [PATCH 0596/2421] Use shellcheck v0.4.7 on Linux --- .travis.yml | 6 ++---- test/test-shellcheck.sh | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index de0d94a26..f0641ae0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,8 @@ matrix: dist: trusty sudo: required install: - - wget "https://storage.googleapis.com/shellcheck/shellcheck-stable.linux.x86_64.tar.xz" - - tar --xz -xvf "shellcheck-stable.linux.x86_64.tar.xz" - - shellcheck() { "shellcheck-stable/shellcheck" "$@"; } - - shellcheck --version + - wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.4.7.linux.x86_64.tar.xz" + - tar --xz -xvf "shellcheck-v0.4.7.linux.x86_64.tar.xz" addons: apt: packages: diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh index 9d73e5684..3f2a7fb94 100755 --- a/test/test-shellcheck.sh +++ b/test/test-shellcheck.sh @@ -9,6 +9,12 @@ BASE_PATH=$(cd "$(dirname "$0")/../" && pwd) begin_test "shellcheck: reports no errors or warnings" ( set -e + # We manually install Shellcheck 0.4.7 on Travis Linux builds as other options + # are too old. + if [ -x "$BASE_PATH/shellcheck-v0.4.7/shellcheck" ]; then + shellcheck() { "$BASE_PATH/shellcheck-v0.4.7/shellcheck" "$@"; } + fi + if ! type shellcheck 1>/dev/null 2>&1; then echo "ShellCheck not installed." skip_test From 0f604a56dd3c449e71fae10ec03d493d0ff92250 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 6 Apr 2018 11:27:33 +0100 Subject: [PATCH 0597/2421] Improve wording --- STYLEGUIDE.md | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index 030e85e74..f2f6c8782 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -1,4 +1,4 @@ -## Bash Styleguide +## Bash Style Guide If you've not done much Bash development before you may find these debugging tips useful: http://wiki.bash-hackers.org/scripting/debuggingtips. @@ -6,7 +6,7 @@ If you've not done much Bash development before you may find these debugging tip ##### Scripts must start with `#!/usr/bin/env bash` --- -##### Scripts must use `set -e` +##### Use `set -e` If the return value of a command can be ignored, suffix it with `|| true`: @@ -19,7 +19,7 @@ command_that_should_not_fail Note that ignoring an exit status with `|| true` is not a good practice though. Generally speaking, it's better to handle the error. --- -##### Scripts should not check exit status via `$?` manually +##### Avoid manually checking exit status with `$?` Rely on `set -e` instead: @@ -40,7 +40,7 @@ fi ``` --- -##### Scripts must include a usage, description and optional examples +##### Include a usage, description and optional examples Use this format: @@ -87,7 +87,7 @@ fi ``` --- -##### Scripts should not use Bash arrays +##### Avoid Bash arrays Main issues: @@ -95,7 +95,7 @@ Main issues: * Important bugs in Bash versions < 4.3 --- -##### Scripts should use `test` or `[` whenever possible +##### Use `test` or `[` whenever possible ```bash test -f /etc/passwd @@ -132,7 +132,7 @@ done ``` --- -##### Scripts should use `$[x+y*z]` for mathematical expressions +##### Use `$[x+y*z]` for mathematical expressions ```bash local n=1 @@ -144,7 +144,7 @@ n=$(($n+1)) ``` --- -##### Scripts should use variables sparingly +##### Use variables sparingly Short paths and other constants should be repeated liberally throughout code since they can be search/replaced easily if they ever change. @@ -163,7 +163,9 @@ rsync /data/user/db remote:/data/user/db ``` --- -##### Scripts should use lowercase variables for locals, and uppercase for variables inherited or exported via the environment +##### Use lowercase and uppercase variable names + +Use lowercase variables for locals and internal veriables, and uppercase for variables inherited or exported via the environment ```bash #!/usr/bin/env bash @@ -176,7 +178,7 @@ git rev-list ``` --- -##### Scripts should use `${var}` for interpolation only when required +##### Use `${var}` for interpolation only when required ```bash greeting=hello @@ -185,7 +187,7 @@ echo ${greeting}world ``` --- -##### Scripts should use functions sparingly, opting for small/simple/sequential scripts instead whenever possible +##### Use functions sparingly, opting for small/simple/sequential scripts instead whenever possible When defining functions, use the following style: @@ -198,7 +200,7 @@ my_function() { ``` --- -##### Scripts should use `< Date: Thu, 12 Apr 2018 15:11:24 +0200 Subject: [PATCH 0598/2421] Go back to optimised restore process --- share/github-backup-utils/ghe-restore-pages | 45 ++++++++-------- .../ghe-restore-repositories | 51 ++++++++++++------- .../ghe-restore-repositories-gist | 51 +++++++++++-------- share/github-backup-utils/ghe-restore-storage | 51 +++++++++++-------- 4 files changed, 117 insertions(+), 81 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 7bcfe801e..cb8c01cbd 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -47,7 +47,8 @@ ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir opts="$GHE_EXTRA_SSH_OPTS" ssh_config_file_opt= tmp_list=$tempdir/tmp_list -to_restore=$tempdir/to_restore +routes_list=$tempdir/routes_list +local_routes_list=$tempdir/local_routes_list if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" @@ -96,23 +97,28 @@ bm_end "$(basename $0) - Building pages list" # # One route per line. # -bm_start "$(basename $0) - Calculating sync routes" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/dpages-cluster-restore-routes \ - | while read route; do - ghe_debug "Got restore route $route" - if $CLUSTER; then - servers=$(echo $route | cut -d ' ' -f2-) - else - servers=$host - fi - page=$(echo $route | cut -d ' ' -f1) - for server in $servers; do - ghe_debug "Adding $page to $tempdir/$server.rsync" - echo "$page" >> $tempdir/$server.rsync - echo "$route" >> $to_restore - done -done -bm_end "$(basename $0) - Calculating sync routes" +# NOTE: The route generation is performed on the appliance as it is considerably +# more performant than performing over an SSH pipe. +# +bm_start "$(basename $0) - Transferring pages list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +ghe_debug "Transferring object list:\n$(cat $tmp_list)" +bm_end "$(basename $0) - Transferring pages list" + +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/dpages-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +ghe_debug "Generating routes:\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Fetching routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list +ghe_debug "Fetching routes:\n$(cat $local_routes_list)" +bm_end "$(basename $0) - Fetching routes" + +bm_start "$(basename $0) - Processing routes" +cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +ghe_debug "Processing routes:\n$(ls -l $tempdir/*.rsync)" +bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then echo "Warning: no routes found, skipping pages restore ..." @@ -135,9 +141,8 @@ bm_end "$(basename $0) - Restoring pages" if $CLUSTER; then bm_start "$(basename $0) - Finalizing routes" ghe_verbose "Finalizing routes" - cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <> $tempdir/$server.rsync - echo "$route" | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' >> $to_restore - done -done -bm_end "$(basename $0) - Calculating sync routes" +# NOTE: The route generation is performed on the appliance as it is considerably +# more performant than performing over an SSH pipe. +# +bm_start "$(basename $0) - Transferring network list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +ghe_debug "Transferring network list:\n$(cat $tmp_list)" +bm_end "$(basename $0) - Transferring network list" + +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/dgit-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +ghe_debug "Generating routes:\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Fetching routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list +ghe_debug "Fetching routes:\n$(cat $local_routes_list)" +bm_end "$(basename $0) - Fetching routes" + +bm_start "$(basename $0) - Processing routes" +cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $local_routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore +ghe_debug "Processing routes:\n$(ls -l $tempdir/*.rsync && cat $to_restore)" +bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then echo "Warning: no routes found, skipping repositories restore ..." exit 0 fi +# rsync all the repository networks to the git server where they belong. +# One rsync invocation per server available. bm_start "$(basename $0) - Restoring repository networks" -# rsync all the repositories for file_list in $tempdir/*.rsync; do - server=$(basename $file_list .rsync) + if $CLUSTER; then + server=$(basename $file_list .rsync) + else + server=$host + fi ghe_verbose "* Transferring repository networks to $server ..." ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index a27c13581..21123e198 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -49,6 +49,8 @@ ssh_config_file_opt= opts="$GHE_EXTRA_SSH_OPTS" tmp_list=$tempdir/tmp_list to_restore=$tempdir/to_restore +routes_list=$tempdir/routes_list +local_routes_list=$tempdir/local_routes_list if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" @@ -95,26 +97,29 @@ bm_end "$(basename $0) - Building gist list" # # One route per line. # -bm_start "$(basename $0) - Calculating Sync Routes" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/gist-cluster-restore-routes \ - | while read route; do - ghe_debug "Got restore route $route" - if $CLUSTER; then - servers=$(echo $route | cut -d ' ' -f2-) - else - servers=$host - fi - network_path=$(echo $route | cut -d ' ' -f1) - for server in $servers; do - ghe_debug "Adding $network_path to $tempdir/$server.rsync" - echo "$network_path" >> $tempdir/$server.rsync - done - # Add entries to the to_restore in the form: - # - # gist_id /data/repositories/a/a8/3f/02/gist/gist_id.git dgit-node3 dgit-node2 dgit-node4 - echo "$route" | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' >> $to_restore -done -bm_end "$(basename $0) - Calculating Sync Routes" +# NOTE: The route generation is performed on the appliance as it is considerably +# more performant than performing over an SSH pipe. +# +bm_start "$(basename $0) - Transferring gist list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +ghe_debug "Transferring gist list:\n$(cat $tmp_list)" +bm_end "$(basename $0) - Transferring gist list" + +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/gist-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +ghe_debug "Generating routes:\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Transferring routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list +ghe_debug "Fetching routes:\n$(cat $local_routes_list)" +bm_end "$(basename $0) - Transferring routes" + +bm_start "$(basename $0) - Processing routes" +cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $local_routes_list | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore +ghe_debug "Processing routes:\n$(ls -l $tempdir/*.rsync && cat $to_restore)" +bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then echo "Warning: no routes found, skipping gists restore ..." @@ -124,7 +129,11 @@ fi # rsync all the gist repositories bm_start "$(basename $0) - Restoring gists" for file_list in $tempdir/*.rsync; do - server=$(basename $file_list .rsync) + if $CLUSTER; then + server=$(basename $file_list .rsync) + else + server=$host + fi ghe_verbose "* Transferring gists to $server" ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 6f9df40de..f15de37a3 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -48,7 +48,8 @@ ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir ssh_config_file_opt= opts="$GHE_EXTRA_SSH_OPTS" tmp_list=$tempdir/tmp_list -to_restore=$tempdir/to_restore +routes_list=$tempdir/routes_list +local_routes_list=$tempdir/local_routes_list if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" @@ -88,23 +89,28 @@ bm_end "$(basename $0) - Building object list" # # One route per line. # -bm_start "$(basename $0) - Calculating sync routes" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- github-env ./bin/storage-cluster-restore-routes \ - | while read route; do - ghe_debug "Got restore route $route" - if $CLUSTER; then - servers=$(echo $route | cut -d ' ' -f2-) - else - servers=$host - fi - object=$(echo $route | cut -d ' ' -f1) - for server in $servers; do - ghe_debug "Adding $object to $tempdir/$server.rsync" - echo "$object" | awk '{ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1}' >> $tempdir/$server.rsync - echo "$route" >> $to_restore - done -done -bm_end "$(basename $0) - Calculating sync routes" +# NOTE: The route generation is performed on the appliance as it is considerably +# more performant than performing over an SSH pipe. +# +bm_start "$(basename $0) - Transferring object list" +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +ghe_debug "Transferring object list:\n$(cat $tmp_list)" +bm_end "$(basename $0) - Transferring object list" + +bm_start "$(basename $0) - Generating routes" +echo "cat $tmp_list | github-env ./bin/storage-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +ghe_debug "Generating routes:\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Fetching routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list +ghe_debug "Fetching routes:\n$(cat $local_routes_list)" +bm_end "$(basename $0) - Fetching routes" + +bm_start "$(basename $0) - Processing routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' +ghe_debug "Processing routes:\n$(ls -l $tempdir/*.rsync)" +bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then echo "Warning: no routes found, skipping storage restore ..." @@ -115,7 +121,11 @@ fi # One rsync invocation per server available. bm_start "$(basename $0) - Restoring objects" for file_list in $tempdir/*.rsync; do - server=$(basename $file_list .rsync) + if $CLUSTER; then + server=$(basename $file_list .rsync) + else + server=$host + fi ghe_verbose "* Transferring data to $server ..." ghe-rsync -arvHR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ @@ -130,9 +140,8 @@ bm_end "$(basename $0) - Restoring objects" if $CLUSTER; then bm_start "$(basename $0) - Finalizing routes" ghe_verbose "Finalizing routes" - cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Thu, 12 Apr 2018 15:11:46 +0200 Subject: [PATCH 0599/2421] Interpret formatting chars in debug statements --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index c01baa5c7..07404abe2 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -288,7 +288,7 @@ ghe_verbose() { # Log if debug mode is enabled (GHE_DEBUG). ghe_debug() { if [ -n "$GHE_DEBUG" ]; then - echo "Debug: $*" 1>&3 + echo -e "Debug: $*" 1>&3 fi } From 02eaf0410f176ff759a69bd54296161632e36c01 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 12 Apr 2018 15:11:59 +0200 Subject: [PATCH 0600/2421] Use debug when testing --- test/test-ghe-restore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 6918becc7..75205c23e 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -23,7 +23,7 @@ begin_test "ghe-restore into configured vm" export GHE_RESTORE_HOST # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully false From 9ae2b394a8f69716cd41c159c02cd7cb244c5207 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 12 Apr 2018 15:33:56 +0200 Subject: [PATCH 0601/2421] Use provided hostname for single node restore --- share/github-backup-utils/ghe-restore-pages | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index cb8c01cbd..107c8e90a 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -127,7 +127,11 @@ fi bm_start "$(basename $0) - Restoring pages" for file_list in $tempdir/*.rsync; do - server=$(basename $file_list .rsync) + if $CLUSTER; then + server=$(basename $file_list .rsync) + else + server=$host + fi ghe_verbose "* Transferring Pages to $server" ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ From f0aeab40e5939b2895aa597a4e8d7df7abcd3027 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 13 Apr 2018 11:02:51 +0200 Subject: [PATCH 0602/2421] Use local routes file --- share/github-backup-utils/ghe-restore-storage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index f15de37a3..414944f7c 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -108,7 +108,7 @@ ghe_debug "Fetching routes:\n$(cat $local_routes_list)" bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' +cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' ghe_debug "Processing routes:\n$(ls -l $tempdir/*.rsync)" bm_end "$(basename $0) - Processing routes" From f9b56b71ccbd4c7d143fafdb3eb2db4c2902a5fd Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 13 Apr 2018 13:25:22 +0200 Subject: [PATCH 0603/2421] Output benchmark times when debugging --- share/github-backup-utils/bm.sh | 7 ++++++- share/github-backup-utils/ghe-restore-pages | 8 ++++---- share/github-backup-utils/ghe-restore-repositories | 8 ++++---- share/github-backup-utils/ghe-restore-repositories-gist | 8 ++++---- share/github-backup-utils/ghe-restore-storage | 8 ++++---- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 554d338a9..2d4455927 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -17,7 +17,9 @@ bm_desc_to_varname(){ bm_start() { eval "$(bm_desc_to_varname $@)_start=$(date +%s)" - + if [ -n "$GHE_DEBUG" ]; then + echo "Debug: $1 (bm_start)" + fi bm_init > /dev/null } @@ -48,4 +50,7 @@ bm_end() { local tstart=$(eval "echo \$$(bm_desc_to_varname $@)_start") echo "$1 took $(($tend - $tstart))s" >> $BM_FILE_PATH + if [ -n "$GHE_DEBUG" ]; then + echo "Debug: $1 took $(($tend - $tstart))s (bm_end)" + fi } diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 107c8e90a..be32fcfb1 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -102,22 +102,22 @@ bm_end "$(basename $0) - Building pages list" # bm_start "$(basename $0) - Transferring pages list" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list -ghe_debug "Transferring object list:\n$(cat $tmp_list)" +ghe_debug "\n$(cat $tmp_list)" bm_end "$(basename $0) - Transferring pages list" bm_start "$(basename $0) - Generating routes" echo "cat $tmp_list | github-env ./bin/dpages-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash -ghe_debug "Generating routes:\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "Fetching routes:\n$(cat $local_routes_list)" +ghe_debug "\n$(cat $local_routes_list)" bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' -ghe_debug "Processing routes:\n$(ls -l $tempdir/*.rsync)" +ghe_debug "\n$(ls -l $tempdir/*.rsync)" bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index db7ea3479..77ae6afd6 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -109,23 +109,23 @@ bm_end "$(basename $0) - Building network list" # bm_start "$(basename $0) - Transferring network list" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list -ghe_debug "Transferring network list:\n$(cat $tmp_list)" +ghe_debug "\n$(cat $tmp_list)" bm_end "$(basename $0) - Transferring network list" bm_start "$(basename $0) - Generating routes" echo "cat $tmp_list | github-env ./bin/dgit-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "Generating routes:\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "Fetching routes:\n$(cat $local_routes_list)" +ghe_debug "\n$(cat $local_routes_list)" bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' cat $local_routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore -ghe_debug "Processing routes:\n$(ls -l $tempdir/*.rsync && cat $to_restore)" +ghe_debug "\n$(ls -l $tempdir/*.rsync && cat $to_restore)" bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 21123e198..b320dc9bc 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -102,23 +102,23 @@ bm_end "$(basename $0) - Building gist list" # bm_start "$(basename $0) - Transferring gist list" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list -ghe_debug "Transferring gist list:\n$(cat $tmp_list)" +ghe_debug "\n$(cat $tmp_list)" bm_end "$(basename $0) - Transferring gist list" bm_start "$(basename $0) - Generating routes" echo "cat $tmp_list | github-env ./bin/gist-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "Generating routes:\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Transferring routes" ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "Fetching routes:\n$(cat $local_routes_list)" +ghe_debug "\n$(cat $local_routes_list)" bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' cat $local_routes_list | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore -ghe_debug "Processing routes:\n$(ls -l $tempdir/*.rsync && cat $to_restore)" +ghe_debug "\n$(ls -l $tempdir/*.rsync && cat $to_restore)" bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 414944f7c..1fa1b603c 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -94,22 +94,22 @@ bm_end "$(basename $0) - Building object list" # bm_start "$(basename $0) - Transferring object list" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list -ghe_debug "Transferring object list:\n$(cat $tmp_list)" +ghe_debug "\n$(cat $tmp_list)" bm_end "$(basename $0) - Transferring object list" bm_start "$(basename $0) - Generating routes" echo "cat $tmp_list | github-env ./bin/storage-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash -ghe_debug "Generating routes:\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "Fetching routes:\n$(cat $local_routes_list)" +ghe_debug "\n$(cat $local_routes_list)" bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' -ghe_debug "Processing routes:\n$(ls -l $tempdir/*.rsync)" +ghe_debug "\n$(ls -l $tempdir/*.rsync)" bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then From a642db3f175afa72656d2d444f5707f5e2222df0 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 13 Apr 2018 13:32:30 +0200 Subject: [PATCH 0604/2421] Only calc the diff once --- share/github-backup-utils/bm.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 2d4455927..ac7a7d2db 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -48,9 +48,10 @@ bm_end() { local tend=$(date +%s) local tstart=$(eval "echo \$$(bm_desc_to_varname $@)_start") + local total=$(($tend - $tstart)) - echo "$1 took $(($tend - $tstart))s" >> $BM_FILE_PATH + echo "$1 took ${total}s" >> $BM_FILE_PATH if [ -n "$GHE_DEBUG" ]; then - echo "Debug: $1 took $(($tend - $tstart))s (bm_end)" + echo "Debug: $1 took ${total}s (bm_end)" fi } From 7e9b680b777ca932350b1cff2443e41878d7aa05 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sat, 14 Apr 2018 10:50:15 +0100 Subject: [PATCH 0605/2421] Quote array expansion --- share/github-backup-utils/bm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 807689e35..c512f3d44 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -48,7 +48,7 @@ bm_end() { local tend tstart total tend=$(date +%s) - tstart=$(eval "echo \$$(bm_desc_to_varname $@)_start") + tstart=$(eval "echo \$$(bm_desc_to_varname "$@")_start") total=$(($tend - $tstart)) echo "$1 took ${total}s" >> $BM_FILE_PATH From c049964f794d8a69c4e533aed63478b76fd120b4 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 18 Apr 2018 12:31:55 +1000 Subject: [PATCH 0606/2421] Improve code readability --- share/github-backup-utils/ghe-rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index a4cd06fb8..d75bf085a 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -17,7 +17,7 @@ ignoreout='^(file has vanished: |rsync warning: some files vanished before they # Remove --ignore-missing-args parameter if using an earlier version of rsync. if ! rsync -h | grep -q '\-\-ignore-missing-args'; then - for parameter; do + for parameter in "$@"; do [[ ! $parameter == "--ignore-missing-args" ]] && parameters+=("$parameter") || ignore23=1 done else From c7536bf34d12e958dcf7ced74c3177fe15fd1530 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 18 Apr 2018 12:51:19 +1000 Subject: [PATCH 0607/2421] Test for false warnings --- test/test-ghe-backup.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6d3a4d6e3..1c085be56 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -299,6 +299,25 @@ begin_test "ghe-backup cluster" ) end_test +begin_test "ghe-backup not missing directories or files on source appliance" +( + # Tests the scenario where the database and on disk state are consistent. + set -e + + if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then + cat "$TRASHDIR/backup-out" + : ghe-backup should have completed successfully + false + fi + + # Check the output for the warnings + ! cat "$TRASHDIR/backup-out" | grep "Warning: One or more repository networks and/or gists were not found on the source appliance." + ! cat "$TRASHDIR/backup-out" | grep "Warning: One or more storage objects were not found on the source appliance." + + verify_all_backedup_data +) +end_test + begin_test "ghe-backup missing directories or files on source appliance" ( # Tests the scenario where something exists in the database, but not on disk. From b5a67e1609bfbc4b059906e3a7968a00c3908756 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 18 Apr 2018 12:58:14 +1000 Subject: [PATCH 0608/2421] Fix find parameters --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 8104df513..74d0971f3 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -356,7 +356,7 @@ bm_end "$(basename $0) - Special Data Directories Sync" bm_start "$(basename $0) - Verifying Routes" cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes -(cd $backup_dir/ && find * -mindepth 6 -maxdepth 7 -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes +(cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes diff $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index a9cf436f4..8dd5e6f5e 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -130,7 +130,7 @@ bm_end "$(basename $0) - Storage object sync" bm_start "$(basename $0) - Verifying Routes" cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes -(cd $backup_dir/ && find * -mindepth 4 -maxdepth 4 -type f -exec wc -c {} \; | sort | uniq) > $tempdir/destination_routes +(cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | sort | uniq) > $tempdir/destination_routes diff $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." From 40798d10c6609db42787c002e73c20378997d13b Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 18 Apr 2018 13:40:45 +1000 Subject: [PATCH 0609/2421] Fix grep matching The negative matches weren't working as was for some unknown reason. --- test/test-ghe-backup.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 1c085be56..6ff648581 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -310,9 +310,9 @@ begin_test "ghe-backup not missing directories or files on source appliance" false fi - # Check the output for the warnings - ! cat "$TRASHDIR/backup-out" | grep "Warning: One or more repository networks and/or gists were not found on the source appliance." - ! cat "$TRASHDIR/backup-out" | grep "Warning: One or more storage objects were not found on the source appliance." + # Ensure the output doesn't contain the warnings + grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 + grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 verify_all_backedup_data ) @@ -333,8 +333,8 @@ begin_test "ghe-backup missing directories or files on source appliance" fi # Check the output for the warnings - cat "$TRASHDIR/backup-out" | grep "Warning: One or more repository networks and/or gists were not found on the source appliance." - cat "$TRASHDIR/backup-out" | grep "Warning: One or more storage objects were not found on the source appliance." + grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" + grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" verify_all_backedup_data ) From 68baae4a663b1378a8a113dba008e7b0079f6201 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 18 Apr 2018 14:07:10 +1000 Subject: [PATCH 0610/2421] Test for expected diff output --- test/test-ghe-backup.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6ff648581..333550d3a 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -334,7 +334,10 @@ begin_test "ghe-backup missing directories or files on source appliance" # Check the output for the warnings grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" + grep -q "< 1/23/bb/4c/gist" "$TRASHDIR/backup-out" + grep -q "< 1/nw/23/bb/4c/2345" "$TRASHDIR/backup-out" grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" + grep -q "< e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" "$TRASHDIR/backup-out" verify_all_backedup_data ) From 34e03b9b53c2394686f68158d7e34dd899ecbbad Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 18 Apr 2018 14:13:29 +1000 Subject: [PATCH 0611/2421] Flip if statement --- share/github-backup-utils/ghe-rsync | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index d75bf085a..ff32999f3 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -15,13 +15,13 @@ set -o pipefail # filter stderr while also keeping stdout and stderr separated. ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -# Remove --ignore-missing-args parameter if using an earlier version of rsync. -if ! rsync -h | grep -q '\-\-ignore-missing-args'; then +# Check for --ignore-missing-args parameter support and remove if unavailable. +if rsync -h | grep -q '\-\-ignore-missing-args'; then + parameters=("$@") +else for parameter in "$@"; do [[ ! $parameter == "--ignore-missing-args" ]] && parameters+=("$parameter") || ignore23=1 done -else - parameters=("$@") fi (rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | From 10b509144eea6eb2ee816e585c8b24fe8538d0eb Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 18 Apr 2018 14:14:03 +1000 Subject: [PATCH 0612/2421] Formatting --- share/github-backup-utils/ghe-rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index ff32999f3..61ae414a3 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -17,7 +17,7 @@ ignoreout='^(file has vanished: |rsync warning: some files vanished before they # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep -q '\-\-ignore-missing-args'; then - parameters=("$@") + parameters=("$@") else for parameter in "$@"; do [[ ! $parameter == "--ignore-missing-args" ]] && parameters+=("$parameter") || ignore23=1 From 6c1133e0bb417b7078fbc24f77e7e4615078ec53 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 18 Apr 2018 19:42:26 +1000 Subject: [PATCH 0613/2421] Workaround grepism -q appears to cause issues in some circumstances when used in combination with pipefail. --- share/github-backup-utils/ghe-rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index e67a84a94..fa212e8f0 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -17,7 +17,7 @@ set -o pipefail ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' # Check for --ignore-missing-args parameter support and remove if unavailable. -if rsync -h | grep -q '\-\-ignore-missing-args'; then +if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") else for parameter in "$@"; do From 0773e3c1464b406583c2eee4882a15ea126aecb2 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Wed, 18 Apr 2018 21:14:20 +1000 Subject: [PATCH 0614/2421] Optimise find by limiting to directories --- share/github-backup-utils/ghe-backup-repositories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index af8f373f8..14304111f 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -357,7 +357,7 @@ bm_end "$(basename $0) - Special Data Directories Sync" bm_start "$(basename $0) - Verifying Routes" cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes -(cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes +(cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes diff $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." From cbb2947c1cecd2ca39384fb89a26c4193458299d Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 20 Apr 2018 21:17:35 -0600 Subject: [PATCH 0615/2421] Test verbose logging to file --- test/test-ghe-backup-config.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 21afceee7..3c78d16b1 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -126,3 +126,17 @@ begin_test "ghe-backup-config ghe_parse_remote_version v2.x series" [ "$GHE_VERSION_PATCH" = "5" ] ) end_test + +begin_test "ghe-backup-config verbose log redirects to file" +( + set -e + + export GHE_VERBOSE=1 + export GHE_VERBOSE_LOG="$TRASHDIR/verbose.log" + . "share/github-backup-utils/ghe-backup-config" + ghe_verbose "Hello world" + [ "$(wc -l <"$GHE_VERBOSE_LOG")" -gt 0 ] + unset GHE_VERBOSE + unset GHE_VERBOSE_LOG +) +end_test From 633827cca4b5173132817cb7497f5c5846521c7e Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 20 Apr 2018 21:20:51 -0600 Subject: [PATCH 0616/2421] Redirect fd 3 when GHE_VERBOSE_LOG is set Co-authored-by: Steven Honson Co-authored-by: Michael Renner --- backup.config-example | 5 +++++ share/github-backup-utils/ghe-backup-config | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/backup.config-example b/backup.config-example index d2fe3828a..b708c45cc 100644 --- a/backup.config-example +++ b/backup.config-example @@ -23,6 +23,11 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_RESTORE_HOST="github-standby.example.com" +# When verbose output is enabled with `-v`, it's written to stdout by default. If +# you'd prefer it to be written to a separate file, set this option. +# +# GHE_VERBOSE_LOG="/var/log/backup-verbose.log" + # Any extra options passed to the SSH command. # In a single instance environment, nothing is required by default. # In a clustering environment, "-i abs-path-to-ssh-private-key" is required. diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 0c5ccc61a..f0a22e426 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -26,12 +26,16 @@ if [ -n "$GHE_SHOW_VERSION" ]; then exit 0 fi -# If verbose logging is enabled, redirect fd 3 to stdout; otherwise, redirect it -# to /dev/null. Write verbose output to fd 3. +# If verbose logging is enabled, redirect fd 3 to stdout or the specified log file; +# otherwise, redirect it to /dev/null. Write verbose output to fd 3. if [ -n "$GHE_VERBOSE" ]; then - exec 3>&1 + if [ -n "$GHE_VERBOSE_LOG" ]; then + exec 3<> "$GHE_VERBOSE_LOG" + else + exec 3>&1 + fi else - exec 3>/dev/null + exec 3>/dev/null fi # Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage From a18c537328fbbf895bd98be4783c3cf9b9372ca1 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 20 Apr 2018 21:53:28 -0600 Subject: [PATCH 0617/2421] Move verbose definition after backup.config is sourced Co-authored-by: Steven Honson --- share/github-backup-utils/ghe-backup-config | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index f0a22e426..5d64b3900 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -26,18 +26,6 @@ if [ -n "$GHE_SHOW_VERSION" ]; then exit 0 fi -# If verbose logging is enabled, redirect fd 3 to stdout or the specified log file; -# otherwise, redirect it to /dev/null. Write verbose output to fd 3. -if [ -n "$GHE_VERBOSE" ]; then - if [ -n "$GHE_VERBOSE_LOG" ]; then - exec 3<> "$GHE_VERBOSE_LOG" - else - exec 3>&1 - fi -else - exec 3>/dev/null -fi - # Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage # shellcheck disable=SC2120 # the script name is always referenced print_usage () { @@ -88,6 +76,18 @@ if ! $config_found; then exit 2 fi +# If verbose logging is enabled, redirect fd 3 to stdout or the specified log file; +# otherwise, redirect it to /dev/null. Write verbose output to fd 3. +if [ -n "$GHE_VERBOSE" ]; then + if [ -n "$GHE_VERBOSE_LOG" ]; then + exec 3<> "$GHE_VERBOSE_LOG" + else + exec 3>&1 + fi +else + exec 3>/dev/null +fi + # Restore saved off hostname. [ -n "$GHE_HOSTNAME_PRESERVE" ] && GHE_HOSTNAME="$GHE_HOSTNAME_PRESERVE" From 95cb13b8b073a611178445d5e4097bdd18d31c8a Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 20 Apr 2018 21:54:56 -0600 Subject: [PATCH 0618/2421] Nix extra space --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index b708c45cc..5a38b0c87 100644 --- a/backup.config-example +++ b/backup.config-example @@ -26,7 +26,7 @@ GHE_NUM_SNAPSHOTS=10 # When verbose output is enabled with `-v`, it's written to stdout by default. If # you'd prefer it to be written to a separate file, set this option. # -# GHE_VERBOSE_LOG="/var/log/backup-verbose.log" +#GHE_VERBOSE_LOG="/var/log/backup-verbose.log" # Any extra options passed to the SSH command. # In a single instance environment, nothing is required by default. From 77b624c5edba24eba996094750397c694371b256 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 20 Apr 2018 22:03:22 -0600 Subject: [PATCH 0619/2421] Fix an indent nit too --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 5d64b3900..c859aa786 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -85,7 +85,7 @@ if [ -n "$GHE_VERBOSE" ]; then exec 3>&1 fi else - exec 3>/dev/null + exec 3>/dev/null fi # Restore saved off hostname. From 2a284df9aa32083d4cab051c41c7e985ffa527af Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 24 Apr 2018 12:23:18 +0100 Subject: [PATCH 0620/2421] Bring back optimised route calculation --- .../ghe-backup-repositories | 38 +++++++++++-------- share/github-backup-utils/ghe-backup-storage | 36 +++++++++++------- 2 files changed, 45 insertions(+), 29 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index c1b7f7833..34434d9b9 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -64,6 +64,8 @@ user="${host%@*}" hostnames=$host ssh_config_file_opt= tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +routes_list=$tempdir/routes_list +local_routes_list=$tempdir/local_routes_list opts="$GHE_EXTRA_SSH_OPTS" # git server hostnames under cluster @@ -113,22 +115,28 @@ fi # a/nw/a8/bc/8d/100000880 dgit-node3 >> dgit-node3.sync # a/nw/a5/06/81/100000659 dgit-node2 >> dgit-node2.sync # ... -#one route per line. +# One route per line. # -bm_start "$(basename $0) - Calculating Sync Routes" -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/dgit-cluster-backup-routes \ - | while read route; do - ghe_debug "Got backup route $route" - if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - server=$(echo $route | cut -d ' ' -f2-) - else - server=$host - fi - network_path=$(echo $route | cut -d ' ' -f1) - ghe_debug "Adding $network_path to $tempdir/$server.rsync" - echo "$network_path" >> $tempdir/$server.rsync -done -bm_end "$(basename $0) - Calculating Sync Routes" +# NOTE: The route generation is performed on the appliance as it is considerably +# more performant than performing over an SSH pipe. +# +bm_start "$(basename $0) - Generating routes" +echo "github-env ./bin/dgit-cluster-backup-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Fetching routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list +ghe_debug "\n$(cat $local_routes_list)" +bm_end "$(basename $0) - Fetching routes" + +bm_start "$(basename $0) - Processing routes" +if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then + server=$host +fi +cat $local_routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' +ghe_debug "\n$(ls -l $tempdir/*.rsync)" +bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then echo "Warning: no routes found, skipping repositories backup ..." diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 7e32964f3..e20acb2de 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -37,6 +37,8 @@ user="${host%@*}" hostnames=$host ssh_config_file_opt= tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +routes_list=$tempdir/routes_list +local_routes_list=$tempdir/local_routes_list opts="$GHE_EXTRA_SSH_OPTS" # storage server hostnames under cluster @@ -84,20 +86,26 @@ fi # ... #one route per line. # -bm_start "$(basename $0) - Calculating sync routes" -ghe-ssh "$GHE_HOSTNAME" github-env ./bin/storage-cluster-backup-routes \ - | while read route; do - ghe_debug "Got backup route $route" - if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - server=$(echo $route | cut -d ' ' -f2-) - else - server=$host - fi - network_path=$(echo $route | cut -d ' ' -f1) - ghe_debug "Adding $network_path to $tempdir/$server.rsync" - echo "$network_path" >> $tempdir/$server.rsync -done -bm_end "$(basename $0) - Calculating sync routes" +# NOTE: The route generation is performed on the appliance as it is considerably +# more performant than performing over an SSH pipe. +# +bm_start "$(basename $0) - Generating routes" +echo "github-env ./bin/storage-cluster-backup-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +bm_end "$(basename $0) - Generating routes" + +bm_start "$(basename $0) - Fetching routes" +ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list +ghe_debug "\n$(cat $local_routes_list)" +bm_end "$(basename $0) - Fetching routes" + +bm_start "$(basename $0) - Processing routes" +if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then + server=$host +fi +cat $local_routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' +ghe_debug "\n$(ls -l $tempdir/*.rsync)" +bm_end "$(basename $0) - Processing routes" if ! ls $tempdir/*.rsync >/dev/null 2>&1; then echo "Warning: no routes found, skipping storage backup ..." From 7b3381aa4a1fb14a42a2d2ff1fab6f3d7dcedc14 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 24 Apr 2018 12:46:08 +0100 Subject: [PATCH 0621/2421] Ensure remote tmp dir exists --- share/github-backup-utils/ghe-backup-repositories | 1 + share/github-backup-utils/ghe-backup-storage | 1 + 2 files changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 34434d9b9..d127891ba 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -64,6 +64,7 @@ user="${host%@*}" hostnames=$host ssh_config_file_opt= tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir routes_list=$tempdir/routes_list local_routes_list=$tempdir/local_routes_list opts="$GHE_EXTRA_SSH_OPTS" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index e20acb2de..b78d91067 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -37,6 +37,7 @@ user="${host%@*}" hostnames=$host ssh_config_file_opt= tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir routes_list=$tempdir/routes_list local_routes_list=$tempdir/local_routes_list opts="$GHE_EXTRA_SSH_OPTS" From 96bf9defc3d3c7075790a55c738f7a8597dbcbf4 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 24 Apr 2018 13:02:04 +0100 Subject: [PATCH 0622/2421] Use accurate tempdir names --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index d127891ba..7f6278fc8 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -63,7 +63,7 @@ user="${host%@*}" hostnames=$host ssh_config_file_opt= -tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir routes_list=$tempdir/routes_list local_routes_list=$tempdir/local_routes_list diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index b78d91067..88366278d 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -36,7 +36,7 @@ user="${host%@*}" hostnames=$host ssh_config_file_opt= -tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir routes_list=$tempdir/routes_list local_routes_list=$tempdir/local_routes_list From e6c4a60662d7e65487068a587571f85046d08d11 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Tue, 24 Apr 2018 22:29:16 +1000 Subject: [PATCH 0623/2421] Remove check for git This introduced a bug, as the && isn't interpreted as part of the ||, so GHE_DISABLE_SSH_MUX was always being set to true. As git is listed as part of our requirements, and is being used in more and more places in the backup utilities, it should no-longer be optional. --- share/github-backup-utils/ghe-ssh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 5e63777bb..0183f2f58 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -62,11 +62,6 @@ if echo "$*" | grep "[|;]" >/dev/null || [ "$(echo "$*" | wc -l)" -gt 1 ]; then exit 1 fi -# Warn if git is not installed, and set GHE_DISABLE_SSH_MUX=true -if [ -z "$GHE_DISABLE_SSH_MUX" ]; then - command -v git >/dev/null 2>&1 || echo "Warning: SSH multiplexing requires git but it's not installed." && export GHE_DISABLE_SSH_MUX=true -fi - if [ -z "$GHE_DISABLE_SSH_MUX" ]; then controlpath="$TMPDIR/.ghe-sshmux-$(echo -n "$user@$host:$port" | git hash-object --stdin | cut -c 1-8)" # shellcheck disable=SC2089 # We don't use bash arrays From bd667a1bf274921f58420764740e6ed3e43210df Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 24 Apr 2018 16:34:17 +0100 Subject: [PATCH 0624/2421] Move -print0 to end of find --- share/github-backup-utils/ghe-restore-es-audit-log | 2 +- share/github-backup-utils/ghe-restore-es-hookshot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 03f0162f8..5d27057df 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -20,7 +20,7 @@ GHE_HOSTNAME="$1" # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" -indices=$(find -print0 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.gz 2>/dev/null | xargs -0 -I{} -n1 basename {} .gz) +indices=$(find $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.gz -print0 2>/dev/null | xargs -0 -I{} -n1 basename {} .gz) # Platform neutral and robust method of determining last month this_yr=$(date +"%Y") diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index 0c4c80b04..0809d4550 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -22,7 +22,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1) -indices=$(find -print0 $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz 2>/dev/null | xargs -0 -I{} -n1 basename {} .gz) +indices=$(find $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz -print0 2>/dev/null | xargs -0 -I{} -n1 basename {} .gz) tmp_list="$(mktemp -t backup-utils-restore-XXXXXX)" if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then configured=true From b1ce2389fddba42a982f2f563b6447957b80d1c5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 24 Apr 2018 16:57:42 +0100 Subject: [PATCH 0625/2421] Add test for hookshot and audit log restore --- test/bin/ghe-es-load-json | 6 +++++- test/testlib.sh | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) mode change 120000 => 100755 test/bin/ghe-es-load-json diff --git a/test/bin/ghe-es-load-json b/test/bin/ghe-es-load-json deleted file mode 120000 index a5ed742f4..000000000 --- a/test/bin/ghe-es-load-json +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-true \ No newline at end of file diff --git a/test/bin/ghe-es-load-json b/test/bin/ghe-es-load-json new file mode 100755 index 000000000..4bfe4a05a --- /dev/null +++ b/test/bin/ghe-es-load-json @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Usage: ghe-es-load-json +# Emulates the remote GitHub ghe-es-load-json command. Tests use this +# to assert that the command was executed. +cat - diff --git a/test/testlib.sh b/test/testlib.sh index bff0de188..a0e95b549 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -252,13 +252,13 @@ setup_test_data () { mkdir -p "$loc/audit-log/" cd "$loc/audit-log/" - touch audit_log-1-$last_yr-$last_mth-1.gz - touch audit_log-1-$this_yr-$this_mth-1.gz + echo "fake audit log last yr last mth" | gzip > audit_log-1-$last_yr-$last_mth-1.gz + echo "fake audit log this yr this mth" | gzip > audit_log-1-$this_yr-$this_mth-1.gz # Create hookshot logs mkdir -p "$loc/hookshot/" cd "$loc/hookshot/" - touch hookshot-logs-2018-03-05.gz + echo "fake hookshot log" | gzip > hookshot-logs-2018-03-05.gz # Create some test repositories in the remote repositories dir mkdir -p "$loc/repositories/info" @@ -413,6 +413,10 @@ verify_all_restored_data() { grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" # verify all ES data was transferred from live directory to the temporary restore directory diff -ru --exclude="*.gz" "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" + else + grep -q "fake audit log last yr last mth" "$TRASHDIR/restore-out" + grep -q "fake audit log this yr this mth" "$TRASHDIR/restore-out" + grep -q "fake hookshot log" "$TRASHDIR/restore-out" fi # verify settings import was *not* run due to instance already being From 14d4f61405980a68c197170384d3af650bfe5d4e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 24 Apr 2018 18:07:37 +0100 Subject: [PATCH 0626/2421] Use remote's mktemp to create temp dir on remote host This is to protect against the situation where the backup host may have a different default $TMPDIR settings vs the backup host, for example macOS uses /var/folders whilst Linux uses /tmp. --- .../ghe-backup-repositories | 15 ++++++------- share/github-backup-utils/ghe-backup-storage | 16 +++++++------- share/github-backup-utils/ghe-restore-pages | 19 +++++++++-------- .../ghe-restore-repositories | 21 ++++++++++--------- .../ghe-restore-repositories-gist | 19 +++++++++-------- share/github-backup-utils/ghe-restore-storage | 19 +++++++++-------- 6 files changed, 57 insertions(+), 52 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 7f6278fc8..f43af82b1 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -64,9 +64,9 @@ user="${host%@*}" hostnames=$host ssh_config_file_opt= tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) -ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-backup-XXXXXX) routes_list=$tempdir/routes_list -local_routes_list=$tempdir/local_routes_list +remote_routes_list=$remote_tempdir/remote_routes_list opts="$GHE_EXTRA_SSH_OPTS" # git server hostnames under cluster @@ -93,6 +93,7 @@ cleanup() { ghe-gc-enable $ssh_config_file_opt $hostname:$port || true done + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir rm -rf $tempdir } trap 'cleanup' EXIT @@ -122,20 +123,20 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "github-env ./bin/dgit-cluster-backup-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +echo "github-env ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "\n$(cat $local_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe_debug "\n$(cat $routes_list)" bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then server=$host fi -cat $local_routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' +cat $routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' ghe_debug "\n$(ls -l $tempdir/*.rsync)" bm_end "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 88366278d..f33f96560 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -37,9 +37,9 @@ user="${host%@*}" hostnames=$host ssh_config_file_opt= tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) -ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-backup-XXXXXX) routes_list=$tempdir/routes_list -local_routes_list=$tempdir/local_routes_list +remote_routes_list=$remote_tempdir/remote_routes_list opts="$GHE_EXTRA_SSH_OPTS" # storage server hostnames under cluster @@ -62,7 +62,7 @@ cleanup() { ghe-gc-enable $ssh_config_file_opt $hostname:$port || true done - ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir rm -rf $tempdir } trap 'cleanup' EXIT INT @@ -91,20 +91,20 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "github-env ./bin/storage-cluster-backup-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +echo "github-env ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "\n$(cat $local_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe_debug "\n$(cat $routes_list)" bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then server=$host fi -cat $local_routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' +cat $routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' ghe_debug "\n$(ls -l $tempdir/*.rsync)" bm_end "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 9b420e7bb..f9a35951d 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -44,12 +44,13 @@ user="${host%@*}" hostnames=$host tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-restore-XXXXXX) opts="$GHE_EXTRA_SSH_OPTS" ssh_config_file_opt= tmp_list=$tempdir/tmp_list +remote_tmp_list=$remote_tempdir/remote_tmp_list routes_list=$tempdir/routes_list -local_routes_list=$tempdir/local_routes_list +remote_routes_list=$remote_tempdir/remote_routes_list if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" @@ -61,7 +62,7 @@ fi cleanup() { rm -rf $tempdir - ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir true } @@ -102,22 +103,22 @@ bm_end "$(basename $0) - Building pages list" # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Transferring pages list" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list ghe_debug "\n$(cat $tmp_list)" bm_end "$(basename $0) - Transferring pages list" bm_start "$(basename $0) - Generating routes" -echo "cat $tmp_list | github-env ./bin/dpages-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +echo "cat $remote_tmp_list | github-env ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "\n$(cat $local_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe_debug "\n$(cat $routes_list)" bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" -cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' ghe_debug "\n$(ls -l $tempdir/*.rsync)" bm_end "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 538a0c6ac..29f8382ad 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -43,13 +43,14 @@ user="${host%@*}" hostnames=$host tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file_opt= opts="$GHE_EXTRA_SSH_OPTS" tmp_list=$tempdir/tmp_list +remote_tmp_list=$remote_tempdir/remote_tmp_list to_restore=$tempdir/to_restore routes_list=$tempdir/routes_list -local_routes_list=$tempdir/local_routes_list +remote_routes_list=$remote_tempdir/remote_routes_list if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" @@ -63,7 +64,7 @@ cleanup() { for hostname in $hostnames; do ghe-gc-enable $ssh_config_file_opt $hostname:$port || true done - ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir rm -rf $tempdir } trap cleanup EXIT @@ -109,23 +110,23 @@ bm_end "$(basename $0) - Building network list" # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Transferring network list" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list ghe_debug "\n$(cat $tmp_list)" bm_end "$(basename $0) - Transferring network list" bm_start "$(basename $0) - Generating routes" -echo "cat $tmp_list | github-env ./bin/dgit-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +echo "cat $remote_tmp_list | github-env ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "\n$(cat $local_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe_debug "\n$(cat $routes_list)" bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" -cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' -cat $local_routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore ghe_debug "\n$(ls -l $tempdir/*.rsync && cat $to_restore)" bm_end "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index a7a4a8153..0d903a903 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -45,13 +45,14 @@ user="${host%@*}" hostnames=$host tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file_opt= opts="$GHE_EXTRA_SSH_OPTS" tmp_list=$tempdir/tmp_list +remote_tmp_list=$remote_tempdir/remote_tmp_list to_restore=$tempdir/to_restore routes_list=$tempdir/routes_list -local_routes_list=$tempdir/local_routes_list +remote_routes_list=$remote_tempdir/remote_routes_list if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" @@ -102,23 +103,23 @@ bm_end "$(basename $0) - Building gist list" # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Transferring gist list" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list ghe_debug "\n$(cat $tmp_list)" bm_end "$(basename $0) - Transferring gist list" bm_start "$(basename $0) - Generating routes" -echo "cat $tmp_list | github-env ./bin/gist-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +echo "cat $remote_tmp_list | github-env ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Transferring routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "\n$(cat $local_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe_debug "\n$(cat $routes_list)" bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" -cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' -cat $local_routes_list | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore ghe_debug "\n$(ls -l $tempdir/*.rsync && cat $to_restore)" bm_end "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index d6d521a70..fe522bac7 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -45,12 +45,13 @@ user="${host%@*}" hostnames=$host tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -ghe-ssh "$GHE_HOSTNAME" -- mkdir -p $tempdir +remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file_opt= opts="$GHE_EXTRA_SSH_OPTS" tmp_list=$tempdir/tmp_list +remote_tmp_list=$remote_tempdir/remote_tmp_list routes_list=$tempdir/routes_list -local_routes_list=$tempdir/local_routes_list +remote_routes_list=$remote_tempdir/remote_routes_list if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" @@ -62,7 +63,7 @@ fi cleanup() { rm -rf $tempdir - ghe-ssh "$GHE_HOSTNAME" -- rm -rf $tempdir + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir true } @@ -94,22 +95,22 @@ bm_end "$(basename $0) - Building object list" # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Transferring object list" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $tmp_list +cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list ghe_debug "\n$(cat $tmp_list)" bm_end "$(basename $0) - Transferring object list" bm_start "$(basename $0) - Generating routes" -echo "cat $tmp_list | github-env ./bin/storage-cluster-restore-routes > $routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list)" +echo "cat $remote_tmp_list | github-env ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $routes_list > $local_routes_list -ghe_debug "\n$(cat $local_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe_debug "\n$(cat $routes_list)" bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" -cat $local_routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' +cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' ghe_debug "\n$(ls -l $tempdir/*.rsync)" bm_end "$(basename $0) - Processing routes" From 2756368eeb4503b886ca3e3ba5cf43015d1a6107 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 24 Apr 2018 18:33:29 +0100 Subject: [PATCH 0627/2421] Use correct remote dir for finalization step --- share/github-backup-utils/ghe-restore-repositories | 7 ++++--- share/github-backup-utils/ghe-restore-repositories-gist | 7 ++++--- share/github-backup-utils/ghe-restore-storage | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 29f8382ad..dc644066f 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -49,6 +49,7 @@ opts="$GHE_EXTRA_SSH_OPTS" tmp_list=$tempdir/tmp_list remote_tmp_list=$remote_tempdir/remote_tmp_list to_restore=$tempdir/to_restore +remote_to_restore=$remote_tempdir/remote_to_restore routes_list=$tempdir/routes_list remote_routes_list=$remote_tempdir/remote_routes_list @@ -158,10 +159,10 @@ bm_end "$(basename $0) - Restoring repository networks" if $CLUSTER; then bm_start "$(basename $0) - Finalizing routes" ghe_verbose "Finalizing routes" - cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $to_restore + cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <&3 <&3 < Date: Tue, 24 Apr 2018 18:49:28 +0100 Subject: [PATCH 0628/2421] Missed another few remote tempdir spots --- share/github-backup-utils/ghe-restore-repositories | 2 +- share/github-backup-utils/ghe-restore-repositories-gist | 2 +- share/github-backup-utils/ghe-restore-storage | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index dc644066f..43bfee99c 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -161,7 +161,7 @@ if $CLUSTER; then ghe_verbose "Finalizing routes" cat $to_restore | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_to_restore ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <&3 <&3 < Date: Thu, 26 Apr 2018 14:02:00 +0100 Subject: [PATCH 0629/2421] Clean up stale HA nodes --- bin/ghe-restore | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 4357d5809..94784fa78 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -341,6 +341,16 @@ else fi fi +# Clean up all stale replicas +if ! $CLUSTER; then + inactive_nodes=$(echo "ghe-spokes server show inactive --json | jq -r '.[] | select(.host | contains(\"git-server\")).host' | sed 's/^git-server-//g'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) + if [ -n "$inactive_nodes" ]; then + echo "Cleaning up stale nodes ..." + for uuid in $inactive_nodes; do + ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-cluster-cleanup-node $uuid" 1>&3 + done + fi +fi # Update the remote status to "complete". This has to happen before importing # ssh host keys because subsequent commands will fail due to the host key From 8ae58029fde7d5271ca43dd23af6b0ed82e8b6cf Mon Sep 17 00:00:00 2001 From: Eric Lordahl Date: Wed, 2 May 2018 15:18:44 -0400 Subject: [PATCH 0630/2421] Removing unneeded COPY from Dockerfile --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0363e4254..6dcecacd8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,6 @@ ADD https://github.com/github/backup-utils/archive/stable.tar.gz / RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils && \ rm -r /stable.tar.gz -COPY share/github-backup-utils/ghe-docker-init /backup-utils/share/github-backup-utils/ghe-docker-init RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init ENTRYPOINT ["/backup-utils/share/github-backup-utils/ghe-docker-init"] From f0a05aaed9fd336917ef7ceb425e2b67c2715b8c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 4 May 2018 11:40:14 +0100 Subject: [PATCH 0631/2421] Block replica backups --- bin/ghe-backup | 4 ++++ bin/ghe-host-check | 9 +++++++++ test/test-ghe-host-check.sh | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index 8f17ccab3..e76a7c69a 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -139,6 +139,10 @@ echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION ghe_remote_version_required echo "$GHE_REMOTE_VERSION" > version +if [ -n "$GHE_ALLOW_REPLICA_BACKUP" ]; then + echo "Warning: backing up a high availability replica may result in inconsistent or unreliable backups." +fi + # Log backup start message in /var/log/syslog on remote instance ghe_remote_logger "Starting backup from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP ..." diff --git a/bin/ghe-host-check b/bin/ghe-host-check index cddb94f20..7f9698cad 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -91,6 +91,15 @@ if [ -z "$version" ]; then exit 2 fi +if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then + if [ -f "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" ] && [ "$(cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state)" = "replica" ]; then + echo "Error: high availability replica detected." 1>&2 + echo "Backup Utilities should be used to backup from the primary node in" 1>&2 + echo "high availability environments to ensure consistent and repliable backups." 1>&2 + exit 1 + fi +fi + # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. supported_minimum_version="2.11.0" diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index eb95b8594..50745acf6 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -62,3 +62,15 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise versions" GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check ) end_test + +begin_test "ghe-host-check detects high availability replica" +( + set -e + echo "primary" > "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + ghe-host-check + + echo "replica" > "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + ! ghe-host-check + GHE_ALLOW_REPLICA_BACKUP=yes ghe-host-check +) +end_test From 087a7136781ca56bf6895232af5fbafe47fb318a Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 4 May 2018 17:02:25 +0100 Subject: [PATCH 0632/2421] Read repl-state from node --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 7f9698cad..4d8df1f81 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -92,7 +92,7 @@ if [ -z "$version" ]; then fi if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then - if [ -f "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" ] && [ "$(cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state)" = "replica" ]; then + if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state 2>/dev/null || true)" = "replica" ]; then echo "Error: high availability replica detected." 1>&2 echo "Backup Utilities should be used to backup from the primary node in" 1>&2 echo "high availability environments to ensure consistent and repliable backups." 1>&2 From aac61f5e787f58fcd9d51a7a1739668257cc437c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 9 May 2018 03:16:18 -0700 Subject: [PATCH 0633/2421] Bump version: 2.13.1 [ci skip] --- debian/changelog | 13 +++++++++++++ share/github-backup-utils/version | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e982511da..899726162 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +github-backup-utils (2.13.1) UNRELEASED; urgency=medium + + * Retry with the admin ssh port on network unreachable too. #377 + * Output backup utils version on backup and restore #384 + * Check filesystem supports hardlinks #388 + * Switch back to optimised restore route calculation #389 + * Optionally log verbose output to a file instead of stdout #391 + * Switch back to optimised backup route calculation #392 + * Remove check for git from ghe-ssh #393 + * Use remote's mktemp to create temp dir on remote host #395 + + -- Colin Seymour Wed, 09 May 2018 10:16:18 +0000 + github-backup-utils (2.13.0) UNRELEASED; urgency=medium * Unify the backup & restore process #375 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index fb2c0766b..94f15e9cc 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.13.0 +2.13.1 From 33076e344748b6bf46b54166cbceba4b21683e22 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 11 May 2018 11:30:38 +1000 Subject: [PATCH 0634/2421] Cleanup all mux sockets that exist --- bin/ghe-backup | 2 +- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-ssh | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index e76a7c69a..09bf80174 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -101,7 +101,7 @@ cleanup () { fi # Cleanup SSH multiplexing - ghe-ssh --clean "$GHE_HOSTNAME" + ghe-ssh --clean } # Setup exit traps diff --git a/bin/ghe-restore b/bin/ghe-restore index 4357d5809..a4cd3a0ad 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -73,7 +73,7 @@ cleanup () { fi # Cleanup SSH multiplexing - ghe-ssh --clean "$GHE_HOSTNAME" + ghe-ssh --clean } # Bring in the backup configuration diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 0183f2f58..feb7c785b 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -23,7 +23,7 @@ while true; do ;; -c|--clean) cleanup_mux=1 - shift + break ;; --) echo "Error: illegal '--' in ssh invocation" @@ -37,6 +37,13 @@ while true; do esac done +if [ -n "$cleanup_mux" ]; then + while find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1; do + find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 + done + exit +fi + # Show usage with no host [ -z "$host" ] && print_usage @@ -77,12 +84,5 @@ fi $GHE_VERBOSE_SSH && set -x # Exec ssh command with modified host / port args and add nice to command. -if [ -z "$cleanup_mux" ]; then - # Exec ssh command with modified host / port args and add nice to command. - # shellcheck disable=SC2090 # We don't need the quote/backslashes respected - exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" -elif [ -z "$GHE_DISABLE_SSH_MUX" ]; then - while ssh -O check -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1; do - ssh -O stop -o ControlPath="$controlpath" "$GHE_HOSTNAME" > /dev/null 2>&1 - done -fi +# shellcheck disable=SC2090 # We don't need the quote/backslashes respected +exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" From 3f12ef5746e3bd9c9e5107feea5e6a5fc5fb18ca Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 11 May 2018 11:33:36 +1000 Subject: [PATCH 0635/2421] Only try once --- share/github-backup-utils/ghe-ssh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index feb7c785b..c557791fe 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -38,9 +38,7 @@ while true; do done if [ -n "$cleanup_mux" ]; then - while find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1; do - find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 - done + find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 exit fi From 5c22ef8c3fe5df686c4c822491be0aeeccb9de9e Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 11 May 2018 11:35:00 +1000 Subject: [PATCH 0636/2421] Always true --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index c557791fe..a705c9109 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -38,7 +38,7 @@ while true; do done if [ -n "$cleanup_mux" ]; then - find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 + find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 || true exit fi From 2096468ede53e8760bb38cd37e66e61cc0ada3ea Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Fri, 11 May 2018 15:03:46 +1000 Subject: [PATCH 0637/2421] Use git diff --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- test/test-ghe-backup.sh | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index fed82a04e..a82b63891 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -369,7 +369,7 @@ bm_start "$(basename $0) - Verifying Routes" cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes -diff $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." +git diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." bm_end "$(basename $0) - Verifying Routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index f4ca9a064..3561f05c9 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -142,7 +142,7 @@ bm_start "$(basename $0) - Verifying Routes" cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | sort | uniq) > $tempdir/destination_routes -diff $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." +git diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." bm_end "$(basename $0) - Verifying Routes" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index a4814b22d..9fe8eb9bb 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -336,10 +336,10 @@ begin_test "ghe-backup missing directories or files on source appliance" # Check the output for the warnings grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" - grep -q "< 1/23/bb/4c/gist" "$TRASHDIR/backup-out" - grep -q "< 1/nw/23/bb/4c/2345" "$TRASHDIR/backup-out" + grep -q "\-1/23/bb/4c/gist" "$TRASHDIR/backup-out" + grep -q "\-1/nw/23/bb/4c/2345" "$TRASHDIR/backup-out" grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" - grep -q "< e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" "$TRASHDIR/backup-out" + grep -q "\-e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" "$TRASHDIR/backup-out" verify_all_backedup_data ) From 3d91a83a71090d29e81d3281c6de9dede5d5bba8 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 14 May 2018 14:05:28 +1000 Subject: [PATCH 0638/2421] Add environment variable to skip verification --- share/github-backup-utils/ghe-backup-repositories | 12 +++++++----- share/github-backup-utils/ghe-backup-storage | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index a82b63891..a17a66143 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -364,13 +364,15 @@ RULES done bm_end "$(basename $0) - Special Data Directories Sync" -bm_start "$(basename $0) - Verifying Routes" +if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then + bm_start "$(basename $0) - Verifying Routes" -cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes -(cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes + cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes + (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes -git diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + git diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." -bm_end "$(basename $0) - Verifying Routes" + bm_end "$(basename $0) - Verifying Routes" +fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 3561f05c9..34b0ca125 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -137,13 +137,15 @@ for pid in $(jobs -p); do done bm_end "$(basename $0) - Storage object sync" -bm_start "$(basename $0) - Verifying Routes" +if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then + bm_start "$(basename $0) - Verifying Routes" -cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes -(cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | sort | uniq) > $tempdir/destination_routes + cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes + (cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | sort | uniq) > $tempdir/destination_routes -git diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + git diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." -bm_end "$(basename $0) - Verifying Routes" + bm_end "$(basename $0) - Verifying Routes" +fi bm_end "$(basename $0)" From 230d1c141f809be28657d31f777432dc4cd3c91e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 14 May 2018 14:03:36 +0100 Subject: [PATCH 0639/2421] Remove all other nodes --- bin/ghe-restore | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index fc776e65e..84b819a96 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -343,10 +343,14 @@ fi # Clean up all stale replicas if ! $CLUSTER; then - inactive_nodes=$(echo "ghe-spokes server show inactive --json | jq -r '.[] | select(.host | contains(\"git-server\")).host' | sed 's/^git-server-//g'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) - if [ -n "$inactive_nodes" ]; then + restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) + other_nodes=$(echo "ghe-spokes server show --json | jq -r '.[] | select(.host | contains(\"git-server\")).host' | sed 's/^git-server-//g'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) + if [ -n "$other_nodes" ]; then echo "Cleaning up stale nodes ..." - for uuid in $inactive_nodes; do + for uuid in $other_nodes; do + if [ "$uuid" = "$restored_uuid" ]; then + continue + fi ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-cluster-cleanup-node $uuid" 1>&3 done fi From 480274604cb6aabb0fcae8d2c01339d92ddfdcad Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 15 May 2018 21:07:13 -0600 Subject: [PATCH 0640/2421] Test snapshot presence --- test/test-ghe-restore.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 67f4b7c83..d518a4062 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -10,6 +10,28 @@ setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" +begin_test "ghe-restore reports an error when current symlink doesn't exist" +( + set -e + rm "$GHE_DATA_DIR/current" + + ghe-restore -v -f localhost > "$TRASHDIR/restore-out" 2>&1 || true + ln -s 1 "$GHE_DATA_DIR/current" + grep -q "Error: Snapshot 'current' doesn't exist." "$TRASHDIR/restore-out" +) +end_test + +begin_test "ghe-restore reports an error when specified snapshot doesn't exist" +( + set -e + rm "$GHE_DATA_DIR/current" + + ghe-restore -v -f -s foo localhost > "$TRASHDIR/restore-out" 2>&1 || true + ln -s 1 "$GHE_DATA_DIR/current" + grep -q "Error: Snapshot 'foo' doesn't exist." "$TRASHDIR/restore-out" +) +end_test + begin_test "ghe-restore into configured vm" ( set -e From 6f3b90cdefd4d7b1b1c5f1b4c0da19c15ee2c647 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 15 May 2018 21:24:53 -0600 Subject: [PATCH 0641/2421] Verify that current snapshot exists --- share/github-backup-utils/ghe-restore-snapshot-path | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-snapshot-path b/share/github-backup-utils/ghe-restore-snapshot-path index b07594350..00bbbfcd2 100755 --- a/share/github-backup-utils/ghe-restore-snapshot-path +++ b/share/github-backup-utils/ghe-restore-snapshot-path @@ -23,7 +23,8 @@ if [ "$GHE_RESTORE_SNAPSHOT" = "current" ]; then fi # Bail out if we don't have a good snapshot. -if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" ]; then +if [ -z "$GHE_RESTORE_SNAPSHOT" ] || [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" ]; then + : "${GHE_RESTORE_SNAPSHOT:=current}" echo "Error: Snapshot '$GHE_RESTORE_SNAPSHOT' doesn't exist." 1>&2 exit 1 fi From 8fcb84c3f37aa6364973602f2af05ce4a866ae2f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 16 May 2018 13:59:35 +0200 Subject: [PATCH 0642/2421] Simplify and make more readible --- bin/ghe-restore | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 84b819a96..797274a10 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -344,13 +344,15 @@ fi # Clean up all stale replicas if ! $CLUSTER; then restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) - other_nodes=$(echo "ghe-spokes server show --json | jq -r '.[] | select(.host | contains(\"git-server\")).host' | sed 's/^git-server-//g'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) + other_nodes=$(echo " + set -o pipefail; \ + ghe-spokes server show --json \ + | jq -r '.[] | select(.host | contains(\"git-server\")).host' \ + | sed 's/^git-server-//g' | grep -F -x -v \"$restored_uuid\"" \ + | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) if [ -n "$other_nodes" ]; then echo "Cleaning up stale nodes ..." for uuid in $other_nodes; do - if [ "$uuid" = "$restored_uuid" ]; then - continue - fi ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-cluster-cleanup-node $uuid" 1>&3 done fi From 99a8ea3131b8e024a581b96a8cdd25882fed6500 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 17 May 2018 14:01:45 +0200 Subject: [PATCH 0643/2421] Add dummy cmds for testing --- test/bin/ghe-cluster-cleanup-node | 1 + test/bin/ghe-spokes | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 120000 test/bin/ghe-cluster-cleanup-node create mode 100755 test/bin/ghe-spokes diff --git a/test/bin/ghe-cluster-cleanup-node b/test/bin/ghe-cluster-cleanup-node new file mode 120000 index 000000000..9a9fbee29 --- /dev/null +++ b/test/bin/ghe-cluster-cleanup-node @@ -0,0 +1 @@ +ghe-fake-finalize-command \ No newline at end of file diff --git a/test/bin/ghe-spokes b/test/bin/ghe-spokes new file mode 100755 index 000000000..26c82da27 --- /dev/null +++ b/test/bin/ghe-spokes @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Usage: ghe-spokes +# Emulates the remote GitHub ghe-spokes command. Tests use this +# to assert that the command was executed. +set -e +echo '[ + { + "host": "git-server-fake-uuid" + }, + { + "host": "git-server-fake-uuid1" + }, + { + "host": "git-server-fake-uuid2" + } +]' From b96b87a3e72a0f09057547ab0ae57017c7f95514 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 17 May 2018 14:03:13 +0200 Subject: [PATCH 0644/2421] Test to ensure stale node cleanup takes place --- test/testlib.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/testlib.sh b/test/testlib.sh index a0e95b549..f564535cf 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -413,6 +413,8 @@ verify_all_restored_data() { grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" # verify all ES data was transferred from live directory to the temporary restore directory diff -ru --exclude="*.gz" "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" else grep -q "fake audit log last yr last mth" "$TRASHDIR/restore-out" grep -q "fake audit log this yr this mth" "$TRASHDIR/restore-out" From e34aede55932faf8322e6be4a13b627cd3fbeb76 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 17 May 2018 15:36:18 +0200 Subject: [PATCH 0645/2421] Install jq on Travis --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index f0641ae0f..e1e05d8f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ matrix: - brew install gnu-tar - brew install moreutils - brew install shellcheck + - brew install jq script: make test - os: linux dist: trusty @@ -21,4 +22,5 @@ matrix: - debhelper - moreutils - fakeroot + - jq script: debuild -uc -us From 156cd687cbe7610957e8ab2ad17b9e5158c40bd8 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 18 May 2018 00:11:53 -0600 Subject: [PATCH 0646/2421] Call ghe-restore-snapshot-path directly --- test/test-ghe-restore.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index d518a4062..1a40405b6 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -10,23 +10,23 @@ setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" -begin_test "ghe-restore reports an error when current symlink doesn't exist" +begin_test "ghe-restore-snapshot-path reports an error when current symlink doesn't exist" ( set -e rm "$GHE_DATA_DIR/current" - ghe-restore -v -f localhost > "$TRASHDIR/restore-out" 2>&1 || true + ghe-restore-snapshot-path > "$TRASHDIR/restore-out" 2>&1 || true ln -s 1 "$GHE_DATA_DIR/current" grep -q "Error: Snapshot 'current' doesn't exist." "$TRASHDIR/restore-out" ) end_test -begin_test "ghe-restore reports an error when specified snapshot doesn't exist" +begin_test "ghe-restore-snapshot-path reports an error when specified snapshot doesn't exist" ( set -e rm "$GHE_DATA_DIR/current" - ghe-restore -v -f -s foo localhost > "$TRASHDIR/restore-out" 2>&1 || true + ghe-restore-snapshot-path foo > "$TRASHDIR/restore-out" 2>&1 || true ln -s 1 "$GHE_DATA_DIR/current" grep -q "Error: Snapshot 'foo' doesn't exist." "$TRASHDIR/restore-out" ) From 7c97cf9d2ffaad20743447029de607a635548d75 Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Tue, 22 May 2018 14:58:35 +0200 Subject: [PATCH 0647/2421] Don't overwrite the verbose log after each stage --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index c859aa786..aa148a6b1 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -80,7 +80,7 @@ fi # otherwise, redirect it to /dev/null. Write verbose output to fd 3. if [ -n "$GHE_VERBOSE" ]; then if [ -n "$GHE_VERBOSE_LOG" ]; then - exec 3<> "$GHE_VERBOSE_LOG" + exec 3>> "$GHE_VERBOSE_LOG" else exec 3>&1 fi From fcd23e37df2094f5c29486dbafe3b83dd0d27fc4 Mon Sep 17 00:00:00 2001 From: Michael Renner Date: Tue, 22 May 2018 15:00:20 +0200 Subject: [PATCH 0648/2421] Redirect repositories STDERR output to the verbose log as well --- share/github-backup-utils/ghe-backup-repositories | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index a17a66143..b751ad684 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -166,7 +166,7 @@ rsync_repository_data () { --files-from="$files_list" \ --ignore-missing-args \ "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 + "$backup_dir" 1>&3 2>&3 else shift ghe-rsync -avr \ @@ -176,7 +176,7 @@ rsync_repository_data () { --include-from=- --exclude=\* \ --ignore-missing-args \ "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 + "$backup_dir" 1>&3 2>&3 fi } From 22c2718c409b271f2062a3ca774e09b098d1c910 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 22 May 2018 17:15:50 +0100 Subject: [PATCH 0649/2421] Don't exit 1 if grep returns no results --- bin/ghe-restore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 797274a10..37e243b39 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -348,7 +348,8 @@ if ! $CLUSTER; then set -o pipefail; \ ghe-spokes server show --json \ | jq -r '.[] | select(.host | contains(\"git-server\")).host' \ - | sed 's/^git-server-//g' | grep -F -x -v \"$restored_uuid\"" \ + | sed 's/^git-server-//g' \ + | ( grep -F -x -v \"$restored_uuid\" || true )" \ | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) if [ -n "$other_nodes" ]; then echo "Cleaning up stale nodes ..." From 02310de00f54d85df79255262691d28a47a9648f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 30 May 2018 11:30:18 +0100 Subject: [PATCH 0650/2421] Don't attempt stale node cleanup on unconfigured instances Unconfigured instances may have pending database migrations that could cause the required database queries to fail. We can't predict which migrations will affect the cleanup so the best option is to not run them on unconfigured instances. --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 37e243b39..bf232f4e0 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -341,8 +341,8 @@ else fi fi -# Clean up all stale replicas -if ! $CLUSTER; then +# Clean up all stale replicas on configured instances. +if ! $CLUSTER && $instance_configured; then restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) other_nodes=$(echo " set -o pipefail; \ From 346065e4ef9a161021d689097f4868aefdd526e7 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 30 May 2018 11:47:47 +0100 Subject: [PATCH 0651/2421] Update tests --- test/test-ghe-restore.sh | 15 +++++++++++++++ test/testlib.sh | 2 -- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 1a40405b6..a3a079d64 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -58,6 +58,9 @@ begin_test "ghe-restore into configured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + # Verify all the data we've restored is as expected verify_all_restored_data ) @@ -140,6 +143,12 @@ begin_test "ghe-restore -c into unconfigured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify attempt to clear stale servers was not made + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { + echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." + exit 1 + } + # Verify all the data we've restored is as expected verify_all_restored_data ) @@ -168,6 +177,12 @@ begin_test "ghe-restore into unconfigured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify attempt to clear stale servers was not made + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { + echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." + exit 1 + } + # Verify all the data we've restored is as expected verify_all_restored_data ) diff --git a/test/testlib.sh b/test/testlib.sh index f564535cf..a0e95b549 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -413,8 +413,6 @@ verify_all_restored_data() { grep -q "fake ghe-export-ssh-host-keys data" "$TRASHDIR/restore-out" # verify all ES data was transferred from live directory to the temporary restore directory diff -ru --exclude="*.gz" "$GHE_DATA_DIR/current/elasticsearch" "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" else grep -q "fake audit log last yr last mth" "$TRASHDIR/restore-out" grep -q "fake audit log this yr this mth" "$TRASHDIR/restore-out" From 627051b981854f5ab8933b2121d11ded3d8b6c11 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 22 Jun 2018 03:08:22 -0700 Subject: [PATCH 0652/2421] Bump version: 2.13.2 [ci skip] --- debian/changelog | 9 +++++++++ share/github-backup-utils/version | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 899726162..45a3bbead 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +github-backup-utils (2.13.2) UNRELEASED; urgency=medium + + * Treat missing repository networks, gists, and storage objects as a non-critical error #386 + * Clean up stale HA nodes on restore #396 + * Cleanup all SSH muxes in a non blocking way #402 + * Raise an error if the current symlink doesn't exist when attempting to restore it #404 + + -- Colin Seymour Fri, 22 Jun 2018 10:08:22 +0000 + github-backup-utils (2.13.1) UNRELEASED; urgency=medium * Retry with the admin ssh port on network unreachable too. #377 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 94f15e9cc..0e83a9a9c 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.13.1 +2.13.2 From 526b8fd6d45b2f3188d5cf4cef7a8ac8b0a1d449 Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 2 Jul 2018 11:21:12 +1000 Subject: [PATCH 0653/2421] Disable pager when running git-diff The pager (if invoked due to excessive output) prevents the backup from running non-interactively. --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index b751ad684..97350b597 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -370,7 +370,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes - git diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + git --no-pager diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." bm_end "$(basename $0) - Verifying Routes" fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 34b0ca125..e68801ea8 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -143,7 +143,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | sort | uniq) > $tempdir/destination_routes - git diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + git --no-pager diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." bm_end "$(basename $0) - Verifying Routes" fi From 7b56ee057f54bcaf34c774aec6b47069bcf8599c Mon Sep 17 00:00:00 2001 From: Steven Honson Date: Mon, 2 Jul 2018 11:47:57 +1000 Subject: [PATCH 0654/2421] No context is needed --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 97350b597..c92b6ab5e 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -370,7 +370,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes - git --no-pager diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." bm_end "$(basename $0) - Verifying Routes" fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index e68801ea8..99f399b7e 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -143,7 +143,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | sort | uniq) > $tempdir/destination_routes - git --no-pager diff -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." bm_end "$(basename $0) - Verifying Routes" fi From add13aedc1b6255dcb7503e80d7525b65b4501c2 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 2 Jul 2018 14:26:36 +0100 Subject: [PATCH 0655/2421] gzip Elasticsearch data before sending --- share/github-backup-utils/ghe-backup-es-audit-log | 2 +- share/github-backup-utils/ghe-backup-es-hookshot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 8bc942454..b3898c88b 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -48,7 +48,7 @@ for index in $indices; do ln $GHE_DATA_DIR/current/audit-log/$index_name.gz $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz ln $GHE_DATA_DIR/current/audit-log/$index_name.gz.size $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz + ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\" | gzip" > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz echo $index_size > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size fi done diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index eb54e5e45..9862d7a64 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -41,7 +41,7 @@ for index in $indices; do ln $GHE_DATA_DIR/current/hookshot/$index_name.gz $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz ln $GHE_DATA_DIR/current/hookshot/$index_name.gz.size $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\"" | gzip > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz + ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\" | gzip" > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz echo $index_size > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size fi done From 190cec48d7c84d19a7ce44db346d0d7513b35be0 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 2 Jul 2018 15:37:31 +0100 Subject: [PATCH 0656/2421] Transfer MySQL compressed before attempting import This should significantly speed up the restore of large instances as the data is transferred across the network compressed. --- bin/ghe-restore | 4 +- share/github-backup-utils/ghe-restore-mysql | 49 +++++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100755 share/github-backup-utils/ghe-restore-mysql diff --git a/bin/ghe-restore b/bin/ghe-restore index bf232f4e0..05c8b5f5f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -261,9 +261,7 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then fi echo "Restoring MySQL database ..." -bm_start "ghe-import-mysql" -gzip -dc "$GHE_RESTORE_SNAPSHOT_PATH/mysql.sql.gz" | ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-mysql' -bm_end "ghe-import-mysql" +ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 echo "Restoring Redis database ..." bm_start "ghe-import-redis" diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql new file mode 100755 index 000000000..5d1ebb87b --- /dev/null +++ b/share/github-backup-utils/ghe-restore-mysql @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-mysql +#/ Restore MySQL backup to a GitHub instance. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when the rsync strategy is used. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# The directory holding the snapshot to restore +snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + +cleanup() { + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" +} +trap 'cleanup' INT TERM EXIT + +ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 + +# Transfer MySQL data from the snapshot to the GitHub instance. +ghe-rsync -avz \ + -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ + --whole-file \ + "$snapshot_dir/mysql.sql.gz" \ + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/tmp" 1>&3 + +# Import the database +echo "gunzip -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | ghe-import-mysql" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 + + +bm_end "$(basename $0)" From 701b528b3c19b0c2016de42b516ebb32b6191e59 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 5 Jul 2018 15:52:32 +0100 Subject: [PATCH 0657/2421] Fix usage to abide by complex cmd usage --- share/github-backup-utils/ghe-backup-es-audit-log | 2 +- share/github-backup-utils/ghe-backup-es-hookshot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index b3898c88b..e28525e5d 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -48,7 +48,7 @@ for index in $indices; do ln $GHE_DATA_DIR/current/audit-log/$index_name.gz $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz ln $GHE_DATA_DIR/current/audit-log/$index_name.gz.size $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\" | gzip" > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz + echo "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\" | gzip" | ghe-ssh "$host" -- /bin/bash > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz echo $index_size > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size fi done diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot index 9862d7a64..678928d3b 100755 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ b/share/github-backup-utils/ghe-backup-es-hookshot @@ -41,7 +41,7 @@ for index in $indices; do ln $GHE_DATA_DIR/current/hookshot/$index_name.gz $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz ln $GHE_DATA_DIR/current/hookshot/$index_name.gz.size $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size else - ghe-ssh "$host" "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\" | gzip" > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz + echo "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\" | gzip" | ghe-ssh "$host" -- /bin/bash > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz echo $index_size > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size fi done From 1d554a554a767f57553e5ce5769fcc0c2f72f8aa Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 5 Jul 2018 15:53:13 +0100 Subject: [PATCH 0658/2421] Transfer compressed file and extract and import on appliance --- .../ghe-restore-es-audit-log | 21 +++++++++++++------ .../ghe-restore-es-hookshot | 20 ++++++++++++------ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 5d27057df..e356128e4 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -43,22 +43,31 @@ fi # Only restore indices that don't exist and the last two months' indices. for index in $indices; do if ! ghe-ssh "$GHE_HOSTNAME" "curl -f -s -XGET http://localhost:9201/$index > /dev/null" || [[ $index =~ $last_month ]] || [[ $index =~ $current_month ]]; then - if $CLUSTER || [ -n "$configured" ]; then - ghe_verbose "* Restoring $index" - gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 - else - echo "$index.gz" >> $tmp_list - fi + echo "$index.gz" >> $tmp_list fi done if [ -s "$tmp_list" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 + ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u elasticsearch rsync" \ --files-from=$tmp_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 + + if $CLUSTER || [ -n "$configured" ]; then + for index in $(cat $tmp_list | sed 's/\.gz$//g'); do + ghe_verbose "* Restoring $index" + echo "export PATH=\$PATH:/usr/local/share/enterprise && gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 + done + fi + + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz" 1>&3 rm $tmp_list fi + bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index 0809d4550..d1d114a86 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -30,22 +30,30 @@ fi for index in $indices; do if [ -z "$last_index" ] || ! [ $index \< $last_index ]; then - if $CLUSTER || [ -n "$configured" ]; then - ghe_verbose "* Restoring $index" - gzip -dc $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/$index.gz | ghe-ssh "$GHE_HOSTNAME" "/usr/local/share/enterprise/ghe-es-load-json 'http://localhost:9201/$index'" 1>&3 - else - echo "$index.gz" >> $tmp_list - fi + echo "$index.gz" >> $tmp_list fi done if [ -s "$tmp_list" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 + ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u elasticsearch rsync" \ --files-from=$tmp_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 + + if $CLUSTER || [ -n "$configured" ]; then + for index in $(cat $tmp_list | sed 's/\.gz$//g'); do + ghe_verbose "* Restoring $index" + echo "export PATH=\$PATH:/usr/local/share/enterprise && gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 + done + fi + + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz" 1>&3 rm $tmp_list fi From 12dcc2b24cc696a16eaba1d957b9e8c283bb7d8b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 10 Jul 2018 17:20:07 +0100 Subject: [PATCH 0659/2421] Use cat and dd for mysql transfer This removes the rsync overhead which is really unnecessary for a single file transfer --- share/github-backup-utils/ghe-restore-mysql | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 5d1ebb87b..9f1ed3c8a 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -36,11 +36,7 @@ trap 'cleanup' INT TERM EXIT ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 # Transfer MySQL data from the snapshot to the GitHub instance. -ghe-rsync -avz \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --whole-file \ - "$snapshot_dir/mysql.sql.gz" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/tmp" 1>&3 +cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database echo "gunzip -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | ghe-import-mysql" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 From 6b5f755a0889f0612bca9ed1c4d8a7a7be6551b5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 11 Jul 2018 10:52:17 +0100 Subject: [PATCH 0660/2421] Make ghe-host-check test less version-specific --- test/test-ghe-host-check.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 50745acf6..de4b9fb21 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -52,14 +52,18 @@ end_test begin_test "ghe-host-check detects unsupported GitHub Enterprise versions" ( set -e + # shellcheck disable=SC2046 # Word splitting is required to populate the variables + read -r bu_version_major bu_version_minor _ <<<$(ghe_parse_version $BACKUP_UTILS_VERSION) + ! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.11.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.12.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.13.999 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.13.999gm1 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=2.$((bu_version_minor-3)).0 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.$((bu_version_minor-2)).0 ghe-host-check + GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check + GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check + GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check + GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999gm1 ghe-host-check ! GHE_TEST_REMOTE_VERSION=2.9999.1521793591.performancetest ghe-host-check - GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=$((bu_version_minor+1)).0.0 ghe-host-check ) end_test From 741597d270964487c5e64fab8387bd3d1cf51d4c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 11 Jul 2018 11:22:16 +0100 Subject: [PATCH 0661/2421] Use 2.12 and 2.14 for test remote versions --- script/cibuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/cibuild b/script/cibuild index 8351c9c60..ebb89100f 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,8 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.11.0 - 2.13.0 + 2.12.0 + 2.14.0 " # Enable verbose logging of ssh commands From 809b102a18fb1eaf9327e56993974faf2ae9d45e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 11 Jul 2018 11:28:19 +0100 Subject: [PATCH 0662/2421] Update default test version when bumping major releases --- script/release | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/script/release b/script/release index c8421121b..c7cda8bb9 100755 --- a/script/release +++ b/script/release @@ -205,6 +205,10 @@ def bump_version(new_version, min_version = nil, path = 'share/github-backup-uti content = File.read('bin/ghe-host-check') new_content = content.gsub(/supported_minimum_version="[0-9]\.[0-9]+\.0"/, "supported_minimum_version=\"#{min_version}\"") File.open('bin/ghe-host-check', 'w') {|file| file.puts new_content } + + content = File.read('test/testlib.sh') + new_content = content.gsub(/GHE_TEST_REMOTE_VERSION:=[0-9]\.[0-9]+\.0/,"GHE_TEST_REMOTE_VERSION:=#{new_version}") + File.open('test/testlib.sh', 'w') {|file| file.puts new_content } end end @@ -384,6 +388,7 @@ if $PROGRAM_NAME == __FILE__ puts `git diff --color` `git checkout -- share/github-backup-utils/version` `git checkout -- bin/ghe-host-check` + `git checkout -- test/testlib.sh` exit end From 3d8ff8881e86d6bc7a0cd9e74b80e0d593100a55 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 11 Jul 2018 11:32:01 +0100 Subject: [PATCH 0663/2421] Add dummy ghe-es-remove-1x-indices req'd for testing 2.14 and later --- test/bin/ghe-es-remove-1x-indices | 1 + 1 file changed, 1 insertion(+) create mode 120000 test/bin/ghe-es-remove-1x-indices diff --git a/test/bin/ghe-es-remove-1x-indices b/test/bin/ghe-es-remove-1x-indices new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/ghe-es-remove-1x-indices @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From 9e9d3434446f50cb4cd1432c3970f1f1da832ec5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 11 Jul 2018 11:32:40 +0100 Subject: [PATCH 0664/2421] Add dummy ghe-es-remove-1x-indices req'd for testing 2.14 and later --- test/bin/ghe-es-remove-1x-indices | 1 + 1 file changed, 1 insertion(+) create mode 120000 test/bin/ghe-es-remove-1x-indices diff --git a/test/bin/ghe-es-remove-1x-indices b/test/bin/ghe-es-remove-1x-indices new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/ghe-es-remove-1x-indices @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From 295cb98ac0b71346147198922487047c5895c3b3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 11 Jul 2018 11:35:44 +0100 Subject: [PATCH 0665/2421] Use major version variable --- test/test-ghe-host-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index de4b9fb21..8930dad38 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -63,7 +63,7 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise versions" GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999gm1 ghe-host-check ! GHE_TEST_REMOTE_VERSION=2.9999.1521793591.performancetest ghe-host-check - GHE_TEST_REMOTE_VERSION=$((bu_version_minor+1)).0.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=$((bu_version_major+1)).0.0 ghe-host-check ) end_test From 77825a9c1d5550a9eadaab0f18d369dc4fb77f0b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 11 Jul 2018 11:49:54 +0100 Subject: [PATCH 0666/2421] Move cleanup into $CLUSTER || $configured section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🎩 tip @snh --- share/github-backup-utils/ghe-restore-es-audit-log | 3 ++- share/github-backup-utils/ghe-restore-es-hookshot | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index e356128e4..e158a545c 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -64,9 +64,10 @@ if [ -s "$tmp_list" ]; then echo "export PATH=\$PATH:/usr/local/share/enterprise && gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 done + + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz" 1>&3 fi - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz" 1>&3 rm $tmp_list fi diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index d1d114a86..ee3f6faaa 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -51,9 +51,10 @@ if [ -s "$tmp_list" ]; then echo "export PATH=\$PATH:/usr/local/share/enterprise && gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 done + + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz" 1>&3 fi - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz" 1>&3 rm $tmp_list fi From 53f9dfd47b58588beedc3a32fb9d8fb83b908ebb Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 12 Jul 2018 08:11:11 -0700 Subject: [PATCH 0667/2421] Bump version: 2.14.0 [ci skip] --- debian/changelog | 7 +++++++ share/github-backup-utils/version | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 45a3bbead..d500d9adf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.14.0) UNRELEASED; urgency=medium + + * Disable pager and context when running git-diff #411 + * Optimise hookshot and audit log backups and restores and MySQL restores #413 + + -- Colin Seymour Thu, 12 Jul 2018 15:11:11 +0000 + github-backup-utils (2.13.2) UNRELEASED; urgency=medium * Treat missing repository networks, gists, and storage objects as a non-critical error #386 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 0e83a9a9c..edcfe40d1 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.13.2 +2.14.0 From a7645f3020e1e96966893e85d14aba6bccc53354 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 13 Jul 2018 16:08:21 -0600 Subject: [PATCH 0668/2421] Don't bail if `ghe-config secrets.manage` exits non-zero --- share/github-backup-utils/ghe-backup-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 859ad1f0a..59ac802fb 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -26,7 +26,7 @@ echo "* Transferring license data ..." 1>&3 ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl echo "* Transferring management console password ..." 1>&3 -ghe-ssh "$host" -- ghe-config secrets.manage > manage-password+ +ghe-ssh "$host" -- ghe-config secrets.manage > manage-password+ || true if [ -n "$(cat manage-password+)" ]; then mv manage-password+ manage-password else From f9abe231ed838e99a17df7f45a2cebf6eae103c6 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Fri, 13 Jul 2018 16:24:27 -0600 Subject: [PATCH 0669/2421] Show warning --- share/github-backup-utils/ghe-backup-settings | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 59ac802fb..1e5f0935a 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -26,7 +26,9 @@ echo "* Transferring license data ..." 1>&3 ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl echo "* Transferring management console password ..." 1>&3 -ghe-ssh "$host" -- ghe-config secrets.manage > manage-password+ || true +ghe-ssh "$host" -- ghe-config secrets.manage > manage-password+ || ( + echo "Warning: Management Console password not set" >&2 +) if [ -n "$(cat manage-password+)" ]; then mv manage-password+ manage-password else From 279e09a1c41f87a1bd94330da261b7dc9f5d8a3b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 17 Jul 2018 16:35:40 +0100 Subject: [PATCH 0670/2421] Use sudo to extract and cleanup --- share/github-backup-utils/ghe-restore-es-audit-log | 4 ++-- share/github-backup-utils/ghe-restore-es-hookshot | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index e158a545c..77055d692 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -61,11 +61,11 @@ if [ -s "$tmp_list" ]; then if $CLUSTER || [ -n "$configured" ]; then for index in $(cat $tmp_list | sed 's/\.gz$//g'); do ghe_verbose "* Restoring $index" - echo "export PATH=\$PATH:/usr/local/share/enterprise && gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | + echo "export PATH=\$PATH:/usr/local/share/enterprise && sudo gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 done - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz'" 1>&3 fi rm $tmp_list diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index ee3f6faaa..997ab5677 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -48,11 +48,10 @@ if [ -s "$tmp_list" ]; then if $CLUSTER || [ -n "$configured" ]; then for index in $(cat $tmp_list | sed 's/\.gz$//g'); do ghe_verbose "* Restoring $index" - echo "export PATH=\$PATH:/usr/local/share/enterprise && gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | + echo "export PATH=\$PATH:/usr/local/share/enterprise && sudo gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 done - - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz'" 1>&3 fi rm $tmp_list From 8f07611eb76256f10c71a5572922993fb4be043d Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Tue, 17 Jul 2018 13:24:23 -0700 Subject: [PATCH 0671/2421] Add missing dependencies to debian packaging jq and sponge (from moreutils) were getting caught by the test suite failing during package build. Adding these to both build-depends and depends fixes the problem at build time and later install time. --- debian/control | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index 4c9bb61b9..fe79d1e41 100644 --- a/debian/control +++ b/debian/control @@ -3,11 +3,11 @@ Maintainer: Twan Wolthof Section: misc Priority: optional Standards-Version: 3.9.2 -Build-Depends: debhelper (>= 9), git, devscripts +Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq Package: github-backup-utils Architecture: any -Depends: ${misc:Depends}, rsync (>= 2.6.4) +Depends: ${misc:Depends}, rsync (>= 2.6.4), moreutils, jq Description: Backup and recovery utilities for GitHub Enterprise The backup utilities implement a number of advanced capabilities for backup hosts, built on top of the backup and restore features already included in From 37d7b51c0abb312f0850b485427124d45ac386c3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sun, 29 Jul 2018 18:22:41 +0100 Subject: [PATCH 0672/2421] Block restoring to older release --- bin/ghe-restore | 9 +++++++++ test/test-ghe-restore.sh | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 05c8b5f5f..887370d2f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -106,6 +106,15 @@ GHE_BACKUP_STRATEGY=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/strategy") # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" +# Block restoring snapshots to older releases of GitHub Enterprise +snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) +# shellcheck disable=SC2046 # Word splitting is required to populate the variables +read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) +if [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version $snapshot_version_major.$snapshot_version_minor.0)" ]; then + echo "Error: Snapshot can not be restored to an older release of GitHub Enterprise." >&2 + exit 1 +fi + # Figure out if this instance has been configured or is entirely new. instance_configured=false if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index a3a079d64..62e6e8ef0 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -398,6 +398,18 @@ begin_test "ghe-restore exits early on unsupported version" ) end_test +begin_test "ghe-restore exits early when restoring to older release" +( + set -e + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # shellcheck disable=SC2046 # Word splitting is required to populate the variables + read -r bu_version_major bu_version_minor bu_version_patch <<<$(ghe_parse_version $GHE_TEST_REMOTE_VERSION) + ! GHE_TEST_REMOTE_VERSION=$bu_version_major.$((bu_version_minor-1)).$bu_version_patch ghe-restore -v +) +end_test + # Reset data for sub-subsequent tests rm -rf "$GHE_DATA_DIR/1" setup_test_data "$GHE_DATA_DIR/1" From 6a1c352be8765dae993f28bf2aeb5b13b0c8d2ab Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Sun, 29 Jul 2018 18:22:53 +0100 Subject: [PATCH 0673/2421] Simplify version check --- test/test-ghe-restore.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 62e6e8ef0..8ce5c7109 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -341,7 +341,7 @@ begin_test "ghe-restore fails when restore 2.9/2.10 snapshot without audit log m set -e # noop if not testing against 2.11 - if [ "$GHE_VERSION_MAJOR" -ne 2 ] && [ "$GHE_VERSION_MINOR" -ne 11 ]; then + if [ "$(version $GHE_REMOTE_VERSION)" -ne "$(version 2.11.0)" ]; then skip_test fi @@ -368,7 +368,7 @@ begin_test "ghe-restore force restore of 2.9/2.10 snapshot without audit log mig set -e # noop if not testing against 2.11 - if [ "$GHE_VERSION_MAJOR" -ne 2 ] && [ "$GHE_VERSION_MINOR" -ne 11 ]; then + if [ "$(version $GHE_REMOTE_VERSION)" -ne "$(version 2.11.0)" ]; then skip_test fi From d0a7464608894b646fb1cc57f0503f3723a99416 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 30 Jul 2018 12:59:10 +0100 Subject: [PATCH 0674/2421] Move enforcement to ghe-host-check This ensures all the individual scripts also detect the version step down if run individually. --- bin/ghe-host-check | 11 +++++++++++ bin/ghe-restore | 9 --------- test/test-ghe-host-check.sh | 13 +++++++++++++ test/test-ghe-restore.sh | 12 ------------ 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 4d8df1f81..aa4312eac 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -91,6 +91,17 @@ if [ -z "$version" ]; then exit 2 fi +# Block restoring snapshots to older releases of GitHub Enterprise +if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then + snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) + # shellcheck disable=SC2046 # Word splitting is required to populate the variables + read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) + if [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version $snapshot_version_major.$snapshot_version_minor.0)" ]; then + echo "Error: Snapshot can not be restored to an older release of GitHub Enterprise." >&2 + exit 1 + fi +fi + if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state 2>/dev/null || true)" = "replica" ]; then echo "Error: high availability replica detected." 1>&2 diff --git a/bin/ghe-restore b/bin/ghe-restore index 887370d2f..05c8b5f5f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -106,15 +106,6 @@ GHE_BACKUP_STRATEGY=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/strategy") # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" -# Block restoring snapshots to older releases of GitHub Enterprise -snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) -# shellcheck disable=SC2046 # Word splitting is required to populate the variables -read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) -if [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version $snapshot_version_major.$snapshot_version_minor.0)" ]; then - echo "Error: Snapshot can not be restored to an older release of GitHub Enterprise." >&2 - exit 1 -fi - # Figure out if this instance has been configured or is entirely new. instance_configured=false if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 8930dad38..cc2afa2c7 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -78,3 +78,16 @@ begin_test "ghe-host-check detects high availability replica" GHE_ALLOW_REPLICA_BACKUP=yes ghe-host-check ) end_test + +begin_test "ghe-host-check blocks restore to old release" +( + set -e + + mkdir -p "$GHE_DATA_DIR/current/" + echo "$GHE_TEST_REMOTE_VERSION" > "$GHE_DATA_DIR/current/version" + + # shellcheck disable=SC2046 # Word splitting is required to populate the variables + read -r bu_version_major bu_version_minor bu_version_patch <<<$(ghe_parse_version $GHE_TEST_REMOTE_VERSION) + ! GHE_TEST_REMOTE_VERSION=$bu_version_major.$((bu_version_minor-1)).$bu_version_patch ghe-restore -v +) +end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 8ce5c7109..f4dcd1460 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -398,18 +398,6 @@ begin_test "ghe-restore exits early on unsupported version" ) end_test -begin_test "ghe-restore exits early when restoring to older release" -( - set -e - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # shellcheck disable=SC2046 # Word splitting is required to populate the variables - read -r bu_version_major bu_version_minor bu_version_patch <<<$(ghe_parse_version $GHE_TEST_REMOTE_VERSION) - ! GHE_TEST_REMOTE_VERSION=$bu_version_major.$((bu_version_minor-1)).$bu_version_patch ghe-restore -v -) -end_test - # Reset data for sub-subsequent tests rm -rf "$GHE_DATA_DIR/1" setup_test_data "$GHE_DATA_DIR/1" From 4b453a595da20a0d4a98239954ac3eb4d4b7fd34 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 7 Aug 2018 09:00:36 -0700 Subject: [PATCH 0675/2421] Bump version: 2.14.1 [ci skip] --- debian/changelog | 9 +++++++++ share/github-backup-utils/version | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index d500d9adf..ad49ed901 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +github-backup-utils (2.14.1) UNRELEASED; urgency=medium + + * Don't fail a backup if the Management Console password isn't set #416 + * Fix permissions issues when repeat restoring to configured cluster instance #417 + * Add missing dependencies to debian packaging #418 + * Prevent restoring snapshots to older releases #420 + + -- Colin Seymour Tue, 07 Aug 2018 16:00:36 +0000 + github-backup-utils (2.14.0) UNRELEASED; urgency=medium * Disable pager and context when running git-diff #411 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index edcfe40d1..b70ae75a8 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.14.0 +2.14.1 From 4d8ad300aa0fe35a7b34dfe4fe57e5f9ff9b8d86 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 7 Aug 2018 17:09:10 +0100 Subject: [PATCH 0676/2421] Only need to mention GHE version support if .0 release. --- script/release | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/release b/script/release index c7cda8bb9..5e6fe6756 100755 --- a/script/release +++ b/script/release @@ -407,7 +407,8 @@ if $PROGRAM_NAME == __FILE__ puts 'Updating changelog...' update_changelog release_changes, DEB_PKG_NAME, version - release_body = "Includes general improvements, bug fixes and support for GitHub Enterprise v#{version}" + release_body = "Includes general improvements & bug fixes" + release_body += " and support for GitHub Enterprise v#{version}" unless min_version.nil? release_changes.each do |c| release_body += "\n* #{c}" end From feba56a1db9aabe05d0fe0c7d642c33d6bd58215 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 7 Aug 2018 14:30:02 -0600 Subject: [PATCH 0677/2421] Test for cluster restore warnings --- test/test-ghe-restore.sh | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index f4dcd1460..893e95715 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -466,8 +466,54 @@ begin_test "ghe-restore cluster" grep -q "Pages to git-server-fake-uuid2" "$TRASHDIR/restore-out" grep -q "dpages-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + # verify no warnings printed + grep -qv "Warning" "$TRASHDIR/restore-out" # Verify all the data we've restored is as expected verify_all_restored_data ) end_test + +begin_test "ghe-restore missing directories or files from source snapshot displays warning" +( + # Tests the scenario where something exists in the database, but not on disk. + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + setup_remote_cluster + echo "cluster" > "$GHE_DATA_DIR/current/strategy" + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # CI servers may have moreutils parallel and GNU parallel installed. We need moreutils parallel. + if [ -x "/usr/bin/parallel.moreutils" ]; then + ln -sf /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel" + fi + + # Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings + export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1 + export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1 + + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + if [ -h "$ROOTDIR/test/bin/parallel" ]; then + unlink "$ROOTDIR/test/bin/parallel" + fi + + # for debugging + cat "$TRASHDIR/restore-out" + + grep -q "Warning: One or more repository networks failed to restore successfully." "$TRASHDIR/restore-out" + grep -q "Warning: One or more Gists failed to restore successfully." "$TRASHDIR/restore-out" +) +end_test From d1343f07ca272f3cd515dadb9692a925baa68d2c Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 7 Aug 2018 14:32:54 -0600 Subject: [PATCH 0678/2421] Print warnings in *-finalize --- test/bin/ghe-fake-finalize-command | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/test/bin/ghe-fake-finalize-command b/test/bin/ghe-fake-finalize-command index 22f266be2..857c25c06 100755 --- a/test/bin/ghe-fake-finalize-command +++ b/test/bin/ghe-fake-finalize-command @@ -2,4 +2,15 @@ # Emulates a remote GitHub restore finalize command. Each of the *-finalize utilities # that are run on the remote side have corresponding commands in this directory # that symlink to this file. The command just writes a simple success message. -echo "$(basename $0) OK" +binname="$(basename "$0")" +echo "$binname OK" + +# The RESTORE_FINALIZE_WARNING environment variables can be used to simulate a +# warning from each finalize step on the remote side. +if [ "$binname" == "dgit-cluster-restore-finalize" ] && [ -n "$GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING" ]; then + echo "1: /data/repositories/c/nw/c4/ca/42/1" >&2 +fi + +if [ "$binname" == "gist-cluster-restore-finalize" ] && [ -n "$GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING" ]; then + echo "aabbccdd: /data/repositories/c/nw/c4/ca/42/1/gist/aabbccdd.git" >&2 +fi From 70c4df384d49c710d63a1c4ea06c00b71daf3e99 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 7 Aug 2018 14:47:59 -0600 Subject: [PATCH 0679/2421] Capture repository restore warnings --- share/github-backup-utils/ghe-restore-repositories | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 43bfee99c..0306f29b5 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -52,6 +52,7 @@ to_restore=$tempdir/to_restore remote_to_restore=$remote_tempdir/remote_to_restore routes_list=$tempdir/routes_list remote_routes_list=$remote_tempdir/remote_routes_list +remote_warnings=$remote_tempdir/repo_warnings if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" @@ -163,7 +164,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi @@ -190,4 +191,10 @@ else fi bm_end "$(basename $0) - Updating repository info data" +restore_warnings="$(ghe-ssh "$GHE_HOSTNAME" -- cat "$remote_warnings" 2>/dev/null || true)" +if [ -n "$restore_warnings" ]; then + echo "Warning: One or more repository networks failed to restore successfully." + echo "$restore_warnings" +fi + bm_end "$(basename $0)" From 9d6aa92b1e32a8fd12ca3ff334b6e4d1bd156ba9 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 7 Aug 2018 14:48:20 -0600 Subject: [PATCH 0680/2421] Capture Gist restore warnings --- share/github-backup-utils/ghe-restore-repositories-gist | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index d5d79310d..100d8e1c3 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -54,6 +54,7 @@ to_restore=$tempdir/to_restore remote_to_restore=$remote_tempdir/remote_to_restore routes_list=$tempdir/routes_list remote_routes_list=$remote_tempdir/remote_routes_list +remote_warnings=$remote_tempdir/gist_warnings if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" @@ -154,9 +155,15 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi +restore_warnings="$(ghe-ssh "$GHE_HOSTNAME" -- cat "$remote_warnings" 2>/dev/null || true)" +if [ -n "$restore_warnings" ]; then + echo "Warning: One or more Gists failed to restore successfully." + echo "$restore_warnings" +fi + bm_end "$(basename $0)" From 688f8058b0081c3fd7f8f747e5b8f041dc36ee18 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 7 Aug 2018 14:48:46 -0600 Subject: [PATCH 0681/2421] Don't send repo/gist restore output to verbose log --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 05c8b5f5f..6079d4b27 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -271,10 +271,10 @@ bm_end "ghe-import-redis" # Unified and enhanced restore method to 2.13.0 and newer if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; then echo "Restoring Git repositories ..." - ghe-restore-repositories "$GHE_HOSTNAME" 1>&3 + ghe-restore-repositories "$GHE_HOSTNAME" echo "Restoring Gists ..." - ghe-restore-repositories-gist "$GHE_HOSTNAME" 1>&3 + ghe-restore-repositories-gist "$GHE_HOSTNAME" else echo "Restoring Git repositories and Gists ..." ghe-restore-repositories-rsync "$GHE_HOSTNAME" 1>&3 From c40c6f002a69950b5c5e1b5063579a0f0e8de8b5 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 7 Aug 2018 15:57:55 -0600 Subject: [PATCH 0682/2421] Verify restored data in warning test --- test/test-ghe-restore.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 893e95715..92819ba05 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -515,5 +515,8 @@ begin_test "ghe-restore missing directories or files from source snapshot displa grep -q "Warning: One or more repository networks failed to restore successfully." "$TRASHDIR/restore-out" grep -q "Warning: One or more Gists failed to restore successfully." "$TRASHDIR/restore-out" + + # Verify all the data we've restored is as expected + verify_all_restored_data ) end_test From 9eedb7fdd5d65245e0dd2b409f21abb97846aa49 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 7 Aug 2018 17:19:42 -0600 Subject: [PATCH 0683/2421] Mention support --- share/github-backup-utils/ghe-restore-repositories | 2 +- share/github-backup-utils/ghe-restore-repositories-gist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 0306f29b5..6cf7f059e 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -193,7 +193,7 @@ bm_end "$(basename $0) - Updating repository info data" restore_warnings="$(ghe-ssh "$GHE_HOSTNAME" -- cat "$remote_warnings" 2>/dev/null || true)" if [ -n "$restore_warnings" ]; then - echo "Warning: One or more repository networks failed to restore successfully." + echo "Warning: One or more repository networks failed to restore successfully. Please contact GitHub Enterprise Support for assistance." echo "$restore_warnings" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 100d8e1c3..c4fb66363 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -162,7 +162,7 @@ fi restore_warnings="$(ghe-ssh "$GHE_HOSTNAME" -- cat "$remote_warnings" 2>/dev/null || true)" if [ -n "$restore_warnings" ]; then - echo "Warning: One or more Gists failed to restore successfully." + echo "Warning: One or more Gists failed to restore successfully. Please contact GitHub Enterprise Support for assistance." echo "$restore_warnings" fi From c1663acabf6ad82b16c639d0ebfe6454c998f391 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Wed, 8 Aug 2018 17:37:05 -0600 Subject: [PATCH 0684/2421] Fix no-warninggrep test --- test/test-ghe-restore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 92819ba05..9af5632da 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -467,7 +467,7 @@ begin_test "ghe-restore cluster" grep -q "dpages-cluster-restore-finalize OK" "$TRASHDIR/restore-out" # verify no warnings printed - grep -qv "Warning" "$TRASHDIR/restore-out" + ! grep -q "Warning" "$TRASHDIR/restore-out" # Verify all the data we've restored is as expected verify_all_restored_data From feea50979958d7376d86c1d2e93b07f84c442824 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Thu, 9 Aug 2018 18:06:35 -0600 Subject: [PATCH 0685/2421] Use remote tempdir when finalizing Pages routes --- share/github-backup-utils/ghe-restore-pages | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index f9a35951d..dfa0bc7d1 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -148,8 +148,8 @@ if $CLUSTER; then bm_start "$(basename $0) - Finalizing routes" ghe_verbose "Finalizing routes" ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Mon, 20 Aug 2018 14:08:38 +0100 Subject: [PATCH 0686/2421] Add back ghe-restore-pages-rsync This is needed for restoring to pre-2.13 releases and was missed when I did something similar for repo, storage and gist restores. --- .../ghe-restore-pages-rsync | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 share/github-backup-utils/ghe-restore-pages-rsync diff --git a/share/github-backup-utils/ghe-restore-pages-rsync b/share/github-backup-utils/ghe-restore-pages-rsync new file mode 100644 index 000000000..2c1c3e171 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-pages-rsync @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-pages-rsync +#/ Restore an rsync snapshot of all Pages data to a GitHub instance. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when the rsync strategy is used. +set -e + +# Bring in the backup configuration +. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Restore all pages data via rsync +ghe-restore-userdata pages "$1" + +bm_end "$(basename $0)" From 43785b777160ccec168d39f5c276aa7ee0f98ca1 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 20 Aug 2018 14:13:48 +0100 Subject: [PATCH 0687/2421] Use rsync method for Pages restores to pre-2.13.0 releases --- bin/ghe-restore | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 6079d4b27..716a3db77 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -275,13 +275,17 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; the echo "Restoring Gists ..." ghe-restore-repositories-gist "$GHE_HOSTNAME" + + echo "Restoring GitHub Pages ..." + ghe-restore-pages "$GHE_HOSTNAME" 1>&3 else echo "Restoring Git repositories and Gists ..." ghe-restore-repositories-rsync "$GHE_HOSTNAME" 1>&3 + + echo "Restoring GitHub Pages ..." + ghe-restore-pages-rsync "$GHE_HOSTNAME" 1>&3 fi -echo "Restoring GitHub Pages ..." -ghe-restore-pages "$GHE_HOSTNAME" 1>&3 echo "Restoring SSH authorized keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json" 1>&3 From a620a2c43e6bd1a8bbc271d7e7cc264d1925c357 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 20 Aug 2018 15:49:19 +0100 Subject: [PATCH 0688/2421] Add exec perms --- share/github-backup-utils/ghe-restore-pages-rsync | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 share/github-backup-utils/ghe-restore-pages-rsync diff --git a/share/github-backup-utils/ghe-restore-pages-rsync b/share/github-backup-utils/ghe-restore-pages-rsync old mode 100644 new mode 100755 From 04b9aead7a1232cc3722484567232a01338b29fb Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 20 Aug 2018 15:50:47 +0100 Subject: [PATCH 0689/2421] Fix shellcheck errors --- share/github-backup-utils/ghe-restore-pages-rsync | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-pages-rsync b/share/github-backup-utils/ghe-restore-pages-rsync index 2c1c3e171..d1b2b7b82 100755 --- a/share/github-backup-utils/ghe-restore-pages-rsync +++ b/share/github-backup-utils/ghe-restore-pages-rsync @@ -7,7 +7,8 @@ set -e # Bring in the backup configuration -. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Show usage and bail with no arguments [ -z "$*" ] && print_usage From 2d2b886c52817f1d6a61a140698caf185569a900 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 21 Aug 2018 06:57:20 -0700 Subject: [PATCH 0690/2421] Bump version: 2.14.2 [ci skip] --- debian/changelog | 8 ++++++++ share/github-backup-utils/version | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index ad49ed901..1c7e07c95 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +github-backup-utils (2.14.2) UNRELEASED; urgency=medium + + * Capture and display repository/gist warnings during cluster restore #423 + * Use remote tempdir when finalizing Pages routes #424 + * Use old rsync restore method for pages prior to 2.13 #426 + + -- Colin Seymour Tue, 21 Aug 2018 13:57:20 +0000 + github-backup-utils (2.14.1) UNRELEASED; urgency=medium * Don't fail a backup if the Management Console password isn't set #416 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index b70ae75a8..7243b12cf 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.14.1 +2.14.2 From 638f4e570b4a34bfc2981825593952228d8edffc Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 30 Aug 2018 16:14:33 -0600 Subject: [PATCH 0691/2421] Default to port 122 We'll never need to connect on port 22 so shouldn't default to it. --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index aa148a6b1..4f1420589 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -274,7 +274,7 @@ ssh_host_part () { # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. ssh_port_part () { - [ "${1##*:}" = "$1" ] && echo 22 || echo "${1##*:}" + [ "${1##*:}" = "$1" ] && echo 122 || echo "${1##*:}" } # Usage: ghe_remote_logger ... From 6f77d7ee50031e0f4c16d0d6fd83881ac1e0f8ad Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 30 Aug 2018 16:15:15 -0600 Subject: [PATCH 0692/2421] Switch ssh opts order to be consistent with elsewhere --- share/github-backup-utils/ghe-ssh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index a705c9109..54d7e4538 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -74,7 +74,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 if ! [ -S $controlpath ]; then # shellcheck disable=SC2090 # We don't need the quote/backslashes respected - ( cd "$TMPDIR" && ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true ) + ( cd "$TMPDIR" && ssh -f $opts -p $port -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true ) fi fi @@ -83,4 +83,4 @@ $GHE_VERBOSE_SSH && set -x # Exec ssh command with modified host / port args and add nice to command. # shellcheck disable=SC2090 # We don't need the quote/backslashes respected -exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" +exec ssh $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" From ebac4cad20029309a4acc402bf56d5aefb3cb3d8 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 30 Aug 2018 16:20:15 -0600 Subject: [PATCH 0693/2421] Revert "Switch ssh opts order to be consistent with elsewhere" This reverts commit 6f77d7ee50031e0f4c16d0d6fd83881ac1e0f8ad. --- share/github-backup-utils/ghe-ssh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 54d7e4538..a705c9109 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -74,7 +74,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 if ! [ -S $controlpath ]; then # shellcheck disable=SC2090 # We don't need the quote/backslashes respected - ( cd "$TMPDIR" && ssh -f $opts -p $port -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true ) + ( cd "$TMPDIR" && ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true ) fi fi @@ -83,4 +83,4 @@ $GHE_VERBOSE_SSH && set -x # Exec ssh command with modified host / port args and add nice to command. # shellcheck disable=SC2090 # We don't need the quote/backslashes respected -exec ssh $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" +exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" From 50f4008008500227f822eac9d697aa5696bcc223 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 30 Aug 2018 16:20:24 -0600 Subject: [PATCH 0694/2421] Revert "Default to port 122" This reverts commit 638f4e570b4a34bfc2981825593952228d8edffc. --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 4f1420589..aa148a6b1 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -274,7 +274,7 @@ ssh_host_part () { # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. ssh_port_part () { - [ "${1##*:}" = "$1" ] && echo 122 || echo "${1##*:}" + [ "${1##*:}" = "$1" ] && echo 22 || echo "${1##*:}" } # Usage: ghe_remote_logger ... From ee803ac9da1019520775feda235f5fd900407a2b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 30 Aug 2018 16:14:33 -0600 Subject: [PATCH 0695/2421] Default to port 122 We'll never need to connect on port 22 so shouldn't default to it. --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index aa148a6b1..4f1420589 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -274,7 +274,7 @@ ssh_host_part () { # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. ssh_port_part () { - [ "${1##*:}" = "$1" ] && echo 22 || echo "${1##*:}" + [ "${1##*:}" = "$1" ] && echo 122 || echo "${1##*:}" } # Usage: ghe_remote_logger ... From 31450ab5f52732f37bac7c71ae6557678ff28861 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 30 Aug 2018 16:15:15 -0600 Subject: [PATCH 0696/2421] Switch ssh opts order to be consistent with elsewhere --- share/github-backup-utils/ghe-ssh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index a705c9109..54d7e4538 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -74,7 +74,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 if ! [ -S $controlpath ]; then # shellcheck disable=SC2090 # We don't need the quote/backslashes respected - ( cd "$TMPDIR" && ssh -f -p $port $opts -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true ) + ( cd "$TMPDIR" && ssh -f $opts -p $port -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true ) fi fi @@ -83,4 +83,4 @@ $GHE_VERBOSE_SSH && set -x # Exec ssh command with modified host / port args and add nice to command. # shellcheck disable=SC2090 # We don't need the quote/backslashes respected -exec ssh -p $port $opts -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" +exec ssh $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" From 9748bb5042f69d05d18e0594689664d85a164489 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 31 Aug 2018 11:38:29 -0600 Subject: [PATCH 0697/2421] Update test --- test/test-ghe-backup-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 3c78d16b1..7205867eb 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -89,7 +89,7 @@ end_test begin_test "ghe-backup-config ssh_port_part" ( set -e - [ "$(ssh_port_part 'github.example.com')" = "22" ] + [ "$(ssh_port_part 'github.example.com')" = "122" ] [ "$(ssh_port_part 'github.example.com:22')" = "22" ] [ "$(ssh_port_part 'github.example.com:5000')" = "5000" ] [ "$(ssh_port_part 'git@github.example.com:5000')" = "5000" ] From 27e225a7abdb9af6cc359f639c7dd92822415c96 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 31 Aug 2018 14:46:00 -0600 Subject: [PATCH 0698/2421] Put back port 22 --- share/github-backup-utils/ghe-backup-config | 2 +- test/test-ghe-backup-config.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 4f1420589..aa148a6b1 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -274,7 +274,7 @@ ssh_host_part () { # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. ssh_port_part () { - [ "${1##*:}" = "$1" ] && echo 122 || echo "${1##*:}" + [ "${1##*:}" = "$1" ] && echo 22 || echo "${1##*:}" } # Usage: ghe_remote_logger ... diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 7205867eb..3c78d16b1 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -89,7 +89,7 @@ end_test begin_test "ghe-backup-config ssh_port_part" ( set -e - [ "$(ssh_port_part 'github.example.com')" = "122" ] + [ "$(ssh_port_part 'github.example.com')" = "22" ] [ "$(ssh_port_part 'github.example.com:22')" = "22" ] [ "$(ssh_port_part 'github.example.com:5000')" = "5000" ] [ "$(ssh_port_part 'git@github.example.com:5000')" = "5000" ] From 47e1762bf154512264bfdb3e309091f1c70d9d14 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Thu, 6 Sep 2018 14:49:46 +1000 Subject: [PATCH 0699/2421] improve multi-platform detection of simultaneous ghe-backup runs --- bin/ghe-backup | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 09bf80174..af2e9d3cb 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -119,12 +119,14 @@ if [ -f ../in-progress ]; then progress=$(cat ../in-progress) snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) - if ! ps -p $pid | grep ghe-backup; then + if ! ps -p "$pid" >/dev/null 2>&1; then # We can safely remove in-progress, ghe-prune-snapshots # will clean up the failed backup. unlink ../in-progress else - echo "Error: backup process $pid of $GHE_HOSTNAME already in progress in snapshot $snapshot. Aborting." 1>&2 + echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 + echo "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 + echo "the $GHE_DATA_DIR/in-progress file and try again." 1>&2 exit 1 fi fi From 198443249826ec9a755098552c0a8cce15ca5c3a Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 6 Sep 2018 10:24:28 +0100 Subject: [PATCH 0700/2421] Add PATH option to config example --- backup.config-example | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backup.config-example b/backup.config-example index 5a38b0c87..d34c770e1 100644 --- a/backup.config-example +++ b/backup.config-example @@ -48,3 +48,9 @@ GHE_NUM_SNAPSHOTS=10 # # WARNING: do not enable this, only useful for debugging/development #GHE_BACKUP_FSCK=no + +# The PATH for the backup utilities to use. The default PATH used is that of the +# executing user which may not always be customizable or contain all the utilities +# required by the backup utilities. +# +#PATH="" \ No newline at end of file From a327059bf86f21188c79201a61e3ba8ef99078be Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 6 Sep 2018 10:25:05 +0100 Subject: [PATCH 0701/2421] Make it clear backing up to replica is not supported --- docs/getting-started.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index d972b3df7..777b2aa4b 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -12,10 +12,13 @@ backup and restore GitHub Enterprise 2.10 and earlier. 2. Copy the [`backup.config-example`][3] file to `backup.config` and modify as - necessary. The `GHE_HOSTNAME` value must be set to the GitHub Enterprise + necessary. The `GHE_HOSTNAME` value must be set to the primary GitHub Enterprise host name. Additional options are available and documented in the configuration file but none are required for basic backup functionality. + As the data on a High Availability replica may be in a transient state at the time of backup, + Backup Utilities should not be used to backup data from a High Availability replica. + * Backup Utilities will attempt to load the backup configuration from the following locations, in this order: From 64ee64ba6c7b0a3e8c384c6dad97cef5d838d3ee Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 11 Sep 2018 16:30:30 +0100 Subject: [PATCH 0702/2421] Revert "Add PATH option to config example" This reverts commit 198443249826ec9a755098552c0a8cce15ca5c3a. Safer to not mention this as it makes it too easy to shoot yourself in the foot. --- backup.config-example | 6 ------ 1 file changed, 6 deletions(-) diff --git a/backup.config-example b/backup.config-example index d34c770e1..5a38b0c87 100644 --- a/backup.config-example +++ b/backup.config-example @@ -48,9 +48,3 @@ GHE_NUM_SNAPSHOTS=10 # # WARNING: do not enable this, only useful for debugging/development #GHE_BACKUP_FSCK=no - -# The PATH for the backup utilities to use. The default PATH used is that of the -# executing user which may not always be customizable or contain all the utilities -# required by the backup utilities. -# -#PATH="" \ No newline at end of file From ea08957465c70def4a9966573e350d3b1bb77287 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 11 Sep 2018 10:03:42 -0700 Subject: [PATCH 0703/2421] Bump version: 2.14.3 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 1c7e07c95..e32af22c9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.14.3) UNRELEASED; urgency=medium + + * Improve multi-platform detection of simultaneous ghe-backup runs #435 + + -- Colin Seymour Tue, 11 Sep 2018 17:03:42 +0000 + github-backup-utils (2.14.2) UNRELEASED; urgency=medium * Capture and display repository/gist warnings during cluster restore #423 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 7243b12cf..cf28a128f 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.14.2 +2.14.3 From 6e1b129c1c757a68a402b135144558e01e94e021 Mon Sep 17 00:00:00 2001 From: Jose Javier De Leon Date: Sat, 29 Sep 2018 00:21:49 -0700 Subject: [PATCH 0704/2421] consul recover from uuid change --- bin/ghe-restore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 716a3db77..4b6130ad5 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -258,7 +258,9 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then echo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" -fi + ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" + fi echo "Restoring MySQL database ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 From 335c88a99fd7ccf85f5759485c24840d84ab162b Mon Sep 17 00:00:00 2001 From: Jose Javier De Leon Date: Mon, 1 Oct 2018 10:58:45 -0700 Subject: [PATCH 0705/2421] Symlink to `ghe-fake-true` for `systemctl` --- test/bin/systemctl | 1 + 1 file changed, 1 insertion(+) create mode 120000 test/bin/systemctl diff --git a/test/bin/systemctl b/test/bin/systemctl new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/systemctl @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From 7a72cb2eb9bf3b7c575fe94cb8f18b9b9820052b Mon Sep 17 00:00:00 2001 From: Jose Javier De Leon Date: Tue, 2 Oct 2018 11:45:45 -0700 Subject: [PATCH 0706/2421] adding `|| true` to consul stop --- bin/ghe-restore | 4 ++-- test/bin/systemctl | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 120000 test/bin/systemctl diff --git a/bin/ghe-restore b/bin/ghe-restore index 4b6130ad5..3fd632b5e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -258,8 +258,8 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then echo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" - ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" + ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul || true " + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft || true " fi echo "Restoring MySQL database ..." diff --git a/test/bin/systemctl b/test/bin/systemctl deleted file mode 120000 index a5ed742f4..000000000 --- a/test/bin/systemctl +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-true \ No newline at end of file From 333afc3d9797cb77f8da30d2037c59e2bd830ce8 Mon Sep 17 00:00:00 2001 From: Jose Javier De Leon Date: Tue, 2 Oct 2018 11:56:06 -0700 Subject: [PATCH 0707/2421] Getting around `ghe-ssh` limitations --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 3fd632b5e..6f30897a1 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -258,7 +258,7 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then echo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" - ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul || true " + ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft || true " fi From 1793aa522a1ddd8f1d120a43a2a4a0e9ecfd8e82 Mon Sep 17 00:00:00 2001 From: Jose Javier De Leon Date: Tue, 2 Oct 2018 11:56:40 -0700 Subject: [PATCH 0708/2421] removing needless `|| true` --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 6f30897a1..03b7a26a2 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -258,8 +258,8 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then echo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" - ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft || true " + ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" fi echo "Restoring MySQL database ..." From 0de711375ba82e8a1d12c2c118092e1f71357490 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Oct 2018 09:03:46 -0700 Subject: [PATCH 0709/2421] Test against 2.13 and 2.15 --- script/cibuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/cibuild b/script/cibuild index ebb89100f..d06fe54e7 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,8 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.12.0 - 2.14.0 + 2.13.0 + 2.15.0 " # Enable verbose logging of ssh commands From 1d1c78efe689f26dee30d3f19a2314b7657497ce Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Oct 2018 09:07:36 -0700 Subject: [PATCH 0710/2421] Bump version: 2.15.0 [ci skip] --- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e32af22c9..7ea37cb01 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (2.15.0) UNRELEASED; urgency=medium + + + -- Colin Seymour Tue, 16 Oct 2018 16:07:36 +0000 + github-backup-utils (2.14.3) UNRELEASED; urgency=medium * Improve multi-platform detection of simultaneous ghe-backup runs #435 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index cf28a128f..68e69e405 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.14.3 +2.15.0 From 4bc71c26fb39f1f018961adf0d2f06acd44ce1b5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Oct 2018 09:19:18 -0700 Subject: [PATCH 0711/2421] Revert "Merge pull request #444 from github/release-2.15.0" This reverts commit 938379d17a7f897cee0a866482dc91aedefb687c, reversing changes made to 1864c58045ca648a15b5e127c230d10375dd2be2. --- debian/changelog | 5 ----- script/cibuild | 4 ++-- share/github-backup-utils/version | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 7ea37cb01..e32af22c9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,3 @@ -github-backup-utils (2.15.0) UNRELEASED; urgency=medium - - - -- Colin Seymour Tue, 16 Oct 2018 16:07:36 +0000 - github-backup-utils (2.14.3) UNRELEASED; urgency=medium * Improve multi-platform detection of simultaneous ghe-backup runs #435 diff --git a/script/cibuild b/script/cibuild index d06fe54e7..ebb89100f 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,8 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.13.0 - 2.15.0 + 2.12.0 + 2.14.0 " # Enable verbose logging of ssh commands diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 68e69e405..cf28a128f 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.15.0 +2.14.3 From efae1ef113fafc5fe41a38b6e26849d7f3f8c03e Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Oct 2018 09:21:18 -0700 Subject: [PATCH 0712/2421] Include ghe-host-check and testlib.sh updates on releases --- script/release | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/release b/script/release index 5e6fe6756..0cc2e8517 100755 --- a/script/release +++ b/script/release @@ -217,7 +217,7 @@ def push_release_branch(version) raise "Creating release branch failed:\n\n#{out}" end - unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version`) + unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version bin/ghe-host-check test/testlib.sh`) raise "Error committing changelog and version:\n\n#{out}" end @@ -456,3 +456,4 @@ if $PROGRAM_NAME == __FILE__ exit 1 end end + From 7204dbee192b0d184cc6805991f5d73ab6bbdd36 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Oct 2018 09:21:34 -0700 Subject: [PATCH 0713/2421] Bump version: 2.15.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index aa4312eac..9aec6deb6 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_version="2.11.0" +supported_minimum_version="2.13.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index e32af22c9..5f588393c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (2.15.0) UNRELEASED; urgency=medium + + + -- Colin Seymour Tue, 16 Oct 2018 16:21:34 +0000 + github-backup-utils (2.14.3) UNRELEASED; urgency=medium * Improve multi-platform detection of simultaneous ghe-backup runs #435 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index cf28a128f..68e69e405 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.14.3 +2.15.0 diff --git a/test/testlib.sh b/test/testlib.sh index a0e95b549..28f86e694 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.11.0} +: ${GHE_TEST_REMOTE_VERSION:=2.15.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 135dd544b821386f25f3cc0418f9411612ee655b Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Oct 2018 09:27:47 -0700 Subject: [PATCH 0714/2421] Revert "Merge pull request #445 from github/release-2.15.0" This reverts commit 7fe25c74d986b09a3d282996d94ed961484309c4, reversing changes made to 938379d17a7f897cee0a866482dc91aedefb687c. --- bin/ghe-host-check | 2 +- debian/changelog | 2 +- script/cibuild | 4 ++-- script/release | 3 +-- test/testlib.sh | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 9aec6deb6..aa4312eac 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_version="2.13.0" +supported_minimum_version="2.11.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 5f588393c..7ea37cb01 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,7 @@ github-backup-utils (2.15.0) UNRELEASED; urgency=medium - -- Colin Seymour Tue, 16 Oct 2018 16:21:34 +0000 + -- Colin Seymour Tue, 16 Oct 2018 16:07:36 +0000 github-backup-utils (2.14.3) UNRELEASED; urgency=medium diff --git a/script/cibuild b/script/cibuild index ebb89100f..d06fe54e7 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,8 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.12.0 - 2.14.0 + 2.13.0 + 2.15.0 " # Enable verbose logging of ssh commands diff --git a/script/release b/script/release index 0cc2e8517..5e6fe6756 100755 --- a/script/release +++ b/script/release @@ -217,7 +217,7 @@ def push_release_branch(version) raise "Creating release branch failed:\n\n#{out}" end - unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version bin/ghe-host-check test/testlib.sh`) + unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version`) raise "Error committing changelog and version:\n\n#{out}" end @@ -456,4 +456,3 @@ if $PROGRAM_NAME == __FILE__ exit 1 end end - diff --git a/test/testlib.sh b/test/testlib.sh index 28f86e694..a0e95b549 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.15.0} +: ${GHE_TEST_REMOTE_VERSION:=2.11.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 2583c86146ed197b98b600a4578d7d12d36f4eac Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Oct 2018 09:35:58 -0700 Subject: [PATCH 0715/2421] Include other changed files in releases --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index 5e6fe6756..d6e3d7233 100755 --- a/script/release +++ b/script/release @@ -217,7 +217,7 @@ def push_release_branch(version) raise "Creating release branch failed:\n\n#{out}" end - unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version`) + unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version bin/ghe-host-check test/testlib.sh`) raise "Error committing changelog and version:\n\n#{out}" end From ef62481a1f2284e495ef54268edc99bdb95aa718 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 16 Oct 2018 09:40:03 -0700 Subject: [PATCH 0716/2421] Bump version: 2.15.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ test/testlib.sh | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index aa4312eac..9aec6deb6 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise. -supported_minimum_version="2.11.0" +supported_minimum_version="2.13.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 7ea37cb01..c1aea2616 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,11 @@ github-backup-utils (2.15.0) UNRELEASED; urgency=medium + -- Colin Seymour Tue, 16 Oct 2018 16:40:03 +0000 + +github-backup-utils (2.15.0) UNRELEASED; urgency=medium + + -- Colin Seymour Tue, 16 Oct 2018 16:07:36 +0000 github-backup-utils (2.14.3) UNRELEASED; urgency=medium diff --git a/test/testlib.sh b/test/testlib.sh index a0e95b549..28f86e694 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.11.0} +: ${GHE_TEST_REMOTE_VERSION:=2.15.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From b070855455c829bc035150a7e8dcb6ee0493afd5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 18 Oct 2018 14:25:47 +0100 Subject: [PATCH 0717/2421] Remove 2.11 and earlier specific code and tests --- bin/ghe-restore | 15 ------------ test/test-ghe-restore.sh | 52 ---------------------------------------- 2 files changed, 67 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 03b7a26a2..f6be82b08 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -137,21 +137,6 @@ if ghe-ssh "$GHE_HOSTNAME" -- \ exit 1 fi -# Only allow restores of 2.9 and 2.10 snapshots that have run the audit log migration to 2.11 and above -if ! $force; then - snapshot_instance_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) - snapshot_version_major=$(echo "${snapshot_instance_version#v}" | cut -f 1 -d .) - snapshot_version_minor=$(echo "$snapshot_instance_version" | cut -f 2 -d .) - if ! test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete && \ - [ "$snapshot_version_major" -eq 2 ] && [ "$snapshot_version_minor" -lt 11 ] && \ - [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 11 ]; then - echo "Error: Snapshot must be from GitHub Enterprise v2.9 or v2.10 after running the" >&2 - echo " audit log migration, or from v2.11.0 or above." >&2 - echo "Please see https://git.io/v5rCE for the audit log migration procedure." >&2 - exit 1 - fi -fi - # Prompt to verify the restore host given is correct. Restoring overwrites # important data on the destination appliance that cannot be recovered. This is # mostly to prevent accidents where the backup host is given to restore instead diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 9af5632da..4477686be 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -336,58 +336,6 @@ begin_test "ghe-restore honours --help and -h flags" ) end_test -begin_test "ghe-restore fails when restore 2.9/2.10 snapshot without audit log migration sentinel file to 2.11" -( - set -e - - # noop if not testing against 2.11 - if [ "$(version $GHE_REMOTE_VERSION)" -ne "$(version 2.11.0)" ]; then - skip_test - fi - - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - echo "rsync" > "$GHE_DATA_DIR/current/strategy" - echo "v2.9.10" > "$GHE_DATA_DIR/current/version" - rm "$GHE_DATA_DIR/current/es-scan-complete" - - ! output=$(ghe-restore -v localhost 2>&1) - - echo $output | grep -q "Error: Snapshot must be from GitHub Enterprise v2.9 or v2.10 after running the" - - echo "v2.10.5" > "$GHE_DATA_DIR/current/version" - ! output=$(ghe-restore -v localhost 2>&1) - - echo $output | grep -q "Error: Snapshot must be from GitHub Enterprise v2.9 or v2.10 after running the" -) -end_test - -begin_test "ghe-restore force restore of 2.9/2.10 snapshot without audit log migration sentinel file to 2.11" -( - set -e - - # noop if not testing against 2.11 - if [ "$(version $GHE_REMOTE_VERSION)" -ne "$(version 2.11.0)" ]; then - skip_test - fi - - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - echo "rsync" > "$GHE_DATA_DIR/current/strategy" - echo "v2.9.10" > "$GHE_DATA_DIR/current/version" - - # Create fake remote repositories dir - mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" - - ghe-restore -v -f localhost - - echo "v2.10.5" > "$GHE_DATA_DIR/current/version" - ghe-restore -v -f localhost -) -end_test - begin_test "ghe-restore exits early on unsupported version" ( set -e From 9fea5f8650ceef284354e7e03d1a211521a1a2f2 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Tue, 23 Oct 2018 15:25:21 +0200 Subject: [PATCH 0718/2421] Check the user that owns storage instead of assuming the git user This ensures this keeps working if we would change the user that owns this directory in the future. --- share/github-backup-utils/ghe-backup-storage | 4 +++- share/github-backup-utils/ghe-restore-storage | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 99f399b7e..e8fab4eb4 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -113,6 +113,8 @@ if ! ls $tempdir/*.rsync >/dev/null 2>&1; then exit 0 fi +storage_user=$(ghe-ssh "$GHE_HOSTNAME" -- stat -c %U /data/user/storage || echo git) + # rsync all the storage objects bm_start "$(basename $0) - Storage object sync" for file_list in $tempdir/*.rsync; do @@ -124,7 +126,7 @@ for file_list in $tempdir/*.rsync; do ghe-rsync -avr \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ + --rsync-path="sudo -u $storage_user rsync" \ --files-from="$file_list" \ --ignore-missing-args \ --size-only \ diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 9fa824b3d..8e7748c3c 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -119,6 +119,8 @@ if ! ls $tempdir/*.rsync >/dev/null 2>&1; then exit 0 fi +storage_user=$(ghe-ssh "$GHE_HOSTNAME" -- stat -c %U /data/user/storage || echo git) + # rsync all the objects to the storage server where they belong. # One rsync invocation per server available. bm_start "$(basename $0) - Restoring objects" @@ -131,7 +133,7 @@ for file_list in $tempdir/*.rsync; do ghe_verbose "* Transferring data to $server ..." ghe-rsync -arvHR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - --rsync-path="sudo -u git rsync" \ + --rsync-path="sudo -u $storage_user rsync" \ --files-from=$file_list \ --size-only \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ From 471f0b8bd8d355eed442fad6290a263de5a35e73 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Thu, 8 Nov 2018 23:16:19 +1100 Subject: [PATCH 0719/2421] fixes config apply failure due to missing license file --- share/github-backup-utils/ghe-restore-settings | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 624a21f46..95813d91a 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -25,15 +25,15 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Path to snapshot dir we're restoring from GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" +echo "Restoring license ..." +ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 + echo "Restoring settings ..." # work around issue importing settings with bad storage mode values ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | ghe-ssh "$GHE_HOSTNAME" -- '/usr/bin/env GHEBUVER=2 ghe-import-settings' 1>&3 -echo "Restoring license ..." -ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 - # Restore management console password hash if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/manage-password" ]; then echo "Restoring management console password ..." From 564132bdae0c13df0fab9a9f6984df52618c7d42 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Thu, 8 Nov 2018 23:30:18 +1100 Subject: [PATCH 0720/2421] fixes ghe-restore arg parsing when the host is specified first --- bin/ghe-restore | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index f6be82b08..7373cca7c 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -62,7 +62,12 @@ while true; do exit 1 ;; *) - break + if [ -n "$1" ]; then + GHE_HOSTNAME="$1" + shift + else + break + fi ;; esac done @@ -81,7 +86,7 @@ cleanup () { . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" # Grab the host arg -GHE_HOSTNAME="${1:-$GHE_RESTORE_HOST}" +GHE_HOSTNAME="${GHE_HOSTNAME:-$GHE_RESTORE_HOST}" # Hostname without any port suffix hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :) From dc367e7e2794aabaf4de56a508d15a8a6e7d8684 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Fri, 9 Nov 2018 00:09:06 +1100 Subject: [PATCH 0721/2421] fixes fallback to hostname from backup.config --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7373cca7c..484714e7e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -63,7 +63,7 @@ while true; do ;; *) if [ -n "$1" ]; then - GHE_HOSTNAME="$1" + GHE_RESTORE_HOST="$1" shift else break @@ -86,7 +86,7 @@ cleanup () { . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" # Grab the host arg -GHE_HOSTNAME="${GHE_HOSTNAME:-$GHE_RESTORE_HOST}" +GHE_HOSTNAME="$GHE_RESTORE_HOST" # Hostname without any port suffix hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :) From f45938e18cb938620e824e84e6247651d7a2fc01 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 13 Nov 2018 09:34:21 -0800 Subject: [PATCH 0722/2421] Bump version: 2.15.1 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index c1aea2616..3ad41cb27 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.15.1) UNRELEASED; urgency=medium + + * Restoring to an un-configured appliance fails due to a missing license file #449 + + -- Colin Seymour Tue, 13 Nov 2018 17:34:21 +0000 + github-backup-utils (2.15.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 68e69e405..3b1fc7950 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.15.0 +2.15.1 From 98f9a11a8880397dbd8dff064ac2fca6b5e3b8cc Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 30 Nov 2018 16:57:49 +0000 Subject: [PATCH 0723/2421] Cater for v that may occur in the version string --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index aa148a6b1..0d16c704d 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -302,5 +302,5 @@ ghe_debug() { } version() { - echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; + echo "${@#v}" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } From 5e551d24f9fc13c40371e623ac3ac90b74ae57b5 Mon Sep 17 00:00:00 2001 From: Daniel Hwang Date: Mon, 24 Dec 2018 09:05:58 -0800 Subject: [PATCH 0724/2421] GitHub Enterprise Server Signed-off-by: bwestover --- README.md | 23 +++++++++++++---------- RELEASING.md | 6 +++--- backup.config-example | 4 ++-- bin/ghe-host-check | 24 ++++++++++++------------ debian/control | 7 ++++--- script/release | 4 ++-- test/bin/ghe-negotiate-version | 2 +- test/test-ghe-host-check.sh | 2 +- 8 files changed, 38 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 7a52da634..83f832896 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,19 @@ -# GitHub Enterprise Backup Utilities +# GitHub Enterprise Server Backup Utilities -This repository includes backup and recovery utilities for [GitHub Enterprise][1]. +This repository includes backup and recovery utilities for +[GitHub Enterprise Server][1]. -**Note**: the [GitHub Enterprise version requirements](docs/requirements.md#github-enterprise-version-requirements) have +**Note**: the [GitHub Enterprise Server version requirements][2] have changed starting with Backup Utilities v2.13.0, released on 27 March 2018. ### Features Backup Utilities implement a number of advanced capabilities for backup hosts, built on top of the backup and restore features already included in -GitHub Enterprise. +GitHub Enterprise Server. - - Complete GitHub Enterprise backup and recovery system via two simple utilities:
- `ghe-backup` and `ghe-restore`. + - Complete GitHub Enterprise Server backup and recovery system via two simple + utilities:
`ghe-backup` and `ghe-restore`. - Online backups. The GitHub appliance need not be put in maintenance mode for the duration of the backup run. - Incremental backup of Git repository data. Only changes since the last @@ -31,7 +32,7 @@ GitHub Enterprise. - **[Requirements](docs/requirements.md)** - **[Backup host requirements](docs/requirements.md#backup-host-requirements)** - **[Storage requirements](docs/requirements.md#storage-requirements)** - - **[GitHub Enterprise version requirements](docs/requirements.md#github-enterprise-version-requirements)** + - **[GitHub Enterprise Server version requirements](docs/requirements.md#github-enterprise-version-requirements)** - **[Getting started](docs/getting-started.md)** - **[Using the backup and restore commands](docs/usage.md)** - **[Scheduling backups](docs/scheduling-backups.md)** @@ -43,8 +44,10 @@ GitHub Enterprise. If you find a bug or would like to request a feature in Backup Utilities, please open an issue or pull request on this repository. If you have a question related -to your specific GitHub Enterprise setup or would like assistance with backup -site setup or recovery, please contact our [Enterprise support team][2] instead. +to your specific GitHub Enterprise Server setup or would like assistance with +backup site setup or recovery, please contact our [Enterprise support team][3] +instead. [1]: https://enterprise.github.com -[2]: https://enterprise.github.com/support/ +[2]: docs/requirements.md#github-enterprise-version-requirements +[3]: https://enterprise.github.com/support/ diff --git a/RELEASING.md b/RELEASING.md index da56aff57..f46ebe681 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -1,12 +1,12 @@ # Making a Backup Utilities release -Starting with Backup Utilities v2.13.0, all major releases will follow GitHub Enterprise releases and the version support is inline with that of the [GitHub Enterprise upgrade requirements](https://help.github.com/enterprise/admin/guides/installation/about-upgrade-requirements/) and as such, support is limited to three versions of GitHub Enterprise: the version that corresponds with the version of Backup Utilities, and the two releases prior to it. +Starting with Backup Utilities v2.13.0, all major releases will follow GitHub Enterprise Server releases and the version support is inline with that of the [GitHub Enterprise Server upgrade requirements](https://help.github.com/enterprise/admin/guides/installation/about-upgrade-requirements/) and as such, support is limited to three versions of GitHub Enterprise Server: the version that corresponds with the version of Backup Utilities, and the two releases prior to it. For example, Backup Utilities 2.13.0 can be used to backup and restore all patch releases from 2.11.0 to the latest patch release of GitHub Enterprise 2.13. Backup utilities 2.14.0 will be released when GitHub Enterprise 2.14.0 is released and will then be used to backup all releases of GitHub Enterprise from 2.12.0 to the latest patch release of GitHub Enterprise 2.14. -There is no need to align Backup Utilities patch releases with GitHub Enterprise patch releases. +There is no need to align Backup Utilities patch releases with GitHub Enterprise Server patch releases. -When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise that that release supports. +When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise Server that that release supports. ## Automatic Process from chatops (internal to GitHub only) - Coming :soon: diff --git a/backup.config-example b/backup.config-example index 5a38b0c87..1ea7fb61f 100644 --- a/backup.config-example +++ b/backup.config-example @@ -1,6 +1,6 @@ -# GitHub Enterprise backup configuration file +# GitHub Enterprise Server backup configuration file -# The hostname of the GitHub Enterprise appliance to back up. The host +# The hostname of the GitHub Enterprise Server appliance to back up. The host # must be reachable via SSH from the backup host. GHE_HOSTNAME="github.example.com" diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 9aec6deb6..70187af3a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -1,14 +1,14 @@ #!/usr/bin/env bash #/ Usage: ghe-host-check [-h] [--version] [] #/ -#/ Verify connectivity with the GitHub Enterprise host. +#/ Verify connectivity with the GitHub Enterprise Server host. #/ #/ OPTIONS: #/ -h | --help Show this message. #/ --version Display version information. -#/ The GitHub Enterprise host to check. When no is -#/ provided, the $GHE_HOSTNAME configured in backup.config -#/ is assumed. +#/ The GitHub Enterprise Server host to check. When no +#/ is provided, the $GHE_HOSTNAME configured in +#/ backup.config is assumed. #/ set -e @@ -70,7 +70,7 @@ if [ $rc -ne 0 ]; then echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2 ;; 101) - echo "Error: couldn't read GitHub Enterprise fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 + echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 ;; 1) if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then @@ -84,20 +84,20 @@ if [ $rc -ne 0 ]; then exit $rc fi -version=$(echo "$output" | sed -n 's/GitHub Enterprise version \(.*\)/\1/p') +version=$(echo "$output" | sed -E -n 's/GitHub Enterprise( Server)? version (.*)/\2/p') if [ -z "$version" ]; then echo "Error: failed to parse version on '$host' or this isn't a GitHub appliance." 1>&2 exit 2 fi -# Block restoring snapshots to older releases of GitHub Enterprise +# Block restoring snapshots to older releases of GitHub Enterprise Server if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) # shellcheck disable=SC2046 # Word splitting is required to populate the variables read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) if [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version $snapshot_version_major.$snapshot_version_minor.0)" ]; then - echo "Error: Snapshot can not be restored to an older release of GitHub Enterprise." >&2 + echo "Error: Snapshot can not be restored to an older release of GitHub Enterprise Server." >&2 exit 1 fi fi @@ -112,7 +112,7 @@ if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then fi # backup-utils 2.13 onwards limits support to the current and previous two releases -# of GitHub Enterprise. +# of GitHub Enterprise Server. supported_minimum_version="2.13.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then @@ -120,9 +120,9 @@ if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then fi if [ -z "$supported" ]; then - echo "Error: unsupported release of GitHub Enterprise detected." 1>&2 - echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise v$supported_minimum_version or newer." 1>&2 - echo "Please update your GitHub Enterprise appliance or use an older version of Backup Utilities." 1>&2 + echo "Error: unsupported release of GitHub Enterprise Server detected." 1>&2 + echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise Server v$supported_minimum_version or newer." 1>&2 + echo "Please update your GitHub Enterprise Server appliance or use an older version of Backup Utilities." 1>&2 exit 1 fi diff --git a/debian/control b/debian/control index fe79d1e41..e89ff97b7 100644 --- a/debian/control +++ b/debian/control @@ -8,14 +8,15 @@ Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq Package: github-backup-utils Architecture: any Depends: ${misc:Depends}, rsync (>= 2.6.4), moreutils, jq -Description: Backup and recovery utilities for GitHub Enterprise +Description: Backup and recovery utilities for GitHub Enterprise Server The backup utilities implement a number of advanced capabilities for backup hosts, built on top of the backup and restore features already included in - GitHub Enterprise. + GitHub Enterprise Server. . These advanced features include: . - Complete GitHub Enterprise backup and recovery system via two simple utilities: + Complete GitHub Enterprise Server backup and recovery system via two simple + utilities: `ghe-backup` and `ghe-restore`. Online backups. The GitHub appliance need not be put in maintenance mode for the duration of the backup run. diff --git a/script/release b/script/release index d6e3d7233..667457190 100755 --- a/script/release +++ b/script/release @@ -408,7 +408,7 @@ if $PROGRAM_NAME == __FILE__ puts 'Updating changelog...' update_changelog release_changes, DEB_PKG_NAME, version release_body = "Includes general improvements & bug fixes" - release_body += " and support for GitHub Enterprise v#{version}" unless min_version.nil? + release_body += " and support for GitHub Enterprise Server v#{version}" unless min_version.nil? release_changes.each do |c| release_body += "\n* #{c}" end @@ -424,7 +424,7 @@ if $PROGRAM_NAME == __FILE__ tag "v#{version}", res['sha'] puts 'Creating release...' - release_title = "GitHub Enterprise Backup Utilities v#{version}" + release_title = "GitHub Enterprise Server Backup Utilities v#{version}" res = create_release "v#{version}", 'master', release_title, release_body, true # Tidy up before building tarball and deb pkg diff --git a/test/bin/ghe-negotiate-version b/test/bin/ghe-negotiate-version index 1cdbe8612..6fe49c064 100755 --- a/test/bin/ghe-negotiate-version +++ b/test/bin/ghe-negotiate-version @@ -3,5 +3,5 @@ # Emulates the remote GitHub ghe-negotiate-version command. Tests use this # to assert that the command was executed. set -e -echo "GitHub Enterprise version $GHE_TEST_REMOTE_VERSION" +echo "GitHub Enterprise Server version $GHE_TEST_REMOTE_VERSION" echo "backup-utils $2 is supported." diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index cc2afa2c7..5cc3ec72e 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -49,7 +49,7 @@ begin_test "ghe-host-check honours --help and -h flags" ) end_test -begin_test "ghe-host-check detects unsupported GitHub Enterprise versions" +begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions" ( set -e # shellcheck disable=SC2046 # Word splitting is required to populate the variables From 45482f2837a35294793f706abcd8cc3be11df14a Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 14 Jan 2019 15:26:12 +0000 Subject: [PATCH 0725/2421] Make it clear the cmds run on the backup host [ci skip] Fixes https://github.com/github/backup-utils/issues/459 --- docs/usage.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index cc35f4ab7..25801188f 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -8,6 +8,8 @@ After the initial backup, use the following commands: Enterprise appliance. You must add the backup host's SSH key to the target GitHub Enterprise appliance before using this command. +These commands are run on the host you [installed][1] Backup Utilities on. + ### Example backup and restore usage The following assumes that `GHE_HOSTNAME` is set to "github.example.com" in @@ -79,3 +81,5 @@ When restoring to an already configured GitHub Enterprise instance, settings, ce are *not* restored to prevent overwriting manual configuration on the restore host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`, forcing settings, certificate, and license data to be overwritten with the backup copy's data. + +[1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md From 7c9c1122b876bf3f0aff7bd674ecd8b4518ef1cb Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 21 Jan 2019 12:17:30 +0000 Subject: [PATCH 0726/2421] Further clarify version support for very old releases --- docs/requirements.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index 9bce50087..9e5715574 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -40,8 +40,9 @@ Backup Utilities v2.14.0 will be released when GitHub Enterprise 2.14.0 is relea and will then be used to backup all releases of GitHub Enterprise from 2.12.0 to the latest patch release of GitHub Enterprise 2.14. -Backup Utilities v2.11.4 and earlier offer support for GitHub Enterprise 2.10 -and earlier releases. +Backup Utilities v2.11.4 and earlier offer support for GitHub Enterprise Server 2.10 +and earlier releases up to GitHub Enterprise Server 2.2.0. Backup Utilities v2.11.0 and earlier +offer support for GitHub Enterprise Server 2.1.0 and earlier. **Note**: You can restore a snapshot that's at most two feature releases behind the restore target's version of GitHub Enterprise. For example, to restore a From 81ba2e94091a478d381dcd6d2390bbb9cce230db Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 21 Jan 2019 12:18:46 +0000 Subject: [PATCH 0727/2421] Update docs for GitHub Enterprise Server rename --- docs/README.md | 4 ++-- docs/docker.md | 4 ++-- docs/faq.md | 4 ++-- docs/getting-started.md | 4 ++-- docs/requirements.md | 26 +++++++++++++------------- docs/usage.md | 10 +++++----- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/README.md b/docs/README.md index db1d8a085..153549d14 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,9 +1,9 @@ -# GitHub Enterprise Backup Utilities Documentation +# GitHub Enterprise Server Backup Utilities Documentation - **[Requirements](requirements.md)** - **[Backup host requirements](requirements.md#backup-host-requirements)** - **[Storage requirements](requirements.md#storage-requirements)** - - **[GitHub Enterprise version requirements](requirements.md#github-enterprise-version-requirements)** + - **[GitHub Enterprise Server version requirements](requirements.md#github-enterprise-version-requirements)** - **[Getting started](getting-started.md)** - **[Using the backup and restore commands](usage.md)** - **[Scheduling backups](scheduling-backups.md)** diff --git a/docs/docker.md b/docs/docker.md index ad3f11d77..c9798e1b8 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -38,7 +38,7 @@ github/backup-utils ghe-backup ## SSH Keys -A SSH private key that has been added to the GitHub Enterprise [Management Console +A SSH private key that has been added to the GitHub Enterprise Server [Management Console for administrative SSH access][1] needs to be mounted into the container from the host system. It is also recommended to mount a SSH `.ssh/known_hosts` file into the container. @@ -57,7 +57,7 @@ github/backup-utils ghe-backup ### Using ssh-agent If your SSH private key is protected with a passphrase, you can mount the `ssh-agent` -socket from the Docker host into the GitHub Enterprise Backup Utilities image. +socket from the Docker host into the GitHub Enterprise Server Backup Utilities image. 1. Start the ssh-agent in the background. diff --git a/docs/faq.md b/docs/faq.md index 7fa7f7e0d..fc8d53bb0 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -2,10 +2,10 @@ ## How does Backup Utilities differ from a High Availability replica? It is recommended that both Backup Utilities and an [High Availability replica][1] -are used as part of a GitHub Enterprise deployment but they serve different roles. +are used as part of a GitHub Enterprise Server deployment but they serve different roles. ### The purpose of the High Availability replica -The High Availability replica is a fully redundant secondary GitHub Enterprise +The High Availability replica is a fully redundant secondary GitHub Enterprise Server instance, kept in sync with the primary instance via replication of all major datastores. This active/passive cluster configuration is designed to minimize service disruption in the event of hardware failure or major network outage diff --git a/docs/getting-started.md b/docs/getting-started.md index 777b2aa4b..80e141218 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -9,10 +9,10 @@ `git clone -b stable https://github.com/github/backup-utils.git` **Note**: you will need to use [Backup Utilities v2.11.x][2] or the `legacy` branch to - backup and restore GitHub Enterprise 2.10 and earlier. + backup and restore GitHub Enterprise Server 2.10 and earlier. 2. Copy the [`backup.config-example`][3] file to `backup.config` and modify as - necessary. The `GHE_HOSTNAME` value must be set to the primary GitHub Enterprise + necessary. The `GHE_HOSTNAME` value must be set to the primary GitHub Enterprise Server host name. Additional options are available and documented in the configuration file but none are required for basic backup functionality. diff --git a/docs/requirements.md b/docs/requirements.md index 9e5715574..fbdc0b442 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -1,7 +1,7 @@ # Requirements Backup Utilities should be run on a host dedicated to long-term permanent -storage and must have network connectivity with the GitHub Enterprise appliance. +storage and must have network connectivity with the GitHub Enterprise Server appliance. ## Backup host requirements @@ -12,7 +12,7 @@ We encourage the use of [Docker](docker.md) if your backup host doesn't meet the requirements, or if Docker is your preferred platform. The backup host must be able to establish outbound network connections to the -GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise. +GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. ## Storage requirements @@ -22,32 +22,32 @@ of storage allocated to the primary GitHub appliance for historical snapshots and growth over time. Backup Utilities use [hard links][5] to store data efficiently, and the -repositories on GitHub Enterprise use [symbolic links][6] so the backup snapshots +repositories on GitHub Enterprise Server use [symbolic links][6] so the backup snapshots must be written to a filesystem with support for symbolic and hard links. Using a [case sensitive][7] file system is also required to avoid conflicts. -## GitHub Enterprise version requirements +## GitHub Enterprise Server version requirements Starting with Backup Utilities v2.13.0, version support is inline with that of the -[GitHub Enterprise upgrade requirements][8] and as such, support is limited to -three versions of GitHub Enterprise: the version that corresponds with the version +[GitHub Enterprise Server upgrade requirements][8] and as such, support is limited to +three versions of GitHub Enterprise Server: the version that corresponds with the version of Backup Utilities, and the two releases prior to it. For example, Backup Utilities v2.13.0 can be used to backup and restore all patch -releases from 2.11.0 to the latest patch release of GitHub Enterprise 2.13. -Backup Utilities v2.14.0 will be released when GitHub Enterprise 2.14.0 is released -and will then be used to backup all releases of GitHub Enterprise from 2.12.0 -to the latest patch release of GitHub Enterprise 2.14. +releases from 2.11.0 to the latest patch release of GitHub Enterprise Server 2.13. +Backup Utilities v2.14.0 will be released when GitHub Enterprise Server 2.14.0 is released +and will then be used to backup all releases of GitHub Enterprise Server from 2.12.0 +to the latest patch release of GitHub Enterprise Server 2.14. Backup Utilities v2.11.4 and earlier offer support for GitHub Enterprise Server 2.10 and earlier releases up to GitHub Enterprise Server 2.2.0. Backup Utilities v2.11.0 and earlier offer support for GitHub Enterprise Server 2.1.0 and earlier. **Note**: You can restore a snapshot that's at most two feature releases behind -the restore target's version of GitHub Enterprise. For example, to restore a -snapshot of GitHub Enterprise 2.11, the target GitHub Enterprise appliance must -be running GitHub Enterprise 2.12.x or 2.13.x. You can't restore a snapshot from +the restore target's version of GitHub Enterprise Server. For example, to restore a +snapshot of GitHub Enterprise Server 2.11, the target GitHub Enterprise Server appliance must +be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapshot from 2.10 to 2.13, because that's three releases ahead. [1]: https://www.gnu.org/software/bash/ diff --git a/docs/usage.md b/docs/usage.md index 25801188f..94f163797 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -6,7 +6,7 @@ After the initial backup, use the following commands: along with full snapshots of all other pertinent data stores. - The `ghe-restore` command restores snapshots to the same or separate GitHub Enterprise appliance. You must add the backup host's SSH key to the target - GitHub Enterprise appliance before using this command. + GitHub Enterprise Server appliance before using this command. These commands are run on the host you [installed][1] Backup Utilities on. @@ -36,7 +36,7 @@ Creating a backup snapshot: Checking for leaked ssh keys ... * No leaked keys found -Restoring from last successful snapshot to a newly provisioned GitHub Enterprise +Restoring from last successful snapshot to a newly provisioned GitHub Enterprise Server appliance at IP "5.5.5.5": $ ghe-restore 5.5.5.5 @@ -72,12 +72,12 @@ The `ghe-backup` and `ghe-restore` commands also have a verbose output mode (`-v`) that lists files as they're being transferred. It's often useful to enable when output is logged to a file. -When restoring to a new GitHub Enterprise instance, settings, certificate, and +When restoring to a new GitHub Enterprise Server instance, settings, certificate, and license data *are* restored. These settings must be reviewed and saved before -using the GitHub Enterprise to ensure all migrations take place and all required +using the GitHub Enterprise Server to ensure all migrations take place and all required services are started. -When restoring to an already configured GitHub Enterprise instance, settings, certificate, and license data +When restoring to an already configured GitHub Enterprise Server instance, settings, certificate, and license data are *not* restored to prevent overwriting manual configuration on the restore host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`, forcing settings, certificate, and license data to be overwritten with the backup copy's data. From b66c63465a9bff3fdefc2f8961c784d1b08ad7cd Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 22 Jan 2019 11:53:01 -0800 Subject: [PATCH 0728/2421] Bump version: 2.16.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 70187af3a..87ed13888 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.13.0" +supported_minimum_version="2.14.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 3ad41cb27..5e82ae7e4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.16.0) UNRELEASED; urgency=medium + + * Cater for v that may occur in the version string #458 + + -- Colin Seymour Tue, 22 Jan 2019 19:53:01 +0000 + github-backup-utils (2.15.1) UNRELEASED; urgency=medium * Restoring to an un-configured appliance fails due to a missing license file #449 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 3b1fc7950..752490696 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.15.1 +2.16.0 diff --git a/test/testlib.sh b/test/testlib.sh index 28f86e694..1763d87af 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.15.0} +: ${GHE_TEST_REMOTE_VERSION:=2.16.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 2ae5b62d589fbb9e79d32e29256ec8feb0234028 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 22 Jan 2019 12:00:06 -0800 Subject: [PATCH 0729/2421] Revert "Merge pull request #465 from github/release-2.16.0" This reverts commit 341b1812ea466ac0e7cab2d280b0b097604140d7, reversing changes made to 7f92a6a4d59387aba7f8a7e829ecd56fa9c2668c. --- bin/ghe-host-check | 2 +- debian/changelog | 6 ------ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 87ed13888..70187af3a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.14.0" +supported_minimum_version="2.13.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 5e82ae7e4..3ad41cb27 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,3 @@ -github-backup-utils (2.16.0) UNRELEASED; urgency=medium - - * Cater for v that may occur in the version string #458 - - -- Colin Seymour Tue, 22 Jan 2019 19:53:01 +0000 - github-backup-utils (2.15.1) UNRELEASED; urgency=medium * Restoring to an un-configured appliance fails due to a missing license file #449 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 752490696..3b1fc7950 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.16.0 +2.15.1 diff --git a/test/testlib.sh b/test/testlib.sh index 1763d87af..28f86e694 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.16.0} +: ${GHE_TEST_REMOTE_VERSION:=2.15.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From c2f7b85e24bf3a35983ec2ae509c19888be76dc3 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 22 Jan 2019 12:03:06 -0800 Subject: [PATCH 0730/2421] Test against 2.14 and 2.16 --- script/cibuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/cibuild b/script/cibuild index d06fe54e7..a8fa946a5 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,8 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.13.0 - 2.15.0 + 2.14.0 + 2.16.0 " # Enable verbose logging of ssh commands From 658349d687f708fa039baf91ba512a3027079c09 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 22 Jan 2019 12:05:27 -0800 Subject: [PATCH 0731/2421] Bump version: 2.16.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 70187af3a..87ed13888 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.13.0" +supported_minimum_version="2.14.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 3ad41cb27..ea30b4c52 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (2.16.0) UNRELEASED; urgency=medium + + + -- Colin Seymour Tue, 22 Jan 2019 20:05:27 +0000 + github-backup-utils (2.15.1) UNRELEASED; urgency=medium * Restoring to an un-configured appliance fails due to a missing license file #449 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 3b1fc7950..752490696 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.15.1 +2.16.0 diff --git a/test/testlib.sh b/test/testlib.sh index 28f86e694..1763d87af 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.15.0} +: ${GHE_TEST_REMOTE_VERSION:=2.16.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 5230b6a68bdf5d1719e156a25a26845ea1aaf3b6 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 22 Jan 2019 12:10:54 -0800 Subject: [PATCH 0732/2421] Revert "Merge pull request #466 from github/release-2.16.0" This reverts commit f6c7348861546e5279ccf77cdf159c42946aa134, reversing changes made to 341b1812ea466ac0e7cab2d280b0b097604140d7. --- debian/changelog | 3 ++- script/cibuild | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index ea30b4c52..5e82ae7e4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,8 @@ github-backup-utils (2.16.0) UNRELEASED; urgency=medium + * Cater for v that may occur in the version string #458 - -- Colin Seymour Tue, 22 Jan 2019 20:05:27 +0000 + -- Colin Seymour Tue, 22 Jan 2019 19:53:01 +0000 github-backup-utils (2.15.1) UNRELEASED; urgency=medium diff --git a/script/cibuild b/script/cibuild index a8fa946a5..d06fe54e7 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,8 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.14.0 - 2.16.0 + 2.13.0 + 2.15.0 " # Enable verbose logging of ssh commands From 344169549347439f4fcc9bb7e36bc4d6e44773f8 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 22 Jan 2019 12:11:39 -0800 Subject: [PATCH 0733/2421] Revert "Merge pull request #465 from github/release-2.16.0" This reverts commit 341b1812ea466ac0e7cab2d280b0b097604140d7, reversing changes made to 7f92a6a4d59387aba7f8a7e829ecd56fa9c2668c. --- bin/ghe-host-check | 2 +- debian/changelog | 6 ------ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 87ed13888..70187af3a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.14.0" +supported_minimum_version="2.13.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 5e82ae7e4..3ad41cb27 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,3 @@ -github-backup-utils (2.16.0) UNRELEASED; urgency=medium - - * Cater for v that may occur in the version string #458 - - -- Colin Seymour Tue, 22 Jan 2019 19:53:01 +0000 - github-backup-utils (2.15.1) UNRELEASED; urgency=medium * Restoring to an un-configured appliance fails due to a missing license file #449 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 752490696..3b1fc7950 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.16.0 +2.15.1 diff --git a/test/testlib.sh b/test/testlib.sh index 1763d87af..28f86e694 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.16.0} +: ${GHE_TEST_REMOTE_VERSION:=2.15.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 730fa99221a32cbe33fa262c09c23180ff8876f4 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 22 Jan 2019 12:03:06 -0800 Subject: [PATCH 0734/2421] Test against 2.14 and 2.16 --- script/cibuild | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/cibuild b/script/cibuild index d06fe54e7..a8fa946a5 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,8 +7,8 @@ set -e # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. REMOTE_VERSIONS=" - 2.13.0 - 2.15.0 + 2.14.0 + 2.16.0 " # Enable verbose logging of ssh commands From d330e3f01e8da7a282f839381836e4e12ba597e0 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 22 Jan 2019 12:25:34 -0800 Subject: [PATCH 0735/2421] Bump version: 2.16.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 70187af3a..87ed13888 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.13.0" +supported_minimum_version="2.14.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 3ad41cb27..4372de77c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (2.16.0) UNRELEASED; urgency=medium + + + -- Colin Seymour Tue, 22 Jan 2019 20:25:34 +0000 + github-backup-utils (2.15.1) UNRELEASED; urgency=medium * Restoring to an un-configured appliance fails due to a missing license file #449 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 3b1fc7950..752490696 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.15.1 +2.16.0 diff --git a/test/testlib.sh b/test/testlib.sh index 28f86e694..1763d87af 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.15.0} +: ${GHE_TEST_REMOTE_VERSION:=2.16.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From b0327151a095ed1320394bcbd9c42f0d03d366f9 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 28 Jan 2019 10:14:00 +0000 Subject: [PATCH 0736/2421] Put all versions on same line for easy replacement --- script/cibuild | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/script/cibuild b/script/cibuild index d06fe54e7..6ed4019c6 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,10 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS=" - 2.13.0 - 2.15.0 -" +REMOTE_VERSIONS="2.14.0 2.16.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true From e8a6637ecec083632a554513dfc04e36ddb6cdc5 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 28 Jan 2019 10:41:06 +0000 Subject: [PATCH 0737/2421] Bump min test versions --- script/release | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/script/release b/script/release index 667457190..d5bb57776 100755 --- a/script/release +++ b/script/release @@ -209,6 +209,10 @@ def bump_version(new_version, min_version = nil, path = 'share/github-backup-uti content = File.read('test/testlib.sh') new_content = content.gsub(/GHE_TEST_REMOTE_VERSION:=[0-9]\.[0-9]+\.0/,"GHE_TEST_REMOTE_VERSION:=#{new_version}") File.open('test/testlib.sh', 'w') {|file| file.puts new_content } + + content = File.read('script/cibuild') + new_content = content.gsub(/^REMOTE_VERSIONS=.*$/, "REMOTE_VERSIONS=\"#{min_version} #{new_version}\"") + File.open('script/cibuild', 'w') {|file| file.puts new_content } end end @@ -217,7 +221,7 @@ def push_release_branch(version) raise "Creating release branch failed:\n\n#{out}" end - unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version bin/ghe-host-check test/testlib.sh`) + unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version bin/ghe-host-check test/testlib.sh script/cibuild`) raise "Error committing changelog and version:\n\n#{out}" end From 97e407bfa471c0220985914c6551848afd290e47 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Tue, 29 Jan 2019 21:49:01 -0800 Subject: [PATCH 0738/2421] Remove -H when restoring repositories & gists --- share/github-backup-utils/ghe-restore-repositories | 2 +- share/github-backup-utils/ghe-restore-repositories-gist | 2 +- share/github-backup-utils/ghe-restore-repositories-rsync | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 6cf7f059e..23e5afa6d 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -147,7 +147,7 @@ for file_list in $tempdir/*.rsync; do server=$host fi ghe_verbose "* Transferring repository networks to $server ..." - ghe-rsync -avrHR --delete \ + ghe-rsync -avrR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index c4fb66363..4513c295c 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -139,7 +139,7 @@ for file_list in $tempdir/*.rsync; do server=$host fi ghe_verbose "* Transferring gists to $server" - ghe-rsync -avrHR --delete \ + ghe-rsync -avrR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ diff --git a/share/github-backup-utils/ghe-restore-repositories-rsync b/share/github-backup-utils/ghe-restore-repositories-rsync index af758f95f..b151a6645 100755 --- a/share/github-backup-utils/ghe-restore-repositories-rsync +++ b/share/github-backup-utils/ghe-restore-repositories-rsync @@ -37,7 +37,7 @@ ghe-gc-disable $GHE_HOSTNAME # Transfer all git repository data from the latest snapshot to the GitHub # instance in a single rsync invocation. -ghe-rsync -avH --delete \ +ghe-rsync -av --delete \ --exclude ".sync_in_progress" \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u git rsync" \ From 6629efc167758016f04b8da986f3c280bfcb5aa8 Mon Sep 17 00:00:00 2001 From: John Stautinger Date: Fri, 8 Feb 2019 09:31:18 -0500 Subject: [PATCH 0739/2421] Fix broken link --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index fbdc0b442..d91079bc2 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -57,4 +57,4 @@ be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapsh [5]: https://en.wikipedia.org/wiki/Hard_link [6]: https://en.wikipedia.org/wiki/Symbolic_link [7]: https://en.wikipedia.org/wiki/Case_sensitivity -[8]: https://help.github.com/enterprise/admin/guides/installation/about-upgrade-requirements/ +[8]: https://help.github.com/enterprise/admin/guides/installation/upgrade-requirements/ From 294e4bbd84e154bac985813f554c097f09bd9962 Mon Sep 17 00:00:00 2001 From: Ben Gollmer Date: Sun, 17 Feb 2019 19:24:23 -0800 Subject: [PATCH 0740/2421] Detect storage user on each host being backed up/restored --- share/github-backup-utils/ghe-backup-storage | 3 +-- share/github-backup-utils/ghe-restore-storage | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index e8fab4eb4..5078adcd1 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -113,12 +113,11 @@ if ! ls $tempdir/*.rsync >/dev/null 2>&1; then exit 0 fi -storage_user=$(ghe-ssh "$GHE_HOSTNAME" -- stat -c %U /data/user/storage || echo git) - # rsync all the storage objects bm_start "$(basename $0) - Storage object sync" for file_list in $tempdir/*.rsync; do hostname=$(basename $file_list .rsync) + storage_user=$(ghe-ssh $ssh_config_file_opt $hostname:$port -- stat -c %U /data/user/storage || echo git) object_num=$(cat $file_list | wc -l) ghe_verbose "* Transferring $object_num objects from $hostname" diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 8e7748c3c..c0eac20d5 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -119,8 +119,6 @@ if ! ls $tempdir/*.rsync >/dev/null 2>&1; then exit 0 fi -storage_user=$(ghe-ssh "$GHE_HOSTNAME" -- stat -c %U /data/user/storage || echo git) - # rsync all the objects to the storage server where they belong. # One rsync invocation per server available. bm_start "$(basename $0) - Restoring objects" @@ -130,6 +128,8 @@ for file_list in $tempdir/*.rsync; do else server=$host fi + storage_user=$(ghe-ssh $ssh_config_file_opt $server:$port -- stat -c %U /data/user/storage || echo git) + ghe_verbose "* Transferring data to $server ..." ghe-rsync -arvHR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ From 4287298083184be0e545799fb3613fb2ea469c4f Mon Sep 17 00:00:00 2001 From: JordanSussman Date: Wed, 20 Feb 2019 11:10:19 -0600 Subject: [PATCH 0741/2421] add Dockerfile based on alpine --- Dockerfile.alpine | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile.alpine diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 000000000..203952fe8 --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,22 @@ +FROM alpine:latest + +RUN apk --update --no-cache add \ + tar \ + rsync \ + ca-certificates \ + openssh \ + git \ + bash \ + gawk \ + procps + +WORKDIR /backup-utils +ADD https://github.com/github/backup-utils/archive/stable.tar.gz / +RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils && \ + mv /usr/bin/gawk /usr/bin/awk && \ + rm -r /stable.tar.gz + +RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init + +ENTRYPOINT ["/backup-utils/share/github-backup-utils/ghe-docker-init"] +CMD ["ghe-host-check"] From 1e03ba562713477e513379094e4c3c453fc8cc19 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 26 Feb 2019 08:37:04 -0800 Subject: [PATCH 0742/2421] Bump version: 2.16.1 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 4372de77c..9c94f30a7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.16.1) UNRELEASED; urgency=medium + + * Detect storage user on each cluster host being backed up or restored #472 + + -- Colin Seymour Tue, 26 Feb 2019 16:37:04 +0000 + github-backup-utils (2.16.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 752490696..0e7079b69 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.16.0 +2.16.1 From 46758320b8aa40a6a410564274520343bdb1d091 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Fri, 1 Mar 2019 17:08:57 +1100 Subject: [PATCH 0743/2421] Fix command line restore target argument being ignored --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 484714e7e..eb2c1acfe 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -63,7 +63,7 @@ while true; do ;; *) if [ -n "$1" ]; then - GHE_RESTORE_HOST="$1" + GHE_RESTORE_HOST_OPT="$1" shift else break @@ -86,7 +86,7 @@ cleanup () { . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" # Grab the host arg -GHE_HOSTNAME="$GHE_RESTORE_HOST" +GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" # Hostname without any port suffix hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :) From 49eb7985c6322e44a716b94f55fc84cd551f653f Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Mar 2019 11:15:07 +0000 Subject: [PATCH 0744/2421] Explicitly state a language If no language is specified, Travis falls back to Ruby. We don't need Ruby for anything other than script/release so lets speed up CI by not installing ruby. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e1e05d8f9..d8e789a6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ --- +language: bash matrix: include: - os: osx From d5ec6a017a1b351be29c3bb318210bd9297bad4c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Mar 2019 11:38:26 +0000 Subject: [PATCH 0745/2421] Use minimal "language" for travis testing --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d8e789a6b..e8b540837 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ --- -language: bash +language: minimal matrix: include: - os: osx From f452cc0eb07f2722c34874297dceabd9cc8d4469 Mon Sep 17 00:00:00 2001 From: juruen Date: Mon, 8 Apr 2019 00:39:42 -0700 Subject: [PATCH 0746/2421] add ghe-backup-mysql-audit-log --- .../ghe-backup-mysql-audit-log | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100755 share/github-backup-utils/ghe-backup-mysql-audit-log diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log new file mode 100755 index 000000000..4cf78a15c --- /dev/null +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-mysql-audit-log +#/ Take a backup of audit logs in MySQL. +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-backup. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +export_tool="/usr/local/share/enterprise/ghe-export-audit-logs" + +# Setup GHE_REMOTE_XXX variables, host and make sure work dir is created +setup(){ + # Perform a host-check and establish GHE_REMOTE_XXX variables. + ghe_remote_version_required "$host" + + # Set up remote host and root elastic backup directory based on config + host="$GHE_HOSTNAME" + + # Make sure root backup dir exists if this is the first run + mkdir -p "$GHE_SNAPSHOT_DIR/audit-log-mysql" + + log=$(mktemp -t ghe-backup-mysql-audit-log-XXXXXX) + + trap cleanup EXIT +} + +# Clean up after exit +cleanup(){ + test -e "$log" || return + + [ -n "$GHE_VERBOSE" ] && cat $log + rm -f $log +} + +# Use $export_tool to fetch the current metadata for all stored +# months in MySQL. For each month: number of entries, minum ID, maximum ID +fetch_current_meta(){ + local meta + if ! meta=$(ghe-ssh "$host" "github-env $export_tool months" 2>>$log); then + echo "Error: failed to retrieve audit log metadata" 1>&2 + exit 1 + fi + + [ -z "$meta" ] && return 1 + + echo "$meta" +} + +# Check if a month data exists in the current snapshot. Use its +# size, minimum ID and maximum ID to assume it's the same if +# they all match. +is_month_synced(){ + local meta="$1" + local name=$2 + + local dir="$GHE_DATA_DIR/current/audit-log-mysql" + + test -f "${dir}/${name}.gz" || return 1 + test -f "${dir}/${name}.meta" || return 1 + + [ "$(cat "${dir}/${name}.meta")" = "$meta" ] +} + +# Dump a month of audit entries from MySQL and store it +# in $name.gz. +# Create $name.meta with number of entries, minimum ID and maximum ID. +dump_month(){ + local meta="$1" + local name=$2 + + local dir="$GHE_SNAPSHOT_DIR/audit-log-mysql" + echo "sudo $export_tool dump $name | gzip" \ + | ghe-ssh "$host" -- /bin/bash > "${dir}/${name}.gz" 2>>$log + + echo "$meta" > "${dir}/${name}.meta" +} + +# Backup audit log entries: +# +# 1. Fetch metadata about the existing audit log entries in MySQL per month +# (month, number of entries, minumim ID, maximum ID) +# 2. If any month is uptodate in the current snapshot, hardlink it +# 3. Otherwise, dump those month entries from MySQL +do_backup(){ + local meta + if ! meta=$(fetch_current_meta); then + return + fi + + IFS=$'\n' + for month in $meta; do + local month_name + month_name=$(echo "$month" | awk '{print $1}') + + if is_month_synced "$month" "$month_name"; then + # Month is in-sync with current data, create hardlink to it + echo "$month_name is in sync, hardlinking to it.." >>$log + ln "$GHE_DATA_DIR/current/audit-log-mysql/${month_name}.gz" "$GHE_SNAPSHOT_DIR/audit-log-mysql/${month_name}.gz" + ln "$GHE_DATA_DIR/current/audit-log-mysql/${month_name}.meta" "$GHE_SNAPSHOT_DIR/audit-log-mysql/${month_name}.meta" + continue + fi + + dump_month "$month" "$month_name" + done +} + +main(){ + bm_start "$(basename "$0")" + setup + do_backup + bm_end "$(basename "$0")" +} + +main From 4a8259b32666a4c5f6057d3158fc81c383aafb97 Mon Sep 17 00:00:00 2001 From: juruen Date: Mon, 8 Apr 2019 01:15:17 -0700 Subject: [PATCH 0747/2421] add GHE_BACKUP_ES_AUDIT_LOG --- backup.config-example | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backup.config-example b/backup.config-example index 1ea7fb61f..20d3db5e5 100644 --- a/backup.config-example +++ b/backup.config-example @@ -48,3 +48,10 @@ GHE_NUM_SNAPSHOTS=10 # # WARNING: do not enable this, only useful for debugging/development #GHE_BACKUP_FSCK=no + +# If set to 'no', Elasticsearch audit log indices will not be backed up. +# Note that they will still be backed up from MySQL. This will reduce +# the time and size of the backup process but it will take longer +# for the audit log entries to be searchable as they need to be reindexed +# in Elasticsearch. +#GHE_BACKUP_ES_AUDIT_LOGS=no From 998c5152c9c5fb89e4f896141f87206fe82b3146 Mon Sep 17 00:00:00 2001 From: juruen Date: Mon, 8 Apr 2019 01:16:40 -0700 Subject: [PATCH 0748/2421] add ghe-backup-audit-log to use both mysql and ES --- bin/ghe-backup | 2 +- .../github-backup-utils/ghe-backup-audit-log | 91 +++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100755 share/github-backup-utils/ghe-backup-audit-log diff --git a/bin/ghe-backup b/bin/ghe-backup index af2e9d3cb..3abe96749 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -184,7 +184,7 @@ echo "Backing up Redis database ..." ghe-backup-redis > redis.rdb || failures="$failures redis" echo "Backing up audit log ..." -ghe-backup-es-audit-log || failures="$failures audit-log" +ghe-backup-audit-log || failures="$failures audit-log" echo "Backing up hookshot logs ..." ghe-backup-es-hookshot || failures="$failures hookshot" diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log new file mode 100755 index 000000000..39b20d6af --- /dev/null +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-audit-log +#/ Take a backup of audit logs. +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-backup. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +base_path="$( dirname "${BASH_SOURCE[0]}" )" +. "${base_path}/ghe-backup-config" + +# Setup GHE_REMOTE_XXX variables, host and make sure work dir is created +setup(){ + # Perform a host-check and establish GHE_REMOTE_XXX variables. + ghe_remote_version_required "$host" + + # Set up remote host and root elastic backup directory based on config + host="$GHE_HOSTNAME" + + # Make sure root backup dir exists if this is the first run + mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" + + log=$(mktemp -t ghe-backup-audit-log-XXXXXX) + + trap cleanup EXIT +} + +# Clean up after exit +cleanup(){ + test -e "$log" || return + + [ -n "$GHE_VERBOSE" ] && cat $log + rm -f $log +} + +# Check whether the MySQL import is complete by checking if +# /data/user/common/audit-log-import/complete exists +is_import_complete(){ + ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/complete" +} + +# If the import to MySQL is complete, add a flag in the snapshot to indicate so. +# And also use `ghe-backup-mysql-audit-log` to dump the audit entries. +backup_mysql(){ + if ! is_import_complete; then + echo "Audit log import to MySQL is not complete" >>$log + return + fi + + echo "Audit log import to MySQL is complete" >>$log + touch "$GHE_SNAPSHOT_DIR/audit-log/mysql-import-complete" + ${base_path}/ghe-backup-mysql-audit-log || exit 1 +} + +# Audit log indices in Elasticsearch are backed up when: +# +# - import to MySQL is not complete +# - GHE_BACKUP_ES_AUDIT_LOGS is not set to 'no' +es_backup_enabled(){ + if ! is_import_complete; then + return + fi + + [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no"] +} + +# Use ghe-backup-es-audit-log to back up Elasticsearch indices +backup_es(){ + ${base_path}/ghe-backup-es-audit-log || exit 1 +} + +do_backup(){ + backup_mysql + + if ! es_backup_enabled; then + return + fi + + backup_es +} + +main(){ + bm_start "$(basename "$0")" + setup + do_backup + bm_end "$(basename "$0")" +} + +main From 89ddd3668a2b6d3fc484acc7c9ef943b4ed78160 Mon Sep 17 00:00:00 2001 From: juruen Date: Mon, 8 Apr 2019 01:19:46 -0700 Subject: [PATCH 0749/2421] add test for audit log import --- test/test-ghe-backup.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 9fe8eb9bb..f18420bf9 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -344,3 +344,19 @@ begin_test "ghe-backup missing directories or files on source appliance" verify_all_backedup_data ) end_test + +begin_test "ghe-backup creates audit log import to MySQL flag in snapshot when present" +( + set -e + + mkdir "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import" + touch "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/complete" + + if ! output=$(ghe-backup -v 2>&1); then + echo "Error: failed to backup $output" >&2 + exit 1 + fi + + test -e "$GHE_DATA_DIR/current/audit-log/mysql-import-complete" +) +end_test From 6d1a976e170152212a1bb6995263f1a0e4a6e87e Mon Sep 17 00:00:00 2001 From: juruen Date: Tue, 9 Apr 2019 08:17:30 -0700 Subject: [PATCH 0750/2421] add logic to deal with MySQL and ES audit log restores --- bin/ghe-restore | 4 +- .../github-backup-utils/ghe-backup-audit-log | 22 ++- .../ghe-backup-mysql-audit-log | 16 +- .../github-backup-utils/ghe-restore-audit-log | 89 ++++++++++ .../ghe-restore-mysql-audit-log | 159 ++++++++++++++++++ 5 files changed, 268 insertions(+), 22 deletions(-) create mode 100755 share/github-backup-utils/ghe-restore-audit-log create mode 100755 share/github-backup-utils/ghe-restore-mysql-audit-log diff --git a/bin/ghe-restore b/bin/ghe-restore index 484714e7e..f15ab11df 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -301,8 +301,8 @@ fi # Restore exported audit and hookshot logs to 2.12.9 and newer single nodes and # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then - echo "Restoring Elasticsearch Audit logs ..." - ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 + echo "Restoring Audit logs ..." + ghe-restore-audit-log "$GHE_HOSTNAME" 1>&3 echo "Restoring hookshot logs ..." ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 39b20d6af..353b80752 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -6,9 +6,9 @@ #/ ghe-backup. set -e +base_path="$( dirname "${BASH_SOURCE[0]}" )" # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config -base_path="$( dirname "${BASH_SOURCE[0]}" )" . "${base_path}/ghe-backup-config" # Setup GHE_REMOTE_XXX variables, host and make sure work dir is created @@ -31,8 +31,8 @@ setup(){ cleanup(){ test -e "$log" || return - [ -n "$GHE_VERBOSE" ] && cat $log - rm -f $log + [ -n "$GHE_VERBOSE" ] && cat "$log" + rm -f "$log" } # Check whether the MySQL import is complete by checking if @@ -45,13 +45,13 @@ is_import_complete(){ # And also use `ghe-backup-mysql-audit-log` to dump the audit entries. backup_mysql(){ if ! is_import_complete; then - echo "Audit log import to MySQL is not complete" >>$log + echo "Audit log import to MySQL is not complete" >>"$log" return fi - echo "Audit log import to MySQL is complete" >>$log + echo "Audit log import to MySQL is complete" >>"$log" touch "$GHE_SNAPSHOT_DIR/audit-log/mysql-import-complete" - ${base_path}/ghe-backup-mysql-audit-log || exit 1 + "${base_path}/ghe-backup-mysql-audit-log" || exit 1 } # Audit log indices in Elasticsearch are backed up when: @@ -63,22 +63,20 @@ es_backup_enabled(){ return fi - [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no"] + [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no" ] } # Use ghe-backup-es-audit-log to back up Elasticsearch indices backup_es(){ - ${base_path}/ghe-backup-es-audit-log || exit 1 + "${base_path}/ghe-backup-es-audit-log" || exit 1 } do_backup(){ backup_mysql - if ! es_backup_enabled; then - return + if es_backup_enabled; then + backup_es fi - - backup_es } main(){ diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index 4cf78a15c..88d0ee5b6 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -32,15 +32,15 @@ setup(){ cleanup(){ test -e "$log" || return - [ -n "$GHE_VERBOSE" ] && cat $log - rm -f $log + [ -n "$GHE_VERBOSE" ] && cat "$log" + rm -f "$log" } # Use $export_tool to fetch the current metadata for all stored # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$host" "github-env $export_tool months" 2>>$log); then + if ! meta=$(ghe-ssh "$host" "github-env $export_tool months" 2>>"$log"); then echo "Error: failed to retrieve audit log metadata" 1>&2 exit 1 fi @@ -73,8 +73,8 @@ dump_month(){ local name=$2 local dir="$GHE_SNAPSHOT_DIR/audit-log-mysql" - echo "sudo $export_tool dump $name | gzip" \ - | ghe-ssh "$host" -- /bin/bash > "${dir}/${name}.gz" 2>>$log + echo "$export_tool dump $name | gzip" \ + | ghe-ssh "$host" -- /bin/bash > "${dir}/${name}.gz" 2>>"$log" echo "$meta" > "${dir}/${name}.meta" } @@ -85,7 +85,7 @@ dump_month(){ # (month, number of entries, minumim ID, maximum ID) # 2. If any month is uptodate in the current snapshot, hardlink it # 3. Otherwise, dump those month entries from MySQL -do_backup(){ +backup(){ local meta if ! meta=$(fetch_current_meta); then return @@ -98,7 +98,7 @@ do_backup(){ if is_month_synced "$month" "$month_name"; then # Month is in-sync with current data, create hardlink to it - echo "$month_name is in sync, hardlinking to it.." >>$log + echo "$month_name is in sync, hardlinking to it.." >>"$log" ln "$GHE_DATA_DIR/current/audit-log-mysql/${month_name}.gz" "$GHE_SNAPSHOT_DIR/audit-log-mysql/${month_name}.gz" ln "$GHE_DATA_DIR/current/audit-log-mysql/${month_name}.meta" "$GHE_SNAPSHOT_DIR/audit-log-mysql/${month_name}.meta" continue @@ -111,7 +111,7 @@ do_backup(){ main(){ bm_start "$(basename "$0")" setup - do_backup + backup bm_end "$(basename "$0")" } diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log new file mode 100755 index 000000000..34c571819 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-audit-log +#/ Restore audit logs. +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-backup. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +base_path="$( dirname "${BASH_SOURCE[0]}" )" +. "${base_path}/ghe-backup-config" + +# Show usage and bail with no arguments +[ $# -lt 1 ] && print_usage + +GHE_HOSTNAME="$1" + +# Setup GHE_REMOTE_XXX variables, host and make sure work dir is created +setup(){ + # Perform a host-check and establish GHE_REMOTE_XXX variables. + ghe_remote_version_required "$GHE_HOSTNAME" + + log=$(mktemp -t ghe-restore-audit-log-XXXXXX) + + trap cleanup EXIT +} + +# Clean up after exit +cleanup(){ + test -e "$log" || return + + [ -n "$GHE_VERBOSE" ] && cat "$log" + rm -f "$log" +} + +# Check whether the snapshot comes from an instance +# where the MySQL import was complete +is_import_complete(){ + test -e "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/mysql-import-complete" +} + +# If the import to MySQL is complete, add a flag in the snapshot to indicate so. +# And also use `ghe-backup-mysql-audit-log` to dump the audit entries. +restore_mysql(){ + if ! is_import_complete; then + echo "Audit log import to MySQL is not complete" >>"$log" + return + fi + + ${base_path}/ghe-restore-mysql-audit-log "$GHE_HOSTNAME"|| exit 1 + + echo "Audit log import to MySQL is complete" >>"$log" + ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" +} + +# Audit log indices in Elasticsearch are restored when: +# +# - import to MySQL is not complete +# - GHE_BACKUP_ES_AUDIT_LOGS is not set to 'no' +es_restore_enabled(){ + if ! is_import_complete; then + return + fi + + [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no"] +} + +# Use ghe-restore-es-audit-log to restore Elasticsearch indices +restore_es(){ + ${base_path}/ghe-restore-es-audit-log "$GHE_HOSTNAME"|| exit 1 +} + +do_restore(){ + restore_mysql + + if es_restore_enabled; then + restore_es + fi +} + +main(){ + bm_start "$(basename "$0")" + setup + do_restore + bm_end "$(basename "$0")" +} + +main diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log new file mode 100755 index 000000000..dfe7ab90c --- /dev/null +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -0,0 +1,159 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-audit-log +#/ Restore audit logs. +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-backup. +set -e + +# Bring in the backup configuration +base_path="$( dirname "${BASH_SOURCE[0]}" )" +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "${base_path}/ghe-backup-config" + +export_tool="/usr/local/share/enterprise/ghe-export-audit-logs" + +# Show usage and bail with no arguments +[ $# -lt 1 ] && print_usage "$@" + +GHE_HOSTNAME="$1" + +# Setup GHE_REMOTE_XXX variables, snapshot_dir and log +setup(){ + # Perform a host-check and establish GHE_REMOTE_XXX variables. + ghe_remote_version_required "$GHE_HOSTNAME" + + snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log-mysql" + remote_dir="$GHE_REMOTE_DATA_USER_DIR/tmp" + remote_dump="$remote_dump/month.gz" + skip_prepare=false + + log=$(mktemp -t ghe-restore-mysql-audit-log-XXXXXX) + + ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$remote_dir'" >>"$log" + + trap cleanup EXIT +} + +# Clean up after exit +cleanup(){ + test -e "$log" || return + + [ -n "$GHE_VERBOSE" ] && cat "$log" + rm -f "$log" + + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $remote_dump" +} + +# Use $export_tool to fetch the current metadata for all stored +# months in MySQL. For each month: number of entries, minum ID, maximum ID +fetch_current_meta(){ + local meta + if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "github-env $export_tool months" 2>>"$log"); then + echo "Error: failed to retrieve audit log metadata" >>"$log" + return + fi + + [ -z "$meta" ] && return 1 + + echo "$meta" +} + +# Read the audt log metadata for all stored months in the current snapshot +fetch_snapshot_meta(){ + local indices + if ! indices=$(cat "${snapshot_dir}"/*.meta); then + echo "Snapshot doesn't contain MySQL audit log dumps" >>"$log" + return 1 + fi + + echo "$indices" +} + +# Return metadata of months that need to be restored by +# checking snapshot's metadata vs intances's. +# i.e: metadata doesn't match or doesn't exist in MySQL +# This allows us to do a incremental restore. +notsynced_meta(){ + local snapshot_meta + if ! snapshot_meta=$(fetch_snapshot_meta); then + return + fi + + local current_meta + if ! current_meta=$(fetch_current_meta); then + echo "Current instance doesn't have any audit log entries in MySQL" >>"$log" + skip_prepare=true + echo "$snapshot_meta" + return + fi + + IFS=$'\n' + for m in $snapshot_meta; do + if echo "$current_meta" | grep -qx "$m"; then + echo "$m is in sync" >>"$log" + continue + fi + + echo "$m is NOT in sync" >>"$log" + echo "$m" + done + unset IFS +} + +# Prepare restore: remove audit entries that match the month to be restored to +# avoid ID collisions +prepare_month_restore(){ + local month=$1 + local meta=$2 + + # If table doesn't exist in the first place, we don't need + # to delete anything + if $skip_prepare; then + return + fi + + if ! ghe-ssh "$GHE_HOSTNAME" "github-env $export_tool prepare_restore $meta" 2>>"$log"; then + echo "failed to run $export_tool prepare_restore $meta" >>"$log" + fi +} + +# Restore a month of audit entries +restore_month(){ + local month=$1 + local meta=$2 + + prepare_month_restore "$month" "$meta" + + local dump="$snapshot_dir/${month}.gz" + if ! test -e "$dump"; then + echo "snapshot is missing the $dump file" 2>>"$log" + return 1 + fi + + # Transfer MySQL data from the snapshot to the GitHub instance. + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$remote_dump 2>&1" >>"$log" 2>&1 <"$dump" + + # Import the entries + echo "gunzip -cd $remote_dump | sudo $export_tool restore" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 2>>"$log" +} + +restore(){ + IFS=$'\n' + for month in $(notsynced_meta); do + local month_name + month_name=$(echo "$month" | awk '{print $1}') + + restore_month "$month_name" "$month" + done + unset IFS +} + +main(){ + bm_start "$(basename "$0")" + setup + restore + bm_end "$(basename "$0")" +} + +main From 2a607f974bdbe19bb84601ca85ec8401dfbc2e91 Mon Sep 17 00:00:00 2001 From: juruen Date: Wed, 10 Apr 2019 03:05:31 -0700 Subject: [PATCH 0751/2421] handle table schema --- .../github-backup-utils/ghe-backup-audit-log | 3 +- .../ghe-backup-mysql-audit-log | 71 ++++++++++++++++--- .../ghe-restore-mysql-audit-log | 26 +++++-- 3 files changed, 81 insertions(+), 19 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 353b80752..f18d23734 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -46,12 +46,13 @@ is_import_complete(){ backup_mysql(){ if ! is_import_complete; then echo "Audit log import to MySQL is not complete" >>"$log" + "${base_path}/ghe-backup-mysql-audit-log" --only-schema || exit 1 return fi echo "Audit log import to MySQL is complete" >>"$log" touch "$GHE_SNAPSHOT_DIR/audit-log/mysql-import-complete" - "${base_path}/ghe-backup-mysql-audit-log" || exit 1 + "${base_path}/ghe-backup-mysql-audit-log" --only-schema || exit 1 } # Audit log indices in Elasticsearch are backed up when: diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index 88d0ee5b6..d50e3e8cc 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -2,6 +2,9 @@ #/ Usage: ghe-backup-mysql-audit-log #/ Take a backup of audit logs in MySQL. #/ +#/ Args: +#/ --only-schema (optional: only dump the table schema) +#/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. set -e @@ -11,6 +14,7 @@ set -e . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" export_tool="/usr/local/share/enterprise/ghe-export-audit-logs" +only_schema="$1" # Setup GHE_REMOTE_XXX variables, host and make sure work dir is created setup(){ @@ -20,8 +24,17 @@ setup(){ # Set up remote host and root elastic backup directory based on config host="$GHE_HOSTNAME" + # Where the new MySQL dumps go + snapshot_dir="$GHE_SNAPSHOT_DIR/audit-log-mysql" + + # Where the current MySQL dumps live + current_dir="$GHE_DATA_DIR/current/audit-log-mysql" + + # Wheter we need a full backup and not incremental + force_full_backup=false + # Make sure root backup dir exists if this is the first run - mkdir -p "$GHE_SNAPSHOT_DIR/audit-log-mysql" + mkdir -p "$snapshot_dir" log=$(mktemp -t ghe-backup-mysql-audit-log-XXXXXX) @@ -57,12 +70,43 @@ is_month_synced(){ local meta="$1" local name=$2 - local dir="$GHE_DATA_DIR/current/audit-log-mysql" + test -f "${current_dir}/${name}.gz" || return 1 + test -f "${current_dir}/${name}.meta" || return 1 + + [ "$(cat "${current_dir}/${name}.meta")" = "$meta" ] +} - test -f "${dir}/${name}.gz" || return 1 - test -f "${dir}/${name}.meta" || return 1 +# To compare two schemas, we filter out comments +# and blank lines to only leave SQL statements +filter_schema(){ + local schema="$1" - [ "$(cat "${dir}/${name}.meta")" = "$meta" ] + echo "$schema" | grep -v "^--" | grep -v "^/\\*" | grep . +} + +# Dump table schema and check whether it has changed when +# compared with the schema stored in the current snapshot. +# If it has changed, we can't do an incremental backup +# and all data needs to be dumped in the new snapshot. +dump_schema(){ + local current + current=$(ghe-ssh "$host" "$export_tool dump --schema-only" 2>>"$log") + + echo "$current" | gzip >"${snapshot_dir}/schema.gz" + + if ! test -e "${current_dir}/schema.gz"; then + return + fi + + local previous + previous=$(gunzip -c "${current_dir}/schema.gz") + + if ! diff -Naur <(filter_schema "$current") <(filter_schema "$previous") >>"$log" 2>&1; then + echo "Current and previous schema don't match, forcing full backup" >>"$log" + force_full_backup=true + fi + + echo "Current and previous schemas match" >>"$log" } # Dump a month of audit entries from MySQL and store it @@ -72,11 +116,10 @@ dump_month(){ local meta="$1" local name=$2 - local dir="$GHE_SNAPSHOT_DIR/audit-log-mysql" echo "$export_tool dump $name | gzip" \ - | ghe-ssh "$host" -- /bin/bash > "${dir}/${name}.gz" 2>>"$log" + | ghe-ssh "$host" -- /bin/bash > "${snapshot_dir}/${name}.gz" 2>>"$log" - echo "$meta" > "${dir}/${name}.meta" + echo "$meta" > "${snapshot_dir}/${name}.meta" } # Backup audit log entries: @@ -86,6 +129,12 @@ dump_month(){ # 2. If any month is uptodate in the current snapshot, hardlink it # 3. Otherwise, dump those month entries from MySQL backup(){ + dump_schema + + if $only_schema; then + return + fi + local meta if ! meta=$(fetch_current_meta); then return @@ -96,11 +145,11 @@ backup(){ local month_name month_name=$(echo "$month" | awk '{print $1}') - if is_month_synced "$month" "$month_name"; then + if ! $force_full_backup && is_month_synced "$month" "$month_name"; then # Month is in-sync with current data, create hardlink to it echo "$month_name is in sync, hardlinking to it.." >>"$log" - ln "$GHE_DATA_DIR/current/audit-log-mysql/${month_name}.gz" "$GHE_SNAPSHOT_DIR/audit-log-mysql/${month_name}.gz" - ln "$GHE_DATA_DIR/current/audit-log-mysql/${month_name}.meta" "$GHE_SNAPSHOT_DIR/audit-log-mysql/${month_name}.meta" + ln "${current_dir}/${month_name}.gz" "${snapshot_dir}/${month_name}.gz" + ln "${current_dir}/${month_name}.meta" "${snapshot_dir}/${month_name}.meta" continue fi diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index dfe7ab90c..049050026 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -118,14 +118,11 @@ prepare_month_restore(){ fi } -# Restore a month of audit entries -restore_month(){ - local month=$1 - local meta=$2 +# Restore a SQL dump of audit entries +restore_dump(){ + local name=$1 - prepare_month_restore "$month" "$meta" - - local dump="$snapshot_dir/${month}.gz" + local dump="$snapshot_dir/${name}.gz" if ! test -e "$dump"; then echo "snapshot is missing the $dump file" 2>>"$log" return 1 @@ -138,7 +135,22 @@ restore_month(){ echo "gunzip -cd $remote_dump | sudo $export_tool restore" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 2>>"$log" } +# Restore a month of audit entries +restore_month(){ + local month=$1 + local meta=$2 + + prepare_month_restore "$month" "$meta" + restore_dump "$month" +} + +restore_schema(){ + restore_dump schema +} + restore(){ + restore_schema + IFS=$'\n' for month in $(notsynced_meta); do local month_name From 410e28060fdd5ea0d4f6be898f308c493039d7c9 Mon Sep 17 00:00:00 2001 From: juruen Date: Wed, 10 Apr 2019 03:52:22 -0700 Subject: [PATCH 0752/2421] support old snapshots --- .../github-backup-utils/ghe-backup-audit-log | 8 +++---- .../ghe-backup-mysql-audit-log | 2 +- .../github-backup-utils/ghe-restore-audit-log | 24 ++++++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index f18d23734..44d7ec45d 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -44,15 +44,15 @@ is_import_complete(){ # If the import to MySQL is complete, add a flag in the snapshot to indicate so. # And also use `ghe-backup-mysql-audit-log` to dump the audit entries. backup_mysql(){ + "${base_path}/ghe-backup-mysql-audit-log" + if ! is_import_complete; then echo "Audit log import to MySQL is not complete" >>"$log" - "${base_path}/ghe-backup-mysql-audit-log" --only-schema || exit 1 return fi echo "Audit log import to MySQL is complete" >>"$log" touch "$GHE_SNAPSHOT_DIR/audit-log/mysql-import-complete" - "${base_path}/ghe-backup-mysql-audit-log" --only-schema || exit 1 } # Audit log indices in Elasticsearch are backed up when: @@ -72,7 +72,7 @@ backup_es(){ "${base_path}/ghe-backup-es-audit-log" || exit 1 } -do_backup(){ +backup(){ backup_mysql if es_backup_enabled; then @@ -83,7 +83,7 @@ do_backup(){ main(){ bm_start "$(basename "$0")" setup - do_backup + backup bm_end "$(basename "$0")" } diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index d50e3e8cc..f5177ce41 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -131,7 +131,7 @@ dump_month(){ backup(){ dump_schema - if $only_schema; then + if [ -n "$only_schema" ]; then return fi diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 34c571819..c7bc896f8 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -7,12 +7,12 @@ set -e # Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config base_path="$( dirname "${BASH_SOURCE[0]}" )" +# shellcheck source=share/github-backup-utils/ghe-backup-config . "${base_path}/ghe-backup-config" # Show usage and bail with no arguments -[ $# -lt 1 ] && print_usage +[ $# -lt 1 ] && print_usage "$@" GHE_HOSTNAME="$1" @@ -40,16 +40,22 @@ is_import_complete(){ test -e "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/mysql-import-complete" } +# Check whether the snapshot was taken on an instance +# where MySQL audit logs were enabled +mysql_restored_enabled(){ + test -e "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log-mysql" +} + +# Use `ghe-backup-mysql-audit-log` to dump the audit entries. # If the import to MySQL is complete, add a flag in the snapshot to indicate so. -# And also use `ghe-backup-mysql-audit-log` to dump the audit entries. restore_mysql(){ + "${base_path}/ghe-restore-mysql-audit-log" "$GHE_HOSTNAME" + if ! is_import_complete; then echo "Audit log import to MySQL is not complete" >>"$log" return fi - ${base_path}/ghe-restore-mysql-audit-log "$GHE_HOSTNAME"|| exit 1 - echo "Audit log import to MySQL is complete" >>"$log" ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" } @@ -63,16 +69,18 @@ es_restore_enabled(){ return fi - [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no"] + [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no" ] } # Use ghe-restore-es-audit-log to restore Elasticsearch indices restore_es(){ - ${base_path}/ghe-restore-es-audit-log "$GHE_HOSTNAME"|| exit 1 + "${base_path}/ghe-restore-es-audit-log" "$GHE_HOSTNAME" } do_restore(){ - restore_mysql + if mysql_restored_enabled; then + restore_mysql + fi if es_restore_enabled; then restore_es From 90dc7160fef507b85c03aed07ead0c9f02b9d95c Mon Sep 17 00:00:00 2001 From: juruen Date: Thu, 11 Apr 2019 07:32:40 -0700 Subject: [PATCH 0753/2421] check export tool --- share/github-backup-utils/ghe-backup-mysql-audit-log | 9 +++++++++ share/github-backup-utils/ghe-restore-mysql-audit-log | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index f5177ce41..11e70c536 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -122,6 +122,11 @@ dump_month(){ echo "$meta" > "${snapshot_dir}/${name}.meta" } +# Check if the export tool is available in this version +export_tool_available(){ + ghe-ssh "$host" "test -e $export_tool" +} + # Backup audit log entries: # # 1. Fetch metadata about the existing audit log entries in MySQL per month @@ -129,6 +134,10 @@ dump_month(){ # 2. If any month is uptodate in the current snapshot, hardlink it # 3. Otherwise, dump those month entries from MySQL backup(){ + if ! export_tool_available; then + return + fi + dump_schema if [ -n "$only_schema" ]; then diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index 049050026..b2ae82160 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -148,7 +148,16 @@ restore_schema(){ restore_dump schema } +# Check if the export tool is available in this version +export_tool_available(){ + ghe-ssh "$GHE_HOSTNAME" "test -e $export_tool" +} + restore(){ + if ! export_tool_available; then + return + fi + restore_schema IFS=$'\n' From 013b2de1501e5b09c42c5fb384792b8e380fb5f7 Mon Sep 17 00:00:00 2001 From: juruen Date: Thu, 11 Apr 2019 07:36:57 -0700 Subject: [PATCH 0754/2421] add restore test --- test/test-ghe-restore.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 4477686be..5ec573396 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -246,6 +246,32 @@ begin_test "ghe-restore with no pages backup" ) end_test +begin_test "ghe-restore creates audit log import to MySQL flag in file system when present" +( + set -e + + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + touch "$GHE_DATA_DIR/current/audit-log/mysql-import-complete" + mkdir "$GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import" + + if ! output=$(ghe-restore -v -f localhost 2>&1); then + echo "Error: failed to restore $output" >&2 + exit 1 + fi + + flag="$GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" + test -e "$flag" || { + echo "Error: the restore process should've created $flag" >&2 + exit 1 + } +) +end_test + begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e From 149d7b59ff274acce9fac43ea40466acf449eed9 Mon Sep 17 00:00:00 2001 From: juruen Date: Thu, 11 Apr 2019 07:44:09 -0700 Subject: [PATCH 0755/2421] create missing dir --- test/test-ghe-restore.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 5ec573396..fe7e6f1c7 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -256,6 +256,7 @@ begin_test "ghe-restore creates audit log import to MySQL flag in file system wh # set as configured, enable maintenance mode and create required directories setup_maintenance_mode "configured" + mkdir "$GHE_DATA_DIR/current/audit-log-mysql" touch "$GHE_DATA_DIR/current/audit-log/mysql-import-complete" mkdir "$GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import" From 0bd2023cabf0f213e5d5a863d78605e35da3d1fe Mon Sep 17 00:00:00 2001 From: juruen Date: Fri, 12 Apr 2019 03:44:21 -0700 Subject: [PATCH 0756/2421] check audit log import skip flag --- share/github-backup-utils/ghe-backup-audit-log | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 44d7ec45d..eae454407 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -41,9 +41,20 @@ is_import_complete(){ ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/complete" } +# Check whether the MySQL import is disable by verifying if +# /data/user/common/audit-log-import/skip exists +is_import_disabled(){ + ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip" +} + # If the import to MySQL is complete, add a flag in the snapshot to indicate so. # And also use `ghe-backup-mysql-audit-log` to dump the audit entries. backup_mysql(){ + if is_import_disabled; then + "${base_path}/ghe-backup-mysql-audit-log" --schema-only + return + fi + "${base_path}/ghe-backup-mysql-audit-log" if ! is_import_complete; then From 7e44a999449264588dd4b0fef1437ec1b6fe1894 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Sat, 13 Apr 2019 13:16:12 +0200 Subject: [PATCH 0757/2421] use builtin gzip/gunzip in export tool --- share/github-backup-utils/ghe-backup-mysql-audit-log | 4 +--- share/github-backup-utils/ghe-restore-mysql-audit-log | 7 ++----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index 11e70c536..c8c202825 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -116,9 +116,7 @@ dump_month(){ local meta="$1" local name=$2 - echo "$export_tool dump $name | gzip" \ - | ghe-ssh "$host" -- /bin/bash > "${snapshot_dir}/${name}.gz" 2>>"$log" - + ghe-ssh "$host" "$export_tool dump --use-gzip=true dump $name" >"${snapshot_dir}/${name}.gz" 2>>"$log" echo "$meta" > "${snapshot_dir}/${name}.meta" } diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index b2ae82160..819a91dd6 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -128,11 +128,8 @@ restore_dump(){ return 1 fi - # Transfer MySQL data from the snapshot to the GitHub instance. - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$remote_dump 2>&1" >>"$log" 2>&1 <"$dump" - - # Import the entries - echo "gunzip -cd $remote_dump | sudo $export_tool restore" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 2>>"$log" + # Transfer MySQL data from the snapshot to the GitHub instance and restore it on the fly + ghe-ssh "$GHE_HOSTNAME" -- "sudo $export_tool restore --use-gunzip=true" >>"$log" 2>&1 <"$dump" } # Restore a month of audit entries From 110795176a664042e3b2f17730de5ecde208333e Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Sat, 13 Apr 2019 14:40:52 +0200 Subject: [PATCH 0758/2421] fix use of dump command --- share/github-backup-utils/ghe-backup-mysql-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index c8c202825..15779f4f9 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -116,7 +116,7 @@ dump_month(){ local meta="$1" local name=$2 - ghe-ssh "$host" "$export_tool dump --use-gzip=true dump $name" >"${snapshot_dir}/${name}.gz" 2>>"$log" + ghe-ssh "$host" "$export_tool dump --use-gzip=true $name" >"${snapshot_dir}/${name}.gz" 2>>"$log" echo "$meta" > "${snapshot_dir}/${name}.meta" } From c24d9b92860e390643fdeb4a781563d490d3eba2 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 15 Apr 2019 12:17:58 +0200 Subject: [PATCH 0759/2421] use ghe-export-mysql-audit-logs in /usr/local/bin --- .../github-backup-utils/ghe-backup-mysql-audit-log | 11 +++++------ .../ghe-restore-mysql-audit-log | 14 ++++++-------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index 15779f4f9..b5a7ae71a 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -13,7 +13,6 @@ set -e # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -export_tool="/usr/local/share/enterprise/ghe-export-audit-logs" only_schema="$1" # Setup GHE_REMOTE_XXX variables, host and make sure work dir is created @@ -49,11 +48,11 @@ cleanup(){ rm -f "$log" } -# Use $export_tool to fetch the current metadata for all stored +# Use ghe-export-audit-logs to fetch the current metadata for all stored # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$host" "github-env $export_tool months" 2>>"$log"); then + if ! meta=$(ghe-ssh "$host" "github-env ghe-export-audit-logs months" 2>>"$log"); then echo "Error: failed to retrieve audit log metadata" 1>&2 exit 1 fi @@ -90,7 +89,7 @@ filter_schema(){ # and all data needs to be dumped in the new snapshot. dump_schema(){ local current - current=$(ghe-ssh "$host" "$export_tool dump --schema-only" 2>>"$log") + current=$(ghe-ssh "$host" "ghe-export-audit-logs dump --schema-only" 2>>"$log") echo "$current" | gzip >"${snapshot_dir}/schema.gz" @@ -116,13 +115,13 @@ dump_month(){ local meta="$1" local name=$2 - ghe-ssh "$host" "$export_tool dump --use-gzip=true $name" >"${snapshot_dir}/${name}.gz" 2>>"$log" + ghe-ssh "$host" "ghe-export-audit-logs dump --use-gzip=true $name" >"${snapshot_dir}/${name}.gz" 2>>"$log" echo "$meta" > "${snapshot_dir}/${name}.meta" } # Check if the export tool is available in this version export_tool_available(){ - ghe-ssh "$host" "test -e $export_tool" + ghe-ssh "$host" "test -e /usr/local/bin/ghe-export-audit-logs" } # Backup audit log entries: diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index 819a91dd6..b1ff90077 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -11,8 +11,6 @@ base_path="$( dirname "${BASH_SOURCE[0]}" )" # shellcheck source=share/github-backup-utils/ghe-backup-config . "${base_path}/ghe-backup-config" -export_tool="/usr/local/share/enterprise/ghe-export-audit-logs" - # Show usage and bail with no arguments [ $# -lt 1 ] && print_usage "$@" @@ -45,11 +43,11 @@ cleanup(){ ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $remote_dump" } -# Use $export_tool to fetch the current metadata for all stored +# Use ghe-export-audit-logs to fetch the current metadata for all stored # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "github-env $export_tool months" 2>>"$log"); then + if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "github-env ghe-export-audit-logs months" 2>>"$log"); then echo "Error: failed to retrieve audit log metadata" >>"$log" return fi @@ -113,8 +111,8 @@ prepare_month_restore(){ return fi - if ! ghe-ssh "$GHE_HOSTNAME" "github-env $export_tool prepare_restore $meta" 2>>"$log"; then - echo "failed to run $export_tool prepare_restore $meta" >>"$log" + if ! ghe-ssh "$GHE_HOSTNAME" "github-env ghe-export-audit-logs prepare_restore $meta" 2>>"$log"; then + echo "failed to run ghe-export-audit-logs prepare_restore $meta" >>"$log" fi } @@ -129,7 +127,7 @@ restore_dump(){ fi # Transfer MySQL data from the snapshot to the GitHub instance and restore it on the fly - ghe-ssh "$GHE_HOSTNAME" -- "sudo $export_tool restore --use-gunzip=true" >>"$log" 2>&1 <"$dump" + ghe-ssh "$GHE_HOSTNAME" -- "sudo ghe-export-audit-logs restore --use-gunzip=true" >>"$log" 2>&1 <"$dump" } # Restore a month of audit entries @@ -147,7 +145,7 @@ restore_schema(){ # Check if the export tool is available in this version export_tool_available(){ - ghe-ssh "$GHE_HOSTNAME" "test -e $export_tool" + ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-export-audit-logs" } restore(){ From 8986f754d5c9a52ef7d84d881613a9fcff73ed1d Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 15 Apr 2019 12:22:44 +0200 Subject: [PATCH 0760/2421] do not use github-env for ghe-export-mysql-audit-log --- share/github-backup-utils/ghe-backup-mysql-audit-log | 2 +- share/github-backup-utils/ghe-restore-mysql-audit-log | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index b5a7ae71a..345a503d8 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -52,7 +52,7 @@ cleanup(){ # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$host" "github-env ghe-export-audit-logs months" 2>>"$log"); then + if ! meta=$(ghe-ssh "$host" "sudo ghe-export-audit-logs months" 2>>"$log"); then echo "Error: failed to retrieve audit log metadata" 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index b1ff90077..2033f241e 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -47,7 +47,7 @@ cleanup(){ # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "github-env ghe-export-audit-logs months" 2>>"$log"); then + if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs months" 2>>"$log"); then echo "Error: failed to retrieve audit log metadata" >>"$log" return fi @@ -111,7 +111,7 @@ prepare_month_restore(){ return fi - if ! ghe-ssh "$GHE_HOSTNAME" "github-env ghe-export-audit-logs prepare_restore $meta" 2>>"$log"; then + if ! ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs prepare_restore $meta" 2>>"$log"; then echo "failed to run ghe-export-audit-logs prepare_restore $meta" >>"$log" fi } From c3b6475935a572b2cc5eb1e949845cce05748982 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 15 Apr 2019 13:08:10 +0200 Subject: [PATCH 0761/2421] improve restore logging --- share/github-backup-utils/ghe-restore-mysql-audit-log | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index 2033f241e..a8b993ee6 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -120,9 +120,11 @@ prepare_month_restore(){ restore_dump(){ local name=$1 + echo "restoring ${name}.gz..." >>"$log" + local dump="$snapshot_dir/${name}.gz" if ! test -e "$dump"; then - echo "snapshot is missing the $dump file" 2>>"$log" + echo "snapshot is missing the $dump file" >>"$log" return 1 fi From 7b9f40003a1e356f08612d5b2191609ec40f4390 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 15 Apr 2019 16:51:07 +0200 Subject: [PATCH 0762/2421] use ghe_verbose and redirections to the log descriptor (3) --- .../ghe-backup-mysql-audit-log | 35 ++++++++----------- .../ghe-restore-mysql-audit-log | 35 ++++++++----------- 2 files changed, 29 insertions(+), 41 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index 345a503d8..44c56ea8b 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -34,26 +34,14 @@ setup(){ # Make sure root backup dir exists if this is the first run mkdir -p "$snapshot_dir" - - log=$(mktemp -t ghe-backup-mysql-audit-log-XXXXXX) - - trap cleanup EXIT -} - -# Clean up after exit -cleanup(){ - test -e "$log" || return - - [ -n "$GHE_VERBOSE" ] && cat "$log" - rm -f "$log" } # Use ghe-export-audit-logs to fetch the current metadata for all stored # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$host" "sudo ghe-export-audit-logs months" 2>>"$log"); then - echo "Error: failed to retrieve audit log metadata" 1>&2 + if ! meta=$(ghe-ssh "$host" "sudo ghe-export-audit-logs months" 2>&3); then + ghe_verbose "Error: failed to retrieve audit log metadata" exit 1 fi @@ -88,8 +76,10 @@ filter_schema(){ # If it has changed, we can't do an incremental backup # and all data needs to be dumped in the new snapshot. dump_schema(){ + ghe_verbose "dumping table schema..." + local current - current=$(ghe-ssh "$host" "ghe-export-audit-logs dump --schema-only" 2>>"$log") + current=$(ghe-ssh "$host" "ghe-export-audit-logs dump --schema-only" 2>&3) echo "$current" | gzip >"${snapshot_dir}/schema.gz" @@ -100,12 +90,12 @@ dump_schema(){ local previous previous=$(gunzip -c "${current_dir}/schema.gz") - if ! diff -Naur <(filter_schema "$current") <(filter_schema "$previous") >>"$log" 2>&1; then - echo "Current and previous schema don't match, forcing full backup" >>"$log" + if ! diff -Naur <(filter_schema "$current") <(filter_schema "$previous") 1>&3 2>&3; then + ghe_verbose "Current and previous schema don't match, forcing full backup" force_full_backup=true fi - echo "Current and previous schemas match" >>"$log" + ghe_verbose "Current and previous schemas match" } # Dump a month of audit entries from MySQL and store it @@ -115,7 +105,9 @@ dump_month(){ local meta="$1" local name=$2 - ghe-ssh "$host" "ghe-export-audit-logs dump --use-gzip=true $name" >"${snapshot_dir}/${name}.gz" 2>>"$log" + ghe_verbose "dumping ${meta}..." + + ghe-ssh "$host" "ghe-export-audit-logs dump --use-gzip=true $name" >"${snapshot_dir}/${name}.gz" 2>&3 echo "$meta" > "${snapshot_dir}/${name}.meta" } @@ -132,17 +124,20 @@ export_tool_available(){ # 3. Otherwise, dump those month entries from MySQL backup(){ if ! export_tool_available; then + ghe_verbose "ghe-export-audit-logs is not available" return fi dump_schema if [ -n "$only_schema" ]; then + ghe_verbose "only table schema was dumped" return fi local meta if ! meta=$(fetch_current_meta); then + ghe_verbose "there are no current audit log entries" return fi @@ -153,7 +148,7 @@ backup(){ if ! $force_full_backup && is_month_synced "$month" "$month_name"; then # Month is in-sync with current data, create hardlink to it - echo "$month_name is in sync, hardlinking to it.." >>"$log" + ghe_verbose "$month_name is in sync, hardlinking to it.." ln "${current_dir}/${month_name}.gz" "${snapshot_dir}/${month_name}.gz" ln "${current_dir}/${month_name}.meta" "${snapshot_dir}/${month_name}.meta" continue diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index a8b993ee6..ef3c04367 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -25,21 +25,14 @@ setup(){ remote_dir="$GHE_REMOTE_DATA_USER_DIR/tmp" remote_dump="$remote_dump/month.gz" skip_prepare=false - - log=$(mktemp -t ghe-restore-mysql-audit-log-XXXXXX) - ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$remote_dir'" >>"$log" + ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$remote_dir'" 1>&3 2>&3 trap cleanup EXIT } # Clean up after exit cleanup(){ - test -e "$log" || return - - [ -n "$GHE_VERBOSE" ] && cat "$log" - rm -f "$log" - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $remote_dump" } @@ -47,8 +40,8 @@ cleanup(){ # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs months" 2>>"$log"); then - echo "Error: failed to retrieve audit log metadata" >>"$log" + if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs months" 2>&3); then + ghe_verbose "Error: failed to retrieve audit log metadata" return fi @@ -60,8 +53,8 @@ fetch_current_meta(){ # Read the audt log metadata for all stored months in the current snapshot fetch_snapshot_meta(){ local indices - if ! indices=$(cat "${snapshot_dir}"/*.meta); then - echo "Snapshot doesn't contain MySQL audit log dumps" >>"$log" + if ! indices=$(cat "${snapshot_dir}"/*.meta 2>/dev/null); then + ghe_verbose "Snapshot doesn't contain MySQL audit log dumps" return 1 fi @@ -80,20 +73,19 @@ notsynced_meta(){ local current_meta if ! current_meta=$(fetch_current_meta); then - echo "Current instance doesn't have any audit log entries in MySQL" >>"$log" + ghe_verbose "Current instance doesn't have any audit log entries in MySQL" skip_prepare=true - echo "$snapshot_meta" return fi IFS=$'\n' for m in $snapshot_meta; do if echo "$current_meta" | grep -qx "$m"; then - echo "$m is in sync" >>"$log" + ghe_verbose "$m is in sync" continue fi - echo "$m is NOT in sync" >>"$log" + ghe_verbose "$m is NOT in sync" echo "$m" done unset IFS @@ -111,8 +103,8 @@ prepare_month_restore(){ return fi - if ! ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs prepare_restore $meta" 2>>"$log"; then - echo "failed to run ghe-export-audit-logs prepare_restore $meta" >>"$log" + if ! ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs prepare_restore $meta" 2>&3; then + ghe_verbose "failed to run ghe-export-audit-logs prepare_restore $meta" fi } @@ -120,16 +112,16 @@ prepare_month_restore(){ restore_dump(){ local name=$1 - echo "restoring ${name}.gz..." >>"$log" + ghe_verbose "restoring ${name}.gz..." local dump="$snapshot_dir/${name}.gz" if ! test -e "$dump"; then - echo "snapshot is missing the $dump file" >>"$log" + ghe_verbose "snapshot is missing the $dump file" return 1 fi # Transfer MySQL data from the snapshot to the GitHub instance and restore it on the fly - ghe-ssh "$GHE_HOSTNAME" -- "sudo ghe-export-audit-logs restore --use-gunzip=true" >>"$log" 2>&1 <"$dump" + ghe-ssh "$GHE_HOSTNAME" -- "sudo ghe-export-audit-logs restore --use-gunzip=true" 1>&3 2>&3 <"$dump" } # Restore a month of audit entries @@ -152,6 +144,7 @@ export_tool_available(){ restore(){ if ! export_tool_available; then + ghe_verbose "ghe-export-audit-logs is not available" return fi From 64439b958771756ec2b388e8e49cba737336e24c Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 15 Apr 2019 17:02:09 +0200 Subject: [PATCH 0763/2421] comment and simplify mysql audit log changes --- .../ghe-backup-mysql-audit-log | 5 +++-- .../ghe-restore-mysql-audit-log | 21 ++++++------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index 44c56ea8b..a4d48fb0b 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -6,16 +6,17 @@ #/ --only-schema (optional: only dump the table schema) #/ #/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. +#/ ghe-backup-audit-log. set -e # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +# Whether we just need to dump the table schema and no data only_schema="$1" -# Setup GHE_REMOTE_XXX variables, host and make sure work dir is created +# Setup GHE_REMOTE_XXX variables and other global variables setup(){ # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index ef3c04367..bdf4a9243 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -1,9 +1,9 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-audit-log -#/ Restore audit logs. +#/ Usage: ghe-restore-mysql-audit-log +#/ Restore MySQL audit logs. #/ #/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. +#/ ghe-restore-audit-log set -e # Bring in the backup configuration @@ -16,24 +16,13 @@ base_path="$( dirname "${BASH_SOURCE[0]}" )" GHE_HOSTNAME="$1" -# Setup GHE_REMOTE_XXX variables, snapshot_dir and log +# Setup GHE_REMOTE_XXX variables, snapshot_dir and skip_prepare setup(){ # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log-mysql" - remote_dir="$GHE_REMOTE_DATA_USER_DIR/tmp" - remote_dump="$remote_dump/month.gz" skip_prepare=false - - ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$remote_dir'" 1>&3 2>&3 - - trap cleanup EXIT -} - -# Clean up after exit -cleanup(){ - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $remote_dump" } # Use ghe-export-audit-logs to fetch the current metadata for all stored @@ -133,6 +122,7 @@ restore_month(){ restore_dump "$month" } +# Restore the audit_entries table schema restore_schema(){ restore_dump schema } @@ -142,6 +132,7 @@ export_tool_available(){ ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-export-audit-logs" } +# Restore table schema and audit entries restore(){ if ! export_tool_available; then ghe_verbose "ghe-export-audit-logs is not available" From c581774a6273f697b4400a66ad0c05f08a6ae7c6 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 15 Apr 2019 18:34:12 +0200 Subject: [PATCH 0764/2421] fix issue showing current metadata --- share/github-backup-utils/ghe-restore-mysql-audit-log | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index bdf4a9243..c88275929 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -64,6 +64,7 @@ notsynced_meta(){ if ! current_meta=$(fetch_current_meta); then ghe_verbose "Current instance doesn't have any audit log entries in MySQL" skip_prepare=true + echo "$snapshot_meta" return fi From 95ee957222108a3f5b3597a3c99dd45c1b23fb50 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 15 Apr 2019 22:19:07 +0200 Subject: [PATCH 0765/2421] more ghe_verbose use --- .../github-backup-utils/ghe-backup-audit-log | 21 ++++++------------- .../ghe-backup-mysql-audit-log | 1 + 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index eae454407..575ee4d9b 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -21,18 +21,6 @@ setup(){ # Make sure root backup dir exists if this is the first run mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" - - log=$(mktemp -t ghe-backup-audit-log-XXXXXX) - - trap cleanup EXIT -} - -# Clean up after exit -cleanup(){ - test -e "$log" || return - - [ -n "$GHE_VERBOSE" ] && cat "$log" - rm -f "$log" } # Check whether the MySQL import is complete by checking if @@ -51,6 +39,8 @@ is_import_disabled(){ # And also use `ghe-backup-mysql-audit-log` to dump the audit entries. backup_mysql(){ if is_import_disabled; then + ghe_verbose "audit log import is configured to be skipped" + "${base_path}/ghe-backup-mysql-audit-log" --schema-only return fi @@ -58,11 +48,11 @@ backup_mysql(){ "${base_path}/ghe-backup-mysql-audit-log" if ! is_import_complete; then - echo "Audit log import to MySQL is not complete" >>"$log" + ghe_verbose "Audit log import to MySQL is not complete" return fi - echo "Audit log import to MySQL is complete" >>"$log" + ghe_verbose "Audit log import to MySQL is complete" touch "$GHE_SNAPSHOT_DIR/audit-log/mysql-import-complete" } @@ -80,13 +70,14 @@ es_backup_enabled(){ # Use ghe-backup-es-audit-log to back up Elasticsearch indices backup_es(){ - "${base_path}/ghe-backup-es-audit-log" || exit 1 + "${base_path}/ghe-backup-es-audit-log" } backup(){ backup_mysql if es_backup_enabled; then + ghe_verbose "Elasticsearch audit logs backup is disabled" backup_es fi } diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index a4d48fb0b..7c4550c38 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -94,6 +94,7 @@ dump_schema(){ if ! diff -Naur <(filter_schema "$current") <(filter_schema "$previous") 1>&3 2>&3; then ghe_verbose "Current and previous schema don't match, forcing full backup" force_full_backup=true + return fi ghe_verbose "Current and previous schemas match" From e0f17e9ed400d6137ec8d16f071428a0ebf60081 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 15 Apr 2019 22:21:34 +0200 Subject: [PATCH 0766/2421] fix typo --- share/github-backup-utils/ghe-backup-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 575ee4d9b..11523d676 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -29,7 +29,7 @@ is_import_complete(){ ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/complete" } -# Check whether the MySQL import is disable by verifying if +# Check whether the MySQL import is disabled by verifying if # /data/user/common/audit-log-import/skip exists is_import_disabled(){ ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip" From d7c3775deeb7de21ed10d021f7e8e0d0d4299107 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Tue, 16 Apr 2019 08:00:25 +0200 Subject: [PATCH 0767/2421] remove AUTO_INCREMENT=XXXX when comparing schemas --- share/github-backup-utils/ghe-backup-mysql-audit-log | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index 7c4550c38..db0cbea7f 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -64,12 +64,17 @@ is_month_synced(){ [ "$(cat "${current_dir}/${name}.meta")" = "$meta" ] } -# To compare two schemas, we filter out comments -# and blank lines to only leave SQL statements +# To compare two schemas, we filter out comments, +# the AUTO_INCREMENT=XXXX value and blank lines +# to only leave SQL statements. filter_schema(){ local schema="$1" - echo "$schema" | grep -v "^--" | grep -v "^/\\*" | grep . + echo "$schema" | \ + grep -v "^--" | + grep -v "^/\\*" | \ + grep . | \ + sed 's/ AUTO_INCREMENT=[0-9]*\b//' } # Dump table schema and check whether it has changed when From 1e5bda890530aabd8cc5a920f2398e26eaeeb5eb Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Tue, 16 Apr 2019 09:11:29 +0200 Subject: [PATCH 0768/2421] restore schema conditionally --- .../ghe-restore-mysql-audit-log | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index c88275929..e095ac402 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -123,9 +123,57 @@ restore_month(){ restore_dump "$month" } -# Restore the audit_entries table schema +# To compare two schemas, we filter out comments, +# the AUTO_INCREMENT=XXXX value and blank lines +# to only leave SQL statements. +filter_schema(){ + local schema="$1" + + echo "$schema" | \ + grep -v "^--" | + grep -v "^/\\*" | \ + grep . | \ + sed 's/ AUTO_INCREMENT=[0-9]*\b//' +} + +# Check whether the snapshot's schema and the instance's +# are the same. If they are not the same, we can't do +# an incremental restore. +has_schema_changed(){ + local current + if ! current=$(ghe-ssh "$GHE_HOSTNAME" "ghe-export-audit-logs dump --schema-only" 2>&3); then + ghe_verbose "Failed to dump current table schema, forcing full restore" + return + fi + + local previous + previous=$(gunzip -c "${snapshot_dir}/schema.gz") + + if ! diff -Naur <(filter_schema "$current") <(filter_schema "$previous") 1>&3 2>&3; then + ghe_verbose "Current and previous schema don't match, forcing full restore" + return + fi + + ghe_verbose "Current and previous schemas match" + return 1 +} + +# Add DROP TABLE to a table schema dump +add_drop_table(){ + # shellcheck disable=SC2016 + sed '/40101 SET @saved_cs_client/i DROP TABLE IF EXISTS `audit_entries`;' +} + +# Restore the audit_entries table schema if it has changed restore_schema(){ - restore_dump schema + if ! has_schema_changed; then + return + fi + + gunzip -c "${snapshot_dir}/schema.gz" | add_drop_table | gzip > "${snapshot_dir}/schema.new.gz" 2>&3 + zcat "${snapshot_dir}/schema.new.gz" 1>&3 + + restore_dump schema.new } # Check if the export tool is available in this version From ae4a194f63167932a2f2b62cebc62b0a359e86c8 Mon Sep 17 00:00:00 2001 From: Craig Errington Date: Wed, 17 Apr 2019 11:28:44 +0100 Subject: [PATCH 0769/2421] slight typo --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 87ed13888..602a2af71 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -106,7 +106,7 @@ if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state 2>/dev/null || true)" = "replica" ]; then echo "Error: high availability replica detected." 1>&2 echo "Backup Utilities should be used to backup from the primary node in" 1>&2 - echo "high availability environments to ensure consistent and repliable backups." 1>&2 + echo "high availability environments to ensure consistent and reliable backups." 1>&2 exit 1 fi fi From 2f534d734c95a5ecdc3f0c160dfa76be15936def Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 17 Apr 2019 14:13:03 +0200 Subject: [PATCH 0770/2421] ignore empty months --- share/github-backup-utils/ghe-restore-mysql-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index e095ac402..eee0adb06 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -29,7 +29,7 @@ setup(){ # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs months" 2>&3); then + if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs months" | grep -v NULL 2>&3); then ghe_verbose "Error: failed to retrieve audit log metadata" return fi From 19b4a883c5d4d31a59da5f1e2d3727523525577e Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 17 Apr 2019 14:16:07 +0200 Subject: [PATCH 0771/2421] ignore empty months during backup as well --- share/github-backup-utils/ghe-backup-mysql-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index db0cbea7f..6665c723d 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -41,7 +41,7 @@ setup(){ # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$host" "sudo ghe-export-audit-logs months" 2>&3); then + if ! meta=$(ghe-ssh "$host" "sudo ghe-export-audit-logs months" | grep -v NULL 2>&3); then ghe_verbose "Error: failed to retrieve audit log metadata" exit 1 fi From c481fedb31573828b672237476e3be6de70fc349 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 18 Apr 2019 10:05:20 +0200 Subject: [PATCH 0772/2421] go back to first upload the dump and later import the entries This mimics what we do with regular MySQL data. --- .../ghe-restore-mysql-audit-log | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index eee0adb06..7526fae87 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -16,13 +16,24 @@ base_path="$( dirname "${BASH_SOURCE[0]}" )" GHE_HOSTNAME="$1" -# Setup GHE_REMOTE_XXX variables, snapshot_dir and skip_prepare +# Setup GHE_REMOTE_XXX variables, snapshot_dir, +# remote_dir, remote_dump and skip_prepare setup(){ # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log-mysql" + remote_dir="$GHE_REMOTE_DATA_USER_DIR/tmp" + remote_dump="$remote_dump/month.gz" skip_prepare=false + + ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$remote_dir'" 1>&3 2>&3 + trap cleanup EXIT +} + +# Clean up on exit +cleanup(){ + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $remote_dump" } # Use ghe-export-audit-logs to fetch the current metadata for all stored @@ -110,8 +121,11 @@ restore_dump(){ return 1 fi - # Transfer MySQL data from the snapshot to the GitHub instance and restore it on the fly - ghe-ssh "$GHE_HOSTNAME" -- "sudo ghe-export-audit-logs restore --use-gunzip=true" 1>&3 2>&3 <"$dump" + # Transfer MySQL data from the snapshot to the GitHub instance. + ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$remote_dump" 1>&3 2>&3 <"$dump" + + # Import the entries + echo "gunzip -cd $remote_dump | sudo ghe-export-audit-logs restore" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 2>&3 } # Restore a month of audit entries From 919844553cdd179326794d10414a9eefa4e46d20 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 18 Apr 2019 15:38:33 +0200 Subject: [PATCH 0773/2421] use ghe_verbose in ghe-restore-audit-log --- .../github-backup-utils/ghe-restore-audit-log | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index c7bc896f8..056f4d391 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -20,18 +20,6 @@ GHE_HOSTNAME="$1" setup(){ # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" - - log=$(mktemp -t ghe-restore-audit-log-XXXXXX) - - trap cleanup EXIT -} - -# Clean up after exit -cleanup(){ - test -e "$log" || return - - [ -n "$GHE_VERBOSE" ] && cat "$log" - rm -f "$log" } # Check whether the snapshot comes from an instance @@ -49,14 +37,16 @@ mysql_restored_enabled(){ # Use `ghe-backup-mysql-audit-log` to dump the audit entries. # If the import to MySQL is complete, add a flag in the snapshot to indicate so. restore_mysql(){ + ghe_verbose "Restoring MySQL audit logs ..." + "${base_path}/ghe-restore-mysql-audit-log" "$GHE_HOSTNAME" if ! is_import_complete; then - echo "Audit log import to MySQL is not complete" >>"$log" + ghe_verbose "Audit log import to MySQL is not complete" return fi - echo "Audit log import to MySQL is complete" >>"$log" + ghe_verbose "Audit log import to MySQL is complete" ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" } @@ -74,16 +64,22 @@ es_restore_enabled(){ # Use ghe-restore-es-audit-log to restore Elasticsearch indices restore_es(){ + ghe_verbose "Restoring Elasticsearch audit logs ..." + "${base_path}/ghe-restore-es-audit-log" "$GHE_HOSTNAME" } do_restore(){ if mysql_restored_enabled; then restore_mysql + else + ghe_verbose "MySQL audit log restore is not enabled" fi if es_restore_enabled; then restore_es + else + ghe_verbose "Elasticsearch audit log restore is not enabled" fi } From df776ec8914cf1d287a8b61f3b8a13e0aaf7af15 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 18 Apr 2019 16:27:30 +0200 Subject: [PATCH 0774/2421] check whether MySQL backup is enabled --- share/github-backup-utils/ghe-backup-audit-log | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 11523d676..d2c12e56e 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -23,6 +23,12 @@ setup(){ mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" } +# Check whether the MySQL backup should be enabled +# by checking if the audit-log-import directory exists +mysql_backup_enabled(){ + ghe-ssh "$host" test -d "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import" +} + # Check whether the MySQL import is complete by checking if # /data/user/common/audit-log-import/complete exists is_import_complete(){ @@ -74,11 +80,18 @@ backup_es(){ } backup(){ - backup_mysql + if mysql_backup_enabled; then + ghe_verbose "MySQL audit logs backup is enabled" + backup_mysql + else + ghe_verbose "MySQL audit logs backup is disabled" + fi if es_backup_enabled; then - ghe_verbose "Elasticsearch audit logs backup is disabled" + ghe_verbose "Elasticsearch audit logs backup is enabled" backup_es + else + ghe_verbose "Elasticsearch audit logs backup is disabled" fi } From 22f555ef4e42beb561b7c81da8c8483781f4c8d9 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Tue, 23 Apr 2019 17:36:45 +1000 Subject: [PATCH 0775/2421] add new ghe-restore command line hostname test --- test/test-ghe-restore.sh | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 4477686be..499e3385b 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -188,6 +188,40 @@ begin_test "ghe-restore into unconfigured vm" ) end_test +begin_test "ghe-restore with host arg and config value" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var (which we shouldn't see) + GHE_RESTORE_HOST="broken.config.restore.host" + export GHE_RESTORE_HOST + + # set restore host config var (which we shouldn't see) + GHE_BACKUP_CONFIG_TEMP="${GHE_BACKUP_CONFIG}.temp" + cp "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_CONFIG_TEMP" + echo 'GHE_RESTORE_HOST="broken.config.restore.host"' >> "$GHE_BACKUP_CONFIG_TEMP" + GHE_BACKUP_CONFIG="$GHE_BACKUP_CONFIG_TEMP" + export GHE_BACKUP_CONFIG + + # run it + output="$(ghe-restore -f localhost)" || false + + # clean up the config file + rm "$GHE_BACKUP_CONFIG_TEMP" + + # verify host arg overrides configured restore host + echo "$output" | grep -q 'Connect localhost:22 OK' + + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test + begin_test "ghe-restore with host arg" ( set -e @@ -198,7 +232,7 @@ begin_test "ghe-restore with host arg" setup_maintenance_mode "configured" # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 + GHE_RESTORE_HOST="broken.environ.restore.host" export GHE_RESTORE_HOST # run it From d775e925d1e8a279cc07e0de87d431fbaba37aa6 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 24 Apr 2019 19:47:10 +0200 Subject: [PATCH 0776/2421] trigger index repair --- .../github-backup-utils/ghe-restore-audit-log | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 056f4d391..1d3a67495 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -69,6 +69,19 @@ restore_es(){ "${base_path}/ghe-restore-es-audit-log" "$GHE_HOSTNAME" } +# Whether or not we should trigger a reindex from MySQL into Elasticsearch +should_start_reindex(){ + if [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no" ]; then + ghe_verbose "GHE_BACKUP_ES_AUDIT_LOGS is not set to 'no'" + return 1 + fi + + if ! ghe-ssh "$GHE_HOSTNAME" -- "test -e /usr/local/share/enterprise/ghe-auditlog-repair"; then + ghe_verbose "ghe-auditlog-repiar doesn't exist" + return 1 + fi +} + do_restore(){ if mysql_restored_enabled; then restore_mysql @@ -78,8 +91,14 @@ do_restore(){ if es_restore_enabled; then restore_es - else - ghe_verbose "Elasticsearch audit log restore is not enabled" + return + fi + + ghe_verbose "Elasticsearch audit log restore is not enabled" + + if should_start_reindex; then + ghe_verbose "Starting audit log reindex from MySQL to Elasticsearch" + ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl --no-block restart auditlog-repair"; then fi } From 8687f95c5687ac3dcc9060d3870f407d95d257da Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 24 Apr 2019 20:09:55 +0200 Subject: [PATCH 0777/2421] fix typo --- share/github-backup-utils/ghe-restore-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 1d3a67495..fd40264f3 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -98,7 +98,7 @@ do_restore(){ if should_start_reindex; then ghe_verbose "Starting audit log reindex from MySQL to Elasticsearch" - ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl --no-block restart auditlog-repair"; then + ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl --no-block restart auditlog-repair"; fi } From e45ecb1d4d96633b0be4497ab33edfe9f3434505 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 25 Apr 2019 18:51:42 +0200 Subject: [PATCH 0778/2421] skip MySQL data if reconciler is not available --- .../github-backup-utils/ghe-backup-audit-log | 51 ++++++++++++++----- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index d2c12e56e..6f96b8072 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -24,7 +24,8 @@ setup(){ } # Check whether the MySQL backup should be enabled -# by checking if the audit-log-import directory exists +# by checking if the audit-log-import directory exists, +# this makes it backwards-compatible with old snapshots mysql_backup_enabled(){ ghe-ssh "$host" test -d "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import" } @@ -41,33 +42,59 @@ is_import_disabled(){ ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip" } -# If the import to MySQL is complete, add a flag in the snapshot to indicate so. -# And also use `ghe-backup-mysql-audit-log` to dump the audit entries. -backup_mysql(){ +# Check whether the instance ships an audit log reconciler, if it doesn't +# we can't dump audit_entries data, only the schema +is_reconciler_available(){ + ghe-ssh "$GHE_HOSTNAME" -- "test -e /usr/local/share/enterprise/ghe-auditlog-repair" +} + +# Check whether we only need to back up the audit_entries schema and +# ignore the actual data. +# +# This is the case when: +# - The import to MySQL is not complete +# - The import is disabled +# - The reconciler tool is not available +skip_mysql_entries(){ + if ! is_import_complete; then + ghe_verbose "audit log import is not complete" + return + fi + if is_import_disabled; then - ghe_verbose "audit log import is configured to be skipped" + ghe_verbose "audit log import is disabled" + return + fi - "${base_path}/ghe-backup-mysql-audit-log" --schema-only + if ! is_reconciler_available; then + ghe_verbose "audit log reconciler is not available" return fi - "${base_path}/ghe-backup-mysql-audit-log" + return 1 +} - if ! is_import_complete; then - ghe_verbose "Audit log import to MySQL is not complete" +# If the import to MySQL is complete, add a flag in the snapshot to indicate so. +# And also use `ghe-backup-mysql-audit-log` to dump the audit entries. +backup_mysql(){ + if skip_mysql_entries; then + ghe_verbose "only backing up audit log table schema" + "${base_path}/ghe-backup-mysql-audit-log" --schema-only return fi - ghe_verbose "Audit log import to MySQL is complete" + "${base_path}/ghe-backup-mysql-audit-log" touch "$GHE_SNAPSHOT_DIR/audit-log/mysql-import-complete" } # Audit log indices in Elasticsearch are backed up when: # -# - import to MySQL is not complete +# - Import is not complete +# - Import is disabled +# - Reconciler is not available # - GHE_BACKUP_ES_AUDIT_LOGS is not set to 'no' es_backup_enabled(){ - if ! is_import_complete; then + if skip_mysql_entries; then return fi From 56e191dce82eca29c8015e556d25621d0ed6796a Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Fri, 26 Apr 2019 09:46:39 +0200 Subject: [PATCH 0779/2421] remove complete flag if it doesn't exist in the snapshot --- share/github-backup-utils/ghe-restore-audit-log | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index fd40264f3..6102ee6ed 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -43,6 +43,7 @@ restore_mysql(){ if ! is_import_complete; then ghe_verbose "Audit log import to MySQL is not complete" + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" 1>&3 2>&3 return fi From 10ad4126eb97ecab61ab2fdcd1a5300cee73f88f Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 29 Apr 2019 15:23:55 +0200 Subject: [PATCH 0780/2421] remove unused tests --- test/test-ghe-backup.sh | 16 ---------------- test/test-ghe-restore.sh | 27 --------------------------- 2 files changed, 43 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index f18420bf9..9fe8eb9bb 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -344,19 +344,3 @@ begin_test "ghe-backup missing directories or files on source appliance" verify_all_backedup_data ) end_test - -begin_test "ghe-backup creates audit log import to MySQL flag in snapshot when present" -( - set -e - - mkdir "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import" - touch "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/complete" - - if ! output=$(ghe-backup -v 2>&1); then - echo "Error: failed to backup $output" >&2 - exit 1 - fi - - test -e "$GHE_DATA_DIR/current/audit-log/mysql-import-complete" -) -end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index fe7e6f1c7..4477686be 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -246,33 +246,6 @@ begin_test "ghe-restore with no pages backup" ) end_test -begin_test "ghe-restore creates audit log import to MySQL flag in file system when present" -( - set -e - - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - mkdir "$GHE_DATA_DIR/current/audit-log-mysql" - touch "$GHE_DATA_DIR/current/audit-log/mysql-import-complete" - mkdir "$GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import" - - if ! output=$(ghe-restore -v -f localhost 2>&1); then - echo "Error: failed to restore $output" >&2 - exit 1 - fi - - flag="$GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" - test -e "$flag" || { - echo "Error: the restore process should've created $flag" >&2 - exit 1 - } -) -end_test - begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e From e0046e805e33b57a58570403494400323db23446 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 1 May 2019 22:34:40 +0200 Subject: [PATCH 0781/2421] fix audit log import to MySQL flag removal for old snapshots --- .../github-backup-utils/ghe-restore-audit-log | 9 +++++-- test/test-ghe-restore.sh | 26 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 6102ee6ed..7a130fbf9 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -34,6 +34,11 @@ mysql_restored_enabled(){ test -e "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log-mysql" } +remove_complete_flag(){ + ghe_verbose "Setting instance as pending for audit log import to MySQL" + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" 1>&3 2>&3 +} + # Use `ghe-backup-mysql-audit-log` to dump the audit entries. # If the import to MySQL is complete, add a flag in the snapshot to indicate so. restore_mysql(){ @@ -42,8 +47,7 @@ restore_mysql(){ "${base_path}/ghe-restore-mysql-audit-log" "$GHE_HOSTNAME" if ! is_import_complete; then - ghe_verbose "Audit log import to MySQL is not complete" - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" 1>&3 2>&3 + remove_complete_flag return fi @@ -88,6 +92,7 @@ do_restore(){ restore_mysql else ghe_verbose "MySQL audit log restore is not enabled" + remove_complete_flag fi if es_restore_enabled; then diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 4477686be..703e46b47 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -246,6 +246,32 @@ begin_test "ghe-restore with no pages backup" ) end_test +begin_test "ghe-restore removes audit log import to MySQL flag when is a < 2.17 snapshot" +( + set -e + + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + flag="$GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" + mkdir -p "$(dirname $flag)" + touch "$flag" + + if ! output=$(ghe-restore -v -f localhost 2>&1); then + echo "Error: failed to restore $output" >&2 + exit 1 + fi + + ! test -e "$flag" || { + echo "Error: the restore process should've removed $flag" >&2 + exit 1 + } +) +end_test + begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e From ce377aa1da45ca6c87cd56b67ac739862be6ea0d Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 1 May 2019 23:25:59 +0200 Subject: [PATCH 0782/2421] only repair audit log indices in clustering mode --- share/github-backup-utils/ghe-restore-audit-log | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 7a130fbf9..c84098596 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -85,6 +85,11 @@ should_start_reindex(){ ghe_verbose "ghe-auditlog-repiar doesn't exist" return 1 fi + + if ! $CLUSTER; then + ghe_verbose "skipping ghe-auditlog-repair as remote instance is not a clustering setup" + return 1 + fi } do_restore(){ From 788c1162aacc4116fe792ea0188084cee79da522 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 2 May 2019 12:07:07 +0200 Subject: [PATCH 0783/2421] Revert "only repair audit log indices in clustering mode" This reverts commit ce377aa1da45ca6c87cd56b67ac739862be6ea0d. --- share/github-backup-utils/ghe-restore-audit-log | 5 ----- 1 file changed, 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index c84098596..7a130fbf9 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -85,11 +85,6 @@ should_start_reindex(){ ghe_verbose "ghe-auditlog-repiar doesn't exist" return 1 fi - - if ! $CLUSTER; then - ghe_verbose "skipping ghe-auditlog-repair as remote instance is not a clustering setup" - return 1 - fi } do_restore(){ From 46de4480c6b27907796605438e5ed839fd8f9a2c Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 2 May 2019 14:05:13 +0200 Subject: [PATCH 0784/2421] skip audit log indices if GHE_BACKUP_ES_AUDIT_LOGS=no --- share/github-backup-utils/ghe-backup-es-rsync | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index c73509584..078b88517 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -27,6 +27,17 @@ fi # Make sure root backup dir exists if this is the first run mkdir -p "$GHE_SNAPSHOT_DIR/elasticsearch" +# Create exclude file +exclude_file="$(mktemp)" +echo elasticsearch.yml >"$exclude_file" + +# Exclude audit log indices when configuration says so and import to MySQL is complete +# as those indices will be rebuilt from MySQL during a restore +if [ "$GHE_BACKUP_ES_AUDIT_LOGS" = "no" ] && ghe-ssh "$host" test -e "/data/user/common/audit-log-import/complete"; then + ghe_verbose "* Excluding Audit Log indices" + ghe-ssh "$host" curl -s 'localhost:9201/_cat/indices/audit_log?h=uuid' >>$exclude_file 2>&3 +fi + # Verify that the /data/elasticsearch directory exists. if ! ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' ]"; then ghe_verbose "* The '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' directory doesn't exist." @@ -47,15 +58,16 @@ ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ - --exclude='elasticsearch.yml' \ + --exclude-from="$exclude_file" \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 -# Set up a trap to re-enable flushing on exit +# Set up a trap to re-enable flushing on exit and remove temp file cleanup () { ghe_verbose "* Enabling ES index flushing ..." echo '{"index":{"translog.disable_flush":false}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null + ghe-ssh "$host" rm -rf "$exclude_file" } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate @@ -72,7 +84,7 @@ ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ - --exclude='elasticsearch.yml' \ + --exclude-from="$exclude_file" \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 From e34b81b857292177c345e0cef6c6a4ffcf3f604c Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 2 May 2019 15:53:22 +0200 Subject: [PATCH 0785/2421] use explicit http:// --- share/github-backup-utils/ghe-backup-es-rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 078b88517..7ed765852 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -35,7 +35,7 @@ echo elasticsearch.yml >"$exclude_file" # as those indices will be rebuilt from MySQL during a restore if [ "$GHE_BACKUP_ES_AUDIT_LOGS" = "no" ] && ghe-ssh "$host" test -e "/data/user/common/audit-log-import/complete"; then ghe_verbose "* Excluding Audit Log indices" - ghe-ssh "$host" curl -s 'localhost:9201/_cat/indices/audit_log?h=uuid' >>$exclude_file 2>&3 + ghe-ssh "$host" curl -s 'http://localhost:9201/_cat/indices/audit_log?h=uuid' >>$exclude_file 2>&3 fi # Verify that the /data/elasticsearch directory exists. From e46f8c9d9a21947a4bb1bc77c599973f1a2d43f2 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 2 May 2019 21:18:07 +0200 Subject: [PATCH 0786/2421] remove complete flag from all cluster nodes --- share/github-backup-utils/ghe-restore-audit-log | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 7a130fbf9..33efc29cf 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -35,8 +35,14 @@ mysql_restored_enabled(){ } remove_complete_flag(){ - ghe_verbose "Setting instance as pending for audit log import to MySQL" + ghe_verbose "Setting instance(s) as pending for audit log import to MySQL" ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" 1>&3 2>&3 + + if $CLUSTER; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo rm -rf /data/user/common/audit-log-import/complete" 1>&3 2>&3; then + ghe_verbose "Failed to set as pending for audit log import to MySQL all instances in cluster" + fi + fi } # Use `ghe-backup-mysql-audit-log` to dump the audit entries. From 9bc7dfa1e435493e227cf976369610d2572b8b29 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Fri, 3 May 2019 16:33:06 +0200 Subject: [PATCH 0787/2421] fix GNUisms and macOS errors --- share/github-backup-utils/ghe-restore-mysql-audit-log | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index 7526fae87..ecdfc827c 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -174,8 +174,7 @@ has_schema_changed(){ # Add DROP TABLE to a table schema dump add_drop_table(){ - # shellcheck disable=SC2016 - sed '/40101 SET @saved_cs_client/i DROP TABLE IF EXISTS `audit_entries`;' + awk '/40101 SET @saved_cs_client/{print "DROP TABLE IF EXISTS `audit_entries`;"}1' } # Restore the audit_entries table schema if it has changed @@ -185,7 +184,7 @@ restore_schema(){ fi gunzip -c "${snapshot_dir}/schema.gz" | add_drop_table | gzip > "${snapshot_dir}/schema.new.gz" 2>&3 - zcat "${snapshot_dir}/schema.new.gz" 1>&3 + zcat <"${snapshot_dir}/schema.new.gz" 1>&3 restore_dump schema.new } From f7e83fef31632598623f2a0a5f5e177dc6d3184c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 23 May 2019 09:02:37 +0100 Subject: [PATCH 0788/2421] Add pre and post release actions --- RELEASING.md | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index f46ebe681..e3dea5f93 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -8,24 +8,28 @@ There is no need to align Backup Utilities patch releases with GitHub Enterprise When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise Server that that release supports. -## Automatic Process from chatops (internal to GitHub only) - Coming :soon: +## Pre-release Actions -### Feature release: +Prior to making a release, -`.ghe backup-utils-release 2.13.0 2.11.0` +1. Go through the list of open pull requests and merge any that are ready for merging. +2. Go through the list of closed pull requests since the last release and ensure those that should be included in the changelog: + - have a "bug", "enhancement" or "feature" label, + - have a title that clearly describes the changes in that pull request. Reword if necessary. +3. Perform a dry run (add `--dry-run` to one of the command below) and verify the version strings are going to be changed and verify the changelog and release content. -### Patch release: +## Automatic Process from chatops (internal to GitHub only) -`.ghe backup-utils-release 2.13.1` +Coming :soon: ## Automatic Process from CLI 1. Install the Debian `devscripts` package: `sudo apt-get install devscripts` 2. Run... - - Feature release: + - Feature release: `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.0 2.11.0` - - Patch release: + - Patch release: `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.1` ## Manual Process @@ -45,3 +49,13 @@ In the event you can't perform the automatic process, or a problem is encountere 8. Draft a new release at https://github.com/github/backup-utils/releases, including the release notes and attaching the tarball and deb packages. The dist tarball you should upload has the revision in the file name, i.e. something like `github-backup-utils-v2.13.0.tar.gz` 9. Push the head of the release to the 'stable' branch. + +## Post-release Actions + +Immediately after making a release using one of the methods above, verify the release has succeeded by checking: + +- latest release at https://github.com/github/backup-utils/releases is correct, +- release at https://github.com/github/backup-utils/releases is linked to the vX.Y.Z tag, +- release has the changelog notes you expect to see, +- asset download links for the latest release at https://github.com/github/backup-utils/releases all download the correct version of Backup Utilities, +- the stable branch is inline with master - https://github.com/github/backup-utils/compare/stable...master. From 1e31ecae351dd3ee3f5dec8f11be070cf89fe164 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 23 May 2019 09:05:51 +0100 Subject: [PATCH 0789/2421] Typo --- RELEASING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index e3dea5f93..ab68a04de 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -16,7 +16,7 @@ Prior to making a release, 2. Go through the list of closed pull requests since the last release and ensure those that should be included in the changelog: - have a "bug", "enhancement" or "feature" label, - have a title that clearly describes the changes in that pull request. Reword if necessary. -3. Perform a dry run (add `--dry-run` to one of the command below) and verify the version strings are going to be changed and verify the changelog and release content. +3. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the changelog and release content. ## Automatic Process from chatops (internal to GitHub only) From 39a13b6b49749609c42d6df5c437d314f1239441 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 23 May 2019 09:08:17 +0100 Subject: [PATCH 0790/2421] Use release notes --- RELEASING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index ab68a04de..9ba732ac0 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -13,10 +13,10 @@ When making a `.0` release, you will need to specify the minimum supported versi Prior to making a release, 1. Go through the list of open pull requests and merge any that are ready for merging. -2. Go through the list of closed pull requests since the last release and ensure those that should be included in the changelog: +2. Go through the list of closed pull requests since the last release and ensure those that should be included in the release notes: - have a "bug", "enhancement" or "feature" label, - have a title that clearly describes the changes in that pull request. Reword if necessary. -3. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the changelog and release content. +3. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the release notes. ## Automatic Process from chatops (internal to GitHub only) @@ -56,6 +56,6 @@ Immediately after making a release using one of the methods above, verify the re - latest release at https://github.com/github/backup-utils/releases is correct, - release at https://github.com/github/backup-utils/releases is linked to the vX.Y.Z tag, -- release has the changelog notes you expect to see, +- release has the notes you expect to see, - asset download links for the latest release at https://github.com/github/backup-utils/releases all download the correct version of Backup Utilities, - the stable branch is inline with master - https://github.com/github/backup-utils/compare/stable...master. From 16fa68949d1ab8bf5ba40e70eeea7b0703be5784 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 23 May 2019 01:20:15 -0700 Subject: [PATCH 0791/2421] Bump version: 2.17.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 7 +++++++ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 602a2af71..45fd9ce7b 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.14.0" +supported_minimum_version="2.15.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 9c94f30a7..df5123425 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.17.0) UNRELEASED; urgency=medium + + * Restore target is ignored when specified on the command line #476 + * Support incremental backups for MySQL-stored audit logs #485 + + -- Colin Seymour Thu, 23 May 2019 08:20:15 +0000 + github-backup-utils (2.16.1) UNRELEASED; urgency=medium * Detect storage user on each cluster host being backed up or restored #472 diff --git a/script/cibuild b/script/cibuild index 6ed4019c6..fb5cd7668 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.14.0 2.16.0" +REMOTE_VERSIONS="2.15.0 2.17.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 0e7079b69..d76bd2ba3 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.16.1 +2.17.0 diff --git a/test/testlib.sh b/test/testlib.sh index 1763d87af..878892511 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.16.0} +: ${GHE_TEST_REMOTE_VERSION:=2.17.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 5c6c71d23be9323232e19a85e105c2fc51c4bdbc Mon Sep 17 00:00:00 2001 From: juruen Date: Tue, 4 Jun 2019 08:30:02 -0700 Subject: [PATCH 0792/2421] add missing stderr redirect fixes #496 --- share/github-backup-utils/ghe-backup-mysql-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log index 6665c723d..654169ae2 100755 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ b/share/github-backup-utils/ghe-backup-mysql-audit-log @@ -41,7 +41,7 @@ setup(){ # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ local meta - if ! meta=$(ghe-ssh "$host" "sudo ghe-export-audit-logs months" | grep -v NULL 2>&3); then + if ! meta=$(ghe-ssh "$host" "sudo ghe-export-audit-logs months" 2>&3 | grep -v NULL 2>&3); then ghe_verbose "Error: failed to retrieve audit log metadata" exit 1 fi From c44e68dfc1c454f7fb56ad2ed49b440cb119cbd4 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 5 Jun 2019 01:43:25 -0700 Subject: [PATCH 0793/2421] Bump version: 2.17.1 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index df5123425..9d4a41f1a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.17.1) UNRELEASED; urgency=medium + + * Redirect ghe-export-audit-logs stderr output unless using verbose output #497 + + -- Colin Seymour Wed, 05 Jun 2019 08:43:25 +0000 + github-backup-utils (2.17.0) UNRELEASED; urgency=medium * Restore target is ignored when specified on the command line #476 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index d76bd2ba3..3f8eb714d 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.17.0 +2.17.1 From 925c05a093c3a54e6142feca15fe192fbdb62c56 Mon Sep 17 00:00:00 2001 From: Rafal Mierzwiak Date: Wed, 19 Jun 2019 16:36:11 +0100 Subject: [PATCH 0794/2421] Add build dependency rsync This is to address tests failure: test: ghe-backup first snapshot ... ... FAILED (0s) ++ date +%s + before_time=1560955867 + set -e + '[' '!' -d /<>/test/tmp/test-ghe-backup.sh-10011/data/current ']' + ghe-backup -v Error: rsync encountered an error that could indicate a problem with permissions, hard links, symbolic links, or another issue that may affect backups. /<>/bin/ghe-backup: line 70: rsync: command not found test failed. last command exited with 1 ++ date +%s + after_time=1560955867 + elapsed_time=0 --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index e89ff97b7..007d313f5 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Maintainer: Twan Wolthof Section: misc Priority: optional Standards-Version: 3.9.2 -Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq +Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq, rsync (>= 2.6.4) Package: github-backup-utils Architecture: any From 492492e88fdb922a308709ae985ae58068a172f9 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Fri, 16 Aug 2019 12:41:29 +1000 Subject: [PATCH 0795/2421] Replaces sed with something i think is more portable --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 45fd9ce7b..71534d29b 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -84,7 +84,7 @@ if [ $rc -ne 0 ]; then exit $rc fi -version=$(echo "$output" | sed -E -n 's/GitHub Enterprise( Server)? version (.*)/\2/p') +version=$(echo "$output" | head -1 | awk '{print $NF}') if [ -z "$version" ]; then echo "Error: failed to parse version on '$host' or this isn't a GitHub appliance." 1>&2 From dba7848a82569e6e03eadc7814c903e34d324444 Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Fri, 16 Aug 2019 20:22:19 +1000 Subject: [PATCH 0796/2421] Testing grep to awk --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 71534d29b..c1713314a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -84,7 +84,7 @@ if [ $rc -ne 0 ]; then exit $rc fi -version=$(echo "$output" | head -1 | awk '{print $NF}') +version=$(echo "$output" | grep "GitHub Enterprise" | awk '{print $NF}') if [ -z "$version" ]; then echo "Error: failed to parse version on '$host' or this isn't a GitHub appliance." 1>&2 From 741ee75962354cfb5943a5e9c0d03ce06508eec1 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 20 Aug 2019 11:49:44 -0700 Subject: [PATCH 0797/2421] Bump version: 2.18.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 6 ++++++ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index c1713314a..3b2d964dd 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.15.0" +supported_minimum_version="2.16.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 9d4a41f1a..1d8679000 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.18.0) UNRELEASED; urgency=medium + + * Replace "sed -E" in ghe-host-check with a more portable solution #509 + + -- Colin Seymour Tue, 20 Aug 2019 18:49:44 +0000 + github-backup-utils (2.17.1) UNRELEASED; urgency=medium * Redirect ghe-export-audit-logs stderr output unless using verbose output #497 diff --git a/script/cibuild b/script/cibuild index fb5cd7668..0a367d2bc 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.15.0 2.17.0" +REMOTE_VERSIONS="2.16.0 2.18.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 3f8eb714d..cf8690732 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.17.1 +2.18.0 diff --git a/test/testlib.sh b/test/testlib.sh index 878892511..61501d3a4 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.17.0} +: ${GHE_TEST_REMOTE_VERSION:=2.18.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From cb43a169fa354a655c22f4e0e242d63a1b2dbd1d Mon Sep 17 00:00:00 2001 From: Ben Blazely Date: Thu, 3 Oct 2019 09:54:50 +1000 Subject: [PATCH 0798/2421] Remove temporary exclude file from backup host not GHES --- share/github-backup-utils/ghe-backup-es-rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 7ed765852..1497414b3 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -67,7 +67,7 @@ cleanup () { ghe_verbose "* Enabling ES index flushing ..." echo '{"index":{"translog.disable_flush":false}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null - ghe-ssh "$host" rm -rf "$exclude_file" + rm -rf "$exclude_file" } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate From 62b33249ba57a633afe94fd414df173c17688a09 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 7 Oct 2019 16:17:36 +0200 Subject: [PATCH 0799/2421] do not dump audit log entries from MySQL --- .../github-backup-utils/ghe-backup-audit-log | 87 +------------------ 1 file changed, 1 insertion(+), 86 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 6f96b8072..2ee17a04b 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -23,82 +23,8 @@ setup(){ mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" } -# Check whether the MySQL backup should be enabled -# by checking if the audit-log-import directory exists, -# this makes it backwards-compatible with old snapshots -mysql_backup_enabled(){ - ghe-ssh "$host" test -d "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import" -} - -# Check whether the MySQL import is complete by checking if -# /data/user/common/audit-log-import/complete exists -is_import_complete(){ - ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/complete" -} - -# Check whether the MySQL import is disabled by verifying if -# /data/user/common/audit-log-import/skip exists -is_import_disabled(){ - ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip" -} - -# Check whether the instance ships an audit log reconciler, if it doesn't -# we can't dump audit_entries data, only the schema -is_reconciler_available(){ - ghe-ssh "$GHE_HOSTNAME" -- "test -e /usr/local/share/enterprise/ghe-auditlog-repair" -} - -# Check whether we only need to back up the audit_entries schema and -# ignore the actual data. -# -# This is the case when: -# - The import to MySQL is not complete -# - The import is disabled -# - The reconciler tool is not available -skip_mysql_entries(){ - if ! is_import_complete; then - ghe_verbose "audit log import is not complete" - return - fi - - if is_import_disabled; then - ghe_verbose "audit log import is disabled" - return - fi - - if ! is_reconciler_available; then - ghe_verbose "audit log reconciler is not available" - return - fi - - return 1 -} - -# If the import to MySQL is complete, add a flag in the snapshot to indicate so. -# And also use `ghe-backup-mysql-audit-log` to dump the audit entries. backup_mysql(){ - if skip_mysql_entries; then - ghe_verbose "only backing up audit log table schema" - "${base_path}/ghe-backup-mysql-audit-log" --schema-only - return - fi - - "${base_path}/ghe-backup-mysql-audit-log" - touch "$GHE_SNAPSHOT_DIR/audit-log/mysql-import-complete" -} - -# Audit log indices in Elasticsearch are backed up when: -# -# - Import is not complete -# - Import is disabled -# - Reconciler is not available -# - GHE_BACKUP_ES_AUDIT_LOGS is not set to 'no' -es_backup_enabled(){ - if skip_mysql_entries; then - return - fi - - [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no" ] + "${base_path}/ghe-backup-mysql-audit-log" --schema-only } # Use ghe-backup-es-audit-log to back up Elasticsearch indices @@ -107,19 +33,8 @@ backup_es(){ } backup(){ - if mysql_backup_enabled; then - ghe_verbose "MySQL audit logs backup is enabled" backup_mysql - else - ghe_verbose "MySQL audit logs backup is disabled" - fi - - if es_backup_enabled; then - ghe_verbose "Elasticsearch audit logs backup is enabled" backup_es - else - ghe_verbose "Elasticsearch audit logs backup is disabled" - fi } main(){ From 2bfbdeff27984a1ab8983a5b5e371c2809216b65 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 7 Oct 2019 16:48:31 +0200 Subject: [PATCH 0800/2421] add --only-schema argument to ghe=restore=mysql-audit-log --- share/github-backup-utils/ghe-restore-mysql-audit-log | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index ecdfc827c..909376afe 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -16,6 +16,9 @@ base_path="$( dirname "${BASH_SOURCE[0]}" )" GHE_HOSTNAME="$1" +# Whether we just need to imprt the table schema and no data +only_schema="$2" + # Setup GHE_REMOTE_XXX variables, snapshot_dir, # remote_dir, remote_dump and skip_prepare setup(){ @@ -202,6 +205,10 @@ restore(){ fi restore_schema + if [ -n "$only_schema" ]; then + ghe_verbose "only table schema was imported" + return + fi IFS=$'\n' for month in $(notsynced_meta); do From 167cdae16e2558559bc89b2c272f20e6f64ae638 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 7 Oct 2019 17:48:31 +0200 Subject: [PATCH 0801/2421] prepare restore for the MySQL audit log backend deprecation --- .../github-backup-utils/ghe-restore-audit-log | 108 +++++++++--------- 1 file changed, 53 insertions(+), 55 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 33efc29cf..47f76981f 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -22,55 +22,54 @@ setup(){ ghe_remote_version_required "$GHE_HOSTNAME" } -# Check whether the snapshot comes from an instance -# where the MySQL import was complete -is_import_complete(){ - test -e "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/mysql-import-complete" +# Check whether the snapshot contains audit logs that +# were taken from Elasticsearch +es_data_available(){ + ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.size" >/dev/null 2>&1 } -# Check whether the snapshot was taken on an instance -# where MySQL audit logs were enabled -mysql_restored_enabled(){ - test -e "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log-mysql" +# Check whether the snapshot contains audit logs that +# were taken from MySQL +mysql_dump_available(){ + ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log-mysql/20*.gz" >/dev/null 2>&1 } -remove_complete_flag(){ - ghe_verbose "Setting instance(s) as pending for audit log import to MySQL" - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" 1>&3 2>&3 +# Check whether the remote host is running a version where the MySQL backend +# is supported, i.e: < 2.19 +is_mysql_supported(){ + [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version 2.19.0)" ] +} + +set_remote_flag(){ + local flag=$1 + local msg=$2 + + ghe_verbose "$2" + ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/skip" 1>&3 2>&3 if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo rm -rf /data/user/common/audit-log-import/complete" 1>&3 2>&3; then - ghe_verbose "Failed to set as pending for audit log import to MySQL all instances in cluster" + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo touch /data/user/common/audit-log-import/skip" 1>&3 2>&3; then + ghe_verbose "Failed to $msg in all instances in cluster" fi fi } +set_skip_transition_flag(){ + set_remote_flag "skip" "add flag to skip audit log import to MySQL" +} + +set_skip_truncate_flag(){ + set_remote_flag "skip_truncate" "add flag to skip truncating audit log table in MySQL" +} + # Use `ghe-backup-mysql-audit-log` to dump the audit entries. # If the import to MySQL is complete, add a flag in the snapshot to indicate so. restore_mysql(){ - ghe_verbose "Restoring MySQL audit logs ..." - - "${base_path}/ghe-restore-mysql-audit-log" "$GHE_HOSTNAME" - - if ! is_import_complete; then - remove_complete_flag - return - fi - - ghe_verbose "Audit log import to MySQL is complete" - ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" -} + local only_schema=$1 -# Audit log indices in Elasticsearch are restored when: -# -# - import to MySQL is not complete -# - GHE_BACKUP_ES_AUDIT_LOGS is not set to 'no' -es_restore_enabled(){ - if ! is_import_complete; then - return - fi + ghe_verbose "Restoring MySQL audit logs ..." - [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no" ] + "${base_path}/ghe-restore-mysql-audit-log" "$GHE_HOSTNAME" "$only_schema" } # Use ghe-restore-es-audit-log to restore Elasticsearch indices @@ -80,38 +79,37 @@ restore_es(){ "${base_path}/ghe-restore-es-audit-log" "$GHE_HOSTNAME" } -# Whether or not we should trigger a reindex from MySQL into Elasticsearch -should_start_reindex(){ - if [ -z "$GHE_BACKUP_ES_AUDIT_LOGS" ] || [ "$GHE_BACKUP_ES_AUDIT_LOGS" != "no" ]; then - ghe_verbose "GHE_BACKUP_ES_AUDIT_LOGS is not set to 'no'" - return 1 - fi - - if ! ghe-ssh "$GHE_HOSTNAME" -- "test -e /usr/local/share/enterprise/ghe-auditlog-repair"; then - ghe_verbose "ghe-auditlog-repiar doesn't exist" - return 1 - fi -} - do_restore(){ - if mysql_restored_enabled; then - restore_mysql - else - ghe_verbose "MySQL audit log restore is not enabled" - remove_complete_flag + if is_mysql_supported; then + ghe_verbose "Add flag to skip transition to MySQL" + set_skip_transtion_flag fi - if es_restore_enabled; then + # ES data is available, restore it along + # with the table schema + if es_data_available; then restore_es + restore_mysql --only-schema return fi - ghe_verbose "Elasticsearch audit log restore is not enabled" + # Only MySQL data is available, restore it + # and trigger a reindex + if mysql_dump_available; then + restore_mysql + + if ! is_mysql_supported; then + ghe_verbose "Add flag to skip MySQL audit log table truncation" + set_skip_truncate_flag + fi - if should_start_reindex; then ghe_verbose "Starting audit log reindex from MySQL to Elasticsearch" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl --no-block restart auditlog-repair"; + return fi + + # Only the table schema is available, restore it + restore_mysql --only-schema } main(){ From 24811b3ea5100ea53376c2e1755a200f5bfbe891 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Tue, 8 Oct 2019 15:53:04 +0200 Subject: [PATCH 0802/2421] dump mysql entries if skip_truncate is present --- share/github-backup-utils/ghe-backup-audit-log | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 2ee17a04b..01add554d 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -23,8 +23,20 @@ setup(){ mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" } +# Check whether the flag to skip the MySQL audit_entries table truncation +# exists. +is_skip_truncate_enabled(){ + ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip_truncate" +} + backup_mysql(){ - "${base_path}/ghe-backup-mysql-audit-log" --schema-only + if is_skip_truncate_enabled; then + # As skip_truncate exists, we need to also backup the audit entries + # in MySQL because Elasticsearch may not be fully synced. + "${base_path}/ghe-backup-mysql-audit-log" + else + "${base_path}/ghe-backup-mysql-audit-log" --schema-only + fi } # Use ghe-backup-es-audit-log to back up Elasticsearch indices From b5ce438e2c2440cddb01f9cf1e963a1c8746208b Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Tue, 8 Oct 2019 17:29:47 +0200 Subject: [PATCH 0803/2421] fix typo --- share/github-backup-utils/ghe-restore-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 47f76981f..08aacf371 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -82,7 +82,7 @@ restore_es(){ do_restore(){ if is_mysql_supported; then ghe_verbose "Add flag to skip transition to MySQL" - set_skip_transtion_flag + set_skip_transition_flag fi # ES data is available, restore it along From 8b4b01eb9ec7d98b39f78cc65504a9ebf2fa76ab Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 9 Oct 2019 13:10:39 +0200 Subject: [PATCH 0804/2421] add more verbose output --- share/github-backup-utils/ghe-restore-audit-log | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 08aacf371..9bb2be2f5 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -55,11 +55,11 @@ set_remote_flag(){ } set_skip_transition_flag(){ - set_remote_flag "skip" "add flag to skip audit log import to MySQL" + set_remote_flag "skip" "Add flag to skip audit log import to MySQL" } set_skip_truncate_flag(){ - set_remote_flag "skip_truncate" "add flag to skip truncating audit log table in MySQL" + set_remote_flag "skip_truncate" "Add flag to skip truncating audit log table in MySQL" } # Use `ghe-backup-mysql-audit-log` to dump the audit entries. @@ -81,13 +81,14 @@ restore_es(){ do_restore(){ if is_mysql_supported; then - ghe_verbose "Add flag to skip transition to MySQL" set_skip_transition_flag fi # ES data is available, restore it along # with the table schema if es_data_available; then + ghe_verbose "Elasticsearch data is available" + restore_es restore_mysql --only-schema return @@ -96,6 +97,8 @@ do_restore(){ # Only MySQL data is available, restore it # and trigger a reindex if mysql_dump_available; then + ghe_verbose "Only MySQL data is available" + restore_mysql if ! is_mysql_supported; then @@ -109,6 +112,7 @@ do_restore(){ fi # Only the table schema is available, restore it + ghe_verbose "Only audit_entries schema is available" restore_mysql --only-schema } From cdd5f501920027f60599c0581f6dddffab5a5654 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 9 Oct 2019 14:01:07 +0200 Subject: [PATCH 0805/2421] fix globbing --- share/github-backup-utils/ghe-restore-audit-log | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 9bb2be2f5..97b118e4c 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -25,13 +25,13 @@ setup(){ # Check whether the snapshot contains audit logs that # were taken from Elasticsearch es_data_available(){ - ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/*.size" >/dev/null 2>&1 + ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"/audit-log/*.size >/dev/null 2>&1 } # Check whether the snapshot contains audit logs that # were taken from MySQL mysql_dump_available(){ - ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log-mysql/20*.gz" >/dev/null 2>&1 + ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"/audit-log-mysql/20*.gz >/dev/null 2>&1 } # Check whether the remote host is running a version where the MySQL backend From aa5432400c8621090c362eb57d52c517536dffe8 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Wed, 9 Oct 2019 16:18:30 +0200 Subject: [PATCH 0806/2421] enable debug --- share/github-backup-utils/ghe-restore-audit-log | 2 +- share/github-backup-utils/ghe-restore-es-audit-log | 2 +- share/github-backup-utils/ghe-restore-mysql-audit-log | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 97b118e4c..10576c493 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -4,7 +4,7 @@ #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. -set -e +set -ex # Bring in the backup configuration base_path="$( dirname "${BASH_SOURCE[0]}" )" diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 77055d692..4c8163fc7 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -4,7 +4,7 @@ #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-restore. -set -e +set -ex # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index 909376afe..44a8b3ba8 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -4,7 +4,7 @@ #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-restore-audit-log -set -e +set -ex # Bring in the backup configuration base_path="$( dirname "${BASH_SOURCE[0]}" )" From daec15e7d2496dde2f7a9228d1ecf670d33e2be0 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Fri, 11 Oct 2019 10:00:42 +0200 Subject: [PATCH 0807/2421] create right flag --- share/github-backup-utils/ghe-restore-audit-log | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 10576c493..821b72d8c 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -45,10 +45,10 @@ set_remote_flag(){ local msg=$2 ghe_verbose "$2" - ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/skip" 1>&3 2>&3 + ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/$flag" 1>&3 2>&3 if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo touch /data/user/common/audit-log-import/skip" 1>&3 2>&3; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo touch /data/user/common/audit-log-import/$flag" 1>&3 2>&3; then ghe_verbose "Failed to $msg in all instances in cluster" fi fi From 6419b1b9af76cbefb053da70472bc0c8a4b18ba2 Mon Sep 17 00:00:00 2001 From: juruen Date: Fri, 11 Oct 2019 09:31:40 -0700 Subject: [PATCH 0808/2421] fix tests --- .../github-backup-utils/ghe-restore-audit-log | 30 ++++++++++++++----- test/test-ghe-restore.sh | 26 ---------------- test/testlib.sh | 2 ++ 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 821b72d8c..81ece6c93 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -34,21 +34,33 @@ mysql_dump_available(){ ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"/audit-log-mysql/20*.gz >/dev/null 2>&1 } +# Check whether the snapshot contains the audit log table schema +mysql_table_schema_available(){ + ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"/audit-log-mysql/schema.gz >/dev/null 2>&1 +} + # Check whether the remote host is running a version where the MySQL backend # is supported, i.e: < 2.19 is_mysql_supported(){ - [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version 2.19.0)" ] + [ "$(version "$GHE_REMOTE_VERSION")" -lt "$(version 2.19.0)" ] } set_remote_flag(){ local flag=$1 local msg=$2 - ghe_verbose "$2" - ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/$flag" 1>&3 2>&3 + local dir="/data/user/common/audit-log-import" + + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo test -d $GHE_REMOTE_ROOT_DIR/$dir" 1>&3 2>&3; then + ghe_verbose "Remote version doesn't support audit log import, skipping '$msg'" + return + fi + + ghe_verbose "$msg" + ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/$dir/$flag" 1>&3 2>&3 if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo touch /data/user/common/audit-log-import/$flag" 1>&3 2>&3; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo touch $dir/$flag" 1>&3 2>&3; then ghe_verbose "Failed to $msg in all instances in cluster" fi fi @@ -111,9 +123,13 @@ do_restore(){ return fi - # Only the table schema is available, restore it - ghe_verbose "Only audit_entries schema is available" - restore_mysql --only-schema + if mysql_table_schema_available; then + # Only the table schema is available, restore it + ghe_verbose "Only audit_entries schema is available" + restore_mysql --only-schema + else + ghe_verbose "MySQL table schema is not available" + fi } main(){ diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index e9988c6e3..499e3385b 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -280,32 +280,6 @@ begin_test "ghe-restore with no pages backup" ) end_test -begin_test "ghe-restore removes audit log import to MySQL flag when is a < 2.17 snapshot" -( - set -e - - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - flag="$GHE_REMOTE_ROOT_DIR/data/user/common/audit-log-import/complete" - mkdir -p "$(dirname $flag)" - touch "$flag" - - if ! output=$(ghe-restore -v -f localhost 2>&1); then - echo "Error: failed to restore $output" >&2 - exit 1 - fi - - ! test -e "$flag" || { - echo "Error: the restore process should've removed $flag" >&2 - exit 1 - } -) -end_test - begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index 61501d3a4..f1895aabb 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -253,7 +253,9 @@ setup_test_data () { mkdir -p "$loc/audit-log/" cd "$loc/audit-log/" echo "fake audit log last yr last mth" | gzip > audit_log-1-$last_yr-$last_mth-1.gz + echo "1" > audit_log-1-$last_yr-$last_mth-1.size echo "fake audit log this yr this mth" | gzip > audit_log-1-$this_yr-$this_mth-1.gz + echo "1" > audit_log-1-$this_yr-$this_mth-1.size # Create hookshot logs mkdir -p "$loc/hookshot/" From 86269cee69ac9484a471368f9d1b30621ace3539 Mon Sep 17 00:00:00 2001 From: juruen Date: Fri, 11 Oct 2019 09:32:51 -0700 Subject: [PATCH 0809/2421] remove debug option --- share/github-backup-utils/ghe-restore-audit-log | 2 +- share/github-backup-utils/ghe-restore-es-audit-log | 2 +- share/github-backup-utils/ghe-restore-mysql-audit-log | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 81ece6c93..36f69d4b9 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -4,7 +4,7 @@ #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. -set -ex +set -e # Bring in the backup configuration base_path="$( dirname "${BASH_SOURCE[0]}" )" diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 4c8163fc7..77055d692 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -4,7 +4,7 @@ #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-restore. -set -ex +set -e # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index 44a8b3ba8..909376afe 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -4,7 +4,7 @@ #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-restore-audit-log -set -ex +set -e # Bring in the backup configuration base_path="$( dirname "${BASH_SOURCE[0]}" )" From 687d4e871c8876e426f54fe56b884a4f39133554 Mon Sep 17 00:00:00 2001 From: juruen Date: Fri, 11 Oct 2019 09:38:10 -0700 Subject: [PATCH 0810/2421] Add doc to functions --- share/github-backup-utils/ghe-restore-audit-log | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 36f69d4b9..59c6962be 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -45,6 +45,8 @@ is_mysql_supported(){ [ "$(version "$GHE_REMOTE_VERSION")" -lt "$(version 2.19.0)" ] } +# Helper function to set remote flags in `/data/user/common/audit-log-import` +# if it's supported, i.e: directory exists. set_remote_flag(){ local flag=$1 local msg=$2 @@ -66,10 +68,12 @@ set_remote_flag(){ fi } +# Add flag to not trigger transitions from MySQL to Elasticsearch set_skip_transition_flag(){ set_remote_flag "skip" "Add flag to skip audit log import to MySQL" } +# Add flag to not trigger the truncation of the MySQL audit log table set_skip_truncate_flag(){ set_remote_flag "skip_truncate" "Add flag to skip truncating audit log table in MySQL" } From afe17b508a3f9d33e45f62f5110c25754af25e6b Mon Sep 17 00:00:00 2001 From: juruen Date: Mon, 14 Oct 2019 08:48:38 -0700 Subject: [PATCH 0811/2421] remove GHE_BACKUP_ES_AUDIT_LOGS from config example --- backup.config-example | 7 ------- 1 file changed, 7 deletions(-) diff --git a/backup.config-example b/backup.config-example index 20d3db5e5..1ea7fb61f 100644 --- a/backup.config-example +++ b/backup.config-example @@ -48,10 +48,3 @@ GHE_NUM_SNAPSHOTS=10 # # WARNING: do not enable this, only useful for debugging/development #GHE_BACKUP_FSCK=no - -# If set to 'no', Elasticsearch audit log indices will not be backed up. -# Note that they will still be backed up from MySQL. This will reduce -# the time and size of the backup process but it will take longer -# for the audit log entries to be searchable as they need to be reindexed -# in Elasticsearch. -#GHE_BACKUP_ES_AUDIT_LOGS=no From 0d129caf518702979230d6b070c7b9023ea65389 Mon Sep 17 00:00:00 2001 From: juruen Date: Mon, 14 Oct 2019 08:50:32 -0700 Subject: [PATCH 0812/2421] do not exclude audit log ES indices --- share/github-backup-utils/ghe-backup-es-rsync | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 1497414b3..11fa99f70 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -27,17 +27,6 @@ fi # Make sure root backup dir exists if this is the first run mkdir -p "$GHE_SNAPSHOT_DIR/elasticsearch" -# Create exclude file -exclude_file="$(mktemp)" -echo elasticsearch.yml >"$exclude_file" - -# Exclude audit log indices when configuration says so and import to MySQL is complete -# as those indices will be rebuilt from MySQL during a restore -if [ "$GHE_BACKUP_ES_AUDIT_LOGS" = "no" ] && ghe-ssh "$host" test -e "/data/user/common/audit-log-import/complete"; then - ghe_verbose "* Excluding Audit Log indices" - ghe-ssh "$host" curl -s 'http://localhost:9201/_cat/indices/audit_log?h=uuid' >>$exclude_file 2>&3 -fi - # Verify that the /data/elasticsearch directory exists. if ! ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' ]"; then ghe_verbose "* The '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' directory doesn't exist." @@ -58,7 +47,6 @@ ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ - --exclude-from="$exclude_file" \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 @@ -67,7 +55,6 @@ cleanup () { ghe_verbose "* Enabling ES index flushing ..." echo '{"index":{"translog.disable_flush":false}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null - rm -rf "$exclude_file" } trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate @@ -84,7 +71,6 @@ ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ - --exclude-from="$exclude_file" \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 From 3d2947723b4ea0d5686dc9fc9b81bbf78e37dd94 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Mon, 21 Oct 2019 22:50:24 +0200 Subject: [PATCH 0813/2421] check snapshot contains MySQL audit log dir --- share/github-backup-utils/ghe-restore-mysql-audit-log | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log index 44a8b3ba8..e5d2cdbd0 100755 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ b/share/github-backup-utils/ghe-restore-mysql-audit-log @@ -39,6 +39,11 @@ cleanup(){ ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $remote_dump" } +# Check whether the snapshot contains any MySQL data at all +is_mysql_snapshot(){ + test -d "$snapshot_dir" +} + # Use ghe-export-audit-logs to fetch the current metadata for all stored # months in MySQL. For each month: number of entries, minum ID, maximum ID fetch_current_meta(){ @@ -204,6 +209,11 @@ restore(){ return fi + if ! is_mysql_snapshot; then + ghe_verbose "snapshot doesn't contain MySQL data" + return + fi + restore_schema if [ -n "$only_schema" ]; then ghe_verbose "only table schema was imported" From ff53a775ae4be4e0407656216a03604eaca02bb5 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Thu, 24 Oct 2019 13:19:07 +0200 Subject: [PATCH 0814/2421] check whether the MySQL audit logger is enabled instead of GHE versions --- share/github-backup-utils/ghe-restore-audit-log | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 59c6962be..76c6c12e7 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -42,7 +42,8 @@ mysql_table_schema_available(){ # Check whether the remote host is running a version where the MySQL backend # is supported, i.e: < 2.19 is_mysql_supported(){ - [ "$(version "$GHE_REMOTE_VERSION")" -lt "$(version 2.19.0)" ] + ghe-ssh sudo grep -q "ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED='1'" \ + /data/github/current/.app-config/env.d/99-instance.sh } # Helper function to set remote flags in `/data/user/common/audit-log-import` From 495dd268f5fc45c4b5c9628a556ed276acd579f3 Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Fri, 25 Oct 2019 09:04:44 +0200 Subject: [PATCH 0815/2421] pass host to ghe-ssh --- share/github-backup-utils/ghe-restore-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 76c6c12e7..6302baf40 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -42,7 +42,7 @@ mysql_table_schema_available(){ # Check whether the remote host is running a version where the MySQL backend # is supported, i.e: < 2.19 is_mysql_supported(){ - ghe-ssh sudo grep -q "ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED='1'" \ + ghe-ssh "$GHE_HOSTNAME" sudo grep -q "ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED='1'" \ /data/github/current/.app-config/env.d/99-instance.sh } From d5802d5e94b635e4a4637a9a068cd60df483c74f Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Tue, 29 Oct 2019 12:56:46 +0100 Subject: [PATCH 0816/2421] fix logger check --- share/github-backup-utils/ghe-restore-audit-log | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 6302baf40..d95232914 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -42,8 +42,7 @@ mysql_table_schema_available(){ # Check whether the remote host is running a version where the MySQL backend # is supported, i.e: < 2.19 is_mysql_supported(){ - ghe-ssh "$GHE_HOSTNAME" sudo grep -q "ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED='1'" \ - /data/github/current/.app-config/env.d/99-instance.sh + ghe-ssh "$GHE_HOSTNAME" "sudo grep \"ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED='1'\" /data/github/current/.app-config/env.d/99-instance.sh" } # Helper function to set remote flags in `/data/user/common/audit-log-import` From aab52da5137c16fa4345eef770981b02d2cb186c Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Tue, 29 Oct 2019 15:25:42 +0100 Subject: [PATCH 0817/2421] don't use grep to verify the mysql audit logger --- share/github-backup-utils/ghe-restore-audit-log | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index d95232914..aaee7ba42 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -42,7 +42,8 @@ mysql_table_schema_available(){ # Check whether the remote host is running a version where the MySQL backend # is supported, i.e: < 2.19 is_mysql_supported(){ - ghe-ssh "$GHE_HOSTNAME" "sudo grep \"ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED='1'\" /data/github/current/.app-config/env.d/99-instance.sh" + echo 'sudo bash -c ". /data/github/current/.app-config/env.d/99-instance.sh;' \ + 'test \"\$ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED\" = \"1\""' | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash } # Helper function to set remote flags in `/data/user/common/audit-log-import` From 9fae1c875f11c50dac2f6b12311547085102fdf5 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Wed, 30 Oct 2019 16:37:26 -0700 Subject: [PATCH 0818/2421] Update debian package depends to include git Closes #479 --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 007d313f5..4ccf03654 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq, rsync (>= 2.6.4 Package: github-backup-utils Architecture: any -Depends: ${misc:Depends}, rsync (>= 2.6.4), moreutils, jq +Depends: ${misc:Depends}, rsync (>= 2.6.4), moreutils, jq, git Description: Backup and recovery utilities for GitHub Enterprise Server The backup utilities implement a number of advanced capabilities for backup hosts, built on top of the backup and restore features already included in From 43667179dd0f6cd54ac716b5956b087c42174599 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Nov 2019 17:36:08 +0000 Subject: [PATCH 0819/2421] Only return dirname for repos --- share/github-backup-utils/ghe-backup-repositories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index c92b6ab5e..a2a1cfe65 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -368,7 +368,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then bm_start "$(basename $0) - Verifying Routes" cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes - (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git -exec dirname {} \; | sort | uniq) > $tempdir/destination_routes + (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | while read -r line; do if [[ ! $line == */gist/* ]]; then dirname "$line"; else echo "$line"; fi; done | sort | uniq) > $tempdir/destination_routes git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." From 28ddd908ddfe69f6364b5f0404a7e7f2e4364150 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Tue, 12 Nov 2019 10:57:12 -0800 Subject: [PATCH 0820/2421] Bump version: 2.19.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 7 +++++++ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3b2d964dd..f5ccbb89e 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.16.0" +supported_minimum_version="2.17.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 1d8679000..4e86d2f9c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.19.0) UNRELEASED; urgency=medium + + * Remove temporary exclude file from the backup host not the target GHES appliance #516 + * Update Debian package depends to include git #520 + + -- Colin Seymour Tue, 12 Nov 2019 18:57:12 +0000 + github-backup-utils (2.18.0) UNRELEASED; urgency=medium * Replace "sed -E" in ghe-host-check with a more portable solution #509 diff --git a/script/cibuild b/script/cibuild index 0a367d2bc..b68f5c539 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.16.0 2.18.0" +REMOTE_VERSIONS="2.17.0 2.19.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index cf8690732..ef0f38abe 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.18.0 +2.19.0 diff --git a/test/testlib.sh b/test/testlib.sh index f1895aabb..c8182b911 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.18.0} +: ${GHE_TEST_REMOTE_VERSION:=2.19.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 0a04ca087edd7738fad2095b0ea8eca16ba6866c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Nov 2019 15:21:45 +0000 Subject: [PATCH 0821/2421] Implement function to different gist path parsing --- .../ghe-backup-repositories | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index a2a1cfe65..1432327be 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -367,8 +367,24 @@ bm_end "$(basename $0) - Special Data Directories Sync" if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then bm_start "$(basename $0) - Verifying Routes" + # The list of gists returned by the source changed in 2.16.22, 2.17.13, 2.18.7 & 2.19.1 + # so we need to account for this difference here. + parse_paths() { + while read -r line; do + if [[ "$GHE_REMOTE_VERSION" =~ 2.16 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.16.22)" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.17 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.17.13)" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.18 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.18.7)" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.19 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.19.1)" ]] && \ + (echo "$line" | grep -q "gist"); then + echo "$line" + else + dirname "$line" + fi + done + } + cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes - (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | while read -r line; do if [[ ! $line == */gist/* ]]; then dirname "$line"; else echo "$line"; fi; done | sort | uniq) > $tempdir/destination_routes + (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | parse_paths | sort | uniq) > $tempdir/destination_routes git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." From 19ee80caf7d8d89b5bf4b25713d24f04f1f5b00d Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 13 Nov 2019 15:57:41 +0000 Subject: [PATCH 0822/2421] Refactor testing for existance of rsync files --- share/github-backup-utils/ghe-backup-repositories | 4 ++-- share/github-backup-utils/ghe-backup-storage | 4 ++-- share/github-backup-utils/ghe-restore-pages | 4 ++-- share/github-backup-utils/ghe-restore-repositories | 4 ++-- share/github-backup-utils/ghe-restore-repositories-gist | 4 ++-- share/github-backup-utils/ghe-restore-storage | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index c92b6ab5e..583914bcf 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -137,10 +137,10 @@ if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then server=$host fi cat $routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' -ghe_debug "\n$(ls -l $tempdir/*.rsync)" +ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" -if ! ls $tempdir/*.rsync >/dev/null 2>&1; then +if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then echo "Warning: no routes found, skipping repositories backup ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 5078adcd1..334284eba 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -105,10 +105,10 @@ if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then server=$host fi cat $routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' -ghe_debug "\n$(ls -l $tempdir/*.rsync)" +ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" -if ! ls $tempdir/*.rsync >/dev/null 2>&1; then +if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then echo "Warning: no routes found, skipping storage backup ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index dfa0bc7d1..9bd51b7ac 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -119,10 +119,10 @@ bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' -ghe_debug "\n$(ls -l $tempdir/*.rsync)" +ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" -if ! ls $tempdir/*.rsync >/dev/null 2>&1; then +if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then echo "Warning: no routes found, skipping pages restore ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 23e5afa6d..c87c8b421 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -129,10 +129,10 @@ bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore -ghe_debug "\n$(ls -l $tempdir/*.rsync && cat $to_restore)" +ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" -if ! ls $tempdir/*.rsync >/dev/null 2>&1; then +if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then echo "Warning: no routes found, skipping repositories restore ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 4513c295c..6a0a40c91 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -122,10 +122,10 @@ bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' cat $routes_list | awk '{ n = split($1, p, "/"); i = p[n]; sub(/\.git/, "", i); printf i " /data/repositories/" $1; $1=""; print $0}' > $to_restore -ghe_debug "\n$(ls -l $tempdir/*.rsync && cat $to_restore)" +ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" -if ! ls $tempdir/*.rsync >/dev/null 2>&1; then +if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then echo "Warning: no routes found, skipping gists restore ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index c0eac20d5..047937fde 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -111,10 +111,10 @@ bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print substr($1,1,1) "/" substr($1,1,2) "/" substr($1,3,2) "/" $1 > (tempdir"/"$i".rsync") }}' -ghe_debug "\n$(ls -l $tempdir/*.rsync)" +ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" -if ! ls $tempdir/*.rsync >/dev/null 2>&1; then +if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then echo "Warning: no routes found, skipping storage restore ..." exit 0 fi From eb81c2801687f3862d58fa641896245324f15759 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Mon, 18 Nov 2019 07:12:05 -0600 Subject: [PATCH 0823/2421] Update versions --- share/github-backup-utils/ghe-backup-repositories | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 1432327be..3275dc8ca 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -367,14 +367,14 @@ bm_end "$(basename $0) - Special Data Directories Sync" if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then bm_start "$(basename $0) - Verifying Routes" - # The list of gists returned by the source changed in 2.16.22, 2.17.13, 2.18.7 & 2.19.1 + # The list of gists returned by the source changed in 2.16.23, 2.17.14, 2.18.8 & 2.19.3 # so we need to account for this difference here. parse_paths() { while read -r line; do - if [[ "$GHE_REMOTE_VERSION" =~ 2.16 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.16.22)" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.17 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.17.13)" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.18 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.18.7)" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.19 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.19.1)" ]] && \ + if [[ "$GHE_REMOTE_VERSION" =~ 2.16 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.16.23)" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.17 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.17.14)" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.18 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.18.8)" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.19 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.19.3)" ]] && \ (echo "$line" | grep -q "gist"); then echo "$line" else From 04b3fee6f9538d31aae9d0addceef178a6f49d9d Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 27 Nov 2019 09:37:23 -0800 Subject: [PATCH 0824/2421] Skip backup and retore audit_entries indiviually if binary backup is available --- share/github-backup-utils/ghe-backup-audit-log | 8 ++++++++ share/github-backup-utils/ghe-restore-audit-log | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 01add554d..d7c78554d 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -29,7 +29,15 @@ is_skip_truncate_enabled(){ ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip_truncate" } +is_binary_backup(){ + ghe-ssh "$host" ghe-config --true "mysql.backup.binary" +} + backup_mysql(){ + if is_binary_backup; then + ghe-verbose "Skip backup audit_entries for Mysql since it is using binary backup" + return + fi if is_skip_truncate_enabled; then # As skip_truncate exists, we need to also backup the audit entries # in MySQL because Elasticsearch may not be fully synced. diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index aaee7ba42..4251c9222 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -46,6 +46,10 @@ is_mysql_supported(){ 'test \"\$ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED\" = \"1\""' | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash } +is_binary_backup(){ + ghe-ssh "$host" ghe-config --true "mysql.backup.binary" +} + # Helper function to set remote flags in `/data/user/common/audit-log-import` # if it's supported, i.e: directory exists. set_remote_flag(){ @@ -107,7 +111,17 @@ do_restore(){ ghe_verbose "Elasticsearch data is available" restore_es - restore_mysql --only-schema + + if is_binary_backup; then + ghe_verbose "Table audit_entries is already restored by binary backup" + else + restore_mysql --only-schema + fi + return + fi + + if is_binary_backup; then + ghe_verbose "Table audit_entries is already restored by binary backup" return fi From 585b209fc00b151d4afc1ba99b2543a5718cc7b0 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 27 Nov 2019 13:18:17 -0800 Subject: [PATCH 0825/2421] Fix a bug for variable --- share/github-backup-utils/ghe-restore-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 4251c9222..3e4622059 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -47,7 +47,7 @@ is_mysql_supported(){ } is_binary_backup(){ - ghe-ssh "$host" ghe-config --true "mysql.backup.binary" + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } # Helper function to set remote flags in `/data/user/common/audit-log-import` From d10f162368ee6cf0701c67e6c42a5ce2ca98d5af Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 27 Nov 2019 14:24:36 -0800 Subject: [PATCH 0826/2421] Fix small issue for ghe-verbose --- share/github-backup-utils/ghe-backup-audit-log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index d7c78554d..9366246f7 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -35,7 +35,7 @@ is_binary_backup(){ backup_mysql(){ if is_binary_backup; then - ghe-verbose "Skip backup audit_entries for Mysql since it is using binary backup" + ghe_verbose "Skip backup audit_entries for Mysql since it is using binary backup" return fi if is_skip_truncate_enabled; then From c2fc54a04bc152ac165bd77b82e2a8f437677fea Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 11 Dec 2019 01:33:01 -0800 Subject: [PATCH 0827/2421] Bump version: 2.19.1 [ci skip] --- debian/changelog | 7 +++++++ share/github-backup-utils/version | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 4e86d2f9c..0fc1811f0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.19.1) UNRELEASED; urgency=medium + + * Cater for more explicit gist paths used in routes file #524 + * Suppress "*.rsync': No such file or directory" errors when no data to backup or restore #525 + + -- Colin Seymour Wed, 11 Dec 2019 09:33:01 +0000 + github-backup-utils (2.19.0) UNRELEASED; urgency=medium * Remove temporary exclude file from the backup host not the target GHES appliance #516 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index ef0f38abe..b8e248f40 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.19.0 +2.19.1 From ac15b307d01bd0377c5c646d5cf8eea609608cdb Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 16 Dec 2019 12:07:25 -0800 Subject: [PATCH 0828/2421] Use sentinel file to identify type of mysql backup --- bin/ghe-backup | 8 +++++++ .../github-backup-utils/ghe-restore-audit-log | 3 ++- share/github-backup-utils/ghe-restore-mysql | 23 +++++++++++++++++-- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 3abe96749..11c4f3308 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -174,10 +174,18 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar || failures="$failures ssh-host-keys" bm_end "ghe-export-ssh-host-keys" +# if we are going to take a binary backup +is_binary_backup(){ + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" +} + echo "Backing up MySQL database ..." bm_start "ghe-export-mysql" echo 'set -o pipefail; ghe-export-mysql | gzip' | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql" +if is_binary_backup; then + touch mysql-binary-backup-sentinel +fi bm_end "ghe-export-mysql" echo "Backing up Redis database ..." diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 3e4622059..75fe0d419 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -46,8 +46,9 @@ is_mysql_supported(){ 'test \"\$ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED\" = \"1\""' | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash } +# Check if the backup is binary by looking up the sentinel file is_binary_backup(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" + test -f "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"/mysql-binary-backup-sentinel } # Helper function to set remote flags in `/data/user/common/audit-log-import` diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 9f1ed3c8a..e661e78e6 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -33,13 +33,32 @@ cleanup() { } trap 'cleanup' INT TERM EXIT +# Check if the backup is binary by looking up the sentinel file +is_binary_backup(){ + test -f $snapshot_dir/mysql-binary-backup-sentinel +} + +# if mysql.backup.binary feature flag is on +is_binary_backup_feature_on(){ + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" +} + +if is_binary_backup; then + if ! is_binary_backup_feature_on; then + echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 + exit 2 + fi + IMPORT_MYSQL=ghe-import-mysql-xtrabackup +else + IMPORT_MYSQL=ghe-import-mysql-mysqldump +fi + ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 # Transfer MySQL data from the snapshot to the GitHub instance. cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "gunzip -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | ghe-import-mysql" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 - +echo "gunzip -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 452b6921f134cbd4acee9a20f6c370af8365b206 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 16 Dec 2019 12:53:26 -0800 Subject: [PATCH 0829/2421] We need to support legacy version of GHES without new import scripts --- share/github-backup-utils/ghe-restore-mysql | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index e661e78e6..4c8cec9e4 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -43,14 +43,22 @@ is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } -if is_binary_backup; then - if ! is_binary_backup_feature_on; then +if is_binary_backup_feature_on; then + # Feature "mysql.backup.binary" is on, which means new backup scripts are available + if is_binary_backup; then + IMPORT_MYSQL=ghe-import-mysql-xtrabackup + else + IMPORT_MYSQL=ghe-import-mysql-mysqldump + fi +else + # We do not allow to restore binary backup without "mysql.backup.binary" set + if is_binary_backup; then echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 + else + # legacy mode + IMPORT_MYSQL=ghe-import-mysql fi - IMPORT_MYSQL=ghe-import-mysql-xtrabackup -else - IMPORT_MYSQL=ghe-import-mysql-mysqldump fi ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 From dbbfc1195d27eaf9cd45d34a3f255db772b638b8 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 16 Dec 2019 13:26:54 -0800 Subject: [PATCH 0830/2421] Add synbolic link for mocked ghe-import-mysql-xtrabackup and ghe-import-mysql-mysqldump --- test/bin/ghe-import-mysql-mysqldump | 1 + test/bin/ghe-import-mysql-xtrabackup | 1 + 2 files changed, 2 insertions(+) create mode 120000 test/bin/ghe-import-mysql-mysqldump create mode 120000 test/bin/ghe-import-mysql-xtrabackup diff --git a/test/bin/ghe-import-mysql-mysqldump b/test/bin/ghe-import-mysql-mysqldump new file mode 120000 index 000000000..bc329368a --- /dev/null +++ b/test/bin/ghe-import-mysql-mysqldump @@ -0,0 +1 @@ +ghe-fake-import-command \ No newline at end of file diff --git a/test/bin/ghe-import-mysql-xtrabackup b/test/bin/ghe-import-mysql-xtrabackup new file mode 120000 index 000000000..bc329368a --- /dev/null +++ b/test/bin/ghe-import-mysql-xtrabackup @@ -0,0 +1 @@ +ghe-fake-import-command \ No newline at end of file From 03f38173b2283dfd473031ae4ee254251bd1ba57 Mon Sep 17 00:00:00 2001 From: juruen Date: Fri, 6 Dec 2019 02:22:58 -0800 Subject: [PATCH 0831/2421] make sure the absence of audit_entries table is not fatal --- share/github-backup-utils/ghe-backup-audit-log | 10 +++++++++- share/github-backup-utils/ghe-restore-audit-log | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 9366246f7..6030b2c5b 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -29,6 +29,11 @@ is_skip_truncate_enabled(){ ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip_truncate" } +# Check whether the audit_entries table is deleted +audit_entries_deleted(){ + [ -z "$(ghe-ssh "$host" -- "/usr/local/share/enterprise/github-mysql 'SHOW TABLES LIKE \"audit_entries\"'")" ] +} + is_binary_backup(){ ghe-ssh "$host" ghe-config --true "mysql.backup.binary" } @@ -38,7 +43,10 @@ backup_mysql(){ ghe_verbose "Skip backup audit_entries for Mysql since it is using binary backup" return fi - if is_skip_truncate_enabled; then + + if audit_entries_deleted; then + ghe_verbose "audit_entries table does not exist" + elif is_skip_truncate_enabled; then # As skip_truncate exists, we need to also backup the audit entries # in MySQL because Elasticsearch may not be fully synced. "${base_path}/ghe-backup-mysql-audit-log" diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log index 75fe0d419..8da16b360 100755 --- a/share/github-backup-utils/ghe-restore-audit-log +++ b/share/github-backup-utils/ghe-restore-audit-log @@ -91,6 +91,11 @@ restore_mysql(){ ghe_verbose "Restoring MySQL audit logs ..." + if ! mysql_table_schema_available; then + ghe_verbose "schema.gz does not exist" + return + fi + "${base_path}/ghe-restore-mysql-audit-log" "$GHE_HOSTNAME" "$only_schema" } From 91a4b9bdd9a68206d528259aca12da86a2ca12ef Mon Sep 17 00:00:00 2001 From: Javier Uruen Val Date: Fri, 10 Jan 2020 22:45:05 +0100 Subject: [PATCH 0832/2421] remove code to handle mysql-stored audit logs --- bin/ghe-backup | 2 +- bin/ghe-restore | 2 +- .../github-backup-utils/ghe-backup-audit-log | 67 ----- .../ghe-backup-mysql-audit-log | 175 ------------- .../github-backup-utils/ghe-restore-audit-log | 162 ------------ .../ghe-restore-mysql-audit-log | 240 ------------------ 6 files changed, 2 insertions(+), 646 deletions(-) delete mode 100755 share/github-backup-utils/ghe-backup-audit-log delete mode 100755 share/github-backup-utils/ghe-backup-mysql-audit-log delete mode 100755 share/github-backup-utils/ghe-restore-audit-log delete mode 100755 share/github-backup-utils/ghe-restore-mysql-audit-log diff --git a/bin/ghe-backup b/bin/ghe-backup index 11c4f3308..4e4ee7a22 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -192,7 +192,7 @@ echo "Backing up Redis database ..." ghe-backup-redis > redis.rdb || failures="$failures redis" echo "Backing up audit log ..." -ghe-backup-audit-log || failures="$failures audit-log" +ghe-backup-es-audit-log || failures="$failures audit-log" echo "Backing up hookshot logs ..." ghe-backup-es-hookshot || failures="$failures hookshot" diff --git a/bin/ghe-restore b/bin/ghe-restore index 386eacdae..80c8921ce 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -302,7 +302,7 @@ fi # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then echo "Restoring Audit logs ..." - ghe-restore-audit-log "$GHE_HOSTNAME" 1>&3 + ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 echo "Restoring hookshot logs ..." ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log deleted file mode 100755 index 9366246f7..000000000 --- a/share/github-backup-utils/ghe-backup-audit-log +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-audit-log -#/ Take a backup of audit logs. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -base_path="$( dirname "${BASH_SOURCE[0]}" )" -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "${base_path}/ghe-backup-config" - -# Setup GHE_REMOTE_XXX variables, host and make sure work dir is created -setup(){ - # Perform a host-check and establish GHE_REMOTE_XXX variables. - ghe_remote_version_required "$host" - - # Set up remote host and root elastic backup directory based on config - host="$GHE_HOSTNAME" - - # Make sure root backup dir exists if this is the first run - mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" -} - -# Check whether the flag to skip the MySQL audit_entries table truncation -# exists. -is_skip_truncate_enabled(){ - ghe-ssh "$host" test -e "$GHE_REMOTE_DATA_USER_DIR/common/audit-log-import/skip_truncate" -} - -is_binary_backup(){ - ghe-ssh "$host" ghe-config --true "mysql.backup.binary" -} - -backup_mysql(){ - if is_binary_backup; then - ghe_verbose "Skip backup audit_entries for Mysql since it is using binary backup" - return - fi - if is_skip_truncate_enabled; then - # As skip_truncate exists, we need to also backup the audit entries - # in MySQL because Elasticsearch may not be fully synced. - "${base_path}/ghe-backup-mysql-audit-log" - else - "${base_path}/ghe-backup-mysql-audit-log" --schema-only - fi -} - -# Use ghe-backup-es-audit-log to back up Elasticsearch indices -backup_es(){ - "${base_path}/ghe-backup-es-audit-log" -} - -backup(){ - backup_mysql - backup_es -} - -main(){ - bm_start "$(basename "$0")" - setup - backup - bm_end "$(basename "$0")" -} - -main diff --git a/share/github-backup-utils/ghe-backup-mysql-audit-log b/share/github-backup-utils/ghe-backup-mysql-audit-log deleted file mode 100755 index 654169ae2..000000000 --- a/share/github-backup-utils/ghe-backup-mysql-audit-log +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-mysql-audit-log -#/ Take a backup of audit logs in MySQL. -#/ -#/ Args: -#/ --only-schema (optional: only dump the table schema) -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup-audit-log. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Whether we just need to dump the table schema and no data -only_schema="$1" - -# Setup GHE_REMOTE_XXX variables and other global variables -setup(){ - # Perform a host-check and establish GHE_REMOTE_XXX variables. - ghe_remote_version_required "$host" - - # Set up remote host and root elastic backup directory based on config - host="$GHE_HOSTNAME" - - # Where the new MySQL dumps go - snapshot_dir="$GHE_SNAPSHOT_DIR/audit-log-mysql" - - # Where the current MySQL dumps live - current_dir="$GHE_DATA_DIR/current/audit-log-mysql" - - # Wheter we need a full backup and not incremental - force_full_backup=false - - # Make sure root backup dir exists if this is the first run - mkdir -p "$snapshot_dir" -} - -# Use ghe-export-audit-logs to fetch the current metadata for all stored -# months in MySQL. For each month: number of entries, minum ID, maximum ID -fetch_current_meta(){ - local meta - if ! meta=$(ghe-ssh "$host" "sudo ghe-export-audit-logs months" 2>&3 | grep -v NULL 2>&3); then - ghe_verbose "Error: failed to retrieve audit log metadata" - exit 1 - fi - - [ -z "$meta" ] && return 1 - - echo "$meta" -} - -# Check if a month data exists in the current snapshot. Use its -# size, minimum ID and maximum ID to assume it's the same if -# they all match. -is_month_synced(){ - local meta="$1" - local name=$2 - - test -f "${current_dir}/${name}.gz" || return 1 - test -f "${current_dir}/${name}.meta" || return 1 - - [ "$(cat "${current_dir}/${name}.meta")" = "$meta" ] -} - -# To compare two schemas, we filter out comments, -# the AUTO_INCREMENT=XXXX value and blank lines -# to only leave SQL statements. -filter_schema(){ - local schema="$1" - - echo "$schema" | \ - grep -v "^--" | - grep -v "^/\\*" | \ - grep . | \ - sed 's/ AUTO_INCREMENT=[0-9]*\b//' -} - -# Dump table schema and check whether it has changed when -# compared with the schema stored in the current snapshot. -# If it has changed, we can't do an incremental backup -# and all data needs to be dumped in the new snapshot. -dump_schema(){ - ghe_verbose "dumping table schema..." - - local current - current=$(ghe-ssh "$host" "ghe-export-audit-logs dump --schema-only" 2>&3) - - echo "$current" | gzip >"${snapshot_dir}/schema.gz" - - if ! test -e "${current_dir}/schema.gz"; then - return - fi - - local previous - previous=$(gunzip -c "${current_dir}/schema.gz") - - if ! diff -Naur <(filter_schema "$current") <(filter_schema "$previous") 1>&3 2>&3; then - ghe_verbose "Current and previous schema don't match, forcing full backup" - force_full_backup=true - return - fi - - ghe_verbose "Current and previous schemas match" -} - -# Dump a month of audit entries from MySQL and store it -# in $name.gz. -# Create $name.meta with number of entries, minimum ID and maximum ID. -dump_month(){ - local meta="$1" - local name=$2 - - ghe_verbose "dumping ${meta}..." - - ghe-ssh "$host" "ghe-export-audit-logs dump --use-gzip=true $name" >"${snapshot_dir}/${name}.gz" 2>&3 - echo "$meta" > "${snapshot_dir}/${name}.meta" -} - -# Check if the export tool is available in this version -export_tool_available(){ - ghe-ssh "$host" "test -e /usr/local/bin/ghe-export-audit-logs" -} - -# Backup audit log entries: -# -# 1. Fetch metadata about the existing audit log entries in MySQL per month -# (month, number of entries, minumim ID, maximum ID) -# 2. If any month is uptodate in the current snapshot, hardlink it -# 3. Otherwise, dump those month entries from MySQL -backup(){ - if ! export_tool_available; then - ghe_verbose "ghe-export-audit-logs is not available" - return - fi - - dump_schema - - if [ -n "$only_schema" ]; then - ghe_verbose "only table schema was dumped" - return - fi - - local meta - if ! meta=$(fetch_current_meta); then - ghe_verbose "there are no current audit log entries" - return - fi - - IFS=$'\n' - for month in $meta; do - local month_name - month_name=$(echo "$month" | awk '{print $1}') - - if ! $force_full_backup && is_month_synced "$month" "$month_name"; then - # Month is in-sync with current data, create hardlink to it - ghe_verbose "$month_name is in sync, hardlinking to it.." - ln "${current_dir}/${month_name}.gz" "${snapshot_dir}/${month_name}.gz" - ln "${current_dir}/${month_name}.meta" "${snapshot_dir}/${month_name}.meta" - continue - fi - - dump_month "$month" "$month_name" - done -} - -main(){ - bm_start "$(basename "$0")" - setup - backup - bm_end "$(basename "$0")" -} - -main diff --git a/share/github-backup-utils/ghe-restore-audit-log b/share/github-backup-utils/ghe-restore-audit-log deleted file mode 100755 index 75fe0d419..000000000 --- a/share/github-backup-utils/ghe-restore-audit-log +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-audit-log -#/ Restore audit logs. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -base_path="$( dirname "${BASH_SOURCE[0]}" )" -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "${base_path}/ghe-backup-config" - -# Show usage and bail with no arguments -[ $# -lt 1 ] && print_usage "$@" - -GHE_HOSTNAME="$1" - -# Setup GHE_REMOTE_XXX variables, host and make sure work dir is created -setup(){ - # Perform a host-check and establish GHE_REMOTE_XXX variables. - ghe_remote_version_required "$GHE_HOSTNAME" -} - -# Check whether the snapshot contains audit logs that -# were taken from Elasticsearch -es_data_available(){ - ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"/audit-log/*.size >/dev/null 2>&1 -} - -# Check whether the snapshot contains audit logs that -# were taken from MySQL -mysql_dump_available(){ - ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"/audit-log-mysql/20*.gz >/dev/null 2>&1 -} - -# Check whether the snapshot contains the audit log table schema -mysql_table_schema_available(){ - ls -A "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"/audit-log-mysql/schema.gz >/dev/null 2>&1 -} - -# Check whether the remote host is running a version where the MySQL backend -# is supported, i.e: < 2.19 -is_mysql_supported(){ - echo 'sudo bash -c ". /data/github/current/.app-config/env.d/99-instance.sh;' \ - 'test \"\$ENTERPRISE_AUDIT_LOG_MYSQL_LOGGER_ENABLED\" = \"1\""' | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -} - -# Check if the backup is binary by looking up the sentinel file -is_binary_backup(){ - test -f "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"/mysql-binary-backup-sentinel -} - -# Helper function to set remote flags in `/data/user/common/audit-log-import` -# if it's supported, i.e: directory exists. -set_remote_flag(){ - local flag=$1 - local msg=$2 - - local dir="/data/user/common/audit-log-import" - - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo test -d $GHE_REMOTE_ROOT_DIR/$dir" 1>&3 2>&3; then - ghe_verbose "Remote version doesn't support audit log import, skipping '$msg'" - return - fi - - ghe_verbose "$msg" - ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_ROOT_DIR/$dir/$flag" 1>&3 2>&3 - - if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo touch $dir/$flag" 1>&3 2>&3; then - ghe_verbose "Failed to $msg in all instances in cluster" - fi - fi -} - -# Add flag to not trigger transitions from MySQL to Elasticsearch -set_skip_transition_flag(){ - set_remote_flag "skip" "Add flag to skip audit log import to MySQL" -} - -# Add flag to not trigger the truncation of the MySQL audit log table -set_skip_truncate_flag(){ - set_remote_flag "skip_truncate" "Add flag to skip truncating audit log table in MySQL" -} - -# Use `ghe-backup-mysql-audit-log` to dump the audit entries. -# If the import to MySQL is complete, add a flag in the snapshot to indicate so. -restore_mysql(){ - local only_schema=$1 - - ghe_verbose "Restoring MySQL audit logs ..." - - "${base_path}/ghe-restore-mysql-audit-log" "$GHE_HOSTNAME" "$only_schema" -} - -# Use ghe-restore-es-audit-log to restore Elasticsearch indices -restore_es(){ - ghe_verbose "Restoring Elasticsearch audit logs ..." - - "${base_path}/ghe-restore-es-audit-log" "$GHE_HOSTNAME" -} - -do_restore(){ - if is_mysql_supported; then - set_skip_transition_flag - fi - - # ES data is available, restore it along - # with the table schema - if es_data_available; then - ghe_verbose "Elasticsearch data is available" - - restore_es - - if is_binary_backup; then - ghe_verbose "Table audit_entries is already restored by binary backup" - else - restore_mysql --only-schema - fi - return - fi - - if is_binary_backup; then - ghe_verbose "Table audit_entries is already restored by binary backup" - return - fi - - # Only MySQL data is available, restore it - # and trigger a reindex - if mysql_dump_available; then - ghe_verbose "Only MySQL data is available" - - restore_mysql - - if ! is_mysql_supported; then - ghe_verbose "Add flag to skip MySQL audit log table truncation" - set_skip_truncate_flag - fi - - ghe_verbose "Starting audit log reindex from MySQL to Elasticsearch" - ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl --no-block restart auditlog-repair"; - return - fi - - if mysql_table_schema_available; then - # Only the table schema is available, restore it - ghe_verbose "Only audit_entries schema is available" - restore_mysql --only-schema - else - ghe_verbose "MySQL table schema is not available" - fi -} - -main(){ - bm_start "$(basename "$0")" - setup - do_restore - bm_end "$(basename "$0")" -} - -main diff --git a/share/github-backup-utils/ghe-restore-mysql-audit-log b/share/github-backup-utils/ghe-restore-mysql-audit-log deleted file mode 100755 index 6185c1b02..000000000 --- a/share/github-backup-utils/ghe-restore-mysql-audit-log +++ /dev/null @@ -1,240 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-mysql-audit-log -#/ Restore MySQL audit logs. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-restore-audit-log -set -e - -# Bring in the backup configuration -base_path="$( dirname "${BASH_SOURCE[0]}" )" -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "${base_path}/ghe-backup-config" - -# Show usage and bail with no arguments -[ $# -lt 1 ] && print_usage "$@" - -GHE_HOSTNAME="$1" - -# Whether we just need to imprt the table schema and no data -only_schema="$2" - -# Setup GHE_REMOTE_XXX variables, snapshot_dir, -# remote_dir, remote_dump and skip_prepare -setup(){ - # Perform a host-check and establish GHE_REMOTE_XXX variables. - ghe_remote_version_required "$GHE_HOSTNAME" - - snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log-mysql" - remote_dir="$GHE_REMOTE_DATA_USER_DIR/tmp" - remote_dump="$remote_dump/month.gz" - skip_prepare=false - - ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$remote_dir'" 1>&3 2>&3 - trap cleanup EXIT -} - -# Clean up on exit -cleanup(){ - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $remote_dump" -} - -# Check whether the snapshot contains any MySQL data at all -is_mysql_snapshot(){ - test -d "$snapshot_dir" -} - -# Use ghe-export-audit-logs to fetch the current metadata for all stored -# months in MySQL. For each month: number of entries, minum ID, maximum ID -fetch_current_meta(){ - local meta - if ! meta=$(ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs months" | grep -v NULL 2>&3); then - ghe_verbose "Error: failed to retrieve audit log metadata" - return - fi - - [ -z "$meta" ] && return 1 - - echo "$meta" -} - -# Read the audt log metadata for all stored months in the current snapshot -fetch_snapshot_meta(){ - local indices - if ! indices=$(cat "${snapshot_dir}"/*.meta 2>/dev/null); then - ghe_verbose "Snapshot doesn't contain MySQL audit log dumps" - return 1 - fi - - echo "$indices" -} - -# Return metadata of months that need to be restored by -# checking snapshot's metadata vs intances's. -# i.e: metadata doesn't match or doesn't exist in MySQL -# This allows us to do a incremental restore. -notsynced_meta(){ - local snapshot_meta - if ! snapshot_meta=$(fetch_snapshot_meta); then - return - fi - - local current_meta - if ! current_meta=$(fetch_current_meta); then - ghe_verbose "Current instance doesn't have any audit log entries in MySQL" - skip_prepare=true - echo "$snapshot_meta" - return - fi - - IFS=$'\n' - for m in $snapshot_meta; do - if echo "$current_meta" | grep -qx "$m"; then - ghe_verbose "$m is in sync" - continue - fi - - ghe_verbose "$m is NOT in sync" - echo "$m" - done - unset IFS -} - -# Prepare restore: remove audit entries that match the month to be restored to -# avoid ID collisions -prepare_month_restore(){ - local month=$1 - local meta=$2 - - # If table doesn't exist in the first place, we don't need - # to delete anything - if $skip_prepare; then - return - fi - - if ! ghe-ssh "$GHE_HOSTNAME" "sudo ghe-export-audit-logs prepare_restore $meta" 2>&3; then - ghe_verbose "failed to run ghe-export-audit-logs prepare_restore $meta" - fi -} - -# Restore a SQL dump of audit entries -restore_dump(){ - local name=$1 - - ghe_verbose "restoring ${name}.gz..." - - local dump="$snapshot_dir/${name}.gz" - if ! test -e "$dump"; then - ghe_verbose "snapshot is missing the $dump file" - return 1 - fi - - # Transfer MySQL data from the snapshot to the GitHub instance. - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$remote_dump" 1>&3 2>&3 <"$dump" - - # Import the entries - echo "gunzip -cd $remote_dump | sudo ghe-export-audit-logs restore" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 2>&3 -} - -# Restore a month of audit entries -restore_month(){ - local month=$1 - local meta=$2 - - prepare_month_restore "$month" "$meta" - restore_dump "$month" -} - -# To compare two schemas, we filter out comments, -# the AUTO_INCREMENT=XXXX value and blank lines -# to only leave SQL statements. -filter_schema(){ - local schema="$1" - - echo "$schema" | \ - grep -v "^--" | - grep -v "^/\\*" | \ - grep . | \ - sed 's/ AUTO_INCREMENT=[0-9]*\b//' -} - -# Check whether the snapshot's schema and the instance's -# are the same. If they are not the same, we can't do -# an incremental restore. -has_schema_changed(){ - local current - if ! current=$(ghe-ssh "$GHE_HOSTNAME" "ghe-export-audit-logs dump --schema-only" 2>&3); then - ghe_verbose "Failed to dump current table schema, forcing full restore" - return - fi - - local previous - previous=$(gunzip -c "${snapshot_dir}/schema.gz") - - if ! diff -Naur <(filter_schema "$current") <(filter_schema "$previous") 1>&3 2>&3; then - ghe_verbose "Current and previous schema don't match, forcing full restore" - return - fi - - ghe_verbose "Current and previous schemas match" - return 1 -} - -# Add DROP TABLE to a table schema dump -add_drop_table(){ - awk '/40101 SET @saved_cs_client/{print "DROP TABLE IF EXISTS `audit_entries`;"}1' -} - -# Restore the audit_entries table schema if it has changed -restore_schema(){ - if ! has_schema_changed; then - return - fi - - gunzip -c "${snapshot_dir}/schema.gz" | add_drop_table | gzip > "${snapshot_dir}/schema.new.gz" 2>&3 - zcat <"${snapshot_dir}/schema.new.gz" 1>&3 - - restore_dump schema.new -} - -# Check if the export tool is available in this version -export_tool_available(){ - ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-export-audit-logs" -} - -# Restore table schema and audit entries -restore(){ - if ! export_tool_available; then - ghe_verbose "ghe-export-audit-logs is not available" - return - fi - - if ! is_mysql_snapshot; then - ghe_verbose "snapshot doesn't contain MySQL data" - return - fi - - restore_schema - if [ -n "$only_schema" ]; then - ghe_verbose "only table schema was imported" - return - fi - - IFS=$'\n' - for month in $(notsynced_meta); do - local month_name - month_name=$(echo "$month" | awk '{print $1}') - - restore_month "$month_name" "$month" - done - unset IFS -} - -main(){ - bm_start "$(basename "$0")" - setup - restore - bm_end "$(basename "$0")" -} - -main From 8cb7d3a869d1b6baaa465a314656ecfd02079808 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 21 Jan 2020 11:29:08 -0800 Subject: [PATCH 0833/2421] Suffix existing script with '-rsync' to differentiate against incoming '-gitbackups' variant --- bin/ghe-backup | 3 ++- ...{ghe-backup-repositories => ghe-backup-repositories-rsync} | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) rename share/github-backup-utils/{ghe-backup-repositories => ghe-backup-repositories-rsync} (99%) diff --git a/bin/ghe-backup b/bin/ghe-backup index 11c4f3308..22b418ad2 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -197,8 +197,9 @@ ghe-backup-audit-log || failures="$failures audit-log" echo "Backing up hookshot logs ..." ghe-backup-es-hookshot || failures="$failures hookshot" +# TODO: introduce fork in logic for rsync vs gitbackups echo "Backing up Git repositories ..." -ghe-backup-repositories || failures="$failures repositories" +ghe-backup-repositories-rsync || failures="$failures repositories" echo "Backing up GitHub Pages ..." ghe-backup-pages || failures="$failures pages" diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories-rsync similarity index 99% rename from share/github-backup-utils/ghe-backup-repositories rename to share/github-backup-utils/ghe-backup-repositories-rsync index 62feb8d22..e89484b01 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories-rsync @@ -1,6 +1,6 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup-repositories -#/ Take an online, incremental snapshot of all Git repository data. +#/ Usage: ghe-backup-repositories-rsync +#/ Take an online, incremental snapshot of all Git repository data using rsync. #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. From b2ed6b0f50a0f202b26d8f0351ff8954ed8d772a Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 21 Jan 2020 11:31:19 -0800 Subject: [PATCH 0834/2421] Add placeholder script 'ghe-backup-repositories-gitbackups' --- .../github-backup-utils/ghe-backup-repositories-gitbackups | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 share/github-backup-utils/ghe-backup-repositories-gitbackups diff --git a/share/github-backup-utils/ghe-backup-repositories-gitbackups b/share/github-backup-utils/ghe-backup-repositories-gitbackups new file mode 100644 index 000000000..4f0529746 --- /dev/null +++ b/share/github-backup-utils/ghe-backup-repositories-gitbackups @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-repositories-gitbackups +#/ Take an online, incremental snapshot of all Git repository data using gitbackups. +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-backup. +set -e From b5691c7ac18e7e2b64aa2d95aad86d59dbb1857b Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 21 Jan 2020 16:55:51 -0800 Subject: [PATCH 0835/2421] Call backup-repositories script --- .../ghe-backup-repositories-gitbackups | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-repositories-gitbackups b/share/github-backup-utils/ghe-backup-repositories-gitbackups index 4f0529746..70dcd01c4 100644 --- a/share/github-backup-utils/ghe-backup-repositories-gitbackups +++ b/share/github-backup-utils/ghe-backup-repositories-gitbackups @@ -5,3 +5,14 @@ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +bm_start "$(basename $0)" + +# TODO: Not sure if we need to ssh onto GHE_HOSTNAME, aren't we on the appliance already? +echo "github-env ./bin/backup-repositories" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash + +bm_end "$(basename $0)" From 16bc3ecec901719591650c29809cec4417bc4df1 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 21 Jan 2020 17:11:24 -0800 Subject: [PATCH 0836/2421] Introduce fork in backup flow for backup mechanism --- bin/ghe-backup | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 22b418ad2..9aa7ad575 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -197,9 +197,18 @@ ghe-backup-audit-log || failures="$failures audit-log" echo "Backing up hookshot logs ..." ghe-backup-es-hookshot || failures="$failures hookshot" -# TODO: introduce fork in logic for rsync vs gitbackups +# if we should use gitbackups to backup repositories +should_use_gitbackups_for_repositories(){ + # TODO: Confirm re-using this setting is OK: https://github.slack.com/archives/CSG4WQ8G0/p1579655068042700?thread_ts=1578693309.052800&cid=CSG4WQ8G0 + ghe-ssh "$host" ghe-config --true "app.github.gitbackups" +} + echo "Backing up Git repositories ..." -ghe-backup-repositories-rsync || failures="$failures repositories" +if should_use_gitbackups_for_repositories; then + ghe-backup-repositories-gitbackups || failures="$failures repositories" +else + ghe-backup-repositories-rsync || failures="$failures repositories" +fi echo "Backing up GitHub Pages ..." ghe-backup-pages || failures="$failures pages" From 6c36e99a83776b9dca42a622530b9cb40c32c5bd Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 21 Jan 2020 17:14:56 -0800 Subject: [PATCH 0837/2421] Change ghe-ssh target from host to GHE_HOSTNAME --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 9aa7ad575..447de87e4 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -200,7 +200,7 @@ ghe-backup-es-hookshot || failures="$failures hookshot" # if we should use gitbackups to backup repositories should_use_gitbackups_for_repositories(){ # TODO: Confirm re-using this setting is OK: https://github.slack.com/archives/CSG4WQ8G0/p1579655068042700?thread_ts=1578693309.052800&cid=CSG4WQ8G0 - ghe-ssh "$host" ghe-config --true "app.github.gitbackups" + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" } echo "Backing up Git repositories ..." From c7159e3602d5cb11e15dc2fcdcea230845158d63 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 21 Jan 2020 17:30:33 -0800 Subject: [PATCH 0838/2421] Update comments --- bin/ghe-backup | 2 +- share/github-backup-utils/ghe-backup-repositories-gitbackups | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 447de87e4..3a140537f 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -199,7 +199,7 @@ ghe-backup-es-hookshot || failures="$failures hookshot" # if we should use gitbackups to backup repositories should_use_gitbackups_for_repositories(){ - # TODO: Confirm re-using this setting is OK: https://github.slack.com/archives/CSG4WQ8G0/p1579655068042700?thread_ts=1578693309.052800&cid=CSG4WQ8G0 + # TODO: Confirm re-using this setting is OK vs introducing a new setting ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" } diff --git a/share/github-backup-utils/ghe-backup-repositories-gitbackups b/share/github-backup-utils/ghe-backup-repositories-gitbackups index 70dcd01c4..35c9c6472 100644 --- a/share/github-backup-utils/ghe-backup-repositories-gitbackups +++ b/share/github-backup-utils/ghe-backup-repositories-gitbackups @@ -12,7 +12,6 @@ set -e bm_start "$(basename $0)" -# TODO: Not sure if we need to ssh onto GHE_HOSTNAME, aren't we on the appliance already? echo "github-env ./bin/backup-repositories" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash bm_end "$(basename $0)" From add11d44e76ceb07f5a815f8dba1ff8e75c3c1b2 Mon Sep 17 00:00:00 2001 From: dangmh Date: Thu, 23 Jan 2020 15:15:25 -0800 Subject: [PATCH 0839/2421] update permissions on backup script --- share/github-backup-utils/ghe-backup-repositories-gitbackups | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 share/github-backup-utils/ghe-backup-repositories-gitbackups diff --git a/share/github-backup-utils/ghe-backup-repositories-gitbackups b/share/github-backup-utils/ghe-backup-repositories-gitbackups old mode 100644 new mode 100755 From da4321b226aa4d60bc0da7bb06f309e851b07123 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Thu, 23 Jan 2020 16:36:23 -0800 Subject: [PATCH 0840/2421] Log which mechanism is being used for repository backup --- bin/ghe-backup | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 3a140537f..1d1589d2b 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -203,10 +203,11 @@ should_use_gitbackups_for_repositories(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" } -echo "Backing up Git repositories ..." if should_use_gitbackups_for_repositories; then + echo "Backing up Git repositories using gitbackups ..." ghe-backup-repositories-gitbackups || failures="$failures repositories" else + echo "Backing up Git repositories using rsync ..." ghe-backup-repositories-rsync || failures="$failures repositories" fi From 30fb1d8cc0b8302fd2230b201eaaa4e3446a765a Mon Sep 17 00:00:00 2001 From: cainejette Date: Thu, 23 Jan 2020 18:05:45 -0800 Subject: [PATCH 0841/2421] Protect against appliance not supporting gitbackups-powered repository backups --- bin/ghe-backup | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 1d1589d2b..ac84c9904 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -203,9 +203,20 @@ should_use_gitbackups_for_repositories(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" } +# check that the appliance supports using gitbackups for repositories +can_use_gitbackups_for_repositories(){ + ghe-ssh "$GHE_HOSTNAME" test -e /data/github/current/bin/backup-repositories +} + if should_use_gitbackups_for_repositories; then - echo "Backing up Git repositories using gitbackups ..." - ghe-backup-repositories-gitbackups || failures="$failures repositories" + if can_use_gitbackups_for_repositories; then + echo "Backing up Git repositories using gitbackups ..." + ghe-backup-repositories-gitbackups || failures="$failures repositories" + else + # we should probably just default to rsync version in this case? + echo "Warning: This version of GHES does not support gitbackups for backing up repositories." + echo "Disable app.github.gitbackups config setting and rerun to use rsync." + fi else echo "Backing up Git repositories using rsync ..." ghe-backup-repositories-rsync || failures="$failures repositories" From 5bed84c7d0d079801d26dc42008f6c7708e77917 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Fri, 24 Jan 2020 08:42:32 -0800 Subject: [PATCH 0842/2421] Remove comment after confirming existing config setting is OK to re-use. --- bin/ghe-backup | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index ac84c9904..fed290cfe 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -199,7 +199,6 @@ ghe-backup-es-hookshot || failures="$failures hookshot" # if we should use gitbackups to backup repositories should_use_gitbackups_for_repositories(){ - # TODO: Confirm re-using this setting is OK vs introducing a new setting ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" } From 566902ecf2a5cfcd852b8f839500d2d4fe915554 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Fri, 24 Jan 2020 08:53:56 -0800 Subject: [PATCH 0843/2421] Exit early if the appliance is set to use gitbackups for repositories but is missing required script to do so --- bin/ghe-backup | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index fed290cfe..555862f2e 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -81,6 +81,25 @@ if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile fi rm -rf src dest1 dest2 +# if we should use gitbackups to backup repositories +should_use_gitbackups_for_repositories(){ + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" +} + +# check that the appliance supports using gitbackups for repositories +can_use_gitbackups_for_repositories(){ + ghe-ssh "$GHE_HOSTNAME" test -e /data/github/current/bin/backup-repositories +} + +# Exit early if the appliance is missing script to backup repositories using gitbackups +if should_use_gitbackups_for_repositories; then + if ! can_use_gitbackups_for_repositories; then + echo "Error: Configuration setting 'app.github.gitbackups' is enabled but gitbackups cannot be used to back up repositories via 'ghe-backup'." + echo "Disable configuration setting 'app.github.gitbackups' and re-run 'ghe-backup' to use rsync." + exit 1 + fi +fi + # To prevent multiple backup runs happening at the same time, we create a # in-progress file with the timestamp and pid of the backup process, # giving us a form of locking. @@ -197,25 +216,9 @@ ghe-backup-audit-log || failures="$failures audit-log" echo "Backing up hookshot logs ..." ghe-backup-es-hookshot || failures="$failures hookshot" -# if we should use gitbackups to backup repositories -should_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" -} - -# check that the appliance supports using gitbackups for repositories -can_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" test -e /data/github/current/bin/backup-repositories -} - -if should_use_gitbackups_for_repositories; then - if can_use_gitbackups_for_repositories; then - echo "Backing up Git repositories using gitbackups ..." - ghe-backup-repositories-gitbackups || failures="$failures repositories" - else - # we should probably just default to rsync version in this case? - echo "Warning: This version of GHES does not support gitbackups for backing up repositories." - echo "Disable app.github.gitbackups config setting and rerun to use rsync." - fi +if should_use_gitbackups_for_repositories && can_use_gitbackups_for_repositories; then + echo "Backing up Git repositories using gitbackups ..." + ghe-backup-repositories-gitbackups || failures="$failures repositories" else echo "Backing up Git repositories using rsync ..." ghe-backup-repositories-rsync || failures="$failures repositories" From 91f8cc289670b6ae1abdb17f57bb332bfd66da34 Mon Sep 17 00:00:00 2001 From: "Courtney (CJ) Oka" <16140724+oakeyc@users.noreply.github.com> Date: Fri, 24 Jan 2020 10:13:55 -0800 Subject: [PATCH 0844/2421] Update bin/ghe-backup update wording Co-Authored-By: Caine Jette --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 555862f2e..f67b4dc71 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -94,7 +94,7 @@ can_use_gitbackups_for_repositories(){ # Exit early if the appliance is missing script to backup repositories using gitbackups if should_use_gitbackups_for_repositories; then if ! can_use_gitbackups_for_repositories; then - echo "Error: Configuration setting 'app.github.gitbackups' is enabled but gitbackups cannot be used to back up repositories via 'ghe-backup'." + echo "Error: Configuration setting 'app.github.gitbackups' is enabled but this version of GHES cannot use gitbackups to back up repositories via 'ghe-backup'." echo "Disable configuration setting 'app.github.gitbackups' and re-run 'ghe-backup' to use rsync." exit 1 fi From 6bf9c51f09c5bd6ac90e72fa68c79318e176f6ea Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 30 Jan 2020 11:08:16 -0800 Subject: [PATCH 0845/2421] Add testing for parse_paths --- share/github-backup-utils/ghe-backup-config | 20 + test/test-ghe-backup.sh | 590 ++++++++++---------- 2 files changed, 326 insertions(+), 284 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 0d16c704d..2e7872adc 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -304,3 +304,23 @@ ghe_debug() { version() { echo "${@#v}" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } + +parse_paths() { + local version_GHE_REMOTE_VERSION=$(version $GHE_REMOTE_VERSION) + local version_2_16_23=$(version 2.16.23) + local version_2_17_14=$(version 2.17.14) + local version_2_18_8=$(version 2.18.8) + local vesrion_2_19_3=$(version 2.19.3) + + while read -r line; do + if [[ "$GHE_REMOTE_VERSION" =~ 2.16 && "$version_GHE_REMOTE_VERSION" -ge "$version_2_16_23" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.17 && "$version_GHE_REMOTE_VERSION" -ge "$version_2_17_14" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.18 && "$version_GHE_REMOTE_VERSION" -ge "$version_2_18_8" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.19 && "$version_GHE_REMOTE_VERSION" -ge "$vesrion_2_19_3" ]] && \ + (echo "$line" | grep -q "gist"); then + echo "$line" + else + dirname "$line" + fi + done +} \ No newline at end of file diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 9fe8eb9bb..f2865ea4f 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -1,346 +1,368 @@ #!/usr/bin/env bash # ghe-backup command tests - +TESTS_DIR="$(realpath "$(dirname "$0")")" # Bring in testlib # shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. "$TESTS_DIR/testlib.sh" # Create the backup data dir and fake remote repositories dirs mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" setup_test_data $GHE_REMOTE_DATA_USER_DIR -begin_test "ghe-backup first snapshot" -( - set -e +# begin_test "ghe-backup first snapshot" +# ( +# set -e - # check that no current symlink exists yet - [ ! -d "$GHE_DATA_DIR/current" ] +# # check that no current symlink exists yet +# [ ! -d "$GHE_DATA_DIR/current" ] - # run it - ghe-backup -v +# # run it +# ghe-backup -v - verify_all_backedup_data -) -end_test +# verify_all_backedup_data +# ) +# end_test -begin_test "ghe-backup subsequent snapshot" -( - set -e +# begin_test "ghe-backup subsequent snapshot" +# ( +# set -e - # wait a second for snapshot timestamp - sleep 1 +# # wait a second for snapshot timestamp +# sleep 1 - # check that no current symlink exists yet - [ -d "$GHE_DATA_DIR/current" ] +# # check that no current symlink exists yet +# [ -d "$GHE_DATA_DIR/current" ] - # grab the first snapshot number so we can compare after - first_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') +# # grab the first snapshot number so we can compare after +# first_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') - # run it - ghe-backup +# # run it +# ghe-backup - # check that current symlink points to new snapshot - this_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') - [ "$first_snapshot" != "$this_snapshot" ] +# # check that current symlink points to new snapshot +# this_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') +# [ "$first_snapshot" != "$this_snapshot" ] - verify_all_backedup_data -) -end_test - -begin_test "ghe-backup logs the benchmark" -( - set -e +# verify_all_backedup_data +# ) +# end_test - # wait a second for snapshot timestamp - sleep 1 +# begin_test "ghe-backup logs the benchmark" +# ( +# set -e - export BM_TIMESTAMP=foo +# # wait a second for snapshot timestamp +# sleep 1 - ghe-backup - - [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] -) -end_test +# export BM_TIMESTAMP=foo -begin_test "ghe-backup with relative data dir path" -( - set -e +# ghe-backup - # wait a second for snapshot timestamp - sleep 1 +# [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] +# ) +# end_test - # generate a timestamp - GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" - export GHE_SNAPSHOT_TIMESTAMP +# begin_test "ghe-backup with relative data dir path" +# ( +# set -e - # change working directory to the root directory - cd $ROOTDIR +# # wait a second for snapshot timestamp +# sleep 1 - # run it - GHE_DATA_DIR=$(echo $GHE_DATA_DIR | sed 's|'$ROOTDIR'/||') ghe-backup +# # generate a timestamp +# GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" +# export GHE_SNAPSHOT_TIMESTAMP - # check that current symlink points to new snapshot - [ "$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.*-> //')" = "$GHE_SNAPSHOT_TIMESTAMP" ] +# # change working directory to the root directory +# cd $ROOTDIR - verify_all_backedup_data -) -end_test +# # run it +# GHE_DATA_DIR=$(echo $GHE_DATA_DIR | sed 's|'$ROOTDIR'/||') ghe-backup -begin_test "ghe-backup fails fast when old style run in progress" -( - set -e +# # check that current symlink points to new snapshot +# [ "$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.*-> //')" = "$GHE_SNAPSHOT_TIMESTAMP" ] - ln -s 1 "$GHE_DATA_DIR/in-progress" - ! ghe-backup +# verify_all_backedup_data +# ) +# end_test - unlink "$GHE_DATA_DIR/in-progress" -) -end_test +# begin_test "ghe-backup fails fast when old style run in progress" +# ( +# set -e -begin_test "ghe-backup cleans up stale in-progress file" -( - set -e +# ln -s 1 "$GHE_DATA_DIR/in-progress" +# ! ghe-backup - echo "20150928T153353 99999" > "$GHE_DATA_DIR/in-progress" - ghe-backup +# unlink "$GHE_DATA_DIR/in-progress" +# ) +# end_test - [ ! -f "$GHE_DATA_DIR/in-progress" ] -) -end_test +# begin_test "ghe-backup cleans up stale in-progress file" +# ( +# set -e -begin_test "ghe-backup without management console password" -( - set -e +# echo "20150928T153353 99999" > "$GHE_DATA_DIR/in-progress" +# ghe-backup - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "" - ghe-backup +# [ ! -f "$GHE_DATA_DIR/in-progress" ] +# ) +# end_test - [ ! -f "$GHE_DATA_DIR/current/manage-password" ] -) -end_test +# begin_test "ghe-backup without management console password" +# ( +# set -e -begin_test "ghe-backup empty hookshot directory" -( - set -e +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "" +# ghe-backup - rm -rf $GHE_REMOTE_DATA_USER_DIR/hookshot/repository-* - rm -rf $GHE_DATA_DIR/current/hookshot/repository-* - ghe-backup +# [ ! -f "$GHE_DATA_DIR/current/manage-password" ] +# ) +# end_test - # Check that the "--link-dest arg does not exist" message hasn't occurred. - [ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ] -) -end_test +# begin_test "ghe-backup empty hookshot directory" +# ( +# set -e -begin_test "ghe-backup empty git-hooks directory" -( - set -e +# rm -rf $GHE_REMOTE_DATA_USER_DIR/hookshot/repository-* +# rm -rf $GHE_DATA_DIR/current/hookshot/repository-* +# ghe-backup - rm -rf $GHE_REMOTE_DATA_USER_DIR/git-hooks/* - rm -rf $GHE_DATA_DIR/current/git-hooks/* - ghe-backup +# # Check that the "--link-dest arg does not exist" message hasn't occurred. +# [ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ] +# ) +# end_test - # Check that the "--link-dest arg does not exist" message hasn't occurred. - [ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ] -) -end_test +# begin_test "ghe-backup empty git-hooks directory" +# ( +# set -e -begin_test "ghe-backup fsck" -( - set -e +# rm -rf $GHE_REMOTE_DATA_USER_DIR/git-hooks/* +# rm -rf $GHE_DATA_DIR/current/git-hooks/* +# ghe-backup - export GHE_BACKUP_FSCK=yes - ghe-backup | grep -q "Repos verified: 6, Errors: 1, Took:" - # Verbose mode disabled by default - ! ghe-backup | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" - ghe-backup -v | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" +# # Check that the "--link-dest arg does not exist" message hasn't occurred. +# [ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ] +# ) +# end_test - export GHE_BACKUP_FSCK=no - ! ghe-backup | grep -q "Repos verified:" -) -end_test +# begin_test "ghe-backup fsck" +# ( +# set -e -begin_test "ghe-backup stores version when not run from a clone" -( - set -e +# export GHE_BACKUP_FSCK=yes +# ghe-backup | grep -q "Repos verified: 6, Errors: 1, Took:" +# # Verbose mode disabled by default +# ! ghe-backup | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" +# ghe-backup -v | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" - # Make sure this doesn't exist - rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" +# export GHE_BACKUP_FSCK=no +# ! ghe-backup | grep -q "Repos verified:" +# ) +# end_test - tmpdir=$(mktemp -d "$TRASHDIR/foo.XXXXXX") +# begin_test "ghe-backup stores version when not run from a clone" +# ( +# set -e - # If user is running the tests extracted from a release tarball, git clone will fail. - if GIT_DIR="$ROOTDIR/.git" git rev-parse --is-inside-work-tree > /dev/null 2>&1; then - git clone "$ROOTDIR" "$tmpdir/backup-utils" - cd "$tmpdir/backup-utils" - rm -rf .git - ./bin/ghe-backup +# # Make sure this doesn't exist +# rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" + +# tmpdir=$(mktemp -d "$TRASHDIR/foo.XXXXXX") - # Verify that ghe-backup wrote its version information to the host - [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] - else - echo ".git directory not found, skipping ghe-backup not from a clone test" - fi -) -end_test +# # If user is running the tests extracted from a release tarball, git clone will fail. +# if GIT_DIR="$ROOTDIR/.git" git rev-parse --is-inside-work-tree > /dev/null 2>&1; then +# git clone "$ROOTDIR" "$tmpdir/backup-utils" +# cd "$tmpdir/backup-utils" +# rm -rf .git +# ./bin/ghe-backup -begin_test "ghe-backup with leaked SSH host key detection for current backup" +# # Verify that ghe-backup wrote its version information to the host +# [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] +# else +# echo ".git directory not found, skipping ghe-backup not from a clone test" +# fi +# ) +# end_test + +# begin_test "ghe-backup with leaked SSH host key detection for current backup" +# ( +# set -e + +# # Rename ghe-export-ssh-keys to generate a fake ssh +# cd "$ROOTDIR/test/bin" +# mv "ghe-export-ssh-host-keys" "ghe-export-ssh-host-keys.orig" +# ln -s ghe-gen-fake-ssh-tar ghe-export-ssh-host-keys +# cd - + +# # Inject the fingerprint into the blacklist +# export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" + +# # Run it +# output=$(ghe-backup -v) + +# # Set the export ssh back +# mv "$ROOTDIR/test/bin/ghe-export-ssh-host-keys.orig" "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" + +# # Test the output for leaked key detection +# echo $output| grep "The current backup contains leaked SSH host keys" + +# ) +# end_test + +# begin_test "ghe-backup with no leaked keys" +# ( +# set -e + +# # Make sure there are no leaked key messages +# ! ghe-backup -v | grep "Leaked key" + +# ) +# end_test + +# begin_test "ghe-backup honours --version flag" +# ( +# set -e + +# # Make sure a partial version string is returned +# ghe-backup --version | grep "GitHub backup-utils v" + +# ) +# end_test + +# begin_test "ghe-backup honours --help and -h flags" +# ( +# set -e + +# arg_help=$(ghe-backup --help | grep -o 'Usage: ghe-backup') +# arg_h=$(ghe-backup -h | grep -o 'Usage: ghe-backup') + +# # Make sure a Usage: string is returned and that it's the same for -h and --help +# [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-backup" + +# ) +# end_test + +# begin_test "ghe-backup exits early on unsupported version" +# ( +# set -e +# ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-backup -v +# ) +# end_test + +# begin_test "ghe-backup-strategy returns rsync for HA backup" +# ( +# set -e +# touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" +# output="$(ghe-backup-strategy)" +# rm "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" +# [ "$output" = "rsync" ] +# ) +# end_test + +# # Reset data for sub-subsequent tests +# rm -rf $GHE_REMOTE_DATA_USER_DIR +# setup_test_data $GHE_REMOTE_DATA_USER_DIR + +# begin_test "ghe-backup cluster" +# ( +# set -e +# setup_remote_cluster + +# if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then +# cat "$TRASHDIR/backup-out" +# : ghe-restore should have exited successfully +# false +# fi + +# cat "$TRASHDIR/backup-out" + +# # verify data was copied from multiple nodes +# # repositories +# grep -q "repositories from git-server-fake-uuid" "$TRASHDIR/backup-out" +# grep -q "repositories from git-server-fake-uuid1" "$TRASHDIR/backup-out" +# grep -q "repositories from git-server-fake-uuid2" "$TRASHDIR/backup-out" + +# # storage +# grep -q "objects from storage-server-fake-uuid" "$TRASHDIR/backup-out" +# grep -q "objects from storage-server-fake-uuid1" "$TRASHDIR/backup-out" +# grep -q "objects from storage-server-fake-uuid2" "$TRASHDIR/backup-out" + +# # pages +# grep -q "Starting backup for host: pages-server-fake-uuid" "$TRASHDIR/backup-out" +# grep -q "Starting backup for host: pages-server-fake-uuid1" "$TRASHDIR/backup-out" +# grep -q "Starting backup for host: pages-server-fake-uuid2" "$TRASHDIR/backup-out" + +# # verify cluster.conf backed up +# [ -f "$GHE_DATA_DIR/current/cluster.conf" ] +# grep -q "fake cluster config" "$GHE_DATA_DIR/current/cluster.conf" + +# verify_all_backedup_data +# ) +# end_test + +# begin_test "ghe-backup not missing directories or files on source appliance" +# ( +# # Tests the scenario where the database and on disk state are consistent. +# set -e + +# if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then +# cat "$TRASHDIR/backup-out" +# : ghe-backup should have completed successfully +# false +# fi + +# # Ensure the output doesn't contain the warnings +# grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 +# grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 + +# verify_all_backedup_data +# ) +# end_test + +# begin_test "ghe-backup missing directories or files on source appliance" +# ( +# # Tests the scenario where something exists in the database, but not on disk. +# set -e + +# rm -rf $GHE_REMOTE_DATA_USER_DIR/repositories/1 +# rm -rf $GHE_REMOTE_DATA_USER_DIR/storage/e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244 + +# if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then +# cat "$TRASHDIR/backup-out" +# : ghe-backup should have completed successfully +# false +# fi + +# # Check the output for the warnings +# grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" +# grep -q "\-1/23/bb/4c/gist" "$TRASHDIR/backup-out" +# grep -q "\-1/nw/23/bb/4c/2345" "$TRASHDIR/backup-out" +# grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" +# grep -q "\-e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" "$TRASHDIR/backup-out" + +# verify_all_backedup_data +# ) +# end_test + +# acceptance criteria is less then 2 seconds for 10,000 lines +begin_test "ghe-backup backup gist" ( - set -e - - # Rename ghe-export-ssh-keys to generate a fake ssh - cd "$ROOTDIR/test/bin" - mv "ghe-export-ssh-host-keys" "ghe-export-ssh-host-keys.orig" - ln -s ghe-gen-fake-ssh-tar ghe-export-ssh-host-keys - cd - - - # Inject the fingerprint into the blacklist - export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" - - # Run it - output=$(ghe-backup -v) - - # Set the export ssh back - mv "$ROOTDIR/test/bin/ghe-export-ssh-host-keys.orig" "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" - - # Test the output for leaked key detection - echo $output| grep "The current backup contains leaked SSH host keys" - -) -end_test - -begin_test "ghe-backup with no leaked keys" -( - set -e - - # Make sure there are no leaked key messages - ! ghe-backup -v | grep "Leaked key" - -) -end_test - -begin_test "ghe-backup honours --version flag" -( - set -e - - # Make sure a partial version string is returned - ghe-backup --version | grep "GitHub backup-utils v" - -) -end_test - -begin_test "ghe-backup honours --help and -h flags" -( - set -e - - arg_help=$(ghe-backup --help | grep -o 'Usage: ghe-backup') - arg_h=$(ghe-backup -h | grep -o 'Usage: ghe-backup') - - # Make sure a Usage: string is returned and that it's the same for -h and --help - [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-backup" - -) -end_test - -begin_test "ghe-backup exits early on unsupported version" -( - set -e - ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-backup -v -) -end_test - -begin_test "ghe-backup-strategy returns rsync for HA backup" -( - set -e - touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" - output="$(ghe-backup-strategy)" - rm "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" - [ "$output" = "rsync" ] -) -end_test - -# Reset data for sub-subsequent tests -rm -rf $GHE_REMOTE_DATA_USER_DIR -setup_test_data $GHE_REMOTE_DATA_USER_DIR - -begin_test "ghe-backup cluster" -( - set -e - setup_remote_cluster - - if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then - cat "$TRASHDIR/backup-out" - : ghe-restore should have exited successfully - false - fi - - cat "$TRASHDIR/backup-out" - - # verify data was copied from multiple nodes - # repositories - grep -q "repositories from git-server-fake-uuid" "$TRASHDIR/backup-out" - grep -q "repositories from git-server-fake-uuid1" "$TRASHDIR/backup-out" - grep -q "repositories from git-server-fake-uuid2" "$TRASHDIR/backup-out" - - # storage - grep -q "objects from storage-server-fake-uuid" "$TRASHDIR/backup-out" - grep -q "objects from storage-server-fake-uuid1" "$TRASHDIR/backup-out" - grep -q "objects from storage-server-fake-uuid2" "$TRASHDIR/backup-out" - - # pages - grep -q "Starting backup for host: pages-server-fake-uuid" "$TRASHDIR/backup-out" - grep -q "Starting backup for host: pages-server-fake-uuid1" "$TRASHDIR/backup-out" - grep -q "Starting backup for host: pages-server-fake-uuid2" "$TRASHDIR/backup-out" - - # verify cluster.conf backed up - [ -f "$GHE_DATA_DIR/current/cluster.conf" ] - grep -q "fake cluster config" "$GHE_DATA_DIR/current/cluster.conf" - - verify_all_backedup_data -) -end_test - -begin_test "ghe-backup not missing directories or files on source appliance" -( - # Tests the scenario where the database and on disk state are consistent. set -e - - if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then - cat "$TRASHDIR/backup-out" - : ghe-backup should have completed successfully - false - fi - - # Ensure the output doesn't contain the warnings - grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 - grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 - - verify_all_backedup_data + timeout 2 bash -c " + source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; + GHE_REMOTE_VERSION=2.16.23; + seq 1 10000 | sed -e 's/$/ gist/' | parse_paths | grep -c gist" ) end_test -begin_test "ghe-backup missing directories or files on source appliance" +# acceptance criteria is less then 2 seconds for 10,000 lines +begin_test "ghe-backup backup wiki" ( - # Tests the scenario where something exists in the database, but not on disk. set -e - - rm -rf $GHE_REMOTE_DATA_USER_DIR/repositories/1 - rm -rf $GHE_REMOTE_DATA_USER_DIR/storage/e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244 - - if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then - cat "$TRASHDIR/backup-out" - : ghe-backup should have completed successfully - false - fi - - # Check the output for the warnings - grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" - grep -q "\-1/23/bb/4c/gist" "$TRASHDIR/backup-out" - grep -q "\-1/nw/23/bb/4c/2345" "$TRASHDIR/backup-out" - grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" - grep -q "\-e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" "$TRASHDIR/backup-out" - - verify_all_backedup_data + timeout 2 bash -c " + source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; + GHE_REMOTE_VERSION=2.16.23; + seq 1 10000 | sed -e 's/$/ wiki/' | parse_paths | grep -c '^\.$'" ) -end_test +end_test \ No newline at end of file From 1773b6e5afce9cd16f81dce275d1da6f7c4a2767 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 30 Jan 2020 11:24:19 -0800 Subject: [PATCH 0846/2421] Use substring match instead of grep for each line --- share/github-backup-utils/ghe-backup-config | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 2e7872adc..6e35e8f0a 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -313,11 +313,11 @@ parse_paths() { local vesrion_2_19_3=$(version 2.19.3) while read -r line; do - if [[ "$GHE_REMOTE_VERSION" =~ 2.16 && "$version_GHE_REMOTE_VERSION" -ge "$version_2_16_23" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.17 && "$version_GHE_REMOTE_VERSION" -ge "$version_2_17_14" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.18 && "$version_GHE_REMOTE_VERSION" -ge "$version_2_18_8" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.19 && "$version_GHE_REMOTE_VERSION" -ge "$vesrion_2_19_3" ]] && \ - (echo "$line" | grep -q "gist"); then + if [[ "$GHE_REMOTE_VERSION" =~ 2.16. && "$version_GHE_REMOTE_VERSION" -ge "$version_2_16_23" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.17. && "$version_GHE_REMOTE_VERSION" -ge "$version_2_17_14" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.18. && "$version_GHE_REMOTE_VERSION" -ge "$version_2_18_8" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.19. && "$version_GHE_REMOTE_VERSION" -ge "$vesrion_2_19_3" ]] && \ + [[ "$line" =~ gist ]]; then echo "$line" else dirname "$line" From 51505a1b71b86ef534bda8e9d6b60e4f791b7a72 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 30 Jan 2020 11:32:54 -0800 Subject: [PATCH 0847/2421] remove old implementation and rename --- share/github-backup-utils/ghe-backup-config | 2 +- .../ghe-backup-repositories | 19 +------------------ test/test-ghe-backup.sh | 4 ++-- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 6e35e8f0a..6e3fca24b 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -305,7 +305,7 @@ version() { echo "${@#v}" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } -parse_paths() { +fix_paths_for_ghe_version() { local version_GHE_REMOTE_VERSION=$(version $GHE_REMOTE_VERSION) local version_2_16_23=$(version 2.16.23) local version_2_17_14=$(version 2.17.14) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 62feb8d22..5e51f4869 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -366,25 +366,8 @@ bm_end "$(basename $0) - Special Data Directories Sync" if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then bm_start "$(basename $0) - Verifying Routes" - - # The list of gists returned by the source changed in 2.16.23, 2.17.14, 2.18.8 & 2.19.3 - # so we need to account for this difference here. - parse_paths() { - while read -r line; do - if [[ "$GHE_REMOTE_VERSION" =~ 2.16 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.16.23)" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.17 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.17.14)" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.18 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.18.8)" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.19 && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.19.3)" ]] && \ - (echo "$line" | grep -q "gist"); then - echo "$line" - else - dirname "$line" - fi - done - } - cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes - (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | parse_paths | sort | uniq) > $tempdir/destination_routes + (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | fix_paths_for_ghe_version | sort | uniq) > $tempdir/destination_routes git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index f2865ea4f..b27f4684e 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -352,7 +352,7 @@ begin_test "ghe-backup backup gist" timeout 2 bash -c " source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; GHE_REMOTE_VERSION=2.16.23; - seq 1 10000 | sed -e 's/$/ gist/' | parse_paths | grep -c gist" + seq 1 10000 | sed -e 's/$/ gist/' | fix_paths_for_ghe_version | grep -c gist" ) end_test @@ -363,6 +363,6 @@ begin_test "ghe-backup backup wiki" timeout 2 bash -c " source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; GHE_REMOTE_VERSION=2.16.23; - seq 1 10000 | sed -e 's/$/ wiki/' | parse_paths | grep -c '^\.$'" + seq 1 10000 | sed -e 's/$/ wiki/' | fix_paths_for_ghe_version | grep -c '^\.$'" ) end_test \ No newline at end of file From db603139a560519421ec2ab84e7e786678fc8bc2 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 11:59:19 -0800 Subject: [PATCH 0848/2421] Make fix_paths 200x faster by writing it in Ruby --- share/github-backup-utils/ghe-backup-config | 38 +++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 6e3fca24b..22553f2c8 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -306,21 +306,23 @@ version() { } fix_paths_for_ghe_version() { - local version_GHE_REMOTE_VERSION=$(version $GHE_REMOTE_VERSION) - local version_2_16_23=$(version 2.16.23) - local version_2_17_14=$(version 2.17.14) - local version_2_18_8=$(version 2.18.8) - local vesrion_2_19_3=$(version 2.19.3) - - while read -r line; do - if [[ "$GHE_REMOTE_VERSION" =~ 2.16. && "$version_GHE_REMOTE_VERSION" -ge "$version_2_16_23" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.17. && "$version_GHE_REMOTE_VERSION" -ge "$version_2_17_14" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.18. && "$version_GHE_REMOTE_VERSION" -ge "$version_2_18_8" ]] || \ - [[ "$GHE_REMOTE_VERSION" =~ 2.19. && "$version_GHE_REMOTE_VERSION" -ge "$vesrion_2_19_3" ]] && \ - [[ "$line" =~ gist ]]; then - echo "$line" - else - dirname "$line" - fi - done -} \ No newline at end of file + ruby -e ' + ghe_remote_version = ARGV.first + version_array = ghe_remote_version.split(".").map(&:to_i) + fail unless version_array.first >= 2 + is_modern = version_array[0] > 2 || + (version_array[0] == 2 && version_array[1] > 19) || + (version_array[0] == 2 && version_array[1] == 19 && version_array[2] >= 3) || + (version_array[0] == 2 && version_array[1] == 18 && version_array[2] >= 8) || + (version_array[0] == 2 && version_array[1] == 17 && version_array[2] >= 14) || + (version_array[0] == 2 && version_array[1] == 16 && version_array[2] >= 23) + + $stdin.each_line do |line| + if is_modern && line =~ /gist/ + puts line + else + puts File.dirname(line) + end + end + ' $(version $GHE_REMOTE_VERSION) +} From c8345089750c0719310c2965554c75e7b9036116 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 11:59:34 -0800 Subject: [PATCH 0849/2421] Make the tests stricter Assert that 100,000 lines (instead of 10,000 lines) can complete in 2 seconds. --- test/test-ghe-backup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index b27f4684e..90fa3b97b 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -352,7 +352,7 @@ begin_test "ghe-backup backup gist" timeout 2 bash -c " source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; GHE_REMOTE_VERSION=2.16.23; - seq 1 10000 | sed -e 's/$/ gist/' | fix_paths_for_ghe_version | grep -c gist" + seq 1 100000 | sed -e 's/$/ gist/' | fix_paths_for_ghe_version | grep -c gist" ) end_test @@ -363,6 +363,6 @@ begin_test "ghe-backup backup wiki" timeout 2 bash -c " source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; GHE_REMOTE_VERSION=2.16.23; - seq 1 10000 | sed -e 's/$/ wiki/' | fix_paths_for_ghe_version | grep -c '^\.$'" + seq 1 100000 | sed -e 's/$/ wiki/' | fix_paths_for_ghe_version | grep -c '^\.$'" ) -end_test \ No newline at end of file +end_test From 7e2953cda66bb31fc52feff9095f94d0e76c8992 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 12:01:10 -0800 Subject: [PATCH 0850/2421] Make the comments match reality --- test/test-ghe-backup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 90fa3b97b..2326dd165 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -345,7 +345,7 @@ setup_test_data $GHE_REMOTE_DATA_USER_DIR # ) # end_test -# acceptance criteria is less then 2 seconds for 10,000 lines +# acceptance criteria is less then 2 seconds for 100,000 lines begin_test "ghe-backup backup gist" ( set -e @@ -356,7 +356,7 @@ begin_test "ghe-backup backup gist" ) end_test -# acceptance criteria is less then 2 seconds for 10,000 lines +# acceptance criteria is less then 2 seconds for 100,000 lines begin_test "ghe-backup backup wiki" ( set -e From d11d045fb737e5bc669673f0563fbbfc1574d907 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 13:42:41 -0800 Subject: [PATCH 0851/2421] Indent for readability --- test/test-ghe-backup.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 2326dd165..eabb6a497 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -350,9 +350,10 @@ begin_test "ghe-backup backup gist" ( set -e timeout 2 bash -c " - source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; - GHE_REMOTE_VERSION=2.16.23; - seq 1 100000 | sed -e 's/$/ gist/' | fix_paths_for_ghe_version | grep -c gist" + source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; + GHE_REMOTE_VERSION=2.16.23; + seq 1 100000 | sed -e 's/$/ gist/' | fix_paths_for_ghe_version | grep -c gist + " ) end_test @@ -361,8 +362,9 @@ begin_test "ghe-backup backup wiki" ( set -e timeout 2 bash -c " - source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; - GHE_REMOTE_VERSION=2.16.23; - seq 1 100000 | sed -e 's/$/ wiki/' | fix_paths_for_ghe_version | grep -c '^\.$'" + source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; + GHE_REMOTE_VERSION=2.16.23; + seq 1 100000 | sed -e 's/$/ wiki/' | fix_paths_for_ghe_version | grep -c '^\.$' + " ) end_test From 3f6182b07b6abdc20a0f7c38dc74ad544ae2892c Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 13:42:47 -0800 Subject: [PATCH 0852/2421] Fix version-check bug and add a test The inline Ruby wanted versions like 2.3.4, but it was getting int-mapped versions like 2003004000. That broke the logic in the inline Ruby completely, so everything was treated as having a major version wayyyy above 3, hence "modern". This is why we unit-test. --- share/github-backup-utils/ghe-backup-config | 2 +- test/test-ghe-backup.sh | 42 +++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 22553f2c8..47c84a384 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -324,5 +324,5 @@ fix_paths_for_ghe_version() { puts File.dirname(line) end end - ' $(version $GHE_REMOTE_VERSION) + ' "$GHE_REMOTE_VERSION" } diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index eabb6a497..40cb046b5 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -368,3 +368,45 @@ begin_test "ghe-backup backup wiki" " ) end_test + +# check fix_paths_for_ghe_version version thresholds +begin_test "ghe-backup fix_paths_for_ghe_version newer/older" +( + set -e + + # modern versions keep foo/gist as foo/gist + for ver in 2.16.23 2.17.14 2.18.8 2.19.3 2.20.0 3.0.0; do + echo == $ver, not gist + [ "$(bash -c " + source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; + GHE_REMOTE_VERSION=$ver; + echo foo/bar | fix_paths_for_ghe_version + ")" == "foo" ] + + echo == $ver, gist + [ "$(bash -c " + source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; + GHE_REMOTE_VERSION=$ver; + echo foo/gist | fix_paths_for_ghe_version + ")" == "foo/gist" ] + done + + # old versions change foo/gist to foo + for ver in 2.0.0 2.15.123 2.16.22 2.17.13 2.18.7 2.19.2; do + echo == $ver, not gist + [ "$(bash -c " + source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; + GHE_REMOTE_VERSION=$ver; + echo foo/bar | fix_paths_for_ghe_version + ")" == "foo" ] + + echo == $ver, gist + [ "$(bash -c " + source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; + GHE_REMOTE_VERSION=$ver; + echo foo/gist | fix_paths_for_ghe_version + ")" == "foo" ] + done + +) +end_test From c35686f4c7a4a2c3041b34693fc2ac002f50e39e Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 13:42:49 -0800 Subject: [PATCH 0853/2421] Uncomment all the tests --- test/test-ghe-backup.sh | 580 ++++++++++++++++++++-------------------- 1 file changed, 290 insertions(+), 290 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 40cb046b5..c35c7c15f 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -10,340 +10,340 @@ mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" setup_test_data $GHE_REMOTE_DATA_USER_DIR -# begin_test "ghe-backup first snapshot" -# ( -# set -e +begin_test "ghe-backup first snapshot" +( + set -e + + # check that no current symlink exists yet + [ ! -d "$GHE_DATA_DIR/current" ] + + # run it + ghe-backup -v + + verify_all_backedup_data +) +end_test + +begin_test "ghe-backup subsequent snapshot" +( + set -e + + # wait a second for snapshot timestamp + sleep 1 + + # check that no current symlink exists yet + [ -d "$GHE_DATA_DIR/current" ] + + # grab the first snapshot number so we can compare after + first_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') + + # run it + ghe-backup + + # check that current symlink points to new snapshot + this_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') + [ "$first_snapshot" != "$this_snapshot" ] + + verify_all_backedup_data +) +end_test + +begin_test "ghe-backup logs the benchmark" +( + set -e + + # wait a second for snapshot timestamp + sleep 1 + + export BM_TIMESTAMP=foo + + ghe-backup + + [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] +) +end_test + +begin_test "ghe-backup with relative data dir path" +( + set -e + + # wait a second for snapshot timestamp + sleep 1 + + # generate a timestamp + GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" + export GHE_SNAPSHOT_TIMESTAMP + + # change working directory to the root directory + cd $ROOTDIR + + # run it + GHE_DATA_DIR=$(echo $GHE_DATA_DIR | sed 's|'$ROOTDIR'/||') ghe-backup + + # check that current symlink points to new snapshot + [ "$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.*-> //')" = "$GHE_SNAPSHOT_TIMESTAMP" ] + + verify_all_backedup_data +) +end_test + +begin_test "ghe-backup fails fast when old style run in progress" +( + set -e + + ln -s 1 "$GHE_DATA_DIR/in-progress" + ! ghe-backup + + unlink "$GHE_DATA_DIR/in-progress" +) +end_test + +begin_test "ghe-backup cleans up stale in-progress file" +( + set -e + + echo "20150928T153353 99999" > "$GHE_DATA_DIR/in-progress" + ghe-backup + + [ ! -f "$GHE_DATA_DIR/in-progress" ] +) +end_test + +begin_test "ghe-backup without management console password" +( + set -e -# # check that no current symlink exists yet -# [ ! -d "$GHE_DATA_DIR/current" ] + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "" + ghe-backup -# # run it -# ghe-backup -v + [ ! -f "$GHE_DATA_DIR/current/manage-password" ] +) +end_test -# verify_all_backedup_data -# ) -# end_test +begin_test "ghe-backup empty hookshot directory" +( + set -e -# begin_test "ghe-backup subsequent snapshot" -# ( -# set -e + rm -rf $GHE_REMOTE_DATA_USER_DIR/hookshot/repository-* + rm -rf $GHE_DATA_DIR/current/hookshot/repository-* + ghe-backup -# # wait a second for snapshot timestamp -# sleep 1 + # Check that the "--link-dest arg does not exist" message hasn't occurred. + [ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ] +) +end_test -# # check that no current symlink exists yet -# [ -d "$GHE_DATA_DIR/current" ] +begin_test "ghe-backup empty git-hooks directory" +( + set -e -# # grab the first snapshot number so we can compare after -# first_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') + rm -rf $GHE_REMOTE_DATA_USER_DIR/git-hooks/* + rm -rf $GHE_DATA_DIR/current/git-hooks/* + ghe-backup -# # run it -# ghe-backup + # Check that the "--link-dest arg does not exist" message hasn't occurred. + [ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ] +) +end_test -# # check that current symlink points to new snapshot -# this_snapshot=$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.* -> //') -# [ "$first_snapshot" != "$this_snapshot" ] +begin_test "ghe-backup fsck" +( + set -e -# verify_all_backedup_data -# ) -# end_test + export GHE_BACKUP_FSCK=yes + ghe-backup | grep -q "Repos verified: 6, Errors: 1, Took:" + # Verbose mode disabled by default + ! ghe-backup | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + ghe-backup -v | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" -# begin_test "ghe-backup logs the benchmark" -# ( -# set -e + export GHE_BACKUP_FSCK=no + ! ghe-backup | grep -q "Repos verified:" +) +end_test -# # wait a second for snapshot timestamp -# sleep 1 +begin_test "ghe-backup stores version when not run from a clone" +( + set -e -# export BM_TIMESTAMP=foo + # Make sure this doesn't exist + rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" -# ghe-backup + tmpdir=$(mktemp -d "$TRASHDIR/foo.XXXXXX") -# [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] -# ) -# end_test + # If user is running the tests extracted from a release tarball, git clone will fail. + if GIT_DIR="$ROOTDIR/.git" git rev-parse --is-inside-work-tree > /dev/null 2>&1; then + git clone "$ROOTDIR" "$tmpdir/backup-utils" + cd "$tmpdir/backup-utils" + rm -rf .git + ./bin/ghe-backup -# begin_test "ghe-backup with relative data dir path" -# ( -# set -e + # Verify that ghe-backup wrote its version information to the host + [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] + else + echo ".git directory not found, skipping ghe-backup not from a clone test" + fi +) +end_test -# # wait a second for snapshot timestamp -# sleep 1 +begin_test "ghe-backup with leaked SSH host key detection for current backup" +( + set -e -# # generate a timestamp -# GHE_SNAPSHOT_TIMESTAMP="relative-$(date +"%Y%m%dT%H%M%S")" -# export GHE_SNAPSHOT_TIMESTAMP + # Rename ghe-export-ssh-keys to generate a fake ssh + cd "$ROOTDIR/test/bin" + mv "ghe-export-ssh-host-keys" "ghe-export-ssh-host-keys.orig" + ln -s ghe-gen-fake-ssh-tar ghe-export-ssh-host-keys + cd - -# # change working directory to the root directory -# cd $ROOTDIR + # Inject the fingerprint into the blacklist + export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" -# # run it -# GHE_DATA_DIR=$(echo $GHE_DATA_DIR | sed 's|'$ROOTDIR'/||') ghe-backup + # Run it + output=$(ghe-backup -v) -# # check that current symlink points to new snapshot -# [ "$(ls -ld "$GHE_DATA_DIR/current" | sed 's/.*-> //')" = "$GHE_SNAPSHOT_TIMESTAMP" ] + # Set the export ssh back + mv "$ROOTDIR/test/bin/ghe-export-ssh-host-keys.orig" "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" -# verify_all_backedup_data -# ) -# end_test + # Test the output for leaked key detection + echo $output| grep "The current backup contains leaked SSH host keys" -# begin_test "ghe-backup fails fast when old style run in progress" -# ( -# set -e +) +end_test -# ln -s 1 "$GHE_DATA_DIR/in-progress" -# ! ghe-backup +begin_test "ghe-backup with no leaked keys" +( + set -e -# unlink "$GHE_DATA_DIR/in-progress" -# ) -# end_test + # Make sure there are no leaked key messages + ! ghe-backup -v | grep "Leaked key" -# begin_test "ghe-backup cleans up stale in-progress file" -# ( -# set -e +) +end_test -# echo "20150928T153353 99999" > "$GHE_DATA_DIR/in-progress" -# ghe-backup +begin_test "ghe-backup honours --version flag" +( + set -e -# [ ! -f "$GHE_DATA_DIR/in-progress" ] -# ) -# end_test + # Make sure a partial version string is returned + ghe-backup --version | grep "GitHub backup-utils v" -# begin_test "ghe-backup without management console password" -# ( -# set -e +) +end_test -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "" -# ghe-backup +begin_test "ghe-backup honours --help and -h flags" +( + set -e -# [ ! -f "$GHE_DATA_DIR/current/manage-password" ] -# ) -# end_test + arg_help=$(ghe-backup --help | grep -o 'Usage: ghe-backup') + arg_h=$(ghe-backup -h | grep -o 'Usage: ghe-backup') -# begin_test "ghe-backup empty hookshot directory" -# ( -# set -e + # Make sure a Usage: string is returned and that it's the same for -h and --help + [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-backup" -# rm -rf $GHE_REMOTE_DATA_USER_DIR/hookshot/repository-* -# rm -rf $GHE_DATA_DIR/current/hookshot/repository-* -# ghe-backup +) +end_test -# # Check that the "--link-dest arg does not exist" message hasn't occurred. -# [ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ] -# ) -# end_test +begin_test "ghe-backup exits early on unsupported version" +( + set -e + ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-backup -v +) +end_test -# begin_test "ghe-backup empty git-hooks directory" -# ( -# set -e +begin_test "ghe-backup-strategy returns rsync for HA backup" +( + set -e + touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + output="$(ghe-backup-strategy)" + rm "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + [ "$output" = "rsync" ] +) +end_test -# rm -rf $GHE_REMOTE_DATA_USER_DIR/git-hooks/* -# rm -rf $GHE_DATA_DIR/current/git-hooks/* -# ghe-backup +# Reset data for sub-subsequent tests +rm -rf $GHE_REMOTE_DATA_USER_DIR +setup_test_data $GHE_REMOTE_DATA_USER_DIR -# # Check that the "--link-dest arg does not exist" message hasn't occurred. -# [ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ] -# ) -# end_test +begin_test "ghe-backup cluster" +( + set -e + setup_remote_cluster + + if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then + cat "$TRASHDIR/backup-out" + : ghe-restore should have exited successfully + false + fi + + cat "$TRASHDIR/backup-out" + + # verify data was copied from multiple nodes + # repositories + grep -q "repositories from git-server-fake-uuid" "$TRASHDIR/backup-out" + grep -q "repositories from git-server-fake-uuid1" "$TRASHDIR/backup-out" + grep -q "repositories from git-server-fake-uuid2" "$TRASHDIR/backup-out" + + # storage + grep -q "objects from storage-server-fake-uuid" "$TRASHDIR/backup-out" + grep -q "objects from storage-server-fake-uuid1" "$TRASHDIR/backup-out" + grep -q "objects from storage-server-fake-uuid2" "$TRASHDIR/backup-out" + + # pages + grep -q "Starting backup for host: pages-server-fake-uuid" "$TRASHDIR/backup-out" + grep -q "Starting backup for host: pages-server-fake-uuid1" "$TRASHDIR/backup-out" + grep -q "Starting backup for host: pages-server-fake-uuid2" "$TRASHDIR/backup-out" + + # verify cluster.conf backed up + [ -f "$GHE_DATA_DIR/current/cluster.conf" ] + grep -q "fake cluster config" "$GHE_DATA_DIR/current/cluster.conf" + + verify_all_backedup_data +) +end_test -# begin_test "ghe-backup fsck" -# ( -# set -e +begin_test "ghe-backup not missing directories or files on source appliance" +( + # Tests the scenario where the database and on disk state are consistent. + set -e -# export GHE_BACKUP_FSCK=yes -# ghe-backup | grep -q "Repos verified: 6, Errors: 1, Took:" -# # Verbose mode disabled by default -# ! ghe-backup | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" -# ghe-backup -v | grep -q "missing tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904" + if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then + cat "$TRASHDIR/backup-out" + : ghe-backup should have completed successfully + false + fi -# export GHE_BACKUP_FSCK=no -# ! ghe-backup | grep -q "Repos verified:" -# ) -# end_test + # Ensure the output doesn't contain the warnings + grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 + grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 -# begin_test "ghe-backup stores version when not run from a clone" -# ( -# set -e + verify_all_backedup_data +) +end_test -# # Make sure this doesn't exist -# rm -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" - -# tmpdir=$(mktemp -d "$TRASHDIR/foo.XXXXXX") +begin_test "ghe-backup missing directories or files on source appliance" +( + # Tests the scenario where something exists in the database, but not on disk. + set -e + + rm -rf $GHE_REMOTE_DATA_USER_DIR/repositories/1 + rm -rf $GHE_REMOTE_DATA_USER_DIR/storage/e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244 + + if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then + cat "$TRASHDIR/backup-out" + : ghe-backup should have completed successfully + false + fi -# # If user is running the tests extracted from a release tarball, git clone will fail. -# if GIT_DIR="$ROOTDIR/.git" git rev-parse --is-inside-work-tree > /dev/null 2>&1; then -# git clone "$ROOTDIR" "$tmpdir/backup-utils" -# cd "$tmpdir/backup-utils" -# rm -rf .git -# ./bin/ghe-backup + # Check the output for the warnings + grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" + grep -q "\-1/23/bb/4c/gist" "$TRASHDIR/backup-out" + grep -q "\-1/nw/23/bb/4c/2345" "$TRASHDIR/backup-out" + grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" + grep -q "\-e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" "$TRASHDIR/backup-out" -# # Verify that ghe-backup wrote its version information to the host -# [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] -# else -# echo ".git directory not found, skipping ghe-backup not from a clone test" -# fi -# ) -# end_test - -# begin_test "ghe-backup with leaked SSH host key detection for current backup" -# ( -# set -e - -# # Rename ghe-export-ssh-keys to generate a fake ssh -# cd "$ROOTDIR/test/bin" -# mv "ghe-export-ssh-host-keys" "ghe-export-ssh-host-keys.orig" -# ln -s ghe-gen-fake-ssh-tar ghe-export-ssh-host-keys -# cd - - -# # Inject the fingerprint into the blacklist -# export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" - -# # Run it -# output=$(ghe-backup -v) - -# # Set the export ssh back -# mv "$ROOTDIR/test/bin/ghe-export-ssh-host-keys.orig" "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" - -# # Test the output for leaked key detection -# echo $output| grep "The current backup contains leaked SSH host keys" - -# ) -# end_test - -# begin_test "ghe-backup with no leaked keys" -# ( -# set -e - -# # Make sure there are no leaked key messages -# ! ghe-backup -v | grep "Leaked key" - -# ) -# end_test - -# begin_test "ghe-backup honours --version flag" -# ( -# set -e - -# # Make sure a partial version string is returned -# ghe-backup --version | grep "GitHub backup-utils v" - -# ) -# end_test - -# begin_test "ghe-backup honours --help and -h flags" -# ( -# set -e - -# arg_help=$(ghe-backup --help | grep -o 'Usage: ghe-backup') -# arg_h=$(ghe-backup -h | grep -o 'Usage: ghe-backup') - -# # Make sure a Usage: string is returned and that it's the same for -h and --help -# [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-backup" - -# ) -# end_test - -# begin_test "ghe-backup exits early on unsupported version" -# ( -# set -e -# ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-backup -v -# ) -# end_test - -# begin_test "ghe-backup-strategy returns rsync for HA backup" -# ( -# set -e -# touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" -# output="$(ghe-backup-strategy)" -# rm "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" -# [ "$output" = "rsync" ] -# ) -# end_test - -# # Reset data for sub-subsequent tests -# rm -rf $GHE_REMOTE_DATA_USER_DIR -# setup_test_data $GHE_REMOTE_DATA_USER_DIR - -# begin_test "ghe-backup cluster" -# ( -# set -e -# setup_remote_cluster - -# if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then -# cat "$TRASHDIR/backup-out" -# : ghe-restore should have exited successfully -# false -# fi - -# cat "$TRASHDIR/backup-out" - -# # verify data was copied from multiple nodes -# # repositories -# grep -q "repositories from git-server-fake-uuid" "$TRASHDIR/backup-out" -# grep -q "repositories from git-server-fake-uuid1" "$TRASHDIR/backup-out" -# grep -q "repositories from git-server-fake-uuid2" "$TRASHDIR/backup-out" - -# # storage -# grep -q "objects from storage-server-fake-uuid" "$TRASHDIR/backup-out" -# grep -q "objects from storage-server-fake-uuid1" "$TRASHDIR/backup-out" -# grep -q "objects from storage-server-fake-uuid2" "$TRASHDIR/backup-out" - -# # pages -# grep -q "Starting backup for host: pages-server-fake-uuid" "$TRASHDIR/backup-out" -# grep -q "Starting backup for host: pages-server-fake-uuid1" "$TRASHDIR/backup-out" -# grep -q "Starting backup for host: pages-server-fake-uuid2" "$TRASHDIR/backup-out" - -# # verify cluster.conf backed up -# [ -f "$GHE_DATA_DIR/current/cluster.conf" ] -# grep -q "fake cluster config" "$GHE_DATA_DIR/current/cluster.conf" - -# verify_all_backedup_data -# ) -# end_test - -# begin_test "ghe-backup not missing directories or files on source appliance" -# ( -# # Tests the scenario where the database and on disk state are consistent. -# set -e - -# if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then -# cat "$TRASHDIR/backup-out" -# : ghe-backup should have completed successfully -# false -# fi - -# # Ensure the output doesn't contain the warnings -# grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 -# grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" && exit 1 - -# verify_all_backedup_data -# ) -# end_test - -# begin_test "ghe-backup missing directories or files on source appliance" -# ( -# # Tests the scenario where something exists in the database, but not on disk. -# set -e - -# rm -rf $GHE_REMOTE_DATA_USER_DIR/repositories/1 -# rm -rf $GHE_REMOTE_DATA_USER_DIR/storage/e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244 - -# if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then -# cat "$TRASHDIR/backup-out" -# : ghe-backup should have completed successfully -# false -# fi - -# # Check the output for the warnings -# grep -q "Warning: One or more repository networks and/or gists were not found on the source appliance." "$TRASHDIR/backup-out" -# grep -q "\-1/23/bb/4c/gist" "$TRASHDIR/backup-out" -# grep -q "\-1/nw/23/bb/4c/2345" "$TRASHDIR/backup-out" -# grep -q "Warning: One or more storage objects were not found on the source appliance." "$TRASHDIR/backup-out" -# grep -q "\-e/ed/1a/ed1aa60f0706cefde8ba2b3be662d3a0e0e1fbc94a52a3201944684cc0c5f244" "$TRASHDIR/backup-out" - -# verify_all_backedup_data -# ) -# end_test + verify_all_backedup_data +) +end_test # acceptance criteria is less then 2 seconds for 100,000 lines begin_test "ghe-backup backup gist" From cbbd447709d9c73be4088ec26f647fbba2aafe9f Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 13:51:50 -0800 Subject: [PATCH 0854/2421] Remove \ and ; for readability --- test/test-ghe-backup.sh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index c35c7c15f..fd10a864c 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -346,24 +346,24 @@ begin_test "ghe-backup missing directories or files on source appliance" end_test # acceptance criteria is less then 2 seconds for 100,000 lines -begin_test "ghe-backup backup gist" +begin_test "ghe-backup fix_paths_for_ghe_version performance tests - gists" ( set -e timeout 2 bash -c " - source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; - GHE_REMOTE_VERSION=2.16.23; + source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' + GHE_REMOTE_VERSION=2.16.23 seq 1 100000 | sed -e 's/$/ gist/' | fix_paths_for_ghe_version | grep -c gist " ) end_test # acceptance criteria is less then 2 seconds for 100,000 lines -begin_test "ghe-backup backup wiki" +begin_test "ghe-backup fix_paths_for_ghe_version performance tests - wikis" ( set -e timeout 2 bash -c " - source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; - GHE_REMOTE_VERSION=2.16.23; + source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' + GHE_REMOTE_VERSION=2.16.23 seq 1 100000 | sed -e 's/$/ wiki/' | fix_paths_for_ghe_version | grep -c '^\.$' " ) @@ -378,15 +378,15 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" for ver in 2.16.23 2.17.14 2.18.8 2.19.3 2.20.0 3.0.0; do echo == $ver, not gist [ "$(bash -c " - source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; - GHE_REMOTE_VERSION=$ver; + source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' + GHE_REMOTE_VERSION=$ver echo foo/bar | fix_paths_for_ghe_version ")" == "foo" ] echo == $ver, gist [ "$(bash -c " - source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; - GHE_REMOTE_VERSION=$ver; + source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' + GHE_REMOTE_VERSION=$ver echo foo/gist | fix_paths_for_ghe_version ")" == "foo/gist" ] done @@ -395,15 +395,15 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" for ver in 2.0.0 2.15.123 2.16.22 2.17.13 2.18.7 2.19.2; do echo == $ver, not gist [ "$(bash -c " - source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; - GHE_REMOTE_VERSION=$ver; + source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' + GHE_REMOTE_VERSION=$ver echo foo/bar | fix_paths_for_ghe_version ")" == "foo" ] echo == $ver, gist [ "$(bash -c " - source \"$TESTS_DIR\"/../share/github-backup-utils/ghe-backup-config; - GHE_REMOTE_VERSION=$ver; + source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' + GHE_REMOTE_VERSION=$ver echo foo/gist | fix_paths_for_ghe_version ")" == "foo" ] done From 25c929dfd77e286b9c06006f4917f8ff5fbb5cb8 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 14:01:44 -0800 Subject: [PATCH 0855/2421] Allow space in $ver --- test/test-ghe-backup.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index fd10a864c..9e16f56ac 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -379,14 +379,14 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" echo == $ver, not gist [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION=$ver + GHE_REMOTE_VERSION="$ver" echo foo/bar | fix_paths_for_ghe_version ")" == "foo" ] echo == $ver, gist [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION=$ver + GHE_REMOTE_VERSION="$ver" echo foo/gist | fix_paths_for_ghe_version ")" == "foo/gist" ] done @@ -396,14 +396,14 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" echo == $ver, not gist [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION=$ver + GHE_REMOTE_VERSION="$ver" echo foo/bar | fix_paths_for_ghe_version ")" == "foo" ] echo == $ver, gist [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION=$ver + GHE_REMOTE_VERSION="$ver" echo foo/gist | fix_paths_for_ghe_version ")" == "foo" ] done From c6757ecfc70fff42654f4cb773a697aae2ddd126 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 14:02:31 -0800 Subject: [PATCH 0856/2421] Test quick-fail path for invalid version strings --- test/test-ghe-backup.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 9e16f56ac..a4eb475f9 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -408,5 +408,14 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" ")" == "foo" ] done + # garbage versions make fix_paths_for_ghe_version fail + for ver in 1.0.0 bob "a b c" "-" "." ""; do + echo == $ver, should fail + bash -c " + source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' + GHE_REMOTE_VERSION="$ver" + ! echo foo/bar | fix_paths_for_ghe_version + " + done ) end_test From 109a6b97b85fb9be1ff2c544eeddf034b26f011d Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 14:05:24 -0800 Subject: [PATCH 0857/2421] Copy comment from the original parse_paths --- share/github-backup-utils/ghe-backup-config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 47c84a384..c200adee7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -305,6 +305,8 @@ version() { echo "${@#v}" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } +# The list of gists returned by the source changed in 2.16.23, 2.17.14, +# 2.18.8, and 2.19.3. So we need to account for this difference here. fix_paths_for_ghe_version() { ruby -e ' ghe_remote_version = ARGV.first From 74113331d2a47b613f7a5861307244698e6dff2c Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 30 Jan 2020 14:32:36 -0800 Subject: [PATCH 0858/2421] install coreutils for tests --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index e8b540837..cdb3b944f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq + - brew install coreutils script: make test - os: linux dist: trusty @@ -24,4 +25,5 @@ matrix: - moreutils - fakeroot - jq + - coreutils script: debuild -uc -us From f1bb5affd16ba1c7d605d992742477d40adbbca4 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 30 Jan 2020 14:40:38 -0800 Subject: [PATCH 0859/2421] switch back to relative import for testlib in tests --- test/test-ghe-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index a4eb475f9..d856f9429 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -3,7 +3,7 @@ TESTS_DIR="$(realpath "$(dirname "$0")")" # Bring in testlib # shellcheck source=test/testlib.sh -. "$TESTS_DIR/testlib.sh" +. "$(dirname "$0")/testlib.sh" # Create the backup data dir and fake remote repositories dirs mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" From 3de44f18f1b25a8f168e37c59047689b52887e63 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 17:40:12 -0500 Subject: [PATCH 0860/2421] Eliminate the need for `realpath` It's not installed on either Mac or Linux CI boxes --- test/test-ghe-backup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index d856f9429..2d2b43fd8 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # ghe-backup command tests -TESTS_DIR="$(realpath "$(dirname "$0")")" + +TESTS_DIR="$PWD/$(dirname "$0")" # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" From f4ecf8708ff5a8177eccb212b07b06b7d744859f Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 17:43:05 -0500 Subject: [PATCH 0861/2421] Provide `timeout` command on Macs --- test/test-ghe-backup.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 2d2b43fd8..fa2d2efe0 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -346,6 +346,12 @@ begin_test "ghe-backup missing directories or files on source appliance" ) end_test +if [ "$(uname)" == "Darwin" ]; then + timeout() { + ruby -rtimeout -e 'duration = ARGV.shift.to_i; Timeout::timeout(duration) { system(*ARGV) }' "$@" + } +fi + # acceptance criteria is less then 2 seconds for 100,000 lines begin_test "ghe-backup fix_paths_for_ghe_version performance tests - gists" ( From c3e960b3773f5579066adf7c32998a8f01f789e7 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 17:44:16 -0500 Subject: [PATCH 0862/2421] Revert "switch back to relative import for testlib in tests" This reverts commit f1bb5affd16ba1c7d605d992742477d40adbbca4. DRY. Not a big deal either way. --- test/test-ghe-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index fa2d2efe0..d908e3b9a 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -4,7 +4,7 @@ TESTS_DIR="$PWD/$(dirname "$0")" # Bring in testlib # shellcheck source=test/testlib.sh -. "$(dirname "$0")/testlib.sh" +. "$TESTS_DIR/testlib.sh" # Create the backup data dir and fake remote repositories dirs mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" From d364260a0ac0e85acc262f03a62e29e3a9e6cd9b Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 17:50:06 -0500 Subject: [PATCH 0863/2421] Make shellcheck's recommended changes --- test/test-ghe-backup.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index d908e3b9a..aff55b952 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -383,44 +383,44 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" # modern versions keep foo/gist as foo/gist for ver in 2.16.23 2.17.14 2.18.8 2.19.3 2.20.0 3.0.0; do - echo == $ver, not gist + echo "## $ver, not gist" [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION="$ver" + GHE_REMOTE_VERSION=$ver echo foo/bar | fix_paths_for_ghe_version ")" == "foo" ] - echo == $ver, gist + echo "## $ver, gist" [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION="$ver" + GHE_REMOTE_VERSION=$ver echo foo/gist | fix_paths_for_ghe_version ")" == "foo/gist" ] done # old versions change foo/gist to foo for ver in 2.0.0 2.15.123 2.16.22 2.17.13 2.18.7 2.19.2; do - echo == $ver, not gist + echo "## $ver, not gist" [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION="$ver" + GHE_REMOTE_VERSION=$ver echo foo/bar | fix_paths_for_ghe_version ")" == "foo" ] - echo == $ver, gist + echo "## $ver, gist" [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION="$ver" + GHE_REMOTE_VERSION=$ver echo foo/gist | fix_paths_for_ghe_version ")" == "foo" ] done # garbage versions make fix_paths_for_ghe_version fail for ver in 1.0.0 bob "a b c" "-" "." ""; do - echo == $ver, should fail + echo "## $ver, should fail" bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION="$ver" + GHE_REMOTE_VERSION=$ver ! echo foo/bar | fix_paths_for_ghe_version " done From 3f64d3e3ba178c46e1c6a8dc0aa51149684a8a66 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 17:50:44 -0500 Subject: [PATCH 0864/2421] Revert "install coreutils for tests" This reverts commit 74113331d2a47b613f7a5861307244698e6dff2c. We don't need coreutils. I used $PWD to eliminate the need for `realpath`, and I've implemented `timeout` for OSX. If the Linux CI is missing `timeout`, I'll push another commit to let it use the OSX implementation. --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index cdb3b944f..e8b540837 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq - - brew install coreutils script: make test - os: linux dist: trusty @@ -25,5 +24,4 @@ matrix: - moreutils - fakeroot - jq - - coreutils script: debuild -uc -us From 66fc0503e7a37307b2020435e7271755c03de87b Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 30 Jan 2020 16:11:43 -0800 Subject: [PATCH 0865/2421] fix getting version number in fix_paths_for_ghe_version --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index c200adee7..9b97dc5b8 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -309,7 +309,7 @@ version() { # 2.18.8, and 2.19.3. So we need to account for this difference here. fix_paths_for_ghe_version() { ruby -e ' - ghe_remote_version = ARGV.first + ghe_remote_version = ARGV.first[1..-1] # removing "v" literal from version string version_array = ghe_remote_version.split(".").map(&:to_i) fail unless version_array.first >= 2 is_modern = version_array[0] > 2 || From 91ebc5bfca4709231ca413264d5b968511f2dc70 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 30 Jan 2020 16:29:33 -0800 Subject: [PATCH 0866/2421] remove "v" from version only if it there --- share/github-backup-utils/ghe-backup-config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 9b97dc5b8..3816f28d0 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -309,7 +309,8 @@ version() { # 2.18.8, and 2.19.3. So we need to account for this difference here. fix_paths_for_ghe_version() { ruby -e ' - ghe_remote_version = ARGV.first[1..-1] # removing "v" literal from version string + version = ARGV.first + ghe_remote_version = version[0] == "v" ? version[1..-1] : version # removing "v" literal from version string version_array = ghe_remote_version.split(".").map(&:to_i) fail unless version_array.first >= 2 is_modern = version_array[0] > 2 || From b3bc65847eb3cac0576aa8b015d7434547cbdd80 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 30 Jan 2020 16:29:59 -0800 Subject: [PATCH 0867/2421] update tests (including "v" and "without-v" formats) --- test/test-ghe-backup.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index aff55b952..5fc42c16d 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -382,7 +382,7 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" set -e # modern versions keep foo/gist as foo/gist - for ver in 2.16.23 2.17.14 2.18.8 2.19.3 2.20.0 3.0.0; do + for ver in 2.16.23 v2.16.23 v2.17.14 v2.18.8 v2.19.3 v2.20.0 v3.0.0; do echo "## $ver, not gist" [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' @@ -399,7 +399,7 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" done # old versions change foo/gist to foo - for ver in 2.0.0 2.15.123 2.16.22 2.17.13 2.18.7 2.19.2; do + for ver in 2.0.0 v2.0.0 v2.15.123 v2.16.22 v2.17.13 v2.18.7 v2.19.2; do echo "## $ver, not gist" [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' From cf2f9c77236a868f973c527ed46d7724ececc065 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 20:00:37 -0500 Subject: [PATCH 0868/2421] Regexes are idiomatic Ruby --- share/github-backup-utils/ghe-backup-config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 3816f28d0..0e2ca8dae 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -309,10 +309,10 @@ version() { # 2.18.8, and 2.19.3. So we need to account for this difference here. fix_paths_for_ghe_version() { ruby -e ' - version = ARGV.first - ghe_remote_version = version[0] == "v" ? version[1..-1] : version # removing "v" literal from version string - version_array = ghe_remote_version.split(".").map(&:to_i) + version = ARGV.first.gsub(/^v/, "") # removing any leading "v" from version string + version_array = version.split(".").map(&:to_i) fail unless version_array.first >= 2 + is_modern = version_array[0] > 2 || (version_array[0] == 2 && version_array[1] > 19) || (version_array[0] == 2 && version_array[1] == 19 && version_array[2] >= 3) || From 521bca6415281d491fb33b573c1acbc68bea76a8 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 20:45:18 -0500 Subject: [PATCH 0869/2421] Use sed instead of Ruby We can't rely on the customer's admin box (which isn't the appliance) having any actual programming languages on it. But we can use sed, and sed is good enough to simulate dirname with a single fork+exec. This commit also fixes future versions: 2.20.x, 3.x, etc. All future versions will be >= 2.19.3, so we just combine the 2.19 check with the future-versions check. --- share/github-backup-utils/ghe-backup-config | 43 +++++++++++---------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 0e2ca8dae..ad5454582 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -306,26 +306,27 @@ version() { } # The list of gists returned by the source changed in 2.16.23, 2.17.14, -# 2.18.8, and 2.19.3. So we need to account for this difference here. +# 2.18.8, and 2.19.3. We need to account for this difference here. +# In older versions, all paths need to be truncated with `dirname`. +# In newer versions, gist paths are unmodified, and only other repo types +# are truncated with `dirname`. fix_paths_for_ghe_version() { - ruby -e ' - version = ARGV.first.gsub(/^v/, "") # removing any leading "v" from version string - version_array = version.split(".").map(&:to_i) - fail unless version_array.first >= 2 - - is_modern = version_array[0] > 2 || - (version_array[0] == 2 && version_array[1] > 19) || - (version_array[0] == 2 && version_array[1] == 19 && version_array[2] >= 3) || - (version_array[0] == 2 && version_array[1] == 18 && version_array[2] >= 8) || - (version_array[0] == 2 && version_array[1] == 17 && version_array[2] >= 14) || - (version_array[0] == 2 && version_array[1] == 16 && version_array[2] >= 23) - - $stdin.each_line do |line| - if is_modern && line =~ /gist/ - puts line - else - puts File.dirname(line) - end - end - ' "$GHE_REMOTE_VERSION" + if [[ "$GHE_REMOTE_VERSION" =~ 2.16. && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.16.23)" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.17. && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.17.14)" ]] || \ + [[ "$GHE_REMOTE_VERSION" =~ 2.18. && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.18.8)" ]] || \ + [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.19.3)" ]]; then + GIST_FILTER="-e /gist/b" + else + unset GIST_FILTER + fi + + # This sed expression is equivalent to running `dirname` on each line, + # but without all the fork+exec overhead of calling `dirname` that many + # times: + # 1. strip off trailing slashes + # 2. if the result has no slashes in it, the dirname is "." + # 3. truncate from the final slash (if any) to the end + # If the GIST_FILTER was set above (because we're on a modern version of + # GHES), then don't modify lines with "gist" in them. + sed $GIST_FILTER -e 's/\/$//; s/^[^\/]*$/./; s/\/[^\/]*$//' } From 01cda66afaad2b1036af06413407919770d65105 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 20:47:42 -0500 Subject: [PATCH 0870/2421] Combine "fail" with "old" tests The shell `version` function treats garbage as equivalent to 0.0.0, rather than throwing exceptions and exiting with an error code, as the Ruby implementation did. So roll the invalid-input tests into the use-the-old-version test. --- test/test-ghe-backup.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 5fc42c16d..b892aba31 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -399,7 +399,7 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" done # old versions change foo/gist to foo - for ver in 2.0.0 v2.0.0 v2.15.123 v2.16.22 v2.17.13 v2.18.7 v2.19.2; do + for ver in 1.0.0 bob a.b.c "" 1.2.16 2.0.0 v2.0.0 v2.15.123 v2.16.22 v2.17.13 v2.18.7 v2.19.2; do echo "## $ver, not gist" [ "$(bash -c " source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' @@ -414,15 +414,5 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" echo foo/gist | fix_paths_for_ghe_version ")" == "foo" ] done - - # garbage versions make fix_paths_for_ghe_version fail - for ver in 1.0.0 bob "a b c" "-" "." ""; do - echo "## $ver, should fail" - bash -c " - source '$TESTS_DIR/../share/github-backup-utils/ghe-backup-config' - GHE_REMOTE_VERSION=$ver - ! echo foo/bar | fix_paths_for_ghe_version - " - done ) end_test From 239e9927eed400389747c6196d504134405e595b Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Thu, 30 Jan 2020 22:38:44 -0500 Subject: [PATCH 0871/2421] Run `uniq | sort | uniq` The data we're sorting has clusters of duplicates in the input, because `dirname` reduces all repos in the same network (i.e., forks) to the same network path. Running `uniq` before `sort` eliminates those duplicates, which means `sort` requires less CPU and RAM to do its thing. We still need `uniq` on the output end, because there's no guarantee that all duplicates in the input are clustered. I've run tests, and the cost of `uniq` is small enough that it does no harm if the input has no duplicates at all. --- share/github-backup-utils/ghe-backup-repositories | 4 ++-- share/github-backup-utils/ghe-backup-storage | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 5e51f4869..bc9a55e99 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -366,8 +366,8 @@ bm_end "$(basename $0) - Special Data Directories Sync" if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then bm_start "$(basename $0) - Verifying Routes" - cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes - (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | fix_paths_for_ghe_version | sort | uniq) > $tempdir/destination_routes + cat $tempdir/*.rsync | uniq | sort | uniq > $tempdir/source_routes + (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | fix_paths_for_ghe_version | uniq | sort | uniq) > $tempdir/destination_routes git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 334284eba..180ba8d36 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -141,8 +141,8 @@ bm_end "$(basename $0) - Storage object sync" if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then bm_start "$(basename $0) - Verifying Routes" - cat $tempdir/*.rsync | sort | uniq > $tempdir/source_routes - (cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | sort | uniq) > $tempdir/destination_routes + cat $tempdir/*.rsync | uniq | sort | uniq > $tempdir/source_routes + (cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | uniq | sort | uniq) > $tempdir/destination_routes git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." From b023bcdc5992d904ae363d339f1ac13f5306ce7f Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 30 Jan 2020 14:32:36 -0800 Subject: [PATCH 0872/2421] install coreutils for tests --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index e8b540837..cdb3b944f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq + - brew install coreutils script: make test - os: linux dist: trusty @@ -24,4 +25,5 @@ matrix: - moreutils - fakeroot - jq + - coreutils script: debuild -uc -us From 5206c134b100a64705536ae6d6f8e6767da9f6ec Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Fri, 31 Jan 2020 12:59:50 -0500 Subject: [PATCH 0873/2421] Remove Ruby-based implementation of `timeout` We brought back coreutils, which provides it. --- test/test-ghe-backup.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index b892aba31..e0d01cf92 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -346,12 +346,6 @@ begin_test "ghe-backup missing directories or files on source appliance" ) end_test -if [ "$(uname)" == "Darwin" ]; then - timeout() { - ruby -rtimeout -e 'duration = ARGV.shift.to_i; Timeout::timeout(duration) { system(*ARGV) }' "$@" - } -fi - # acceptance criteria is less then 2 seconds for 100,000 lines begin_test "ghe-backup fix_paths_for_ghe_version performance tests - gists" ( From 4df05f5eb9ee268ac0c35c269660d9f5ee9bdc72 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Fri, 31 Jan 2020 10:48:30 -0800 Subject: [PATCH 0874/2421] Allow specifying GH_BASE_BRANCH for release script --- script/release | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/script/release b/script/release index d5bb57776..bee1bcb85 100755 --- a/script/release +++ b/script/release @@ -31,6 +31,7 @@ GH_REPO = ENV['GH_REPO'] || 'backup-utils' GH_OWNER = ENV['GH_OWNER'] || 'github' GH_AUTHOR = ENV['GH_AUTHOR'] DEB_PKG_NAME = 'github-backup-utils' +GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master' CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium @@ -136,7 +137,7 @@ def beautify_changes(changes) end def changelog - changes = `git log --pretty=oneline origin/stable...origin/master --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) + changes = `git log --pretty=oneline origin/stable...origin/#{GH_BASE_BRANCH} --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) raise 'Building the changelog failed' if $CHILD_STATUS != 0 changes @@ -232,8 +233,8 @@ end def update_stable_branch `git checkout --quiet stable` - unless (out = `git merge --quiet --ff-only origin/master`) - warn "Merging master into stable failed:\n\n#{out}" + unless (out = `git merge --quiet --ff-only origin/#{GH_BASE_BRANCH}`) + warn "Merging #{GH_BASE_BRANCH} into stable failed:\n\n#{out}" end unless (out = `git push --quiet origin stable`) warn "Failed pushing the stable branch:\n\n#{out}" @@ -245,7 +246,7 @@ def create_release_pr(version, release_body) 'title': "Bump version: #{version}", 'body': release_body, 'head': "release-#{version}", - 'base': 'master' + 'base': GH_BASE_BRANCH }.to_json res = post("/repos/#{GH_OWNER}/#{GH_REPO}/pulls", body) raise "Creating release PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess @@ -328,9 +329,9 @@ def attach_assets_to_release(upload_url, release_id, files) end def clean_up(version) - `git checkout --quiet master` + `git checkout --quiet #{GH_BASE_BRANCH}` `git fetch --quiet origin --prune` - `git pull --quiet origin master --prune` + `git pull --quiet origin #{GH_BASE_BRANCH} --prune` `git branch --quiet -D release-#{version} >/dev/null 2>&1` `git push --quiet origin :release-#{version} >/dev/null 2>&1` `git branch --quiet -D tmp-packging >/dev/null 2>&1` @@ -382,6 +383,7 @@ if $PROGRAM_NAME == __FILE__ puts "Repo: #{GH_REPO}" puts "Author: #{GH_AUTHOR}" puts "Token: #{ENV['GH_RELEASE_TOKEN'] && 'set' || 'unset'}" + puts "Base branch: #{GH_BASE_BRANCH}" puts 'Changelog:' if release_changes.empty? puts ' => No new bug fixes, enhancements or features.' @@ -429,7 +431,7 @@ if $PROGRAM_NAME == __FILE__ puts 'Creating release...' release_title = "GitHub Enterprise Server Backup Utilities v#{version}" - res = create_release "v#{version}", 'master', release_title, release_body, true + res = create_release "v#{version}", GH_BASE_BRANCH, release_title, release_body, true # Tidy up before building tarball and deb pkg clean_up version From efb9fe73029f53273e35a7d0bf48bd6c71e190fd Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Fri, 31 Jan 2020 11:13:46 -0800 Subject: [PATCH 0875/2421] Bump version: 2.19.2 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 0fc1811f0..86d72a6ee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.19.2) UNRELEASED; urgency=medium + + * Fix `ghe-backup-repositories` performance for large instances #541 + + -- Evgenii Khramkov Fri, 31 Jan 2020 19:13:46 +0000 + github-backup-utils (2.19.1) UNRELEASED; urgency=medium * Cater for more explicit gist paths used in routes file #524 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index b8e248f40..17bdb70fa 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.19.1 +2.19.2 From bfcd0d7a601ffe8b1dae3e9b681d82b615a3c84c Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 3 Feb 2020 15:34:56 -0800 Subject: [PATCH 0876/2421] Add ghe- prefix to script --- share/github-backup-utils/ghe-backup-repositories-gitbackups | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories-gitbackups b/share/github-backup-utils/ghe-backup-repositories-gitbackups index 35c9c6472..4d8667cdc 100755 --- a/share/github-backup-utils/ghe-backup-repositories-gitbackups +++ b/share/github-backup-utils/ghe-backup-repositories-gitbackups @@ -1,6 +1,6 @@ #!/usr/bin/env bash #/ Usage: ghe-backup-repositories-gitbackups -#/ Take an online, incremental snapshot of all Git repository data using gitbackups. +#/ Take an online, incremental snapshot of all Git repository, wiki, and gist data using gitbackups. #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. @@ -12,6 +12,6 @@ set -e bm_start "$(basename $0)" -echo "github-env ./bin/backup-repositories" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "github-env ./bin/ghe-backup-repositories" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash bm_end "$(basename $0)" From a9c2acb579d6109e606c25ed3a94e58dd19416ad Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 3 Feb 2020 15:40:03 -0800 Subject: [PATCH 0877/2421] Update test for script existence --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index f67b4dc71..05dca06cc 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -88,7 +88,7 @@ should_use_gitbackups_for_repositories(){ # check that the appliance supports using gitbackups for repositories can_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" test -e /data/github/current/bin/backup-repositories + ghe-ssh "$GHE_HOSTNAME" test -e /data/github/current/bin/ghe-backup-repositories } # Exit early if the appliance is missing script to backup repositories using gitbackups From 317957204c80b73b9f4d6e6f9a3b20faf889c7e6 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 5 Feb 2020 12:53:25 -0800 Subject: [PATCH 0878/2421] Use pigz instead of gzip in backup-util --- bin/ghe-backup | 2 +- share/github-backup-utils/ghe-restore-mysql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index f67b4dc71..822301096 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -200,7 +200,7 @@ is_binary_backup(){ echo "Backing up MySQL database ..." bm_start "ghe-export-mysql" -echo 'set -o pipefail; ghe-export-mysql | gzip' | +echo 'set -o pipefail; ghe-export-mysql | pigz' | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql" if is_binary_backup; then touch mysql-binary-backup-sentinel diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 4c8cec9e4..7db8c6d05 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -67,6 +67,6 @@ ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "gunzip -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | unpigz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 bm_end "$(basename $0)" From a6e6d7d61b1a5c59dcf2caa05098e85b0d5f231c Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 6 Feb 2020 08:30:52 -0800 Subject: [PATCH 0879/2421] Use unpigz -cd option --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 7db8c6d05..8336ea61c 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -67,6 +67,6 @@ ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | unpigz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 +unpigz -cd "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 16465cdf82e62aeeb9b389befb2e5c44aac17561 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 6 Feb 2020 10:18:02 -0800 Subject: [PATCH 0880/2421] Fix issue with last commit --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 8336ea61c..3cefb77ff 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -67,6 +67,6 @@ ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -unpigz -cd "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 +echo "unpigz -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 05a63423e3bf2525fa2c503faf230302fd7099e1 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 6 Feb 2020 13:07:28 -0800 Subject: [PATCH 0881/2421] Not to compress for binary backup --- bin/ghe-backup | 9 +++++++-- share/github-backup-utils/ghe-restore-mysql | 14 ++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 822301096..abcb9b5d1 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -200,10 +200,15 @@ is_binary_backup(){ echo "Backing up MySQL database ..." bm_start "ghe-export-mysql" -echo 'set -o pipefail; ghe-export-mysql | pigz' | +export_command="ghe-export-mysql" +if ! is_binary_backup; then + # binary backup is already compressed + export_command+=" | pigz" +fi +echo "set -o pipefail; ${export_command}" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql" if is_binary_backup; then - touch mysql-binary-backup-sentinel + echo "NO_ADDITIONAL_COMPRESSION" > mysql-binary-backup-sentinel fi bm_end "ghe-export-mysql" diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 3cefb77ff..0abe00da3 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -46,9 +46,15 @@ is_binary_backup_feature_on(){ if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available if is_binary_backup; then - IMPORT_MYSQL=ghe-import-mysql-xtrabackup + # Check if the decompress needed by looking into the sentinel file + # In 2.19.5 we compress the binary backup twice + if [ $(cat $snapshot_dir/mysql-binary-backup-sentinel) = "NO_ADDITIONAL_COMPRESSION" ]; then + IMPORT_MYSQL=ghe-import-mysql-xtrabackup + else + IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" + fi else - IMPORT_MYSQL=ghe-import-mysql-mysqldump + IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" fi else # We do not allow to restore binary backup without "mysql.backup.binary" set @@ -57,7 +63,7 @@ else exit 2 else # legacy mode - IMPORT_MYSQL=ghe-import-mysql + IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" fi fi @@ -67,6 +73,6 @@ ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "unpigz -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 41ad92ded8be2ccdf7d03b3f1cc4fd1694a73126 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 7 Feb 2020 06:50:44 -0800 Subject: [PATCH 0882/2421] Make sure xtrabackup restore will be imported on mysql master --- share/github-backup-utils/ghe-restore-mysql | 23 ++++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 0abe00da3..f1b2c85d7 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -28,11 +28,6 @@ ghe_remote_version_required "$GHE_HOSTNAME" # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -cleanup() { - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" -} -trap 'cleanup' INT TERM EXIT - # Check if the backup is binary by looking up the sentinel file is_binary_backup(){ test -f $snapshot_dir/mysql-binary-backup-sentinel @@ -43,6 +38,9 @@ is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } +port=$(ssh_port_part "$GHE_HOSTNAME") +ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master"):$port + if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available if is_binary_backup; then @@ -50,11 +48,14 @@ if is_binary_backup_feature_on; then # In 2.19.5 we compress the binary backup twice if [ $(cat $snapshot_dir/mysql-binary-backup-sentinel) = "NO_ADDITIONAL_COMPRESSION" ]; then IMPORT_MYSQL=ghe-import-mysql-xtrabackup + GHE_RESTORE_HOST=$ghe_mysql_master else IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" + GHE_RESTORE_HOST=$ghe_mysql_master fi else IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + GHE_RESTORE_HOST=$GHE_HOSTNAME fi else # We do not allow to restore binary backup without "mysql.backup.binary" set @@ -64,15 +65,21 @@ else else # legacy mode IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + GHE_RESTORE_HOST=$GHE_HOSTNAME fi fi -ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 +cleanup() { + ghe-ssh "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" +} +trap 'cleanup' INT TERM EXIT + +ghe-ssh "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 # Transfer MySQL data from the snapshot to the GitHub instance. -cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" +cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 74f23c42ea40cf82cd60ea25968feb12645d75e1 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 7 Feb 2020 07:16:41 -0800 Subject: [PATCH 0883/2421] ignore port if not set in hostname --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index f1b2c85d7..2f7cd3a39 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -39,7 +39,7 @@ is_binary_backup_feature_on(){ } port=$(ssh_port_part "$GHE_HOSTNAME") -ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master"):$port +ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master")${port:+:$port} if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available From d645bf46c3c3a554af2cbf6646816fa67c28ff5e Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 7 Feb 2020 08:13:58 -0800 Subject: [PATCH 0884/2421] Check if sql master exists --- share/github-backup-utils/ghe-restore-mysql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 2f7cd3a39..3f2250160 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -39,7 +39,12 @@ is_binary_backup_feature_on(){ } port=$(ssh_port_part "$GHE_HOSTNAME") -ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master")${port:+:$port} +ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") +if [ -z $ghe_mysql_master ]; then + ghe_mysql_master=$GHE_HOSTNAME +else + ghe_mysql_master=$ghe_mysql_master${port:+:$port} +fi if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available From f29f0c1fbc80e492f78d02148b2680afe57ce071 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 7 Feb 2020 10:33:54 -0800 Subject: [PATCH 0885/2421] check /etc/github/cluster as well --- share/github-backup-utils/ghe-restore-mysql | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 3f2250160..bbcf3ab9a 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -38,12 +38,16 @@ is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } -port=$(ssh_port_part "$GHE_HOSTNAME") -ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") -if [ -z $ghe_mysql_master ]; then - ghe_mysql_master=$GHE_HOSTNAME +if ghe-ssh "$GHE_HOSTNAME" test -f /etc/github/cluster ; then + ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") + if [ -z $ghe_mysql_master ]; then + ghe_mysql_master=$GHE_HOSTNAME + else + port=$(ssh_port_part "$GHE_HOSTNAME") + ghe_mysql_master=$ghe_mysql_master${port:+:$port} + fi else - ghe_mysql_master=$ghe_mysql_master${port:+:$port} + ghe_mysql_master=$GHE_HOSTNAME fi if is_binary_backup_feature_on; then @@ -51,7 +55,7 @@ if is_binary_backup_feature_on; then if is_binary_backup; then # Check if the decompress needed by looking into the sentinel file # In 2.19.5 we compress the binary backup twice - if [ $(cat $snapshot_dir/mysql-binary-backup-sentinel) = "NO_ADDITIONAL_COMPRESSION" ]; then + if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then IMPORT_MYSQL=ghe-import-mysql-xtrabackup GHE_RESTORE_HOST=$ghe_mysql_master else From f6ffabf37a02ff8d7f21bae6831381a1b40bc22b Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 11:06:38 -0800 Subject: [PATCH 0886/2421] add pigz to travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e8b540837..36e27a0c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,4 +24,5 @@ matrix: - moreutils - fakeroot - jq + - pigz script: debuild -uc -us From e20f1baa1f284ddd2c3e13278ee00bd4c581da55 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 13:13:19 -0800 Subject: [PATCH 0887/2421] check git version --- test/test-ghe-backup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 9fe8eb9bb..9c338aeac 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -54,6 +54,8 @@ begin_test "ghe-backup logs the benchmark" # wait a second for snapshot timestamp sleep 1 + echo "GIT VERSION" + echo $(git --version) export BM_TIMESTAMP=foo From 7a18097986bccf6def40736d12987a2beeded013 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 13:33:33 -0800 Subject: [PATCH 0888/2421] try with git --- .travis.yml | 1 + test/test-ghe-backup.sh | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 36e27a0c6..a2e1ab83e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,4 +25,5 @@ matrix: - fakeroot - jq - pigz + - git script: debuild -uc -us diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 9c338aeac..9fe8eb9bb 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -54,8 +54,6 @@ begin_test "ghe-backup logs the benchmark" # wait a second for snapshot timestamp sleep 1 - echo "GIT VERSION" - echo $(git --version) export BM_TIMESTAMP=foo From 86b0698acab7d2c7c8de8b306321109c229255d6 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 13:50:58 -0800 Subject: [PATCH 0889/2421] git for mac --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a2e1ab83e..78ce5be59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq + - brew install git script: make test - os: linux dist: trusty From aa72af40994605dd23141bc3cc88f6f0da8403ec Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 13:58:46 -0800 Subject: [PATCH 0890/2421] remove brew git --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 78ce5be59..a2e1ab83e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq - - brew install git script: make test - os: linux dist: trusty From ddd329341483d1391b70cbd87975c343f0b62439 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 14:12:57 -0800 Subject: [PATCH 0891/2421] change to true --- bin/ghe-backup | 4 ++-- share/github-backup-utils/ghe-backup-audit-log | 2 +- share/github-backup-utils/ghe-restore-mysql | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 93ea8d23c..ee60abcdf 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -83,7 +83,7 @@ rm -rf src dest1 dest2 # if we should use gitbackups to backup repositories should_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" + ghe-ssh "$GHE_HOSTNAME" ghe-config "app.github.gitbackups" true } # check that the appliance supports using gitbackups for repositories @@ -195,7 +195,7 @@ bm_end "ghe-export-ssh-host-keys" # if we are going to take a binary backup is_binary_backup(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" + ghe-ssh "$GHE_HOSTNAME" ghe-config "mysql.backup.binary" true } echo "Backing up MySQL database ..." diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 6030b2c5b..c59274d1b 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -35,7 +35,7 @@ audit_entries_deleted(){ } is_binary_backup(){ - ghe-ssh "$host" ghe-config --true "mysql.backup.binary" + ghe-ssh "$host" ghe-config "mysql.backup.binary" true } backup_mysql(){ diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index bbcf3ab9a..c65db3ad1 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -35,7 +35,7 @@ is_binary_backup(){ # if mysql.backup.binary feature flag is on is_binary_backup_feature_on(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" + ghe-ssh "$GHE_HOSTNAME" ghe-config "mysql.backup.binary" true } if ghe-ssh "$GHE_HOSTNAME" test -f /etc/github/cluster ; then From b7dd1bbf4da8e5194bf6132c5f71be35289803c7 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 14:43:52 -0800 Subject: [PATCH 0892/2421] Revert "change to true" This reverts commit ddd329341483d1391b70cbd87975c343f0b62439. --- bin/ghe-backup | 4 ++-- share/github-backup-utils/ghe-backup-audit-log | 2 +- share/github-backup-utils/ghe-restore-mysql | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index ee60abcdf..93ea8d23c 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -83,7 +83,7 @@ rm -rf src dest1 dest2 # if we should use gitbackups to backup repositories should_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config "app.github.gitbackups" true + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" } # check that the appliance supports using gitbackups for repositories @@ -195,7 +195,7 @@ bm_end "ghe-export-ssh-host-keys" # if we are going to take a binary backup is_binary_backup(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config "mysql.backup.binary" true + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } echo "Backing up MySQL database ..." diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index c59274d1b..6030b2c5b 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -35,7 +35,7 @@ audit_entries_deleted(){ } is_binary_backup(){ - ghe-ssh "$host" ghe-config "mysql.backup.binary" true + ghe-ssh "$host" ghe-config --true "mysql.backup.binary" } backup_mysql(){ diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index c65db3ad1..bbcf3ab9a 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -35,7 +35,7 @@ is_binary_backup(){ # if mysql.backup.binary feature flag is on is_binary_backup_feature_on(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config "mysql.backup.binary" true + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } if ghe-ssh "$GHE_HOSTNAME" test -f /etc/github/cluster ; then From 178da66f3cbefbb16b0909cc3ed8310f47bfb0d1 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 15:31:42 -0800 Subject: [PATCH 0893/2421] add pigz to macos --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a2e1ab83e..ef07336ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq + - brew install pigz script: make test - os: linux dist: trusty @@ -25,5 +26,4 @@ matrix: - fakeroot - jq - pigz - - git script: debuild -uc -us From c96c6d23eac47dfe35c6de908119c01fb48c41ff Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 10 Feb 2020 08:55:42 -0800 Subject: [PATCH 0894/2421] Adopt comments --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 93ea8d23c..2f94cb408 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -205,7 +205,7 @@ if ! is_binary_backup; then # binary backup is already compressed export_command+=" | pigz" fi -echo "set -o pipefail; ${export_command}" | +echo "set -o pipefail; $export_command" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql" if is_binary_backup; then echo "NO_ADDITIONAL_COMPRESSION" > mysql-binary-backup-sentinel From 6368c9d3e9b83199f54a0e403afdc5e081f4c885 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 5 Feb 2020 12:53:25 -0800 Subject: [PATCH 0895/2421] Use pigz instead of gzip in backup-util --- bin/ghe-backup | 2 +- share/github-backup-utils/ghe-restore-mysql | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 3abe96749..889340cde 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -176,7 +176,7 @@ bm_end "ghe-export-ssh-host-keys" echo "Backing up MySQL database ..." bm_start "ghe-export-mysql" -echo 'set -o pipefail; ghe-export-mysql | gzip' | +echo 'set -o pipefail; ghe-export-mysql | pigz' | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql" bm_end "ghe-export-mysql" diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 9f1ed3c8a..51da1cea5 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -39,7 +39,6 @@ ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "gunzip -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | ghe-import-mysql" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 - +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | unpigz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 9c106f6083348e16607b94cdd2952f4cd6722463 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 6 Feb 2020 08:30:52 -0800 Subject: [PATCH 0896/2421] Use unpigz -cd option --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 51da1cea5..0d8171107 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -39,6 +39,6 @@ ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | unpigz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 +unpigz -cd "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 bm_end "$(basename $0)" From aa6d28d6fc8e461b15c8d3d1294cd64006f6223c Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 6 Feb 2020 10:18:02 -0800 Subject: [PATCH 0897/2421] Fix issue with last commit --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 0d8171107..860780e90 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -39,6 +39,6 @@ ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -unpigz -cd "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 +echo "unpigz -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 2f2bce7d8d9befa4c2293837f057d4cb71f9f433 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 6 Feb 2020 13:07:28 -0800 Subject: [PATCH 0898/2421] Not to compress for binary backup --- bin/ghe-backup | 10 +++++- share/github-backup-utils/ghe-restore-mysql | 36 ++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 889340cde..cc0d0addb 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -176,8 +176,16 @@ bm_end "ghe-export-ssh-host-keys" echo "Backing up MySQL database ..." bm_start "ghe-export-mysql" -echo 'set -o pipefail; ghe-export-mysql | pigz' | +export_command="ghe-export-mysql" +if ! is_binary_backup; then + # binary backup is already compressed + export_command+=" | pigz" +fi +echo "set -o pipefail; ${export_command}" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql" +if is_binary_backup; then + echo "NO_ADDITIONAL_COMPRESSION" > mysql-binary-backup-sentinel +fi bm_end "ghe-export-mysql" echo "Backing up Redis database ..." diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 860780e90..0abe00da3 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -33,12 +33,46 @@ cleanup() { } trap 'cleanup' INT TERM EXIT +# Check if the backup is binary by looking up the sentinel file +is_binary_backup(){ + test -f $snapshot_dir/mysql-binary-backup-sentinel +} + +# if mysql.backup.binary feature flag is on +is_binary_backup_feature_on(){ + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" +} + +if is_binary_backup_feature_on; then + # Feature "mysql.backup.binary" is on, which means new backup scripts are available + if is_binary_backup; then + # Check if the decompress needed by looking into the sentinel file + # In 2.19.5 we compress the binary backup twice + if [ $(cat $snapshot_dir/mysql-binary-backup-sentinel) = "NO_ADDITIONAL_COMPRESSION" ]; then + IMPORT_MYSQL=ghe-import-mysql-xtrabackup + else + IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" + fi + else + IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + fi +else + # We do not allow to restore binary backup without "mysql.backup.binary" set + if is_binary_backup; then + echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 + exit 2 + else + # legacy mode + IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + fi +fi + ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 # Transfer MySQL data from the snapshot to the GitHub instance. cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "unpigz -cd $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 2108f3dd5415820695925d3c045ede34836f8d8a Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 7 Feb 2020 06:50:44 -0800 Subject: [PATCH 0899/2421] Make sure xtrabackup restore will be imported on mysql master --- share/github-backup-utils/ghe-restore-mysql | 23 ++++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 0abe00da3..f1b2c85d7 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -28,11 +28,6 @@ ghe_remote_version_required "$GHE_HOSTNAME" # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -cleanup() { - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" -} -trap 'cleanup' INT TERM EXIT - # Check if the backup is binary by looking up the sentinel file is_binary_backup(){ test -f $snapshot_dir/mysql-binary-backup-sentinel @@ -43,6 +38,9 @@ is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } +port=$(ssh_port_part "$GHE_HOSTNAME") +ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master"):$port + if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available if is_binary_backup; then @@ -50,11 +48,14 @@ if is_binary_backup_feature_on; then # In 2.19.5 we compress the binary backup twice if [ $(cat $snapshot_dir/mysql-binary-backup-sentinel) = "NO_ADDITIONAL_COMPRESSION" ]; then IMPORT_MYSQL=ghe-import-mysql-xtrabackup + GHE_RESTORE_HOST=$ghe_mysql_master else IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" + GHE_RESTORE_HOST=$ghe_mysql_master fi else IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + GHE_RESTORE_HOST=$GHE_HOSTNAME fi else # We do not allow to restore binary backup without "mysql.backup.binary" set @@ -64,15 +65,21 @@ else else # legacy mode IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + GHE_RESTORE_HOST=$GHE_HOSTNAME fi fi -ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 +cleanup() { + ghe-ssh "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" +} +trap 'cleanup' INT TERM EXIT + +ghe-ssh "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 # Transfer MySQL data from the snapshot to the GitHub instance. -cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" +cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 0c6e40f968ea1f0c7cbbc8dcc1ad4fd07b9e7b74 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 7 Feb 2020 07:16:41 -0800 Subject: [PATCH 0900/2421] ignore port if not set in hostname --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index f1b2c85d7..2f7cd3a39 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -39,7 +39,7 @@ is_binary_backup_feature_on(){ } port=$(ssh_port_part "$GHE_HOSTNAME") -ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master"):$port +ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master")${port:+:$port} if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available From e49883732c755627261dfdae9503b1ec23a964fc Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 7 Feb 2020 08:13:58 -0800 Subject: [PATCH 0901/2421] Check if sql master exists --- share/github-backup-utils/ghe-restore-mysql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 2f7cd3a39..3f2250160 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -39,7 +39,12 @@ is_binary_backup_feature_on(){ } port=$(ssh_port_part "$GHE_HOSTNAME") -ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master")${port:+:$port} +ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") +if [ -z $ghe_mysql_master ]; then + ghe_mysql_master=$GHE_HOSTNAME +else + ghe_mysql_master=$ghe_mysql_master${port:+:$port} +fi if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available From 676b39fa930a5c92f6d7d91b8280321af646ce4d Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 7 Feb 2020 10:33:54 -0800 Subject: [PATCH 0902/2421] check /etc/github/cluster as well --- share/github-backup-utils/ghe-restore-mysql | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 3f2250160..bbcf3ab9a 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -38,12 +38,16 @@ is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } -port=$(ssh_port_part "$GHE_HOSTNAME") -ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") -if [ -z $ghe_mysql_master ]; then - ghe_mysql_master=$GHE_HOSTNAME +if ghe-ssh "$GHE_HOSTNAME" test -f /etc/github/cluster ; then + ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") + if [ -z $ghe_mysql_master ]; then + ghe_mysql_master=$GHE_HOSTNAME + else + port=$(ssh_port_part "$GHE_HOSTNAME") + ghe_mysql_master=$ghe_mysql_master${port:+:$port} + fi else - ghe_mysql_master=$ghe_mysql_master${port:+:$port} + ghe_mysql_master=$GHE_HOSTNAME fi if is_binary_backup_feature_on; then @@ -51,7 +55,7 @@ if is_binary_backup_feature_on; then if is_binary_backup; then # Check if the decompress needed by looking into the sentinel file # In 2.19.5 we compress the binary backup twice - if [ $(cat $snapshot_dir/mysql-binary-backup-sentinel) = "NO_ADDITIONAL_COMPRESSION" ]; then + if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then IMPORT_MYSQL=ghe-import-mysql-xtrabackup GHE_RESTORE_HOST=$ghe_mysql_master else From fecf561c0353450e906d9fed0dfb4f44d834fb96 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 11:06:38 -0800 Subject: [PATCH 0903/2421] add pigz to travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cdb3b944f..5345d9419 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,5 +25,5 @@ matrix: - moreutils - fakeroot - jq - - coreutils + - pigz script: debuild -uc -us From e868e851aa889b32bfa74630a073f0c6eff4ff39 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 13:13:19 -0800 Subject: [PATCH 0904/2421] check git version --- test/test-ghe-backup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index e0d01cf92..6836f927c 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -55,6 +55,8 @@ begin_test "ghe-backup logs the benchmark" # wait a second for snapshot timestamp sleep 1 + echo "GIT VERSION" + echo $(git --version) export BM_TIMESTAMP=foo From eb4a1d7315718caabf53b869f5f01acacebe75f5 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 13:33:33 -0800 Subject: [PATCH 0905/2421] try with git --- .travis.yml | 1 + test/test-ghe-backup.sh | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5345d9419..71b76ba48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,4 +26,5 @@ matrix: - fakeroot - jq - pigz + - git script: debuild -uc -us diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6836f927c..e0d01cf92 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -55,8 +55,6 @@ begin_test "ghe-backup logs the benchmark" # wait a second for snapshot timestamp sleep 1 - echo "GIT VERSION" - echo $(git --version) export BM_TIMESTAMP=foo From be5a90b436384a9e0e25dea8cdb619bb70e717dc Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 13:50:58 -0800 Subject: [PATCH 0906/2421] git for mac --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 71b76ba48..78ce5be59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq - - brew install coreutils + - brew install git script: make test - os: linux dist: trusty From 97d90f82bd484db85d017377ce4f1211c8666d78 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 13:58:46 -0800 Subject: [PATCH 0907/2421] remove brew git --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 78ce5be59..a2e1ab83e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq - - brew install git script: make test - os: linux dist: trusty From d99160834fcd2610956914157edcb97abecf96b5 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 14:12:57 -0800 Subject: [PATCH 0908/2421] change to true --- bin/ghe-backup | 24 +++++++++++++++++++ .../github-backup-utils/ghe-backup-audit-log | 2 +- share/github-backup-utils/ghe-restore-mysql | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index cc0d0addb..23bcbd89b 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -81,6 +81,25 @@ if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile fi rm -rf src dest1 dest2 +# if we should use gitbackups to backup repositories +should_use_gitbackups_for_repositories(){ + ghe-ssh "$GHE_HOSTNAME" ghe-config "app.github.gitbackups" true +} + +# check that the appliance supports using gitbackups for repositories +can_use_gitbackups_for_repositories(){ + ghe-ssh "$GHE_HOSTNAME" test -e /data/github/current/bin/ghe-backup-repositories +} + +# Exit early if the appliance is missing script to backup repositories using gitbackups +if should_use_gitbackups_for_repositories; then + if ! can_use_gitbackups_for_repositories; then + echo "Error: Configuration setting 'app.github.gitbackups' is enabled but this version of GHES cannot use gitbackups to back up repositories via 'ghe-backup'." + echo "Disable configuration setting 'app.github.gitbackups' and re-run 'ghe-backup' to use rsync." + exit 1 + fi +fi + # To prevent multiple backup runs happening at the same time, we create a # in-progress file with the timestamp and pid of the backup process, # giving us a form of locking. @@ -174,6 +193,11 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar || failures="$failures ssh-host-keys" bm_end "ghe-export-ssh-host-keys" +# if we are going to take a binary backup +is_binary_backup(){ + ghe-ssh "$GHE_HOSTNAME" ghe-config "mysql.backup.binary" true +} + echo "Backing up MySQL database ..." bm_start "ghe-export-mysql" export_command="ghe-export-mysql" diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index 9366246f7..b0504d822 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -30,7 +30,7 @@ is_skip_truncate_enabled(){ } is_binary_backup(){ - ghe-ssh "$host" ghe-config --true "mysql.backup.binary" + ghe-ssh "$host" ghe-config "mysql.backup.binary" true } backup_mysql(){ diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index bbcf3ab9a..c65db3ad1 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -35,7 +35,7 @@ is_binary_backup(){ # if mysql.backup.binary feature flag is on is_binary_backup_feature_on(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" + ghe-ssh "$GHE_HOSTNAME" ghe-config "mysql.backup.binary" true } if ghe-ssh "$GHE_HOSTNAME" test -f /etc/github/cluster ; then From 4d93f60044b384d2760031d27444d52568211c15 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 14:43:52 -0800 Subject: [PATCH 0909/2421] Revert "change to true" This reverts commit ddd329341483d1391b70cbd87975c343f0b62439. --- bin/ghe-backup | 4 ++-- share/github-backup-utils/ghe-backup-audit-log | 2 +- share/github-backup-utils/ghe-restore-mysql | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 23bcbd89b..c537ec18b 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -83,7 +83,7 @@ rm -rf src dest1 dest2 # if we should use gitbackups to backup repositories should_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config "app.github.gitbackups" true + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" } # check that the appliance supports using gitbackups for repositories @@ -195,7 +195,7 @@ bm_end "ghe-export-ssh-host-keys" # if we are going to take a binary backup is_binary_backup(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config "mysql.backup.binary" true + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } echo "Backing up MySQL database ..." diff --git a/share/github-backup-utils/ghe-backup-audit-log b/share/github-backup-utils/ghe-backup-audit-log index b0504d822..9366246f7 100755 --- a/share/github-backup-utils/ghe-backup-audit-log +++ b/share/github-backup-utils/ghe-backup-audit-log @@ -30,7 +30,7 @@ is_skip_truncate_enabled(){ } is_binary_backup(){ - ghe-ssh "$host" ghe-config "mysql.backup.binary" true + ghe-ssh "$host" ghe-config --true "mysql.backup.binary" } backup_mysql(){ diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index c65db3ad1..bbcf3ab9a 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -35,7 +35,7 @@ is_binary_backup(){ # if mysql.backup.binary feature flag is on is_binary_backup_feature_on(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config "mysql.backup.binary" true + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } if ghe-ssh "$GHE_HOSTNAME" test -f /etc/github/cluster ; then From 1548b84adfeb7c9858753036328574b6ab20666b Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 14:43:52 -0800 Subject: [PATCH 0910/2421] Revert "change to true" This reverts commit ddd329341483d1391b70cbd87975c343f0b62439. From ae8e3022bdc32ff16438a7be450e4058c9c57de9 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Fri, 7 Feb 2020 15:31:42 -0800 Subject: [PATCH 0911/2421] add pigz to macos --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a2e1ab83e..ef07336ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq + - brew install pigz script: make test - os: linux dist: trusty @@ -25,5 +26,4 @@ matrix: - fakeroot - jq - pigz - - git script: debuild -uc -us From e77219cc31ec9fc0dd31b93989d0c5ed549e6597 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 10 Feb 2020 08:55:42 -0800 Subject: [PATCH 0912/2421] Adopt comments --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index c537ec18b..1acf095c1 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -205,7 +205,7 @@ if ! is_binary_backup; then # binary backup is already compressed export_command+=" | pigz" fi -echo "set -o pipefail; ${export_command}" | +echo "set -o pipefail; $export_command" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql" if is_binary_backup; then echo "NO_ADDITIONAL_COMPRESSION" > mysql-binary-backup-sentinel From a9a1aacdcf0239a29c54cdc6f9b1e9e71ea015d6 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Mon, 10 Feb 2020 13:49:28 -0800 Subject: [PATCH 0913/2421] add coreutils --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ef07336ab..308e30ca9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq + - brew install coreutils - brew install pigz script: make test - os: linux @@ -25,5 +26,6 @@ matrix: - moreutils - fakeroot - jq + - coreutils - pigz script: debuild -uc -us From 1f2f2cdc5240f69dd752bf07571058df2041b3aa Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 16 Dec 2019 13:26:54 -0800 Subject: [PATCH 0914/2421] Add synbolic link for mocked ghe-import-mysql-xtrabackup and ghe-import-mysql-mysqldump --- test/bin/ghe-import-mysql-mysqldump | 1 + test/bin/ghe-import-mysql-xtrabackup | 1 + 2 files changed, 2 insertions(+) create mode 120000 test/bin/ghe-import-mysql-mysqldump create mode 120000 test/bin/ghe-import-mysql-xtrabackup diff --git a/test/bin/ghe-import-mysql-mysqldump b/test/bin/ghe-import-mysql-mysqldump new file mode 120000 index 000000000..bc329368a --- /dev/null +++ b/test/bin/ghe-import-mysql-mysqldump @@ -0,0 +1 @@ +ghe-fake-import-command \ No newline at end of file diff --git a/test/bin/ghe-import-mysql-xtrabackup b/test/bin/ghe-import-mysql-xtrabackup new file mode 120000 index 000000000..bc329368a --- /dev/null +++ b/test/bin/ghe-import-mysql-xtrabackup @@ -0,0 +1 @@ +ghe-fake-import-command \ No newline at end of file From 8283873b1873f29923de19a375faa7af839f299d Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 10 Feb 2020 14:53:40 -0800 Subject: [PATCH 0915/2421] bump version --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 17bdb70fa..6ef6ef5ac 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.19.2 +2.19.3 From fdb09ab4ffb3b976803e3a2ef60b6bb85193a784 Mon Sep 17 00:00:00 2001 From: thejandroman Date: Tue, 11 Feb 2020 10:36:18 -0800 Subject: [PATCH 0916/2421] Bump version: 2.20.0 [ci skip] --- debian/changelog | 6 ++++++ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0fc1811f0..e50d21c52 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.20.0) UNRELEASED; urgency=medium + + * Fix `ghe-backup-repositories` performance for large instances #541 + + -- Alejandro Figueroa Tue, 11 Feb 2020 18:36:18 +0000 + github-backup-utils (2.19.1) UNRELEASED; urgency=medium * Cater for more explicit gist paths used in routes file #524 diff --git a/script/cibuild b/script/cibuild index b68f5c539..251b4e47b 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.17.0 2.19.0" +REMOTE_VERSIONS="2.17.0 2.20.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index b8e248f40..7329e21c3 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.19.1 +2.20.0 diff --git a/test/testlib.sh b/test/testlib.sh index c8182b911..a5933cc9d 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.19.0} +: ${GHE_TEST_REMOTE_VERSION:=2.20.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From a69714b0ec1c369f9cc4f314154356249526e9b3 Mon Sep 17 00:00:00 2001 From: Alejandro Figueroa Date: Tue, 11 Feb 2020 14:42:48 -0400 Subject: [PATCH 0917/2421] Update RELEASING.md --- RELEASING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 9ba732ac0..a0e37b5c6 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -24,8 +24,8 @@ Coming :soon: ## Automatic Process from CLI -1. Install the Debian `devscripts` package: - `sudo apt-get install devscripts` +1. Install the Debian `devscripts` and `moreutils` packages: + `sudo apt-get install devscripts moreutils` 2. Run... - Feature release: `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.0 2.11.0` @@ -36,8 +36,8 @@ Coming :soon: In the event you can't perform the automatic process, or a problem is encountered with the automatic process, these are the manual steps you need to perform for a release. -1. Install the Debian `devscripts` package: - `sudo apt-get install devscripts` +1. Install the Debian `devscripts` and `moreutils` packages: + `sudo apt-get install devscripts moreutils` 2. Add a new version and release notes to the `debian/changelog` file: `dch --newversion 2.13.0 --release-heuristic log` You can use `make pending-prs` to craft the release notes. From 64462f556feb25e22b9e6e08d56850aa37beb825 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 11 Feb 2020 11:31:55 -0800 Subject: [PATCH 0918/2421] Bump version: 2.19.3 [ci skip] --- debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/debian/changelog b/debian/changelog index 86d72a6ee..035d0dfe8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.19.3) UNRELEASED; urgency=medium + + * Fix two issues with binary backup (slow gzip compression and support for restore from instances other than SQL master) #551 + + -- Hao Jiang Tue, 11 Feb 2020 19:31:55 +0000 + github-backup-utils (2.19.2) UNRELEASED; urgency=medium * Fix `ghe-backup-repositories` performance for large instances #541 From 7d92a0d6987f285cbfdc83ea4bef7ffb17e3d3a0 Mon Sep 17 00:00:00 2001 From: Alejandro Figueroa Date: Tue, 11 Feb 2020 15:45:47 -0400 Subject: [PATCH 0919/2421] Revert "Bump version: 2.20.0" --- debian/changelog | 6 ------ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index e50d21c52..0fc1811f0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,3 @@ -github-backup-utils (2.20.0) UNRELEASED; urgency=medium - - * Fix `ghe-backup-repositories` performance for large instances #541 - - -- Alejandro Figueroa Tue, 11 Feb 2020 18:36:18 +0000 - github-backup-utils (2.19.1) UNRELEASED; urgency=medium * Cater for more explicit gist paths used in routes file #524 diff --git a/script/cibuild b/script/cibuild index 251b4e47b..b68f5c539 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.17.0 2.20.0" +REMOTE_VERSIONS="2.17.0 2.19.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 7329e21c3..b8e248f40 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.20.0 +2.19.1 diff --git a/test/testlib.sh b/test/testlib.sh index a5933cc9d..c8182b911 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.20.0} +: ${GHE_TEST_REMOTE_VERSION:=2.19.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From a2011c97b4ce4a126b49de3d315bec3e4b380938 Mon Sep 17 00:00:00 2001 From: thejandroman Date: Tue, 11 Feb 2020 12:06:40 -0800 Subject: [PATCH 0920/2421] Bump version: 2.20.0 [ci skip] --- debian/changelog | 7 +++++++ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0fc1811f0..2704cccc9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.20.0) UNRELEASED; urgency=medium + + * Fix `ghe-backup-repositories` performance for large instances #541 + * Fix two issues with binary backup (slow gzip compression and support for restore from instances other than SQL master) #551 + + -- Alejandro Figueroa Tue, 11 Feb 2020 20:06:40 +0000 + github-backup-utils (2.19.1) UNRELEASED; urgency=medium * Cater for more explicit gist paths used in routes file #524 diff --git a/script/cibuild b/script/cibuild index b68f5c539..251b4e47b 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.17.0 2.19.0" +REMOTE_VERSIONS="2.17.0 2.20.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index b8e248f40..7329e21c3 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.19.1 +2.20.0 diff --git a/test/testlib.sh b/test/testlib.sh index c8182b911..a5933cc9d 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.19.0} +: ${GHE_TEST_REMOTE_VERSION:=2.20.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 87e2c73a7c25229edf347ecb9a9adfddc7437574 Mon Sep 17 00:00:00 2001 From: Alejandro Figueroa Date: Tue, 11 Feb 2020 16:29:22 -0400 Subject: [PATCH 0921/2421] Revert "Bump version: 2.20.0" --- debian/changelog | 7 ------- script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index 2704cccc9..0fc1811f0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,3 @@ -github-backup-utils (2.20.0) UNRELEASED; urgency=medium - - * Fix `ghe-backup-repositories` performance for large instances #541 - * Fix two issues with binary backup (slow gzip compression and support for restore from instances other than SQL master) #551 - - -- Alejandro Figueroa Tue, 11 Feb 2020 20:06:40 +0000 - github-backup-utils (2.19.1) UNRELEASED; urgency=medium * Cater for more explicit gist paths used in routes file #524 diff --git a/script/cibuild b/script/cibuild index 251b4e47b..b68f5c539 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.17.0 2.20.0" +REMOTE_VERSIONS="2.17.0 2.19.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 7329e21c3..b8e248f40 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.20.0 +2.19.1 diff --git a/test/testlib.sh b/test/testlib.sh index a5933cc9d..c8182b911 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.20.0} +: ${GHE_TEST_REMOTE_VERSION:=2.19.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 894d733e4efc7640fca051d38e23c8d131d47a00 Mon Sep 17 00:00:00 2001 From: thejandroman Date: Tue, 11 Feb 2020 12:47:17 -0800 Subject: [PATCH 0922/2421] Bump version: 2.20.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 7 +++++++ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index f5ccbb89e..be77fd315 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.17.0" +supported_minimum_version="2.18.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 0fc1811f0..2e92a6107 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (2.20.0) UNRELEASED; urgency=medium + + * Fix `ghe-backup-repositories` performance for large instances #541 + * Fix two issues with binary backup (slow gzip compression and support for restore from instances other than SQL master) #551 + + -- Alejandro Figueroa Tue, 11 Feb 2020 20:47:17 +0000 + github-backup-utils (2.19.1) UNRELEASED; urgency=medium * Cater for more explicit gist paths used in routes file #524 diff --git a/script/cibuild b/script/cibuild index b68f5c539..13ccc130b 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.17.0 2.19.0" +REMOTE_VERSIONS="2.18.0 2.20.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index b8e248f40..7329e21c3 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.19.1 +2.20.0 diff --git a/test/testlib.sh b/test/testlib.sh index c8182b911..a5933cc9d 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.19.0} +: ${GHE_TEST_REMOTE_VERSION:=2.20.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From a413701c0cdb78deee231c720634194d51465453 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 11 Feb 2020 21:08:59 -0800 Subject: [PATCH 0923/2421] CI with GitHub Actions --- .github/workflows/main.yml | 37 +++++++++++++++++++++++++++++++++++++ .travis.yml | 4 ++-- test/test-shellcheck.sh | 6 +++--- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..4768bfccd --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: Test and build + +on: [push] + +jobs: + build: + strategy: + matrix: + os: ['ubuntu-latest', 'macos-latest'] + runs-on: ${{ matrix.os }} + + steps: + - name: Install Dependencies (Linux) + run: | + sudo apt-get update -y + sudo apt-get install -y devscripts debhelper moreutils fakeroot jq + wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" + tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" + sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck + if: matrix.os == 'ubuntu-latest' + - name: Install Dependencies (macOS) + run: | + brew install gnu-tar shellcheck jq + brew unlink parallel + brew install moreutils + if: matrix.os == 'macos-latest' + - name: Get Sources + uses: actions/checkout@v2 + - name: Test + run: | + export PATH="$PATH:/snap/bin" + make test + shell: bash + - name: Build + run: debuild -uc -us + if: matrix.os == 'ubuntu-latest' + diff --git a/.travis.yml b/.travis.yml index e8b540837..9cbe8633f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,8 @@ matrix: dist: trusty sudo: required install: - - wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.4.7.linux.x86_64.tar.xz" - - tar --xz -xvf "shellcheck-v0.4.7.linux.x86_64.tar.xz" + - wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" + - tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" addons: apt: packages: diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh index 3f2a7fb94..c270d5781 100755 --- a/test/test-shellcheck.sh +++ b/test/test-shellcheck.sh @@ -9,10 +9,10 @@ BASE_PATH=$(cd "$(dirname "$0")/../" && pwd) begin_test "shellcheck: reports no errors or warnings" ( set -e - # We manually install Shellcheck 0.4.7 on Travis Linux builds as other options + # We manually install Shellcheck 0.7.0 on Linux builds as other options # are too old. - if [ -x "$BASE_PATH/shellcheck-v0.4.7/shellcheck" ]; then - shellcheck() { "$BASE_PATH/shellcheck-v0.4.7/shellcheck" "$@"; } + if [ -x "$BASE_PATH/shellcheck-v0.7.0/shellcheck" ]; then + shellcheck() { "$BASE_PATH/shellcheck-v0.7.0/shellcheck" "$@"; } fi if ! type shellcheck 1>/dev/null 2>&1; then From 02d95c6401a5eaa72b1da37ed4ee367b33814280 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 11:17:07 -0500 Subject: [PATCH 0924/2421] Use ssh forwarding to connect to appliances other than GHE_RESTORE_HOST --- share/github-backup-utils/ghe-restore-mysql | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index bbcf3ab9a..00c07aaec 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -38,11 +38,16 @@ is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } -if ghe-ssh "$GHE_HOSTNAME" test -f /etc/github/cluster ; then +ssh_config_file_opt="" +if $CLUSTER ; then ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") if [ -z $ghe_mysql_master ]; then ghe_mysql_master=$GHE_HOSTNAME else + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" port=$(ssh_port_part "$GHE_HOSTNAME") ghe_mysql_master=$ghe_mysql_master${port:+:$port} fi @@ -79,16 +84,16 @@ else fi cleanup() { - ghe-ssh "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" } trap 'cleanup' INT TERM EXIT -ghe-ssh "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 +ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 # Transfer MySQL data from the snapshot to the GitHub instance. -cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" +cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 bm_end "$(basename $0)" From 9e11bec3db6da7c40c0568c6dcf3768dfa04beb5 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 11:27:30 -0500 Subject: [PATCH 0925/2421] make temp dir --- share/github-backup-utils/ghe-restore-mysql | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 00c07aaec..10a0b1bee 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -44,6 +44,7 @@ if $CLUSTER ; then if [ -z $ghe_mysql_master ]; then ghe_mysql_master=$GHE_HOSTNAME else + tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" From 146174425db193498abc677bf2c29717af1ccb88 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 11:52:04 -0500 Subject: [PATCH 0926/2421] Error out for mysql-master not found in cluster setup --- share/github-backup-utils/ghe-restore-mysql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 10a0b1bee..42a349427 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -42,7 +42,8 @@ ssh_config_file_opt="" if $CLUSTER ; then ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") if [ -z $ghe_mysql_master ]; then - ghe_mysql_master=$GHE_HOSTNAME + echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 + exit 2 else tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file="$tempdir/ssh_config" From 9158ebf61598db0bb571945d993b0542c6e135d0 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 11:17:07 -0500 Subject: [PATCH 0927/2421] Use ssh forwarding to connect to appliances other than GHE_RESTORE_HOST --- share/github-backup-utils/ghe-restore-mysql | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index bbcf3ab9a..00c07aaec 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -38,11 +38,16 @@ is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } -if ghe-ssh "$GHE_HOSTNAME" test -f /etc/github/cluster ; then +ssh_config_file_opt="" +if $CLUSTER ; then ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") if [ -z $ghe_mysql_master ]; then ghe_mysql_master=$GHE_HOSTNAME else + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" port=$(ssh_port_part "$GHE_HOSTNAME") ghe_mysql_master=$ghe_mysql_master${port:+:$port} fi @@ -79,16 +84,16 @@ else fi cleanup() { - ghe-ssh "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" } trap 'cleanup' INT TERM EXIT -ghe-ssh "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 +ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 # Transfer MySQL data from the snapshot to the GitHub instance. -cat $snapshot_dir/mysql.sql.gz | ghe-ssh "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" +cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" # Import the database -echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 bm_end "$(basename $0)" From a4c7abaf5c4863f2d5d9cf2a91fd5096b2823c0b Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 11:27:30 -0500 Subject: [PATCH 0928/2421] make temp dir --- share/github-backup-utils/ghe-restore-mysql | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 00c07aaec..10a0b1bee 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -44,6 +44,7 @@ if $CLUSTER ; then if [ -z $ghe_mysql_master ]; then ghe_mysql_master=$GHE_HOSTNAME else + tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" From df45d826d9a602e266fa6c25faa240a83ac7fa8b Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 11:52:04 -0500 Subject: [PATCH 0929/2421] Error out for mysql-master not found in cluster setup --- share/github-backup-utils/ghe-restore-mysql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 10a0b1bee..42a349427 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -42,7 +42,8 @@ ssh_config_file_opt="" if $CLUSTER ; then ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") if [ -z $ghe_mysql_master ]; then - ghe_mysql_master=$GHE_HOSTNAME + echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 + exit 2 else tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file="$tempdir/ssh_config" From a32b235d71297dc421b0ba667a6265ed47ba3c98 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 14:45:10 -0500 Subject: [PATCH 0930/2421] Remove unused opts --- share/github-backup-utils/ghe-restore-mysql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 42a349427..f7919322e 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -38,7 +38,7 @@ is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } -ssh_config_file_opt="" +ssh_config_file_opt= if $CLUSTER ; then ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") if [ -z $ghe_mysql_master ]; then @@ -48,7 +48,6 @@ if $CLUSTER ; then tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" port=$(ssh_port_part "$GHE_HOSTNAME") ghe_mysql_master=$ghe_mysql_master${port:+:$port} From d60eeba50417381513947d209f9dec452c76bf69 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 14:45:10 -0500 Subject: [PATCH 0931/2421] Remove unused opts --- share/github-backup-utils/ghe-restore-mysql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 42a349427..f7919322e 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -38,7 +38,7 @@ is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } -ssh_config_file_opt="" +ssh_config_file_opt= if $CLUSTER ; then ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") if [ -z $ghe_mysql_master ]; then @@ -48,7 +48,6 @@ if $CLUSTER ; then tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" port=$(ssh_port_part "$GHE_HOSTNAME") ghe_mysql_master=$ghe_mysql_master${port:+:$port} From 4df3c933f43fc9288e11444c6c577ebd74f7d506 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 15:45:24 -0500 Subject: [PATCH 0932/2421] move logic around for binary backups only --- share/github-backup-utils/ghe-restore-mysql | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index f7919322e..a939c8d6d 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -39,26 +39,26 @@ is_binary_backup_feature_on(){ } ssh_config_file_opt= -if $CLUSTER ; then - ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") - if [ -z $ghe_mysql_master ]; then - echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 - exit 2 - else - tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" - port=$(ssh_port_part "$GHE_HOSTNAME") - ghe_mysql_master=$ghe_mysql_master${port:+:$port} - fi -else - ghe_mysql_master=$GHE_HOSTNAME -fi - if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available if is_binary_backup; then + if $CLUSTER ; then + ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") + if [ -z $ghe_mysql_master ]; then + echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 + exit 2 + else + tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" + port=$(ssh_port_part "$GHE_HOSTNAME") + ghe_mysql_master=$ghe_mysql_master${port:+:$port} + fi + else + ghe_mysql_master=$GHE_HOSTNAME + fi + # Check if the decompress needed by looking into the sentinel file # In 2.19.5 we compress the binary backup twice if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then From 33efc37e8bdc955ec00c0a083134fece5dedcb0d Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 13 Feb 2020 15:45:24 -0500 Subject: [PATCH 0933/2421] move logic around for binary backups only --- share/github-backup-utils/ghe-restore-mysql | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index f7919322e..a939c8d6d 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -39,26 +39,26 @@ is_binary_backup_feature_on(){ } ssh_config_file_opt= -if $CLUSTER ; then - ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") - if [ -z $ghe_mysql_master ]; then - echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 - exit 2 - else - tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" - port=$(ssh_port_part "$GHE_HOSTNAME") - ghe_mysql_master=$ghe_mysql_master${port:+:$port} - fi -else - ghe_mysql_master=$GHE_HOSTNAME -fi - if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available if is_binary_backup; then + if $CLUSTER ; then + ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") + if [ -z $ghe_mysql_master ]; then + echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 + exit 2 + else + tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" + port=$(ssh_port_part "$GHE_HOSTNAME") + ghe_mysql_master=$ghe_mysql_master${port:+:$port} + fi + else + ghe_mysql_master=$GHE_HOSTNAME + fi + # Check if the decompress needed by looking into the sentinel file # In 2.19.5 we compress the binary backup twice if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then From 2032bce754de7c6f55ad1e5a10f1ad7ee58a7fe6 Mon Sep 17 00:00:00 2001 From: jianghao0718 Date: Tue, 18 Feb 2020 09:54:31 -0800 Subject: [PATCH 0934/2421] Bump version: 2.19.4 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 035d0dfe8..5fc9ba841 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.19.4) UNRELEASED; urgency=medium + + * Fix the way we connect to mysql master using ssh forwarding for binary backups #567 + + -- Hao Jiang Tue, 18 Feb 2020 17:54:31 +0000 + github-backup-utils (2.19.3) UNRELEASED; urgency=medium * Fix two issues with binary backup (slow gzip compression and support for restore from instances other than SQL master) #551 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 6ef6ef5ac..87ca3a54e 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.19.3 +2.19.4 From 72225fd6f61d479ce6283b2348cae2f72a621032 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 18 Feb 2020 11:53:35 -0800 Subject: [PATCH 0935/2421] Undo changes introduced by PR 536 (#570) * Undo changes introduced by https://github.com/github/backup-utils/pull/536 * Undo changes to ghe-backup-repositories --- bin/ghe-backup | 28 ++----------------- ...sitories-rsync => ghe-backup-repositories} | 4 +-- .../ghe-backup-repositories-gitbackups | 17 ----------- 3 files changed, 4 insertions(+), 45 deletions(-) rename share/github-backup-utils/{ghe-backup-repositories-rsync => ghe-backup-repositories} (99%) delete mode 100755 share/github-backup-utils/ghe-backup-repositories-gitbackups diff --git a/bin/ghe-backup b/bin/ghe-backup index 2f94cb408..05f717bcc 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -81,25 +81,6 @@ if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile fi rm -rf src dest1 dest2 -# if we should use gitbackups to backup repositories -should_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" -} - -# check that the appliance supports using gitbackups for repositories -can_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" test -e /data/github/current/bin/ghe-backup-repositories -} - -# Exit early if the appliance is missing script to backup repositories using gitbackups -if should_use_gitbackups_for_repositories; then - if ! can_use_gitbackups_for_repositories; then - echo "Error: Configuration setting 'app.github.gitbackups' is enabled but this version of GHES cannot use gitbackups to back up repositories via 'ghe-backup'." - echo "Disable configuration setting 'app.github.gitbackups' and re-run 'ghe-backup' to use rsync." - exit 1 - fi -fi - # To prevent multiple backup runs happening at the same time, we create a # in-progress file with the timestamp and pid of the backup process, # giving us a form of locking. @@ -221,13 +202,8 @@ ghe-backup-audit-log || failures="$failures audit-log" echo "Backing up hookshot logs ..." ghe-backup-es-hookshot || failures="$failures hookshot" -if should_use_gitbackups_for_repositories && can_use_gitbackups_for_repositories; then - echo "Backing up Git repositories using gitbackups ..." - ghe-backup-repositories-gitbackups || failures="$failures repositories" -else - echo "Backing up Git repositories using rsync ..." - ghe-backup-repositories-rsync || failures="$failures repositories" -fi +echo "Backing up Git repositories ..." +ghe-backup-repositories || failures="$failures repositories" echo "Backing up GitHub Pages ..." ghe-backup-pages || failures="$failures pages" diff --git a/share/github-backup-utils/ghe-backup-repositories-rsync b/share/github-backup-utils/ghe-backup-repositories similarity index 99% rename from share/github-backup-utils/ghe-backup-repositories-rsync rename to share/github-backup-utils/ghe-backup-repositories index e89484b01..62feb8d22 100755 --- a/share/github-backup-utils/ghe-backup-repositories-rsync +++ b/share/github-backup-utils/ghe-backup-repositories @@ -1,6 +1,6 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup-repositories-rsync -#/ Take an online, incremental snapshot of all Git repository data using rsync. +#/ Usage: ghe-backup-repositories +#/ Take an online, incremental snapshot of all Git repository data. #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup. diff --git a/share/github-backup-utils/ghe-backup-repositories-gitbackups b/share/github-backup-utils/ghe-backup-repositories-gitbackups deleted file mode 100755 index 4d8667cdc..000000000 --- a/share/github-backup-utils/ghe-backup-repositories-gitbackups +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-repositories-gitbackups -#/ Take an online, incremental snapshot of all Git repository, wiki, and gist data using gitbackups. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -echo "github-env ./bin/ghe-backup-repositories" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash - -bm_end "$(basename $0)" From 0ca622e43fc31f9f7094f3da7d8411967f438389 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Tue, 18 Feb 2020 12:32:02 -0800 Subject: [PATCH 0936/2421] fix missing line --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index a4cc673ab..7329e21c3 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.20.0 \ No newline at end of file +2.20.0 From 5c0abdaa1a89a86f27088f8981fa9bc780e40f15 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 18 Feb 2020 15:08:15 -0800 Subject: [PATCH 0937/2421] Update release instructions --- RELEASING.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index 9ba732ac0..4cd293dec 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -26,7 +26,8 @@ Coming :soon: 1. Install the Debian `devscripts` package: `sudo apt-get install devscripts` -2. Run... +2. Generate a PAT through github.com with access to the `github/backup-utils` repository. This will be used for the `GH_RELEASE_TOKEN` environment variable in the next step. +3. Run... - Feature release: `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.0 2.11.0` - Patch release: From 48040a541c6be68d2c42ef0ce84da1ca682bd450 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Tue, 18 Feb 2020 19:56:36 -0500 Subject: [PATCH 0938/2421] Fix the copy-pasta comment --- test/bin/dgit-cluster-backup-routes | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bin/dgit-cluster-backup-routes b/test/bin/dgit-cluster-backup-routes index cef8c7d27..a09f67a9d 100755 --- a/test/bin/dgit-cluster-backup-routes +++ b/test/bin/dgit-cluster-backup-routes @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Usage: dgit-cluster-backup-routes -# Emulates the remote GitHub enterprise-configure command. Tests use this -# to assert that the command was executed. +# Emulates the remote GitHub dgit-cluster-backup-routes command. Tests use this +# to assert that all repos and gists get backed up. set -e cat < Date: Tue, 18 Feb 2020 20:01:57 -0500 Subject: [PATCH 0939/2421] Emit gist routes in a GHES-version-specific way --- test/bin/dgit-cluster-backup-routes | 32 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/test/bin/dgit-cluster-backup-routes b/test/bin/dgit-cluster-backup-routes index a09f67a9d..d5d9dcf9e 100755 --- a/test/bin/dgit-cluster-backup-routes +++ b/test/bin/dgit-cluster-backup-routes @@ -3,9 +3,29 @@ # Emulates the remote GitHub dgit-cluster-backup-routes command. Tests use this # to assert that all repos and gists get backed up. set -e -cat < Date: Tue, 18 Feb 2020 20:06:22 -0500 Subject: [PATCH 0940/2421] Use spaces, not tabs --- test/bin/dgit-cluster-backup-routes | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/bin/dgit-cluster-backup-routes b/test/bin/dgit-cluster-backup-routes index d5d9dcf9e..ed363d047 100755 --- a/test/bin/dgit-cluster-backup-routes +++ b/test/bin/dgit-cluster-backup-routes @@ -9,8 +9,8 @@ version() { } if [ -z "$GHE_REMOTE_VERSION" ]; then - echo GHE_REMOTE_VERSION must be set for this script to work. - exit 1 + echo GHE_REMOTE_VERSION must be set for this script to work. + exit 1 fi # The list of gists returned by the source changed in 2.16.23, 2.17.14, @@ -19,10 +19,10 @@ if [[ "$GHE_REMOTE_VERSION" =~ 2.16. && "$(version $GHE_REMOTE_VERSION)" -ge "$( [[ "$GHE_REMOTE_VERSION" =~ 2.17. && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.17.14)" ]] || \ [[ "$GHE_REMOTE_VERSION" =~ 2.18. && "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.18.8)" ]] || \ [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.19.3)" ]]; then - echo 0/nw/01/aa/3f/1234 git-server-fake-uuid - echo 1/nw/23/bb/4c/2345 git-server-fake-uuid1 - echo 0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git git-server-fake-uuid2 - echo 1/23/bb/4c/gist/03de86b717f901789a864375baaab36c.git git-server-fake-uuid + echo 0/nw/01/aa/3f/1234 git-server-fake-uuid + echo 1/nw/23/bb/4c/2345 git-server-fake-uuid1 + echo 0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git git-server-fake-uuid2 + echo 1/23/bb/4c/gist/03de86b717f901789a864375baaab36c.git git-server-fake-uuid else echo 0/nw/01/aa/3f/1234 git-server-fake-uuid echo 1/nw/23/bb/4c/2345 git-server-fake-uuid1 From 4c4050d6b9b0ccf4f60e1815d85626b592a49b0d Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Tue, 18 Feb 2020 22:08:26 -0500 Subject: [PATCH 0941/2421] Use same gist path as setup_test_data `dgit-cluster-backup-routes` needs to use the same fake gist route as `test/testlib.sh`. Now it does. --- test/bin/dgit-cluster-backup-routes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bin/dgit-cluster-backup-routes b/test/bin/dgit-cluster-backup-routes index ed363d047..eb836d4ef 100755 --- a/test/bin/dgit-cluster-backup-routes +++ b/test/bin/dgit-cluster-backup-routes @@ -22,7 +22,7 @@ if [[ "$GHE_REMOTE_VERSION" =~ 2.16. && "$(version $GHE_REMOTE_VERSION)" -ge "$( echo 0/nw/01/aa/3f/1234 git-server-fake-uuid echo 1/nw/23/bb/4c/2345 git-server-fake-uuid1 echo 0/01/aa/3f/gist/93069ad4c391b6203f183e147d52a97a.git git-server-fake-uuid2 - echo 1/23/bb/4c/gist/03de86b717f901789a864375baaab36c.git git-server-fake-uuid + echo 1/23/bb/4c/gist/1234.git git-server-fake-uuid else echo 0/nw/01/aa/3f/1234 git-server-fake-uuid echo 1/nw/23/bb/4c/2345 git-server-fake-uuid1 From 0e355f4c184462a4c27dd324a68c51560fff6065 Mon Sep 17 00:00:00 2001 From: Patrick Reynolds Date: Wed, 19 Feb 2020 11:08:56 -0500 Subject: [PATCH 0942/2421] Stub out the `true` flag for `ghe-config` The new MySQL backup code uses `ghe-config --true ...`. The mock in `test/bin/ghe-config` prints out a lot of error messages when it gets that flag, which makes debugging test failures harder. This commit fixes the mock so it implements `ghe-config --true ...` correctly, the same way recent versions of GHES do. --- test/bin/ghe-config | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/bin/ghe-config b/test/bin/ghe-config index a26123c37..464977fff 100755 --- a/test/bin/ghe-config +++ b/test/bin/ghe-config @@ -3,8 +3,10 @@ # Emulates the remote GitHub ghe-config secrets.manage command. Tests use this # to assert that the command was executed. set -e -if [ $# -eq 1 ]; then - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" "$1" -else - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" "$1" "$2" + +if [ "$1" = "--true" ]; then + shift + [[ $($0 "$@") = true ]] && exit 0 || exit 1 fi + +git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" "$@" From 8f8823da775217e7b8cde7d7421418622b9084c9 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 19 Feb 2020 13:01:52 -0800 Subject: [PATCH 0943/2421] Remove gitbackups changes --- bin/ghe-backup | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 1acf095c1..05f717bcc 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -81,25 +81,6 @@ if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile fi rm -rf src dest1 dest2 -# if we should use gitbackups to backup repositories -should_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.github.gitbackups" -} - -# check that the appliance supports using gitbackups for repositories -can_use_gitbackups_for_repositories(){ - ghe-ssh "$GHE_HOSTNAME" test -e /data/github/current/bin/ghe-backup-repositories -} - -# Exit early if the appliance is missing script to backup repositories using gitbackups -if should_use_gitbackups_for_repositories; then - if ! can_use_gitbackups_for_repositories; then - echo "Error: Configuration setting 'app.github.gitbackups' is enabled but this version of GHES cannot use gitbackups to back up repositories via 'ghe-backup'." - echo "Disable configuration setting 'app.github.gitbackups' and re-run 'ghe-backup' to use rsync." - exit 1 - fi -fi - # To prevent multiple backup runs happening at the same time, we create a # in-progress file with the timestamp and pid of the backup process, # giving us a form of locking. From 7bfc796dc1854c204f68fdf49b5461183c6b08ca Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 19 Feb 2020 13:47:18 -0800 Subject: [PATCH 0944/2421] Bump version: 2.20.1 [ci skip] --- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index bf3f090cd..642cba0fb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (2.20.1) UNRELEASED; urgency=medium + + + -- Caine Jette Wed, 19 Feb 2020 21:47:18 +0000 + github-backup-utils (2.19.4) UNRELEASED; urgency=medium * Fix the way we connect to mysql master using ssh forwarding for binary backups #567 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 7329e21c3..4e2200b98 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.20.0 +2.20.1 From 501bdc87526230e9cacb3a405d1337bd80334ef3 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 19 Feb 2020 13:58:18 -0800 Subject: [PATCH 0945/2421] Update changelog with actual description of changes --- debian/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/changelog b/debian/changelog index 642cba0fb..c4fc58c0c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ github-backup-utils (2.20.1) UNRELEASED; urgency=medium + * Fixes gist route calculation for GHES version 2.20 -- Caine Jette Wed, 19 Feb 2020 21:47:18 +0000 From 6bdb211a39f88dffda6d9afcea271618c3769ced Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Thu, 20 Feb 2020 12:52:09 -0500 Subject: [PATCH 0946/2421] In legacy mode we should use ghe-import-mysql In legacy mode we should use ghe-import-mysql --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index a939c8d6d..150c93a77 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -79,7 +79,7 @@ else exit 2 else # legacy mode - IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + IMPORT_MYSQL="unpigz | ghe-import-mysql" GHE_RESTORE_HOST=$GHE_HOSTNAME fi fi From fcbece3973ef85d8d0758ce368e5b6bc37a418fd Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 20 Feb 2020 14:47:09 -0800 Subject: [PATCH 0947/2421] Bump version: 2.20.2 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index c4fc58c0c..b71885c21 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.20.2) UNRELEASED; urgency=medium + + * In legacy mode we should use ghe-import-mysql #581 + + -- Hao Jiang Thu, 20 Feb 2020 22:47:09 +0000 + github-backup-utils (2.20.1) UNRELEASED; urgency=medium * Fixes gist route calculation for GHES version 2.20 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 4e2200b98..83ecbf1d7 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.20.1 +2.20.2 From df8678a25c439bd058e80615acb95d29f71e6331 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Wed, 5 Feb 2020 14:25:24 -0500 Subject: [PATCH 0948/2421] Add mssql backup portion --- bin/ghe-backup | 3 ++ share/github-backup-utils/ghe-backup-mssql | 35 ++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 share/github-backup-utils/ghe-backup-mssql diff --git a/bin/ghe-backup b/bin/ghe-backup index f67b4dc71..40fb1cb4a 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -207,6 +207,9 @@ if is_binary_backup; then fi bm_end "ghe-export-mysql" +echo "Backing up MSSQL databases ..." +ghe-backup-mssql || failures = "$failures mssql" + echo "Backing up Redis database ..." ghe-backup-redis > redis.rdb || failures="$failures redis" diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql new file mode 100755 index 000000000..f014e6ce8 --- /dev/null +++ b/share/github-backup-utils/ghe-backup-mssql @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-mssql +#/ +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-backup. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Set up remote host and root backup snapshot directory based on config +host="$GHE_HOSTNAME" +backup_dir="$GHE_SNAPSHOT_DIR/mssql" + +# Make sure root backup dir exists if this is the first run +mkdir -p "$backup_dir" + +bm_start "$(basename $0)" +ghe-ssh "$host" -- 'ghe-export-mssql' || failures="$failures mssql" +bm_end "$(basename $0)" + +# Verify rsync is available. +if ! rsync --version 1>/dev/null 2>&1; then + echo "Error: rsync not found." 1>&2 + exit 1 +fi + +appliance_dir="/data/user/mssql/backups" +backups=$(ghe-ssh "$host" "sudo ls $appliance_dir") +for b in $backups +do + ghe-ssh "$host" "sudo cat $appliance_dir/$b" > $backup_dir/$b +done \ No newline at end of file From be2bd011b4ba85a79dded708220717ff38624eb6 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Thu, 6 Feb 2020 11:59:43 -0500 Subject: [PATCH 0949/2421] Create hard links for backup files --- backup.config-example | 9 ++ share/github-backup-utils/ghe-backup-mssql | 145 +++++++++++++++++++-- 2 files changed, 141 insertions(+), 13 deletions(-) diff --git a/backup.config-example b/backup.config-example index 1ea7fb61f..5c068bfb4 100644 --- a/backup.config-example +++ b/backup.config-example @@ -48,3 +48,12 @@ GHE_NUM_SNAPSHOTS=10 # # WARNING: do not enable this, only useful for debugging/development #GHE_BACKUP_FSCK=no + +# Cadence of MSSQL backups +# ,, all in minutes +# e.g. +# - Full backup every week (10080 minutes) +# - Differential backup every day (1440 minutes) +# - Transactionlog backup every 15 minutes +# +GHE_MSSQL_BACKUP_CADENCE=10080,1440,15 \ No newline at end of file diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index f014e6ce8..3b46d2bbd 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -13,23 +13,142 @@ set -e # Set up remote host and root backup snapshot directory based on config host="$GHE_HOSTNAME" backup_dir="$GHE_SNAPSHOT_DIR/mssql" +last= +last_mssql= +backup_command= +take_full= +take_diff= +full_expire= +diff_expire= +tran_expire= + +add_minute() { + # Expect date string in the format of yyyymmddTHHMMSS + # Here parse date differently depending on GNU Linux vs BSD MacOS + if date -v -1d > /dev/null 2>&1; then + echo $(date -v+$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S) + else + echo $(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} + $2 min") + fi +} + +find_timestamp() { + filename="${1##*/}" + parts=(${filename//@/ }) + datetime_part=${parts[1]:0:15} + echo $datetime_part +} + +# Find last snapshot to create potential hard links +count=$(ls $GHE_SNAPSHOT_DIR/.. | egrep '\d{8}T\d{6}' | sort | tail -2 | wc -l) +if [ $count -gt 1 ] +then + last=$(ls $GHE_SNAPSHOT_DIR/.. | egrep '\d{8}T\d{6}' | sort | tail -2 | head -1) +else + unset last +fi + +last_mssql=$GHE_SNAPSHOT_DIR/../$last/mssql + +if [ -z $last ] || [ ! -d $last_mssql ] || [ -z $(find $last_mssql -type f -name "*.bak") ] +then + # Take initial full backup + take_full=1 + backup_command='ghe-export-mssql' +else + # Check schedule to determine backup type + cadence=(${GHE_MSSQL_BACKUP_CADENCE//,/ }) + + current=$(date -u +%Y%m%d%H%M%S) + + full=$(find "$last_mssql" -type f -name "*.bak") + full=$(find_timestamp $full) + full_expire=$(add_minute $full ${cadence[0]}) + full_expire="${full_expire//T}" + + diff=$(find "$last_mssql" -type f -name "*.diff") + if [ ! -z $diff ] + then + diff=$(find_timestamp $diff) + diff_expire=$(add_minute $diff ${cadence[1]}) + diff_expire="${diff_expire//T}" + else + diff_expire=$(add_minute $full ${cadence[1]}) + diff_expire="${diff_expire//T}" + fi + + tran=$(find "$last_mssql" -type f -name "*.log" | egrep '\d{8}T\d{6}' | sort | tail -1) + tran=$(find_timestamp $tran) + tran_expire=$(add_minute $tran ${cadence[2]}) + tran_expire="${tran_expire//T}" + + echo "current $current, full expire $full_expire, diff expire $diff_expire, tran expire $tran_expire" + + # Determine the type of backup to take + if [ $current -gt $full_expire ] + then + echo "Taking full backup" + take_full=1 + backup_command='ghe-export-mssql' + elif [ $current -gt $diff_expire ] + then + echo "Taking diff backup" + take_diff=1 + backup_command='ghe-export-mssql -d' + elif [ $current -gt $tran_expire ] + then + echo "Taking transaction backup" + backup_command='ghe-export-mssql -t' + fi +fi # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" -bm_start "$(basename $0)" -ghe-ssh "$host" -- 'ghe-export-mssql' || failures="$failures mssql" -bm_end "$(basename $0)" +# Create hard links to save disk space and time +if [ ! -z $last ] +then + for p in $(ls $last_mssql) + do + filename="${p##*/}" + extension="${filename##*.}" + transfer= -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 + if [ $extension = "bak" ] && [ -z $take_full ] + then + transfer=1 + fi + + if [ $extension = "diff" ] && [ -z $take_full ] && [ -z $take_diff ] + then + transfer=1 + fi + + if [ $extension = "log" ] && [ -z $take_full ] && [ -z $take_diff ] + then + transfer=1 + fi + + if [ ! -z $transfer ] + then + echo "Creating hard link to $p" + ln $last_mssql/$p $backup_dir/$p + fi + done fi -appliance_dir="/data/user/mssql/backups" -backups=$(ghe-ssh "$host" "sudo ls $appliance_dir") -for b in $backups -do - ghe-ssh "$host" "sudo cat $appliance_dir/$b" > $backup_dir/$b -done \ No newline at end of file +if [ ! -z "$backup_command" ] +then + bm_start "$(basename $0)" + ghe-ssh "$host" -- "$backup_command" || failures="$failures mssql" + bm_end "$(basename $0)" + + # Transfer backup files from appliance to backup host + appliance_dir="/data/user/mssql/backups" + backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then sudo ls \"$appliance_dir\"; fi" | ghe-ssh "$host" /bin/bash) + for b in $backups + do + echo "Transferring $b to backup host" + ghe-ssh "$host" "sudo cat $appliance_dir/$b" > $backup_dir/$b + done +fi \ No newline at end of file From e19d978d7ca62992ca27920816eef070df7145ff Mon Sep 17 00:00:00 2001 From: ritchxu Date: Fri, 7 Feb 2020 14:18:36 -0500 Subject: [PATCH 0950/2421] Add restore part --- bin/ghe-restore | 3 ++ share/github-backup-utils/ghe-backup-mssql | 6 +-- share/github-backup-utils/ghe-restore-mssql | 45 +++++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100755 share/github-backup-utils/ghe-restore-mssql diff --git a/bin/ghe-restore b/bin/ghe-restore index 386eacdae..0d3210a81 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -255,6 +255,9 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then echo "Restoring MySQL database ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 +echo "Restoring MSSQL database ..." +ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 + echo "Restoring Redis database ..." bm_start "ghe-import-redis" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3 diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 3b46d2bbd..932ad4e8c 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -40,15 +40,15 @@ find_timestamp() { } # Find last snapshot to create potential hard links -count=$(ls $GHE_SNAPSHOT_DIR/.. | egrep '\d{8}T\d{6}' | sort | tail -2 | wc -l) +count=$(ls $GHE_DATA_DIR | egrep '\d{8}T\d{6}' | sort | tail -2 | wc -l) if [ $count -gt 1 ] then - last=$(ls $GHE_SNAPSHOT_DIR/.. | egrep '\d{8}T\d{6}' | sort | tail -2 | head -1) + last=$(ls $GHE_DATA_DIR | egrep '\d{8}T\d{6}' | sort | tail -2 | head -1) else unset last fi -last_mssql=$GHE_SNAPSHOT_DIR/../$last/mssql +last_mssql=$GHE_DATA_DIR/$last/mssql if [ -z $last ] || [ ! -d $last_mssql ] || [ -z $(find $last_mssql -type f -name "*.bak") ] then diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql new file mode 100755 index 000000000..c653b76a7 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-mssql @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-mssql +#/ Restore MSSQL backup to a GitHub Actions service instance. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the ghe-restore command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# The directory holding the snapshot to restore +snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" + +# Transfer backup files from appliance to backup host +appliance_dir="/data/user/mssql/backups" +echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh $GHE_HOSTNAME /bin/bash +for b in $(ls $snapshot_dir_mssql) +do + echo "Transferring $b to appliance host" + cat $snapshot_dir_mssql/$b | ghe-ssh $GHE_HOSTNAME "sudo tee -a $appliance_dir/$b >/dev/null 2>&1" +done + +# Change owner to mssql:mssql to ready for restore +ghe-ssh $GHE_HOSTNAME "sudo chown -R mssql:mssql $appliance_dir" + +# Invoke restore command +ghe-ssh $GHE_HOSTNAME -- "ghe-import-mssql" || failures="$failures mssql" + +bm_start "$(basename $0)" \ No newline at end of file From 00efedf7a17d15548303863383424dba933bdd2f Mon Sep 17 00:00:00 2001 From: ritchxu Date: Mon, 10 Feb 2020 10:58:14 -0500 Subject: [PATCH 0951/2421] Use ghe_verbose and PR comments --- share/github-backup-utils/ghe-backup-mssql | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 932ad4e8c..9835ae8a5 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -22,6 +22,17 @@ full_expire= diff_expire= tran_expire= +# Check if the export tool is available in this version +export_tool_available() { + ghe-ssh "$host" "test -e /usr/local/bin/ghe-export-mssql" +} + +if ! export_tool_available +then + ghe_verbose "ghe-export-mssql is not available" + exit +fi + add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS @@ -52,7 +63,7 @@ last_mssql=$GHE_DATA_DIR/$last/mssql if [ -z $last ] || [ ! -d $last_mssql ] || [ -z $(find $last_mssql -type f -name "*.bak") ] then - # Take initial full backup + ghe_verbose "Taking first full backup" take_full=1 backup_command='ghe-export-mssql' else @@ -67,7 +78,7 @@ else full_expire="${full_expire//T}" diff=$(find "$last_mssql" -type f -name "*.diff") - if [ ! -z $diff ] + if [ -f "$diff" ] then diff=$(find_timestamp $diff) diff_expire=$(add_minute $diff ${cadence[1]}) @@ -82,22 +93,22 @@ else tran_expire=$(add_minute $tran ${cadence[2]}) tran_expire="${tran_expire//T}" - echo "current $current, full expire $full_expire, diff expire $diff_expire, tran expire $tran_expire" + ghe_verbose "current $current, full expire $full_expire, diff expire $diff_expire, tran expire $tran_expire" # Determine the type of backup to take if [ $current -gt $full_expire ] then - echo "Taking full backup" + ghe_verbose "Taking full backup" take_full=1 backup_command='ghe-export-mssql' elif [ $current -gt $diff_expire ] then - echo "Taking diff backup" + ghe_verbose "Taking diff backup" take_diff=1 backup_command='ghe-export-mssql -d' elif [ $current -gt $tran_expire ] then - echo "Taking transaction backup" + ghe_verbose "Taking transaction backup" backup_command='ghe-export-mssql -t' fi fi @@ -106,7 +117,7 @@ fi mkdir -p "$backup_dir" # Create hard links to save disk space and time -if [ ! -z $last ] +if [ -d $last_mssql ] then for p in $(ls $last_mssql) do @@ -129,15 +140,15 @@ then transfer=1 fi - if [ ! -z $transfer ] + if [ -n "$transfer" ] then - echo "Creating hard link to $p" + ghe_verbose "Creating hard link to $p" ln $last_mssql/$p $backup_dir/$p fi done fi -if [ ! -z "$backup_command" ] +if [ -n "$backup_command" ] then bm_start "$(basename $0)" ghe-ssh "$host" -- "$backup_command" || failures="$failures mssql" @@ -148,7 +159,7 @@ then backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then sudo ls \"$appliance_dir\"; fi" | ghe-ssh "$host" /bin/bash) for b in $backups do - echo "Transferring $b to backup host" + ghe_verbose "Transferring $b to backup host" ghe-ssh "$host" "sudo cat $appliance_dir/$b" > $backup_dir/$b done fi \ No newline at end of file From 98bf12ba9f38a105130898fc4f74db89622e88ec Mon Sep 17 00:00:00 2001 From: ritchxu Date: Mon, 10 Feb 2020 12:26:13 -0500 Subject: [PATCH 0952/2421] Add documentation --- docs/backup-snapshot-file-structure.md | 18 ++++++++++++++++++ share/github-backup-utils/ghe-restore-mssql | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/backup-snapshot-file-structure.md b/docs/backup-snapshot-file-structure.md index 983c688c6..00221b6ba 100644 --- a/docs/backup-snapshot-file-structure.md +++ b/docs/backup-snapshot-file-structure.md @@ -32,6 +32,7 @@ most recent successful snapshot: |- enterprise.ghl |- es-scan-complete |- manage-password + |- mssql |- mysql.sql.gz |- redis.rdb |- settings.json @@ -44,3 +45,20 @@ most recent successful snapshot: Note: the `GHE_DATA_DIR` variable set in `backup.config` can be used to change the disk location where snapshots are written. + +## MS SQL Server backup structure +Actions service uses MS SQL Server as backend data store. Each snapshot includes a suite of backup files for MS SQL Server. + +To save time in backup, a three-level backup strategy is implemented. Based on the `GHE_MSSQL_BACKUP_CADENCE` setting, at each snapshot, either a (**F**)ull backup, a (**D**)ifferential or a (**T**)ransaction log backup is taken. + +As a result, a suite always contains a full backup, possibly a differential backup and at least one transaction log backup. Their relationship with timeline is demonstrated below: +``` +M-----8-----16----T-----8----16-----W... (timeline) + +F-----------------F-----------------F... (full backup) +#-----D-----D-----#-----D-----D-----#... (diff backup) +T--T--T--T--T--T--T--T--T--T--T--T--T... (tran. backup) +``` +To save disk space, at each snapshot, hard links are created to point to previous backup files. Whenever a new full/differential backup is created, they become the new base line for hard links for subsequent snapshots. + +During restore, a suite of backup files are restored in the sequence of full -> differential -> chronological transaction log. \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index c653b76a7..335be97a5 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -32,7 +32,7 @@ appliance_dir="/data/user/mssql/backups" echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh $GHE_HOSTNAME /bin/bash for b in $(ls $snapshot_dir_mssql) do - echo "Transferring $b to appliance host" + ghe_verbose "Transferring $b to appliance host" cat $snapshot_dir_mssql/$b | ghe-ssh $GHE_HOSTNAME "sudo tee -a $appliance_dir/$b >/dev/null 2>&1" done From 89aecf58f11585a8b2be6e49170638d28272afe2 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Tue, 11 Feb 2020 11:48:49 -0600 Subject: [PATCH 0953/2421] Use verbose flag to control ghe-export-mssql output --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 40fb1cb4a..6756c0a28 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -208,7 +208,7 @@ fi bm_end "ghe-export-mysql" echo "Backing up MSSQL databases ..." -ghe-backup-mssql || failures = "$failures mssql" +ghe-backup-mssql 1>&3 || failures = "$failures mssql" echo "Backing up Redis database ..." ghe-backup-redis > redis.rdb || failures="$failures redis" From 1d1a49415d67f1f80f5748a236539c1d34eb94e3 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Wed, 12 Feb 2020 15:15:27 -0500 Subject: [PATCH 0954/2421] Add test coverage --- docs/backup-snapshot-file-structure.md | 12 ++-- share/github-backup-utils/ghe-backup-mssql | 76 +++++++++------------ share/github-backup-utils/ghe-restore-mssql | 22 ++++-- test/bin/ghe-export-mssql | 1 + test/bin/ghe-import-mssql | 1 + test/test-ghe-backup.sh | 56 +++++++++++++++ test/test-ghe-restore.sh | 25 +++++++ test/testlib.sh | 45 ++++++++++++ 8 files changed, 182 insertions(+), 56 deletions(-) create mode 120000 test/bin/ghe-export-mssql create mode 120000 test/bin/ghe-import-mssql diff --git a/docs/backup-snapshot-file-structure.md b/docs/backup-snapshot-file-structure.md index 00221b6ba..2a950d63e 100644 --- a/docs/backup-snapshot-file-structure.md +++ b/docs/backup-snapshot-file-structure.md @@ -47,18 +47,18 @@ Note: the `GHE_DATA_DIR` variable set in `backup.config` can be used to change the disk location where snapshots are written. ## MS SQL Server backup structure -Actions service uses MS SQL Server as backend data store. Each snapshot includes a suite of backup files for MS SQL Server. +Actions service uses MS SQL Server as backend data store. Each snapshot includes a suite of backup files for MS SQL Server database(s). To save time in backup, a three-level backup strategy is implemented. Based on the `GHE_MSSQL_BACKUP_CADENCE` setting, at each snapshot, either a (**F**)ull backup, a (**D**)ifferential or a (**T**)ransaction log backup is taken. -As a result, a suite always contains a full backup, possibly a differential backup and at least one transaction log backup. Their relationship with timeline is demonstrated below: +As a result, a suite always contains following for each database: a full backup, possibly a differential backup and at least one transaction log backup. Their relationship with timeline is demonstrated below: ``` -M-----8-----16----T-----8----16-----W... (timeline) +M---8:00--16:00---T---8:00--16:00---W... (timeline) F-----------------F-----------------F... (full backup) -#-----D-----D-----#-----D-----D-----#... (diff backup) -T--T--T--T--T--T--T--T--T--T--T--T--T... (tran. backup) +#-----D-----D-----#-----D-----D-----#... (differential backup) +T--T--T--T--T--T--T--T--T--T--T--T--T... (transaction log backup) ``` -To save disk space, at each snapshot, hard links are created to point to previous backup files. Whenever a new full/differential backup is created, they become the new base line for hard links for subsequent snapshots. +To save disk space, at each snapshot, hard links are created to point to previous backup files. Only newly-created backup files are transferred from appliance to backup host. When a new full/differential backup is created, they become the new source for hard links and new base line for transaction log backups, for subsequent snapshots. During restore, a suite of backup files are restored in the sequence of full -> differential -> chronological transaction log. \ No newline at end of file diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 9835ae8a5..7d55b4a0c 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -11,7 +11,6 @@ set -e . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" # Set up remote host and root backup snapshot directory based on config -host="$GHE_HOSTNAME" backup_dir="$GHE_SNAPSHOT_DIR/mssql" last= last_mssql= @@ -24,11 +23,14 @@ tran_expire= # Check if the export tool is available in this version export_tool_available() { - ghe-ssh "$host" "test -e /usr/local/bin/ghe-export-mssql" + if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then + ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-export-mssql" + else + ghe-ssh "$GHE_HOSTNAME" "type ghe-export-mssql" + fi } -if ! export_tool_available -then +if ! export_tool_available; then ghe_verbose "ghe-export-mssql is not available" exit fi @@ -39,7 +41,8 @@ add_minute() { if date -v -1d > /dev/null 2>&1; then echo $(date -v+$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S) else - echo $(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} + $2 min") + echo $(date '+%Y%m%dT%H%M%S' \ + -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} + $2 min") fi } @@ -50,19 +53,10 @@ find_timestamp() { echo $datetime_part } -# Find last snapshot to create potential hard links -count=$(ls $GHE_DATA_DIR | egrep '\d{8}T\d{6}' | sort | tail -2 | wc -l) -if [ $count -gt 1 ] -then - last=$(ls $GHE_DATA_DIR | egrep '\d{8}T\d{6}' | sort | tail -2 | head -1) -else - unset last -fi - -last_mssql=$GHE_DATA_DIR/$last/mssql +last_mssql=$GHE_DATA_DIR/current/mssql -if [ -z $last ] || [ ! -d $last_mssql ] || [ -z $(find $last_mssql -type f -name "*.bak") ] -then +if [ ! -d $last_mssql ] \ + || [ -z "$(find $last_mssql -type f -name '*.bak' | head -n 1)" ]; then ghe_verbose "Taking first full backup" take_full=1 backup_command='ghe-export-mssql' @@ -72,14 +66,13 @@ else current=$(date -u +%Y%m%d%H%M%S) - full=$(find "$last_mssql" -type f -name "*.bak") + full=$(find "$last_mssql" -type f -name "*.bak" | head -n 1) full=$(find_timestamp $full) full_expire=$(add_minute $full ${cadence[0]}) full_expire="${full_expire//T}" - diff=$(find "$last_mssql" -type f -name "*.diff") - if [ -f "$diff" ] - then + diff=$(find "$last_mssql" -type f -name "*.diff" | head -n 1) + if [ -f "$diff" ]; then diff=$(find_timestamp $diff) diff_expire=$(add_minute $diff ${cadence[1]}) diff_expire="${diff_expire//T}" @@ -93,21 +86,19 @@ else tran_expire=$(add_minute $tran ${cadence[2]}) tran_expire="${tran_expire//T}" - ghe_verbose "current $current, full expire $full_expire, diff expire $diff_expire, tran expire $tran_expire" + ghe_verbose "current $current, full expire $full_expire, \ +diff expire $diff_expire, tran expire $tran_expire" # Determine the type of backup to take - if [ $current -gt $full_expire ] - then + if [ $current -gt $full_expire ]; then ghe_verbose "Taking full backup" take_full=1 backup_command='ghe-export-mssql' - elif [ $current -gt $diff_expire ] - then + elif [ $current -gt $diff_expire ]; then ghe_verbose "Taking diff backup" take_diff=1 backup_command='ghe-export-mssql -d' - elif [ $current -gt $tran_expire ] - then + elif [ $current -gt $tran_expire ]; then ghe_verbose "Taking transaction backup" backup_command='ghe-export-mssql -t' fi @@ -117,49 +108,44 @@ fi mkdir -p "$backup_dir" # Create hard links to save disk space and time -if [ -d $last_mssql ] -then +if [ -d $last_mssql ]; then for p in $(ls $last_mssql) do filename="${p##*/}" extension="${filename##*.}" transfer= - if [ $extension = "bak" ] && [ -z $take_full ] - then + if [ $extension = "bak" ] && [ -z $take_full ]; then transfer=1 fi - if [ $extension = "diff" ] && [ -z $take_full ] && [ -z $take_diff ] - then + if [ $extension = "diff" ] && [ -z $take_full ] && [ -z $take_diff ]; then transfer=1 fi - if [ $extension = "log" ] && [ -z $take_full ] && [ -z $take_diff ] - then + if [ $extension = "log" ] && [ -z $take_full ] && [ -z $take_diff ]; then transfer=1 fi - if [ -n "$transfer" ] - then + if [ -n "$transfer" ]; then ghe_verbose "Creating hard link to $p" ln $last_mssql/$p $backup_dir/$p fi done fi -if [ -n "$backup_command" ] -then +if [ -n "$backup_command" ]; then bm_start "$(basename $0)" - ghe-ssh "$host" -- "$backup_command" || failures="$failures mssql" + ghe-ssh "$GHE_HOSTNAME" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename $0)" # Transfer backup files from appliance to backup host - appliance_dir="/data/user/mssql/backups" - backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then sudo ls \"$appliance_dir\"; fi" | ghe-ssh "$host" /bin/bash) + appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" + backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then \ + sudo ls \"$appliance_dir\"; fi" | ghe-ssh "$GHE_HOSTNAME" /bin/bash) for b in $backups do - ghe_verbose "Transferring $b to backup host" - ghe-ssh "$host" "sudo cat $appliance_dir/$b" > $backup_dir/$b + ghe_verbose "Transferring to backup host $b" + ghe-ssh "$GHE_HOSTNAME" "sudo cat $appliance_dir/$b" > $backup_dir/$b done fi \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 335be97a5..c804724f0 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -12,7 +12,19 @@ set -e # Show usage and bail with no arguments [ -z "$*" ] && print_usage -bm_start "$(basename $0)" +# Check if the import tool is available in this version +import_tool_available() { + if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then + ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-import-mssql" + else + ghe-ssh "$GHE_HOSTNAME" "type ghe-import-mssql" + fi +} + +if ! import_tool_available; then + ghe_verbose "ghe-import-mssql is not available" + exit +fi # Grab host arg GHE_HOSTNAME="$1" @@ -28,7 +40,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" # Transfer backup files from appliance to backup host -appliance_dir="/data/user/mssql/backups" +appliance_dir="$GHE_REMOTE_DATA_USER_DIR/mssql/backups" echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh $GHE_HOSTNAME /bin/bash for b in $(ls $snapshot_dir_mssql) do @@ -40,6 +52,6 @@ done ghe-ssh $GHE_HOSTNAME "sudo chown -R mssql:mssql $appliance_dir" # Invoke restore command -ghe-ssh $GHE_HOSTNAME -- "ghe-import-mssql" || failures="$failures mssql" - -bm_start "$(basename $0)" \ No newline at end of file +bm_start "$(basename $0)" +ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-mssql" < "/dev/null" 1>&3 +bm_end "$(basename $0)" \ No newline at end of file diff --git a/test/bin/ghe-export-mssql b/test/bin/ghe-export-mssql new file mode 120000 index 000000000..a772e4ad9 --- /dev/null +++ b/test/bin/ghe-export-mssql @@ -0,0 +1 @@ +ghe-fake-export-command \ No newline at end of file diff --git a/test/bin/ghe-import-mssql b/test/bin/ghe-import-mssql new file mode 120000 index 000000000..bc329368a --- /dev/null +++ b/test/bin/ghe-import-mssql @@ -0,0 +1 @@ +ghe-fake-import-command \ No newline at end of file diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 9fe8eb9bb..5eaf831b8 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -344,3 +344,59 @@ begin_test "ghe-backup missing directories or files on source appliance" verify_all_backedup_data ) end_test + +GHE_MSSQL_BACKUP_CADENCE=10,5,1 +export GHE_MSSQL_BACKUP_CADENCE + +begin_test "ghe-backup takes full backup on first run" +( + # This test is required to run following tests + # It helps create "current" directory as symlink + # setup_mssql_backup_file uses "current" + set -e + + rm -rf $GHE_REMOTE_DATA_USER_DIR/mssql/backups/* + rm -rf $GHE_DATA_DIR/current/mssql/* + output=$(ghe-backup -v) + echo $output | grep "Taking first full backup" + echo $output | grep "fake ghe-export-mssql data" +) +end_test + +begin_test "ghe-backup takes full backup upon expiration" +( + set -e + + setup_mssql_backup_file "full_mssql" 11 "bak" + + output=$(ghe-backup -v) + echo $output | grep "Taking full backup" + ! echo $output | grep "Creating hard link to full_mssql@" +) +end_test + +begin_test "ghe-backup takes diff backup upon expiration" +( + set -e + + setup_mssql_backup_file "full_mssql" 7 "bak" + + output=$(ghe-backup -v) + echo $output | grep "Taking diff backup" + echo $output | egrep "Creating hard link to full_mssql@\d{8}T\d{6}\.bak" + ! echo $output | egrep "Creating hard link to full_mssql@\d{8}T\d{6}\.log" +) +end_test + +begin_test "ghe-backup takes transaction backup upon expiration" +( + set -e + + setup_mssql_backup_file "full_mssql" 3 "bak" + + output=$(ghe-backup -v) + echo $output | grep "Taking transaction backup" + echo $output | egrep "Creating hard link to full_mssql@\d{8}T\d{6}\.bak" + echo $output | egrep "Creating hard link to full_mssql@\d{8}T\d{6}\.log" +) +end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 499e3385b..c1ba32cf3 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -280,6 +280,31 @@ begin_test "ghe-restore with no pages backup" ) end_test +begin_test "ghe-restore invokes ghe-import-mssql" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # enable maintenance mode and create required directories + setup_maintenance_mode + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Restoring MSSQL database" "$TRASHDIR/restore-out" + grep -q "ghe-import-mssql .* OK" "$TRASHDIR/restore-out" +) +end_test + begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index c8182b911..113f29c3c 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -301,6 +301,10 @@ setup_test_data () { if [ "$loc" != "$GHE_REMOTE_DATA_USER_DIR" ]; then # create a fake backups for each datastore echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" + mkdir -p "$loc/mssql" + echo "fake ghe-export-mssql full data" > "$loc/mssql/mssql.bak" + echo "fake ghe-export-mssql diff data" > "$loc/mssql/mssql.diff" + echo "fake ghe-export-mssql tran data" > "$loc/mssql/mssql.log" echo "fake ghe-export-redis data" > "$loc/redis.rdb" echo "fake ghe-export-authorized-keys data" > "$loc/authorized-keys.json" echo "fake ghe-export-ssh-host-keys data" > "$TRASHDIR/ssh-host-keys" @@ -311,6 +315,11 @@ setup_test_data () { echo "fake password hash data" > "$loc/manage-password" echo "rsync" > "$loc/strategy" echo "$GHE_REMOTE_VERSION" > "$loc/version" + else + mkdir -p "$loc/mssql/backups" + echo "fake mssql full data" > "$loc/mssql/backups/mssql.bak" + echo "fake mssql diff data" > "$loc/mssql/backups/mssql.diff" + echo "fake mssql tran data" > "$loc/mssql/backups/mssql.log" fi } @@ -333,6 +342,9 @@ verify_common_data() { # verify the extracted repositories were transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" + # verify mssql backups were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/mssql/backups" "$GHE_DATA_DIR/current/mssql" + # tests that differ for cluster and single node backups and restores if [ "$(cat $GHE_DATA_DIR/current/strategy)" = "rsync" ]; then # verify the UUID was transferred @@ -380,6 +392,11 @@ verify_all_backedup_data() { # check that ca certificates were backed up [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] + # check that mssql databases were backed up + [ "$(cat "$GHE_DATA_DIR/current/mssql/mssql.bak")" = "fake mssql full data" ] + [ "$(cat "$GHE_DATA_DIR/current/mssql/mssql.diff")" = "fake mssql diff data" ] + [ "$(cat "$GHE_DATA_DIR/current/mssql/mssql.log")" = "fake mssql tran data" ] + # verify that ghe-backup wrote its version information to the host [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] @@ -431,3 +448,31 @@ verify_all_restored_data() { # verify common data verify_common_data } + +subtract_minute() { + # Expect date string in the format of yyyymmddTHHMMSS + # Here parse date differently depending on GNU Linux vs BSD MacOS + if date -v -1d > /dev/null 2>&1; then + echo $(date -v-$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S) + else + echo $(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} - $2 min") + fi +} + +setup_mssql_backup_file() { + # $1 name: @... + # $2 minutes ago + # $3 extension: bak, diff, log + rm -rf "$GHE_DATA_DIR/current/mssql" + mkdir -p "$GHE_DATA_DIR/current/mssql" + + current_utc=$(date -u +%Y%m%dT%H%M%S) + fake_last_utc=$(subtract_minute $current_utc $2) + + touch "$GHE_DATA_DIR/current/mssql/$1@$fake_last_utc.$3" + + # Simulate ghe-export-mssql behavior + if [ $3 = "bak" ] || [ $3 = "diff" ]; then + touch "$GHE_DATA_DIR/current/mssql/$1@$fake_last_utc.log" + fi +} From aa401aca91dce2b052074c228e157f489a9df2a1 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Fri, 21 Feb 2020 10:45:19 -0800 Subject: [PATCH 0955/2421] Backport mysql fix to patch release --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index a939c8d6d..150c93a77 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -79,7 +79,7 @@ else exit 2 else # legacy mode - IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + IMPORT_MYSQL="unpigz | ghe-import-mysql" GHE_RESTORE_HOST=$GHE_HOSTNAME fi fi From c47720682bf32f4c13ba0625a20e131f4766792b Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Fri, 21 Feb 2020 11:13:17 -0800 Subject: [PATCH 0956/2421] Bump version: 2.19.5 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 5fc9ba841..5fe9a687d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (2.19.5) UNRELEASED; urgency=medium + + * In legacy mode we should use ghe-import-mysql #581 + + -- Caine Jette Fri, 21 Feb 2020 19:13:17 +0000 + github-backup-utils (2.19.4) UNRELEASED; urgency=medium * Fix the way we connect to mysql master using ssh forwarding for binary backups #567 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 87ca3a54e..21be78bdb 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.19.4 +2.19.5 From ddd1f98988923aa6751cbef7dba36e936b7a8512 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Fri, 21 Feb 2020 16:07:05 -0500 Subject: [PATCH 0957/2421] Always return available for test --- share/github-backup-utils/ghe-backup-mssql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 7d55b4a0c..e53b3795e 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -26,7 +26,8 @@ export_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-export-mssql" else - ghe-ssh "$GHE_HOSTNAME" "type ghe-export-mssql" + # Always return available for test + return 0 fi } From aaf4cb980376dcc3037a1f9b07ef2d92dd462334 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Fri, 21 Feb 2020 16:49:53 -0500 Subject: [PATCH 0958/2421] Fix subtract_minute for Linux --- share/github-backup-utils/ghe-backup-mssql | 6 +++--- test/testlib.sh | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index e53b3795e..a7d528706 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -40,10 +40,10 @@ add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS if date -v -1d > /dev/null 2>&1; then - echo $(date -v+$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S) + echo $(date -v +$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S) else - echo $(date '+%Y%m%dT%H%M%S' \ - -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} + $2 min") + dt=$1 + echo $(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes") fi } diff --git a/test/testlib.sh b/test/testlib.sh index 113f29c3c..abb54ee7f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -453,9 +453,10 @@ subtract_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS if date -v -1d > /dev/null 2>&1; then - echo $(date -v-$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S) + echo $(date -v -$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S) else - echo $(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} - $2 min") + dt=$1 + echo $(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes ago") fi } From ba65c8f687b3c212ed3e762093757f1f0381f1ec Mon Sep 17 00:00:00 2001 From: ritchxu Date: Fri, 21 Feb 2020 17:41:47 -0500 Subject: [PATCH 0959/2421] Fix cross-plat regex --- share/github-backup-utils/ghe-backup-mssql | 2 +- test/test-ghe-backup.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index a7d528706..eb8d49380 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -82,7 +82,7 @@ else diff_expire="${diff_expire//T}" fi - tran=$(find "$last_mssql" -type f -name "*.log" | egrep '\d{8}T\d{6}' | sort | tail -1) + tran=$(find "$last_mssql" -type f -name "*.log" | egrep '[0-9]{8}T[0-9]{6}' | sort | tail -1) tran=$(find_timestamp $tran) tran_expire=$(add_minute $tran ${cadence[2]}) tran_expire="${tran_expire//T}" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 5eaf831b8..2c01de777 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -383,8 +383,8 @@ begin_test "ghe-backup takes diff backup upon expiration" output=$(ghe-backup -v) echo $output | grep "Taking diff backup" - echo $output | egrep "Creating hard link to full_mssql@\d{8}T\d{6}\.bak" - ! echo $output | egrep "Creating hard link to full_mssql@\d{8}T\d{6}\.log" + echo $output | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" + ! echo $output | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" ) end_test @@ -396,7 +396,7 @@ begin_test "ghe-backup takes transaction backup upon expiration" output=$(ghe-backup -v) echo $output | grep "Taking transaction backup" - echo $output | egrep "Creating hard link to full_mssql@\d{8}T\d{6}\.bak" - echo $output | egrep "Creating hard link to full_mssql@\d{8}T\d{6}\.log" + echo $output | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" + echo $output | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" ) end_test From 94d33d792992e85e58bba416606dba9ce235cb1b Mon Sep 17 00:00:00 2001 From: ritchxu Date: Fri, 21 Feb 2020 18:23:29 -0500 Subject: [PATCH 0960/2421] Fix issues found by shellcheck --- bin/ghe-backup | 2 +- share/github-backup-utils/ghe-backup-mssql | 17 +++++++++-------- share/github-backup-utils/ghe-restore-mssql | 9 ++++++--- test/testlib.sh | 4 ++-- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 6756c0a28..d77cab7a8 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -208,7 +208,7 @@ fi bm_end "ghe-export-mysql" echo "Backing up MSSQL databases ..." -ghe-backup-mssql 1>&3 || failures = "$failures mssql" +ghe-backup-mssql 1>&3 || failures="$failures mssql" echo "Backing up Redis database ..." ghe-backup-redis > redis.rdb || failures="$failures redis" diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index eb8d49380..608147109 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -12,7 +12,6 @@ set -e # Set up remote host and root backup snapshot directory based on config backup_dir="$GHE_SNAPSHOT_DIR/mssql" -last= last_mssql= backup_command= take_full= @@ -40,16 +39,16 @@ add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS if date -v -1d > /dev/null 2>&1; then - echo $(date -v +$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S) + echo "$(date -v +$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S)" else dt=$1 - echo $(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes") + echo "$(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes")" fi } find_timestamp() { filename="${1##*/}" - parts=(${filename//@/ }) + IFS='@' read -ra parts <<< "$filename" datetime_part=${parts[1]:0:15} echo $datetime_part } @@ -63,7 +62,7 @@ if [ ! -d $last_mssql ] \ backup_command='ghe-export-mssql' else # Check schedule to determine backup type - cadence=(${GHE_MSSQL_BACKUP_CADENCE//,/ }) + IFS=',' read -ra cadence <<< "$GHE_MSSQL_BACKUP_CADENCE" current=$(date -u +%Y%m%d%H%M%S) @@ -110,8 +109,10 @@ mkdir -p "$backup_dir" # Create hard links to save disk space and time if [ -d $last_mssql ]; then - for p in $(ls $last_mssql) + for p in $last_mssql/* do + [[ -e "$p" ]] || break + filename="${p##*/}" extension="${filename##*.}" transfer= @@ -129,8 +130,8 @@ if [ -d $last_mssql ]; then fi if [ -n "$transfer" ]; then - ghe_verbose "Creating hard link to $p" - ln $last_mssql/$p $backup_dir/$p + ghe_verbose "Creating hard link to $filename" + ln $last_mssql/$filename $backup_dir/$filename fi done fi diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index c804724f0..947a572af 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -42,10 +42,13 @@ snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_USER_DIR/mssql/backups" echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh $GHE_HOSTNAME /bin/bash -for b in $(ls $snapshot_dir_mssql) +for b in $snapshot_dir_mssql/* do - ghe_verbose "Transferring $b to appliance host" - cat $snapshot_dir_mssql/$b | ghe-ssh $GHE_HOSTNAME "sudo tee -a $appliance_dir/$b >/dev/null 2>&1" + [[ -e "$b" ]] || break + + filename="${b##*/}" + ghe_verbose "Transferring $filename to appliance host" + cat $snapshot_dir_mssql/$filename | ghe-ssh $GHE_HOSTNAME "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" done # Change owner to mssql:mssql to ready for restore diff --git a/test/testlib.sh b/test/testlib.sh index abb54ee7f..0379301a5 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -453,10 +453,10 @@ subtract_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS if date -v -1d > /dev/null 2>&1; then - echo $(date -v -$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S) + echo "$(date -v -$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S)" else dt=$1 - echo $(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes ago") + echo "$(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes ago")" fi } From 9a67f248a71aaa8133848fcaa61058952c8d6197 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 18 Mar 2020 20:40:57 -0400 Subject: [PATCH 0961/2421] Separate out ghe-backup-mysql from ghe-backup --- bin/ghe-backup | 18 +--------- share/github-backup-utils/ghe-backup-mysql | 40 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 17 deletions(-) create mode 100755 share/github-backup-utils/ghe-backup-mysql diff --git a/bin/ghe-backup b/bin/ghe-backup index 05f717bcc..f442909ba 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -174,24 +174,8 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar || failures="$failures ssh-host-keys" bm_end "ghe-export-ssh-host-keys" -# if we are going to take a binary backup -is_binary_backup(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" -} - echo "Backing up MySQL database ..." -bm_start "ghe-export-mysql" -export_command="ghe-export-mysql" -if ! is_binary_backup; then - # binary backup is already compressed - export_command+=" | pigz" -fi -echo "set -o pipefail; $export_command" | -ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz || failures="$failures mysql" -if is_binary_backup; then - echo "NO_ADDITIONAL_COMPRESSION" > mysql-binary-backup-sentinel -fi -bm_end "ghe-export-mysql" +ghe-backup-mysql || failures="$failures mysql" echo "Backing up Redis database ..." ghe-backup-redis > redis.rdb || failures="$failures redis" diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql new file mode 100755 index 000000000..077127eca --- /dev/null +++ b/share/github-backup-utils/ghe-backup-mysql @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-mysql +#/ Backup MySQL from a GitHub instance. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-backup command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. +ghe_remote_version_required "$GHE_HOSTNAME" + +# if we are going to take a binary backup +is_binary_backup_feature_on(){ + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" +} + +export_command="ghe-export-mysql" +if ! is_binary_backup_feature_on; then + # binary backup is already compressed + export_command+=" | pigz" +fi +echo "set -o pipefail; $export_command" | +ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz +if is_binary_backup_feature_on; then + echo "NO_ADDITIONAL_COMPRESSION" > mysql-binary-backup-sentinel +fi + +bm_end "$(basename $0)" From 2783fd1afb421a4ba851ef317e95e9b507e528bf Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 18 Mar 2020 20:49:41 -0400 Subject: [PATCH 0962/2421] Fix arguments --- share/github-backup-utils/ghe-backup-mysql | 6 ------ 1 file changed, 6 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 077127eca..722b9f6fc 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -10,14 +10,8 @@ set -e # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - bm_start "$(basename $0)" -# Grab host arg -GHE_HOSTNAME="$1" - # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" From 9c189b8368556d1c40225a03819dd1d552b1d77a Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 18 Mar 2020 20:55:17 -0400 Subject: [PATCH 0963/2421] backup to snapshot data dir --- share/github-backup-utils/ghe-backup-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 722b9f6fc..7926ee7ec 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -26,7 +26,7 @@ if ! is_binary_backup_feature_on; then export_command+=" | pigz" fi echo "set -o pipefail; $export_command" | -ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > mysql.sql.gz +ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" if is_binary_backup_feature_on; then echo "NO_ADDITIONAL_COMPRESSION" > mysql-binary-backup-sentinel fi From d4c4c4dc807c945207f38c420e45a309e9595045 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 18 Mar 2020 20:58:13 -0400 Subject: [PATCH 0964/2421] save sentinel file to data dir --- share/github-backup-utils/ghe-backup-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 7926ee7ec..983341461 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -28,7 +28,7 @@ fi echo "set -o pipefail; $export_command" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" if is_binary_backup_feature_on; then - echo "NO_ADDITIONAL_COMPRESSION" > mysql-binary-backup-sentinel + echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" fi bm_end "$(basename $0)" From b1e218d0a4339f53a48472d412f8f293787cc78e Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Thu, 19 Mar 2020 11:57:37 -0400 Subject: [PATCH 0965/2421] Not to install coreutils not to install coreutils as it is included in the image I saw following ``` Error: coreutils 8.31 is already installed 2526To upgrade to 8.32, run `brew upgrade coreutils`. 2527The command "brew install coreutils" failed and exited with 1 during . ``` --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 308e30ca9..caf0add82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ matrix: - brew install moreutils - brew install shellcheck - brew install jq - - brew install coreutils - brew install pigz script: make test - os: linux From 408d8c2fb9909f6f27a0d6af06f2a7e3580e2faf Mon Sep 17 00:00:00 2001 From: Rowena Foo <38323656+rwnfoo@users.noreply.github.com> Date: Fri, 27 Mar 2020 11:30:17 -0500 Subject: [PATCH 0966/2421] Add additional requirements to run in docker @droidpl and I were testing this out, and for the second example, @droidpl found that `GHE_EXTRA_SSH_OPTS` is a mandatory variable in the `backup.config` file or we'll run into SSH issues. --- docs/docker.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docker.md b/docs/docker.md index c9798e1b8..6e0785716 100644 --- a/docs/docker.md +++ b/docs/docker.md @@ -24,7 +24,7 @@ github/backup-utils ghe-backup It is also possible to specify a `-e GHE_BACKUP_CONFIG` flag and volume mount in a local `backup.config` file rather than specify the variables individually at -run time: +run time, as long as `GHE_HOSTNAME` and `GHE_EXTRA_SSH_OPTS` variables are configured : ``` $ docker run -it -e "GHE_BACKUP_CONFIG=/mnt/backup.config" \ From 7505e1bf3fa58a66215244cfd33cec9e7006d199 Mon Sep 17 00:00:00 2001 From: Dan Rigby Date: Mon, 30 Mar 2020 19:01:55 +0000 Subject: [PATCH 0967/2421] "WIP - Add --skip-pages flag to ghe-backup - Causes ghe-backup to skip backup of GitHub Pages generated artifacts" --- bin/ghe-backup | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index f442909ba..8d2ff5ff8 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -5,9 +5,10 @@ #/ the MySQL database, instance settings, GitHub Pages data, etc. #/ #/ OPTIONS: -#/ -v | --verbose Enable verbose output. -#/ -h | --help Show this message. -#/ --version Display version information. +#/ -v | --verbose Enable verbose output. +#/ -h | --help Show this message. +#/ --version Display version information. +#/ --skip-pages Skip backup of GitHub Pages artifacts. #/ set -e @@ -27,6 +28,10 @@ while true; do export GHE_VERBOSE=true shift ;; + --skip-pages) + export GHE_SKIP_PAGES=true + shift + ;; -*) echo "Error: invalid argument: '$1'" 1>&2 exit 1 @@ -189,8 +194,12 @@ ghe-backup-es-hookshot || failures="$failures hookshot" echo "Backing up Git repositories ..." ghe-backup-repositories || failures="$failures repositories" -echo "Backing up GitHub Pages ..." -ghe-backup-pages || failures="$failures pages" +if [ -z "$GHE_SKIP_PAGES" ]; then + echo "Backing up GitHub Pages artifacts ..." + ghe-backup-pages || failures="$failures pages" +else + echo "Skipping backup of GitHub Pages artifacts ..." +fi echo "Backing up storage data ..." ghe-backup-storage || failures="$failures storage" From 8b25261204805fac78d18b953db5588099c7db28 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Mon, 30 Mar 2020 22:07:16 +0000 Subject: [PATCH 0968/2421] add parameter to ghe-restore to skip pages restore --- bin/ghe-restore | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 386eacdae..8ee7a377d 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -9,21 +9,22 @@ #/ #/ #/ OPTIONS: -#/ -f | --force Don't prompt for confirmation before restoring. -#/ -c | --config Restore appliance settings and license in addition to -#/ datastores. Settings are not restored by default to -#/ prevent overwriting different configuration on the -#/ restore host. -#/ -v | --verbose Enable verbose output. -#/ -h | --help Show this message. -#/ --version Display version information and exit. -#/ -s Restore from the snapshot with the given id. Available -#/ snapshots may be listed under the data directory. -#/ The is the hostname or IP of the GitHub Enterprise -#/ instance. The may be omitted when the -#/ GHE_RESTORE_HOST config variable is set in backup.config. -#/ When a argument is provided, it always overrides -#/ the configured restore host. +#/ -f | --force Don't prompt for confirmation before restoring. +#/ -c | --config Restore appliance settings and license in addition to +#/ datastores. Settings are not restored by default to +#/ prevent overwriting different configuration on the +#/ restore host. +#/ --skip-pages Skip backup of GitHub Pages artifacts. +#/ -v | --verbose Enable verbose output. +#/ -h | --help Show this message. +#/ --version Display version information and exit. +#/ -s Restore from the snapshot with the given id. Available +#/ snapshots may be listed under the data directory. +#/ The is the hostname or IP of the GitHub Enterprise +#/ instance. The may be omitted when the +#/ GHE_RESTORE_HOST config variable is set in backup.config. +#/ When a argument is provided, it always overrides +#/ the configured restore host. #/ set -e @@ -45,6 +46,10 @@ while true; do restore_settings=true shift ;; + --skip-pages) + export GHE_SKIP_PAGES=true + shift + ;; -h|--help) export GHE_SHOW_HELP=true shift @@ -268,8 +273,12 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; the echo "Restoring Gists ..." ghe-restore-repositories-gist "$GHE_HOSTNAME" - echo "Restoring GitHub Pages ..." - ghe-restore-pages "$GHE_HOSTNAME" 1>&3 + if [ -z "$GHE_SKIP_PAGES" ]; then + echo "Restoring GitHub Pages artifacts ..." + ghe-restore-pages "$GHE_HOSTNAME" 1>&3 + else + echo "Skipping restore of GitHub Pages artifacts ..." + fi else echo "Restoring Git repositories and Gists ..." ghe-restore-repositories-rsync "$GHE_HOSTNAME" 1>&3 From 62325c7932fffafaa738d4b250a985dcffd27787 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Mon, 30 Mar 2020 23:33:01 +0000 Subject: [PATCH 0969/2421] add logic for skipping pages when backup does not have it --- share/github-backup-utils/ghe-restore-pages | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 9bd51b7ac..a65debf42 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -23,7 +23,17 @@ GHE_HOSTNAME="$1" : ${GHE_RESTORE_SNAPSHOT:=current} # Find the pages to restore -pages_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 -maxdepth 5 | cut -d / -f2-) + +check_pages=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 -maxdepth 5 2> /dev/null) + +# Check if there were pages in backup, if no skip restore +if [[ $? -ne 0 ]]; then + echo "Skipping: No Pages artifact backup ..." + exit 0 +fi + +# Otherwise Find the path +pages_paths="$(echo "$check_pages" | cut -d / -f2-)" # No need to restore anything, early exit if [ -z "$pages_paths" ]; then From 3c87304ad37bb453917c97c5c86d663c3b0006ed Mon Sep 17 00:00:00 2001 From: Dan Rigby Date: Tue, 31 Mar 2020 14:25:34 +0000 Subject: [PATCH 0970/2421] Fix typo in restore script help --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 8ee7a377d..4f638cbd4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -14,7 +14,7 @@ #/ datastores. Settings are not restored by default to #/ prevent overwriting different configuration on the #/ restore host. -#/ --skip-pages Skip backup of GitHub Pages artifacts. +#/ --skip-pages Skip restore of GitHub Pages artifacts. #/ -v | --verbose Enable verbose output. #/ -h | --help Show this message. #/ --version Display version information and exit. From 1969b35cea0417cb245319b6c4e7237c6183ef80 Mon Sep 17 00:00:00 2001 From: "Courtney (CJ) Oka" <16140724+oakeyc@users.noreply.github.com> Date: Tue, 31 Mar 2020 10:32:32 -0700 Subject: [PATCH 0971/2421] remove extra line Co-Authored-By: Caine Jette --- share/github-backup-utils/ghe-restore-pages | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index a65debf42..8fc9084a1 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -23,7 +23,6 @@ GHE_HOSTNAME="$1" : ${GHE_RESTORE_SNAPSHOT:=current} # Find the pages to restore - check_pages=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 -maxdepth 5 2> /dev/null) # Check if there were pages in backup, if no skip restore From b9989c4e9764cd7aed0a0bb2997d1e50789df29c Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 31 Mar 2020 11:51:37 -0700 Subject: [PATCH 0972/2421] Introduce configuration to skip restoring of audit logs --- backup.config-example | 3 +++ bin/ghe-restore | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backup.config-example b/backup.config-example index 1ea7fb61f..1fc3571c8 100644 --- a/backup.config-example +++ b/backup.config-example @@ -43,6 +43,9 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_CREATE_DATA_DIR=yes +# If set to 'no', skip restoring audit logs to speed up restore time +RESTORE_AUDIT_LOGS=no + # If set to 'yes', git fsck will run on the repositories # and print some additional info. # diff --git a/bin/ghe-restore b/bin/ghe-restore index 386eacdae..4e2c60168 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -301,8 +301,12 @@ fi # Restore exported audit and hookshot logs to 2.12.9 and newer single nodes and # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then - echo "Restoring Audit logs ..." - ghe-restore-audit-log "$GHE_HOSTNAME" 1>&3 + if [[ "$RESTORE_AUDIT_LOGS" = "yes" ]]; then + echo "Restoring Audit logs ..." + ghe-restore-audit-log "$GHE_HOSTNAME" 1>&3 + else + echo "Skipping restore of audit logs." + fi echo "Restoring hookshot logs ..." ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 From 407f772b98d7c2c2052ebc067843629022da6c8e Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 31 Mar 2020 11:55:01 -0700 Subject: [PATCH 0973/2421] Move configuration higher in the file --- backup.config-example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup.config-example b/backup.config-example index 1fc3571c8..2a81bb8e6 100644 --- a/backup.config-example +++ b/backup.config-example @@ -23,6 +23,9 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_RESTORE_HOST="github-standby.example.com" +# If set to 'no', skip restoring audit logs to speed up restore time +RESTORE_AUDIT_LOGS=yes + # When verbose output is enabled with `-v`, it's written to stdout by default. If # you'd prefer it to be written to a separate file, set this option. # @@ -43,9 +46,6 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_CREATE_DATA_DIR=yes -# If set to 'no', skip restoring audit logs to speed up restore time -RESTORE_AUDIT_LOGS=no - # If set to 'yes', git fsck will run on the repositories # and print some additional info. # From f8d966d7dacbd3c5b20ad7d0f0341928881c6a4a Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 31 Mar 2020 11:56:38 -0700 Subject: [PATCH 0974/2421] Prefix configuration with GHE_ for consistency --- backup.config-example | 2 +- bin/ghe-restore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backup.config-example b/backup.config-example index 2a81bb8e6..26bf2f1c7 100644 --- a/backup.config-example +++ b/backup.config-example @@ -24,7 +24,7 @@ GHE_NUM_SNAPSHOTS=10 #GHE_RESTORE_HOST="github-standby.example.com" # If set to 'no', skip restoring audit logs to speed up restore time -RESTORE_AUDIT_LOGS=yes +GHE_RESTORE_AUDIT_LOGS=yes # When verbose output is enabled with `-v`, it's written to stdout by default. If # you'd prefer it to be written to a separate file, set this option. diff --git a/bin/ghe-restore b/bin/ghe-restore index 4e2c60168..a36b104f3 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -301,7 +301,7 @@ fi # Restore exported audit and hookshot logs to 2.12.9 and newer single nodes and # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then - if [[ "$RESTORE_AUDIT_LOGS" = "yes" ]]; then + if [[ "$GHE_RESTORE_AUDIT_LOGS" = "yes" ]]; then echo "Restoring Audit logs ..." ghe-restore-audit-log "$GHE_HOSTNAME" 1>&3 else From 946287c773b9c24a14835b5dd02df8fb1dc48845 Mon Sep 17 00:00:00 2001 From: Dan Rigby Date: Tue, 31 Mar 2020 19:13:02 +0000 Subject: [PATCH 0975/2421] Switch to using a config setting instead of a flag --- backup.config-example | 9 +++++++++ bin/ghe-backup | 17 ++++++----------- bin/ghe-restore | 41 ++++++++++++++++++----------------------- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/backup.config-example b/backup.config-example index 1ea7fb61f..6d2dba245 100644 --- a/backup.config-example +++ b/backup.config-example @@ -48,3 +48,12 @@ GHE_NUM_SNAPSHOTS=10 # # WARNING: do not enable this, only useful for debugging/development #GHE_BACKUP_FSCK=no + +# If set to 'yes', ghe-backup will omit the backup of Pages artifacts. +# +#GHE_BACKUP_SKIP_PAGES=no + +# If set to 'yes', ghe-restore will omit the restore of Pages artifacts +# contained in the backup and will rebuild them instead. +# +#GHE_RESTORE_SKIP_PAGES=no diff --git a/bin/ghe-backup b/bin/ghe-backup index 8d2ff5ff8..1bb5c6e60 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -5,10 +5,9 @@ #/ the MySQL database, instance settings, GitHub Pages data, etc. #/ #/ OPTIONS: -#/ -v | --verbose Enable verbose output. -#/ -h | --help Show this message. -#/ --version Display version information. -#/ --skip-pages Skip backup of GitHub Pages artifacts. +#/ -v | --verbose Enable verbose output. +#/ -h | --help Show this message. +#/ --version Display version information. #/ set -e @@ -28,10 +27,6 @@ while true; do export GHE_VERBOSE=true shift ;; - --skip-pages) - export GHE_SKIP_PAGES=true - shift - ;; -*) echo "Error: invalid argument: '$1'" 1>&2 exit 1 @@ -194,11 +189,11 @@ ghe-backup-es-hookshot || failures="$failures hookshot" echo "Backing up Git repositories ..." ghe-backup-repositories || failures="$failures repositories" -if [ -z "$GHE_SKIP_PAGES" ]; then +if [ "$GHE_RESTORE_SKIP_PAGES" = "yes" ]; then + echo "Skipping backup of GitHub Pages artifacts ..." +else echo "Backing up GitHub Pages artifacts ..." ghe-backup-pages || failures="$failures pages" -else - echo "Skipping backup of GitHub Pages artifacts ..." fi echo "Backing up storage data ..." diff --git a/bin/ghe-restore b/bin/ghe-restore index 4f638cbd4..fd75bb87e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -9,22 +9,21 @@ #/ #/ #/ OPTIONS: -#/ -f | --force Don't prompt for confirmation before restoring. -#/ -c | --config Restore appliance settings and license in addition to -#/ datastores. Settings are not restored by default to -#/ prevent overwriting different configuration on the -#/ restore host. -#/ --skip-pages Skip restore of GitHub Pages artifacts. -#/ -v | --verbose Enable verbose output. -#/ -h | --help Show this message. -#/ --version Display version information and exit. -#/ -s Restore from the snapshot with the given id. Available -#/ snapshots may be listed under the data directory. -#/ The is the hostname or IP of the GitHub Enterprise -#/ instance. The may be omitted when the -#/ GHE_RESTORE_HOST config variable is set in backup.config. -#/ When a argument is provided, it always overrides -#/ the configured restore host. +#/ -f | --force Don't prompt for confirmation before restoring. +#/ -c | --config Restore appliance settings and license in addition to +#/ datastores. Settings are not restored by default to +#/ prevent overwriting different configuration on the +#/ restore host. +#/ -v | --verbose Enable verbose output. +#/ -h | --help Show this message. +#/ --version Display version information and exit. +#/ -s Restore from the snapshot with the given id. Available +#/ snapshots may be listed under the data directory. +#/ The is the hostname or IP of the GitHub Enterprise +#/ instance. The may be omitted when the +#/ GHE_RESTORE_HOST config variable is set in backup.config. +#/ When a argument is provided, it always overrides +#/ the configured restore host. #/ set -e @@ -46,10 +45,6 @@ while true; do restore_settings=true shift ;; - --skip-pages) - export GHE_SKIP_PAGES=true - shift - ;; -h|--help) export GHE_SHOW_HELP=true shift @@ -273,11 +268,11 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; the echo "Restoring Gists ..." ghe-restore-repositories-gist "$GHE_HOSTNAME" - if [ -z "$GHE_SKIP_PAGES" ]; then + if [ "$GHE_RESTORE_SKIP_PAGES" = "yes" ]; then + echo "Skipping restore of GitHub Pages artifacts ..." + else echo "Restoring GitHub Pages artifacts ..." ghe-restore-pages "$GHE_HOSTNAME" 1>&3 - else - echo "Skipping restore of GitHub Pages artifacts ..." fi else echo "Restoring Git repositories and Gists ..." From 9585b3b12dcbed8e11ab4308ce9c6644197b7b2a Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 31 Mar 2020 12:26:24 -0700 Subject: [PATCH 0976/2421] Switch flag default --- backup.config-example | 4 ++-- bin/ghe-restore | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backup.config-example b/backup.config-example index 26bf2f1c7..8b43cc5a1 100644 --- a/backup.config-example +++ b/backup.config-example @@ -23,8 +23,8 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_RESTORE_HOST="github-standby.example.com" -# If set to 'no', skip restoring audit logs to speed up restore time -GHE_RESTORE_AUDIT_LOGS=yes +# If set to 'yes', skip restoring audit logs to speed up restore time. +#GHE_RESTORE_SKIP_AUDIT_LOGS=no # When verbose output is enabled with `-v`, it's written to stdout by default. If # you'd prefer it to be written to a separate file, set this option. diff --git a/bin/ghe-restore b/bin/ghe-restore index a36b104f3..b7448eebf 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -301,11 +301,11 @@ fi # Restore exported audit and hookshot logs to 2.12.9 and newer single nodes and # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then - if [[ "$GHE_RESTORE_AUDIT_LOGS" = "yes" ]]; then + if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then + echo "Skipping restore of audit logs." + else echo "Restoring Audit logs ..." ghe-restore-audit-log "$GHE_HOSTNAME" 1>&3 - else - echo "Skipping restore of audit logs." fi echo "Restoring hookshot logs ..." From 9089ab2c3aa4253227454507a651cb73a7b622bd Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 31 Mar 2020 12:28:02 -0700 Subject: [PATCH 0977/2421] Add newline comment for consistency --- backup.config-example | 1 + 1 file changed, 1 insertion(+) diff --git a/backup.config-example b/backup.config-example index 8b43cc5a1..9451a57f2 100644 --- a/backup.config-example +++ b/backup.config-example @@ -24,6 +24,7 @@ GHE_NUM_SNAPSHOTS=10 #GHE_RESTORE_HOST="github-standby.example.com" # If set to 'yes', skip restoring audit logs to speed up restore time. +# #GHE_RESTORE_SKIP_AUDIT_LOGS=no # When verbose output is enabled with `-v`, it's written to stdout by default. If From 5a4b69ad5dd26e9a4be576866aea2aeb071c9966 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 31 Mar 2020 12:32:10 -0700 Subject: [PATCH 0978/2421] Change wording to match pages PR --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 9451a57f2..4a339dd29 100644 --- a/backup.config-example +++ b/backup.config-example @@ -23,7 +23,7 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_RESTORE_HOST="github-standby.example.com" -# If set to 'yes', skip restoring audit logs to speed up restore time. +# If set to 'yes', ghe-restore will omit the restore of audit logs. # #GHE_RESTORE_SKIP_AUDIT_LOGS=no From 8dd54a3c156ee7f83df084e4a62ce5e4823df1d5 Mon Sep 17 00:00:00 2001 From: Dan Rigby Date: Tue, 31 Mar 2020 20:03:38 +0000 Subject: [PATCH 0979/2421] Move check for pages in backup to ghe-restore --- bin/ghe-restore | 8 ++++++-- share/github-backup-utils/ghe-restore-pages | 11 +---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index fd75bb87e..ebe1f7e5f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -271,8 +271,12 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; the if [ "$GHE_RESTORE_SKIP_PAGES" = "yes" ]; then echo "Skipping restore of GitHub Pages artifacts ..." else - echo "Restoring GitHub Pages artifacts ..." - ghe-restore-pages "$GHE_HOSTNAME" 1>&3 + if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/pages" ]; then + echo "Restoring GitHub Pages artifacts ..." + ghe-restore-pages "$GHE_HOSTNAME" 1>&3 + else + echo "No GitHub Pages artifacts found in backup, skipping restore ..." + fi fi else echo "Restoring Git repositories and Gists ..." diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 8fc9084a1..9bd51b7ac 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -23,16 +23,7 @@ GHE_HOSTNAME="$1" : ${GHE_RESTORE_SNAPSHOT:=current} # Find the pages to restore -check_pages=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 -maxdepth 5 2> /dev/null) - -# Check if there were pages in backup, if no skip restore -if [[ $? -ne 0 ]]; then - echo "Skipping: No Pages artifact backup ..." - exit 0 -fi - -# Otherwise Find the path -pages_paths="$(echo "$check_pages" | cut -d / -f2-)" +pages_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 -maxdepth 5 | cut -d / -f2-) # No need to restore anything, early exit if [ -z "$pages_paths" ]; then From 09313784ab2fb2c149ca36ba63374bf3733562b2 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Tue, 31 Mar 2020 21:42:45 +0000 Subject: [PATCH 0980/2421] wrong env var --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 1bb5c6e60..b88de85f3 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -189,7 +189,7 @@ ghe-backup-es-hookshot || failures="$failures hookshot" echo "Backing up Git repositories ..." ghe-backup-repositories || failures="$failures repositories" -if [ "$GHE_RESTORE_SKIP_PAGES" = "yes" ]; then +if [ "$GHE_BACKUP_SKIP_PAGES" = "yes" ]; then echo "Skipping backup of GitHub Pages artifacts ..." else echo "Backing up GitHub Pages artifacts ..." From 76d654e3a30b8048d26e38f4645b3b03573dc56d Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Wed, 1 Apr 2020 10:57:43 -0700 Subject: [PATCH 0981/2421] add configuration + skip pages --- docs/usage.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 94f163797..166e5f011 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -10,7 +10,13 @@ After the initial backup, use the following commands: These commands are run on the host you [installed][1] Backup Utilities on. -### Example backup and restore usage +## Understanding Configuration + +Users can supply their own configuration file or use the example configuration file as a template where they can set up their environment for backing up and restoring. + +Among other levers, here is where you can specify if you want to skip backing up and/or reestoring pages artifacts with `GHE_BACKUP_SKIP_PAGES` and `GHE_RESTORE_SKIP_PAGES` respectively. + +## Example backup and restore usage The following assumes that `GHE_HOSTNAME` is set to "github.example.com" in `backup.config`. From 99ae0de3a15caf01cd13493394cda56cfe077220 Mon Sep 17 00:00:00 2001 From: "Courtney (CJ) Oka" <16140724+oakeyc@users.noreply.github.com> Date: Wed, 1 Apr 2020 11:24:30 -0700 Subject: [PATCH 0982/2421] Update docs/usage.md Co-Authored-By: Dan Rigby --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 166e5f011..a68ce8d1f 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -14,7 +14,7 @@ These commands are run on the host you [installed][1] Backup Utilities on. Users can supply their own configuration file or use the example configuration file as a template where they can set up their environment for backing up and restoring. -Among other levers, here is where you can specify if you want to skip backing up and/or reestoring pages artifacts with `GHE_BACKUP_SKIP_PAGES` and `GHE_RESTORE_SKIP_PAGES` respectively. +An example configuration file with documentation on possible settings can found in [backup.config-example](../backup.config-example). ## Example backup and restore usage From 2c7331484f4a60103c028a3048ba999d9635e33b Mon Sep 17 00:00:00 2001 From: "Courtney (CJ) Oka" <16140724+oakeyc@users.noreply.github.com> Date: Wed, 1 Apr 2020 11:24:49 -0700 Subject: [PATCH 0983/2421] Update docs/usage.md Co-Authored-By: Caine Jette --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index a68ce8d1f..247153633 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -10,7 +10,7 @@ After the initial backup, use the following commands: These commands are run on the host you [installed][1] Backup Utilities on. -## Understanding Configuration +## Configuring backup and restore behavior Users can supply their own configuration file or use the example configuration file as a template where they can set up their environment for backing up and restoring. From ab3441c477bc620f738ab485e2490b83485f8d5b Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Wed, 1 Apr 2020 11:39:29 -0700 Subject: [PATCH 0984/2421] wording --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 166e5f011..f0fef6c06 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -12,7 +12,7 @@ These commands are run on the host you [installed][1] Backup Utilities on. ## Understanding Configuration -Users can supply their own configuration file or use the example configuration file as a template where they can set up their environment for backing up and restoring. +You can supply your own configuration file or use the example configuration file as a template where you can set up your environment for backing up and restoring. Among other levers, here is where you can specify if you want to skip backing up and/or reestoring pages artifacts with `GHE_BACKUP_SKIP_PAGES` and `GHE_RESTORE_SKIP_PAGES` respectively. From d0e56ef7597af7f45315f3e954db84fe84e56970 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 1 Apr 2020 12:02:22 -0700 Subject: [PATCH 0985/2421] Fix description of GHE_RESTORE_SKIP_PAGES config setting --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 6d2dba245..1cfe29fb4 100644 --- a/backup.config-example +++ b/backup.config-example @@ -54,6 +54,6 @@ GHE_NUM_SNAPSHOTS=10 #GHE_BACKUP_SKIP_PAGES=no # If set to 'yes', ghe-restore will omit the restore of Pages artifacts -# contained in the backup and will rebuild them instead. +# contained in the backup. # #GHE_RESTORE_SKIP_PAGES=no From a5107e1da97e74b1c02cddde1880b267bc2d2d62 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Tue, 31 Mar 2020 14:02:33 -0700 Subject: [PATCH 0986/2421] Execute ghe-backup tasks in parallel --- Dockerfile | 1 + bin/ghe-backup | 63 +++++++++++++-------- docs/requirements.md | 3 +- share/github-backup-utils/ghe-backup-config | 23 +++++++- 4 files changed, 63 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6dcecacd8..c50c35113 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ RUN apt-get -q -y update && \ ca-certificates \ ssh \ git \ + moreutils \ && rm -rf /var/lib/apt/lists/* WORKDIR /backup-utils diff --git a/bin/ghe-backup b/bin/ghe-backup index f35367992..38205a572 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -41,8 +41,13 @@ done # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" +# Check to make sure moreutils parallel is installed and working properly +ghe_parallel_check + # Used to record failed backup steps failures= +tempdir="$(mktemp -d -t backup-utils-backup-XXXXXX)" +failures_file="$tempdir/failures" # CPU and IO throttling to keep backups from thrashing around. export GHE_NICE=${GHE_NICE:-"nice -n 19"} @@ -100,6 +105,8 @@ cleanup () { fi fi + rm -rf "$tempdir" + # Cleanup SSH multiplexing ghe-ssh --clean } @@ -177,34 +184,40 @@ bm_end "ghe-export-ssh-host-keys" echo "Backing up MySQL database ..." ghe-backup-mysql || failures="$failures mysql" -echo "Backing up Redis database ..." -ghe-backup-redis > redis.rdb || failures="$failures redis" - -echo "Backing up audit log ..." -ghe-backup-es-audit-log || failures="$failures audit-log" - -echo "Backing up hookshot logs ..." -ghe-backup-es-hookshot || failures="$failures hookshot" - -echo "Backing up Git repositories ..." -ghe-backup-repositories || failures="$failures repositories" - -if [ "$GHE_BACKUP_SKIP_PAGES" = "yes" ]; then - echo "Skipping backup of GitHub Pages artifacts ..." +$parallel_command -- " +echo \"Backing up Redis database ...\" +ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\" +" " +echo \"Backing up audit log ...\" +ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\" +" " +echo \"Backing up hookshot logs ...\" +ghe-backup-es-hookshot || printf %s \"hookshot \" >> \"$failures_file\" +" " +echo \"Backing up Git repositories ...\" +ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\" +" " +if [ \"$GHE_BACKUP_SKIP_PAGES\" = \"yes\" ]; then + echo \"Skipping backup of GitHub Pages artifacts ...\" else - echo "Backing up GitHub Pages artifacts ..." - ghe-backup-pages || failures="$failures pages" + echo \"Backing up GitHub Pages artifacts ...\" + ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\" fi +" " +echo \"Backing up storage data ...\" +ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\" +" " +echo \"Backing up custom Git hooks ...\" +ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\" +" " +if [ \"$GHE_BACKUP_STRATEGY\" = \"rsync\" ]; then + echo \"Backing up Elasticsearch indices ...\" + ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\" +fi +" -echo "Backing up storage data ..." -ghe-backup-storage || failures="$failures storage" - -echo "Backing up custom Git hooks ..." -ghe-backup-git-hooks || failures="$failures git-hooks" - -if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then - echo "Backing up Elasticsearch indices ..." - ghe-backup-es-rsync || failures="$failures elasticsearch" +if [ -f "$failures_file" ]; then + failures="$failures $(cat "$failures_file")" fi # git fsck repositories after the backup diff --git a/docs/requirements.md b/docs/requirements.md index d91079bc2..221e290d3 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -6,7 +6,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements Backup host software requirements are modest: Linux or other modern Unix operating -system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. +system with [bash][1], [git][2], [moreutils parallel][9], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. We encourage the use of [Docker](docker.md) if your backup host doesn't meet these requirements, or if Docker is your preferred platform. @@ -58,3 +58,4 @@ be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapsh [6]: https://en.wikipedia.org/wiki/Symbolic_link [7]: https://en.wikipedia.org/wiki/Case_sensitivity [8]: https://help.github.com/enterprise/admin/guides/installation/upgrade-requirements/ +[9]: https://joeyh.name/code/moreutils diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index ad5454582..fb7e95ef0 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,6 +66,26 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done +# Check that moreutils ts has been installed +if ! echo "moreutils" | ts &>/dev/null; then + echo "Error: moreutils not found. Please install https://joeyh.name/code/moreutils" 1>&2 + exit 1 +fi + +ghe_parallel_check() { + # Some machines may have both moreutils parallel and GNU parallel installed. + parallel_command="parallel" + if [ -x "/usr/bin/parallel.moreutils" ]; then + parallel_command="/usr/bin/parallel.moreutils" + fi + + # Check that the parallel_command is pointing to moreutils parallel + if ! $parallel_command -h | grep -q "parallel \[OPTIONS\] command -- arguments"; then + echo "Error: moreutils not found. Please install https://joeyh.name/code/moreutils" 1>&2 + exit 1 + fi +} + # Check that the config file exists before we source it in. if ! $config_found; then echo "Error: No backup configuration file found. Tried:" 1>&2 @@ -80,7 +100,8 @@ fi # otherwise, redirect it to /dev/null. Write verbose output to fd 3. if [ -n "$GHE_VERBOSE" ]; then if [ -n "$GHE_VERBOSE_LOG" ]; then - exec 3>> "$GHE_VERBOSE_LOG" + calling_script_name="$(caller | sed 's:.*/::')" + exec 3> >(sed "s/^/$calling_script_name: /" | ts >> "$GHE_VERBOSE_LOG") else exec 3>&1 fi From 85a9369cb79815f23283853e7c0c882b0ef5da03 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Thu, 2 Apr 2020 09:04:41 -0700 Subject: [PATCH 0987/2421] Add GHE_PARALLEL_ENABLED, MAX_JOBS and MAX_LOAD --- bin/ghe-backup | 2 +- share/github-backup-utils/ghe-backup-config | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 38205a572..e1c50a96d 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -184,7 +184,7 @@ bm_end "ghe-export-ssh-host-keys" echo "Backing up MySQL database ..." ghe-backup-mysql || failures="$failures mysql" -$parallel_command -- " +$GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- " echo \"Backing up Redis database ...\" ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\" " " diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index fb7e95ef0..f1cfbad57 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -74,16 +74,29 @@ fi ghe_parallel_check() { # Some machines may have both moreutils parallel and GNU parallel installed. - parallel_command="parallel" + GHE_PARALLEL_COMMAND="parallel" if [ -x "/usr/bin/parallel.moreutils" ]; then - parallel_command="/usr/bin/parallel.moreutils" + GHE_PARALLEL_COMMAND="/usr/bin/parallel.moreutils" fi - # Check that the parallel_command is pointing to moreutils parallel - if ! $parallel_command -h | grep -q "parallel \[OPTIONS\] command -- arguments"; then + # Check that the GHE_PARALLEL_COMMAND is pointing to moreutils parallel + if ! $GHE_PARALLEL_COMMAND -h | grep -q "parallel \[OPTIONS\] command -- arguments"; then echo "Error: moreutils not found. Please install https://joeyh.name/code/moreutils" 1>&2 exit 1 fi + + GHE_PARALLEL_COMMAND_OPTIONS="" + if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then + GHE_PARALLEL_MAX_JOBS="1" + GHE_PARALLEL_MAX_LOAD="" + fi + + if [ -n "$GHE_PARALLEL_MAX_JOBS" ]; then + GHE_PARALLEL_COMMAND_OPTIONS="-j $GHE_PARALLEL_MAX_JOBS" + fi + if [ -n "$GHE_PARALLEL_MAX_LOAD" ]; then + GHE_PARALLEL_COMMAND_OPTIONS+=" -l $GHE_PARALLEL_MAX_LOAD" + fi } # Check that the config file exists before we source it in. From b115c690ee0bd5cdc547776754241f67b0a2b1fd Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Thu, 2 Apr 2020 09:40:21 -0700 Subject: [PATCH 0988/2421] Remove tempdir in ghe-backup --- bin/ghe-backup | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index e1c50a96d..d7d2fefcc 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -46,8 +46,7 @@ ghe_parallel_check # Used to record failed backup steps failures= -tempdir="$(mktemp -d -t backup-utils-backup-XXXXXX)" -failures_file="$tempdir/failures" +failures_file="$(mktemp -t backup-utils-backup-failures-XXXXXX)" # CPU and IO throttling to keep backups from thrashing around. export GHE_NICE=${GHE_NICE:-"nice -n 19"} @@ -105,7 +104,7 @@ cleanup () { fi fi - rm -rf "$tempdir" + rm -rf "$failures_file" # Cleanup SSH multiplexing ghe-ssh --clean From 7186a46cdec982ab36152bde62d3a425ff4d13b9 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Thu, 2 Apr 2020 10:41:38 -0700 Subject: [PATCH 0989/2421] Fixup backup tests --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index d7d2fefcc..bfadb9936 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -215,7 +215,7 @@ if [ \"$GHE_BACKUP_STRATEGY\" = \"rsync\" ]; then fi " -if [ -f "$failures_file" ]; then +if [ -s "$failures_file" ]; then failures="$failures $(cat "$failures_file")" fi From d15ccc70f22f5febda87604316a42e52a971ff72 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Thu, 2 Apr 2020 12:14:48 -0700 Subject: [PATCH 0990/2421] Remove verbose log redirect test --- test/test-ghe-backup-config.sh | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 3c78d16b1..0a1fa955a 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -127,16 +127,3 @@ begin_test "ghe-backup-config ghe_parse_remote_version v2.x series" ) end_test -begin_test "ghe-backup-config verbose log redirects to file" -( - set -e - - export GHE_VERBOSE=1 - export GHE_VERBOSE_LOG="$TRASHDIR/verbose.log" - . "share/github-backup-utils/ghe-backup-config" - ghe_verbose "Hello world" - [ "$(wc -l <"$GHE_VERBOSE_LOG")" -gt 0 ] - unset GHE_VERBOSE - unset GHE_VERBOSE_LOG -) -end_test From 91eec24ec1ab9f4986a21afeaa209de39e807dc9 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Thu, 2 Apr 2020 16:15:44 -0700 Subject: [PATCH 0991/2421] with notes --- share/github-backup-utils/ghe-restore-repositories | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index c87c8b421..66e40d07e 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -139,6 +139,9 @@ fi # rsync all the repository networks to the git server where they belong. # One rsync invocation per server available. + +# NOTES(oakeyc): Can we parallelize the calls to each server? (this was attempted in https://github.com/github/backup-utils/pull/456/files) +# We could leverage changes: https://github.com/github/backup-utils/pull/597/files bm_start "$(basename $0) - Restoring repository networks" for file_list in $tempdir/*.rsync; do if $CLUSTER; then @@ -172,6 +175,8 @@ fi bm_start "$(basename $0) - Updating repository info data" if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" + + # NOTES(oakeyc): Can we parallelize the calls to each host? for hostname in $hostnames; do if ! ghe-rsync -av --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ From 874ba4d2c44f54bb8fadf418b34658610e646576 Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Thu, 2 Apr 2020 16:42:11 -0700 Subject: [PATCH 0992/2421] rough draft parallel --- .../ghe-restore-repositories | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 66e40d07e..b7f2bd5fb 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -139,9 +139,6 @@ fi # rsync all the repository networks to the git server where they belong. # One rsync invocation per server available. - -# NOTES(oakeyc): Can we parallelize the calls to each server? (this was attempted in https://github.com/github/backup-utils/pull/456/files) -# We could leverage changes: https://github.com/github/backup-utils/pull/597/files bm_start "$(basename $0) - Restoring repository networks" for file_list in $tempdir/*.rsync; do if $CLUSTER; then @@ -155,8 +152,17 @@ for file_list in $tempdir/*.rsync; do --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 + "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 & +done +for pid in $(jobs -p); do + wait $pid + ret_code=$? + if [ "$ret_code" != "0" ]; then + echo "$pid exited $ret_code" + #exit $ret_code + fi done + bm_end "$(basename $0) - Restoring repository networks" # Tell dgit about the repositories restored @@ -176,16 +182,24 @@ bm_start "$(basename $0) - Updating repository info data" if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" - # NOTES(oakeyc): Can we parallelize the calls to each host? for hostname in $hostnames; do - if ! ghe-rsync -av --delete \ + + ghe-rsync -av --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to $hostname" 1>&2 + "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3 & + done + + for pid in $(jobs -p); do + wait $pid + ret_code=$? + if [ "$ret_code" != "0" ]; then + echo "$pid exited $ret_code" + #exit $ret_code fi done + else ghe_verbose "* Removing repository info data" if $CLUSTER; then From 020b2f5617ded1c0151698345a3341c5f36f8eac Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Fri, 3 Apr 2020 10:53:09 -0700 Subject: [PATCH 0993/2421] Fix verbose log buffering --- share/github-backup-utils/ghe-backup-config | 8 +------- test/test-ghe-backup-config.sh | 22 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index f1cfbad57..c796e5891 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,12 +66,6 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done -# Check that moreutils ts has been installed -if ! echo "moreutils" | ts &>/dev/null; then - echo "Error: moreutils not found. Please install https://joeyh.name/code/moreutils" 1>&2 - exit 1 -fi - ghe_parallel_check() { # Some machines may have both moreutils parallel and GNU parallel installed. GHE_PARALLEL_COMMAND="parallel" @@ -114,7 +108,7 @@ fi if [ -n "$GHE_VERBOSE" ]; then if [ -n "$GHE_VERBOSE_LOG" ]; then calling_script_name="$(caller | sed 's:.*/::')" - exec 3> >(sed "s/^/$calling_script_name: /" | ts >> "$GHE_VERBOSE_LOG") + exec 3> >(awk -v c=$calling_script_name '{ print strftime("%b %d %H:%M:%S"), c":", $0; fflush(); }' >> "$GHE_VERBOSE_LOG") else exec 3>&1 fi diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 0a1fa955a..5505decca 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -127,3 +127,25 @@ begin_test "ghe-backup-config ghe_parse_remote_version v2.x series" ) end_test +begin_test "ghe-backup-config verbose log redirects to file" +( + set -e + + export GHE_VERBOSE=1 + export GHE_VERBOSE_LOG="$TRASHDIR/verbose.log" + . "share/github-backup-utils/ghe-backup-config" + ghe_verbose "Hello world" + for i in {1..60} + do + if [ "$(wc -l <"$GHE_VERBOSE_LOG")" -gt 0 ]; then + unset GHE_VERBOSE + unset GHE_VERBOSE_LOG + exit 0 + fi + echo "Waiting for log to be written $i" + sleep 1 + done + + exit 1 +) +end_test From fa8db38c274f1d9aa31bcfb446fa58e594844fe5 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Fri, 3 Apr 2020 12:40:07 -0700 Subject: [PATCH 0994/2421] Update README.md to include req for moreutils --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 83f832896..011a562e9 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ This repository includes backup and recovery utilities for [GitHub Enterprise Server][1]. +**UPDATE**: `ghe-backup` now requires the installation of [moreutils](https://joeyh.name/code/moreutils). + **Note**: the [GitHub Enterprise Server version requirements][2] have changed starting with Backup Utilities v2.13.0, released on 27 March 2018. From 23061a83e2c24cc69ab3c823f862f13316bc29ab Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Fri, 3 Apr 2020 13:01:05 -0700 Subject: [PATCH 0995/2421] Add check for awk --- .travis.yml | 1 + README.md | 2 +- share/github-backup-utils/ghe-backup-config | 5 +++++ test/test-ghe-backup-config.sh | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index caf0add82..9a5a2fc14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ matrix: - os: osx before_install: - brew update + - brew install gawk - brew install gnu-tar - brew install moreutils - brew install shellcheck diff --git a/README.md b/README.md index 011a562e9..b7e6a228f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository includes backup and recovery utilities for [GitHub Enterprise Server][1]. -**UPDATE**: `ghe-backup` now requires the installation of [moreutils](https://joeyh.name/code/moreutils). +**UPDATE**: `backup-utils` now requires [awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils). **Note**: the [GitHub Enterprise Server version requirements][2] have changed starting with Backup Utilities v2.13.0, released on 27 March 2018. diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index c796e5891..93b0f48e4 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,6 +66,11 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done +if ! echo | awk '{ print strftime("%b %d %H:%M:%S"); fflush(); }' &>/dev/null; then + echo "Error: awk not found. Please install https://www.gnu.org/software/gawk" 1>&2 + exit 1 +fi + ghe_parallel_check() { # Some machines may have both moreutils parallel and GNU parallel installed. GHE_PARALLEL_COMMAND="parallel" diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 5505decca..afaa8dfac 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -135,14 +135,14 @@ begin_test "ghe-backup-config verbose log redirects to file" export GHE_VERBOSE_LOG="$TRASHDIR/verbose.log" . "share/github-backup-utils/ghe-backup-config" ghe_verbose "Hello world" - for i in {1..60} + for i in {1..5} do if [ "$(wc -l <"$GHE_VERBOSE_LOG")" -gt 0 ]; then unset GHE_VERBOSE unset GHE_VERBOSE_LOG exit 0 fi - echo "Waiting for log to be written $i" + echo "Waiting for log file to be written $i" sleep 1 done From 0e1907d4c2e52972552d1e41484c29e76a3c57ac Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Fri, 3 Apr 2020 18:06:40 -0700 Subject: [PATCH 0996/2421] Update documentation for parallel backups --- backup.config-example | 18 ++++++++++++++++++ docs/requirements.md | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 7c46142fc..640da87c7 100644 --- a/backup.config-example +++ b/backup.config-example @@ -61,3 +61,21 @@ GHE_NUM_SNAPSHOTS=10 # contained in the backup. # #GHE_RESTORE_SKIP_PAGES=no + +# If set to 'yes', ghe-backup jobs will run in parallel. Defaults to 'no'. +# +# WARNING: this feature is in beta. +#GHE_PARALLEL_ENABLED=yes + +# Sets the maximum number of jobs to run in parallel. Defaults to the number +# of available processing units on the machine. +# +# WARNING: this feature is in beta. +#GHE_PARALLEL_MAX_JOBS=2 + +# When jobs are running in parallel wait as needed to avoid starting new jobs +# when the system's load average is not below the specified limit. Defaults to +# unrestricted. +# +# WARNING: this feature is in beta. +GHE_PARALLEL_MAX_LOAD=50 diff --git a/docs/requirements.md b/docs/requirements.md index 221e290d3..c5635d183 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -6,7 +6,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements Backup host software requirements are modest: Linux or other modern Unix operating -system with [bash][1], [git][2], [moreutils parallel][9], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. +system with [awk][10], [bash][1], [git][2], [moreutils][9], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. We encourage the use of [Docker](docker.md) if your backup host doesn't meet these requirements, or if Docker is your preferred platform. @@ -59,3 +59,4 @@ be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapsh [7]: https://en.wikipedia.org/wiki/Case_sensitivity [8]: https://help.github.com/enterprise/admin/guides/installation/upgrade-requirements/ [9]: https://joeyh.name/code/moreutils +[10]: https://www.gnu.org/software/gawk \ No newline at end of file From 7561b14efc9718f21b8109f07d0f61cccd76086b Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Fri, 3 Apr 2020 18:14:11 -0700 Subject: [PATCH 0997/2421] Add gawk to Dockerfile --- Dockerfile | 1 + README.md | 2 +- docs/requirements.md | 2 +- share/github-backup-utils/ghe-backup-config | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c50c35113..4cf1ef888 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ RUN apt-get -q -y update && \ ssh \ git \ moreutils \ + gawk \ && rm -rf /var/lib/apt/lists/* WORKDIR /backup-utils diff --git a/README.md b/README.md index b7e6a228f..fc44d68ae 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository includes backup and recovery utilities for [GitHub Enterprise Server][1]. -**UPDATE**: `backup-utils` now requires [awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils). +**UPDATE**: `backup-utils` now requires [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils). **Note**: the [GitHub Enterprise Server version requirements][2] have changed starting with Backup Utilities v2.13.0, released on 27 March 2018. diff --git a/docs/requirements.md b/docs/requirements.md index c5635d183..2e30571d3 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -6,7 +6,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements Backup host software requirements are modest: Linux or other modern Unix operating -system with [awk][10], [bash][1], [git][2], [moreutils][9], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. +system with [GNU awk][10], [bash][1], [git][2], [moreutils][9], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. We encourage the use of [Docker](docker.md) if your backup host doesn't meet these requirements, or if Docker is your preferred platform. diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 93b0f48e4..3f3bf1015 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -67,7 +67,7 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ done if ! echo | awk '{ print strftime("%b %d %H:%M:%S"); fflush(); }' &>/dev/null; then - echo "Error: awk not found. Please install https://www.gnu.org/software/gawk" 1>&2 + echo "Error: awk command failed. Please install https://www.gnu.org/software/gawk" 1>&2 exit 1 fi From d263c8acfc2fad1ae0976e3e5e191afa22844368 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Sat, 4 Apr 2020 15:40:59 -0700 Subject: [PATCH 0998/2421] Do not require moreutils parallel to be installed --- bin/ghe-backup | 54 +++++++++++++-------- share/github-backup-utils/ghe-backup-config | 11 ++--- test/test-ghe-backup-parallel.sh | 9 ++++ 3 files changed, 48 insertions(+), 26 deletions(-) create mode 100755 test/test-ghe-backup-parallel.sh diff --git a/bin/ghe-backup b/bin/ghe-backup index bfadb9936..acf246ec7 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -183,37 +183,51 @@ bm_end "ghe-export-ssh-host-keys" echo "Backing up MySQL database ..." ghe-backup-mysql || failures="$failures mysql" -$GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- " +commands=(" echo \"Backing up Redis database ...\" -ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\" -" " +ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"") + +commands+=(" echo \"Backing up audit log ...\" -ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\" -" " +ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"") + +commands+=(" echo \"Backing up hookshot logs ...\" -ghe-backup-es-hookshot || printf %s \"hookshot \" >> \"$failures_file\" -" " +ghe-backup-es-hookshot || printf %s \"hookshot \" >> \"$failures_file\"") + +commands+=(" echo \"Backing up Git repositories ...\" -ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\" -" " -if [ \"$GHE_BACKUP_SKIP_PAGES\" = \"yes\" ]; then - echo \"Skipping backup of GitHub Pages artifacts ...\" +ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") + +if [ "$GHE_BACKUP_SKIP_PAGES" = "yes" ]; then + echo "Skipping backup of GitHub Pages artifacts ..." else + commands+=(" echo \"Backing up GitHub Pages artifacts ...\" - ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\" + ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") fi -" " + +commands+=(" echo \"Backing up storage data ...\" -ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\" -" " +ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\"") + +commands+=(" echo \"Backing up custom Git hooks ...\" -ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\" -" " -if [ \"$GHE_BACKUP_STRATEGY\" = \"rsync\" ]; then +ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"") + +if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then + commands+=(" echo \"Backing up Elasticsearch indices ...\" - ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\" + ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\"") +fi + +if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then + $GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}" +else + for c in "${commands[@]}"; do + eval "$c" + done fi -" if [ -s "$failures_file" ]; then failures="$failures $(cat "$failures_file")" diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 3f3bf1015..ce616ae27 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -72,6 +72,10 @@ if ! echo | awk '{ print strftime("%b %d %H:%M:%S"); fflush(); }' &>/dev/null; t fi ghe_parallel_check() { + if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then + return 0 + fi + # Some machines may have both moreutils parallel and GNU parallel installed. GHE_PARALLEL_COMMAND="parallel" if [ -x "/usr/bin/parallel.moreutils" ]; then @@ -84,15 +88,10 @@ ghe_parallel_check() { exit 1 fi - GHE_PARALLEL_COMMAND_OPTIONS="" - if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then - GHE_PARALLEL_MAX_JOBS="1" - GHE_PARALLEL_MAX_LOAD="" - fi - if [ -n "$GHE_PARALLEL_MAX_JOBS" ]; then GHE_PARALLEL_COMMAND_OPTIONS="-j $GHE_PARALLEL_MAX_JOBS" fi + if [ -n "$GHE_PARALLEL_MAX_LOAD" ]; then GHE_PARALLEL_COMMAND_OPTIONS+=" -l $GHE_PARALLEL_MAX_LOAD" fi diff --git a/test/test-ghe-backup-parallel.sh b/test/test-ghe-backup-parallel.sh new file mode 100755 index 000000000..c36b98a0d --- /dev/null +++ b/test/test-ghe-backup-parallel.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# ghe-backup command tests run in parallel +set -e + +export GHE_PARALLEL_ENABLED=yes + +TESTS_DIR="$PWD/$(dirname "$0")" +# shellcheck source=test/test-ghe-backup.sh +. "$TESTS_DIR/test-ghe-backup.sh" From 4b62f04e975e828a19777f1d67bb59a051b41314 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Sun, 5 Apr 2020 11:33:07 -0700 Subject: [PATCH 0999/2421] Do not require gawk to be installed --- share/github-backup-utils/ghe-backup-config | 17 ++++++++++------- test/test-ghe-backup-config.sh | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index ce616ae27..13247f43c 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,11 +66,6 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done -if ! echo | awk '{ print strftime("%b %d %H:%M:%S"); fflush(); }' &>/dev/null; then - echo "Error: awk command failed. Please install https://www.gnu.org/software/gawk" 1>&2 - exit 1 -fi - ghe_parallel_check() { if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then return 0 @@ -111,8 +106,16 @@ fi # otherwise, redirect it to /dev/null. Write verbose output to fd 3. if [ -n "$GHE_VERBOSE" ]; then if [ -n "$GHE_VERBOSE_LOG" ]; then - calling_script_name="$(caller | sed 's:.*/::')" - exec 3> >(awk -v c=$calling_script_name '{ print strftime("%b %d %H:%M:%S"), c":", $0; fflush(); }' >> "$GHE_VERBOSE_LOG") + if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then + exec 3>> "$GHE_VERBOSE_LOG" + else + if ! echo | awk '{ print strftime("%b %d %H:%M:%S"); fflush(); }' &>/dev/null; then + echo "Error: awk command failed. Please install https://www.gnu.org/software/gawk" 1>&2 + exit 1 + fi + calling_script_name="$(caller | sed 's:.*/::')" + exec 3> >(awk -v c=$calling_script_name '{ print strftime("%b %d %H:%M:%S"), c":", $0; fflush(); }' >> "$GHE_VERBOSE_LOG") + fi else exec 3>&1 fi diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index afaa8dfac..84ef5c526 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -131,6 +131,20 @@ begin_test "ghe-backup-config verbose log redirects to file" ( set -e + export GHE_VERBOSE=1 + export GHE_VERBOSE_LOG="$TRASHDIR/verbose.log" + . "share/github-backup-utils/ghe-backup-config" + ghe_verbose "Hello world" + [ "$(wc -l <"$GHE_VERBOSE_LOG")" -gt 0 ] + unset GHE_VERBOSE + unset GHE_VERBOSE_LOG +) + +begin_test "ghe-backup-config verbose log redirects to file under parallel" +( + set -e + + export GHE_PARALLEL_ENABLED=yes export GHE_VERBOSE=1 export GHE_VERBOSE_LOG="$TRASHDIR/verbose.log" . "share/github-backup-utils/ghe-backup-config" From c8eccf802cff475154ac5312c39377982e97671e Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Sun, 5 Apr 2020 17:31:17 -0700 Subject: [PATCH 1000/2421] Fix ghe-backup leaked ssh key test --- test/bin/ghe-export-ssh-host-keys | 20 +++++++++++++++++--- test/bin/ghe-gen-fake-ssh-tar | 10 ---------- test/test-ghe-backup.sh | 9 ++------- 3 files changed, 19 insertions(+), 20 deletions(-) delete mode 100755 test/bin/ghe-gen-fake-ssh-tar diff --git a/test/bin/ghe-export-ssh-host-keys b/test/bin/ghe-export-ssh-host-keys index 919af4767..7e7dd57a1 100755 --- a/test/bin/ghe-export-ssh-host-keys +++ b/test/bin/ghe-export-ssh-host-keys @@ -1,4 +1,18 @@ #!/usr/bin/env bash -echo "fake ghe-export-ssh-host-keys data" > tmp/ssh-host-keys -tar -C tmp -cf - ssh-host-keys -rm -f tmp/ssh-host-keys + +if [ "$GHE_GEN_FAKE_SSH_TAR" = "yes" ]; then + set -x + # Add a custom ssh key that will be used as part of the backup and fingerprint injection for the tests + cat < "$GHE_REMOTE_DATA_USER_DIR/common/ssh_host_dsa_key.pub" +ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils +EOF + + tar -cf - -C "$GHE_REMOTE_DATA_USER_DIR/common" ssh_host_dsa_key.pub + set +x +else + ssh_tempdir="$(mktemp -d -t ssh-host-keys-XXXXXX)" + echo "fake ghe-export-ssh-host-keys data" > "$ssh_tempdir/ssh-host-keys" + tar -C "$ssh_tempdir" -cf - ssh-host-keys + mv "$ssh_tempdir/ssh-host-keys.tar" "tmp/ssh-host-keys.tar" + rm -rf "$ssh_tempdir" +fi diff --git a/test/bin/ghe-gen-fake-ssh-tar b/test/bin/ghe-gen-fake-ssh-tar deleted file mode 100755 index 163711178..000000000 --- a/test/bin/ghe-gen-fake-ssh-tar +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -set -x -# Add a custom ssh key that will be used as part of the backup and fingerprint injection for the tests -cat < "$GHE_REMOTE_DATA_USER_DIR/common/ssh_host_dsa_key.pub" -ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils -EOF - -tar -cf - -C "$GHE_REMOTE_DATA_USER_DIR/common" ssh_host_dsa_key.pub -set +x diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index e0d01cf92..a58ce1f3d 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -190,11 +190,7 @@ begin_test "ghe-backup with leaked SSH host key detection for current backup" ( set -e - # Rename ghe-export-ssh-keys to generate a fake ssh - cd "$ROOTDIR/test/bin" - mv "ghe-export-ssh-host-keys" "ghe-export-ssh-host-keys.orig" - ln -s ghe-gen-fake-ssh-tar ghe-export-ssh-host-keys - cd - + export GHE_GEN_FAKE_SSH_TAR="yes" # Inject the fingerprint into the blacklist export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" @@ -202,8 +198,7 @@ begin_test "ghe-backup with leaked SSH host key detection for current backup" # Run it output=$(ghe-backup -v) - # Set the export ssh back - mv "$ROOTDIR/test/bin/ghe-export-ssh-host-keys.orig" "$ROOTDIR/test/bin/ghe-export-ssh-host-keys" + unset GHE_GEN_FAKE_SSH_TAR # Test the output for leaked key detection echo $output| grep "The current backup contains leaked SSH host keys" From 097158a1d62c85c8289b688823fa5f0c8274e42b Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Mon, 6 Apr 2020 11:21:03 -0700 Subject: [PATCH 1001/2421] Update documentation --- README.md | 2 +- backup.config-example | 2 +- docs/requirements.md | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fc44d68ae..5de138c87 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository includes backup and recovery utilities for [GitHub Enterprise Server][1]. -**UPDATE**: `backup-utils` now requires [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils). +**UPDATE**: The new parallel backup and restore beta feature, will require [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils) to be installed. **Note**: the [GitHub Enterprise Server version requirements][2] have changed starting with Backup Utilities v2.13.0, released on 27 March 2018. diff --git a/backup.config-example b/backup.config-example index 640da87c7..594bdc3c9 100644 --- a/backup.config-example +++ b/backup.config-example @@ -78,4 +78,4 @@ GHE_NUM_SNAPSHOTS=10 # unrestricted. # # WARNING: this feature is in beta. -GHE_PARALLEL_MAX_LOAD=50 +#GHE_PARALLEL_MAX_LOAD=50 diff --git a/docs/requirements.md b/docs/requirements.md index 2e30571d3..9e1424826 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -6,7 +6,9 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements Backup host software requirements are modest: Linux or other modern Unix operating -system with [GNU awk][10], [bash][1], [git][2], [moreutils][9], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. +system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. + +The new parallel backup and restore beta feature, will require [GNU awk][10] and [moreutils][9] to be installed. We encourage the use of [Docker](docker.md) if your backup host doesn't meet these requirements, or if Docker is your preferred platform. From 719ee291f943f83d16aa96c4f68115762b071384 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Mon, 6 Apr 2020 16:42:22 -0700 Subject: [PATCH 1002/2421] PR feedback --- README.md | 2 +- backup.config-example | 2 +- docs/requirements.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5de138c87..de483cf5f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository includes backup and recovery utilities for [GitHub Enterprise Server][1]. -**UPDATE**: The new parallel backup and restore beta feature, will require [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils) to be installed. +**UPDATE**: The new parallel backup and restore beta feature will require [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils) to be installed. **Note**: the [GitHub Enterprise Server version requirements][2] have changed starting with Backup Utilities v2.13.0, released on 27 March 2018. diff --git a/backup.config-example b/backup.config-example index 594bdc3c9..a1b4c0870 100644 --- a/backup.config-example +++ b/backup.config-example @@ -74,7 +74,7 @@ GHE_NUM_SNAPSHOTS=10 #GHE_PARALLEL_MAX_JOBS=2 # When jobs are running in parallel wait as needed to avoid starting new jobs -# when the system's load average is not below the specified limit. Defaults to +# when the system's load average is not below the specified percentage. Defaults to # unrestricted. # # WARNING: this feature is in beta. diff --git a/docs/requirements.md b/docs/requirements.md index 9e1424826..f6a1ba3d8 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -8,7 +8,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app Backup host software requirements are modest: Linux or other modern Unix operating system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. -The new parallel backup and restore beta feature, will require [GNU awk][10] and [moreutils][9] to be installed. +The new parallel backup and restore beta feature will require [GNU awk][10] and [moreutils][9] to be installed. We encourage the use of [Docker](docker.md) if your backup host doesn't meet these requirements, or if Docker is your preferred platform. From 947ca62824697a13d08e1c45384f053d0e89f120 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Sat, 4 Apr 2020 14:33:36 -0700 Subject: [PATCH 1003/2421] Execute ghe-restore tasks in parallel --- bin/ghe-restore | 74 +++++++++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index f01beec19..3f2f1704a 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -85,6 +85,9 @@ cleanup () { # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" +# Check to make sure moreutils parallel is installed and working properly +ghe_parallel_check + # Grab the host arg GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" @@ -255,50 +258,57 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then echo "Restoring MySQL database ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 -echo "Restoring Redis database ..." -bm_start "ghe-import-redis" -ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3 -bm_end "ghe-import-redis" +commands=(" +echo \"Restoring Redis database ...\" +ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") # Unified and enhanced restore method to 2.13.0 and newer if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; then - echo "Restoring Git repositories ..." - ghe-restore-repositories "$GHE_HOSTNAME" + commands+=(" + echo \"Restoring Git repositories ...\" + ghe-restore-repositories \"$GHE_HOSTNAME\"") - echo "Restoring Gists ..." - ghe-restore-repositories-gist "$GHE_HOSTNAME" + commands+=(" + echo \"Restoring Gists ...\" + ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") if [ "$GHE_RESTORE_SKIP_PAGES" = "yes" ]; then echo "Skipping restore of GitHub Pages artifacts ..." else if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/pages" ]; then - echo "Restoring GitHub Pages artifacts ..." - ghe-restore-pages "$GHE_HOSTNAME" 1>&3 + commands+=(" + echo \"Restoring GitHub Pages artifacts ...\" + ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") else echo "No GitHub Pages artifacts found in backup, skipping restore ..." fi fi else - echo "Restoring Git repositories and Gists ..." - ghe-restore-repositories-rsync "$GHE_HOSTNAME" 1>&3 + commands+=(" + echo \"Restoring Git repositories and Gists ...\" + ghe-restore-repositories-rsync \"$GHE_HOSTNAME\" 1>&3") - echo "Restoring GitHub Pages ..." - ghe-restore-pages-rsync "$GHE_HOSTNAME" 1>&3 + commands+=(" + echo \"Restoring GitHub Pages ...\" + ghe-restore-pages-rsync \"$GHE_HOSTNAME\" 1>&3") fi +commands+=(" +echo \"Restoring SSH authorized keys ...\" +ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") -echo "Restoring SSH authorized keys ..." -ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json" 1>&3 - -echo "Restoring storage data ..." -ghe-restore-storage "$GHE_HOSTNAME" 1>&3 +commands+=(" +echo \"Restoring storage data ...\" +ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") -echo "Restoring custom Git hooks ..." -ghe-restore-git-hooks "$GHE_HOSTNAME" 1>&3 +commands+=(" +echo \"Restoring custom Git hooks ...\" +ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then - echo "Restoring Elasticsearch indices ..." - ghe-restore-es-rsync "$GHE_HOSTNAME" 1>&3 + commands+=(" + echo \"Restoring Elasticsearch indices ...\" + ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") fi # Restore the audit log migration sentinel file, if it exists in the snapshot @@ -312,12 +322,22 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then echo "Skipping restore of audit logs." else - echo "Restoring Audit logs ..." - ghe-restore-es-audit-log "$GHE_HOSTNAME" 1>&3 + commands+=(" + echo \"Restoring Audit logs ...\" + ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi + + commands+=(" + echo \"Restoring hookshot logs ...\" + ghe-restore-es-hookshot \"$GHE_HOSTNAME\" 1>&3") +fi - echo "Restoring hookshot logs ..." - ghe-restore-es-hookshot "$GHE_HOSTNAME" 1>&3 +if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then + $GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}" +else + for c in "${commands[@]}"; do + eval "$c" + done fi # Restart an already running memcached to reset the cache after restore From 2de4e8800392b100834a931e2fe9a48df93d501e Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Sun, 5 Apr 2020 11:11:17 -0700 Subject: [PATCH 1004/2421] Add ghe-restore parallel test --- test/test-ghe-restore-parallel.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 test/test-ghe-restore-parallel.sh diff --git a/test/test-ghe-restore-parallel.sh b/test/test-ghe-restore-parallel.sh new file mode 100755 index 000000000..835cbdd29 --- /dev/null +++ b/test/test-ghe-restore-parallel.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# ghe-restore command tests run in parallel +set -e + +export GHE_PARALLEL_ENABLED=yes + +TESTS_DIR="$PWD/$(dirname "$0")" +# shellcheck source=test/test-ghe-restore.sh +. "$TESTS_DIR/test-ghe-restore.sh" From 239d082542f1d3debec2334c041db7f1666f196d Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Sun, 5 Apr 2020 11:11:58 -0700 Subject: [PATCH 1005/2421] Enable elasticsearch to restore in parallel --- share/github-backup-utils/ghe-restore-es-audit-log | 8 ++++---- share/github-backup-utils/ghe-restore-es-hookshot | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 77055d692..8586237f2 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -56,18 +56,18 @@ if [ -s "$tmp_list" ]; then --rsync-path="sudo -u elasticsearch rsync" \ --files-from=$tmp_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/audit-log/" 1>&3 if $CLUSTER || [ -n "$configured" ]; then for index in $(cat $tmp_list | sed 's/\.gz$//g'); do ghe_verbose "* Restoring $index" - echo "export PATH=\$PATH:/usr/local/share/enterprise && sudo gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | + echo "export PATH=\$PATH:/usr/local/share/enterprise && sudo gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/audit-log/$index | ghe-es-load-json 'http://localhost:9201/$index'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 done - - ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz'" 1>&3 fi + ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'rm -rf $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/audit-log/'" 1>&3 + rm $tmp_list fi diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index 997ab5677..aba81c1e2 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -43,17 +43,18 @@ if [ -s "$tmp_list" ]; then --rsync-path="sudo -u elasticsearch rsync" \ --files-from=$tmp_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/" 1>&3 + "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/" 1>&3 if $CLUSTER || [ -n "$configured" ]; then for index in $(cat $tmp_list | sed 's/\.gz$//g'); do ghe_verbose "* Restoring $index" - echo "export PATH=\$PATH:/usr/local/share/enterprise && sudo gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/$index | ghe-es-load-json 'http://localhost:9201/$index'" | + echo "export PATH=\$PATH:/usr/local/share/enterprise && sudo gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/$index | ghe-es-load-json 'http://localhost:9201/$index'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 done - ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'rm $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/*.gz'" 1>&3 fi + ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'rm -rf $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/'" 1>&3 + rm $tmp_list fi From 956e878569583897731e0082a7bf23118645bf63 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Sun, 5 Apr 2020 15:40:28 -0700 Subject: [PATCH 1006/2421] Fix ghe-restore tests --- test/test-ghe-restore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 499e3385b..b9feaa398 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -202,7 +202,7 @@ begin_test "ghe-restore with host arg and config value" export GHE_RESTORE_HOST # set restore host config var (which we shouldn't see) - GHE_BACKUP_CONFIG_TEMP="${GHE_BACKUP_CONFIG}.temp" + GHE_BACKUP_CONFIG_TEMP="$TRASHDIR/backup.config.temp" cp "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_CONFIG_TEMP" echo 'GHE_RESTORE_HOST="broken.config.restore.host"' >> "$GHE_BACKUP_CONFIG_TEMP" GHE_BACKUP_CONFIG="$GHE_BACKUP_CONFIG_TEMP" From dcee3b015c77b32e8f1f3d4ed036df81d53bd425 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Mon, 6 Apr 2020 13:43:23 -0700 Subject: [PATCH 1007/2421] Fixup elasticsearch restore --- share/github-backup-utils/ghe-restore-es-audit-log | 2 ++ share/github-backup-utils/ghe-restore-es-hookshot | 2 ++ 2 files changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 8586237f2..13c98ab94 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -64,6 +64,8 @@ if [ -s "$tmp_list" ]; then echo "export PATH=\$PATH:/usr/local/share/enterprise && sudo gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/audit-log/$index | ghe-es-load-json 'http://localhost:9201/$index'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 done + else + ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'mv $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/audit-log/* $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/'" 1>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'rm -rf $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/audit-log/'" 1>&3 diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index aba81c1e2..dab42c953 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -51,6 +51,8 @@ if [ -s "$tmp_list" ]; then echo "export PATH=\$PATH:/usr/local/share/enterprise && sudo gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/$index | ghe-es-load-json 'http://localhost:9201/$index'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 done + else + ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'mv $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/* $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/'" 1>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'rm -rf $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/'" 1>&3 From b0e6f27fbe1b5a6603488c6afcbdaf264957307c Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Tue, 7 Apr 2020 15:38:31 +0000 Subject: [PATCH 1008/2421] Terminate any background jobs when exiting. --- share/github-backup-utils/ghe-restore-repositories | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index b7f2bd5fb..9f7b9dbdc 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -63,6 +63,11 @@ if $CLUSTER; then fi cleanup() { + # Kill any backgrounded rsync jobs + for pid in $(jobs -p); do + kill -KILL $pid > /dev/null 2>&1 || true + done + for hostname in $hostnames; do ghe-gc-enable $ssh_config_file_opt $hostname:$port || true done @@ -152,8 +157,9 @@ for file_list in $tempdir/*.rsync; do --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 & + "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 2>&3 & done + for pid in $(jobs -p); do wait $pid ret_code=$? @@ -188,7 +194,7 @@ if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3 & + "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3 2>&3 & done for pid in $(jobs -p); do From 01d430e23d6dfc6b6fc7b83bc9119e88e56f77ee Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Apr 2020 13:23:23 +0000 Subject: [PATCH 1009/2421] Run repository network rsync in parallel, with configurable max jobs. --- .../ghe-restore-repositories | 56 +++++++++---------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 9f7b9dbdc..3f6cee3ca 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -10,6 +10,9 @@ set -e # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +# Check to make sure moreutils parallel is installed and working properly +ghe_parallel_check + # Show usage and bail with no arguments [ -z "$*" ] && print_usage @@ -63,11 +66,6 @@ if $CLUSTER; then fi cleanup() { - # Kill any backgrounded rsync jobs - for pid in $(jobs -p); do - kill -KILL $pid > /dev/null 2>&1 || true - done - for hostname in $hostnames; do ghe-gc-enable $ssh_config_file_opt $hostname:$port || true done @@ -145,30 +143,36 @@ fi # rsync all the repository networks to the git server where they belong. # One rsync invocation per server available. bm_start "$(basename $0) - Restoring repository networks" +rsync_commands=() for file_list in $tempdir/*.rsync; do if $CLUSTER; then server=$(basename $file_list .rsync) else server=$host fi - ghe_verbose "* Transferring repository networks to $server ..." - ghe-rsync -avrR --delete \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - --rsync-path="sudo -u git rsync" \ - --files-from=$file_list \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/repositories/" 1>&3 2>&3 & -done -for pid in $(jobs -p); do - wait $pid - ret_code=$? - if [ "$ret_code" != "0" ]; then - echo "$pid exited $ret_code" - #exit $ret_code - fi + rsync_commands+=(" + if [ -n \"$GHE_VERBOSE\" ]; then + echo \"* Transferring repository networks to $server ...\" 1>&3 + fi + + ghe-rsync -avrR --delete \ + -e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \ + --rsync-path=\"sudo -u git rsync\" \ + --files-from=$file_list \ + \"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./\" \ + \"$server:$GHE_REMOTE_DATA_USER_DIR/repositories/\" 1>&3 + ") done +if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then + $GHE_PARALLEL_COMMAND -j $GHE_PARALLEL_RSYNC_MAX_JOBS -- "${rsync_commands[@]}" +else + for c in "${rsync_commands[@]}"; do + eval "$c" + done +fi + bm_end "$(basename $0) - Restoring repository networks" # Tell dgit about the repositories restored @@ -189,21 +193,11 @@ if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" for hostname in $hostnames; do - ghe-rsync -av --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3 2>&3 & - done - - for pid in $(jobs -p); do - wait $pid - ret_code=$? - if [ "$ret_code" != "0" ]; then - echo "$pid exited $ret_code" - #exit $ret_code - fi + "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3 done else From f1a16f5b5b7c289588468560fe9d2024f8a3800f Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Apr 2020 16:56:31 +0000 Subject: [PATCH 1010/2421] Default GHE_PARALLEL_MAX_RSYNC_JOBS to same as GHE_PARALLEL_MAX_JOBS if not set. --- share/github-backup-utils/ghe-backup-config | 8 ++++++++ share/github-backup-utils/ghe-restore-repositories | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 13247f43c..396a818bd 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -85,10 +85,18 @@ ghe_parallel_check() { if [ -n "$GHE_PARALLEL_MAX_JOBS" ]; then GHE_PARALLEL_COMMAND_OPTIONS="-j $GHE_PARALLEL_MAX_JOBS" + # Default to the number of max rsync jobs to the same as GHE_PARALLEL_MAX_JOBS, if not set. + # This is only applicable to ghe-restore-repositories currently. + : ${GHE_PARALLEL_MAX_RSYNC_JOBS:="$GHE_PARALLEL_MAX_JOBS"} + fi + + if [ -n "$GHE_PARALLEL_MAX_RSYNC_JOBS" ]; then + GHE_PARALLEL_RSYNC_COMMAND_OPTIONS="-j $GHE_PARALLEL_MAX_RSYNC_JOBS" fi if [ -n "$GHE_PARALLEL_MAX_LOAD" ]; then GHE_PARALLEL_COMMAND_OPTIONS+=" -l $GHE_PARALLEL_MAX_LOAD" + GHE_PARALLEL_RSYNC_COMMAND_OPTIONS+=" -l $GHE_PARALLEL_MAX_LOAD" fi } diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 3f6cee3ca..97fa83a88 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -166,7 +166,7 @@ for file_list in $tempdir/*.rsync; do done if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - $GHE_PARALLEL_COMMAND -j $GHE_PARALLEL_RSYNC_MAX_JOBS -- "${rsync_commands[@]}" + $GHE_PARALLEL_COMMAND $GHE_PARALLEL_RSYNC_COMMAND_OPTIONS -- "${rsync_commands[@]}" else for c in "${rsync_commands[@]}"; do eval "$c" From 9f390d5be5aac6e6f92e0a1c1c5179384f275bdc Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Apr 2020 17:02:18 +0000 Subject: [PATCH 1011/2421] Add GHE_PARALLEL_RSYNC_MAX_JOBS to config example --- backup.config-example | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backup.config-example b/backup.config-example index a1b4c0870..8cb3d424f 100644 --- a/backup.config-example +++ b/backup.config-example @@ -73,6 +73,13 @@ GHE_NUM_SNAPSHOTS=10 # WARNING: this feature is in beta. #GHE_PARALLEL_MAX_JOBS=2 +# Sets the maximum number of rsync jobs to run in parallel. Defaults to the +# configured GHE_PARALLEL_MAX_JOBS, or the number of available processing +# units on the machine. +# +# WARNING: this feature is in beta. +# GHE_PARALLEL_RSYNC_MAX_JOBS=3 + # When jobs are running in parallel wait as needed to avoid starting new jobs # when the system's load average is not below the specified percentage. Defaults to # unrestricted. From 574cb2b8600557d3ae2c0578184d7e91c7058321 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Fri, 10 Apr 2020 15:53:44 +0000 Subject: [PATCH 1012/2421] fix typo in GHE_PARALLEL_RSYNC_MAX_JOBS --- share/github-backup-utils/ghe-backup-config | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 396a818bd..65ad13ada 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -87,11 +87,11 @@ ghe_parallel_check() { GHE_PARALLEL_COMMAND_OPTIONS="-j $GHE_PARALLEL_MAX_JOBS" # Default to the number of max rsync jobs to the same as GHE_PARALLEL_MAX_JOBS, if not set. # This is only applicable to ghe-restore-repositories currently. - : ${GHE_PARALLEL_MAX_RSYNC_JOBS:="$GHE_PARALLEL_MAX_JOBS"} + : ${GHE_PARALLEL_RSYNC_MAX_JOBS:="$GHE_PARALLEL_MAX_JOBS"} fi - if [ -n "$GHE_PARALLEL_MAX_RSYNC_JOBS" ]; then - GHE_PARALLEL_RSYNC_COMMAND_OPTIONS="-j $GHE_PARALLEL_MAX_RSYNC_JOBS" + if [ -n "$GHE_PARALLEL_RSYNC_MAX_JOBS" ]; then + GHE_PARALLEL_RSYNC_COMMAND_OPTIONS="-j $GHE_PARALLEL_RSYNC_MAX_JOBS" fi if [ -n "$GHE_PARALLEL_MAX_LOAD" ]; then From ed9383ac06f5a89b40da1876a45e36a6df9cbc82 Mon Sep 17 00:00:00 2001 From: Dan Rigby Date: Fri, 10 Apr 2020 16:18:55 -0400 Subject: [PATCH 1013/2421] Back out Skip Pages modifications for now --- backup.config-example | 9 --------- bin/ghe-backup | 10 +++------- bin/ghe-restore | 14 +++----------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/backup.config-example b/backup.config-example index a1b4c0870..9e1e4f157 100644 --- a/backup.config-example +++ b/backup.config-example @@ -53,15 +53,6 @@ GHE_NUM_SNAPSHOTS=10 # WARNING: do not enable this, only useful for debugging/development #GHE_BACKUP_FSCK=no -# If set to 'yes', ghe-backup will omit the backup of Pages artifacts. -# -#GHE_BACKUP_SKIP_PAGES=no - -# If set to 'yes', ghe-restore will omit the restore of Pages artifacts -# contained in the backup. -# -#GHE_RESTORE_SKIP_PAGES=no - # If set to 'yes', ghe-backup jobs will run in parallel. Defaults to 'no'. # # WARNING: this feature is in beta. diff --git a/bin/ghe-backup b/bin/ghe-backup index acf246ec7..e45817727 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -199,13 +199,9 @@ commands+=(" echo \"Backing up Git repositories ...\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") -if [ "$GHE_BACKUP_SKIP_PAGES" = "yes" ]; then - echo "Skipping backup of GitHub Pages artifacts ..." -else - commands+=(" - echo \"Backing up GitHub Pages artifacts ...\" - ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") -fi +commands+=(" +echo \"Backing up GitHub Pages artifacts ...\" +ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") commands+=(" echo \"Backing up storage data ...\" diff --git a/bin/ghe-restore b/bin/ghe-restore index 3f2f1704a..e9089da3a 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -272,17 +272,9 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; the echo \"Restoring Gists ...\" ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") - if [ "$GHE_RESTORE_SKIP_PAGES" = "yes" ]; then - echo "Skipping restore of GitHub Pages artifacts ..." - else - if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/pages" ]; then - commands+=(" - echo \"Restoring GitHub Pages artifacts ...\" - ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") - else - echo "No GitHub Pages artifacts found in backup, skipping restore ..." - fi - fi + commands+=(" + echo \"Restoring GitHub Pages artifacts ...\" + ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") else commands+=(" echo \"Restoring Git repositories and Gists ...\" From 384a91c8beccef4f3f2fc710df844c9fd0337b9e Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Fri, 10 Apr 2020 15:49:41 -0700 Subject: [PATCH 1014/2421] WIP: show file_list contents --- share/github-backup-utils/ghe-restore-repositories | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 97fa83a88..0a25c8009 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -153,7 +153,8 @@ for file_list in $tempdir/*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - echo \"* Transferring repository networks to $server ...\" 1>&3 + echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 + cat $file_list fi ghe-rsync -avrR --delete \ From c07afd9d43bd83486749bc8184dd6de58c8820f5 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 13 Apr 2020 23:04:52 -0700 Subject: [PATCH 1015/2421] fix tests by passing "--copy-dirlinks" argument --- test/test-ghe-restore-parallel.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test-ghe-restore-parallel.sh b/test/test-ghe-restore-parallel.sh index 835cbdd29..bfa38849e 100755 --- a/test/test-ghe-restore-parallel.sh +++ b/test/test-ghe-restore-parallel.sh @@ -3,6 +3,7 @@ set -e export GHE_PARALLEL_ENABLED=yes +export GHE_EXTRA_RSYNC_OPTS="--copy-dirlinks" # handle symlink directories for tests TESTS_DIR="$PWD/$(dirname "$0")" # shellcheck source=test/test-ghe-restore.sh From 14d3aacfe3f0b7a90aed2e03c6b81fd7dde5af2b Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 13 Apr 2020 23:10:14 -0700 Subject: [PATCH 1016/2421] use temp rsync directory for parallel restore test --- test/test-ghe-restore-parallel.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-restore-parallel.sh b/test/test-ghe-restore-parallel.sh index bfa38849e..a99da61e5 100755 --- a/test/test-ghe-restore-parallel.sh +++ b/test/test-ghe-restore-parallel.sh @@ -2,8 +2,11 @@ # ghe-restore command tests run in parallel set -e +# use tempdir to fix rsync file issues in parallel execution +tempdir=$(mktemp -d -t backup-utils-restore-temp-XXXXXX) + export GHE_PARALLEL_ENABLED=yes -export GHE_EXTRA_RSYNC_OPTS="--copy-dirlinks" # handle symlink directories for tests +export GHE_EXTRA_RSYNC_OPTS="--copy-dirlinks --temp-dir=$tempdir" # handle symlink directories for tests TESTS_DIR="$PWD/$(dirname "$0")" # shellcheck source=test/test-ghe-restore.sh From c6daeaf6acb92038741aa6c87e1a504ecd17d2a2 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 13 Apr 2020 23:14:03 -0700 Subject: [PATCH 1017/2421] more detailed comment --- test/test-ghe-restore-parallel.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-restore-parallel.sh b/test/test-ghe-restore-parallel.sh index a99da61e5..a62cdea41 100755 --- a/test/test-ghe-restore-parallel.sh +++ b/test/test-ghe-restore-parallel.sh @@ -2,11 +2,13 @@ # ghe-restore command tests run in parallel set -e -# use tempdir to fix rsync file issues in parallel execution -tempdir=$(mktemp -d -t backup-utils-restore-temp-XXXXXX) - export GHE_PARALLEL_ENABLED=yes -export GHE_EXTRA_RSYNC_OPTS="--copy-dirlinks --temp-dir=$tempdir" # handle symlink directories for tests + +# use temp dir to fix rsync file issues in parallel execution: +# we are imitating remote server by local files, and running rsync in parallel may cause +# race conditions when two processes writing to same folder +tempdir=$(mktemp -d -t backup-utils-restore-temp-XXXXXX) +export GHE_EXTRA_RSYNC_OPTS="--copy-dirlinks --temp-dir=$tempdir" TESTS_DIR="$PWD/$(dirname "$0")" # shellcheck source=test/test-ghe-restore.sh From 43933d1c83737d703b7e117b4779de14e7a0694d Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 13 Apr 2020 23:20:32 -0700 Subject: [PATCH 1018/2421] revert "Updating repository info data" changes --- share/github-backup-utils/ghe-restore-repositories | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 0a25c8009..9dd0f1459 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -194,11 +194,13 @@ if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" for hostname in $hostnames; do - ghe-rsync -av --delete \ + if ! ghe-rsync -av --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3 + "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then + echo "Error restoring /data/repositories/info to $hostname" 1>&2 + fi done else From 4f2374f9702373caedd4a330eb22a76d944362e0 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 13 Apr 2020 23:21:10 -0700 Subject: [PATCH 1019/2421] fix extra space --- share/github-backup-utils/ghe-restore-repositories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 9dd0f1459..276994050 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -199,7 +199,7 @@ if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info/" \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/repositories/info" 1>&3; then - echo "Error restoring /data/repositories/info to $hostname" 1>&2 + echo "Error restoring /data/repositories/info to $hostname" 1>&2 fi done From d3216ba062decbd8318e5dbf1902008a1cddcc32 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 13 Apr 2020 23:21:49 -0700 Subject: [PATCH 1020/2421] fix extra lines --- share/github-backup-utils/ghe-restore-repositories | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 276994050..d499db5a4 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -192,7 +192,6 @@ fi bm_start "$(basename $0) - Updating repository info data" if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then ghe_verbose "* Transferring repository info data" - for hostname in $hostnames; do if ! ghe-rsync -av --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ @@ -202,7 +201,6 @@ if [ -d $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/info ]; then echo "Error restoring /data/repositories/info to $hostname" 1>&2 fi done - else ghe_verbose "* Removing repository info data" if $CLUSTER; then From 7af23f734569ca5eb91b4f6de9250fd41efb3b75 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Tue, 14 Apr 2020 11:44:44 +0000 Subject: [PATCH 1021/2421] Remove `cat $file_list` and echo verbose output to fd3 --- share/github-backup-utils/ghe-restore-repositories | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index d499db5a4..e5f028e7c 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -152,10 +152,7 @@ for file_list in $tempdir/*.rsync; do fi rsync_commands+=(" - if [ -n \"$GHE_VERBOSE\" ]; then - echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 - cat $file_list - fi + echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 ghe-rsync -avrR --delete \ -e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \ From 95a631879285d0e4df7713512152c00515d9e707 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Tue, 14 Apr 2020 11:54:40 +0000 Subject: [PATCH 1022/2421] Guard on GHE_VERBOSE again. More descriptive variable name. --- share/github-backup-utils/ghe-restore-repositories | 4 +++- test/test-ghe-restore-parallel.sh | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index e5f028e7c..affa72e4b 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -152,7 +152,9 @@ for file_list in $tempdir/*.rsync; do fi rsync_commands+=(" - echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 + if [ -n "$GHE_VERBOSE" ]; then + echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 + fi ghe-rsync -avrR --delete \ -e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \ diff --git a/test/test-ghe-restore-parallel.sh b/test/test-ghe-restore-parallel.sh index a62cdea41..35d85d2d0 100755 --- a/test/test-ghe-restore-parallel.sh +++ b/test/test-ghe-restore-parallel.sh @@ -7,8 +7,8 @@ export GHE_PARALLEL_ENABLED=yes # use temp dir to fix rsync file issues in parallel execution: # we are imitating remote server by local files, and running rsync in parallel may cause # race conditions when two processes writing to same folder -tempdir=$(mktemp -d -t backup-utils-restore-temp-XXXXXX) -export GHE_EXTRA_RSYNC_OPTS="--copy-dirlinks --temp-dir=$tempdir" +parallel_rsync_tempdir=$(mktemp -d -t backup-utils-restore-temp-XXXXXX) +export GHE_EXTRA_RSYNC_OPTS="--copy-dirlinks --temp-dir=$parallel_rsync_tempdir" TESTS_DIR="$PWD/$(dirname "$0")" # shellcheck source=test/test-ghe-restore.sh From e4fba3725c8d945fac9fc2b84ef82a23bf34a8f8 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Tue, 14 Apr 2020 12:12:26 +0000 Subject: [PATCH 1023/2421] Escape GHE_VERBOSE check --- share/github-backup-utils/ghe-restore-repositories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index affa72e4b..201f20092 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -152,7 +152,7 @@ for file_list in $tempdir/*.rsync; do fi rsync_commands+=(" - if [ -n "$GHE_VERBOSE" ]; then + if [ -n \"$GHE_VERBOSE\" ]; then echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 fi From 0ea4a114643cdd27de3bff3ef38be2d38b7f49e7 Mon Sep 17 00:00:00 2001 From: Sho Mizutani Date: Thu, 30 Apr 2020 11:41:11 +0900 Subject: [PATCH 1024/2421] Make ghe_debug handle piped stdin (#592) Make ghe_debug to accept piped stdin --- share/github-backup-utils/ghe-backup-config | 12 +++++++++-- .../ghe-backup-repositories | 4 ++-- share/github-backup-utils/ghe-backup-storage | 4 ++-- share/github-backup-utils/ghe-restore-pages | 6 +++--- .../ghe-restore-repositories | 6 +++--- .../ghe-restore-repositories-gist | 6 +++--- share/github-backup-utils/ghe-restore-storage | 6 +++--- test/test-ghe-backup-config.sh | 21 +++++++++++++++++++ 8 files changed, 47 insertions(+), 18 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 65ad13ada..8b0d1d4bf 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -336,11 +336,19 @@ ghe_verbose() { fi } -# Usage: ghe_debug +# Usage: ghe_debug OR echo | ghe_debug # Log if debug mode is enabled (GHE_DEBUG). ghe_debug() { - if [ -n "$GHE_DEBUG" ]; then + [ -z "$GHE_DEBUG" ] && return + + if [ $# -ne 0 ]; then echo -e "Debug: $*" 1>&3 + elif [ -p /dev/stdin ]; then + echo "\n" 1>&3 + while read line + do + echo -e "Debug: $line" 1>&3 + done < /dev/stdin fi } diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index bc9a55e99..bd979f908 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -124,12 +124,12 @@ fi # bm_start "$(basename $0) - Generating routes" echo "github-env ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list -ghe_debug "\n$(cat $routes_list)" +cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 180ba8d36..c561b164d 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -92,12 +92,12 @@ fi # bm_start "$(basename $0) - Generating routes" echo "github-env ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list -ghe_debug "\n$(cat $routes_list)" +cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 9bd51b7ac..0149bb48a 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -104,17 +104,17 @@ bm_end "$(basename $0) - Building pages list" # bm_start "$(basename $0) - Transferring pages list" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list -ghe_debug "\n$(cat $tmp_list)" +cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring pages list" bm_start "$(basename $0) - Generating routes" echo "cat $remote_tmp_list | github-env ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list -ghe_debug "\n$(cat $routes_list)" +cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 201f20092..a420c6c70 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -116,17 +116,17 @@ bm_end "$(basename $0) - Building network list" # bm_start "$(basename $0) - Transferring network list" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list -ghe_debug "\n$(cat $tmp_list)" +cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring network list" bm_start "$(basename $0) - Generating routes" echo "cat $remote_tmp_list | github-env ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list -ghe_debug "\n$(cat $routes_list)" +cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 6a0a40c91..6ba96ea51 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -106,17 +106,17 @@ bm_end "$(basename $0) - Building gist list" # bm_start "$(basename $0) - Transferring gist list" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list -ghe_debug "\n$(cat $tmp_list)" +cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring gist list" bm_start "$(basename $0) - Generating routes" echo "cat $remote_tmp_list | github-env ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Transferring routes" ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list -ghe_debug "\n$(cat $routes_list)" +cat $routes_list | ghe_debug bm_end "$(basename $0) - Transferring routes" bm_start "$(basename $0) - Processing routes" diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 047937fde..bd86ed91f 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -96,17 +96,17 @@ bm_end "$(basename $0) - Building object list" # bm_start "$(basename $0) - Transferring object list" cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list -ghe_debug "\n$(cat $tmp_list)" +cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring object list" bm_start "$(basename $0) - Generating routes" echo "cat $remote_tmp_list | github-env ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash -ghe_debug "\n$(ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list)" +ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list -ghe_debug "\n$(cat $routes_list)" +cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 84ef5c526..1cc3968f5 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -163,3 +163,24 @@ begin_test "ghe-backup-config verbose log redirects to file under parallel" exit 1 ) end_test + +begin_test "ghe-backup-config ghe_debug accepts stdin as well as argument" +( + set -e + + export GHE_DEBUG=1 + export GHE_VERBOSE=1 + export GHE_VERBOSE_LOG="$TRASHDIR/verbose.log" + . "share/github-backup-utils/ghe-backup-config" + + ghe_debug "debug arg" + grep -q "debug arg" ${GHE_VERBOSE_LOG} + + echo "debug stdin" | ghe_debug + grep -q "debug stdin" ${GHE_VERBOSE_LOG} + + unset GHE_DEBUG + unset GHE_VERBOSE + unset GHE_VERBOSE_LOG +) +end_test From 365f004776a7dea34c32ffdc11b7c73cced4680c Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 5 May 2020 11:52:17 -0700 Subject: [PATCH 1025/2421] Change bm_start to bm_end --- share/github-backup-utils/ghe-restore-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 95813d91a..ff4bbdb72 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -55,4 +55,4 @@ if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates" fi -bm_start "$(basename $0)" +bm_end "$(basename $0)" From f4f842678d37bc836c39c73ea2833b5798801cb9 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 5 May 2020 11:55:27 -0700 Subject: [PATCH 1026/2421] Remove extra bm_start --- share/github-backup-utils/ghe-backup-git-hooks | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-git-hooks b/share/github-backup-utils/ghe-backup-git-hooks index d481c2426..c7bd5429e 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks +++ b/share/github-backup-utils/ghe-backup-git-hooks @@ -18,8 +18,6 @@ if ! rsync --version 1>/dev/null 2>&1; then exit 1 fi -bm_start "$(basename $0)" - backup_dir="$GHE_SNAPSHOT_DIR/git-hooks" # Location of last good backup for rsync --link-dest backup_current="$GHE_DATA_DIR/current/git-hooks" From 26879621e38776c8883d2e1b6265d23d56ad2b07 Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Mon, 11 May 2020 15:20:11 +0200 Subject: [PATCH 1027/2421] remove rsync restore method used by GHES versions prior to 2.13 GHES 2.13 is already out of support and therefore I think we should remove the code. Furthermore the `ghe-restore-pages-rsync` script uses `share/github-backup-utils/ghe-restore-userdata` which I think does not quote/escape the variable `$dirname` properly. As a consequence GitHub pages with whitespaces in their path cause errors on restore. --- bin/ghe-restore | 31 ++++-------- .../ghe-restore-pages-rsync | 21 --------- .../ghe-restore-repositories-rsync | 47 ------------------- .../github-backup-utils/ghe-restore-userdata | 47 ------------------- 4 files changed, 10 insertions(+), 136 deletions(-) delete mode 100755 share/github-backup-utils/ghe-restore-pages-rsync delete mode 100755 share/github-backup-utils/ghe-restore-repositories-rsync delete mode 100755 share/github-backup-utils/ghe-restore-userdata diff --git a/bin/ghe-restore b/bin/ghe-restore index e9089da3a..a25d66ece 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -262,28 +262,17 @@ commands=(" echo \"Restoring Redis database ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") -# Unified and enhanced restore method to 2.13.0 and newer -if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.13.0)" ]; then - commands+=(" - echo \"Restoring Git repositories ...\" - ghe-restore-repositories \"$GHE_HOSTNAME\"") - - commands+=(" - echo \"Restoring Gists ...\" - ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") +commands+=(" +echo \"Restoring Git repositories ...\" +ghe-restore-repositories \"$GHE_HOSTNAME\"") - commands+=(" - echo \"Restoring GitHub Pages artifacts ...\" - ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") -else - commands+=(" - echo \"Restoring Git repositories and Gists ...\" - ghe-restore-repositories-rsync \"$GHE_HOSTNAME\" 1>&3") +commands+=(" +echo \"Restoring Gists ...\" +ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") - commands+=(" - echo \"Restoring GitHub Pages ...\" - ghe-restore-pages-rsync \"$GHE_HOSTNAME\" 1>&3") -fi +commands+=(" +echo \"Restoring GitHub Pages artifacts ...\" +ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") commands+=(" echo \"Restoring SSH authorized keys ...\" @@ -318,7 +307,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the echo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi - + commands+=(" echo \"Restoring hookshot logs ...\" ghe-restore-es-hookshot \"$GHE_HOSTNAME\" 1>&3") diff --git a/share/github-backup-utils/ghe-restore-pages-rsync b/share/github-backup-utils/ghe-restore-pages-rsync deleted file mode 100755 index d1b2b7b82..000000000 --- a/share/github-backup-utils/ghe-restore-pages-rsync +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-pages-rsync -#/ Restore an rsync snapshot of all Pages data to a GitHub instance. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when the rsync strategy is used. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Restore all pages data via rsync -ghe-restore-userdata pages "$1" - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-repositories-rsync b/share/github-backup-utils/ghe-restore-repositories-rsync deleted file mode 100755 index b151a6645..000000000 --- a/share/github-backup-utils/ghe-restore-repositories-rsync +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-repositories-rsync -#/ Restore an rsync snapshot of all Git repository data to a GitHub instance. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command when the rsync strategy is used. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -cleanup() { - # Enable remote GC operations - ghe-gc-enable $GHE_HOSTNAME -} - -trap 'cleanup' INT TERM EXIT - -# Disable remote GC operations -ghe-gc-disable $GHE_HOSTNAME - -# Transfer all git repository data from the latest snapshot to the GitHub -# instance in a single rsync invocation. -ghe-rsync -av --delete \ - --exclude ".sync_in_progress" \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/repositories" 1>&3 - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-userdata b/share/github-backup-utils/ghe-restore-userdata deleted file mode 100755 index cfb8834d3..000000000 --- a/share/github-backup-utils/ghe-restore-userdata +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-userdata -#/ Restore a special user data directory via rsync. This is used -#/ for a number of different simple datastores kept under /data/user on the -#/ remote appliance, including: hookshot, alambic_assets, and pages data. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Show usage and bail with no arguments -[ $# -lt 2 ] && print_usage - -bm_start "$(basename $0) - $1" - -# Grab userdata directory name and host args -dirname="$1" -GHE_HOSTNAME="$2" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 - exit 1 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Transfer data from the latest snapshot to the GitHub instance in a single -# rsync invocation. -if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname" ]; then - # Create the remote user data directory - ghe-ssh "$GHE_HOSTNAME" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/$dirname" - - ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u git rsync" \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/$dirname/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/$dirname" 1>&3 -fi - -bm_end "$(basename $0) - $1" From e73dcc3659396e1c870d50eb1cebbc8fac8048c1 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 13 May 2020 18:12:08 -0700 Subject: [PATCH 1028/2421] Echo MySQL backup strategy --- bin/ghe-backup | 6 +++++- share/github-backup-utils/ghe-backup-config | 4 ++++ share/github-backup-utils/ghe-backup-mysql | 5 ----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index e45817727..e86f94ec5 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -180,7 +180,11 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar || failures="$failures ssh-host-keys" bm_end "ghe-export-ssh-host-keys" -echo "Backing up MySQL database ..." +if is_binary_backup_feature_on; then + echo "Backing up MySQL database using binary backup ..." +else + echo "Backing up MySQL database using logical backup ..." +fi ghe-backup-mysql || failures="$failures mysql" commands=(" diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 8b0d1d4bf..493efa51b 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -381,3 +381,7 @@ fix_paths_for_ghe_version() { # GHES), then don't modify lines with "gist" in them. sed $GIST_FILTER -e 's/\/$//; s/^[^\/]*$/./; s/\/[^\/]*$//' } + +is_binary_backup_feature_on(){ + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" +} diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 983341461..6148fd2d5 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -15,11 +15,6 @@ bm_start "$(basename $0)" # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" -# if we are going to take a binary backup -is_binary_backup_feature_on(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" -} - export_command="ghe-export-mysql" if ! is_binary_backup_feature_on; then # binary backup is already compressed From f7e955ee294f74f2f0255d3048229c011c937746 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 13 May 2020 18:13:28 -0700 Subject: [PATCH 1029/2421] Update wording --- bin/ghe-backup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index e86f94ec5..3763aa5bf 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -181,9 +181,9 @@ failures="$failures ssh-host-keys" bm_end "ghe-export-ssh-host-keys" if is_binary_backup_feature_on; then - echo "Backing up MySQL database using binary backup ..." + echo "Backing up MySQL database using binary backup strategy ..." else - echo "Backing up MySQL database using logical backup ..." + echo "Backing up MySQL database using logical backup strategy ..." fi ghe-backup-mysql || failures="$failures mysql" From 61c78bdd4e215f2a3e34393860609fe84e91fb00 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 13 May 2020 18:17:33 -0700 Subject: [PATCH 1030/2421] Remove extra declaration of is_binary_backup_feature_on --- share/github-backup-utils/ghe-restore-mysql | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 150c93a77..538690635 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -28,14 +28,9 @@ ghe_remote_version_required "$GHE_HOSTNAME" # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -# Check if the backup is binary by looking up the sentinel file +# Check if the backup is binary by looking up the sentinel file is_binary_backup(){ - test -f $snapshot_dir/mysql-binary-backup-sentinel -} - -# if mysql.backup.binary feature flag is on -is_binary_backup_feature_on(){ - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" + test -f $snapshot_dir/mysql-binary-backup-sentinel } ssh_config_file_opt= @@ -59,7 +54,7 @@ if is_binary_backup_feature_on; then ghe_mysql_master=$GHE_HOSTNAME fi - # Check if the decompress needed by looking into the sentinel file + # Check if the decompress needed by looking into the sentinel file # In 2.19.5 we compress the binary backup twice if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then IMPORT_MYSQL=ghe-import-mysql-xtrabackup @@ -73,9 +68,9 @@ if is_binary_backup_feature_on; then GHE_RESTORE_HOST=$GHE_HOSTNAME fi else - # We do not allow to restore binary backup without "mysql.backup.binary" set + # We do not allow to restore binary backup without "mysql.backup.binary" set if is_binary_backup; then - echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 + echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 else # legacy mode From 7be554b8cd963ae0575b74018177605bed4e272d Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 13 May 2020 18:23:48 -0700 Subject: [PATCH 1031/2421] Add output to ghe-restore --- share/github-backup-utils/ghe-restore-mysql | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 538690635..b7db9a799 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -33,6 +33,18 @@ is_binary_backup(){ test -f $snapshot_dir/mysql-binary-backup-sentinel } +if is_binary_backup_feature_on; then + echo "Appliance is configured for binary backups." +else + echo "Appliance is configured for logical backups." +fi + +if is_binary_backup; then + echo "Backup being restored is a binary backup." +else + echo "Backup being restored is a logical backup." +fi + ssh_config_file_opt= if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available From b0e690893a238320bf319ab0216db0a398dba0b6 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Thu, 14 May 2020 04:32:59 +0000 Subject: [PATCH 1032/2421] Add top level logging to ghe-restore --- bin/ghe-restore | 16 ++++++++++++++-- share/github-backup-utils/ghe-backup-config | 5 +++++ share/github-backup-utils/ghe-restore-mysql | 11 +++-------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index e9089da3a..c891793d7 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -255,7 +255,19 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" fi -echo "Restoring MySQL database ..." +if is_binary_backup_feature_on; then + appliance_strategy="binary" +else + appliance_strategy="logical" +fi + +if is_binary_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"; then + backup_snapshot_strategy="binary" +else + backup_snapshot_strategy="logical" +fi + +echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 commands=(" @@ -318,7 +330,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the echo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi - + commands+=(" echo \"Restoring hookshot logs ...\" ghe-restore-es-hookshot \"$GHE_HOSTNAME\" 1>&3") diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 493efa51b..176ecdc17 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -385,3 +385,8 @@ fix_paths_for_ghe_version() { is_binary_backup_feature_on(){ ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" } + +# Check if the backup is binary by looking up the sentinel file +is_binary_backup(){ + test -f "$1/mysql-binary-backup-sentinel" +} \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index b7db9a799..f43b5b786 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -28,18 +28,13 @@ ghe_remote_version_required "$GHE_HOSTNAME" # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -# Check if the backup is binary by looking up the sentinel file -is_binary_backup(){ - test -f $snapshot_dir/mysql-binary-backup-sentinel -} - if is_binary_backup_feature_on; then echo "Appliance is configured for binary backups." else echo "Appliance is configured for logical backups." fi -if is_binary_backup; then +if is_binary_backup $snapshot_dir; then echo "Backup being restored is a binary backup." else echo "Backup being restored is a logical backup." @@ -48,7 +43,7 @@ fi ssh_config_file_opt= if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available - if is_binary_backup; then + if is_binary_backup $snapshot_dir; then if $CLUSTER ; then ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") if [ -z $ghe_mysql_master ]; then @@ -81,7 +76,7 @@ if is_binary_backup_feature_on; then fi else # We do not allow to restore binary backup without "mysql.backup.binary" set - if is_binary_backup; then + if is_binary_backup $snapshot_dir; then echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 else From 9f728a165af83fd6df1db288b298fc9c3e8799fa Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Thu, 14 May 2020 05:00:17 +0000 Subject: [PATCH 1033/2421] Remove logging in ghe-restore-mysql --- share/github-backup-utils/ghe-restore-mysql | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index f43b5b786..6a546a52a 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -28,18 +28,6 @@ ghe_remote_version_required "$GHE_HOSTNAME" # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -if is_binary_backup_feature_on; then - echo "Appliance is configured for binary backups." -else - echo "Appliance is configured for logical backups." -fi - -if is_binary_backup $snapshot_dir; then - echo "Backup being restored is a binary backup." -else - echo "Backup being restored is a logical backup." -fi - ssh_config_file_opt= if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available From 195882a3c15cca154cc47845c5317a247749995b Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Thu, 14 May 2020 05:01:13 +0000 Subject: [PATCH 1034/2421] Quote variable for protection --- share/github-backup-utils/ghe-restore-mysql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 6a546a52a..81189f059 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -31,7 +31,7 @@ snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" ssh_config_file_opt= if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available - if is_binary_backup $snapshot_dir; then + if is_binary_backup "$snapshot_dir"; then if $CLUSTER ; then ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") if [ -z $ghe_mysql_master ]; then @@ -64,7 +64,7 @@ if is_binary_backup_feature_on; then fi else # We do not allow to restore binary backup without "mysql.backup.binary" set - if is_binary_backup $snapshot_dir; then + if is_binary_backup "$snapshot_dir"; then echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 else From a4210b3121349482baa79393b4d477e26a2b50cd Mon Sep 17 00:00:00 2001 From: Sho Mizutani Date: Sat, 7 Mar 2020 01:06:30 +0900 Subject: [PATCH 1035/2421] Compress remote_routes_list on the source instance --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- share/github-backup-utils/ghe-restore-pages | 2 +- share/github-backup-utils/ghe-restore-repositories | 2 +- share/github-backup-utils/ghe-restore-repositories-gist | 2 +- share/github-backup-utils/ghe-restore-storage | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index bd979f908..a66934d0d 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -128,7 +128,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index c561b164d..db49bc8e7 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -96,7 +96,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 0149bb48a..17f80ae79 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -113,7 +113,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index a420c6c70..e1ab6e0a7 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -125,7 +125,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 6ba96ea51..946dbc50d 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -115,7 +115,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Transferring routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list cat $routes_list | ghe_debug bm_end "$(basename $0) - Transferring routes" diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index bd86ed91f..292db7659 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -105,7 +105,7 @@ ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list > $routes_list +ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list cat $routes_list | ghe_debug bm_end "$(basename $0) - Fetching routes" From adfdc07c21ecd0c7be2bffd75ab0caa0f2613ece Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 1 Jun 2020 22:07:18 -0400 Subject: [PATCH 1036/2421] Fix main.yml to get test pass --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4768bfccd..32b4d8a97 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,16 +13,16 @@ jobs: - name: Install Dependencies (Linux) run: | sudo apt-get update -y - sudo apt-get install -y devscripts debhelper moreutils fakeroot jq + sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck if: matrix.os == 'ubuntu-latest' - name: Install Dependencies (macOS) run: | - brew install gnu-tar shellcheck jq + brew install gnu-tar shellcheck jq pigz coreutils brew unlink parallel - brew install moreutils + brew install moreutils gawk if: matrix.os == 'macos-latest' - name: Get Sources uses: actions/checkout@v2 From ff2eee0562bcbfa982a1b4201aeba3174ba1bbd0 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 3 Jun 2020 14:35:37 +0000 Subject: [PATCH 1037/2421] Add external service check, for mysql only now. --- share/github-backup-utils/ghe-backup-config | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 176ecdc17..83258b735 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -389,4 +389,16 @@ is_binary_backup_feature_on(){ # Check if the backup is binary by looking up the sentinel file is_binary_backup(){ test -f "$1/mysql-binary-backup-sentinel" +} + +is_service_external(){ + service=$1 + case $service in + "mysql") + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.external.enabled" + ;; + *) + return 1 + ;; + esac } \ No newline at end of file From e0800da4e2a23c5f25844a6941c63ad177caf2ed Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 3 Jun 2020 15:45:22 +0000 Subject: [PATCH 1038/2421] Execute backup script and exit early from `ghe-backup-mysql` --- backup.config-example | 4 ++++ bin/ghe-backup | 5 ----- share/github-backup-utils/ghe-backup-config | 2 +- share/github-backup-utils/ghe-backup-mysql | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/backup.config-example b/backup.config-example index a7a51bb32..c2610574d 100644 --- a/backup.config-example +++ b/backup.config-example @@ -77,3 +77,7 @@ GHE_NUM_SNAPSHOTS=10 # # WARNING: this feature is in beta. #GHE_PARALLEL_MAX_LOAD=50 + +# When running an external mysql database, run this script to trigger a MySQL backup +# rather than attempting to backup via backup-utils directly. +#EXTERNAL_DATABASE_BACKUP_SCRIPT="" \ No newline at end of file diff --git a/bin/ghe-backup b/bin/ghe-backup index 3763aa5bf..c661a74f2 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -180,11 +180,6 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar || failures="$failures ssh-host-keys" bm_end "ghe-export-ssh-host-keys" -if is_binary_backup_feature_on; then - echo "Backing up MySQL database using binary backup strategy ..." -else - echo "Backing up MySQL database using logical backup strategy ..." -fi ghe-backup-mysql || failures="$failures mysql" commands=(" diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 83258b735..7fab8cd36 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -401,4 +401,4 @@ is_service_external(){ return 1 ;; esac -} \ No newline at end of file +} diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 6148fd2d5..e74f093e1 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -15,6 +15,20 @@ bm_start "$(basename $0)" # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" +if is_service_external 'mysql'; then + # Trigger client mysql backup hook + $EXTERNAL_DATABASE_BACKUP_SCRIPT + # Exit early. If the script returns a non-zero exit code, it will be caught by + # `set -e` + exit 0 +fi + +if is_binary_backup_feature_on; then + echo "Backing up MySQL database using binary backup strategy ..." +else + echo "Backing up MySQL database using logical backup strategy ..." +fi + export_command="ghe-export-mysql" if ! is_binary_backup_feature_on; then # binary backup is already compressed From 187c29fea6cc4187ef3a2b6d4c9df05b10fd9f0a Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 3 Jun 2020 15:51:10 +0000 Subject: [PATCH 1039/2421] Finish the benchmark before exiting --- share/github-backup-utils/ghe-backup-mysql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index e74f093e1..459771586 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -18,8 +18,9 @@ ghe_remote_version_required "$GHE_HOSTNAME" if is_service_external 'mysql'; then # Trigger client mysql backup hook $EXTERNAL_DATABASE_BACKUP_SCRIPT - # Exit early. If the script returns a non-zero exit code, it will be caught by - # `set -e` + # Finsh the benchmark and exit early. If the script returns a non-zero + # exit code, it will be caught by`set -e` + bm_end "$(basename $0)" exit 0 fi From d4b730f6e7add871489f0f1522d7f0f1ae98ff33 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 3 Jun 2020 15:52:46 +0000 Subject: [PATCH 1040/2421] Newline at end of file --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index c2610574d..81711f4b6 100644 --- a/backup.config-example +++ b/backup.config-example @@ -80,4 +80,4 @@ GHE_NUM_SNAPSHOTS=10 # When running an external mysql database, run this script to trigger a MySQL backup # rather than attempting to backup via backup-utils directly. -#EXTERNAL_DATABASE_BACKUP_SCRIPT="" \ No newline at end of file +#EXTERNAL_DATABASE_BACKUP_SCRIPT="" From 822df78d73281f5a7f853909ad16d777096a99a1 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 3 Jun 2020 16:06:43 +0000 Subject: [PATCH 1041/2421] Set default value to /bin/false. Mysql backups will fail until changed. --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 81711f4b6..9269bc137 100644 --- a/backup.config-example +++ b/backup.config-example @@ -80,4 +80,4 @@ GHE_NUM_SNAPSHOTS=10 # When running an external mysql database, run this script to trigger a MySQL backup # rather than attempting to backup via backup-utils directly. -#EXTERNAL_DATABASE_BACKUP_SCRIPT="" +#EXTERNAL_DATABASE_BACKUP_SCRIPT="/bin/false" From e6f7a1dc4d38c9c7c3019e8a0dd88b29cf2668bb Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 3 Jun 2020 16:41:14 +0000 Subject: [PATCH 1042/2421] Logging and backup script check --- share/github-backup-utils/ghe-backup-mysql | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 459771586..e07cb68a5 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -17,7 +17,13 @@ ghe_remote_version_required "$GHE_HOSTNAME" if is_service_external 'mysql'; then # Trigger client mysql backup hook - $EXTERNAL_DATABASE_BACKUP_SCRIPT + echo "Backing up external MySQL database using customer-provided script..." + if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then + $EXTERNAL_DATABASE_BACKUP_SCRIPT + else + echo "Error: EXTERNAL_DATABASE_BACKUP_SCRIPT is not configured. Please configure in backup.config." + exit 1 + fi # Finsh the benchmark and exit early. If the script returns a non-zero # exit code, it will be caught by`set -e` bm_end "$(basename $0)" From 97ee985bdee741d06da0d37886a17acdf398cc11 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 3 Jun 2020 16:42:49 +0000 Subject: [PATCH 1043/2421] Remove comment --- share/github-backup-utils/ghe-backup-mysql | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index e07cb68a5..3a8daa830 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -16,7 +16,6 @@ bm_start "$(basename $0)" ghe_remote_version_required "$GHE_HOSTNAME" if is_service_external 'mysql'; then - # Trigger client mysql backup hook echo "Backing up external MySQL database using customer-provided script..." if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then $EXTERNAL_DATABASE_BACKUP_SCRIPT From 7d0904d42f4cfbb492ce0a873c949bb236a1da3b Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 4 Jun 2020 14:22:53 +0000 Subject: [PATCH 1044/2421] Backup and restore the external mysql password --- share/github-backup-utils/ghe-backup-settings | 13 +++++++++++++ share/github-backup-utils/ghe-restore-settings | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 1e5f0935a..33e14168f 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -35,6 +35,19 @@ else unlink manage-password+ fi +# Backup external MySQL password if running external MySQL DB. +if is_service_external 'mysql'; then + echo "Transferring external MySQL password..." 1>&3 + ghe-ssh "$host" -- ghe-config secrets.external.mysql > external-mysql-password+ || ( + echo "Warning: External MySQL password not set" >&2 + ) + if [ -n "$(cat external-mysql-password+)" ]; then + mv external-mysql-password+ external-mysql-password + else + unlink external-mysql-password+ + fi +fi + if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then echo "* Transferring SAML keys ..." 1>&3 ghe-ssh $host -- sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -cf - "idp.crt saml-sp.p12" > saml-keys.tar diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index ff4bbdb72..c236a3e36 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -41,6 +41,13 @@ if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/manage-password" ]; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash fi +# Restore external MySQL password if running external MySQL DB. +if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password"]; then + echo "Restoring external MySQL password ..." + echo "ghe-config secrets.external.mysql '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password")'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +fi + # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then echo "Restoring SAML keys ..." From 1c15d0d6ff80452b40df818366d38d1ff7dd80e3 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 4 Jun 2020 16:02:36 +0000 Subject: [PATCH 1045/2421] Fix syntax error --- share/github-backup-utils/ghe-restore-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index c236a3e36..068150f76 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -42,7 +42,7 @@ if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/manage-password" ]; then fi # Restore external MySQL password if running external MySQL DB. -if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password"]; then +if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password" ]; then echo "Restoring external MySQL password ..." echo "ghe-config secrets.external.mysql '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password")'" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash From c84db01acc7a2e04b8bb1f6275cf449f1604143f Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 4 Jun 2020 17:12:39 +0000 Subject: [PATCH 1046/2421] Restore the MySQL password before importing settings --- share/github-backup-utils/ghe-restore-settings | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 068150f76..017a9eb0a 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -28,6 +28,13 @@ GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" echo "Restoring license ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 +# Restore external MySQL password if running external MySQL DB. +if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password" ]; then + echo "Restoring external MySQL password ..." + echo "ghe-config secrets.external.mysql '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password")'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +fi + echo "Restoring settings ..." # work around issue importing settings with bad storage mode values ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | @@ -41,13 +48,6 @@ if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/manage-password" ]; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash fi -# Restore external MySQL password if running external MySQL DB. -if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password" ]; then - echo "Restoring external MySQL password ..." - echo "ghe-config secrets.external.mysql '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password")'" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -fi - # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then echo "Restoring SAML keys ..." From 73ed1c754fba6b1f73ce53d68b21c7b07c13064d Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 4 Jun 2020 19:51:38 +0000 Subject: [PATCH 1047/2421] Add restore entry point --- backup.config-example | 4 + share/github-backup-utils/ghe-restore-mysql | 99 +++++++++++---------- 2 files changed, 56 insertions(+), 47 deletions(-) diff --git a/backup.config-example b/backup.config-example index 9269bc137..565235d0b 100644 --- a/backup.config-example +++ b/backup.config-example @@ -81,3 +81,7 @@ GHE_NUM_SNAPSHOTS=10 # When running an external mysql database, run this script to trigger a MySQL backup # rather than attempting to backup via backup-utils directly. #EXTERNAL_DATABASE_BACKUP_SCRIPT="/bin/false" + +# When running an external mysql database, run this script to trigger a MySQL restore +# rather than attempting to backup via backup-utils directly. +#EXTERNAL_DATABASE_RESTORE_SCRIPT="/bin/false" \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 81189f059..6ced71013 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -28,63 +28,68 @@ ghe_remote_version_required "$GHE_HOSTNAME" # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -ssh_config_file_opt= -if is_binary_backup_feature_on; then - # Feature "mysql.backup.binary" is on, which means new backup scripts are available - if is_binary_backup "$snapshot_dir"; then - if $CLUSTER ; then - ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") - if [ -z $ghe_mysql_master ]; then - echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 - exit 2 +# When customer uses external database, we rely on customer to implement the restore process +if is_service_external 'mysql'; then + cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $EXTERNAL_DATABASE_RESTORE_SCRIPT +else + ssh_config_file_opt= + if is_binary_backup_feature_on; then + # Feature "mysql.backup.binary" is on, which means new backup scripts are available + if is_binary_backup "$snapshot_dir"; then + if $CLUSTER ; then + ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") + if [ -z $ghe_mysql_master ]; then + echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 + exit 2 + else + tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" + port=$(ssh_port_part "$GHE_HOSTNAME") + ghe_mysql_master=$ghe_mysql_master${port:+:$port} + fi else - tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" - port=$(ssh_port_part "$GHE_HOSTNAME") - ghe_mysql_master=$ghe_mysql_master${port:+:$port} + ghe_mysql_master=$GHE_HOSTNAME fi - else - ghe_mysql_master=$GHE_HOSTNAME - fi - # Check if the decompress needed by looking into the sentinel file - # In 2.19.5 we compress the binary backup twice - if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then - IMPORT_MYSQL=ghe-import-mysql-xtrabackup - GHE_RESTORE_HOST=$ghe_mysql_master + # Check if the decompress needed by looking into the sentinel file + # In 2.19.5 we compress the binary backup twice + if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then + IMPORT_MYSQL=ghe-import-mysql-xtrabackup + GHE_RESTORE_HOST=$ghe_mysql_master + else + IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" + GHE_RESTORE_HOST=$ghe_mysql_master + fi else - IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" - GHE_RESTORE_HOST=$ghe_mysql_master + IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + GHE_RESTORE_HOST=$GHE_HOSTNAME fi else - IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" - GHE_RESTORE_HOST=$GHE_HOSTNAME - fi -else - # We do not allow to restore binary backup without "mysql.backup.binary" set - if is_binary_backup "$snapshot_dir"; then - echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 - exit 2 - else - # legacy mode - IMPORT_MYSQL="unpigz | ghe-import-mysql" - GHE_RESTORE_HOST=$GHE_HOSTNAME + # We do not allow to restore binary backup without "mysql.backup.binary" set + if is_binary_backup "$snapshot_dir"; then + echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 + exit 2 + else + # legacy mode + IMPORT_MYSQL="unpigz | ghe-import-mysql" + GHE_RESTORE_HOST=$GHE_HOSTNAME + fi fi -fi -cleanup() { - ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" -} -trap 'cleanup' INT TERM EXIT + cleanup() { + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" + } + trap 'cleanup' INT TERM EXIT -ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 -# Transfer MySQL data from the snapshot to the GitHub instance. -cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" + # Transfer MySQL data from the snapshot to the GitHub instance. + cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" -# Import the database -echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 + # Import the database + echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 +fi bm_end "$(basename $0)" From 32d4eecb26eb98de2008846a58365165bc22da91 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 4 Jun 2020 21:04:43 +0000 Subject: [PATCH 1048/2421] A few updates to ghe-backup and ghe-restore --- bin/ghe-restore | 23 +++++++++++++-------- share/github-backup-utils/ghe-backup-mysql | 2 +- share/github-backup-utils/ghe-restore-mysql | 4 +++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 87f3acb18..39d4e2d5a 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -255,16 +255,21 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" fi -if is_binary_backup_feature_on; then - appliance_strategy="binary" -else - appliance_strategy="logical" -fi +if is_service_external 'mysql'; then + appliance_strategy="external" + backup_snapshot_strategy="external" +else + if is_binary_backup_feature_on; then + appliance_strategy="binary" + else + appliance_strategy="logical" + fi -if is_binary_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"; then - backup_snapshot_strategy="binary" -else - backup_snapshot_strategy="logical" + if is_binary_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"; then + backup_snapshot_strategy="binary" + else + backup_snapshot_strategy="logical" + fi fi echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 3a8daa830..04838f399 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -18,7 +18,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" if is_service_external 'mysql'; then echo "Backing up external MySQL database using customer-provided script..." if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then - $EXTERNAL_DATABASE_BACKUP_SCRIPT + $EXTERNAL_DATABASE_BACKUP_SCRIPT > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" else echo "Error: EXTERNAL_DATABASE_BACKUP_SCRIPT is not configured. Please configure in backup.config." exit 1 diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 6ced71013..1c8b2f22b 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -30,7 +30,8 @@ snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" # When customer uses external database, we rely on customer to implement the restore process if is_service_external 'mysql'; then - cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $EXTERNAL_DATABASE_RESTORE_SCRIPT + echo "Restore external MySQL database using customer-provided script ..." + cat $snapshot_dir/mysql.sql.gz | $EXTERNAL_DATABASE_RESTORE_SCRIPT else ssh_config_file_opt= if is_binary_backup_feature_on; then @@ -88,6 +89,7 @@ else # Transfer MySQL data from the snapshot to the GitHub instance. cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" + echo "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 fi From d059b2a6bb016efe809fe34e34d2e86424a0dfc3 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 5 Jun 2020 11:09:15 +0000 Subject: [PATCH 1049/2421] Add local file support for is_service_external --- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-backup-config | 8 +++- test/test-ghe-backup-config.sh | 41 +++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 39d4e2d5a..ac55a22a1 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -255,7 +255,7 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" fi -if is_service_external 'mysql'; then +if is_service_external 'mysql' "$GHE_RESTORE_SNAPSHOT_PATH/settings.json"; then appliance_strategy="external" backup_snapshot_strategy="external" else diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 7fab8cd36..b097b3dd8 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -393,9 +393,15 @@ is_binary_backup(){ is_service_external(){ service=$1 + config_file=$2 case $service in "mysql") - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.external.enabled" + if [ -n "$config_file" ]; then + enabled=$(GIT_CONFIG="$config_file" git config mysql.external.enabled) + [ "$enabled" == "true" ]; + else + ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.external.enabled" + fi ;; *) return 1 diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 1cc3968f5..326e44fe4 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -184,3 +184,44 @@ begin_test "ghe-backup-config ghe_debug accepts stdin as well as argument" unset GHE_VERBOSE_LOG ) end_test + +begin_test "ghe-backup-config is_service_external enabled external mysql" +( + set -e + + tmpfile=$(mktemp /tmp/abc-script.XXXXXX) + echo " +[mysql \"external\"] + enabled = true +" > $tmpfile + is_service_external 'mysql' $tmpfile +) +end_test + +begin_test "ghe-backup-config is_service_external disabled external mysql" +( + set -e + + tmpfile=$(mktemp /tmp/abc-script.XXXXXX) + echo " +[mysql \"external\"] + enabled = false +" > $tmpfile + + ! is_service_external 'mysql' $tmpfile +) +end_test + +begin_test "ghe-backup-config is_service_external unknown service" +( + set -e + + tmpfile=$(mktemp /tmp/abc-script.XXXXXX) + echo " +[mysql \"external\"] + enabled = false +" > $tmpfile + + ! is_service_external 'hubot' $tmpfile +) +end_test \ No newline at end of file From e09bfa3a0f8d46434cb85ef9a87d62b85c213655 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 5 Jun 2020 12:49:03 +0000 Subject: [PATCH 1050/2421] Use the settings file in the snapshot to determine external db --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 1c8b2f22b..8c0eef425 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -29,7 +29,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" # When customer uses external database, we rely on customer to implement the restore process -if is_service_external 'mysql'; then +if is_service_external 'mysql' "$snapshot_dir/settings.json"; then echo "Restore external MySQL database using customer-provided script ..." cat $snapshot_dir/mysql.sql.gz | $EXTERNAL_DATABASE_RESTORE_SCRIPT else From 7f9b059b107cf047e50ec92237512c6e8c8333ff Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 5 Jun 2020 13:16:33 +0000 Subject: [PATCH 1051/2421] Remove expectation of having the mysql data in the snapshot --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 8c0eef425..adefcc002 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -31,7 +31,7 @@ snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" # When customer uses external database, we rely on customer to implement the restore process if is_service_external 'mysql' "$snapshot_dir/settings.json"; then echo "Restore external MySQL database using customer-provided script ..." - cat $snapshot_dir/mysql.sql.gz | $EXTERNAL_DATABASE_RESTORE_SCRIPT + $EXTERNAL_DATABASE_RESTORE_SCRIPT else ssh_config_file_opt= if is_binary_backup_feature_on; then From 956d127aef865c14714bbb5a169a84dc0737b588 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 5 Jun 2020 16:14:16 -0400 Subject: [PATCH 1052/2421] Export GHE_DATA_DIR in ghe-backup-config so it will be available to customer script --- share/github-backup-utils/ghe-backup-config | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b097b3dd8..9623f9363 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -152,6 +152,7 @@ fi if [ ${GHE_DATA_DIR:0:1} != "/" ]; then GHE_DATA_DIR="$( cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR" 2> /dev/null || echo "$GHE_BACKUP_ROOT/$GHE_DATA_DIR" )" fi +export GHE_DATA_DIR # Assign the Release File path if it hasn't been provided (eg: by test suite) : ${GHE_RELEASE_FILE:="/etc/github/enterprise-release"} From 6cb2b67e42751d6e06c83573f15453e5b84030fc Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 5 Jun 2020 18:05:20 -0400 Subject: [PATCH 1053/2421] Do not require customer to use standard output for backup script --- share/github-backup-utils/ghe-backup-mysql | 2 +- share/github-backup-utils/ghe-restore-mysql | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 04838f399..3a8daa830 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -18,7 +18,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" if is_service_external 'mysql'; then echo "Backing up external MySQL database using customer-provided script..." if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then - $EXTERNAL_DATABASE_BACKUP_SCRIPT > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" + $EXTERNAL_DATABASE_BACKUP_SCRIPT else echo "Error: EXTERNAL_DATABASE_BACKUP_SCRIPT is not configured. Please configure in backup.config." exit 1 diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index adefcc002..3d141c00d 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -30,8 +30,12 @@ snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" # When customer uses external database, we rely on customer to implement the restore process if is_service_external 'mysql' "$snapshot_dir/settings.json"; then - echo "Restore external MySQL database using customer-provided script ..." - $EXTERNAL_DATABASE_RESTORE_SCRIPT + if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then + $EXTERNAL_DATABASE_RESTORE_SCRIPT + else + echo "Error: EXTERNAL_DATABASE_RESTORE_SCRIPT is not configured. Please configure in backup.config." + exit 1 + fi else ssh_config_file_opt= if is_binary_backup_feature_on; then From 5d92693102afa3b6a99d9d2f12ce3b0fbcae4375 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 5 Jun 2020 18:12:15 -0400 Subject: [PATCH 1054/2421] A few minor edits --- backup.config-example | 2 +- share/github-backup-utils/ghe-restore-mysql | 102 ++++++++++---------- test/test-ghe-backup-config.sh | 2 +- 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/backup.config-example b/backup.config-example index 565235d0b..61736a45b 100644 --- a/backup.config-example +++ b/backup.config-example @@ -84,4 +84,4 @@ GHE_NUM_SNAPSHOTS=10 # When running an external mysql database, run this script to trigger a MySQL restore # rather than attempting to backup via backup-utils directly. -#EXTERNAL_DATABASE_RESTORE_SCRIPT="/bin/false" \ No newline at end of file +#EXTERNAL_DATABASE_RESTORE_SCRIPT="/bin/false" diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 3d141c00d..2aa4f6a62 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -36,66 +36,70 @@ if is_service_external 'mysql' "$snapshot_dir/settings.json"; then echo "Error: EXTERNAL_DATABASE_RESTORE_SCRIPT is not configured. Please configure in backup.config." exit 1 fi -else - ssh_config_file_opt= - if is_binary_backup_feature_on; then - # Feature "mysql.backup.binary" is on, which means new backup scripts are available - if is_binary_backup "$snapshot_dir"; then - if $CLUSTER ; then - ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") - if [ -z $ghe_mysql_master ]; then - echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 - exit 2 - else - tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" - port=$(ssh_port_part "$GHE_HOSTNAME") - ghe_mysql_master=$ghe_mysql_master${port:+:$port} - fi - else - ghe_mysql_master=$GHE_HOSTNAME - fi + # Finsh the benchmark and exit early. If the script returns a non-zero + # exit code, it will be caught by`set -e` + bm_end "$(basename $0)" + exit 0 +fi - # Check if the decompress needed by looking into the sentinel file - # In 2.19.5 we compress the binary backup twice - if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then - IMPORT_MYSQL=ghe-import-mysql-xtrabackup - GHE_RESTORE_HOST=$ghe_mysql_master +ssh_config_file_opt= +if is_binary_backup_feature_on; then + # Feature "mysql.backup.binary" is on, which means new backup scripts are available + if is_binary_backup "$snapshot_dir"; then + if $CLUSTER ; then + ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") + if [ -z $ghe_mysql_master ]; then + echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 + exit 2 else - IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" - GHE_RESTORE_HOST=$ghe_mysql_master + tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" + port=$(ssh_port_part "$GHE_HOSTNAME") + ghe_mysql_master=$ghe_mysql_master${port:+:$port} fi else - IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" - GHE_RESTORE_HOST=$GHE_HOSTNAME + ghe_mysql_master=$GHE_HOSTNAME fi - else - # We do not allow to restore binary backup without "mysql.backup.binary" set - if is_binary_backup "$snapshot_dir"; then - echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 - exit 2 + + # Check if the decompress needed by looking into the sentinel file + # In 2.19.5 we compress the binary backup twice + if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then + IMPORT_MYSQL=ghe-import-mysql-xtrabackup + GHE_RESTORE_HOST=$ghe_mysql_master else - # legacy mode - IMPORT_MYSQL="unpigz | ghe-import-mysql" - GHE_RESTORE_HOST=$GHE_HOSTNAME + IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" + GHE_RESTORE_HOST=$ghe_mysql_master fi + else + IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + GHE_RESTORE_HOST=$GHE_HOSTNAME + fi +else + # We do not allow to restore binary backup without "mysql.backup.binary" set + if is_binary_backup "$snapshot_dir"; then + echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 + exit 2 + else + # legacy mode + IMPORT_MYSQL="unpigz | ghe-import-mysql" + GHE_RESTORE_HOST=$GHE_HOSTNAME fi +fi - cleanup() { - ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" - } - trap 'cleanup' INT TERM EXIT +cleanup() { + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" +} +trap 'cleanup' INT TERM EXIT - ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 +ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 - # Transfer MySQL data from the snapshot to the GitHub instance. - cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" +# Transfer MySQL data from the snapshot to the GitHub instance. +cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" - echo "Restore MySQL database ..." - # Import the database - echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 -fi +echo "Restore MySQL database ..." +# Import the database +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 bm_end "$(basename $0)" diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 326e44fe4..16656e798 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -224,4 +224,4 @@ begin_test "ghe-backup-config is_service_external unknown service" ! is_service_external 'hubot' $tmpfile ) -end_test \ No newline at end of file +end_test From 9ec815e250ea57a762cdfcb47494ef4157f87971 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Mon, 8 Jun 2020 13:28:39 +0000 Subject: [PATCH 1055/2421] Export `GHE_RESTORE_SNAPSHOT` for use in custom script --- share/github-backup-utils/ghe-restore-mysql | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 2aa4f6a62..ccd5f4f34 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -24,6 +24,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" # The snapshot to restore should be set by the ghe-restore command but this lets # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} +export GHE_RESTORE_SNAPSHOT # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" From 0683567c45c5595da07ac98abd89b399575fdf2d Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 8 Jun 2020 10:27:13 -0700 Subject: [PATCH 1056/2421] other ubuntu verisons --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 32b4d8a97..05d80ad75 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ jobs: build: strategy: matrix: - os: ['ubuntu-latest', 'macos-latest'] + os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest'] runs-on: ${{ matrix.os }} steps: @@ -17,7 +17,7 @@ jobs: wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck - if: matrix.os == 'ubuntu-latest' + if: matrix.os == ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04'] - name: Install Dependencies (macOS) run: | brew install gnu-tar shellcheck jq pigz coreutils From b9317dc3df41c87d10047a258ebecb8125bb5468 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 8 Jun 2020 10:59:19 -0700 Subject: [PATCH 1057/2421] use not-equals --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 05d80ad75..82bdf486d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck - if: matrix.os == ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04'] + if: matrix.os != 'macos-latest' - name: Install Dependencies (macOS) run: | brew install gnu-tar shellcheck jq pigz coreutils @@ -33,5 +33,5 @@ jobs: shell: bash - name: Build run: debuild -uc -us - if: matrix.os == 'ubuntu-latest' + if: matrix.os != 'macos-latest' From 65cb8f6e00b2d9cf0ef63d48b1e58d1c7560ffe4 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 8 Jun 2020 12:08:52 -0700 Subject: [PATCH 1058/2421] set fail-fast false --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 82bdf486d..e12ef4554 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,8 +7,9 @@ jobs: strategy: matrix: os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest'] + fail-fast: false runs-on: ${{ matrix.os }} - + steps: - name: Install Dependencies (Linux) run: | From 25c68bb137769229d2a5461a85df0c9054f4afc4 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 8 Jun 2020 15:11:27 -0700 Subject: [PATCH 1059/2421] only make test on macOS --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e12ef4554..d37d3bdc6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,12 +27,13 @@ jobs: if: matrix.os == 'macos-latest' - name: Get Sources uses: actions/checkout@v2 - - name: Test + - name: Test (macOS) run: | export PATH="$PATH:/snap/bin" make test shell: bash - - name: Build + if: matrix.os == 'macos-latest' + - name: Build (Linux) run: debuild -uc -us if: matrix.os != 'macos-latest' From 1079f30706dd0a2bc168c7739add2a92d7038abb Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 8 Jun 2020 15:28:01 -0700 Subject: [PATCH 1060/2421] nocheck debuild --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d37d3bdc6..a44864e18 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,19 +21,19 @@ jobs: if: matrix.os != 'macos-latest' - name: Install Dependencies (macOS) run: | - brew install gnu-tar shellcheck jq pigz coreutils + brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt brew unlink parallel brew install moreutils gawk if: matrix.os == 'macos-latest' - name: Get Sources uses: actions/checkout@v2 - - name: Test (macOS) + - name: Test run: | export PATH="$PATH:/snap/bin" make test shell: bash if: matrix.os == 'macos-latest' - name: Build (Linux) - run: debuild -uc -us + run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc if: matrix.os != 'macos-latest' From abca3ffea6610ae9628b9c783b2a9af64af0fed0 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 8 Jun 2020 15:30:17 -0700 Subject: [PATCH 1061/2421] test on all matrix os --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a44864e18..0315a7e28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,7 +32,6 @@ jobs: export PATH="$PATH:/snap/bin" make test shell: bash - if: matrix.os == 'macos-latest' - name: Build (Linux) run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc if: matrix.os != 'macos-latest' From f1e4947aba2bb65060869587e9dd3350ee1fae3f Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Tue, 9 Jun 2020 16:37:53 +0000 Subject: [PATCH 1062/2421] Add --skip-mysql flag and check for compatability of snapshots When using a BYODB snapshot with a non-BYODB instance, and not restoring the BYODB configuration, require that the --skip-mysql flag be passed. Same for non-BYODB to BYODB. This assums that the end user has already restored the backup to MySQL manually prior to triggering the restore. --- bin/ghe-restore | 31 ++++++++++++++++++++- share/github-backup-utils/ghe-backup-config | 31 +++++++++++++++++++++ share/github-backup-utils/ghe-restore-mysql | 6 +++- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index ac55a22a1..f5256f905 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -10,6 +10,7 @@ #/ #/ OPTIONS: #/ -f | --force Don't prompt for confirmation before restoring. +#/ --skip-mysql Skip MySQL restore steps. Only applicable to external databases. #/ -c | --config Restore appliance settings and license in addition to #/ datastores. Settings are not restored by default to #/ prevent overwriting different configuration on the @@ -31,8 +32,16 @@ set -e # Parse arguments restore_settings=false force=false + +: ${SKIP_MYSQL:=false} +export SKIP_MYSQL + while true; do case "$1" in + --skip-mysql) + SKIP_MYSQL=true + shift + ;; -f|--force) force=true shift @@ -116,12 +125,32 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Figure out if this instance has been configured or is entirely new. instance_configured=false -if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then +if instance_is_configured; then instance_configured=true else restore_settings=true fi +# Check backup is compatible with running appliance. +if check_external_database_snapshot_compatibility; then + # External DB backup with non external DB appliance + if external_database_snapshot_to_internal_database; then + echo "Error: Snapshot from GitHub Enterprise with a External Database configured" \ + "cannot be restored to an appliance without external database configured. Aborting." \ + "To restore this snapshot, you must restore the appliance configuration (-c)" \ + "or skip the MySQL restore steps (--skip-mysql) after restoring manually." >&2 + exit 1 + fi + + if internal_database_snapshow_to_external_database; then + echo "Error: Snapshot from GitHub Enterprise with internal database" \ + "cannot be restored to an appliance with an external database configured. Aborting." \ + "To restore this snapshot, you must restore the appliance configuration (-c)" \ + "or skip the MySQL restore steps (--skip-mysql) after restoring manually." >&2 + exit 1 + fi +fi + # Figure out if we're restoring into cluster CLUSTER=false if ghe-ssh "$GHE_HOSTNAME" -- \ diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 9623f9363..1e03b5577 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -409,3 +409,34 @@ is_service_external(){ ;; esac } + +instance_is_configured(){ + ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]" +} + +check_external_database_snapshot_compatibility(){ + # always restore to an unconfigured instance. + if !instance_is_configured; then + return 1 + fi + + # If restoring settings, the target appliance will be converted. + if restore_settings; then + return 1 + fi + + # If skipping MySQL steps, assume the MySQL backup has already been restored prior to ghe-restore. + if SKIP_MYSQL; then + return 1 + fi + + return 0 +} + +external_database_snapshot_to_internal_database(){ + !is_service_external "mysql" && is_service_external "mysql" "$GHE_RESTORE_SNAPSHOT/settings.json" +} + +internal_database_snapshow_to_external_database(){ + is_service_external "mysql" && !is_service_external "mysql" "$GHE_RESTORE_SNAPSHOT/settings.json" +} \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index ccd5f4f34..7ecf97731 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -29,8 +29,12 @@ export GHE_RESTORE_SNAPSHOT # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -# When customer uses external database, we rely on customer to implement the restore process +# When customer uses external database, we rely on customer to implement the restore process. if is_service_external 'mysql' "$snapshot_dir/settings.json"; then + if $SKIP_MYSQL; then + exit 0 + fi + if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT else From 5e064f111a2e2d51ca89c5dc4fb092c95f517394 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 9 Jun 2020 10:27:36 -0700 Subject: [PATCH 1063/2421] Include middle major version for testing --- script/cibuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 13ccc130b..d29053212 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.18.0 2.20.0" +REMOTE_VERSIONS="2.18.0 2.19.0 2.20.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true From 6aed7bbbab10982be850c756d152d34b6ba54fff Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 9 Jun 2020 17:59:06 +0000 Subject: [PATCH 1064/2421] Bump version: 2.21.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 12 ++++++++++++ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index be77fd315..94f235e51 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.18.0" +supported_minimum_version="2.19.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index a3a248779..dfd337512 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +github-backup-utils (2.21.0) UNRELEASED; urgency=medium + + * Introduce option to skip restoring of audit logs #596 + * Beta: Execute ghe-backup tasks in parallel #597 + * Beta: Execute ghe-restore tasks in parallel #601 + * Run repositories restore in parallel #603 + * Fix mismatched `bm_start` and `bm_end` commands #607 + * remove rsync restore method used by GHES versions prior to 2.13 #608 + * Output MySQL backup strategy for clarity during backup and restore #610 + + -- Hao Jiang Tue, 09 Jun 2020 17:59:06 +0000 + github-backup-utils (2.19.5) UNRELEASED; urgency=medium * In legacy mode we should use ghe-import-mysql #581 diff --git a/script/cibuild b/script/cibuild index 13ccc130b..a486ae960 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.18.0 2.20.0" +REMOTE_VERSIONS="2.19.0 2.21.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 83ecbf1d7..db65e2167 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.20.2 +2.21.0 diff --git a/test/testlib.sh b/test/testlib.sh index a5933cc9d..222b8dd9f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.20.0} +: ${GHE_TEST_REMOTE_VERSION:=2.21.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From b322f91cfa892ae836f97d3353b027043c54ab18 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 9 Jun 2020 17:59:06 +0000 Subject: [PATCH 1065/2421] Bump version: 2.21.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 12 ++++++++++++ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index be77fd315..94f235e51 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.18.0" +supported_minimum_version="2.19.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index a3a248779..dfd337512 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +github-backup-utils (2.21.0) UNRELEASED; urgency=medium + + * Introduce option to skip restoring of audit logs #596 + * Beta: Execute ghe-backup tasks in parallel #597 + * Beta: Execute ghe-restore tasks in parallel #601 + * Run repositories restore in parallel #603 + * Fix mismatched `bm_start` and `bm_end` commands #607 + * remove rsync restore method used by GHES versions prior to 2.13 #608 + * Output MySQL backup strategy for clarity during backup and restore #610 + + -- Hao Jiang Tue, 09 Jun 2020 17:59:06 +0000 + github-backup-utils (2.19.5) UNRELEASED; urgency=medium * In legacy mode we should use ghe-import-mysql #581 diff --git a/script/cibuild b/script/cibuild index d29053212..f052a17d8 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.18.0 2.19.0 2.20.0" +REMOTE_VERSIONS="2.19.0 2.20.0 2.21.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 83ecbf1d7..db65e2167 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.20.2 +2.21.0 diff --git a/test/testlib.sh b/test/testlib.sh index a5933cc9d..222b8dd9f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.20.0} +: ${GHE_TEST_REMOTE_VERSION:=2.21.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From a38a259dbb268f42871023675d2bf306e5b10d3c Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 9 Jun 2020 11:08:57 -0700 Subject: [PATCH 1066/2421] Revert "Bump version: 2.21.0 [ci skip]" This reverts commit b322f91cfa892ae836f97d3353b027043c54ab18. --- bin/ghe-host-check | 2 +- debian/changelog | 12 ------------ script/cibuild | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 94f235e51..be77fd315 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.19.0" +supported_minimum_version="2.18.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index dfd337512..a3a248779 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,15 +1,3 @@ -github-backup-utils (2.21.0) UNRELEASED; urgency=medium - - * Introduce option to skip restoring of audit logs #596 - * Beta: Execute ghe-backup tasks in parallel #597 - * Beta: Execute ghe-restore tasks in parallel #601 - * Run repositories restore in parallel #603 - * Fix mismatched `bm_start` and `bm_end` commands #607 - * remove rsync restore method used by GHES versions prior to 2.13 #608 - * Output MySQL backup strategy for clarity during backup and restore #610 - - -- Hao Jiang Tue, 09 Jun 2020 17:59:06 +0000 - github-backup-utils (2.19.5) UNRELEASED; urgency=medium * In legacy mode we should use ghe-import-mysql #581 diff --git a/script/cibuild b/script/cibuild index f052a17d8..d29053212 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,7 +6,7 @@ set -e # place with this version at the beginning of each test and many commands have # conditional logic based on the remote version. Running the suite against # different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.19.0 2.20.0 2.21.0" +REMOTE_VERSIONS="2.18.0 2.19.0 2.20.0" # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index db65e2167..83ecbf1d7 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.21.0 +2.20.2 diff --git a/test/testlib.sh b/test/testlib.sh index 222b8dd9f..a5933cc9d 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.21.0} +: ${GHE_TEST_REMOTE_VERSION:=2.20.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 4a866aa0097bc24b43e8d60c1181110a324e05d5 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Tue, 9 Jun 2020 14:09:56 -0400 Subject: [PATCH 1067/2421] Update RELEASING.md only repo admin can run this. --- RELEASING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASING.md b/RELEASING.md index 1d6ee41c3..d99e797e2 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -8,6 +8,8 @@ There is no need to align Backup Utilities patch releases with GitHub Enterprise When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise Server that that release supports. +Only repo administrator is allowed to run the release script, otherwise it will fail. + ## Pre-release Actions Prior to making a release, From b71e25bafe8e0749034fae5fb14c8b8dd723cccb Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 10 Jun 2020 11:35:28 +0000 Subject: [PATCH 1068/2421] Fix syntax errors and move mysql skipping to ghe-restore --- bin/ghe-restore | 10 +++++++--- share/github-backup-utils/ghe-backup-config | 16 +++++++++++----- share/github-backup-utils/ghe-restore-mysql | 7 +------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index f5256f905..c713a5257 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -284,7 +284,7 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" fi -if is_service_external 'mysql' "$GHE_RESTORE_SNAPSHOT_PATH/settings.json"; then +if is_external_database_restore; then appliance_strategy="external" backup_snapshot_strategy="external" else @@ -301,8 +301,12 @@ else fi fi -echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." -ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 +if is_external_database_restore && $SKIP_MYSQL; then + echo "Skipping MySQL restore." +else + echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." + ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 +fi commands=(" echo \"Restoring Redis database ...\" diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 1e03b5577..dc350da57 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -416,17 +416,17 @@ instance_is_configured(){ check_external_database_snapshot_compatibility(){ # always restore to an unconfigured instance. - if !instance_is_configured; then + if ! instance_is_configured; then return 1 fi # If restoring settings, the target appliance will be converted. - if restore_settings; then + if $restore_settings; then return 1 fi # If skipping MySQL steps, assume the MySQL backup has already been restored prior to ghe-restore. - if SKIP_MYSQL; then + if $SKIP_MYSQL; then return 1 fi @@ -434,9 +434,15 @@ check_external_database_snapshot_compatibility(){ } external_database_snapshot_to_internal_database(){ - !is_service_external "mysql" && is_service_external "mysql" "$GHE_RESTORE_SNAPSHOT/settings.json" + ! is_service_external "mysql" && is_service_external "mysql" "$GHE_RESTORE_SNAPSHOT/settings.json" } internal_database_snapshow_to_external_database(){ - is_service_external "mysql" && !is_service_external "mysql" "$GHE_RESTORE_SNAPSHOT/settings.json" + is_service_external "mysql" && ! is_service_external "mysql" "$GHE_RESTORE_SNAPSHOT/settings.json" +} + +is_external_database_restore(){ + # Check if restoring a snapshot with an external database configured, or restoring + # to an appliance with an external database configured. + is_service_external 'mysql' "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" || is_service_external 'mysql' } \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 7ecf97731..dd7fd00a8 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -29,12 +29,7 @@ export GHE_RESTORE_SNAPSHOT # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -# When customer uses external database, we rely on customer to implement the restore process. -if is_service_external 'mysql' "$snapshot_dir/settings.json"; then - if $SKIP_MYSQL; then - exit 0 - fi - +if is_external_database_restore; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT else From 1b5a095bd1776169e0916d596fe324e3f4677c36 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 10 Jun 2020 11:49:47 +0000 Subject: [PATCH 1069/2421] Rename and export arguments for use in child scripts --- bin/ghe-restore | 17 ++++++++++------- share/github-backup-utils/ghe-backup-config | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index c713a5257..21e71de70 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -30,8 +30,11 @@ set -e # Parse arguments -restore_settings=false -force=false +: ${RESTORE_SETTINGS:=false} +export RESTORE_SETTINGS + +: ${FORCE:=false} +export FORCE : ${SKIP_MYSQL:=false} export SKIP_MYSQL @@ -43,7 +46,7 @@ while true; do shift ;; -f|--force) - force=true + FORCE=true shift ;; -s) @@ -51,7 +54,7 @@ while true; do shift 2 ;; -c|--config) - restore_settings=true + RESTORE_SETTINGS=true shift ;; -h|--help) @@ -128,7 +131,7 @@ instance_configured=false if instance_is_configured; then instance_configured=true else - restore_settings=true + RESTORE_SETTINGS=true fi # Check backup is compatible with running appliance. @@ -178,7 +181,7 @@ fi # important data on the destination appliance that cannot be recovered. This is # mostly to prevent accidents where the backup host is given to restore instead # of a separate restore host since they're used in such close proximity. -if $instance_configured && ! $force; then +if $instance_configured && ! $FORCE; then echo echo "WARNING: All data on GitHub Enterprise appliance $hostname ($GHE_REMOTE_VERSION)" echo " will be overwritten with data from snapshot ${GHE_RESTORE_SNAPSHOT}." @@ -263,7 +266,7 @@ fi # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. -if $restore_settings; then +if $RESTORE_SETTINGS; then ghe-restore-settings "$GHE_HOSTNAME" fi diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index dc350da57..283a46cf4 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -421,7 +421,7 @@ check_external_database_snapshot_compatibility(){ fi # If restoring settings, the target appliance will be converted. - if $restore_settings; then + if $RESTORE_SETTINGS; then return 1 fi From a6b12d6704fd8c4de3ada586a5d5f0de0704ed1b Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 11 Jun 2020 13:39:42 +0000 Subject: [PATCH 1070/2421] Add support for github.conf to ghe-config stub, tests for external db --- share/github-backup-utils/ghe-backup-config | 8 +- test/bin/ghe-config | 8 +- test/test-ghe-restore-external-database.sh | 83 +++++++++++++++++++++ 3 files changed, 94 insertions(+), 5 deletions(-) create mode 100755 test/test-ghe-restore-external-database.sh diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 283a46cf4..1981a5b3d 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -401,7 +401,7 @@ is_service_external(){ enabled=$(GIT_CONFIG="$config_file" git config mysql.external.enabled) [ "$enabled" == "true" ]; else - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.external.enabled" + ghe-ssh "$GHE_HOSTNAME" -- ghe-config --true "mysql.external.enabled" fi ;; *) @@ -434,15 +434,15 @@ check_external_database_snapshot_compatibility(){ } external_database_snapshot_to_internal_database(){ - ! is_service_external "mysql" && is_service_external "mysql" "$GHE_RESTORE_SNAPSHOT/settings.json" + ! is_service_external "mysql" && is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } internal_database_snapshow_to_external_database(){ - is_service_external "mysql" && ! is_service_external "mysql" "$GHE_RESTORE_SNAPSHOT/settings.json" + is_service_external "mysql" && ! is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } is_external_database_restore(){ # Check if restoring a snapshot with an external database configured, or restoring # to an appliance with an external database configured. - is_service_external 'mysql' "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" || is_service_external 'mysql' + is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" || is_service_external 'mysql' } \ No newline at end of file diff --git a/test/bin/ghe-config b/test/bin/ghe-config index 464977fff..f5a44ed66 100755 --- a/test/bin/ghe-config +++ b/test/bin/ghe-config @@ -9,4 +9,10 @@ if [ "$1" = "--true" ]; then [[ $($0 "$@") = true ]] && exit 0 || exit 1 fi -git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" "$@" +if [[ "$1" =~ "secrets." ]]; then + CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" +else + CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/github.conf" +fi + +git config -f $CONFIG "$@" diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh new file mode 100755 index 000000000..29d7a45d3 --- /dev/null +++ b/test/test-ghe-restore-external-database.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash +# ghe-restore command tests - external database + +# Bring in testlib +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" + +setup_test_data "$GHE_DATA_DIR/1" + +# Make the current symlink +ln -s 1 "$GHE_DATA_DIR/current" + +begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # Enable external database in snapshot + rm -rf "$GHE_DATA_DIR/current/settings.json" + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # Verify that the restore failed due to snapshot compatability. + grep -q "Snapshot from GitHub Enterprise with a External Database configured cannot be restored + to an appliance without external database configured." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + + exit 1 + fi +) +end_test + +begin_test "ghe-restore prevents restore of non DB snapshot to external DB appliance" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # Enable external database in snapshot + rm -rf "$GHE_DATA_DIR/current/settings.json" + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 bash -x ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # Verify that the restore failed due to snapshot compatability. + grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored + to an appliance with an external database configured." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + + exit 1 + fi +) +end_test From 48ab8334de59ca55f39bac7a40b5b1a2b79e95ed Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 11 Jun 2020 13:51:45 +0000 Subject: [PATCH 1071/2421] Fix shellcheck issue --- test/bin/ghe-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bin/ghe-config b/test/bin/ghe-config index f5a44ed66..6943ef1a2 100755 --- a/test/bin/ghe-config +++ b/test/bin/ghe-config @@ -9,7 +9,7 @@ if [ "$1" = "--true" ]; then [[ $($0 "$@") = true ]] && exit 0 || exit 1 fi -if [[ "$1" =~ "secrets." ]]; then +if [[ "$1" =~ secrets\..+ ]]; then CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" else CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/github.conf" From 4404e6a3c14eae7427ce23da192e52a4849df149 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 11 Jun 2020 13:52:10 +0000 Subject: [PATCH 1072/2421] Use configured helper --- share/github-backup-utils/ghe-restore-es-audit-log | 2 +- share/github-backup-utils/ghe-restore-es-hookshot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 13c98ab94..bc7b8a4ae 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -36,7 +36,7 @@ last_month=$(printf "audit_log(-[0-9]+)?-%4d-%02d(-[0-9]+)?" $last_yr $last_mth) current_month=$(printf "audit_log(-[0-9]+)?-%4d-%02d(-[0-9]+)?" $this_yr $this_mth) tmp_list="$(mktemp -t backup-utils-restore-XXXXXX)" -if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then +if instance_is_configured; then configured=true fi diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index dab42c953..c51b70c09 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -24,7 +24,7 @@ last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hooks indices=$(find $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz -print0 2>/dev/null | xargs -0 -I{} -n1 basename {} .gz) tmp_list="$(mktemp -t backup-utils-restore-XXXXXX)" -if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]"; then +if instance_is_configured; then configured=true fi From 1670e57ed524f46738c0ae3618102415ad8ea8de Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 11 Jun 2020 15:01:20 +0000 Subject: [PATCH 1073/2421] Add test for external db snapshot to external db instance --- test/test-ghe-restore-external-database.sh | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 29d7a45d3..cca8567ed 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -81,3 +81,44 @@ begin_test "ghe-restore prevents restore of non DB snapshot to external DB appli fi ) end_test + + +begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # Enable external database in snapshot + rm -rf "$GHE_DATA_DIR/current/settings.json" + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 bash -x ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test \ No newline at end of file From 821efeeec98c25209b33f3dad42f8528a459bca2 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 12 Jun 2020 11:11:41 +0000 Subject: [PATCH 1074/2421] Add test for non-external -> external with --skip-mysql --- test/bin/parallel | 1 + test/test-ghe-restore-external-database.sh | 54 ++++++++++++++++++++-- test/testlib.sh | 12 +++-- 3 files changed, 59 insertions(+), 8 deletions(-) create mode 120000 test/bin/parallel diff --git a/test/bin/parallel b/test/bin/parallel new file mode 120000 index 000000000..a0412d691 --- /dev/null +++ b/test/bin/parallel @@ -0,0 +1 @@ +/usr/bin/parallel.moreutils \ No newline at end of file diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index cca8567ed..7c34e0a5c 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -10,6 +10,46 @@ setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" +begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # Enable external database in snapshot + rm -rf "$GHE_DATA_DIR/current/settings.json" + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 bash -x ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" ( set -e @@ -46,7 +86,7 @@ begin_test "ghe-restore prevents restore of external DB snapshot to non-external ) end_test -begin_test "ghe-restore prevents restore of non DB snapshot to external DB appliance" +begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -82,8 +122,7 @@ begin_test "ghe-restore prevents restore of non DB snapshot to external DB appli ) end_test - -begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." +begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -98,21 +137,26 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in # Enable external database in snapshot rm -rf "$GHE_DATA_DIR/current/settings.json" - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false # Disable external database on remote host git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" + SKIP_MYSQL=true + export SKIP_MYSQL + # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 bash -x ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 bash -x ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then # for debugging cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully false fi + grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" + # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" diff --git a/test/testlib.sh b/test/testlib.sh index a5933cc9d..1ed9946db 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -300,7 +300,9 @@ setup_test_data () { if [ "$loc" != "$GHE_REMOTE_DATA_USER_DIR" ]; then # create a fake backups for each datastore - echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" + if [ -z "$SKIP_MYSQL" ]; then + echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" + fi echo "fake ghe-export-redis data" > "$loc/redis.rdb" echo "fake ghe-export-authorized-keys data" > "$loc/authorized-keys.json" echo "fake ghe-export-ssh-host-keys data" > "$TRASHDIR/ssh-host-keys" @@ -363,7 +365,9 @@ verify_all_backedup_data() { [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] # check that mysql data was backed up - [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] + if [ -z "$SKIP_MYSQL" ]; then + [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] + fi # check that redis data was backed up [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] @@ -406,7 +410,9 @@ verify_all_restored_data() { set -e # verify all import scripts were run - grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" + if [ -z "$SKIP_MYSQL" ]; then + grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" + fi grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" From 66963d57020542a06581c5965ffe4f93c5783bd7 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 12 Jun 2020 11:17:05 +0000 Subject: [PATCH 1075/2421] Add test for external db snapshot -> non external with --skip-mysql --- test/test-ghe-restore-external-database.sh | 72 +++++++++++++--------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 7c34e0a5c..bf098604c 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -10,9 +10,7 @@ setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" -begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." -( - set -e +function setup(){ rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata @@ -23,8 +21,15 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in GHE_RESTORE_HOST=127.0.0.1 export GHE_RESTORE_HOST - # Enable external database in snapshot + # Remove settings file with invalid data. rm -rf "$GHE_DATA_DIR/current/settings.json" +} + +begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." +( + set -e + setup + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true # Disable external database on remote host @@ -53,18 +58,8 @@ end_test begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" ( set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST + setup - # Enable external database in snapshot - rm -rf "$GHE_DATA_DIR/current/settings.json" git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true # Disable external database on remote host @@ -89,18 +84,8 @@ end_test begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" ( set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST + setup - # Enable external database in snapshot - rm -rf "$GHE_DATA_DIR/current/settings.json" git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false # Disable external database on remote host @@ -122,6 +107,39 @@ begin_test "ghe-restore prevents restore of non external DB snapshot to external ) end_test +begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + SKIP_MYSQL=true + export SKIP_MYSQL + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 bash -x ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" ( set -e @@ -142,8 +160,6 @@ begin_test "ghe-restore allows restore of non external DB snapshot with --skip-m # Disable external database on remote host git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" - SKIP_MYSQL=true export SKIP_MYSQL From b83b00cd30aa410ce0bf2eaf72181b49368fd1f0 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 12 Jun 2020 11:18:04 +0000 Subject: [PATCH 1076/2421] Newline --- share/github-backup-utils/ghe-backup-config | 2 +- test/test-ghe-restore-external-database.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 1981a5b3d..fa23710b2 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -445,4 +445,4 @@ is_external_database_restore(){ # Check if restoring a snapshot with an external database configured, or restoring # to an appliance with an external database configured. is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" || is_service_external 'mysql' -} \ No newline at end of file +} diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index bf098604c..1046bc934 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -181,4 +181,4 @@ begin_test "ghe-restore allows restore of non external DB snapshot with --skip-m verify_all_restored_data ) -end_test \ No newline at end of file +end_test From d6ae1e642800f2aa9a00552f2287accf79d22a62 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 12 Jun 2020 11:32:06 +0000 Subject: [PATCH 1077/2421] Rename to be more consistent with other checks --- share/github-backup-utils/ghe-backup-config | 4 ++-- share/github-backup-utils/ghe-restore-es-audit-log | 2 +- share/github-backup-utils/ghe-restore-es-hookshot | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index fa23710b2..489739dee 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -410,13 +410,13 @@ is_service_external(){ esac } -instance_is_configured(){ +is_instance_configured(){ ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]" } check_external_database_snapshot_compatibility(){ # always restore to an unconfigured instance. - if ! instance_is_configured; then + if ! is_instance_configured; then return 1 fi diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index bc7b8a4ae..750950425 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -36,7 +36,7 @@ last_month=$(printf "audit_log(-[0-9]+)?-%4d-%02d(-[0-9]+)?" $last_yr $last_mth) current_month=$(printf "audit_log(-[0-9]+)?-%4d-%02d(-[0-9]+)?" $this_yr $this_mth) tmp_list="$(mktemp -t backup-utils-restore-XXXXXX)" -if instance_is_configured; then +if is_instance_configured; then configured=true fi diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot index c51b70c09..0faeb52b9 100755 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ b/share/github-backup-utils/ghe-restore-es-hookshot @@ -24,7 +24,7 @@ last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hooks indices=$(find $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz -print0 2>/dev/null | xargs -0 -I{} -n1 basename {} .gz) tmp_list="$(mktemp -t backup-utils-restore-XXXXXX)" -if instance_is_configured; then +if is_instance_configured; then configured=true fi From 9361e9eb1ae7a5170bf5f3739452689a8d3c6c06 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 12 Jun 2020 12:08:32 +0000 Subject: [PATCH 1078/2421] Remove bash -x, add tests when restoring settings --- test/test-ghe-restore-external-database.sh | 81 ++++++++++++++++++---- 1 file changed, 68 insertions(+), 13 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 1046bc934..cfc26ef76 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -38,7 +38,7 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 bash -x ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then # for debugging cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully @@ -92,7 +92,7 @@ begin_test "ghe-restore prevents restore of non external DB snapshot to external git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 bash -x ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then # Verify that the restore failed due to snapshot compatability. grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored to an appliance with an external database configured." "$TRASHDIR/restore-out" @@ -121,7 +121,7 @@ begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql export SKIP_MYSQL # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 bash -x ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then # for debugging cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully @@ -143,18 +143,10 @@ end_test begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" ( set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST + setup - # Enable external database in snapshot - rm -rf "$GHE_DATA_DIR/current/settings.json" git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false # Disable external database on remote host @@ -164,7 +156,7 @@ begin_test "ghe-restore allows restore of non external DB snapshot with --skip-m export SKIP_MYSQL # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 bash -x ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then # for debugging cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully @@ -182,3 +174,66 @@ begin_test "ghe-restore allows restore of non external DB snapshot with --skip-m verify_all_restored_data ) end_test + +begin_test "ghe-restore allows restore of non external DB snapshot with -c" +( + set -e + + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore allows restore of external DB snapshot with -c" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test \ No newline at end of file From 9999ed9ad5c84a2a18b210d8e9ca5c5b69a3eef9 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 12 Jun 2020 14:02:04 +0000 Subject: [PATCH 1079/2421] Add test for RESTORE_SETTINGS to the external restore check --- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-backup-config | 11 ++++++++--- test/test-ghe-restore-external-database.sh | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 21e71de70..48db01c8f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -128,7 +128,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Figure out if this instance has been configured or is entirely new. instance_configured=false -if instance_is_configured; then +if is_instance_configured; then instance_configured=true else RESTORE_SETTINGS=true diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 489739dee..cb5ebbcac 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -442,7 +442,12 @@ internal_database_snapshow_to_external_database(){ } is_external_database_restore(){ - # Check if restoring a snapshot with an external database configured, or restoring - # to an appliance with an external database configured. - is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" || is_service_external 'mysql' + # If restoring settings, only check the snapshot. + if $RESTORE_SETTINGS; then + is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" + else + # Check if restoring a snapshot with an external database configured, or restoring + # to an appliance with an external database configured. + is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" || is_service_external 'mysql' + fi } diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index cfc26ef76..b467c694f 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -156,7 +156,7 @@ begin_test "ghe-restore allows restore of non external DB snapshot with --skip-m export SKIP_MYSQL # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then # for debugging cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully From 2665f6e7b96f197748788ccea1160e3637851ed1 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 12 Jun 2020 14:15:33 +0000 Subject: [PATCH 1080/2421] Committed unintentionally --- test/bin/parallel | 1 - 1 file changed, 1 deletion(-) delete mode 120000 test/bin/parallel diff --git a/test/bin/parallel b/test/bin/parallel deleted file mode 120000 index a0412d691..000000000 --- a/test/bin/parallel +++ /dev/null @@ -1 +0,0 @@ -/usr/bin/parallel.moreutils \ No newline at end of file From 0f6deed0d2c40eeb75c827f1949a2ef15312618b Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 15 Jun 2020 00:25:36 -0700 Subject: [PATCH 1081/2421] add gh action for CI --- .github/workflow/main.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflow/main.yml diff --git a/.github/workflow/main.yml b/.github/workflow/main.yml new file mode 100644 index 000000000..32b4d8a97 --- /dev/null +++ b/.github/workflow/main.yml @@ -0,0 +1,37 @@ +name: Test and build + +on: [push] + +jobs: + build: + strategy: + matrix: + os: ['ubuntu-latest', 'macos-latest'] + runs-on: ${{ matrix.os }} + + steps: + - name: Install Dependencies (Linux) + run: | + sudo apt-get update -y + sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz + wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" + tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" + sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck + if: matrix.os == 'ubuntu-latest' + - name: Install Dependencies (macOS) + run: | + brew install gnu-tar shellcheck jq pigz coreutils + brew unlink parallel + brew install moreutils gawk + if: matrix.os == 'macos-latest' + - name: Get Sources + uses: actions/checkout@v2 + - name: Test + run: | + export PATH="$PATH:/snap/bin" + make test + shell: bash + - name: Build + run: debuild -uc -us + if: matrix.os == 'ubuntu-latest' + From 1276d74968ff4920ca380ee5ef32e1dcd1ba6e0d Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 15 Jun 2020 00:33:27 -0700 Subject: [PATCH 1082/2421] skip test during build step --- .github/workflow/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflow/main.yml b/.github/workflow/main.yml index 32b4d8a97..e1f43f55d 100644 --- a/.github/workflow/main.yml +++ b/.github/workflow/main.yml @@ -32,6 +32,6 @@ jobs: make test shell: bash - name: Build - run: debuild -uc -us - if: matrix.os == 'ubuntu-latest' + run: DEB_BUILD_OPTIONS=nocheck debuild -uc -us + if: matrix.os != 'macos-latest' From 570226459a8876e25d2271bf9ff92f143059c7fe Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 15 Jun 2020 00:34:14 -0700 Subject: [PATCH 1083/2421] fix typo in folder name --- .github/{workflow => workflows}/main.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{workflow => workflows}/main.yml (100%) diff --git a/.github/workflow/main.yml b/.github/workflows/main.yml similarity index 100% rename from .github/workflow/main.yml rename to .github/workflows/main.yml From e3685207a702bed5f36a0e073a6bd487554889bb Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 15 Jun 2020 12:43:25 -0700 Subject: [PATCH 1084/2421] remove travis config --- .travis.yml | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9a5a2fc14..000000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -language: minimal -matrix: - include: - - os: osx - before_install: - - brew update - - brew install gawk - - brew install gnu-tar - - brew install moreutils - - brew install shellcheck - - brew install jq - - brew install pigz - script: make test - - os: linux - dist: trusty - sudo: required - install: - - wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.4.7.linux.x86_64.tar.xz" - - tar --xz -xvf "shellcheck-v0.4.7.linux.x86_64.tar.xz" - addons: - apt: - packages: - - devscripts - - debhelper - - moreutils - - fakeroot - - jq - - coreutils - - pigz - script: debuild -uc -us From 4d3ce295b0cc69a29cfde133fe7cccadfade8d00 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 15 Jun 2020 12:43:53 -0700 Subject: [PATCH 1085/2421] test several ubuntu versions --- .github/workflows/main.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e1f43f55d..c28880075 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,9 +6,10 @@ jobs: build: strategy: matrix: - os: ['ubuntu-latest', 'macos-latest'] + os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest'] + fail-fast: false runs-on: ${{ matrix.os }} - + steps: - name: Install Dependencies (Linux) run: | @@ -17,10 +18,10 @@ jobs: wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck - if: matrix.os == 'ubuntu-latest' + if: matrix.os != 'macos-latest' - name: Install Dependencies (macOS) run: | - brew install gnu-tar shellcheck jq pigz coreutils + brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt brew unlink parallel brew install moreutils gawk if: matrix.os == 'macos-latest' @@ -31,7 +32,7 @@ jobs: export PATH="$PATH:/snap/bin" make test shell: bash - - name: Build - run: DEB_BUILD_OPTIONS=nocheck debuild -uc -us + - name: Build (Linux) + run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc if: matrix.os != 'macos-latest' - + \ No newline at end of file From fbd506c57374e1d9e284be7937e0108bef6c08c2 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 17 Jun 2020 15:36:07 -0700 Subject: [PATCH 1086/2421] Remove extra loop --- script/cibuild | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/script/cibuild b/script/cibuild index f052a17d8..6128ce684 100755 --- a/script/cibuild +++ b/script/cibuild @@ -2,28 +2,19 @@ # Usage: script/cibuild [--no-package] set -e -# GHE appliance versions to run tests against. Remote metadata files are put in -# place with this version at the beginning of each test and many commands have -# conditional logic based on the remote version. Running the suite against -# different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.19.0 2.20.0 2.21.0" - # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true -# Run over all remote versions and run entire test suite against each res=true -for version in $REMOTE_VERSIONS -do - echo "==> Running testsuite with GHE_TEST_REMOTE_VERSION=$version" - export GHE_TEST_REMOTE_VERSION="$version" - if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then - res=false - fi - echo -done +version=2.21.0 +echo "==> Running testsuite with GHE_TEST_REMOTE_VERSION=$version" +export GHE_TEST_REMOTE_VERSION="$version" +if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then + res=false +fi +echo -# If any of the version tests failed, exit non-zero +# If any of the tests above failed, exit non-zero $res # Bail out when --no-package given From d84118a652c5be4cf6fcbfa9f78dcf3ef2b0ca41 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 19 Jun 2020 09:32:48 +0000 Subject: [PATCH 1087/2421] Extract external DB checks to seperate script. --- bin/ghe-restore | 28 ++++--------------- share/github-backup-utils/ghe-backup-config | 28 +++++++++++++++++-- .../ghe-restore-external-database-check | 25 +++++++++++++++++ share/github-backup-utils/ghe-restore-mysql | 2 +- test/test-ghe-restore-external-database.sh | 4 +-- 5 files changed, 60 insertions(+), 27 deletions(-) create mode 100755 share/github-backup-utils/ghe-restore-external-database-check diff --git a/bin/ghe-restore b/bin/ghe-restore index 48db01c8f..9313ed332 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -134,26 +134,6 @@ else RESTORE_SETTINGS=true fi -# Check backup is compatible with running appliance. -if check_external_database_snapshot_compatibility; then - # External DB backup with non external DB appliance - if external_database_snapshot_to_internal_database; then - echo "Error: Snapshot from GitHub Enterprise with a External Database configured" \ - "cannot be restored to an appliance without external database configured. Aborting." \ - "To restore this snapshot, you must restore the appliance configuration (-c)" \ - "or skip the MySQL restore steps (--skip-mysql) after restoring manually." >&2 - exit 1 - fi - - if internal_database_snapshow_to_external_database; then - echo "Error: Snapshot from GitHub Enterprise with internal database" \ - "cannot be restored to an appliance with an external database configured. Aborting." \ - "To restore this snapshot, you must restore the appliance configuration (-c)" \ - "or skip the MySQL restore steps (--skip-mysql) after restoring manually." >&2 - exit 1 - fi -fi - # Figure out if we're restoring into cluster CLUSTER=false if ghe-ssh "$GHE_HOSTNAME" -- \ @@ -169,6 +149,10 @@ if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then exit 1 fi +if ! ghe-restore-external-database-check; then + exit 1 +fi + # Figure out if this appliance is in a replication pair if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then @@ -287,7 +271,7 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" fi -if is_external_database_restore; then +if is_external_database_target_or_snapshot; then appliance_strategy="external" backup_snapshot_strategy="external" else @@ -304,7 +288,7 @@ else fi fi -if is_external_database_restore && $SKIP_MYSQL; then +if is_external_database_target_or_snapshot && $SKIP_MYSQL; then echo "Skipping MySQL restore." else echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index cb5ebbcac..1b26c9250 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -437,11 +437,11 @@ external_database_snapshot_to_internal_database(){ ! is_service_external "mysql" && is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } -internal_database_snapshow_to_external_database(){ +internal_database_snapshot_to_external_database(){ is_service_external "mysql" && ! is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } -is_external_database_restore(){ +is_external_database_target_or_snapshot(){ # If restoring settings, only check the snapshot. if $RESTORE_SETTINGS; then is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" @@ -451,3 +451,27 @@ is_external_database_restore(){ is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" || is_service_external 'mysql' fi } + +check_external_db_compatibility() { + # Check backup is compatible with running appliance. +if check_external_database_snapshot_compatibility; then + # External DB backup with non external DB appliance + if external_database_snapshot_to_internal_database; then + echo "Error: Snapshot from GitHub Enterprise with an External Database configured" \ + "cannot be restored to an appliance without external database configured. Aborting." \ + "To restore this snapshot, you must restore the appliance configuration (-c)" \ + "or skip the MySQL restore steps (--skip-mysql) after restoring manually." >&2 + return 1 + fi + + if internal_database_snapshot_to_external_database; then + echo "Error: Snapshot from GitHub Enterprise with internal database" \ + "cannot be restored to an appliance with an external database configured. Aborting." \ + "To restore this snapshot, you must restore the appliance configuration (-c)" \ + "or skip the MySQL restore steps (--skip-mysql) after restoring manually." >&2 + return 1 + fi + + return 0 +fi +} \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check new file mode 100755 index 000000000..91c1f5578 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +# Usage: ghe-restore-external-database-check +# GitHub Enterprise checks for external-database related restores. + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Check if there are MySQL nodes in the target environment +if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then + if ghe-ssh "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then + mysql_nodes=$(ghe-ssh "ghe-cluster-each -p -r mysql") + + if [ -z "$mysql_nodes" ]; then + # Restoring a non external DB snapshot to a internal snapshot + # requires that the target environment has a mysql-server + # configured. + echo "Error: Target environment does not have a node with mysql-server node. Aborting restore." + fi + fi +fi + +if ! check_external_db_compatibility; then + exit 1 +fi \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index dd7fd00a8..04469e8cd 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -29,7 +29,7 @@ export GHE_RESTORE_SNAPSHOT # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -if is_external_database_restore; then +if is_external_database_target_or_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT else diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index b467c694f..bfba0e52d 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -32,7 +32,7 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - # Disable external database on remote host + # Enable external database on remote host git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" @@ -68,7 +68,7 @@ begin_test "ghe-restore prevents restore of external DB snapshot to non-external # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then # Verify that the restore failed due to snapshot compatability. - grep -q "Snapshot from GitHub Enterprise with a External Database configured cannot be restored + grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored to an appliance without external database configured." "$TRASHDIR/restore-out" exit 0 From 09379360fe991465554c257f6ff29ab67cbf1ae9 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 19 Jun 2020 14:02:40 +0000 Subject: [PATCH 1088/2421] Add checks for mysql nodes when restoring settings. --- .../ghe-restore-external-database-check | 6 +- test/bin/ghe-cluster-nodes | 31 ++ test/test-ghe-restore-external-database.sh | 414 ++++++++++-------- 3 files changed, 257 insertions(+), 194 deletions(-) create mode 100755 test/bin/ghe-cluster-nodes diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 91c1f5578..4daee5130 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -9,13 +9,15 @@ # Check if there are MySQL nodes in the target environment if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then if ghe-ssh "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then - mysql_nodes=$(ghe-ssh "ghe-cluster-each -p -r mysql") + mysql_nodes=$(ghe-ssh "ghe-cluster-nodes -r mysql") + echo $mysql_nodes if [ -z "$mysql_nodes" ]; then # Restoring a non external DB snapshot to a internal snapshot # requires that the target environment has a mysql-server # configured. - echo "Error: Target environment does not have a node with mysql-server node. Aborting restore." + echo "Error: Target environment does not have a node with mysql-server role. Aborting restore." + exit 1 fi fi fi diff --git a/test/bin/ghe-cluster-nodes b/test/bin/ghe-cluster-nodes new file mode 100755 index 000000000..1684edb86 --- /dev/null +++ b/test/bin/ghe-cluster-nodes @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# Usage: ghe-cluster-nodes +# Emulates the remote GitHub ghe-config command. Tests use this +# to assert that the command was executed. +set -e + +case "$1" in + -r|--role) + # fake change last save timestamp every 1s + ROLE=$2 + shift + shift + ;; +esac + +CONFIG="$GHE_REMOTE_CLUSTER_CONF_FILE" + +hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) + +if [ $? -ne 0 ]; then + hosts="fake-uuid +fake-uuid1 +fake-uuid2" +fi + +echo $hosts + +for hostname in $hosts; do + [ -n "$ROLE" ] && [ "$(git config $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue + echo $hostname +done \ No newline at end of file diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index bfba0e52d..921fa4467 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -25,63 +25,220 @@ function setup(){ rm -rf "$GHE_DATA_DIR/current/settings.json" } -begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Enable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - # Verify that the restore failed due to snapshot compatability. - grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored - to an appliance without external database configured." "$TRASHDIR/restore-out" - - exit 0 - else - # for debugging - cat "$TRASHDIR/restore-out" - - exit 1 - fi -) -end_test - -begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" +#begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true +# +# # Enable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test +# +#begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# # Verify that the restore failed due to snapshot compatability. +# grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored +# to an appliance without external database configured." "$TRASHDIR/restore-out" +# +# exit 0 +# else +# # for debugging +# cat "$TRASHDIR/restore-out" +# +# exit 1 +# fi +#) +#end_test +# +#begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# # Verify that the restore failed due to snapshot compatability. +# grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored +# to an appliance with an external database configured." "$TRASHDIR/restore-out" +# +# exit 0 +# else +# # for debugging +# cat "$TRASHDIR/restore-out" +# +# exit 1 +# fi +#) +#end_test +# +#begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false +# +# SKIP_MYSQL=true +# export SKIP_MYSQL +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test +# +#begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" +#( +# set -e +# +# +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# SKIP_MYSQL=true +# export SKIP_MYSQL +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test +# +#begin_test "ghe-restore allows restore of non external DB snapshot with -c" +#( +# set -e +# +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test +# +#begin_test "ghe-restore allows restore of external DB snapshot with -c" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false +# +# export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test + +begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-server role" ( set -e setup @@ -91,149 +248,22 @@ begin_test "ghe-restore prevents restore of non external DB snapshot to external # Disable external database on remote host git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + echo "[cluster \"fake-uuid\"] + hostname = fake-uuid + git-server = true + web-server = true + " > $GHE_REMOTE_CLUSTER_CONF_FILE + # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - # Verify that the restore failed due to snapshot compatability. - grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored - to an appliance with an external database configured." "$TRASHDIR/restore-out" + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + grep -q "Error: Target environment does not have a node with mysql-server role." "$TRASHDIR/restore-out" exit 0 else # for debugging cat "$TRASHDIR/restore-out" - - exit 1 - fi -) -end_test - -begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - - SKIP_MYSQL=true - export SKIP_MYSQL - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" -( - set -e - - - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - SKIP_MYSQL=true - export SKIP_MYSQL - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully false fi - - grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore allows restore of non external DB snapshot with -c" -( - set -e - - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore allows restore of external DB snapshot with -c" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - - export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data ) end_test \ No newline at end of file From 49e5528a108e712d908207a2fac42806d0b0d832 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Fri, 19 Jun 2020 14:43:09 +0000 Subject: [PATCH 1089/2421] Uncomment the tests that were accidentally commented --- test/bin/ghe-cluster-nodes | 12 +- test/test-ghe-restore-external-database.sh | 424 ++++++++++----------- 2 files changed, 214 insertions(+), 222 deletions(-) diff --git a/test/bin/ghe-cluster-nodes b/test/bin/ghe-cluster-nodes index 1684edb86..15144348b 100755 --- a/test/bin/ghe-cluster-nodes +++ b/test/bin/ghe-cluster-nodes @@ -13,19 +13,11 @@ case "$1" in ;; esac -CONFIG="$GHE_REMOTE_CLUSTER_CONF_FILE" +CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) -if [ $? -ne 0 ]; then - hosts="fake-uuid -fake-uuid1 -fake-uuid2" -fi - -echo $hosts - for hostname in $hosts; do - [ -n "$ROLE" ] && [ "$(git config $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue + [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue echo $hostname done \ No newline at end of file diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 921fa4467..10c246eb1 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -25,218 +25,218 @@ function setup(){ rm -rf "$GHE_DATA_DIR/current/settings.json" } -#begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true -# -# # Enable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test -# -#begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# # Verify that the restore failed due to snapshot compatability. -# grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored -# to an appliance without external database configured." "$TRASHDIR/restore-out" -# -# exit 0 -# else -# # for debugging -# cat "$TRASHDIR/restore-out" -# -# exit 1 -# fi -#) -#end_test -# -#begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# # Verify that the restore failed due to snapshot compatability. -# grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored -# to an appliance with an external database configured." "$TRASHDIR/restore-out" -# -# exit 0 -# else -# # for debugging -# cat "$TRASHDIR/restore-out" -# -# exit 1 -# fi -#) -#end_test -# -#begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false -# -# SKIP_MYSQL=true -# export SKIP_MYSQL -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test -# -#begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" -#( -# set -e -# -# -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# SKIP_MYSQL=true -# export SKIP_MYSQL -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test -# -#begin_test "ghe-restore allows restore of non external DB snapshot with -c" -#( -# set -e -# -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test -# -#begin_test "ghe-restore allows restore of external DB snapshot with -c" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false -# -# export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test +begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Enable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # Verify that the restore failed due to snapshot compatability. + grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored + to an appliance without external database configured." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + + exit 1 + fi +) +end_test + +begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # Verify that the restore failed due to snapshot compatability. + grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored + to an appliance with an external database configured." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + + exit 1 + fi +) +end_test + +begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + SKIP_MYSQL=true + export SKIP_MYSQL + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" +( + set -e + + + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + SKIP_MYSQL=true + export SKIP_MYSQL + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore allows restore of non external DB snapshot with -c" +( + set -e + + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore allows restore of external DB snapshot with -c" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-server role" ( From 0ded0e509a345c84c3c042b5f73908f0d99d2b21 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Sun, 21 Jun 2020 21:03:13 +0000 Subject: [PATCH 1090/2421] setup linter action --- .github/workflows/lint.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..07defc711 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,19 @@ +name: Lint Code Base + +on: + push: + branches-ignore: + - 'master' + +jobs: + build: + name: Lint Code Base + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Lint Code Base + uses: docker://github/super-linter:v2.1.1 + env: + VALIDATE_ALL_CODEBASE: false + VALIDATE_ANSIBLE: false \ No newline at end of file From 0b15894aa77882b2343c88a5d1826402a19401fd Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Sun, 21 Jun 2020 21:22:28 +0000 Subject: [PATCH 1091/2421] try testing only on latest linux --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c28880075..5befe844e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,8 @@ jobs: build: strategy: matrix: - os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest'] + os: ['ubuntu-latest', 'macos-latest'] + # os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest'] fail-fast: false runs-on: ${{ matrix.os }} From 539d80af7b9a268ba3b21114a39a8587b1236d28 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Mon, 22 Jun 2020 10:16:57 +0000 Subject: [PATCH 1092/2421] Add support for role check in ghe-cluster-each. --- .../ghe-restore-external-database-check | 17 ++++++-- test/bin/ghe-cluster-each | 39 ++++++++++++++++--- test/bin/ghe-cluster-nodes | 23 ----------- test/test-ghe-restore-external-database.sh | 35 +++++++++++++++++ 4 files changed, 82 insertions(+), 32 deletions(-) delete mode 100755 test/bin/ghe-cluster-nodes diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 4daee5130..09dda4323 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -8,9 +8,8 @@ # Check if there are MySQL nodes in the target environment if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then - if ghe-ssh "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then - mysql_nodes=$(ghe-ssh "ghe-cluster-nodes -r mysql") - echo $mysql_nodes + if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then + mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") if [ -z "$mysql_nodes" ]; then # Restoring a non external DB snapshot to a internal snapshot @@ -22,6 +21,18 @@ if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then fi fi +# User should remove the `mysql-server` role after the fact. +if $RESTORE_SETTINGS && external_database_snapshot_to_internal_database; then + if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then + mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") + + if [ -z "$mysql_nodes" ]; then + echo "Warning: Target environment has mysql-server role. This should be removed post-restore." + exit 0 + fi + fi +fi + if ! check_external_db_compatibility; then exit 1 fi \ No newline at end of file diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 71ccb7d69..2679a72fc 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -3,10 +3,37 @@ # Emulates the remote GitHub ghe-config command. Tests use this # to assert that the command was executed. set -e -if [[ "$*" =~ "-u" ]]; then - # Mimic `ghe-cluster-each $role -u` - echo "fake-uuid -fake-uuid1 -fake-uuid2 -" + +for arg in "$@"; do + case "$1" in + -u) + SHOW_UUID=true + shift + ;; + -r|--role) + # fake change last save timestamp every 1s + ROLE=$2 + shift + shift + ;; + esac +done + +if $SHOW_UUID; then + CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" + + hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) + + if [ -z "$hosts" ]; then + # Mimic `ghe-cluster-each $role -u` + echo "fake-uuid + fake-uuid1 + fake-uuid2 + " + else + for hostname in $hosts; do + [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue + echo $hostname + done + fi fi diff --git a/test/bin/ghe-cluster-nodes b/test/bin/ghe-cluster-nodes deleted file mode 100755 index 15144348b..000000000 --- a/test/bin/ghe-cluster-nodes +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# Usage: ghe-cluster-nodes -# Emulates the remote GitHub ghe-config command. Tests use this -# to assert that the command was executed. -set -e - -case "$1" in - -r|--role) - # fake change last save timestamp every 1s - ROLE=$2 - shift - shift - ;; -esac - -CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" - -hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) - -for hostname in $hosts; do - [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue - echo $hostname -done \ No newline at end of file diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 10c246eb1..e35082be6 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -266,4 +266,39 @@ begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a clu false fi ) +end_test + +begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluster configured with mysql-server role" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + echo "[cluster \"fake-uuid\"] + hostname = fake-uuid + git-server = true + web-server = true + mysql-server = true + " > $GHE_REMOTE_CLUSTER_CONF_FILE + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 bash -x ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) end_test \ No newline at end of file From 0a1aa671fce5b269d7636cb3f852ea1ae3c0c467 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Mon, 22 Jun 2020 10:24:40 +0000 Subject: [PATCH 1093/2421] Add test asserting warning for left over mysql node. --- .../ghe-restore-external-database-check | 2 +- test/test-ghe-restore-external-database.sh | 527 ++++++++++-------- 2 files changed, 284 insertions(+), 245 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 09dda4323..4c8379727 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -26,7 +26,7 @@ if $RESTORE_SETTINGS && external_database_snapshot_to_internal_database; then if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") - if [ -z "$mysql_nodes" ]; then + if [ -n "$mysql_nodes" ]; then echo "Warning: Target environment has mysql-server role. This should be removed post-restore." exit 0 fi diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index e35082be6..5412f340e 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -25,188 +25,285 @@ function setup(){ rm -rf "$GHE_DATA_DIR/current/settings.json" } -begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Enable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - # Verify that the restore failed due to snapshot compatability. - grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored - to an appliance without external database configured." "$TRASHDIR/restore-out" - - exit 0 - else - # for debugging - cat "$TRASHDIR/restore-out" - - exit 1 - fi -) -end_test - -begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - # Verify that the restore failed due to snapshot compatability. - grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored - to an appliance with an external database configured." "$TRASHDIR/restore-out" - - exit 0 - else - # for debugging - cat "$TRASHDIR/restore-out" - - exit 1 - fi -) -end_test - -begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - - SKIP_MYSQL=true - export SKIP_MYSQL - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" -( - set -e - - - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - SKIP_MYSQL=true - export SKIP_MYSQL - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore allows restore of non external DB snapshot with -c" -( - set -e - - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore allows restore of external DB snapshot with -c" +#begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true +# +# # Enable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test +# +#begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# # Verify that the restore failed due to snapshot compatability. +# grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored +# to an appliance without external database configured." "$TRASHDIR/restore-out" +# +# exit 0 +# else +# # for debugging +# cat "$TRASHDIR/restore-out" +# +# exit 1 +# fi +#) +#end_test +# +#begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# # Verify that the restore failed due to snapshot compatability. +# grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored +# to an appliance with an external database configured." "$TRASHDIR/restore-out" +# +# exit 0 +# else +# # for debugging +# cat "$TRASHDIR/restore-out" +# +# exit 1 +# fi +#) +#end_test +# +#begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false +# +# SKIP_MYSQL=true +# export SKIP_MYSQL +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test +# +#begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" +#( +# set -e +# +# +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# SKIP_MYSQL=true +# export SKIP_MYSQL +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test +# +#begin_test "ghe-restore allows restore of non external DB snapshot with -c" +#( +# set -e +# +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test +# +#begin_test "ghe-restore allows restore of external DB snapshot with -c" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false +# +# export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test +# +#begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-server role" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# echo "[cluster \"fake-uuid\"] +# hostname = fake-uuid +# git-server = true +# web-server = true +# " > $GHE_REMOTE_CLUSTER_CONF_FILE +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then +# grep -q "Error: Target environment does not have a node with mysql-server role." "$TRASHDIR/restore-out" +# +# exit 0 +# else +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +#) +#end_test +# +#begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluster configured with mysql-server role" +#( +# set -e +# setup +# +# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false +# +# # Disable external database on remote host +# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true +# +# echo "[cluster \"fake-uuid\"] +# hostname = fake-uuid +# git-server = true +# web-server = true +# mysql-server = true +# " > $GHE_REMOTE_CLUSTER_CONF_FILE +# +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then +# # for debugging +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi +# +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# +# verify_all_restored_data +#) +#end_test + +begin_test "ghe-restore restore of external DB snapshot with -c to a cluster configured with mysql-server role warns to remove mysql" ( set -e setup @@ -216,68 +313,6 @@ begin_test "ghe-restore allows restore of external DB snapshot with -c" # Disable external database on remote host git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-server role" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - echo "[cluster \"fake-uuid\"] - hostname = fake-uuid - git-server = true - web-server = true - " > $GHE_REMOTE_CLUSTER_CONF_FILE - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - grep -q "Error: Target environment does not have a node with mysql-server role." "$TRASHDIR/restore-out" - - exit 0 - else - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi -) -end_test - -begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluster configured with mysql-server role" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - echo "[cluster \"fake-uuid\"] hostname = fake-uuid git-server = true @@ -285,6 +320,8 @@ begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluste mysql-server = true " > $GHE_REMOTE_CLUSTER_CONF_FILE + export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" + # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 bash -x ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then # for debugging @@ -293,6 +330,8 @@ begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluste false fi + grep -q "Target environment has mysql-server role. This should be removed post-restore." "$TRASHDIR/restore-out" + # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" From 67bab123dd95d133b1b8b2f0138fcccf241a5352 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Mon, 22 Jun 2020 10:57:40 +0000 Subject: [PATCH 1094/2421] Uncomment all tests --- test/test-ghe-restore-external-database.sh | 554 ++++++++++----------- 1 file changed, 277 insertions(+), 277 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 5412f340e..95a1fd5de 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -25,283 +25,283 @@ function setup(){ rm -rf "$GHE_DATA_DIR/current/settings.json" } -#begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true -# -# # Enable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test -# -#begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# # Verify that the restore failed due to snapshot compatability. -# grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored -# to an appliance without external database configured." "$TRASHDIR/restore-out" -# -# exit 0 -# else -# # for debugging -# cat "$TRASHDIR/restore-out" -# -# exit 1 -# fi -#) -#end_test -# -#begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# # Verify that the restore failed due to snapshot compatability. -# grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored -# to an appliance with an external database configured." "$TRASHDIR/restore-out" -# -# exit 0 -# else -# # for debugging -# cat "$TRASHDIR/restore-out" -# -# exit 1 -# fi -#) -#end_test -# -#begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false -# -# SKIP_MYSQL=true -# export SKIP_MYSQL -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test -# -#begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" -#( -# set -e -# -# -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# SKIP_MYSQL=true -# export SKIP_MYSQL -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test -# -#begin_test "ghe-restore allows restore of non external DB snapshot with -c" -#( -# set -e -# -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test -# -#begin_test "ghe-restore allows restore of external DB snapshot with -c" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false -# -# export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test -# -#begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-server role" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# echo "[cluster \"fake-uuid\"] -# hostname = fake-uuid -# git-server = true -# web-server = true -# " > $GHE_REMOTE_CLUSTER_CONF_FILE -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then -# grep -q "Error: Target environment does not have a node with mysql-server role." "$TRASHDIR/restore-out" -# -# exit 0 -# else -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -#) -#end_test -# -#begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluster configured with mysql-server role" -#( -# set -e -# setup -# -# git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false -# -# # Disable external database on remote host -# git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true -# -# echo "[cluster \"fake-uuid\"] -# hostname = fake-uuid -# git-server = true -# web-server = true -# mysql-server = true -# " > $GHE_REMOTE_CLUSTER_CONF_FILE -# -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then -# # for debugging -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi -# -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" -# -# verify_all_restored_data -#) -#end_test +begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Enable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # Verify that the restore failed due to snapshot compatability. + grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored + to an appliance without external database configured." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + + exit 1 + fi +) +end_test + +begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # Verify that the restore failed due to snapshot compatability. + grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored + to an appliance with an external database configured." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + + exit 1 + fi +) +end_test + +begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + SKIP_MYSQL=true + export SKIP_MYSQL + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" +( + set -e + + + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + SKIP_MYSQL=true + export SKIP_MYSQL + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore allows restore of non external DB snapshot with -c" +( + set -e + + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore allows restore of external DB snapshot with -c" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test + +begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-server role" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + echo "[cluster \"fake-uuid\"] + hostname = fake-uuid + git-server = true + web-server = true + " > $GHE_REMOTE_CLUSTER_CONF_FILE + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + grep -q "Error: Target environment does not have a node with mysql-server role." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi +) +end_test + +begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluster configured with mysql-server role" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + echo "[cluster \"fake-uuid\"] + hostname = fake-uuid + git-server = true + web-server = true + mysql-server = true + " > $GHE_REMOTE_CLUSTER_CONF_FILE + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + verify_all_restored_data +) +end_test begin_test "ghe-restore restore of external DB snapshot with -c to a cluster configured with mysql-server role warns to remove mysql" ( From ea5fad44a58dac80508dc9269b02b6471eec50f0 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Mon, 22 Jun 2020 11:01:31 +0000 Subject: [PATCH 1095/2421] set -e --- share/github-backup-utils/ghe-restore-external-database-check | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 4c8379727..9289e0e92 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -6,6 +6,8 @@ # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +set -e + # Check if there are MySQL nodes in the target environment if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then From 23f6260a20656e971069bfc1d19b8e41969e0f2e Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 22 Jun 2020 11:28:59 -0700 Subject: [PATCH 1096/2421] add missing line --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 07defc711..f30c6ab0c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,4 +16,4 @@ jobs: uses: docker://github/super-linter:v2.1.1 env: VALIDATE_ALL_CODEBASE: false - VALIDATE_ANSIBLE: false \ No newline at end of file + VALIDATE_ANSIBLE: false From bee3b8e2c67dd7785df49d8c2e29cd95f0d6736a Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 22 Jun 2020 11:31:25 -0700 Subject: [PATCH 1097/2421] use consistent check --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5befe844e..fa0475149 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck - if: matrix.os != 'macos-latest' + if: matrix.os == 'ubuntu-latest' - name: Install Dependencies (macOS) run: | brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt @@ -35,5 +35,4 @@ jobs: shell: bash - name: Build (Linux) run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc - if: matrix.os != 'macos-latest' - \ No newline at end of file + if: matrix.os == 'ubuntu-latest' From 3d1a6856297cad0bc2ccc671ec765d82baec3256 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 11:32:38 -0700 Subject: [PATCH 1098/2421] Update script/cibuild Co-authored-by: Yunlei Liu --- script/cibuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 6128ce684..88489f958 100755 --- a/script/cibuild +++ b/script/cibuild @@ -7,7 +7,7 @@ export GHE_VERBOSE_SSH=true res=true version=2.21.0 -echo "==> Running testsuite with GHE_TEST_REMOTE_VERSION=$version" +echo "==> Running test suite with GHE_TEST_REMOTE_VERSION=$version" export GHE_TEST_REMOTE_VERSION="$version" if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then res=false From 77107a97ca18e186d52d73975356ece038aa9d6c Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 22 Jun 2020 11:32:42 -0700 Subject: [PATCH 1099/2421] test - try linting whole codebase --- .github/workflows/lint.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f30c6ab0c..77b4abe16 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,5 +15,4 @@ jobs: - name: Lint Code Base uses: docker://github/super-linter:v2.1.1 env: - VALIDATE_ALL_CODEBASE: false - VALIDATE_ANSIBLE: false + VALIDATE_ALL_CODEBASE: true From 1cb20cf8c20c8985876974b39d14540daf4a7ac5 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 11:42:58 -0700 Subject: [PATCH 1100/2421] Update README with note about --skip-mysql flag in ghe-restore --- docs/usage.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index 62c135381..36b3e2a68 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -16,6 +16,8 @@ You can supply your own configuration file or use the example configuration file An example configuration file with documentation on possible settings can found in [backup.config-example](../backup.config-example). +There are a number of command line options that can also be passed to the `ghe-restore` command. Of particular note, if you use an external MySQL service but are restoring from a snapshot prior to enabling this, you must pass `--skip-mysql` to `ghe-restore`. + ## Example backup and restore usage The following assumes that `GHE_HOSTNAME` is set to "github.example.com" in From 252f30ee635938492a57c756af18211bfddb30dd Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 11:49:18 -0700 Subject: [PATCH 1101/2421] Add comments to is_service_external --- share/github-backup-utils/ghe-backup-config | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 1b26c9250..a9c37db6d 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -392,6 +392,8 @@ is_binary_backup(){ test -f "$1/mysql-binary-backup-sentinel" } +# Check if a given service is managed externally +# Usage: is_service_external $service [$config_file] is_service_external(){ service=$1 config_file=$2 @@ -419,7 +421,7 @@ check_external_database_snapshot_compatibility(){ if ! is_instance_configured; then return 1 fi - + # If restoring settings, the target appliance will be converted. if $RESTORE_SETTINGS; then return 1 From 1d12ec3bfceab2093a7803926f40d8eda0bb6fd7 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 11:53:33 -0700 Subject: [PATCH 1102/2421] Add comment to check_external_database_snapshot_compatibility --- share/github-backup-utils/ghe-backup-config | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index a9c37db6d..e0a114243 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -416,6 +416,7 @@ is_instance_configured(){ ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]" } +# Helper method to validate whether we can restore the snapshot to the target appliance check_external_database_snapshot_compatibility(){ # always restore to an unconfigured instance. if ! is_instance_configured; then From 23394289b914212f6b7053f07def29d355c860e2 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 11:55:04 -0700 Subject: [PATCH 1103/2421] indent check_external_db_compatibility --- share/github-backup-utils/ghe-backup-config | 37 +++++++++++---------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index e0a114243..39c57d725 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -457,24 +457,25 @@ is_external_database_target_or_snapshot(){ check_external_db_compatibility() { # Check backup is compatible with running appliance. -if check_external_database_snapshot_compatibility; then - # External DB backup with non external DB appliance - if external_database_snapshot_to_internal_database; then - echo "Error: Snapshot from GitHub Enterprise with an External Database configured" \ - "cannot be restored to an appliance without external database configured. Aborting." \ - "To restore this snapshot, you must restore the appliance configuration (-c)" \ - "or skip the MySQL restore steps (--skip-mysql) after restoring manually." >&2 - return 1 - fi + if check_external_database_snapshot_compatibility; then + + # External DB backup with non external DB appliance + if external_database_snapshot_to_internal_database; then + echo "Error: Snapshot from GitHub Enterprise with an External Database configured" \ + "cannot be restored to an appliance without external database configured. Aborting." \ + "To restore this snapshot, you must restore the appliance configuration (-c)" \ + "or skip the MySQL restore steps (--skip-mysql) after restoring MySQL data manually." >&2 + return 1 + fi - if internal_database_snapshot_to_external_database; then - echo "Error: Snapshot from GitHub Enterprise with internal database" \ - "cannot be restored to an appliance with an external database configured. Aborting." \ - "To restore this snapshot, you must restore the appliance configuration (-c)" \ - "or skip the MySQL restore steps (--skip-mysql) after restoring manually." >&2 - return 1 - fi + if internal_database_snapshot_to_external_database; then + echo "Error: Snapshot from GitHub Enterprise with internal database" \ + "cannot be restored to an appliance with an external database configured. Aborting." \ + "To restore this snapshot, you must restore the appliance configuration (-c)" \ + "or skip the MySQL restore steps (--skip-mysql) after restoring MySQL data manually." >&2 + return 1 + fi - return 0 -fi + return 0 + fi } \ No newline at end of file From 6debbfe2e6d407602f555dfa9aabcf818f82db05 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 11:57:50 -0700 Subject: [PATCH 1104/2421] Update comments in check_external_db_compatibility --- share/github-backup-utils/ghe-backup-config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 39c57d725..8e2f6ade1 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -456,18 +456,19 @@ is_external_database_target_or_snapshot(){ } check_external_db_compatibility() { - # Check backup is compatible with running appliance. + # Check that the backup snapshot is compatible with the running appliance. if check_external_database_snapshot_compatibility; then - # External DB backup with non external DB appliance + # Attempting to restore external DB backup snapshot to internal DB appliance if external_database_snapshot_to_internal_database; then - echo "Error: Snapshot from GitHub Enterprise with an External Database configured" \ + echo "Error: Snapshot from GitHub Enterprise with an external database configured" \ "cannot be restored to an appliance without external database configured. Aborting." \ "To restore this snapshot, you must restore the appliance configuration (-c)" \ "or skip the MySQL restore steps (--skip-mysql) after restoring MySQL data manually." >&2 return 1 fi + # Attempting to restore internal DB backup snapshot to external DB appliance if internal_database_snapshot_to_external_database; then echo "Error: Snapshot from GitHub Enterprise with internal database" \ "cannot be restored to an appliance with an external database configured. Aborting." \ From 110378f25c4c74629da412834ef3538919842c73 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Mon, 22 Jun 2020 11:59:11 -0700 Subject: [PATCH 1105/2421] disable linting whole codebase --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 77b4abe16..f7f72df90 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,4 +15,4 @@ jobs: - name: Lint Code Base uses: docker://github/super-linter:v2.1.1 env: - VALIDATE_ALL_CODEBASE: true + VALIDATE_ALL_CODEBASE: false From d1b66c7e99e0b41f844d4252c09f33da2375a825 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 12:09:53 -0700 Subject: [PATCH 1106/2421] Reduce 3 line comment to 2 lines --- share/github-backup-utils/ghe-restore-external-database-check | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 9289e0e92..395d6f775 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -15,8 +15,7 @@ if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then if [ -z "$mysql_nodes" ]; then # Restoring a non external DB snapshot to a internal snapshot - # requires that the target environment has a mysql-server - # configured. + # requires that the target environment has a mysql-server configured. echo "Error: Target environment does not have a node with mysql-server role. Aborting restore." exit 1 fi From 23b9e29fe3511e074f641cf7bf06077ba443e846 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 12:19:32 -0700 Subject: [PATCH 1107/2421] Add some function level comments for verbosity --- share/github-backup-utils/ghe-backup-config | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 8e2f6ade1..173b2886d 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -436,10 +436,16 @@ check_external_database_snapshot_compatibility(){ return 0 } +# Helper method that returns true if: +# - the target appliance uses the internal MySQL database (aka NOT BYODB), and +# - the snapshot being restored is from an appliance using an external MySQL database (BYODB) external_database_snapshot_to_internal_database(){ ! is_service_external "mysql" && is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } +# Helper method that returns true if: +# - the target appliance uses an external MySQL database (BYODB), and +# - the snapshot being restored is from an appliance using an internal MySQL database (aka NOT BYODB) internal_database_snapshot_to_external_database(){ is_service_external "mysql" && ! is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } From e5351af5ed28ace0c9d9487fceb0d016ca4754c5 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 12:24:50 -0700 Subject: [PATCH 1108/2421] Change text from 'post-restore' to 'after the restore has completed' --- share/github-backup-utils/ghe-restore-external-database-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 395d6f775..c46551bf4 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -28,7 +28,7 @@ if $RESTORE_SETTINGS && external_database_snapshot_to_internal_database; then mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") if [ -n "$mysql_nodes" ]; then - echo "Warning: Target environment has mysql-server role. This should be removed post-restore." + echo "Warning: Target environment has mysql-server role. This should be removed after the restore has completed." exit 0 fi fi From 5ee46e422ba96b0c94438979299f63c5fe0f6af3 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 14:49:42 -0700 Subject: [PATCH 1109/2421] Add comment to ghe-restore-external-database-check --- bin/ghe-restore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 9313ed332..323d0e8b9 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -149,6 +149,8 @@ if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then exit 1 fi +# Ensure target appliance and restore snapshot are a compatible combination +# with respect to BYODB if ! ghe-restore-external-database-check; then exit 1 fi @@ -274,7 +276,7 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then if is_external_database_target_or_snapshot; then appliance_strategy="external" backup_snapshot_strategy="external" -else +else if is_binary_backup_feature_on; then appliance_strategy="binary" else From 1147a41cc931bba5b629644902d1758603e8e100 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 15:11:01 -0700 Subject: [PATCH 1110/2421] Update comment about is_external_database_target_or_snapshot --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 173b2886d..7c2212cdb 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -451,7 +451,7 @@ internal_database_snapshot_to_external_database(){ } is_external_database_target_or_snapshot(){ - # If restoring settings, only check the snapshot. + # If restoring settings, only check if the snapshot being restored was from an appliance with external DB configured. if $RESTORE_SETTINGS; then is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" else From 11b99b541c4f2629828c5946ec41507d483bae20 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 22 Jun 2020 15:11:19 -0700 Subject: [PATCH 1111/2421] Add newline to end of ghe-backup-config file --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 7c2212cdb..8e77c46ad 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -485,4 +485,4 @@ check_external_db_compatibility() { return 0 fi -} \ No newline at end of file +} From d25038cc0f67673cc29dfa1281c4b71ac7700d25 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Tue, 23 Jun 2020 09:27:20 +0200 Subject: [PATCH 1112/2421] Update share/github-backup-utils/ghe-restore-external-database-check Fix comment Co-authored-by: Caine Jette --- share/github-backup-utils/ghe-restore-external-database-check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index c46551bf4..cab0fd8e0 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -14,7 +14,7 @@ if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") if [ -z "$mysql_nodes" ]; then - # Restoring a non external DB snapshot to a internal snapshot + # Restoring a non external DB snapshot to an internal DB appliance # requires that the target environment has a mysql-server configured. echo "Error: Target environment does not have a node with mysql-server role. Aborting restore." exit 1 @@ -36,4 +36,4 @@ fi if ! check_external_db_compatibility; then exit 1 -fi \ No newline at end of file +fi From 5a42c54d34ff9817287fb3d378662f62085f4bb7 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 23 Jun 2020 12:59:49 -0700 Subject: [PATCH 1113/2421] Remove REMOTE_VERSIONS bump from script/release --- script/release | 4 ---- 1 file changed, 4 deletions(-) diff --git a/script/release b/script/release index bee1bcb85..761d56a67 100755 --- a/script/release +++ b/script/release @@ -210,10 +210,6 @@ def bump_version(new_version, min_version = nil, path = 'share/github-backup-uti content = File.read('test/testlib.sh') new_content = content.gsub(/GHE_TEST_REMOTE_VERSION:=[0-9]\.[0-9]+\.0/,"GHE_TEST_REMOTE_VERSION:=#{new_version}") File.open('test/testlib.sh', 'w') {|file| file.puts new_content } - - content = File.read('script/cibuild') - new_content = content.gsub(/^REMOTE_VERSIONS=.*$/, "REMOTE_VERSIONS=\"#{min_version} #{new_version}\"") - File.open('script/cibuild', 'w') {|file| file.puts new_content } end end From 90477b5e5f3624ccc3af1c89325de1c31cea3d30 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 23 Jun 2020 13:03:07 -0700 Subject: [PATCH 1114/2421] Remove testing from script/cibuild Co-authored-by: Colin Seymour --- script/cibuild | 7 ------- 1 file changed, 7 deletions(-) diff --git a/script/cibuild b/script/cibuild index 88489f958..048717ab8 100755 --- a/script/cibuild +++ b/script/cibuild @@ -6,13 +6,6 @@ set -e export GHE_VERBOSE_SSH=true res=true -version=2.21.0 -echo "==> Running test suite with GHE_TEST_REMOTE_VERSION=$version" -export GHE_TEST_REMOTE_VERSION="$version" -if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then - res=false -fi -echo # If any of the tests above failed, exit non-zero $res From 4c8e4cfcb21b8be3ec2b9d2efb71a1e59013fac3 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 23 Jun 2020 13:15:07 -0700 Subject: [PATCH 1115/2421] Remove left over variable --- script/cibuild | 5 ----- 1 file changed, 5 deletions(-) diff --git a/script/cibuild b/script/cibuild index 048717ab8..65c9a110f 100755 --- a/script/cibuild +++ b/script/cibuild @@ -5,11 +5,6 @@ set -e # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true -res=true - -# If any of the tests above failed, exit non-zero -$res - # Bail out when --no-package given [ "$1" = "--no-package" ] && exit 0 From 70127259f3274706d676c58b1c02eb00d955aad5 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 23 Jun 2020 13:51:22 -0700 Subject: [PATCH 1116/2421] Revert "Remove testing from script/cibuild" This reverts commit 90477b5e5f3624ccc3af1c89325de1c31cea3d30. --- script/cibuild | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/script/cibuild b/script/cibuild index 65c9a110f..88489f958 100755 --- a/script/cibuild +++ b/script/cibuild @@ -5,6 +5,18 @@ set -e # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true +res=true +version=2.21.0 +echo "==> Running test suite with GHE_TEST_REMOTE_VERSION=$version" +export GHE_TEST_REMOTE_VERSION="$version" +if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then + res=false +fi +echo + +# If any of the tests above failed, exit non-zero +$res + # Bail out when --no-package given [ "$1" = "--no-package" ] && exit 0 From a0a7b5296976e24655ef53a0ef377b5e4d9d29e6 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 23 Jun 2020 13:55:47 -0700 Subject: [PATCH 1117/2421] Remove res variable and simply exit 1 if tests fail --- script/cibuild | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/script/cibuild b/script/cibuild index 88489f958..7f57f444d 100755 --- a/script/cibuild +++ b/script/cibuild @@ -5,17 +5,9 @@ set -e # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true -res=true -version=2.21.0 -echo "==> Running test suite with GHE_TEST_REMOTE_VERSION=$version" -export GHE_TEST_REMOTE_VERSION="$version" if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then - res=false + exit 1 fi -echo - -# If any of the tests above failed, exit non-zero -$res # Bail out when --no-package given [ "$1" = "--no-package" ] && exit 0 From 9aace6d6542a5b30391e0acb5ed2818882e30f62 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Tue, 23 Jun 2020 15:28:22 -0700 Subject: [PATCH 1118/2421] Sync with from public repo - https://github.com/github/backup-utils/pull/618 --- .github/workflows/lint.yml | 18 ++++++++++++++++++ .github/workflows/main.yml | 11 ++++++----- .travis.yml | 31 ------------------------------- 3 files changed, 24 insertions(+), 36 deletions(-) create mode 100644 .github/workflows/lint.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..f7f72df90 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,18 @@ +name: Lint Code Base + +on: + push: + branches-ignore: + - 'master' + +jobs: + build: + name: Lint Code Base + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: Lint Code Base + uses: docker://github/super-linter:v2.1.1 + env: + VALIDATE_ALL_CODEBASE: false diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 32b4d8a97..6b3fd0641 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,6 +7,8 @@ jobs: strategy: matrix: os: ['ubuntu-latest', 'macos-latest'] + # os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest'] + fail-fast: false runs-on: ${{ matrix.os }} steps: @@ -20,7 +22,7 @@ jobs: if: matrix.os == 'ubuntu-latest' - name: Install Dependencies (macOS) run: | - brew install gnu-tar shellcheck jq pigz coreutils + brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt brew unlink parallel brew install moreutils gawk if: matrix.os == 'macos-latest' @@ -31,7 +33,6 @@ jobs: export PATH="$PATH:/snap/bin" make test shell: bash - - name: Build - run: debuild -uc -us - if: matrix.os == 'ubuntu-latest' - + - name: Build (Linux) + run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc + if: matrix.os == 'ubuntu-latest' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 59aa814db..000000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ ---- -language: minimal -matrix: - include: - - os: osx - before_install: - - brew update - - brew install gawk - - brew install gnu-tar - - brew install moreutils - - brew install shellcheck - - brew install jq - - brew install pigz - script: make test - - os: linux - dist: trusty - sudo: required - install: - - wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" - - tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" - addons: - apt: - packages: - - devscripts - - debhelper - - moreutils - - fakeroot - - jq - - coreutils - - pigz - script: debuild -uc -us From 08f80624b9a6a1c92aca04ece103f1cd2f932c50 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 23 Jun 2020 15:52:19 -0700 Subject: [PATCH 1119/2421] Add comments explaining ghe-restore-external-database-check --- .../ghe-restore-external-database-check | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index cab0fd8e0..9d6bc4d60 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -8,11 +8,14 @@ set -e -# Check if there are MySQL nodes in the target environment +# Restoring an internal DB snapshot to an appliance currently configured with BYODB ON +# $RESTORE_SETTINGS means the appliance will be reconfigured with BYODB OFF +# so we need to ensure that mysql-server roles are present in the cluster config if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then - mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") + # Check if there are MySQL nodes in the target environment + mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") if [ -z "$mysql_nodes" ]; then # Restoring a non external DB snapshot to an internal DB appliance # requires that the target environment has a mysql-server configured. @@ -22,11 +25,13 @@ if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then fi fi -# User should remove the `mysql-server` role after the fact. +# Restoring a BYODB snapshot to an appliance currently configured with BYODB OFF +# $RESTORE_SETTINGS means the appliance will be reconfigured with BYODB ON +# so we should warn that mysql-server roles should be removed from the cluster config if $RESTORE_SETTINGS && external_database_snapshot_to_internal_database; then if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then - mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") + mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") if [ -n "$mysql_nodes" ]; then echo "Warning: Target environment has mysql-server role. This should be removed after the restore has completed." exit 0 From d30deb2589fe756cffc599811f49772c88885a8e Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 23 Jun 2020 16:11:19 -0700 Subject: [PATCH 1120/2421] Switch order of conditions --- share/github-backup-utils/ghe-restore-external-database-check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 9d6bc4d60..514458bdc 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -11,7 +11,7 @@ set -e # Restoring an internal DB snapshot to an appliance currently configured with BYODB ON # $RESTORE_SETTINGS means the appliance will be reconfigured with BYODB OFF # so we need to ensure that mysql-server roles are present in the cluster config -if $RESTORE_SETTINGS && internal_database_snapshot_to_external_database; then +if internal_database_snapshot_to_external_database && $RESTORE_SETTINGS; then if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then # Check if there are MySQL nodes in the target environment @@ -28,7 +28,7 @@ fi # Restoring a BYODB snapshot to an appliance currently configured with BYODB OFF # $RESTORE_SETTINGS means the appliance will be reconfigured with BYODB ON # so we should warn that mysql-server roles should be removed from the cluster config -if $RESTORE_SETTINGS && external_database_snapshot_to_internal_database; then +if external_database_snapshot_to_internal_database && $RESTORE_SETTINGS; then if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") From 1dbb5406070682996414df5f04a33a548e830c86 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Wed, 24 Jun 2020 23:08:24 +0000 Subject: [PATCH 1121/2421] properly pipe stderr from restore command; fix test output --- test/test-ghe-restore-external-database.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 95a1fd5de..6357e71df 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -65,11 +65,9 @@ begin_test "ghe-restore prevents restore of external DB snapshot to non-external # Disable external database on remote host git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f 2> "$TRASHDIR/restore-out"; then # Verify that the restore failed due to snapshot compatability. - grep -q "Snapshot from GitHub Enterprise with an External Database configured cannot be restored - to an appliance without external database configured." "$TRASHDIR/restore-out" + grep -q "Snapshot from GitHub Enterprise with an external database configured cannot be restored to an appliance without external database configured" "$TRASHDIR/restore-out" exit 0 else From 67fb730c869dbbe94370b3d303248cdbbca87ed8 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 25 Jun 2020 06:25:20 +0000 Subject: [PATCH 1122/2421] fix test string --- test/test-ghe-restore-external-database.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 6357e71df..c54a58caf 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -328,7 +328,7 @@ begin_test "ghe-restore restore of external DB snapshot with -c to a cluster con false fi - grep -q "Target environment has mysql-server role. This should be removed post-restore." "$TRASHDIR/restore-out" + grep -q "Target environment has mysql-server role. This should be removed after the restore has completed." "$TRASHDIR/restore-out" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" From db62fb27838a0e5f5b8bc8c599d3a8ebd4b0fa34 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 25 Jun 2020 06:41:29 +0000 Subject: [PATCH 1123/2421] fix lint warning --- test/bin/ghe-cluster-each | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 2679a72fc..129d8e739 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -4,7 +4,7 @@ # to assert that the command was executed. set -e -for arg in "$@"; do +for _ in "$@"; do case "$1" in -u) SHOW_UUID=true From 9c6e47973b52694aee6d48101119d0cc31db814a Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 25 Jun 2020 10:55:59 +0000 Subject: [PATCH 1124/2421] Change to is_external_database_target and is_external_database_snapshot --- bin/ghe-restore | 4 ++-- share/github-backup-utils/ghe-backup-config | 16 ++++++++++++---- share/github-backup-utils/ghe-backup-mysql | 2 +- share/github-backup-utils/ghe-restore-mysql | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 323d0e8b9..4c00aec14 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -273,7 +273,7 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" fi -if is_external_database_target_or_snapshot; then +if is_external_database_snapshot; then appliance_strategy="external" backup_snapshot_strategy="external" else @@ -290,7 +290,7 @@ else fi fi -if is_external_database_target_or_snapshot && $SKIP_MYSQL; then +if is_external_database_snapshot && $SKIP_MYSQL; then echo "Skipping MySQL restore." else echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 8e77c46ad..a0f2a825e 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -440,27 +440,35 @@ check_external_database_snapshot_compatibility(){ # - the target appliance uses the internal MySQL database (aka NOT BYODB), and # - the snapshot being restored is from an appliance using an external MySQL database (BYODB) external_database_snapshot_to_internal_database(){ - ! is_service_external "mysql" && is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" + ! is_external_database_target && is_external_database_snapshot } # Helper method that returns true if: # - the target appliance uses an external MySQL database (BYODB), and # - the snapshot being restored is from an appliance using an internal MySQL database (aka NOT BYODB) internal_database_snapshot_to_external_database(){ - is_service_external "mysql" && ! is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" + is_external_database_target && ! is_external_database_snapshot } is_external_database_target_or_snapshot(){ # If restoring settings, only check if the snapshot being restored was from an appliance with external DB configured. if $RESTORE_SETTINGS; then - is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" + is_external_database_snapshot else # Check if restoring a snapshot with an external database configured, or restoring # to an appliance with an external database configured. - is_service_external 'mysql' "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" || is_service_external 'mysql' + is_external_database_snapshot || is_external_database_target fi } +is_external_database_target(){ + is_service_external "mysql" +} + +is_external_database_snapshot(){ + is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" +} + check_external_db_compatibility() { # Check that the backup snapshot is compatible with the running appliance. if check_external_database_snapshot_compatibility; then diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 3a8daa830..231b23d61 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -15,7 +15,7 @@ bm_start "$(basename $0)" # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" -if is_service_external 'mysql'; then +if is_external_database_target; then echo "Backing up external MySQL database using customer-provided script..." if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then $EXTERNAL_DATABASE_BACKUP_SCRIPT diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 04469e8cd..6d8363a22 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -29,7 +29,7 @@ export GHE_RESTORE_SNAPSHOT # The directory holding the snapshot to restore snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -if is_external_database_target_or_snapshot; then +if is_external_database_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT else From 133e93e6981916c85b09c3a500e7ea902eafde87 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 25 Jun 2020 11:06:43 +0000 Subject: [PATCH 1125/2421] Check for both with skip mysql --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 4c00aec14..f58a7c3b4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -290,7 +290,7 @@ else fi fi -if is_external_database_snapshot && $SKIP_MYSQL; then +if is_external_database_target_or_snapshot && $SKIP_MYSQL; then echo "Skipping MySQL restore." else echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." From 364b5e9eb522c0c5eea62f763f7405f9f4aa74b2 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 25 Jun 2020 13:08:39 +0000 Subject: [PATCH 1126/2421] Check for MySQL master --- .../github-backup-utils/ghe-restore-external-database-check | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 514458bdc..46ba9055e 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -22,6 +22,12 @@ if internal_database_snapshot_to_external_database && $RESTORE_SETTINGS; then echo "Error: Target environment does not have a node with mysql-server role. Aborting restore." exit 1 fi + + mysql_master=$(ghe-ssh "$GHE_HOSTNAME" "git config -f $GHE_REMOTE_CLUSTER_CONF_FILE cluster.mysql-master") + if [ -z "$mysql_master" ]; then + echo "Error: Target environment does not have mysql-master configured. Aborting restore." + exit 1 + fi fi fi From 7458e2ec1478cb44c375672488e067c846b51d9a Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 25 Jun 2020 13:28:01 +0000 Subject: [PATCH 1127/2421] Add check for cluster.mysql-master --- .../ghe-restore-external-database-check | 3 +- test/test-ghe-restore-external-database.sh | 37 ++++++++++++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 46ba9055e..014b39ad3 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -23,8 +23,7 @@ if internal_database_snapshot_to_external_database && $RESTORE_SETTINGS; then exit 1 fi - mysql_master=$(ghe-ssh "$GHE_HOSTNAME" "git config -f $GHE_REMOTE_CLUSTER_CONF_FILE cluster.mysql-master") - if [ -z "$mysql_master" ]; then + if ! ghe-ssh "$GHE_HOSTNAME" "git config -f $GHE_REMOTE_CLUSTER_CONF_FILE cluster.mysql-master"; then echo "Error: Target environment does not have mysql-master configured. Aborting restore." exit 1 fi diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index c54a58caf..4c939b72d 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -266,7 +266,7 @@ begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a clu ) end_test -begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluster configured with mysql-server role" +begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-master" ( set -e setup @@ -283,6 +283,39 @@ begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluste mysql-server = true " > $GHE_REMOTE_CLUSTER_CONF_FILE + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out"; then + grep -q "Error: Target environment does not have mysql-master configured. Aborting restore." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should not have exited successfully + false + fi +) +end_test + +begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluster configured with mysql-server role" +( + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + echo "[cluster] + mysql-master = fake-uuid + [cluster \"fake-uuid\"] + hostname = fake-uuid + git-server = true + web-server = true + mysql-server = true + " > $GHE_REMOTE_CLUSTER_CONF_FILE + # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then # for debugging @@ -321,7 +354,7 @@ begin_test "ghe-restore restore of external DB snapshot with -c to a cluster con export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 bash -x ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then # for debugging cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully From 9fe920934ff47bbbfc2590608e67f10df3bccd3f Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Thu, 25 Jun 2020 08:15:56 -0700 Subject: [PATCH 1128/2421] Remove extra testing loop --- script/cibuild | 23 +++-------------------- script/release | 4 ---- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/script/cibuild b/script/cibuild index 13ccc130b..7f57f444d 100755 --- a/script/cibuild +++ b/script/cibuild @@ -2,29 +2,12 @@ # Usage: script/cibuild [--no-package] set -e -# GHE appliance versions to run tests against. Remote metadata files are put in -# place with this version at the beginning of each test and many commands have -# conditional logic based on the remote version. Running the suite against -# different major versions ensures we're covering these conditional paths. -REMOTE_VERSIONS="2.18.0 2.20.0" - # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true -# Run over all remote versions and run entire test suite against each -res=true -for version in $REMOTE_VERSIONS -do - echo "==> Running testsuite with GHE_TEST_REMOTE_VERSION=$version" - export GHE_TEST_REMOTE_VERSION="$version" - if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then - res=false - fi - echo -done - -# If any of the version tests failed, exit non-zero -$res +if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then + exit 1 +fi # Bail out when --no-package given [ "$1" = "--no-package" ] && exit 0 diff --git a/script/release b/script/release index bee1bcb85..761d56a67 100755 --- a/script/release +++ b/script/release @@ -210,10 +210,6 @@ def bump_version(new_version, min_version = nil, path = 'share/github-backup-uti content = File.read('test/testlib.sh') new_content = content.gsub(/GHE_TEST_REMOTE_VERSION:=[0-9]\.[0-9]+\.0/,"GHE_TEST_REMOTE_VERSION:=#{new_version}") File.open('test/testlib.sh', 'w') {|file| file.puts new_content } - - content = File.read('script/cibuild') - new_content = content.gsub(/^REMOTE_VERSIONS=.*$/, "REMOTE_VERSIONS=\"#{min_version} #{new_version}\"") - File.open('script/cibuild', 'w') {|file| file.puts new_content } end end From ce657dd6a3ff4454bf64700983c6e6a13c251133 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 25 Jun 2020 23:59:32 +0000 Subject: [PATCH 1129/2421] Prevent skipping mysql restore for non-external configuration --- bin/ghe-restore | 6 +++++ test/test-ghe-restore-external-database.sh | 27 ++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index f58a7c3b4..b25940847 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -97,6 +97,12 @@ cleanup () { # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" +# Exit early if --skip-mysql used for non external db target +if ! is_external_database_target && $SKIP_MYSQL; then + echo "Error: --skip-mysql is applicable only to external database configuration. Aborting restore." + exit 1 +fi + # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 4c939b72d..714b80a54 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -112,8 +112,8 @@ begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + # Enable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true SKIP_MYSQL=true export SKIP_MYSQL @@ -173,6 +173,29 @@ begin_test "ghe-restore allows restore of non external DB snapshot with --skip-m ) end_test +begin_test "ghe-restore prevents restoring with --skip-mysql to a cluster configured without mysql-master" +( + set -e + setup + + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out"; then + grep -q "Error: --skip-mysql is applicable only to external database configuration. Aborting restore." "$TRASHDIR/restore-out" + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + : ghe-restore should not have exited successfully + false + fi +) +end_test + +exit + begin_test "ghe-restore allows restore of non external DB snapshot with -c" ( set -e From 5f8682f5ab320defc98e083525381b4a3b182434 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Fri, 26 Jun 2020 10:05:03 -0700 Subject: [PATCH 1130/2421] Revert "Prevent skipping mysql restore for non-external configuration" This reverts commit ce657dd6a3ff4454bf64700983c6e6a13c251133. --- bin/ghe-restore | 6 ----- test/test-ghe-restore-external-database.sh | 27 ++-------------------- 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b25940847..f58a7c3b4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -97,12 +97,6 @@ cleanup () { # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" -# Exit early if --skip-mysql used for non external db target -if ! is_external_database_target && $SKIP_MYSQL; then - echo "Error: --skip-mysql is applicable only to external database configuration. Aborting restore." - exit 1 -fi - # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 714b80a54..4c939b72d 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -112,8 +112,8 @@ begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - # Enable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + # Disable external database on remote host + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false SKIP_MYSQL=true export SKIP_MYSQL @@ -173,29 +173,6 @@ begin_test "ghe-restore allows restore of non external DB snapshot with --skip-m ) end_test -begin_test "ghe-restore prevents restoring with --skip-mysql to a cluster configured without mysql-master" -( - set -e - setup - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out"; then - grep -q "Error: --skip-mysql is applicable only to external database configuration. Aborting restore." "$TRASHDIR/restore-out" - exit 0 - else - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should not have exited successfully - false - fi -) -end_test - -exit - begin_test "ghe-restore allows restore of non external DB snapshot with -c" ( set -e From 6dbab2c908336e817b309a8cdfc21c2a0c2ce711 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Fri, 26 Jun 2020 12:50:40 -0700 Subject: [PATCH 1131/2421] Error out if mysql-server/mysql-master are in cluster config when restoring BYODB snapshot with settings --- .../ghe-restore-external-database-check | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 014b39ad3..4e5257f54 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -10,7 +10,7 @@ set -e # Restoring an internal DB snapshot to an appliance currently configured with BYODB ON # $RESTORE_SETTINGS means the appliance will be reconfigured with BYODB OFF -# so we need to ensure that mysql-server roles are present in the cluster config +# so we need to ensure that mysql-server/mysql-master roles are present in the cluster config if internal_database_snapshot_to_external_database && $RESTORE_SETTINGS; then if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then @@ -19,12 +19,16 @@ if internal_database_snapshot_to_external_database && $RESTORE_SETTINGS; then if [ -z "$mysql_nodes" ]; then # Restoring a non external DB snapshot to an internal DB appliance # requires that the target environment has a mysql-server configured. - echo "Error: Target environment does not have a node with mysql-server role. Aborting restore." + echo "Error: Target environment does not have any nodes with the mysql-server role." + echo "mysql-server roles need to be set in the cluster configuration file prior to attempting this type of restore." + echo "Aborting restore." exit 1 fi if ! ghe-ssh "$GHE_HOSTNAME" "git config -f $GHE_REMOTE_CLUSTER_CONF_FILE cluster.mysql-master"; then - echo "Error: Target environment does not have mysql-master configured. Aborting restore." + echo "Error: Target environment does not have mysql-master configured." + echo "mysql-master role needs to be set in the cluster configuration file prior to attempting this type of restore." + echo "Aborting restore." exit 1 fi fi @@ -32,14 +36,23 @@ fi # Restoring a BYODB snapshot to an appliance currently configured with BYODB OFF # $RESTORE_SETTINGS means the appliance will be reconfigured with BYODB ON -# so we should warn that mysql-server roles should be removed from the cluster config +# so we need to ensure that mysql-server/mysql-master roles are removed from the cluster config if external_database_snapshot_to_internal_database && $RESTORE_SETTINGS; then if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") if [ -n "$mysql_nodes" ]; then - echo "Warning: Target environment has mysql-server role. This should be removed after the restore has completed." - exit 0 + echo "Error: Target environment has nodes with the mysql-server role." + echo "mysql-server roles need to be removed from the cluster configuration file prior to attempting this type of restore." + echo "Aborting restore." + exit 1 + fi + + if ghe-ssh "$GHE_HOSTNAME" "git config -f $GHE_REMOTE_CLUSTER_CONF_FILE cluster.mysql-master"; then + echo "Error: Target environment has mysql-master configured." + echo "mysql-master role needs to be removed from the cluster configuration file prior to attempting this type of restore." + echo "Aborting restore." + exit 1 fi fi fi From 5e396bf5b2cb6646e29fa5173ec7957ca50e060c Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Fri, 26 Jun 2020 22:33:00 +0000 Subject: [PATCH 1132/2421] fix test strings --- test/test-ghe-restore-external-database.sh | 23 ++++++++-------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 4c939b72d..cd67bc26e 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -254,7 +254,7 @@ begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a clu # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - grep -q "Error: Target environment does not have a node with mysql-server role." "$TRASHDIR/restore-out" + grep -q "Error: Target environment does not have any nodes with the mysql-server role." "$TRASHDIR/restore-out" exit 0 else @@ -285,7 +285,7 @@ begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a clu # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out"; then - grep -q "Error: Target environment does not have mysql-master configured. Aborting restore." "$TRASHDIR/restore-out" + grep -q "Error: Target environment does not have mysql-master configured." "$TRASHDIR/restore-out" exit 0 else @@ -334,7 +334,7 @@ begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluste ) end_test -begin_test "ghe-restore restore of external DB snapshot with -c to a cluster configured with mysql-server role warns to remove mysql" +begin_test "ghe-restore prevents restore of external DB snapshot with -c to a cluster configured with mysql-server" ( set -e setup @@ -354,21 +354,14 @@ begin_test "ghe-restore restore of external DB snapshot with -c to a cluster con export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out"; then + grep -q "Error: Target environment has nodes with the mysql-server role." "$TRASHDIR/restore-out" + exit 0 + else # for debugging cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully + : ghe-restore should not have exited successfully false fi - - grep -q "Target environment has mysql-server role. This should be removed after the restore has completed." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data ) end_test \ No newline at end of file From e42940f95100de451f532956738415fb6a52b4bc Mon Sep 17 00:00:00 2001 From: ritchxu Date: Mon, 29 Jun 2020 10:16:41 -0400 Subject: [PATCH 1133/2421] FF backup/restore --- bin/ghe-backup | 6 ++++-- bin/ghe-restore | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index d77cab7a8..fc3ddd0aa 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -207,8 +207,10 @@ if is_binary_backup; then fi bm_end "ghe-export-mysql" -echo "Backing up MSSQL databases ..." -ghe-backup-mssql 1>&3 || failures="$failures mssql" +if ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.actions.enabled"; then + echo "Backing up MSSQL databases ..." + ghe-backup-mssql 1>&3 || failures="$failures mssql" +fi echo "Backing up Redis database ..." ghe-backup-redis > redis.rdb || failures="$failures redis" diff --git a/bin/ghe-restore b/bin/ghe-restore index 0d3210a81..92f4c44f2 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -255,8 +255,10 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then echo "Restoring MySQL database ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 -echo "Restoring MSSQL database ..." -ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 +if ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.actions.enabled"; then + echo "Restoring MSSQL database ..." + ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 +fi echo "Restoring Redis database ..." bm_start "ghe-import-redis" From 4d9a92525d347c5ce6b914da8e9407ea968db56c Mon Sep 17 00:00:00 2001 From: ritchxu Date: Mon, 29 Jun 2020 11:32:18 -0400 Subject: [PATCH 1134/2421] Validate enabled path in tests --- test/testlib.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/testlib.sh b/test/testlib.sh index 67b36ea84..44dce41a3 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -298,6 +298,9 @@ setup_test_data () { # Break a repo to test fsck rm -f $repo3/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 + # Validate enabled path in tests + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "app.actions.enabled" true + if [ "$loc" != "$GHE_REMOTE_DATA_USER_DIR" ]; then # create a fake backups for each datastore echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" From 6225e43d5b7277b29c93cb44c9484ae68b8a519e Mon Sep 17 00:00:00 2001 From: ritchxu Date: Mon, 29 Jun 2020 11:44:14 -0400 Subject: [PATCH 1135/2421] Revert "Validate enabled path in tests" This reverts commit 4d9a92525d347c5ce6b914da8e9407ea968db56c. --- test/testlib.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index 44dce41a3..67b36ea84 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -298,9 +298,6 @@ setup_test_data () { # Break a repo to test fsck rm -f $repo3/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 - # Validate enabled path in tests - ghe-ssh "$GHE_HOSTNAME" -- ghe-config "app.actions.enabled" true - if [ "$loc" != "$GHE_REMOTE_DATA_USER_DIR" ]; then # create a fake backups for each datastore echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" From c39b5a4ab5dcea3c2150bd4d427a4ae3716c49f1 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Mon, 29 Jun 2020 11:44:18 -0400 Subject: [PATCH 1136/2421] Revert "FF backup/restore" This reverts commit e42940f95100de451f532956738415fb6a52b4bc. --- bin/ghe-backup | 6 ++---- bin/ghe-restore | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 2012ba3d4..83ce02a84 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -182,10 +182,8 @@ bm_end "ghe-export-ssh-host-keys" ghe-backup-mysql || failures="$failures mysql" -if ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.actions.enabled"; then - echo "Backing up MSSQL databases ..." - ghe-backup-mssql 1>&3 || failures="$failures mssql" -fi +echo "Backing up MSSQL databases ..." +ghe-backup-mssql 1>&3 || failures="$failures mssql" commands=(" echo \"Backing up Redis database ...\" diff --git a/bin/ghe-restore b/bin/ghe-restore index b6c4f05a3..f25fdbead 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -275,10 +275,8 @@ fi echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 -if ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.actions.enabled"; then - echo "Restoring MSSQL database ..." - ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 -fi +echo "Restoring MSSQL database ..." +ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 commands=(" echo \"Restoring Redis database ...\" From bfc715324f9bcd5ee52d0d7f3cd1c7f502caafa1 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Mon, 29 Jun 2020 12:17:05 -0400 Subject: [PATCH 1137/2421] Another attempt in FF backup/restore --- bin/ghe-backup | 6 ++++-- bin/ghe-restore | 6 ++++-- test/testlib.sh | 3 +++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 83ce02a84..2012ba3d4 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -182,8 +182,10 @@ bm_end "ghe-export-ssh-host-keys" ghe-backup-mysql || failures="$failures mysql" -echo "Backing up MSSQL databases ..." -ghe-backup-mssql 1>&3 || failures="$failures mssql" +if ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.actions.enabled"; then + echo "Backing up MSSQL databases ..." + ghe-backup-mssql 1>&3 || failures="$failures mssql" +fi commands=(" echo \"Backing up Redis database ...\" diff --git a/bin/ghe-restore b/bin/ghe-restore index f25fdbead..b6c4f05a3 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -275,8 +275,10 @@ fi echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 -echo "Restoring MSSQL database ..." -ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 +if ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.actions.enabled"; then + echo "Restoring MSSQL database ..." + ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 +fi commands=(" echo \"Restoring Redis database ...\" diff --git a/test/testlib.sh b/test/testlib.sh index 67b36ea84..7c1f37db4 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -197,6 +197,9 @@ setup_test_data () { mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "fake password hash data" + # Validate enabled path in tests + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" app.actions.enabled "true" + # Create some fake hooks in the remote data directory mkdir -p "$loc/git-hooks/environments/tarballs" mkdir -p "$loc/git-hooks/repos" From f3090f071d6fa58da52042957e1553255b6ecf44 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Mon, 29 Jun 2020 19:08:42 +0000 Subject: [PATCH 1138/2421] Fix tests --- bin/ghe-backup | 2 +- bin/ghe-restore | 2 +- test/test-ghe-backup.sh | 4 ++++ test/test-ghe-restore.sh | 1 + test/testlib.sh | 27 ++++++++++++++++++--------- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 2012ba3d4..30a6a7e6a 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -182,7 +182,7 @@ bm_end "ghe-export-ssh-host-keys" ghe-backup-mysql || failures="$failures mysql" -if ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.actions.enabled"; then +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Backing up MSSQL databases ..." ghe-backup-mssql 1>&3 || failures="$failures mssql" fi diff --git a/bin/ghe-restore b/bin/ghe-restore index b6c4f05a3..377fd6640 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -275,7 +275,7 @@ fi echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 -if ghe-ssh "$GHE_HOSTNAME" ghe-config --true "app.actions.enabled"; then +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Restoring MSSQL database ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 fi diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 589180028..5fe99e0fe 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -350,6 +350,7 @@ begin_test "ghe-backup takes full backup on first run" # It helps create "current" directory as symlink # setup_mssql_backup_file uses "current" set -e + enable_actions rm -rf $GHE_REMOTE_DATA_USER_DIR/mssql/backups/* rm -rf $GHE_DATA_DIR/current/mssql/* @@ -362,6 +363,7 @@ end_test begin_test "ghe-backup takes full backup upon expiration" ( set -e + enable_actions setup_mssql_backup_file "full_mssql" 11 "bak" @@ -374,6 +376,7 @@ end_test begin_test "ghe-backup takes diff backup upon expiration" ( set -e + enable_actions setup_mssql_backup_file "full_mssql" 7 "bak" @@ -387,6 +390,7 @@ end_test begin_test "ghe-backup takes transaction backup upon expiration" ( set -e + enable_actions setup_mssql_backup_file "full_mssql" 3 "bak" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index f92b7d92d..bbfda1bef 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -285,6 +285,7 @@ begin_test "ghe-restore invokes ghe-import-mssql" set -e rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata + enable_actions # enable maintenance mode and create required directories setup_maintenance_mode diff --git a/test/testlib.sh b/test/testlib.sh index 7c1f37db4..df455550f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -197,9 +197,6 @@ setup_test_data () { mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "fake password hash data" - # Validate enabled path in tests - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" app.actions.enabled "true" - # Create some fake hooks in the remote data directory mkdir -p "$loc/git-hooks/environments/tarballs" mkdir -p "$loc/git-hooks/repos" @@ -345,8 +342,10 @@ verify_common_data() { # verify the extracted repositories were transferred diff -ru "$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" "$GHE_DATA_DIR/current/git-hooks/repos" - # verify mssql backups were transferred - diff -ru "$GHE_REMOTE_DATA_USER_DIR/mssql/backups" "$GHE_DATA_DIR/current/mssql" + if is_actions_enabled; then + # verify mssql backups were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/mssql/backups" "$GHE_DATA_DIR/current/mssql" + fi # tests that differ for cluster and single node backups and restores if [ "$(cat $GHE_DATA_DIR/current/strategy)" = "rsync" ]; then @@ -395,10 +394,12 @@ verify_all_backedup_data() { # check that ca certificates were backed up [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] - # check that mssql databases were backed up - [ "$(cat "$GHE_DATA_DIR/current/mssql/mssql.bak")" = "fake mssql full data" ] - [ "$(cat "$GHE_DATA_DIR/current/mssql/mssql.diff")" = "fake mssql diff data" ] - [ "$(cat "$GHE_DATA_DIR/current/mssql/mssql.log")" = "fake mssql tran data" ] + if is_actions_enabled; then + # check that mssql databases were backed up + [ "$(cat "$GHE_DATA_DIR/current/mssql/mssql.bak")" = "fake mssql full data" ] + [ "$(cat "$GHE_DATA_DIR/current/mssql/mssql.diff")" = "fake mssql diff data" ] + [ "$(cat "$GHE_DATA_DIR/current/mssql/mssql.log")" = "fake mssql tran data" ] + fi # verify that ghe-backup wrote its version information to the host [ -f "$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version" ] @@ -480,3 +481,11 @@ setup_mssql_backup_file() { touch "$GHE_DATA_DIR/current/mssql/$1@$fake_last_utc.log" fi } + +enable_actions() { + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config app.actions.enabled true' +} + +is_actions_enabled() { + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled' +} From 3ecab418e997bb42c925a8e60e4f76c4792defce Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 29 Jun 2020 15:19:08 -0700 Subject: [PATCH 1139/2421] Exit when attempting to restore settings and changing BYODB state --- .../ghe-restore-external-database-check | 49 ++++--------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index 4e5257f54..f7e59336e 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -9,52 +9,21 @@ set -e # Restoring an internal DB snapshot to an appliance currently configured with BYODB ON -# $RESTORE_SETTINGS means the appliance will be reconfigured with BYODB OFF -# so we need to ensure that mysql-server/mysql-master roles are present in the cluster config +# $RESTORE_SETTINGS means the appliance would be reconfigured with BYODB OFF +# backup-utils does not support this scenario and they must migrate appliance beforehand if internal_database_snapshot_to_external_database && $RESTORE_SETTINGS; then - if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then - - # Check if there are MySQL nodes in the target environment - mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") - if [ -z "$mysql_nodes" ]; then - # Restoring a non external DB snapshot to an internal DB appliance - # requires that the target environment has a mysql-server configured. - echo "Error: Target environment does not have any nodes with the mysql-server role." - echo "mysql-server roles need to be set in the cluster configuration file prior to attempting this type of restore." - echo "Aborting restore." - exit 1 - fi - - if ! ghe-ssh "$GHE_HOSTNAME" "git config -f $GHE_REMOTE_CLUSTER_CONF_FILE cluster.mysql-master"; then - echo "Error: Target environment does not have mysql-master configured." - echo "mysql-master role needs to be set in the cluster configuration file prior to attempting this type of restore." - echo "Aborting restore." - exit 1 - fi - fi + echo "Restoring the settings of a snapshot with bundled MySQL to an appliance with externally-managed MySQL service is not supported." + echo "Please migrate the appliance using the official MySQL migration tooling first." + exit 1 fi # Restoring a BYODB snapshot to an appliance currently configured with BYODB OFF # $RESTORE_SETTINGS means the appliance will be reconfigured with BYODB ON -# so we need to ensure that mysql-server/mysql-master roles are removed from the cluster config +# backup-utils does not support this scenario and they must migrate appliance beforehand if external_database_snapshot_to_internal_database && $RESTORE_SETTINGS; then - if ghe-ssh "$GHE_HOSTNAME" "test -f $GHE_REMOTE_CLUSTER_CONF_FILE"; then - - mysql_nodes=$(ghe-ssh "$GHE_HOSTNAME" "ghe-cluster-each -u -r mysql") - if [ -n "$mysql_nodes" ]; then - echo "Error: Target environment has nodes with the mysql-server role." - echo "mysql-server roles need to be removed from the cluster configuration file prior to attempting this type of restore." - echo "Aborting restore." - exit 1 - fi - - if ghe-ssh "$GHE_HOSTNAME" "git config -f $GHE_REMOTE_CLUSTER_CONF_FILE cluster.mysql-master"; then - echo "Error: Target environment has mysql-master configured." - echo "mysql-master role needs to be removed from the cluster configuration file prior to attempting this type of restore." - echo "Aborting restore." - exit 1 - fi - fi + echo "Restoring the settings of a snapshot with externally-managed MySQL service to an appliance with bundled MySQL is not supported." + echo "Please migrate the appliance using the official MySQL migration tooling first." + exit 1 fi if ! check_external_db_compatibility; then From c3dd3bbf61cee0d1d3c5bff8a3f163f20b52bd70 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 29 Jun 2020 15:53:46 -0700 Subject: [PATCH 1140/2421] Rework ghe-restore-external-database-check --- share/github-backup-utils/ghe-backup-config | 46 ---------------- .../ghe-restore-external-database-check | 53 ++++++++++++------- 2 files changed, 35 insertions(+), 64 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index a0f2a825e..a1d01e53b 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -416,26 +416,6 @@ is_instance_configured(){ ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]" } -# Helper method to validate whether we can restore the snapshot to the target appliance -check_external_database_snapshot_compatibility(){ - # always restore to an unconfigured instance. - if ! is_instance_configured; then - return 1 - fi - - # If restoring settings, the target appliance will be converted. - if $RESTORE_SETTINGS; then - return 1 - fi - - # If skipping MySQL steps, assume the MySQL backup has already been restored prior to ghe-restore. - if $SKIP_MYSQL; then - return 1 - fi - - return 0 -} - # Helper method that returns true if: # - the target appliance uses the internal MySQL database (aka NOT BYODB), and # - the snapshot being restored is from an appliance using an external MySQL database (BYODB) @@ -468,29 +448,3 @@ is_external_database_target(){ is_external_database_snapshot(){ is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } - -check_external_db_compatibility() { - # Check that the backup snapshot is compatible with the running appliance. - if check_external_database_snapshot_compatibility; then - - # Attempting to restore external DB backup snapshot to internal DB appliance - if external_database_snapshot_to_internal_database; then - echo "Error: Snapshot from GitHub Enterprise with an external database configured" \ - "cannot be restored to an appliance without external database configured. Aborting." \ - "To restore this snapshot, you must restore the appliance configuration (-c)" \ - "or skip the MySQL restore steps (--skip-mysql) after restoring MySQL data manually." >&2 - return 1 - fi - - # Attempting to restore internal DB backup snapshot to external DB appliance - if internal_database_snapshot_to_external_database; then - echo "Error: Snapshot from GitHub Enterprise with internal database" \ - "cannot be restored to an appliance with an external database configured. Aborting." \ - "To restore this snapshot, you must restore the appliance configuration (-c)" \ - "or skip the MySQL restore steps (--skip-mysql) after restoring MySQL data manually." >&2 - return 1 - fi - - return 0 - fi -} diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-check index f7e59336e..2e4b30e74 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-check @@ -8,24 +8,41 @@ set -e -# Restoring an internal DB snapshot to an appliance currently configured with BYODB ON -# $RESTORE_SETTINGS means the appliance would be reconfigured with BYODB OFF -# backup-utils does not support this scenario and they must migrate appliance beforehand -if internal_database_snapshot_to_external_database && $RESTORE_SETTINGS; then - echo "Restoring the settings of a snapshot with bundled MySQL to an appliance with externally-managed MySQL service is not supported." - echo "Please migrate the appliance using the official MySQL migration tooling first." - exit 1 -fi +# Always allow restoring to unconfigured appliances. +# Additional checks are required if the instance is configured. +if is_instance_configured; then -# Restoring a BYODB snapshot to an appliance currently configured with BYODB OFF -# $RESTORE_SETTINGS means the appliance will be reconfigured with BYODB ON -# backup-utils does not support this scenario and they must migrate appliance beforehand -if external_database_snapshot_to_internal_database && $RESTORE_SETTINGS; then - echo "Restoring the settings of a snapshot with externally-managed MySQL service to an appliance with bundled MySQL is not supported." - echo "Please migrate the appliance using the official MySQL migration tooling first." - exit 1 -fi + if internal_database_snapshot_to_external_database; then + + # Restoring settings in this scenario would change BYODB state, which is not supported via backup-utils. + if $RESTORE_SETTINGS; then + echo "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." + echo "Please reconfigure the appliance first, then run ghe-restore again." + exit 1 + fi + + # Restoring interal DB snapshot to BYODB appliance without passing in --skip-mysql is not supported. + if ! $SKIP_MYSQL; then + echo "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." + echo "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." + exit 1 + fi + fi + + if external_database_snapshot_to_internal_database; then + + # Restoring settings in this scenario would change BYODB state, which is not supported via backup-utils. + if $RESTORE_SETTINGS; then + echo "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." + echo "Please reconfigure the appliance first, then run ghe-restore again." + exit 1 + fi -if ! check_external_db_compatibility; then - exit 1 + # Restoring BYODB snapshot to internal DB appliance without passing in --skip-mysql is not supported. + if ! $SKIP_MYSQL; then + echo "Restoring a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." + echo "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." + exit 1 + fi + fi fi From 9eb8c13f055886ff48020d5375213f9cd01d9671 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 10:56:50 -0700 Subject: [PATCH 1141/2421] Rearrange usage text --- bin/ghe-restore | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index f58a7c3b4..51f0731c5 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore [-fchv] [--version] [-s ] [] +#/ Usage: ghe-restore [-cfhv] [--version] [--skip-mysql] [-s ] [] #/ #/ Restores a GitHub instance from local backup snapshots. #/ @@ -9,22 +9,24 @@ #/ #/ #/ OPTIONS: -#/ -f | --force Don't prompt for confirmation before restoring. -#/ --skip-mysql Skip MySQL restore steps. Only applicable to external databases. -#/ -c | --config Restore appliance settings and license in addition to -#/ datastores. Settings are not restored by default to -#/ prevent overwriting different configuration on the -#/ restore host. -#/ -v | --verbose Enable verbose output. -#/ -h | --help Show this message. -#/ --version Display version information and exit. -#/ -s Restore from the snapshot with the given id. Available -#/ snapshots may be listed under the data directory. -#/ The is the hostname or IP of the GitHub Enterprise -#/ instance. The may be omitted when the -#/ GHE_RESTORE_HOST config variable is set in backup.config. -#/ When a argument is provided, it always overrides -#/ the configured restore host. +#/ -c | --config Restore appliance settings and license in addition to +#/ datastores. Settings are not restored by default to +#/ prevent overwriting different configuration on the +#/ restore host. +#/ -f | --force Don't prompt for confirmation before restoring. +#/ -h | --help Show this message. +#/ -v | --verbose Enable verbose output. +#/ --skip-mysql Skip MySQL restore steps. Only applicable to external databases. +#/ --version Display version information and exit. +#/ +#/ -s Restore from the snapshot with the given id. Available +#/ snapshots may be listed under the data directory. +#/ +#/ The is the hostname or IP of the GitHub Enterprise +#/ instance. The may be omitted when the +#/ GHE_RESTORE_HOST config variable is set in backup.config. +#/ When a argument is provided, it always overrides +#/ the configured restore host. #/ set -e From f04232356f21efcdc2f037543049e04893df3700 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 11:06:58 -0700 Subject: [PATCH 1142/2421] Rename ghe-restore-external-database-check --- bin/ghe-restore | 5 ++--- ...eck => ghe-restore-external-database-compatibility-check} | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) rename share/github-backup-utils/{ghe-restore-external-database-check => ghe-restore-external-database-compatibility-check} (97%) diff --git a/bin/ghe-restore b/bin/ghe-restore index 51f0731c5..87bee8011 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -151,9 +151,8 @@ if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then exit 1 fi -# Ensure target appliance and restore snapshot are a compatible combination -# with respect to BYODB -if ! ghe-restore-external-database-check; then +# Ensure target appliance and restore snapshot are a compatible combination with respect to BYODB +if ! ghe-restore-external-database-compatibility-check; then exit 1 fi diff --git a/share/github-backup-utils/ghe-restore-external-database-check b/share/github-backup-utils/ghe-restore-external-database-compatibility-check similarity index 97% rename from share/github-backup-utils/ghe-restore-external-database-check rename to share/github-backup-utils/ghe-restore-external-database-compatibility-check index 2e4b30e74..9a22e63a0 100755 --- a/share/github-backup-utils/ghe-restore-external-database-check +++ b/share/github-backup-utils/ghe-restore-external-database-compatibility-check @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Usage: ghe-restore-external-database-check +# Usage: ghe-restore-external-database-compatibility-check # GitHub Enterprise checks for external-database related restores. # Bring in the backup configuration From 4c7fffd269801829a2630da9b5ce9d21657d8b47 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 11:13:46 -0700 Subject: [PATCH 1143/2421] Update usage.md --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 36b3e2a68..150770fa3 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -16,7 +16,7 @@ You can supply your own configuration file or use the example configuration file An example configuration file with documentation on possible settings can found in [backup.config-example](../backup.config-example). -There are a number of command line options that can also be passed to the `ghe-restore` command. Of particular note, if you use an external MySQL service but are restoring from a snapshot prior to enabling this, you must pass `--skip-mysql` to `ghe-restore`. +There are a number of command line options that can also be passed to the `ghe-restore` command. Of particular note, if you use an external MySQL service but are restoring from a snapshot prior to enabling this, or vice versa, you must migrate the MySQL data outside of the context of backup-utils first, then pass the `--skip-mysql` flag to `ghe-restore`. ## Example backup and restore usage From b4f618934013d333c1832d6c57bd65a022460655 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 11:30:28 -0700 Subject: [PATCH 1144/2421] Update ghe-restore -c tests to look for correct output --- test/test-ghe-restore-external-database.sh | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index cd67bc26e..c47892189 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -27,7 +27,7 @@ function setup(){ begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." ( - set -e + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true @@ -55,9 +55,9 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in ) end_test -begin_test "ghe-restore prevents restore of external DB snapshot to non-external DB appliance" +begin_test "ghe-restore -c from external DB snapshot to non-external DB appliance is not allowed" ( - set -e + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true @@ -65,10 +65,10 @@ begin_test "ghe-restore prevents restore of external DB snapshot to non-external # Disable external database on remote host git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - if ! GHE_DEBUG=1 ghe-restore -v -f 2> "$TRASHDIR/restore-out"; then + if ! GHE_DEBUG=1 ghe-restore -v -f -c 2> "$TRASHDIR/restore-out"; then # Verify that the restore failed due to snapshot compatability. - grep -q "Snapshot from GitHub Enterprise with an external database configured cannot be restored to an appliance without external database configured" "$TRASHDIR/restore-out" - + grep -q "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." "$TRASHDIR/restore-out" + exit 0 else # for debugging @@ -79,9 +79,9 @@ begin_test "ghe-restore prevents restore of external DB snapshot to non-external ) end_test -begin_test "ghe-restore prevents restore of non external DB snapshot to external DB appliance" +begin_test "ghe-restore -c from non external DB snapshot to external DB appliance is not allowed" ( - set -e + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false @@ -92,9 +92,8 @@ begin_test "ghe-restore prevents restore of non external DB snapshot to external # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then # Verify that the restore failed due to snapshot compatability. - grep -q "Snapshot from GitHub Enterprise with internal database cannot be restored - to an appliance with an external database configured." "$TRASHDIR/restore-out" - + grep -q "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." "$TRASHDIR/restore-out" + exit 0 else # for debugging From e85bd9c6c49f1127ea271f8ef829feeab2e3399b Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 11:38:33 -0700 Subject: [PATCH 1145/2421] Fix whitespace --- test/test-ghe-restore-external-database.sh | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index c47892189..210b7016f 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -106,7 +106,7 @@ end_test begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" ( - set -e + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true @@ -139,9 +139,7 @@ end_test begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" ( - set -e - - + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false @@ -174,8 +172,7 @@ end_test begin_test "ghe-restore allows restore of non external DB snapshot with -c" ( - set -e - + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false @@ -205,7 +202,7 @@ end_test begin_test "ghe-restore allows restore of external DB snapshot with -c" ( - set -e + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true @@ -237,7 +234,7 @@ end_test begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-server role" ( - set -e + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false @@ -254,7 +251,7 @@ begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a clu # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then grep -q "Error: Target environment does not have any nodes with the mysql-server role." "$TRASHDIR/restore-out" - + exit 0 else # for debugging @@ -267,7 +264,7 @@ end_test begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-master" ( - set -e + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false @@ -285,7 +282,7 @@ begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a clu # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out"; then grep -q "Error: Target environment does not have mysql-master configured." "$TRASHDIR/restore-out" - + exit 0 else # for debugging @@ -298,7 +295,7 @@ end_test begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluster configured with mysql-server role" ( - set -e + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false @@ -335,7 +332,7 @@ end_test begin_test "ghe-restore prevents restore of external DB snapshot with -c to a cluster configured with mysql-server" ( - set -e + set -e setup git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true @@ -363,4 +360,4 @@ begin_test "ghe-restore prevents restore of external DB snapshot with -c to a cl false fi ) -end_test \ No newline at end of file +end_test From ff0d06929f54fb088d40a2dfda2157e56efc4bbb Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 11:41:41 -0700 Subject: [PATCH 1146/2421] Add comment about is_service_external --- share/github-backup-utils/ghe-backup-config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index a1d01e53b..49236f7a7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -392,8 +392,9 @@ is_binary_backup(){ test -f "$1/mysql-binary-backup-sentinel" } -# Check if a given service is managed externally +# Check if a given service is managed externally on the appliance or in a snapshot. # Usage: is_service_external $service [$config_file] +# Pass in the config file to check if the service is managed externally in the snapshot. is_service_external(){ service=$1 config_file=$2 @@ -446,5 +447,5 @@ is_external_database_target(){ } is_external_database_snapshot(){ - is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" + is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } From d288656e485fa8e369215acf8498ed7a6e0a6967 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 11:50:10 -0700 Subject: [PATCH 1147/2421] Delete outdated tests --- test/test-ghe-restore-external-database.sh | 190 --------------------- 1 file changed, 190 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 210b7016f..35f992d9b 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -170,194 +170,4 @@ begin_test "ghe-restore allows restore of non external DB snapshot with --skip-m ) end_test -begin_test "ghe-restore allows restore of non external DB snapshot with -c" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Restoring MySQL database from logical backup snapshot on an appliance configured for logical backups ..." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore allows restore of external DB snapshot with -c" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - - export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Restoring MySQL database from external backup snapshot on an appliance configured for external backups ..." "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-server role" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - echo "[cluster \"fake-uuid\"] - hostname = fake-uuid - git-server = true - web-server = true - " > $GHE_REMOTE_CLUSTER_CONF_FILE - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - grep -q "Error: Target environment does not have any nodes with the mysql-server role." "$TRASHDIR/restore-out" - - exit 0 - else - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi -) -end_test - -begin_test "ghe-restore prevents restore of interal DB snapshot with -c to a cluster configured without mysql-master" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - echo "[cluster \"fake-uuid\"] - hostname = fake-uuid - git-server = true - web-server = true - mysql-server = true - " > $GHE_REMOTE_CLUSTER_CONF_FILE - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out"; then - grep -q "Error: Target environment does not have mysql-master configured." "$TRASHDIR/restore-out" - - exit 0 - else - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should not have exited successfully - false - fi -) -end_test - -begin_test "ghe-restore allow restore of interal DB snapshot with -c to a cluster configured with mysql-server role" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true - - echo "[cluster] - mysql-master = fake-uuid - [cluster \"fake-uuid\"] - hostname = fake-uuid - git-server = true - web-server = true - mysql-server = true - " > $GHE_REMOTE_CLUSTER_CONF_FILE - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - - verify_all_restored_data -) -end_test - -begin_test "ghe-restore prevents restore of external DB snapshot with -c to a cluster configured with mysql-server" -( - set -e - setup - - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false - - echo "[cluster \"fake-uuid\"] - hostname = fake-uuid - git-server = true - web-server = true - mysql-server = true - " > $GHE_REMOTE_CLUSTER_CONF_FILE - - export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" - - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out"; then - grep -q "Error: Target environment has nodes with the mysql-server role." "$TRASHDIR/restore-out" - exit 0 - else - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should not have exited successfully - false - fi -) -end_test From 8cb6516d8b146dacb4b17d51f5a4543c57b2c745 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 11:58:28 -0700 Subject: [PATCH 1148/2421] Add tests validating error message when omitting --skip-mysql --- test/test-ghe-restore-external-database.sh | 54 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 35f992d9b..81aeb6b2a 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -68,6 +68,7 @@ begin_test "ghe-restore -c from external DB snapshot to non-external DB applianc if ! GHE_DEBUG=1 ghe-restore -v -f -c 2> "$TRASHDIR/restore-out"; then # Verify that the restore failed due to snapshot compatability. grep -q "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." "$TRASHDIR/restore-out" + grep -q "Please reconfigure the appliance first, then run ghe-restore again." "$TRASHDIR/restore-out" exit 0 else @@ -93,6 +94,7 @@ begin_test "ghe-restore -c from non external DB snapshot to external DB applianc if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then # Verify that the restore failed due to snapshot compatability. grep -q "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." "$TRASHDIR/restore-out" + grep -q "Please reconfigure the appliance first, then run ghe-restore again." "$TRASHDIR/restore-out" exit 0 else @@ -104,7 +106,53 @@ begin_test "ghe-restore -c from non external DB snapshot to external DB applianc ) end_test -begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql" +begin_test "ghe-restore from external DB snapshot to non external DB appliance without --skip-mysql is not allowed" + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # Verify that the restore failed due to snapshot compatability. + grep -q "Restoring a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." "$TRASHDIR/restore-out" + grep -q "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + + exit 1 + fi + +end_test + +begin_test "ghe-restore from non external DB snapshot to external DB appliance without --skip-mysql is not allowed" + set -e + setup + + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + # Verify that the restore failed due to snapshot compatability. + grep -q "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." "$TRASHDIR/restore-out" + grep -q "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." "$TRASHDIR/restore-out" + + exit 0 + else + # for debugging + cat "$TRASHDIR/restore-out" + + exit 1 + fi + +end_test + +begin_test "ghe-restore allows restore of external DB snapshot to non-external DB appliance with --skip-mysql" ( set -e setup @@ -137,7 +185,7 @@ begin_test "ghe-restore allows restore of external DB snapshot with --skip-mysql ) end_test -begin_test "ghe-restore allows restore of non external DB snapshot with --skip-mysql" +begin_test "ghe-restore allows restore of non external DB snapshot to external DB appliance with --skip-mysql" ( set -e setup @@ -169,5 +217,3 @@ begin_test "ghe-restore allows restore of non external DB snapshot with --skip-m verify_all_restored_data ) end_test - - From 217ffaf625a7f53708b68345c6f1cef8e9c3f353 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 12:05:17 -0700 Subject: [PATCH 1149/2421] Add test helper methods for setting BYODB state of backup snapshot and appliance --- test/test-ghe-restore-external-database.sh | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 81aeb6b2a..d804bacf8 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -25,15 +25,23 @@ function setup(){ rm -rf "$GHE_DATA_DIR/current/settings.json" } +# Helper function to set BYODB state of backup snapshot +function set_external_database_enabled_state_of_backup_snapshot(){ + git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled "$1" +} + +# Helper function to set BYODB state of remote host +function set_external_database_enabled_state_of_appliance(){ + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled "$1" +} + begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." ( set -e setup - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Enable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + set_external_database_enabled_state_of_backup_snapshot true + set_external_database_enabled_state_of_appliance true export EXTERNAL_DATABASE_RESTORE_SCRIPT="echo 'fake ghe-export-mysql data'" @@ -60,10 +68,8 @@ begin_test "ghe-restore -c from external DB snapshot to non-external DB applianc set -e setup - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + set_external_database_enabled_state_of_backup_snapshot true + set_external_database_enabled_state_of_appliance false if ! GHE_DEBUG=1 ghe-restore -v -f -c 2> "$TRASHDIR/restore-out"; then # Verify that the restore failed due to snapshot compatability. @@ -85,10 +91,8 @@ begin_test "ghe-restore -c from non external DB snapshot to external DB applianc set -e setup - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + set_external_database_enabled_state_of_backup_snapshot false + set_external_database_enabled_state_of_appliance true # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then @@ -110,8 +114,8 @@ begin_test "ghe-restore from external DB snapshot to non external DB appliance w set -e setup - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + set_external_database_enabled_state_of_backup_snapshot true + set_external_database_enabled_state_of_appliance false # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then @@ -133,8 +137,8 @@ begin_test "ghe-restore from non external DB snapshot to external DB appliance w set -e setup - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + set_external_database_enabled_state_of_backup_snapshot false + set_external_database_enabled_state_of_appliance true # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then @@ -157,10 +161,8 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D set -e setup - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled true - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled false + set_external_database_enabled_state_of_backup_snapshot true + set_external_database_enabled_state_of_appliance false SKIP_MYSQL=true export SKIP_MYSQL @@ -190,10 +192,8 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D set -e setup - git config -f "$GHE_DATA_DIR/current/settings.json" mysql.external.enabled false - - # Disable external database on remote host - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled true + set_external_database_enabled_state_of_backup_snapshot false + set_external_database_enabled_state_of_appliance true SKIP_MYSQL=true export SKIP_MYSQL From eef42d99e430a69eedf3216da07c53a1e134bdb0 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 12:14:22 -0700 Subject: [PATCH 1150/2421] Add wrapper for outputting debug logs and failing test --- test/test-ghe-restore-external-database.sh | 44 +++++++--------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index d804bacf8..d6c90b106 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -35,6 +35,11 @@ function set_external_database_enabled_state_of_appliance(){ git config -f "$GHE_REMOTE_DATA_USER_DIR/common/github.conf" mysql.external.enabled "$1" } +function output_debug_logs_and_fail_test() { + cat "$TRASHDIR/restore-out" + exit 1 +} + begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." ( set -e @@ -47,10 +52,7 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false + output_debug_logs_and_fail_test fi # verify connect to right host @@ -72,16 +74,13 @@ begin_test "ghe-restore -c from external DB snapshot to non-external DB applianc set_external_database_enabled_state_of_appliance false if ! GHE_DEBUG=1 ghe-restore -v -f -c 2> "$TRASHDIR/restore-out"; then - # Verify that the restore failed due to snapshot compatability. + # Verify that the restore failed due to snapshot incompatibility. grep -q "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." "$TRASHDIR/restore-out" grep -q "Please reconfigure the appliance first, then run ghe-restore again." "$TRASHDIR/restore-out" exit 0 else - # for debugging - cat "$TRASHDIR/restore-out" - - exit 1 + output_debug_logs_and_fail_test fi ) end_test @@ -95,17 +94,14 @@ begin_test "ghe-restore -c from non external DB snapshot to external DB applianc set_external_database_enabled_state_of_appliance true # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then # Verify that the restore failed due to snapshot compatability. grep -q "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." "$TRASHDIR/restore-out" grep -q "Please reconfigure the appliance first, then run ghe-restore again." "$TRASHDIR/restore-out" exit 0 else - # for debugging - cat "$TRASHDIR/restore-out" - - exit 1 + output_debug_logs_and_fail_test fi ) end_test @@ -125,10 +121,7 @@ begin_test "ghe-restore from external DB snapshot to non external DB appliance w exit 0 else - # for debugging - cat "$TRASHDIR/restore-out" - - exit 1 + output_debug_logs_and_fail_test fi end_test @@ -148,10 +141,7 @@ begin_test "ghe-restore from non external DB snapshot to external DB appliance w exit 0 else - # for debugging - cat "$TRASHDIR/restore-out" - - exit 1 + output_debug_logs_and_fail_test fi end_test @@ -169,10 +159,7 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false + output_debug_logs_and_fail_test fi grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" @@ -200,10 +187,7 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then - # for debugging - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false + output_debug_logs_and_fail_test fi grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" From cf02425a6ffc35887bca7f7df52226187dbc0e33 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 12:25:56 -0700 Subject: [PATCH 1151/2421] Add helper for checking restore output --- test/test-ghe-restore-external-database.sh | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index d6c90b106..bb5efd86c 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -40,6 +40,10 @@ function output_debug_logs_and_fail_test() { exit 1 } +function check_restore_output_for() { + grep -q "$1" "$TRASHDIR/restore-out" +} + begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." ( set -e @@ -56,10 +60,10 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in fi # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + check_restore_output_for "Connect 127.0.0.1:22 OK" # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + check_restore_output_for "ghe-cluster-cleanup-node OK" verify_all_restored_data ) @@ -75,8 +79,8 @@ begin_test "ghe-restore -c from external DB snapshot to non-external DB applianc if ! GHE_DEBUG=1 ghe-restore -v -f -c 2> "$TRASHDIR/restore-out"; then # Verify that the restore failed due to snapshot incompatibility. - grep -q "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." "$TRASHDIR/restore-out" - grep -q "Please reconfigure the appliance first, then run ghe-restore again." "$TRASHDIR/restore-out" + check_restore_output_for "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." + check_restore_output_for "Please reconfigure the appliance first, then run ghe-restore again." exit 0 else @@ -96,8 +100,8 @@ begin_test "ghe-restore -c from non external DB snapshot to external DB applianc # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then # Verify that the restore failed due to snapshot compatability. - grep -q "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." "$TRASHDIR/restore-out" - grep -q "Please reconfigure the appliance first, then run ghe-restore again." "$TRASHDIR/restore-out" + check_restore_output_for "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." + check_restore_output_for "Please reconfigure the appliance first, then run ghe-restore again." exit 0 else @@ -116,8 +120,8 @@ begin_test "ghe-restore from external DB snapshot to non external DB appliance w # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then # Verify that the restore failed due to snapshot compatability. - grep -q "Restoring a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." "$TRASHDIR/restore-out" - grep -q "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." "$TRASHDIR/restore-out" + check_restore_output_for "Restoring a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." + check_restore_output_for "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." exit 0 else @@ -136,8 +140,8 @@ begin_test "ghe-restore from non external DB snapshot to external DB appliance w # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then # Verify that the restore failed due to snapshot compatability. - grep -q "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." "$TRASHDIR/restore-out" - grep -q "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." "$TRASHDIR/restore-out" + check_restore_output_for "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." + check_restore_output_for "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." exit 0 else @@ -162,13 +166,13 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D output_debug_logs_and_fail_test fi - grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" + check_restore_output_for "Skipping MySQL restore." # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + check_restore_output_for "Connect 127.0.0.1:22 OK" # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + check_restore_output_for "ghe-cluster-cleanup-node OK" verify_all_restored_data ) @@ -190,13 +194,13 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D output_debug_logs_and_fail_test fi - grep -q "Skipping MySQL restore." "$TRASHDIR/restore-out" + check_restore_output_for "Skipping MySQL restore." # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + check_restore_output_for "Connect 127.0.0.1:22 OK" # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + check_restore_output_for "ghe-cluster-cleanup-node OK" verify_all_restored_data ) From 1a3d078647b4644ae3af15183bdffdf33c322f6c Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 13:29:34 -0700 Subject: [PATCH 1152/2421] Remove extraneous exit 0s --- test/test-ghe-restore-external-database.sh | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index bb5efd86c..81828a2cb 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -44,7 +44,7 @@ function check_restore_output_for() { grep -q "$1" "$TRASHDIR/restore-out" } -begin_test "ghe-restore allows restore of external DB snapshot to external DB instance." +begin_test "ghe-restore allows restore of external DB snapshot to external DB instance" ( set -e setup @@ -81,8 +81,6 @@ begin_test "ghe-restore -c from external DB snapshot to non-external DB applianc # Verify that the restore failed due to snapshot incompatibility. check_restore_output_for "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." check_restore_output_for "Please reconfigure the appliance first, then run ghe-restore again." - - exit 0 else output_debug_logs_and_fail_test fi @@ -102,8 +100,6 @@ begin_test "ghe-restore -c from non external DB snapshot to external DB applianc # Verify that the restore failed due to snapshot compatability. check_restore_output_for "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." check_restore_output_for "Please reconfigure the appliance first, then run ghe-restore again." - - exit 0 else output_debug_logs_and_fail_test fi @@ -122,8 +118,6 @@ begin_test "ghe-restore from external DB snapshot to non external DB appliance w # Verify that the restore failed due to snapshot compatability. check_restore_output_for "Restoring a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." check_restore_output_for "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." - - exit 0 else output_debug_logs_and_fail_test fi @@ -142,8 +136,6 @@ begin_test "ghe-restore from non external DB snapshot to external DB appliance w # Verify that the restore failed due to snapshot compatability. check_restore_output_for "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." check_restore_output_for "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." - - exit 0 else output_debug_logs_and_fail_test fi From a8f49a141e16ba108789427a4f6d893eb25b3347 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 13:35:03 -0700 Subject: [PATCH 1153/2421] Fix output redirection --- test/test-ghe-restore-external-database.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 81828a2cb..3bc91b11a 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -77,7 +77,7 @@ begin_test "ghe-restore -c from external DB snapshot to non-external DB applianc set_external_database_enabled_state_of_backup_snapshot true set_external_database_enabled_state_of_appliance false - if ! GHE_DEBUG=1 ghe-restore -v -f -c 2> "$TRASHDIR/restore-out"; then + if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then # Verify that the restore failed due to snapshot incompatibility. check_restore_output_for "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." check_restore_output_for "Please reconfigure the appliance first, then run ghe-restore again." @@ -97,7 +97,7 @@ begin_test "ghe-restore -c from non external DB snapshot to external DB applianc # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - # Verify that the restore failed due to snapshot compatability. + # Verify that the restore failed due to snapshot incompatibility. check_restore_output_for "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." check_restore_output_for "Please reconfigure the appliance first, then run ghe-restore again." else @@ -115,7 +115,6 @@ begin_test "ghe-restore from external DB snapshot to non external DB appliance w # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - # Verify that the restore failed due to snapshot compatability. check_restore_output_for "Restoring a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." check_restore_output_for "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." else @@ -133,7 +132,6 @@ begin_test "ghe-restore from non external DB snapshot to external DB appliance w # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - # Verify that the restore failed due to snapshot compatability. check_restore_output_for "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." check_restore_output_for "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." else From fb7586184685883a2879121d97699b83d4154f1c Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 14:28:52 -0700 Subject: [PATCH 1154/2421] Test removing explicit SKIP_MYSQL=true statements --- test/test-ghe-restore-external-database.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 3bc91b11a..a41e3a3e4 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -148,9 +148,6 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D set_external_database_enabled_state_of_backup_snapshot true set_external_database_enabled_state_of_appliance false - SKIP_MYSQL=true - export SKIP_MYSQL - # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then output_debug_logs_and_fail_test @@ -176,9 +173,6 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D set_external_database_enabled_state_of_backup_snapshot false set_external_database_enabled_state_of_appliance true - SKIP_MYSQL=true - export SKIP_MYSQL - # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then output_debug_logs_and_fail_test From 3ad09e80c688dec2c0aa166dec25ca47c07a7a75 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 14:41:57 -0700 Subject: [PATCH 1155/2421] Add back SKIP_MYSQL declarations --- test/test-ghe-restore-external-database.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index a41e3a3e4..3bc91b11a 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -148,6 +148,9 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D set_external_database_enabled_state_of_backup_snapshot true set_external_database_enabled_state_of_appliance false + SKIP_MYSQL=true + export SKIP_MYSQL + # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then output_debug_logs_and_fail_test @@ -173,6 +176,9 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D set_external_database_enabled_state_of_backup_snapshot false set_external_database_enabled_state_of_appliance true + SKIP_MYSQL=true + export SKIP_MYSQL + # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then output_debug_logs_and_fail_test From eb4c3b1e02fb0618ce8794ef3b504255b231f3bf Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 30 Jun 2020 15:17:29 -0700 Subject: [PATCH 1156/2421] Change -z test to directly evaluating SKIP_MYSQL variable value --- test/testlib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index 1ed9946db..672f42e63 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -300,7 +300,7 @@ setup_test_data () { if [ "$loc" != "$GHE_REMOTE_DATA_USER_DIR" ]; then # create a fake backups for each datastore - if [ -z "$SKIP_MYSQL" ]; then + if ! "$SKIP_MYSQL" ; then echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" fi echo "fake ghe-export-redis data" > "$loc/redis.rdb" @@ -365,7 +365,7 @@ verify_all_backedup_data() { [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] # check that mysql data was backed up - if [ -z "$SKIP_MYSQL" ]; then + if ! "$SKIP_MYSQL" ; then [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] fi @@ -410,7 +410,7 @@ verify_all_restored_data() { set -e # verify all import scripts were run - if [ -z "$SKIP_MYSQL" ]; then + if ! "$SKIP_MYSQL" ; then grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" fi grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" From 96539048a8c51f6b28f8f3afa7188d432376c155 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 1 Jul 2020 11:58:53 -0700 Subject: [PATCH 1157/2421] Comment indicating why we have to manually set SKIP_MYSQL=true --- test/test-ghe-restore-external-database.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 3bc91b11a..c33106c2a 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -148,9 +148,6 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D set_external_database_enabled_state_of_backup_snapshot true set_external_database_enabled_state_of_appliance false - SKIP_MYSQL=true - export SKIP_MYSQL - # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then output_debug_logs_and_fail_test @@ -164,7 +161,8 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D # verify stale servers were cleared check_restore_output_for "ghe-cluster-cleanup-node OK" - verify_all_restored_data + # ghe-restore sets this when --skip-mysql is passed, but that won't propagate back to this shell and it affects what we validate + SKIP_MYSQL=true verify_all_restored_data ) end_test @@ -176,9 +174,6 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D set_external_database_enabled_state_of_backup_snapshot false set_external_database_enabled_state_of_appliance true - SKIP_MYSQL=true - export SKIP_MYSQL - # run ghe-restore and write output to file for asserting against if ! GHE_DEBUG=1 ghe-restore -v -f --skip-mysql > "$TRASHDIR/restore-out" 2>&1; then output_debug_logs_and_fail_test @@ -192,6 +187,7 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D # verify stale servers were cleared check_restore_output_for "ghe-cluster-cleanup-node OK" - verify_all_restored_data + # ghe-restore sets SKIP_MYSQL=true when --skip-mysql is passed, but that won't propagate back to this shell and it affects what we validate + SKIP_MYSQL=true verify_all_restored_data ) end_test From b276b352443da8b9390843f80f86e6899c46d050 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Wed, 1 Jul 2020 13:47:34 -0700 Subject: [PATCH 1158/2421] Remove quotes --- test/testlib.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index 672f42e63..11508c2f1 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -300,7 +300,7 @@ setup_test_data () { if [ "$loc" != "$GHE_REMOTE_DATA_USER_DIR" ]; then # create a fake backups for each datastore - if ! "$SKIP_MYSQL" ; then + if ! $SKIP_MYSQL; then echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" fi echo "fake ghe-export-redis data" > "$loc/redis.rdb" @@ -365,7 +365,7 @@ verify_all_backedup_data() { [ "$(cat "$GHE_DATA_DIR/current/settings.json")" = "fake ghe-export-settings data" ] # check that mysql data was backed up - if ! "$SKIP_MYSQL" ; then + if ! $SKIP_MYSQL; then [ "$(gzip -dc < "$GHE_DATA_DIR/current/mysql.sql.gz")" = "fake ghe-export-mysql data" ] fi @@ -410,7 +410,7 @@ verify_all_restored_data() { set -e # verify all import scripts were run - if ! "$SKIP_MYSQL" ; then + if ! $SKIP_MYSQL; then grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" fi grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" From 48efd36cbc9f17db56b408cb3cde8fb4e0e2adf6 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Thu, 2 Jul 2020 16:58:09 +0000 Subject: [PATCH 1159/2421] Adds support for backing up Actions files --- bin/ghe-backup | 3 + bin/ghe-restore | 3 + share/github-backup-utils/ghe-backup-actions | 84 +++++++++++++++++++ share/github-backup-utils/ghe-restore-actions | 73 ++++++++++++++++ test/test-ghe-backup.sh | 12 +++ test/test-ghe-restore.sh | 17 ++++ test/testlib.sh | 7 ++ 7 files changed, 199 insertions(+) create mode 100755 share/github-backup-utils/ghe-backup-actions create mode 100755 share/github-backup-utils/ghe-restore-actions diff --git a/bin/ghe-backup b/bin/ghe-backup index 30a6a7e6a..a2ae380e1 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -185,6 +185,9 @@ ghe-backup-mysql || failures="$failures mysql" if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Backing up MSSQL databases ..." ghe-backup-mssql 1>&3 || failures="$failures mssql" + + echo "Backing up Actions files ..." + ghe-backup-actions 1>&3 || failures="$failures actions" fi commands=(" diff --git a/bin/ghe-restore b/bin/ghe-restore index 377fd6640..23e33153f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -278,6 +278,9 @@ ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Restoring MSSQL database ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 + + echo "Restoring Actions files ..." + ghe-restore-actions "$GHE_HOSTNAME" 1>&3 fi commands=(" diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions new file mode 100755 index 000000000..b08bc6bed --- /dev/null +++ b/share/github-backup-utils/ghe-backup-actions @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-actions +#/ Take an online, incremental snapshot of all Actions data (excluding +#/ what is stored in MSSQL) +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-backup. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +bm_start "$(basename $0)" + +# Set up remote host and root backup snapshot directory based on config +host="$GHE_HOSTNAME" +backup_dir="$GHE_SNAPSHOT_DIR/actions" + +# Verify rsync is available. +if ! rsync --version 1>/dev/null 2>&1; then + echo "Error: rsync not found." 1>&2 + exit 1 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$host" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +hostnames=$host +ssh_config_file_opt= +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +opts="$GHE_EXTRA_SSH_OPTS" + +# Get hostnames running Actions services under cluster +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames="$(ghe-cluster-nodes "$GHE_HOSTNAME" "web-server") $(ghe-cluster-nodes "$GHE_HOSTNAME" "job-server")" + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi + +# Make sure root backup dir exists if this is the first run +mkdir -p "$backup_dir" + +# Removes the remote sync-in-progress file on exit, re-enabling GC operations +# on the remote instance. +cleanup() { + rm -rf $tempdir +} +trap 'cleanup' EXIT INT + +# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's +# --link-dest support. This also decreases physical space usage considerably. +if [ -d "$GHE_DATA_DIR/current/actions" ] && [ "$(ls -A $GHE_DATA_DIR/current/actions)" ]; then + link_dest="--link-dest=../../current/actions" +fi + +for hostname in $hostnames; do + bm_start "$(basename $0) - $hostname" + echo 1>&3 + ghe_verbose "* Starting backup for host: $hostname" + echo 1>&3 + ghe_verbose "* Transferring actions files ..." + + # Transfer all data from the user data directory using rsync. + ghe-rsync -avz \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ + --rsync-path='sudo -u actions rsync' \ + $link_dest \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/actions/" \ + "$GHE_SNAPSHOT_DIR/actions" 1>&3 + bm_end "$(basename $0) - $hostname" +done + +bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions new file mode 100755 index 000000000..3554cf0db --- /dev/null +++ b/share/github-backup-utils/ghe-restore-actions @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-actions +#/ Restore additional Actions files from an rsync snapshot. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# No need to restore anything, early exit +if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions" ]; then + echo "Warning: Actions backup missing. Skipping ..." + exit 0 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# Split host:port into parts +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Add user / -l option +user="${host%@*}" +[ "$user" = "$host" ] && user="admin" + +hostnames=$host +ssh_config_file_opt= +tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) +opts="$GHE_EXTRA_SSH_OPTS" + +if $CLUSTER; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + hostnames="$(ghe-cluster-nodes "$GHE_HOSTNAME" "web-server") $(ghe-cluster-nodes "$GHE_HOSTNAME" "job-server")" + ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" +fi + +cleanup() { + rm -rf $tempdir +} +trap 'cleanup' EXIT + +for hostname in $hostnames; do + bm_start "$(basename $0) - $hostname" + echo 1>&3 + ghe_verbose "* Transferring actions files to $hostname ..." + + ghe-rsync -arvHR --delete \ + -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ + --rsync-path='sudo -u actions rsync' \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions/./" \ + "$hostname:$GHE_REMOTE_DATA_USER_DIR/actions/" 1>&3 + bm_end "$(basename $0) - $hostname" +done + +bm_end "$(basename $0)" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 5fe99e0fe..9d0088cb5 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -401,6 +401,18 @@ begin_test "ghe-backup takes transaction backup upon expiration" ) end_test +begin_test "ghe-backup takes backup of Actions files" +( + set -e + enable_actions + + output=$(ghe-backup -v) + echo $output | grep "Transferring Actions files" + + diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" +) +end_test + # acceptance criteria is less then 2 seconds for 100,000 lines begin_test "ghe-backup fix_paths_for_ghe_version performance tests - gists" ( diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index bbfda1bef..bb409ca47 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -306,6 +306,23 @@ begin_test "ghe-restore invokes ghe-import-mssql" ) end_test +begin_test "ghe-restore with Actions files" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + setup_maintenance_mode "configured" + + output=$(ghe-restore -v -f localhost 2>&1) + + echo "$output" | grep -q "Transferring Actions files to" + + diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" +) +end_test + begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index df455550f..230c57c7c 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -321,7 +321,14 @@ setup_test_data () { echo "fake mssql diff data" > "$loc/mssql/backups/mssql.diff" echo "fake mssql tran data" > "$loc/mssql/backups/mssql.log" fi + + # Setup fake actions data + mkdir -p "$loc/actions/certificates" + mkdir -p "$loc/actions/states" + echo "fake actions certificate" > "$loc/actions/certificates/cert.cer" + echo "fake actions state file" > "$loc/actions/states/actions_state" } + # A unified method to check everything backed up or restored during testing. # Everything tested here should pass regardless of whether we're testing a backup From 2521ebc6db2f44acb235cbb989d09d9a9ffd30bf Mon Sep 17 00:00:00 2001 From: David Hadka Date: Thu, 2 Jul 2020 17:20:51 +0000 Subject: [PATCH 1160/2421] Fix tests --- share/github-backup-utils/ghe-backup-actions | 4 +--- share/github-backup-utils/ghe-restore-actions | 2 ++ test/test-ghe-backup.sh | 2 +- test/test-ghe-restore.sh | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index b08bc6bed..cc3ab9a87 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -67,9 +67,7 @@ fi for hostname in $hostnames; do bm_start "$(basename $0) - $hostname" echo 1>&3 - ghe_verbose "* Starting backup for host: $hostname" - echo 1>&3 - ghe_verbose "* Transferring actions files ..." + ghe_verbose "* Transferring actions files to $hostname ..." # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 3554cf0db..1bcc210dc 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -62,6 +62,8 @@ for hostname in $hostnames; do echo 1>&3 ghe_verbose "* Transferring actions files to $hostname ..." + echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions" | ghe-ssh $hostname /bin/bash + ghe-rsync -arvHR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path='sudo -u actions rsync' \ diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 9d0088cb5..cbb4669c5 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -407,7 +407,7 @@ begin_test "ghe-backup takes backup of Actions files" enable_actions output=$(ghe-backup -v) - echo $output | grep "Transferring Actions files" + echo $output | grep "Transferring actions files to" diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index bb409ca47..296e6f11e 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -317,7 +317,7 @@ begin_test "ghe-restore with Actions files" output=$(ghe-restore -v -f localhost 2>&1) - echo "$output" | grep -q "Transferring Actions files to" + echo "$output" | grep -q "Transferring actions files to" diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) From 6e4771539a4ed0c90cd7a4cf7a39d2be8b4b46d8 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Mon, 6 Jul 2020 22:03:35 +0000 Subject: [PATCH 1161/2421] Warn if database names changed --- share/github-backup-utils/ghe-backup-mssql | 39 ++++++++++++++++++++++ test/test-ghe-backup.sh | 24 ++++++------- test/testlib.sh | 8 ++--- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 608147109..f4579c581 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -53,6 +53,43 @@ find_timestamp() { echo $datetime_part } +ensure_same_dbs() { + all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) + + remotes=() + for db in $all_dbs; do + if [[ ! "$db" =~ ^(master|tempdb|model|msdb)$ ]] && [[ "$db" =~ ^[a-zA-Z0-9_-]+$ ]]; then + remotes+=("$db") + fi + done + + locals=() + while read -r file; do + filename=$(basename "$file") + locals+=("$filename") + done < <(find "$1" \( -name "*.bak" -o -name "*.diff" -o -name "*.log" \)) + + for remote in "${remotes[@]}"; do + remaining_locals=() + for local in "${locals[@]}"; do + if ! [[ "$local" == "$remote"* ]]; then + remaining_locals+=("$local") + fi + done + locals=("${remaining_locals[@]}") + done + + if [[ "${#locals[@]}" -ne 0 ]]; then + ghe_verbose "Warning: Found following ${#locals[@]} backup files that can't be traced back to the specified GHES host." + ghe_verbose "Warning: Did you recently reconfigure the GHES host? Consider deleting these backup files if no longer needed." + for local in "${locals[@]}"; do + ghe_verbose "$local" + done + + exit 1 + fi +} + last_mssql=$GHE_DATA_DIR/current/mssql if [ ! -d $last_mssql ] \ @@ -61,6 +98,8 @@ if [ ! -d $last_mssql ] \ take_full=1 backup_command='ghe-export-mssql' else + ensure_same_dbs "$last_mssql" + # Check schedule to determine backup type IFS=',' read -ra cadence <<< "$GHE_MSSQL_BACKUP_CADENCE" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 5fe99e0fe..f5c64dac6 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -352,11 +352,11 @@ begin_test "ghe-backup takes full backup on first run" set -e enable_actions - rm -rf $GHE_REMOTE_DATA_USER_DIR/mssql/backups/* - rm -rf $GHE_DATA_DIR/current/mssql/* + rm -rf "$GHE_REMOTE_DATA_USER_DIR"/mssql/backups/* + rm -rf "$GHE_DATA_DIR"/current/mssql/* output=$(ghe-backup -v) - echo $output | grep "Taking first full backup" - echo $output | grep "fake ghe-export-mssql data" + echo "$output" | grep "Taking first full backup" + echo "$output" | grep "fake ghe-export-mssql data" ) end_test @@ -368,8 +368,8 @@ begin_test "ghe-backup takes full backup upon expiration" setup_mssql_backup_file "full_mssql" 11 "bak" output=$(ghe-backup -v) - echo $output | grep "Taking full backup" - ! echo $output | grep "Creating hard link to full_mssql@" + echo "$output" | grep "Taking full backup" + ! echo "$output" | grep "Creating hard link to full_mssql@" ) end_test @@ -381,9 +381,9 @@ begin_test "ghe-backup takes diff backup upon expiration" setup_mssql_backup_file "full_mssql" 7 "bak" output=$(ghe-backup -v) - echo $output | grep "Taking diff backup" - echo $output | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" - ! echo $output | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" + echo "$output" | grep "Taking diff backup" + echo "$output" | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" + ! echo "$output" | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" ) end_test @@ -395,9 +395,9 @@ begin_test "ghe-backup takes transaction backup upon expiration" setup_mssql_backup_file "full_mssql" 3 "bak" output=$(ghe-backup -v) - echo $output | grep "Taking transaction backup" - echo $output | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" - echo $output | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" + echo "$output" | grep "Taking transaction backup" + echo "$output" | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" + echo "$output" | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index df455550f..365d89d11 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -457,10 +457,10 @@ subtract_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS if date -v -1d > /dev/null 2>&1; then - echo "$(date -v -$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S)" + date -v -"$2"M -ujf'%Y%m%dT%H%M%S' "$1" +%Y%m%dT%H%M%S else dt=$1 - echo "$(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes ago")" + date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes ago" fi } @@ -472,12 +472,12 @@ setup_mssql_backup_file() { mkdir -p "$GHE_DATA_DIR/current/mssql" current_utc=$(date -u +%Y%m%dT%H%M%S) - fake_last_utc=$(subtract_minute $current_utc $2) + fake_last_utc=$(subtract_minute "$current_utc" "$2") touch "$GHE_DATA_DIR/current/mssql/$1@$fake_last_utc.$3" # Simulate ghe-export-mssql behavior - if [ $3 = "bak" ] || [ $3 = "diff" ]; then + if [ "$3" = "bak" ] || [ "$3" = "diff" ]; then touch "$GHE_DATA_DIR/current/mssql/$1@$fake_last_utc.log" fi } From 84730c5f0f24108f730405ac9b3c060cd307d184 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Mon, 6 Jul 2020 16:22:33 -0700 Subject: [PATCH 1162/2421] Add confirmation prompt when restoring BYODB snapshot to unconfigured instance --- bin/ghe-restore | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 87bee8011..9e140fe9e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -192,6 +192,32 @@ if $instance_configured && ! $FORCE; then echo fi +# Prompt to verify that restoring BYODB snapshot to unconfigured instance +# will result in BYODB connection information being restored as well. +if ! $instance_configured && is_external_database_snapshot; then + echo + echo "WARNING: Restoring the snapshot ${GHE_RESTORE_SNAPSHOT} will also restore the external MySQL database connection information." + echo " If the appliance the snapshot was taken from is still online, this could result in two GHES appliances writing to the same MySQL database." + echo "Please verify that this is understood before continuing." + printf "Type 'yes' to continue: " + + while read -r response; do + case $response in + yes|Yes|YES) + break + ;; + '') + printf "Type 'yes' to continue: " + ;; + *) + echo "Restore aborted." 1>&2 + exit 1 + ;; + esac + done + echo +fi + # Log restore start message locally and in /var/log/syslog on remote instance echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." From 1e4e5f08f6cce9451412b172b193534da8a9d638 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Tue, 7 Jul 2020 03:31:28 +0000 Subject: [PATCH 1163/2421] Add test for mismatch check --- share/github-backup-utils/ghe-backup-mssql | 2 +- share/github-backup-utils/ghe-restore-mssql | 2 +- test/bin/ghe-mssql-console | 4 +++ test/test-ghe-backup.sh | 31 ++++++++++++++++++--- test/testlib.sh | 18 +++++++----- 5 files changed, 44 insertions(+), 13 deletions(-) create mode 100755 test/bin/ghe-mssql-console diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index f4579c581..d878f76b3 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -189,4 +189,4 @@ if [ -n "$backup_command" ]; then ghe_verbose "Transferring to backup host $b" ghe-ssh "$GHE_HOSTNAME" "sudo cat $appliance_dir/$b" > $backup_dir/$b done -fi \ No newline at end of file +fi diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 947a572af..dcf37fa37 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -57,4 +57,4 @@ ghe-ssh $GHE_HOSTNAME "sudo chown -R mssql:mssql $appliance_dir" # Invoke restore command bm_start "$(basename $0)" ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-mssql" < "/dev/null" 1>&3 -bm_end "$(basename $0)" \ No newline at end of file +bm_end "$(basename $0)" diff --git a/test/bin/ghe-mssql-console b/test/bin/ghe-mssql-console new file mode 100755 index 000000000..6f1145ddc --- /dev/null +++ b/test/bin/ghe-mssql-console @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +# Returns environment variable REMOTE_DBS, the variable should be set as space-delimited string +# Tests use this to emulate ghe-mssql-console from a remote GitHub Enterprise Server +echo $REMOTE_DBS diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index f5c64dac6..53e37cf67 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -364,6 +364,7 @@ begin_test "ghe-backup takes full backup upon expiration" ( set -e enable_actions + export REMOTE_DBS="full_mssql" setup_mssql_backup_file "full_mssql" 11 "bak" @@ -377,13 +378,14 @@ begin_test "ghe-backup takes diff backup upon expiration" ( set -e enable_actions + export REMOTE_DBS="full_mssql" setup_mssql_backup_file "full_mssql" 7 "bak" output=$(ghe-backup -v) echo "$output" | grep "Taking diff backup" - echo "$output" | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" - ! echo "$output" | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" + echo "$output" | grep -E "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" + ! echo "$output" | grep -E "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" ) end_test @@ -391,13 +393,34 @@ begin_test "ghe-backup takes transaction backup upon expiration" ( set -e enable_actions + export REMOTE_DBS="full_mssql" setup_mssql_backup_file "full_mssql" 3 "bak" output=$(ghe-backup -v) echo "$output" | grep "Taking transaction backup" - echo "$output" | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" - echo "$output" | egrep "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" + echo "$output" | grep -E "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.bak" + echo "$output" | grep -E "Creating hard link to full_mssql@[0-9]{8}T[0-9]{6}\.log" +) +end_test + +begin_test "ghe-backup warns if database names mismatched" +( + set -e + enable_actions + + rm -rf "$GHE_DATA_DIR/current/mssql" + mkdir -p "$GHE_DATA_DIR/current/mssql" + + export REMOTE_DBS="full_mssql_1 full_mssql_2 full_mssql_3" + + add_mssql_backup_file "full_mssql_1" 3 "bak" + add_mssql_backup_file "full_mssql_4" 3 "diff" + add_mssql_backup_file "full_mssql_5" 3 "log" + + output=$(ghe-backup -v || true) + ! echo "$output" | grep -E "Taking .* backup" + echo "$output" | grep "Warning: Found following 2 backup files" ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index aacf37355..9d30be0c3 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -471,16 +471,10 @@ subtract_minute() { } setup_mssql_backup_file() { - # $1 name: @... - # $2 minutes ago - # $3 extension: bak, diff, log rm -rf "$GHE_DATA_DIR/current/mssql" mkdir -p "$GHE_DATA_DIR/current/mssql" - current_utc=$(date -u +%Y%m%dT%H%M%S) - fake_last_utc=$(subtract_minute "$current_utc" "$2") - - touch "$GHE_DATA_DIR/current/mssql/$1@$fake_last_utc.$3" + add_mssql_backup_file "$@" # Simulate ghe-export-mssql behavior if [ "$3" = "bak" ] || [ "$3" = "diff" ]; then @@ -488,6 +482,16 @@ setup_mssql_backup_file() { fi } +add_mssql_backup_file() { + # $1 name: @... + # $2 minutes ago + # $3 extension: bak, diff, log + current_utc=$(date -u +%Y%m%dT%H%M%S) + fake_last_utc=$(subtract_minute "$current_utc" "$2") + + touch "$GHE_DATA_DIR/current/mssql/$1@$fake_last_utc.$3" +} + enable_actions() { ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config app.actions.enabled true' } From 2ac08f18600b5dcd9aaaa849c8aa4bead11a0b81 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 7 Jul 2020 08:20:29 -0700 Subject: [PATCH 1164/2421] Add BYODB-specific warning when restoring settings --- bin/ghe-restore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 9e140fe9e..925ab63f3 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -172,6 +172,14 @@ if $instance_configured && ! $FORCE; then echo echo "WARNING: All data on GitHub Enterprise appliance $hostname ($GHE_REMOTE_VERSION)" echo " will be overwritten with data from snapshot ${GHE_RESTORE_SNAPSHOT}." + + if is_external_database_snapshot && $RESTORE_SETTINGS; then + echo + echo " This operation will restore the external MySQL connection configuration," + echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." + echo + fi + echo "Please verify that this is the correct restore host before continuing." printf "Type 'yes' to continue: " From f82ee05600b5c03fb3b4f9b6c081e92845f42a6d Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 7 Jul 2020 09:14:19 -0700 Subject: [PATCH 1165/2421] Hide warning if --force passed --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 925ab63f3..141a13b18 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -202,7 +202,7 @@ fi # Prompt to verify that restoring BYODB snapshot to unconfigured instance # will result in BYODB connection information being restored as well. -if ! $instance_configured && is_external_database_snapshot; then +if ! $instance_configured && is_external_database_snapshot && ! $FORCE; then echo echo "WARNING: Restoring the snapshot ${GHE_RESTORE_SNAPSHOT} will also restore the external MySQL database connection information." echo " If the appliance the snapshot was taken from is still online, this could result in two GHES appliances writing to the same MySQL database." From ec53cbd838df6204aeb47c1baa82e194d88144fb Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 7 Jul 2020 09:34:07 -0700 Subject: [PATCH 1166/2421] Re-order conditionals --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 141a13b18..72eba1686 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -202,7 +202,7 @@ fi # Prompt to verify that restoring BYODB snapshot to unconfigured instance # will result in BYODB connection information being restored as well. -if ! $instance_configured && is_external_database_snapshot && ! $FORCE; then +if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then echo echo "WARNING: Restoring the snapshot ${GHE_RESTORE_SNAPSHOT} will also restore the external MySQL database connection information." echo " If the appliance the snapshot was taken from is still online, this could result in two GHES appliances writing to the same MySQL database." From 597e3ae6fce61de35395167c6729939a394d2939 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 7 Jul 2020 11:29:19 -0700 Subject: [PATCH 1167/2421] Add extra WARNING text --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 72eba1686..ad48dc328 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -175,7 +175,7 @@ if $instance_configured && ! $FORCE; then if is_external_database_snapshot && $RESTORE_SETTINGS; then echo - echo " This operation will restore the external MySQL connection configuration," + echo "WARNING: This operation will also restore the external MySQL connection configuration," echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." echo fi From 7d9d867acaa5e7881847926bfe82f343f7103b82 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 7 Jul 2020 11:32:33 -0700 Subject: [PATCH 1168/2421] Add extra empty line --- bin/ghe-restore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index ad48dc328..d788f3ae9 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -206,6 +206,7 @@ if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then echo echo "WARNING: Restoring the snapshot ${GHE_RESTORE_SNAPSHOT} will also restore the external MySQL database connection information." echo " If the appliance the snapshot was taken from is still online, this could result in two GHES appliances writing to the same MySQL database." + echo echo "Please verify that this is understood before continuing." printf "Type 'yes' to continue: " From dfbdec6663476a86149e6d1f26eecf75978db485 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 7 Jul 2020 11:34:13 -0700 Subject: [PATCH 1169/2421] Update wording to match other confirmation prompt --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d788f3ae9..489299525 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -204,10 +204,10 @@ fi # will result in BYODB connection information being restored as well. if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then echo - echo "WARNING: Restoring the snapshot ${GHE_RESTORE_SNAPSHOT} will also restore the external MySQL database connection information." - echo " If the appliance the snapshot was taken from is still online, this could result in two GHES appliances writing to the same MySQL database." + echo "WARNING: This operation will also restore the external MySQL connection configuration," + echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." echo - echo "Please verify that this is understood before continuing." + echo "Please confirm this before continuing." printf "Type 'yes' to continue: " while read -r response; do From f079f1cd267e98fae86397c2d4cc6970263cdf4b Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 7 Jul 2020 13:36:19 -0700 Subject: [PATCH 1170/2421] Pull prompt logic into its own function for reuse --- bin/ghe-restore | 37 ++------------------- share/github-backup-utils/ghe-backup-config | 22 ++++++++++++ 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 489299525..7a817b684 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -180,24 +180,7 @@ if $instance_configured && ! $FORCE; then echo fi - echo "Please verify that this is the correct restore host before continuing." - printf "Type 'yes' to continue: " - - while read -r response; do - case $response in - yes|Yes|YES) - break - ;; - '') - printf "Type 'yes' to continue: " - ;; - *) - echo "Restore aborted." 1>&2 - exit 1 - ;; - esac - done - echo + prompt_for_confirmation "Please verify that this is the correct restore host before continuing." fi # Prompt to verify that restoring BYODB snapshot to unconfigured instance @@ -207,24 +190,8 @@ if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then echo "WARNING: This operation will also restore the external MySQL connection configuration," echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." echo - echo "Please confirm this before continuing." - printf "Type 'yes' to continue: " - while read -r response; do - case $response in - yes|Yes|YES) - break - ;; - '') - printf "Type 'yes' to continue: " - ;; - *) - echo "Restore aborted." 1>&2 - exit 1 - ;; - esac - done - echo + prompt_for_confirmation "Please confirm this before continuing." fi # Log restore start message locally and in /var/log/syslog on remote instance diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 49236f7a7..5fc3cc7bd 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -449,3 +449,25 @@ is_external_database_target(){ is_external_database_snapshot(){ is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } + +prompt_for_confirmation(){ + echo "$1" + printf "Type 'yes' to continue: " + + while read -r response; do + case $response in + yes|Yes|YES) + break + ;; + '') + printf "Type 'yes' to continue: " + ;; + *) + echo "Restore aborted." 1>&2 + exit 1 + ;; + esac + done + + echo +} \ No newline at end of file From 9d9ffa17447323ceaf5fc3c0031d7da06b269bd3 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 7 Jul 2020 13:41:11 -0700 Subject: [PATCH 1171/2421] Add newline to end of file --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 5fc3cc7bd..5d14090f4 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -470,4 +470,4 @@ prompt_for_confirmation(){ done echo -} \ No newline at end of file +} From 7882d41bc844fd868b5ef135e2e9931484c334d3 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 7 Jul 2020 13:43:30 -0700 Subject: [PATCH 1172/2421] Move empty line to first warning so its shown even if second warning is not --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7a817b684..8d686802e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -172,9 +172,9 @@ if $instance_configured && ! $FORCE; then echo echo "WARNING: All data on GitHub Enterprise appliance $hostname ($GHE_REMOTE_VERSION)" echo " will be overwritten with data from snapshot ${GHE_RESTORE_SNAPSHOT}." + echo if is_external_database_snapshot && $RESTORE_SETTINGS; then - echo echo "WARNING: This operation will also restore the external MySQL connection configuration," echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." echo From 625b27d79db7d625e2c59f8e60a784e1b26ca6fc Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Jul 2020 14:11:11 +0000 Subject: [PATCH 1173/2421] Extract out binary and logical backup processes --- share/github-backup-utils/ghe-backup-mysql | 32 ++++++------------- .../ghe-backup-mysql-binary | 25 +++++++++++++++ .../ghe-backup-mysql-logical | 24 ++++++++++++++ 3 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 share/github-backup-utils/ghe-backup-mysql-binary create mode 100644 share/github-backup-utils/ghe-backup-mysql-logical diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 231b23d61..b654acded 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -1,8 +1,8 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup-mysql -#/ Backup MySQL from a GitHub instance. +#/ usage: ghe-backup-mysql +#/ backup mysql from a github instance. #/ -#/ Note: This script typically isn't called directly. It's invoked by the +#/ note: this script typically isn't called directly. it's invoked by the #/ ghe-backup command. set -e @@ -20,30 +20,18 @@ if is_external_database_target; then if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then $EXTERNAL_DATABASE_BACKUP_SCRIPT else - echo "Error: EXTERNAL_DATABASE_BACKUP_SCRIPT is not configured. Please configure in backup.config." - exit 1 + if is_binary_backup_feature_on + echo "Error: Binary backup is not supported with an external MySQL database. + Please provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" + exit 1 + fi fi - # Finsh the benchmark and exit early. If the script returns a non-zero - # exit code, it will be caught by`set -e` - bm_end "$(basename $0)" - exit 0 fi if is_binary_backup_feature_on; then - echo "Backing up MySQL database using binary backup strategy ..." + ghe-backup-mysql-binary else - echo "Backing up MySQL database using logical backup strategy ..." -fi - -export_command="ghe-export-mysql" -if ! is_binary_backup_feature_on; then - # binary backup is already compressed - export_command+=" | pigz" -fi -echo "set -o pipefail; $export_command" | -ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" -if is_binary_backup_feature_on; then - echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" + ghe-backup-mysql-logical fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary new file mode 100644 index 000000000..d6c9aa8ba --- /dev/null +++ b/share/github-backup-utils/ghe-backup-mysql-binary @@ -0,0 +1,25 @@ + +#!/usr/bin/env bash +#/ usage: ghe-backup-mysql-logical +#/ backup mysql from a github instance. +#/ +#/ note: this script typically isn't called directly. it's invoked by the +#/ ghe-backup command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +bm_start "$(basename $0)" + +# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. +ghe_remote_version_required "$GHE_HOSTNAME" + +echo "Backing up MySQL database using binary backup strategy ..." + +echo "set -o pipefail; ghe-export-mysql | pigz" | +ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" +echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" + +bm_end "$(basename $0)" \ No newline at end of file diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical new file mode 100644 index 000000000..37d45edce --- /dev/null +++ b/share/github-backup-utils/ghe-backup-mysql-logical @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +#/ usage: ghe-backup-mysql-logical +#/ backup mysql from a github instance. +#/ +#/ note: this script typically isn't called directly. it's invoked by the +#/ ghe-backup command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +bm_start "$(basename $0)" + +# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. +ghe_remote_version_required "$GHE_HOSTNAME" + +echo "Backing up MySQL database using logical backup strategy ..." + + +echo "set -o pipefail; ghe-export-mysql" | +ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" + +bm_end "$(basename $0)" \ No newline at end of file From 82b3516a87e61af8ee22cf2df9e494f6274be042 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Jul 2020 15:00:50 +0000 Subject: [PATCH 1174/2421] Split mysql restore scripts to binary and logical --- share/github-backup-utils/ghe-restore-mysql | 46 +----------- .../ghe-restore-mysql-binary | 73 +++++++++++++++++++ .../ghe-restore-mysql-logical | 52 +++++++++++++ 3 files changed, 128 insertions(+), 43 deletions(-) create mode 100644 share/github-backup-utils/ghe-restore-mysql-binary create mode 100644 share/github-backup-utils/ghe-restore-mysql-logical diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 6d8363a22..5c5f1b8a6 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -42,38 +42,12 @@ if is_external_database_snapshot; then exit 0 fi -ssh_config_file_opt= if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available if is_binary_backup "$snapshot_dir"; then - if $CLUSTER ; then - ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") - if [ -z $ghe_mysql_master ]; then - echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 - exit 2 - else - tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" - port=$(ssh_port_part "$GHE_HOSTNAME") - ghe_mysql_master=$ghe_mysql_master${port:+:$port} - fi - else - ghe_mysql_master=$GHE_HOSTNAME - fi - - # Check if the decompress needed by looking into the sentinel file - # In 2.19.5 we compress the binary backup twice - if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then - IMPORT_MYSQL=ghe-import-mysql-xtrabackup - GHE_RESTORE_HOST=$ghe_mysql_master - else - IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" - GHE_RESTORE_HOST=$ghe_mysql_master - fi + ghe-restore-mysql-binary else - IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" + ghe-restore-mysql-logical GHE_RESTORE_HOST=$GHE_HOSTNAME fi else @@ -83,23 +57,9 @@ else exit 2 else # legacy mode - IMPORT_MYSQL="unpigz | ghe-import-mysql" + ghe-restore-mysql-logical GHE_RESTORE_HOST=$GHE_HOSTNAME fi fi -cleanup() { - ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" -} -trap 'cleanup' INT TERM EXIT - -ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 - -# Transfer MySQL data from the snapshot to the GitHub instance. -cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" - -echo "Restore MySQL database ..." -# Import the database -echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 - bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-mysql-binary b/share/github-backup-utils/ghe-restore-mysql-binary new file mode 100644 index 000000000..d4812e2dd --- /dev/null +++ b/share/github-backup-utils/ghe-restore-mysql-binary @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-mysql-logical +#/ Restore MySQL backup to a GitHub instance. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when the rsync strategy is used. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} +export GHE_RESTORE_SNAPSHOT + +# The directory holding the snapshot to restore +snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + +if $CLUSTER ; then + ghe_mysql_master=$(ghe-ssh "$GHE_HOSTNAME" ghe-config "cluster.mysql-master") + if [ -z $ghe_mysql_master ]; then + echo "Something is wrong with configuration: cluster.mysql-master not found" >&2 + exit 2 + else + tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + ghe-ssh-config "$GHE_HOSTNAME" "$ghe_mysql_master" > "$ssh_config_file" + port=$(ssh_port_part "$GHE_HOSTNAME") + ghe_mysql_master=$ghe_mysql_master${port:+:$port} + fi +else + ghe_mysql_master=$GHE_HOSTNAME +fi + +# Check if the decompress needed by looking into the sentinel file +# In 2.19.5 we compress the binary backup twice +if [ "$(cat $snapshot_dir/mysql-binary-backup-sentinel)" = "NO_ADDITIONAL_COMPRESSION" ]; then + IMPORT_MYSQL=ghe-import-mysql-xtrabackup + GHE_RESTORE_HOST=$ghe_mysql_master +else + IMPORT_MYSQL="unpigz | ghe-import-mysql-xtrabackup" + GHE_RESTORE_HOST=$ghe_mysql_master +fi + +cleanup() { + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" +} +trap 'cleanup' INT TERM EXIT + +ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 + +# Transfer MySQL data from the snapshot to the GitHub instance. +cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" + +echo "Restore MySQL database ..." +# Import the database +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 + +bm_end "$(basename $0)" \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-mysql-logical b/share/github-backup-utils/ghe-restore-mysql-logical new file mode 100644 index 000000000..94b35505f --- /dev/null +++ b/share/github-backup-utils/ghe-restore-mysql-logical @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-mysql-logical +#/ Restore MySQL backup to a GitHub instance. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when the rsync strategy is used. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} +export GHE_RESTORE_SNAPSHOT + +# The directory holding the snapshot to restore +snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + +ssh_config_file_opt= + +# legacy mode +IMPORT_MYSQL="unpigz | ghe-import-mysql-mysqldump" +GHE_RESTORE_HOST=$GHE_HOSTNAME + +cleanup() { + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" +} +trap 'cleanup' INT TERM EXIT + +ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 + +# Transfer MySQL data from the snapshot to the GitHub instance. +cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" + +echo "Restore MySQL database ..." +# Import the database +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 + +bm_end "$(basename $0)" \ No newline at end of file From 8e62736032132d7aa6ddaa0f03e7dd20f17be217 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Jul 2020 15:04:49 +0000 Subject: [PATCH 1175/2421] External database support --- share/github-backup-utils/ghe-restore-mysql | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 5c5f1b8a6..61a3e5bea 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -33,13 +33,12 @@ if is_external_database_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT else - echo "Error: EXTERNAL_DATABASE_RESTORE_SCRIPT is not configured. Please configure in backup.config." - exit 1 + if is_binary_backup_feature_on || is_binary_backup "$snapshot_dir"; then + echo "Error: Restore of a binary backup to appliance with an external database configured is not supported. + Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" + exit 1 + fi fi - # Finsh the benchmark and exit early. If the script returns a non-zero - # exit code, it will be caught by`set -e` - bm_end "$(basename $0)" - exit 0 fi if is_binary_backup_feature_on; then From 4a353fcd3028d20327b93e4aa3c98b25a1b6c66b Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Jul 2020 15:18:25 +0000 Subject: [PATCH 1176/2421] Somehow all the capitals got lost :sadpanda: --- share/github-backup-utils/ghe-backup-mysql | 6 +++--- share/github-backup-utils/ghe-backup-mysql-binary | 7 +++---- share/github-backup-utils/ghe-backup-mysql-logical | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index b654acded..f0e385e2d 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -1,8 +1,8 @@ #!/usr/bin/env bash -#/ usage: ghe-backup-mysql -#/ backup mysql from a github instance. +#/ Usage: ghe-backup-mysql +#/ Backup MySQL from a GitHub instance. #/ -#/ note: this script typically isn't called directly. it's invoked by the +#/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-backup command. set -e diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary index d6c9aa8ba..66dc8972b 100644 --- a/share/github-backup-utils/ghe-backup-mysql-binary +++ b/share/github-backup-utils/ghe-backup-mysql-binary @@ -1,9 +1,8 @@ - #!/usr/bin/env bash -#/ usage: ghe-backup-mysql-logical -#/ backup mysql from a github instance. +#/ Usage: ghe-backup-mysql-logical +#/ Backup MySQL from a GitHub instance. #/ -#/ note: this script typically isn't called directly. it's invoked by the +#/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-backup command. set -e diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical index 37d45edce..45e2a3b4e 100644 --- a/share/github-backup-utils/ghe-backup-mysql-logical +++ b/share/github-backup-utils/ghe-backup-mysql-logical @@ -1,8 +1,8 @@ #!/usr/bin/env bash -#/ usage: ghe-backup-mysql-logical -#/ backup mysql from a github instance. +#/ Usage: ghe-backup-mysql-logical +#/ Backup MySQL from a GitHub instance. #/ -#/ note: this script typically isn't called directly. it's invoked by the +#/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-backup command. set -e From 3f7c687ba534180ce88ee709123a4239e99b9541 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Jul 2020 15:24:27 +0000 Subject: [PATCH 1177/2421] fix syntax error --- share/github-backup-utils/ghe-backup-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index f0e385e2d..48fcf9bf2 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -20,7 +20,7 @@ if is_external_database_target; then if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then $EXTERNAL_DATABASE_BACKUP_SCRIPT else - if is_binary_backup_feature_on + if is_binary_backup_feature_on; then echo "Error: Binary backup is not supported with an external MySQL database. Please provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" exit 1 From 77dc63aefda17147aa8f424d081385ebdb8b2447 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Jul 2020 15:57:46 +0000 Subject: [PATCH 1178/2421] Set correct permissions on new files --- share/github-backup-utils/ghe-backup-mysql-binary | 0 share/github-backup-utils/ghe-backup-mysql-logical | 0 share/github-backup-utils/ghe-restore-mysql-binary | 0 share/github-backup-utils/ghe-restore-mysql-logical | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 share/github-backup-utils/ghe-backup-mysql-binary mode change 100644 => 100755 share/github-backup-utils/ghe-backup-mysql-logical mode change 100644 => 100755 share/github-backup-utils/ghe-restore-mysql-binary mode change 100644 => 100755 share/github-backup-utils/ghe-restore-mysql-logical diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary old mode 100644 new mode 100755 diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical old mode 100644 new mode 100755 diff --git a/share/github-backup-utils/ghe-restore-mysql-binary b/share/github-backup-utils/ghe-restore-mysql-binary old mode 100644 new mode 100755 diff --git a/share/github-backup-utils/ghe-restore-mysql-logical b/share/github-backup-utils/ghe-restore-mysql-logical old mode 100644 new mode 100755 From ef0a779a1b7ad81a27c64f8b466bdd805bc3d54e Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 8 Jul 2020 17:09:18 +0000 Subject: [PATCH 1179/2421] Need to pass the hostname --- share/github-backup-utils/ghe-restore-mysql | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 61a3e5bea..e14e66d79 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -44,10 +44,9 @@ fi if is_binary_backup_feature_on; then # Feature "mysql.backup.binary" is on, which means new backup scripts are available if is_binary_backup "$snapshot_dir"; then - ghe-restore-mysql-binary + ghe-restore-mysql-binary $GHE_HOSTNAME else - ghe-restore-mysql-logical - GHE_RESTORE_HOST=$GHE_HOSTNAME + ghe-restore-mysql-logical $GHE_HOSTNAME fi else # We do not allow to restore binary backup without "mysql.backup.binary" set @@ -56,8 +55,7 @@ else exit 2 else # legacy mode - ghe-restore-mysql-logical - GHE_RESTORE_HOST=$GHE_HOSTNAME + ghe-restore-mysql-logical $GHE_HOSTNAME fi fi From 02e025599d187c6d21f982c387547fe28ae48e5f Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 8 Jul 2020 17:31:40 +0000 Subject: [PATCH 1180/2421] Also backup and restore settings --- bin/ghe-backup | 2 +- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-backup-actions | 2 +- share/github-backup-utils/ghe-backup-settings | 54 ++++++++++++------ .../github-backup-utils/ghe-restore-settings | 43 ++++++++++---- test/test-ghe-backup.sh | 55 ++++++++++++++++++ test/test-ghe-restore.sh | 57 +++++++++++++++++++ 7 files changed, 183 insertions(+), 32 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index a2ae380e1..1135db7f0 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -186,7 +186,7 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Backing up MSSQL databases ..." ghe-backup-mssql 1>&3 || failures="$failures mssql" - echo "Backing up Actions files ..." + echo "Backing up Actions data ..." ghe-backup-actions 1>&3 || failures="$failures actions" fi diff --git a/bin/ghe-restore b/bin/ghe-restore index 23e33153f..ae344c1fd 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -279,7 +279,7 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Restoring MSSQL database ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 - echo "Restoring Actions files ..." + echo "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 fi diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index cc3ab9a87..25df7e89d 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -67,7 +67,7 @@ fi for hostname in $hostnames; do bm_start "$(basename $0) - $hostname" echo 1>&3 - ghe_verbose "* Transferring actions files to $hostname ..." + ghe_verbose "* Transferring actions files from $hostname ..." # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 33e14168f..95725ceec 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -25,27 +25,45 @@ ghe-ssh "$host" -- 'ghe-export-settings' > settings.json echo "* Transferring license data ..." 1>&3 ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl -echo "* Transferring management console password ..." 1>&3 -ghe-ssh "$host" -- ghe-config secrets.manage > manage-password+ || ( - echo "Warning: Management Console password not set" >&2 -) -if [ -n "$(cat manage-password+)" ]; then - mv manage-password+ manage-password -else - unlink manage-password+ -fi - -# Backup external MySQL password if running external MySQL DB. -if is_service_external 'mysql'; then - echo "Transferring external MySQL password..." 1>&3 - ghe-ssh "$host" -- ghe-config secrets.external.mysql > external-mysql-password+ || ( - echo "Warning: External MySQL password not set" >&2 +# Function to backup a secret setting to a file. +# backup-secret +backup-secret() { + echo "* Transferring $1 ..." 1>&3 + ghe-ssh "$host" -- ghe-config "$3" > "$2+" || ( + echo "Warning: ${1^} not set" >&2 ) - if [ -n "$(cat external-mysql-password+)" ]; then - mv external-mysql-password+ external-mysql-password + if [ -n "$(cat "$2+")" ]; then + mv "$2+" "$2" else - unlink external-mysql-password+ + unlink "$2+" fi +} + +backup-secret "management console password" "manage-password" "secrets.manage" + +# Backup external MySQL password if running external MySQL DB. +if is_service_external 'mysql'; then + backup-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" +fi + +# Backup Actions settings. +if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then + backup-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" + backup-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" + backup-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" + backup-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" + backup-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" + backup-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" + backup-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" + backup-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" + backup-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" + backup-secret "Actions AAD cert thumbprint" "actions-add-cert-thumbprint" "secrets.actions.AADCertThumbprint" + backup-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" + backup-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" + backup-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" + backup-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" + backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" + backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" fi if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 017a9eb0a..f4eca8555 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -28,25 +28,46 @@ GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" echo "Restoring license ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 -# Restore external MySQL password if running external MySQL DB. -if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password" ]; then - echo "Restoring external MySQL password ..." - echo "ghe-config secrets.external.mysql '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/external-mysql-password")'" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -fi +# Function to restore a secret setting stored in a file. +# restore-secret +restore-secret() { + if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then + echo "Restoring $1 ..." + echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash + fi +} echo "Restoring settings ..." + +# Restore external MySQL password if running external MySQL DB. +restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" + +# Restore Actions settings. +restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" +restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" +restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" +restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" +restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" +restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" +restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" +restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" +restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" +restore-secret "Actions AAD cert thumbprint" "actions-add-cert-thumbprint" "secrets.actions.AADCertThumbprint" +restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" +restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" +restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" +restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" +restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" +restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" + # work around issue importing settings with bad storage mode values ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | ghe-ssh "$GHE_HOSTNAME" -- '/usr/bin/env GHEBUVER=2 ghe-import-settings' 1>&3 # Restore management console password hash if present. -if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/manage-password" ]; then - echo "Restoring management console password ..." - echo "ghe-config secrets.manage '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/manage-password")'" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -fi +restore-secret "management console password" "manage-password" "secrets.manage" # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index cbb4669c5..ae0c82686 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -401,6 +401,61 @@ begin_test "ghe-backup takes transaction backup upon expiration" ) end_test +begin_test "ghe-backup takes backup of Actions settings" +( + set -e + enable_actions + + required_secrets=( + "secrets.actions.ConfigurationDatabaseSqlLogin" + "secrets.actions.ConfigurationDatabaseSqlPassword" + "secrets.actions.FrameworkAccessTokenKeySecret" + "secrets.actions.UrlSigningHmacKeyPrimary" + "secrets.actions.UrlSigningHmacKeySecondary" + "secrets.actions.OAuthS2SSigningCert" + "secrets.actions.OAuthS2SSigningKey" + "secrets.actions.OAuthS2SSigningCertThumbprint" + "secrets.actions.PrimaryEncryptionCertificateThumbprint" + "secrets.actions.AADCertThumbprint" + "secrets.actions.DelegatedAuthCertThumbprint" + "secrets.actions.RuntimeServicePrincipalCertificate" + "secrets.actions.S2SEncryptionCertificate" + "secrets.actions.SecondaryEncryptionCertificateThumbprint" + "secrets.actions.ServicePrincipalCertificate" + "secrets.actions.SpsValidationCertThumbprint" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + ghe-backup + + required_files=( + "actions-config-db-login" + "actions-config-db-password" + "actions-framework-access-token" + "actions-url-signing-hmac-key-primary" + "actions-url-signing-hmac-key-secondary" + "actions-oauth-s2s-signing-cert" + "actions-oauth-s2s-signing-key" + "actions-oauth-s2s-signing-cert-thumbprint" + "actions-primary-encryption-cert-thumbprint" + "actions-add-cert-thumbprint" + "actions-delegated-auth-cert-thumbprint" + "actions-runtime-service-principal-cert" + "actions-s2s-encryption-cert" + "actions-secondary-encryption-cert-thumbprint" + "actions-service-principal-cert" + "actions-sps-validation-cert-thumbprint" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$file")" = "foo" ] + done +) +end_test + begin_test "ghe-backup takes backup of Actions files" ( set -e diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 296e6f11e..7221140c7 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -306,6 +306,63 @@ begin_test "ghe-restore invokes ghe-import-mssql" ) end_test +begin_test "ghe-restore with Actions settings" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + required_files=( + "actions-config-db-login" + "actions-config-db-password" + "actions-framework-access-token" + "actions-url-signing-hmac-key-primary" + "actions-url-signing-hmac-key-secondary" + "actions-oauth-s2s-signing-cert" + "actions-oauth-s2s-signing-key" + "actions-oauth-s2s-signing-cert-thumbprint" + "actions-primary-encryption-cert-thumbprint" + "actions-add-cert-thumbprint" + "actions-delegated-auth-cert-thumbprint" + "actions-runtime-service-principal-cert" + "actions-s2s-encryption-cert" + "actions-secondary-encryption-cert-thumbprint" + "actions-service-principal-cert" + "actions-sps-validation-cert-thumbprint" + ) + + for file in "${required_files[@]}"; do + echo "foo" > "$GHE_REMOTE_ROOT_DIR/$file" + done + + ghe-restore -v -f localhost + + required_secrets=( + "secrets.actions.ConfigurationDatabaseSqlLogin" + "secrets.actions.ConfigurationDatabaseSqlPassword" + "secrets.actions.FrameworkAccessTokenKeySecret" + "secrets.actions.UrlSigningHmacKeyPrimary" + "secrets.actions.UrlSigningHmacKeySecondary" + "secrets.actions.OAuthS2SSigningCert" + "secrets.actions.OAuthS2SSigningKey" + "secrets.actions.OAuthS2SSigningCertThumbprint" + "secrets.actions.PrimaryEncryptionCertificateThumbprint" + "secrets.actions.AADCertThumbprint" + "secrets.actions.DelegatedAuthCertThumbprint" + "secrets.actions.RuntimeServicePrincipalCertificate" + "secrets.actions.S2SEncryptionCertificate" + "secrets.actions.SecondaryEncryptionCertificateThumbprint" + "secrets.actions.ServicePrincipalCertificate" + "secrets.actions.SpsValidationCertThumbprint" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done +) +end_test + begin_test "ghe-restore with Actions files" ( set -e From 134e07933d66329b344e51faccd7d58b0babcc09 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 8 Jul 2020 18:31:28 +0000 Subject: [PATCH 1181/2421] Remove cluster mode --- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-backup-actions | 54 ++++--------------- share/github-backup-utils/ghe-restore-actions | 52 +++++------------- test/test-ghe-backup.sh | 2 +- test/test-ghe-restore.sh | 2 +- 5 files changed, 27 insertions(+), 85 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index ae344c1fd..45c3cb36b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -276,7 +276,7 @@ echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Restoring MSSQL database ..." + echo "Restoring MSSQL databases ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 echo "Restoring Actions data ..." diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index 25df7e89d..347de1d56 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -14,7 +14,8 @@ set -e bm_start "$(basename $0)" # Set up remote host and root backup snapshot directory based on config -host="$GHE_HOSTNAME" +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") backup_dir="$GHE_SNAPSHOT_DIR/actions" # Verify rsync is available. @@ -26,57 +27,24 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$host -ssh_config_file_opt= -tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -opts="$GHE_EXTRA_SSH_OPTS" - -# Get hostnames running Actions services under cluster -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames="$(ghe-cluster-nodes "$GHE_HOSTNAME" "web-server") $(ghe-cluster-nodes "$GHE_HOSTNAME" "job-server")" - ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" -fi - # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" -# Removes the remote sync-in-progress file on exit, re-enabling GC operations -# on the remote instance. -cleanup() { - rm -rf $tempdir -} -trap 'cleanup' EXIT INT - # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$GHE_DATA_DIR/current/actions" ] && [ "$(ls -A $GHE_DATA_DIR/current/actions)" ]; then link_dest="--link-dest=../../current/actions" fi -for hostname in $hostnames; do - bm_start "$(basename $0) - $hostname" - echo 1>&3 - ghe_verbose "* Transferring actions files from $hostname ..." +# Transfer all data from the user data directory using rsync. +echo 1>&3 +ghe_verbose "* Transferring actions files from $host ..." - # Transfer all data from the user data directory using rsync. - ghe-rsync -avz \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - --rsync-path='sudo -u actions rsync' \ - $link_dest \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/actions/" \ - "$GHE_SNAPSHOT_DIR/actions" 1>&3 - bm_end "$(basename $0) - $hostname" -done +ghe-rsync -avz \ + -e "ghe-ssh -p $port" \ + --rsync-path='sudo -u actions rsync' \ + $link_dest \ + "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" \ + "$GHE_SNAPSHOT_DIR/actions" 1>&3 bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 1bcc210dc..959ff006a 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -22,6 +22,9 @@ GHE_HOSTNAME="$1" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + # No need to restore anything, early exit if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions" ]; then echo "Warning: Actions backup missing. Skipping ..." @@ -29,47 +32,18 @@ if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions" ]; then fi # Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$host -ssh_config_file_opt= -tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -opts="$GHE_EXTRA_SSH_OPTS" - -if $CLUSTER; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames="$(ghe-cluster-nodes "$GHE_HOSTNAME" "web-server") $(ghe-cluster-nodes "$GHE_HOSTNAME" "job-server")" - ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" -fi - -cleanup() { - rm -rf $tempdir -} -trap 'cleanup' EXIT +ghe_remote_version_required "$host" -for hostname in $hostnames; do - bm_start "$(basename $0) - $hostname" - echo 1>&3 - ghe_verbose "* Transferring actions files to $hostname ..." +echo 1>&3 +ghe_verbose "* Transferring actions files to $host ..." - echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions" | ghe-ssh $hostname /bin/bash +echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions" | +ghe-ssh -p $port $host /bin/bash - ghe-rsync -arvHR --delete \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - --rsync-path='sudo -u actions rsync' \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions/./" \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/actions/" 1>&3 - bm_end "$(basename $0) - $hostname" -done +ghe-rsync -arvHR --delete \ + -e "ghe-ssh -p $port" \ + --rsync-path='sudo -u actions rsync' \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions/./" \ + "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" 1>&3 bm_end "$(basename $0)" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index ae0c82686..7c61095ff 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -462,7 +462,7 @@ begin_test "ghe-backup takes backup of Actions files" enable_actions output=$(ghe-backup -v) - echo $output | grep "Transferring actions files to" + echo $output | grep "Transferring actions files from" diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 7221140c7..6cb61e18b 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -333,7 +333,7 @@ begin_test "ghe-restore with Actions settings" ) for file in "${required_files[@]}"; do - echo "foo" > "$GHE_REMOTE_ROOT_DIR/$file" + echo "foo" > "$GHE_DATA_DIR/current/$file" done ghe-restore -v -f localhost From 757c71789597f7745a60d43021dd1ae5836e53c9 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 8 Jul 2020 18:49:18 +0000 Subject: [PATCH 1182/2421] Fix test --- test/test-ghe-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 7c61095ff..4882cbd3d 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -451,7 +451,7 @@ begin_test "ghe-backup takes backup of Actions settings" ) for file in "${required_files[@]}"; do - [ "$(cat "$file")" = "foo" ] + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] done ) end_test From f1d6f376e2c7fb6794893971b05e0e6e0f84ab7c Mon Sep 17 00:00:00 2001 From: David Hadka Date: Thu, 9 Jul 2020 01:01:46 +0000 Subject: [PATCH 1183/2421] React to feedback --- share/github-backup-utils/ghe-backup-actions | 6 +++--- share/github-backup-utils/ghe-restore-actions | 2 +- share/github-backup-utils/version | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index 347de1d56..3e3013b0a 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -33,16 +33,16 @@ mkdir -p "$backup_dir" # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$GHE_DATA_DIR/current/actions" ] && [ "$(ls -A $GHE_DATA_DIR/current/actions)" ]; then - link_dest="--link-dest=../../current/actions" + link_dest="--link-dest=$GHE_DATA_DIR/current/actions" fi -# Transfer all data from the user data directory using rsync. -echo 1>&3 +# Transfer all Actions data from the user data directory using rsync. ghe_verbose "* Transferring actions files from $host ..." ghe-rsync -avz \ -e "ghe-ssh -p $port" \ --rsync-path='sudo -u actions rsync' \ + --exclude "mutexes" --exclude "dumps" \ $link_dest \ "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" \ "$GHE_SNAPSHOT_DIR/actions" 1>&3 diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 959ff006a..2f83f51a6 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -34,7 +34,7 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$host" -echo 1>&3 +# Transfer all Actions data from the snapshot to the user data directory using rsync. ghe_verbose "* Transferring actions files to $host ..." echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions" | diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 83ecbf1d7..f48f82fa2 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.20.2 +2.22.0 From d81ead8be5773b26817cdb17a02bbcaf3632424f Mon Sep 17 00:00:00 2001 From: David Hadka Date: Thu, 9 Jul 2020 01:36:39 +0000 Subject: [PATCH 1184/2421] Fix bash compat issue on Mac --- share/github-backup-utils/ghe-backup-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 95725ceec..95c8bb268 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -30,7 +30,7 @@ ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl backup-secret() { echo "* Transferring $1 ..." 1>&3 ghe-ssh "$host" -- ghe-config "$3" > "$2+" || ( - echo "Warning: ${1^} not set" >&2 + echo "Warning: $1 not set" >&2 ) if [ -n "$(cat "$2+")" ]; then mv "$2+" "$2" From cfaa9eef5e28562a3c4268cd42b3a0f6640e98f2 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Thu, 9 Jul 2020 01:41:27 +0000 Subject: [PATCH 1185/2421] Undo unintended changes --- share/github-backup-utils/version | 2 +- test/testlib.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index f48f82fa2..83ecbf1d7 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.22.0 +2.20.2 diff --git a/test/testlib.sh b/test/testlib.sh index 230c57c7c..3f1fa175d 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -328,7 +328,6 @@ setup_test_data () { echo "fake actions certificate" > "$loc/actions/certificates/cert.cer" echo "fake actions state file" > "$loc/actions/states/actions_state" } - # A unified method to check everything backed up or restored during testing. # Everything tested here should pass regardless of whether we're testing a backup From 8c9b1c92039a3873b73626c9894108449c97fdbb Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Thu, 9 Jul 2020 12:01:16 +0200 Subject: [PATCH 1186/2421] Exit from mysql scripts early if we are running the external scripts Co-authored-by: Evgenii Khramkov --- share/github-backup-utils/ghe-backup-mysql | 2 ++ share/github-backup-utils/ghe-restore-mysql | 2 ++ 2 files changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 48fcf9bf2..8e30d9bfd 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -19,6 +19,8 @@ if is_external_database_target; then echo "Backing up external MySQL database using customer-provided script..." if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then $EXTERNAL_DATABASE_BACKUP_SCRIPT + bm_end "$(basename $0)" + exit 0 else if is_binary_backup_feature_on; then echo "Error: Binary backup is not supported with an external MySQL database. diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index e14e66d79..3e5391e54 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -32,6 +32,8 @@ snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" if is_external_database_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT + bm_end "$(basename $0)" + exit 0 else if is_binary_backup_feature_on || is_binary_backup "$snapshot_dir"; then echo "Error: Restore of a binary backup to appliance with an external database configured is not supported. From 5036f92d152fb92f50e518025ab8df813e75bb7d Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Thu, 9 Jul 2020 18:32:00 +0000 Subject: [PATCH 1187/2421] prperly use pigz for logical mysql export, instead of binary --- share/github-backup-utils/ghe-backup-mysql-binary | 2 +- share/github-backup-utils/ghe-backup-mysql-logical | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary index 66dc8972b..064ee1593 100755 --- a/share/github-backup-utils/ghe-backup-mysql-binary +++ b/share/github-backup-utils/ghe-backup-mysql-binary @@ -17,7 +17,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" echo "Backing up MySQL database using binary backup strategy ..." -echo "set -o pipefail; ghe-export-mysql | pigz" | +echo "set -o pipefail; ghe-export-mysql" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical index 45e2a3b4e..ba1e9efe4 100755 --- a/share/github-backup-utils/ghe-backup-mysql-logical +++ b/share/github-backup-utils/ghe-backup-mysql-logical @@ -18,7 +18,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" echo "Backing up MySQL database using logical backup strategy ..." -echo "set -o pipefail; ghe-export-mysql" | +echo "set -o pipefail; ghe-export-mysql | pigz" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" bm_end "$(basename $0)" \ No newline at end of file From 2ecab2749db3d25a180293d9186c336f2ffa92ce Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Tue, 14 Jul 2020 10:26:21 +0000 Subject: [PATCH 1188/2421] Fix comments --- share/github-backup-utils/ghe-restore-mysql-binary | 4 ++-- share/github-backup-utils/ghe-restore-mysql-logical | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql-binary b/share/github-backup-utils/ghe-restore-mysql-binary index d4812e2dd..1460e6add 100755 --- a/share/github-backup-utils/ghe-restore-mysql-binary +++ b/share/github-backup-utils/ghe-restore-mysql-binary @@ -1,6 +1,6 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-mysql-logical -#/ Restore MySQL backup to a GitHub instance. +#/ Usage: ghe-restore-mysql-binary +#/ Restore binary MySQL backup to a GitHub instance. #/ #/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-restore command when the rsync strategy is used. diff --git a/share/github-backup-utils/ghe-restore-mysql-logical b/share/github-backup-utils/ghe-restore-mysql-logical index 94b35505f..06530c628 100755 --- a/share/github-backup-utils/ghe-restore-mysql-logical +++ b/share/github-backup-utils/ghe-restore-mysql-logical @@ -1,6 +1,6 @@ #!/usr/bin/env bash #/ Usage: ghe-restore-mysql-logical -#/ Restore MySQL backup to a GitHub instance. +#/ Restore logical MySQL backup to a GitHub instance. #/ #/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-restore command when the rsync strategy is used. From a7254080668628ea7c98d73610add26596c6f100 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Tue, 14 Jul 2020 14:32:31 +0000 Subject: [PATCH 1189/2421] Add a legacy script until 2.22 ships --- share/github-backup-utils/ghe-restore-mysql | 2 +- .../ghe-restore-mysql-legacy | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100755 share/github-backup-utils/ghe-restore-mysql-legacy diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 3e5391e54..01bfb8763 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -57,7 +57,7 @@ else exit 2 else # legacy mode - ghe-restore-mysql-logical $GHE_HOSTNAME + ghe-restore-mysql-legacy $GHE_HOSTNAME fi fi diff --git a/share/github-backup-utils/ghe-restore-mysql-legacy b/share/github-backup-utils/ghe-restore-mysql-legacy new file mode 100755 index 000000000..07d6fc852 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-mysql-legacy @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-mysql-legacy +#/ Restore logical MySQL backup to a GitHub instance using legacy import script. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command when the rsync strategy is used. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} +export GHE_RESTORE_SNAPSHOT + +# The directory holding the snapshot to restore +snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + +ssh_config_file_opt= + +# legacy mode +IMPORT_MYSQL="unpigz | ghe-import-mysql" +GHE_RESTORE_HOST=$GHE_HOSTNAME + +cleanup() { + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" +} +trap 'cleanup' INT TERM EXIT + +ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 + +# Transfer MySQL data from the snapshot to the GitHub instance. +cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" + +echo "Restore MySQL database ..." +# Import the database +echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 + +bm_end "$(basename $0)" \ No newline at end of file From 4eb0eb967c1dc477ee9320f4c4883f53ce64e5c5 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Tue, 14 Jul 2020 14:52:32 +0000 Subject: [PATCH 1190/2421] Warn rather than error on binary settings, then run logical. We should default to what works, rather than forcing customers to change settings in order to get things to work. --- share/github-backup-utils/ghe-backup-mysql | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 8e30d9bfd..115d16066 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -23,17 +23,20 @@ if is_external_database_target; then exit 0 else if is_binary_backup_feature_on; then - echo "Error: Binary backup is not supported with an external MySQL database. - Please provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" - exit 1 + echo "Warning: Binary backup is not supported with an external MySQL database. Backing up using Logical backup strategy. + + Please disable binary backups with `ghe-config mysql.backup.binary false`, or + provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" fi - fi -fi -if is_binary_backup_feature_on; then - ghe-backup-mysql-binary + ghe-backup-mysql-logical + fi else - ghe-backup-mysql-logical + if is_binary_backup_feature_on; then + ghe-backup-mysql-binary + else + ghe-backup-mysql-logical + fi fi bm_end "$(basename $0)" From 1551414e729f88bda3300263db9c2750d6f11b9d Mon Sep 17 00:00:00 2001 From: David Hadka Date: Tue, 14 Jul 2020 17:11:15 +0000 Subject: [PATCH 1191/2421] Prevent leaking MSSQL backup files to subsequent tests --- test/test-ghe-backup.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 36d06084b..d8ceae2cc 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -429,6 +429,10 @@ begin_test "ghe-backup takes backup of Actions settings" set -e enable_actions + # Prevent previous steps from leaking MSSQL backup files + rm -rf "$GHE_DATA_DIR/current/mssql" + mkdir -p "$GHE_DATA_DIR/current/mssql" + required_secrets=( "secrets.actions.ConfigurationDatabaseSqlLogin" "secrets.actions.ConfigurationDatabaseSqlPassword" From ab36713809ea20b326c4a3c0e55c8522c6a91b80 Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 14 Jul 2020 12:19:06 -0700 Subject: [PATCH 1192/2421] Add new lines to ends of files --- share/github-backup-utils/ghe-backup-mysql-binary | 2 +- share/github-backup-utils/ghe-backup-mysql-logical | 3 +-- share/github-backup-utils/ghe-restore-mysql-binary | 2 +- share/github-backup-utils/ghe-restore-mysql-legacy | 2 +- share/github-backup-utils/ghe-restore-mysql-logical | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary index 064ee1593..569539bbb 100755 --- a/share/github-backup-utils/ghe-backup-mysql-binary +++ b/share/github-backup-utils/ghe-backup-mysql-binary @@ -21,4 +21,4 @@ echo "set -o pipefail; ghe-export-mysql" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" -bm_end "$(basename $0)" \ No newline at end of file +bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical index ba1e9efe4..09f0e40e8 100755 --- a/share/github-backup-utils/ghe-backup-mysql-logical +++ b/share/github-backup-utils/ghe-backup-mysql-logical @@ -17,8 +17,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" echo "Backing up MySQL database using logical backup strategy ..." - echo "set -o pipefail; ghe-export-mysql | pigz" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" -bm_end "$(basename $0)" \ No newline at end of file +bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-mysql-binary b/share/github-backup-utils/ghe-restore-mysql-binary index 1460e6add..fb0da41b0 100755 --- a/share/github-backup-utils/ghe-restore-mysql-binary +++ b/share/github-backup-utils/ghe-restore-mysql-binary @@ -70,4 +70,4 @@ echo "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 -bm_end "$(basename $0)" \ No newline at end of file +bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-mysql-legacy b/share/github-backup-utils/ghe-restore-mysql-legacy index 07d6fc852..8678be596 100755 --- a/share/github-backup-utils/ghe-restore-mysql-legacy +++ b/share/github-backup-utils/ghe-restore-mysql-legacy @@ -49,4 +49,4 @@ echo "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 -bm_end "$(basename $0)" \ No newline at end of file +bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-mysql-logical b/share/github-backup-utils/ghe-restore-mysql-logical index 06530c628..3f7e64107 100755 --- a/share/github-backup-utils/ghe-restore-mysql-logical +++ b/share/github-backup-utils/ghe-restore-mysql-logical @@ -49,4 +49,4 @@ echo "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 -bm_end "$(basename $0)" \ No newline at end of file +bm_end "$(basename $0)" From 26fdca95cc4d6ca696ec8012df54d8b209ec8a8f Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Tue, 14 Jul 2020 13:13:11 -0700 Subject: [PATCH 1193/2421] Add some extra verbosity to file comments --- share/github-backup-utils/ghe-backup-mysql-binary | 4 ++-- share/github-backup-utils/ghe-backup-mysql-logical | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary index 569539bbb..37218c82e 100755 --- a/share/github-backup-utils/ghe-backup-mysql-binary +++ b/share/github-backup-utils/ghe-backup-mysql-binary @@ -1,6 +1,6 @@ #!/usr/bin/env bash -#/ Usage: ghe-backup-mysql-logical -#/ Backup MySQL from a GitHub instance. +#/ Usage: ghe-backup-mysql-binary +#/ Backup MySQL from a GitHub instance using binary backup strategy. #/ #/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-backup command. diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical index 09f0e40e8..5748cd1f1 100755 --- a/share/github-backup-utils/ghe-backup-mysql-logical +++ b/share/github-backup-utils/ghe-backup-mysql-logical @@ -1,6 +1,6 @@ #!/usr/bin/env bash #/ Usage: ghe-backup-mysql-logical -#/ Backup MySQL from a GitHub instance. +#/ Backup MySQL from a GitHub instance using logical backup strategy. #/ #/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-backup command. From 54ee32473387bb4de4085ef05ae3d90873c3eca5 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Tue, 14 Jul 2020 21:06:00 +0000 Subject: [PATCH 1194/2421] Fix typo in Actions secret --- share/github-backup-utils/ghe-backup-settings | 2 +- share/github-backup-utils/ghe-restore-settings | 2 +- test/test-ghe-backup.sh | 2 +- test/test-ghe-restore.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 95c8bb268..3f069c8d1 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -57,7 +57,7 @@ if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then backup-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" backup-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" backup-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" - backup-secret "Actions AAD cert thumbprint" "actions-add-cert-thumbprint" "secrets.actions.AADCertThumbprint" + backup-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" backup-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" backup-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" backup-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index f4eca8555..dcff624ee 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -53,7 +53,7 @@ restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" -restore-secret "Actions AAD cert thumbprint" "actions-add-cert-thumbprint" "secrets.actions.AADCertThumbprint" +restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index d8ceae2cc..21b46a772 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -468,7 +468,7 @@ begin_test "ghe-backup takes backup of Actions settings" "actions-oauth-s2s-signing-key" "actions-oauth-s2s-signing-cert-thumbprint" "actions-primary-encryption-cert-thumbprint" - "actions-add-cert-thumbprint" + "actions-aad-cert-thumbprint" "actions-delegated-auth-cert-thumbprint" "actions-runtime-service-principal-cert" "actions-s2s-encryption-cert" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 6cb61e18b..ea9549358 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -323,7 +323,7 @@ begin_test "ghe-restore with Actions settings" "actions-oauth-s2s-signing-key" "actions-oauth-s2s-signing-cert-thumbprint" "actions-primary-encryption-cert-thumbprint" - "actions-add-cert-thumbprint" + "actions-aad-cert-thumbprint" "actions-delegated-auth-cert-thumbprint" "actions-runtime-service-principal-cert" "actions-s2s-encryption-cert" From e6fe5943f9db4c5306b58b8151932fe7c81fa422 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 15 Jul 2020 11:21:19 +0000 Subject: [PATCH 1195/2421] Detech if backup has sentinel or not, and warn differently --- share/github-backup-utils/ghe-restore-mysql | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 01bfb8763..673753ddf 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -35,10 +35,19 @@ if is_external_database_snapshot; then bm_end "$(basename $0)" exit 0 else - if is_binary_backup_feature_on || is_binary_backup "$snapshot_dir"; then - echo "Error: Restore of a binary backup to appliance with an external database configured is not supported. - Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" - exit 1 + if is_binary_backup_feature_on; then + if is_binary_backup "$snapshot_dir"; then + echo "Error: Restore of a binary backup to appliance with an external database configured is not supported." + echo "Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" + exit 1 + else + echo "Warning: Binary backups are configured on the target environment." + echo "Binary backups are not supported with an external database configured." + echo + echo "Please disable binary backups with 'ghe-config mysql.backup.binary false', or" + echo "provide a custom restore script using EXTERNAL_DATABASE_BACKUP_SCRIPT" + exit 1 + fi fi fi fi @@ -55,6 +64,8 @@ else if is_binary_backup "$snapshot_dir"; then echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 + else if is_external_database_snapshot; then + ghe-restore-mysql-logical $GHE_HOSTNAME else # legacy mode ghe-restore-mysql-legacy $GHE_HOSTNAME From 40bd3f8a705b11f8b069a4e00730882681c53d2b Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 15 Jul 2020 11:26:04 +0000 Subject: [PATCH 1196/2421] Change warnings to multiple echos --- share/github-backup-utils/ghe-backup-mysql | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 115d16066..154fac3c2 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -23,10 +23,11 @@ if is_external_database_target; then exit 0 else if is_binary_backup_feature_on; then - echo "Warning: Binary backup is not supported with an external MySQL database. Backing up using Logical backup strategy. - - Please disable binary backups with `ghe-config mysql.backup.binary false`, or - provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" + echo "Warning: Binary backups are configured on the target environment." + echo "Binary backup is not supported with an external MySQL database. Backing up using logical backup strategy." + echo + echo "Please disable binary backups with 'ghe-config mysql.backup.binary false', or" + echo "provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" fi ghe-backup-mysql-logical From 56f6ef5f6839b05c29a5b334b9f8d5abab18df62 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 15 Jul 2020 13:26:55 +0000 Subject: [PATCH 1197/2421] move to seperate if statement --- share/github-backup-utils/ghe-restore-mysql | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 673753ddf..b5f542005 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -64,11 +64,13 @@ else if is_binary_backup "$snapshot_dir"; then echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 - else if is_external_database_snapshot; then - ghe-restore-mysql-logical $GHE_HOSTNAME else - # legacy mode - ghe-restore-mysql-legacy $GHE_HOSTNAME + if is_external_database_snapshot; then + ghe-restore-mysql-logical $GHE_HOSTNAME + else + # legacy mode + ghe-restore-mysql-legacy $GHE_HOSTNAME + fi fi fi From cab7d91143b607cf2ff0b6864e4c15c6d7360824 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 15 Jul 2020 14:19:53 +0000 Subject: [PATCH 1198/2421] Change warning to Error when restoring. --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index b5f542005..265d0662f 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -41,7 +41,7 @@ if is_external_database_snapshot; then echo "Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" exit 1 else - echo "Warning: Binary backups are configured on the target environment." + echo "Error: Binary backups are configured on the target environment." echo "Binary backups are not supported with an external database configured." echo echo "Please disable binary backups with 'ghe-config mysql.backup.binary false', or" From ed7d9ae1d1f7ad320a94861049fa2fd26571a10f Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 15 Jul 2020 14:27:25 +0000 Subject: [PATCH 1199/2421] Don't exit, just warn. --- share/github-backup-utils/ghe-restore-mysql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 265d0662f..b6ee84878 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -41,12 +41,11 @@ if is_external_database_snapshot; then echo "Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" exit 1 else - echo "Error: Binary backups are configured on the target environment." + echo "Warning: Binary backups are configured on the target environment." echo "Binary backups are not supported with an external database configured." echo echo "Please disable binary backups with 'ghe-config mysql.backup.binary false', or" echo "provide a custom restore script using EXTERNAL_DATABASE_BACKUP_SCRIPT" - exit 1 fi fi fi From e4c851b984a96d17abd8ddd0510fac1a43fb9f7b Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 15 Jul 2020 14:30:07 +0000 Subject: [PATCH 1200/2421] Add notice that we're using logical strategy --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index b6ee84878..4d05cec52 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -42,7 +42,7 @@ if is_external_database_snapshot; then exit 1 else echo "Warning: Binary backups are configured on the target environment." - echo "Binary backups are not supported with an external database configured." + echo "Binary backups are not supported with an external database configured. Restoring using logical strategy." echo echo "Please disable binary backups with 'ghe-config mysql.backup.binary false', or" echo "provide a custom restore script using EXTERNAL_DATABASE_BACKUP_SCRIPT" From 0c2f464addf11056afa38cf267df93bbece92d91 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 15 Jul 2020 15:55:16 +0000 Subject: [PATCH 1201/2421] Add sentinel file for logical external backups --- share/github-backup-utils/ghe-backup-mysql-logical | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical index 5748cd1f1..3dc2478ec 100755 --- a/share/github-backup-utils/ghe-backup-mysql-logical +++ b/share/github-backup-utils/ghe-backup-mysql-logical @@ -20,4 +20,8 @@ echo "Backing up MySQL database using logical backup strategy ..." echo "set -o pipefail; ghe-export-mysql | pigz" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" +if is_external_database_target; then + echo "LOGICAL_EXTERNAL_BACKUP" > "$GHE_SNAPSHOT_DIR/logical-external-database-backup-sentinel" +fi + bm_end "$(basename $0)" From 19954a6c9a9e9ea1c03eb7c7f9ef60f24854e2a3 Mon Sep 17 00:00:00 2001 From: Adam Holt Date: Wed, 15 Jul 2020 15:56:41 +0000 Subject: [PATCH 1202/2421] Detect sentinel file on restore and error if not there. --- share/github-backup-utils/ghe-backup-config | 6 +++++ share/github-backup-utils/ghe-backup-mysql | 2 +- share/github-backup-utils/ghe-restore-mysql | 30 ++++++++++++--------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 5d14090f4..9674e0c29 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -450,6 +450,12 @@ is_external_database_snapshot(){ is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" } +# This file exists if this is a backup for an external database AND the backup was +# taken via our logical backup strategy. +is_default_external_database_snapshot(){ + is_external_database_snapshot && test -f "$1/logical-external-database-backup-sentinel" +} + prompt_for_confirmation(){ echo "$1" printf "Type 'yes' to continue: " diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 154fac3c2..7e3fd57e3 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -16,8 +16,8 @@ bm_start "$(basename $0)" ghe_remote_version_required "$GHE_HOSTNAME" if is_external_database_target; then - echo "Backing up external MySQL database using customer-provided script..." if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then + echo "Backing up external MySQL database using customer-provided script..." $EXTERNAL_DATABASE_BACKUP_SCRIPT bm_end "$(basename $0)" exit 0 diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 4d05cec52..21dc01144 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -35,18 +35,24 @@ if is_external_database_snapshot; then bm_end "$(basename $0)" exit 0 else + if is_binary_backup "$snapshot_dir"; then + echo "Error: Restore of a binary backup to appliance with an external database configured is not supported." + echo "Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" + exit 1 + fi + + if ! is_default_external_database_snapshot; then + echo "Error: Backup was not taken with a GitHub provided backup strategy." + echo "You must provide a custom restore script for this backup using EXTERNAL_DATABASE_BACKUP_SCRIPT" + + exit 1 + fi + if is_binary_backup_feature_on; then - if is_binary_backup "$snapshot_dir"; then - echo "Error: Restore of a binary backup to appliance with an external database configured is not supported." - echo "Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" - exit 1 - else - echo "Warning: Binary backups are configured on the target environment." - echo "Binary backups are not supported with an external database configured. Restoring using logical strategy." - echo - echo "Please disable binary backups with 'ghe-config mysql.backup.binary false', or" - echo "provide a custom restore script using EXTERNAL_DATABASE_BACKUP_SCRIPT" - fi + echo "Warning: Binary backups are configured on the target environment." + echo "Binary backup is not supported with an external MySQL database." + echo + echo "Please disable binary backups with 'ghe-config mysql.backup.binary false'" fi fi fi @@ -64,7 +70,7 @@ else echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 else - if is_external_database_snapshot; then + if is_default_external_database_snapshot; then ghe-restore-mysql-logical $GHE_HOSTNAME else # legacy mode From f30c043f86f32831145c4dca9ae98b87488e429d Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Wed, 15 Jul 2020 18:36:07 +0000 Subject: [PATCH 1203/2421] add note about ghe-restore-mysql-legacy file --- share/github-backup-utils/ghe-restore-mysql-legacy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-mysql-legacy b/share/github-backup-utils/ghe-restore-mysql-legacy index 8678be596..e3fa615f1 100755 --- a/share/github-backup-utils/ghe-restore-mysql-legacy +++ b/share/github-backup-utils/ghe-restore-mysql-legacy @@ -4,6 +4,9 @@ #/ #/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-restore command when the rsync strategy is used. + +# Note: Remove this file after 2.22 releases. + set -e # Bring in the backup configuration From 955937082bc17ac20fc04af014e6cddc66a76c76 Mon Sep 17 00:00:00 2001 From: Julio Barba Date: Mon, 20 Jul 2020 18:00:02 +0000 Subject: [PATCH 1204/2421] Add a reminder to restart/reconfigure runners on restore --- bin/ghe-restore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index a1c38aff4..4a5ba63ab 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -306,6 +306,8 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 + echo "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." + echo " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi commands=(" From d0bfbf9c78467f5ded88b880137c61336b1fad46 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Fri, 17 Jul 2020 18:38:01 +0000 Subject: [PATCH 1205/2421] Fail restore if snapshot contains Actions data but Actions is disabled on the appliance --- bin/ghe-restore | 8 ++++++++ test/test-ghe-backup.sh | 1 + test/test-ghe-restore.sh | 20 +++++++++++++++++++- test/testlib.sh | 24 +++++++++++++++++++----- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index a1c38aff4..4d9b73241 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -226,6 +226,14 @@ if $instance_configured; then fi fi +# Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data. +if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then + if ! ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 + exit 1 + fi +fi + # Create benchmark file bm_init > /dev/null diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 21b46a772..7569cc2ca 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -343,6 +343,7 @@ end_test GHE_MSSQL_BACKUP_CADENCE=10,5,1 export GHE_MSSQL_BACKUP_CADENCE +setup_actions_test_data $GHE_REMOTE_DATA_USER_DIR begin_test "ghe-backup takes full backup on first run" ( diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index ea9549358..8dd256b91 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -280,6 +280,9 @@ begin_test "ghe-restore with no pages backup" ) end_test +# Setup Actions data for the subsequent tests +setup_actions_test_data "$GHE_DATA_DIR/1" + begin_test "ghe-restore invokes ghe-import-mssql" ( set -e @@ -363,7 +366,7 @@ begin_test "ghe-restore with Actions settings" ) end_test -begin_test "ghe-restore with Actions files" +begin_test "ghe-restore with Actions data" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -380,6 +383,21 @@ begin_test "ghe-restore with Actions files" ) end_test +begin_test "ghe-restore fails if Actions is disabled but the snapshot contains Actions data" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + setup_maintenance_mode "configured" + + ! ghe-restore -v -f localhost +) +end_test + +# Delete Actions test data from subsequent tests +cleanup_actions_test_data "$GHE_DATA_DIR/1" + begin_test "ghe-restore cluster backup to non-cluster appliance" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index 66f47c79b..632492f42 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -303,10 +303,6 @@ setup_test_data () { if ! $SKIP_MYSQL; then echo "fake ghe-export-mysql data" | gzip > "$loc/mysql.sql.gz" fi - mkdir -p "$loc/mssql" - echo "fake ghe-export-mssql full data" > "$loc/mssql/mssql.bak" - echo "fake ghe-export-mssql diff data" > "$loc/mssql/mssql.diff" - echo "fake ghe-export-mssql tran data" > "$loc/mssql/mssql.log" echo "fake ghe-export-redis data" > "$loc/redis.rdb" echo "fake ghe-export-authorized-keys data" > "$loc/authorized-keys.json" echo "fake ghe-export-ssh-host-keys data" > "$TRASHDIR/ssh-host-keys" @@ -317,6 +313,17 @@ setup_test_data () { echo "fake password hash data" > "$loc/manage-password" echo "rsync" > "$loc/strategy" echo "$GHE_REMOTE_VERSION" > "$loc/version" + fi +} + +setup_actions_test_data() { + local loc=$1 + + if [ "$loc" != "$GHE_REMOTE_DATA_USER_DIR" ]; then + mkdir -p "$loc/mssql" + echo "fake ghe-export-mssql full data" > "$loc/mssql/mssql.bak" + echo "fake ghe-export-mssql diff data" > "$loc/mssql/mssql.diff" + echo "fake ghe-export-mssql tran data" > "$loc/mssql/mssql.log" else mkdir -p "$loc/mssql/backups" echo "fake mssql full data" > "$loc/mssql/backups/mssql.bak" @@ -324,13 +331,20 @@ setup_test_data () { echo "fake mssql tran data" > "$loc/mssql/backups/mssql.log" fi - # Setup fake actions data + # Setup fake Actions data mkdir -p "$loc/actions/certificates" mkdir -p "$loc/actions/states" echo "fake actions certificate" > "$loc/actions/certificates/cert.cer" echo "fake actions state file" > "$loc/actions/states/actions_state" } +cleanup_actions_test_data() { + local loc=$1 + + rm -rf "$loc/mssql" + rm -rf "$loc/actions" +} + # A unified method to check everything backed up or restored during testing. # Everything tested here should pass regardless of whether we're testing a backup # or a restore. From d3b5c1446b7e7ebb1d300c201815d9960f6d02ce Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 22 Jul 2020 11:01:59 -0500 Subject: [PATCH 1206/2421] Fix comment Co-authored-by: Ray Xu --- test/test-ghe-restore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 8dd256b91..063c77e08 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -395,7 +395,7 @@ begin_test "ghe-restore fails if Actions is disabled but the snapshot contains A ) end_test -# Delete Actions test data from subsequent tests +# Delete Actions test data before subsequent tests cleanup_actions_test_data "$GHE_DATA_DIR/1" begin_test "ghe-restore cluster backup to non-cluster appliance" From 23e7eb3dcbf637ea5254d7043ad517c072c28ea5 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 22 Jul 2020 19:46:44 +0000 Subject: [PATCH 1207/2421] Set permissions on actions files before restore --- share/github-backup-utils/ghe-restore-actions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 2f83f51a6..cf587ab9a 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -37,7 +37,7 @@ ghe_remote_version_required "$host" # Transfer all Actions data from the snapshot to the user data directory using rsync. ghe_verbose "* Transferring actions files to $host ..." -echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions" | +echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions && sudo chown -R actions:actions $GHE_REMOTE_DATA_USER_DIR/actions" | ghe-ssh -p $port $host /bin/bash ghe-rsync -arvHR --delete \ From 0fc99359c9410624deba9067fc47af8d9df5eb5b Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 22 Jul 2020 20:09:38 +0000 Subject: [PATCH 1208/2421] Purge parallel so Ubuntu uses moreutils --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b3fd0641..6ba962563 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,7 @@ jobs: - name: Install Dependencies (Linux) run: | sudo apt-get update -y + sudo apt-get --purge remove parallel sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" From 845e2d5a693fcf6af590abcb606f7718afae409d Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 22 Jul 2020 21:17:42 +0000 Subject: [PATCH 1209/2421] Ensure restore can remove existing content in actions folder --- share/github-backup-utils/ghe-restore-actions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index cf587ab9a..27324463d 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -37,8 +37,8 @@ ghe_remote_version_required "$host" # Transfer all Actions data from the snapshot to the user data directory using rsync. ghe_verbose "* Transferring actions files to $host ..." -echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions && sudo chown -R actions:actions $GHE_REMOTE_DATA_USER_DIR/actions" | -ghe-ssh -p $port $host /bin/bash +ghe-ssh -p $port $host -- sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions +ghe-ssh -p $port $host -- sudo chown -R actions:actions $GHE_REMOTE_DATA_USER_DIR/actions ghe-rsync -arvHR --delete \ -e "ghe-ssh -p $port" \ From 4d6e45a508d9456ab61c200cf00f5be12ad6fb58 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 22 Jul 2020 20:07:05 -0500 Subject: [PATCH 1210/2421] Update .github/workflows/main.yml Co-authored-by: Ray Xu --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ba962563..376bdab1f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - name: Install Dependencies (Linux) run: | sudo apt-get update -y - sudo apt-get --purge remove parallel + sudo apt-get purge parallel sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" From f5ea799772a0bb55561504070b87db4526867184 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Thu, 23 Jul 2020 01:21:47 +0000 Subject: [PATCH 1211/2421] Fix shellcheck errors --- share/github-backup-utils/ghe-restore-actions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 27324463d..4513ed3ce 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -37,8 +37,8 @@ ghe_remote_version_required "$host" # Transfer all Actions data from the snapshot to the user data directory using rsync. ghe_verbose "* Transferring actions files to $host ..." -ghe-ssh -p $port $host -- sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions -ghe-ssh -p $port $host -- sudo chown -R actions:actions $GHE_REMOTE_DATA_USER_DIR/actions +ghe-ssh -p "$port" "$host" -- sudo mkdir -p "$GHE_REMOTE_DATA_USER_DIR/actions" +ghe-ssh -p "$port" "$host" -- sudo chown -R actions:actions "$GHE_REMOTE_DATA_USER_DIR/actions" ghe-rsync -arvHR --delete \ -e "ghe-ssh -p $port" \ From bb4fab12178c2d842d3e88377f288e0927cebf81 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Thu, 23 Jul 2020 19:26:11 +0000 Subject: [PATCH 1212/2421] Always restore Actions settings --- share/github-backup-utils/ghe-backup-actions | 2 +- share/github-backup-utils/ghe-backup-config | 10 +++++++ share/github-backup-utils/ghe-restore-actions | 29 +++++++++++++++++-- .../github-backup-utils/ghe-restore-settings | 28 ------------------ test/test-ghe-backup.sh | 2 +- test/test-ghe-restore.sh | 2 +- 6 files changed, 39 insertions(+), 34 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index 3e3013b0a..1c5149a40 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -37,7 +37,7 @@ if [ -d "$GHE_DATA_DIR/current/actions" ] && [ "$(ls -A $GHE_DATA_DIR/current/ac fi # Transfer all Actions data from the user data directory using rsync. -ghe_verbose "* Transferring actions files from $host ..." +ghe_verbose "* Transferring Actions files from $host ..." ghe-rsync -avz \ -e "ghe-ssh -p $port" \ diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 9674e0c29..64d4d17dd 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -477,3 +477,13 @@ prompt_for_confirmation(){ echo } + +# Function to restore a secret setting stored in a file. +# restore-secret +restore-secret() { + if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then + echo "Restoring $1 ..." + echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash + fi +} diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 2f83f51a6..25e33baf5 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -22,11 +22,14 @@ GHE_HOSTNAME="$1" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} +# Path to snapshot dir we're restoring from +GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") # No need to restore anything, early exit -if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions" ]; then +if [ ! -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then echo "Warning: Actions backup missing. Skipping ..." exit 0 fi @@ -35,7 +38,7 @@ fi ghe_remote_version_required "$host" # Transfer all Actions data from the snapshot to the user data directory using rsync. -ghe_verbose "* Transferring actions files to $host ..." +ghe_verbose "* Transferring Actions files to $host ..." echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions" | ghe-ssh -p $port $host /bin/bash @@ -43,7 +46,27 @@ ghe-ssh -p $port $host /bin/bash ghe-rsync -arvHR --delete \ -e "ghe-ssh -p $port" \ --rsync-path='sudo -u actions rsync' \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions/./" \ + "$GHE_RESTORE_SNAPSHOT_PATH/actions/./" \ "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" 1>&3 +# Restore Actions settings. +ghe_verbose "* Restoring Actions settings to $host ..." + +restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" +restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" +restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" +restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" +restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" +restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" +restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" +restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" +restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" +restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" +restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" +restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" +restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" +restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" +restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" +restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" + bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index dcff624ee..5e90e863d 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -28,39 +28,11 @@ GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" echo "Restoring license ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 -# Function to restore a secret setting stored in a file. -# restore-secret -restore-secret() { - if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then - echo "Restoring $1 ..." - echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash - fi -} - echo "Restoring settings ..." # Restore external MySQL password if running external MySQL DB. restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" -# Restore Actions settings. -restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" -restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" -restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" -restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" -restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" -restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" -restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" -restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" -restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" -restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" -restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" -restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" -restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" -restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" -restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" -restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" - # work around issue importing settings with bad storage mode values ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 7569cc2ca..9e9a68a3b 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -490,7 +490,7 @@ begin_test "ghe-backup takes backup of Actions files" enable_actions output=$(ghe-backup -v) - echo $output | grep "Transferring actions files from" + echo $output | grep "Transferring Actions files from" diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 063c77e08..f8a848b49 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -377,7 +377,7 @@ begin_test "ghe-restore with Actions data" output=$(ghe-restore -v -f localhost 2>&1) - echo "$output" | grep -q "Transferring actions files to" + echo "$output" | grep -q "Transferring Actions files to" diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) From c60f08f4e8da64f10b42b9192c154fe5150bbc78 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Thu, 23 Jul 2020 19:27:48 +0000 Subject: [PATCH 1213/2421] Revert "Always restore Actions settings" This reverts commit bb4fab12178c2d842d3e88377f288e0927cebf81. --- share/github-backup-utils/ghe-backup-actions | 2 +- share/github-backup-utils/ghe-backup-config | 10 ------- share/github-backup-utils/ghe-restore-actions | 29 ++----------------- .../github-backup-utils/ghe-restore-settings | 28 ++++++++++++++++++ test/test-ghe-backup.sh | 2 +- test/test-ghe-restore.sh | 2 +- 6 files changed, 34 insertions(+), 39 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index 1c5149a40..3e3013b0a 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -37,7 +37,7 @@ if [ -d "$GHE_DATA_DIR/current/actions" ] && [ "$(ls -A $GHE_DATA_DIR/current/ac fi # Transfer all Actions data from the user data directory using rsync. -ghe_verbose "* Transferring Actions files from $host ..." +ghe_verbose "* Transferring actions files from $host ..." ghe-rsync -avz \ -e "ghe-ssh -p $port" \ diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 64d4d17dd..9674e0c29 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -477,13 +477,3 @@ prompt_for_confirmation(){ echo } - -# Function to restore a secret setting stored in a file. -# restore-secret -restore-secret() { - if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then - echo "Restoring $1 ..." - echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash - fi -} diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 25e33baf5..2f83f51a6 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -22,14 +22,11 @@ GHE_HOSTNAME="$1" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} -# Path to snapshot dir we're restoring from -GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" - port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") # No need to restore anything, early exit -if [ ! -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then +if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions" ]; then echo "Warning: Actions backup missing. Skipping ..." exit 0 fi @@ -38,7 +35,7 @@ fi ghe_remote_version_required "$host" # Transfer all Actions data from the snapshot to the user data directory using rsync. -ghe_verbose "* Transferring Actions files to $host ..." +ghe_verbose "* Transferring actions files to $host ..." echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions" | ghe-ssh -p $port $host /bin/bash @@ -46,27 +43,7 @@ ghe-ssh -p $port $host /bin/bash ghe-rsync -arvHR --delete \ -e "ghe-ssh -p $port" \ --rsync-path='sudo -u actions rsync' \ - "$GHE_RESTORE_SNAPSHOT_PATH/actions/./" \ + "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions/./" \ "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" 1>&3 -# Restore Actions settings. -ghe_verbose "* Restoring Actions settings to $host ..." - -restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" -restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" -restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" -restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" -restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" -restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" -restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" -restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" -restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" -restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" -restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" -restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" -restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" -restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" -restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" -restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" - bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 5e90e863d..dcff624ee 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -28,11 +28,39 @@ GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" echo "Restoring license ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 +# Function to restore a secret setting stored in a file. +# restore-secret +restore-secret() { + if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then + echo "Restoring $1 ..." + echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash + fi +} + echo "Restoring settings ..." # Restore external MySQL password if running external MySQL DB. restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" +# Restore Actions settings. +restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" +restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" +restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" +restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" +restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" +restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" +restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" +restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" +restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" +restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" +restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" +restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" +restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" +restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" +restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" +restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" + # work around issue importing settings with bad storage mode values ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 9e9a68a3b..7569cc2ca 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -490,7 +490,7 @@ begin_test "ghe-backup takes backup of Actions files" enable_actions output=$(ghe-backup -v) - echo $output | grep "Transferring Actions files from" + echo $output | grep "Transferring actions files from" diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index f8a848b49..063c77e08 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -377,7 +377,7 @@ begin_test "ghe-restore with Actions data" output=$(ghe-restore -v -f localhost 2>&1) - echo "$output" | grep -q "Transferring Actions files to" + echo "$output" | grep -q "Transferring actions files to" diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) From 7aa0eca2a0f64d24f3bda6cf7f83021ba3972afe Mon Sep 17 00:00:00 2001 From: ritchxu Date: Thu, 23 Jul 2020 19:26:11 +0000 Subject: [PATCH 1214/2421] Always restore Actions settings --- share/github-backup-utils/ghe-backup-actions | 2 +- share/github-backup-utils/ghe-backup-config | 10 +++++++ share/github-backup-utils/ghe-restore-actions | 29 +++++++++++++++++-- .../github-backup-utils/ghe-restore-settings | 28 ------------------ test/test-ghe-backup.sh | 2 +- test/test-ghe-restore.sh | 2 +- 6 files changed, 39 insertions(+), 34 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index 3e3013b0a..1c5149a40 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -37,7 +37,7 @@ if [ -d "$GHE_DATA_DIR/current/actions" ] && [ "$(ls -A $GHE_DATA_DIR/current/ac fi # Transfer all Actions data from the user data directory using rsync. -ghe_verbose "* Transferring actions files from $host ..." +ghe_verbose "* Transferring Actions files from $host ..." ghe-rsync -avz \ -e "ghe-ssh -p $port" \ diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 9674e0c29..64d4d17dd 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -477,3 +477,13 @@ prompt_for_confirmation(){ echo } + +# Function to restore a secret setting stored in a file. +# restore-secret +restore-secret() { + if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then + echo "Restoring $1 ..." + echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash + fi +} diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 2f83f51a6..25e33baf5 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -22,11 +22,14 @@ GHE_HOSTNAME="$1" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} +# Path to snapshot dir we're restoring from +GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + port=$(ssh_port_part "$GHE_HOSTNAME") host=$(ssh_host_part "$GHE_HOSTNAME") # No need to restore anything, early exit -if [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions" ]; then +if [ ! -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then echo "Warning: Actions backup missing. Skipping ..." exit 0 fi @@ -35,7 +38,7 @@ fi ghe_remote_version_required "$host" # Transfer all Actions data from the snapshot to the user data directory using rsync. -ghe_verbose "* Transferring actions files to $host ..." +ghe_verbose "* Transferring Actions files to $host ..." echo "sudo mkdir -p $GHE_REMOTE_DATA_USER_DIR/actions" | ghe-ssh -p $port $host /bin/bash @@ -43,7 +46,27 @@ ghe-ssh -p $port $host /bin/bash ghe-rsync -arvHR --delete \ -e "ghe-ssh -p $port" \ --rsync-path='sudo -u actions rsync' \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/actions/./" \ + "$GHE_RESTORE_SNAPSHOT_PATH/actions/./" \ "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" 1>&3 +# Restore Actions settings. +ghe_verbose "* Restoring Actions settings to $host ..." + +restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" +restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" +restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" +restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" +restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" +restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" +restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" +restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" +restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" +restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" +restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" +restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" +restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" +restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" +restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" +restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" + bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index dcff624ee..5e90e863d 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -28,39 +28,11 @@ GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" echo "Restoring license ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 -# Function to restore a secret setting stored in a file. -# restore-secret -restore-secret() { - if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then - echo "Restoring $1 ..." - echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash - fi -} - echo "Restoring settings ..." # Restore external MySQL password if running external MySQL DB. restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" -# Restore Actions settings. -restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" -restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" -restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" -restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" -restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" -restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" -restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" -restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" -restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" -restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" -restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" -restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" -restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" -restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" -restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" -restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" - # work around issue importing settings with bad storage mode values ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 7569cc2ca..9e9a68a3b 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -490,7 +490,7 @@ begin_test "ghe-backup takes backup of Actions files" enable_actions output=$(ghe-backup -v) - echo $output | grep "Transferring actions files from" + echo $output | grep "Transferring Actions files from" diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 063c77e08..f8a848b49 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -377,7 +377,7 @@ begin_test "ghe-restore with Actions data" output=$(ghe-restore -v -f localhost 2>&1) - echo "$output" | grep -q "Transferring actions files to" + echo "$output" | grep -q "Transferring Actions files to" diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) From 7d027dbc8a947333e5e53b9da3b8e0ecc2dbb066 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Fri, 24 Jul 2020 20:53:18 +0000 Subject: [PATCH 1215/2421] Repair database logins after restore --- share/github-backup-utils/ghe-restore-actions | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 8fd34d40a..665d4e98a 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -69,4 +69,11 @@ restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" +# Setup the database logins. +ghe_verbose "* Restoring database logins and users to $host ..." + +ghe-ssh -p "$port" "$host" -- ghe-actions-console -s mps -c "Repair-DatabaseLogins" +ghe-ssh -p "$port" "$host" -- ghe-actions-console -s token -c "Repair-DatabaseLogins" +ghe-ssh -p "$port" "$host" -- ghe-actions-console -s actions -c "Repair-DatabaseLogins" + bm_end "$(basename $0)" From fd13034c432d1631796cf4c9b5f951ea5b01d1d6 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Fri, 24 Jul 2020 21:18:03 +0000 Subject: [PATCH 1216/2421] Adds fake for ghe-actions-console --- test/bin/ghe-actions-console | 1 + 1 file changed, 1 insertion(+) create mode 100755 test/bin/ghe-actions-console diff --git a/test/bin/ghe-actions-console b/test/bin/ghe-actions-console new file mode 100755 index 000000000..8a094b360 --- /dev/null +++ b/test/bin/ghe-actions-console @@ -0,0 +1 @@ +ghe-fake-true From d27c68278ecbd00693b99bd5b38e5e103f063e68 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Tue, 28 Jul 2020 21:22:15 -0500 Subject: [PATCH 1217/2421] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 376bdab1f..44c184277 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: sudo apt-get update -y sudo apt-get purge parallel sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz - wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" + wget "https://github.com/koalaman/shellcheck/releases/download/v0.7.0/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck if: matrix.os == 'ubuntu-latest' From 9e0e03223132fbdc796f4e95debf7198c1f7a005 Mon Sep 17 00:00:00 2001 From: Christopher Schleiden Date: Fri, 31 Jul 2020 08:58:16 -0700 Subject: [PATCH 1218/2421] Add launch secrets to backup --- share/github-backup-utils/ghe-backup-settings | 14 ++++++++ share/github-backup-utils/ghe-restore-actions | 17 ++++++++++ test/test-ghe-backup.sh | 34 +++++++++++++++++-- test/test-ghe-restore.sh | 30 ++++++++++++++++ 4 files changed, 93 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 3f069c8d1..e38eb7ad5 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -64,6 +64,20 @@ if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then backup-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" + + backup-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" + backup-secret "Actions Launch credz HMAC key" "actions-launch-credz-hmac" "secrets.launch.credz-hmac-secret" + backup-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" + backup-secret "Actions Launch Client id" "actions-launch-client-id" "secrets.launch.client-id" + backup-secret "Actions Launch Client secret" "actions-launch-client-secret" "secrets.launch.client-secret" + backup-secret "Actions Launch receiver webhook secret" "actions-launch-receiver-webhook-secret" "secrets.launch.receiver-webhook-secret" + backup-secret "Actions Launch app private key" "actions-launch-app-private-key" "secrets.launch.app-private-key" + backup-secret "Actions Launch app public key" "actions-launch-app-public-key" "secrets.launch.app-public-key" + backup-secret "Actions Launch app id" "actions-launch-app-id" "secrets.launch.app-id" + backup-secret "Actions Launch app relay id" "actions-launch-app-relay-id" "secrets.launch.app-relay-id" + backup-secret "Actions Launch action runner secret" "actions-launch-action-runner-secret" "secrets.launch.action-runner-secret" + backup-secret "Actions Launch service cert" "actions-launch-azp-app-cert" "secrets.launch.azp-app-cert" + backup-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" fi if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 665d4e98a..62832b24f 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -69,6 +69,23 @@ restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" +restore-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" +restore-secret "Actions Launch credz HMAC key" "actions-launch-credz-hmac" "secrets.launch.credz-hmac-secret" +restore-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" +restore-secret "Actions Launch Client id" "actions-launch-client-id" "secrets.launch.client-id" +restore-secret "Actions Launch Client secret" "actions-launch-client-secret" "secrets.launch.client-secret" +restore-secret "Actions Launch receiver webhook secret" "actions-launch-receiver-webhook-secret" "secrets.launch.receiver-webhook-secret" +restore-secret "Actions Launch app private key" "actions-launch-app-private-key" "secrets.launch.app-private-key" +restore-secret "Actions Launch app public key" "actions-launch-app-public-key" "secrets.launch.app-public-key" +restore-secret "Actions Launch app id" "actions-launch-app-id" "secrets.launch.app-id" +restore-secret "Actions Launch app relay id" "actions-launch-app-relay-id" "secrets.launch.app-relay-id" +restore-secret "Actions Launch action runner secret" "actions-launch-action-runner-secret" "secrets.launch.action-runner-secret" +restore-secret "Actions Launch service cert" "actions-launch-azp-app-cert" "secrets.launch.azp-app-cert" +restore-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" + +restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" "secrets.launch.token-oauth-key" +restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert" + # Setup the database logins. ghe_verbose "* Restoring database logins and users to $host ..." diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 9e9a68a3b..ff7831f48 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -420,7 +420,7 @@ begin_test "ghe-backup warns if database names mismatched" add_mssql_backup_file "full_mssql_5" 3 "log" output=$(ghe-backup -v || true) - ! echo "$output" | grep -E "Taking .* backup" + ! echo "$output" | grep -E "Taking .* backup" echo "$output" | grep "Warning: Found following 2 backup files" ) end_test @@ -451,6 +451,22 @@ begin_test "ghe-backup takes backup of Actions settings" "secrets.actions.SecondaryEncryptionCertificateThumbprint" "secrets.actions.ServicePrincipalCertificate" "secrets.actions.SpsValidationCertThumbprint" + + "secrets.launch.actions-secrets-private-key" + "secrets.launch.credz-hmac-secret" + "secrets.launch.deployer-hmac-secret" + "secrets.launch.client-id" + "secrets.launch.client-secret" + "secrets.launch.receiver-webhook-secret" + "secrets.launch.app-private-key" + "secrets.launch.app-public-key" + "secrets.launch.app-id" + "secrets.launch.app-relay-id" + "secrets.launch.action-runner-secret" + "secrets.launch.token-oauth-key" + "secrets.launch.token-oauth-cert" + "secrets.launch.azp-app-cert" + "secrets.launch.azp-app-private-key" ) for secret in "${required_secrets[@]}"; do @@ -476,6 +492,20 @@ begin_test "ghe-backup takes backup of Actions settings" "actions-secondary-encryption-cert-thumbprint" "actions-service-principal-cert" "actions-sps-validation-cert-thumbprint" + + "actions-launch-secrets-private-key" + "actions-launch-credz-hmac" + "actions-launch-deployer-hmac" + "actions-launch-client-id" + "actions-launch-client-secret" + "actions-launch-receiver-webhook-secret" + "actions-launch-app-private-key" + "actions-launch-app-public-key" + "actions-launch-app-id" + "actions-launch-app-relay-id" + "actions-launch-action-runner-secret" + "actions-launch-azp-app-cert" + "actions-launch-app-app-private-key" ) for file in "${required_files[@]}"; do @@ -491,7 +521,7 @@ begin_test "ghe-backup takes backup of Actions files" output=$(ghe-backup -v) echo $output | grep "Transferring Actions files from" - + diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" ) end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index f8a848b49..3121ee545 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -333,6 +333,20 @@ begin_test "ghe-restore with Actions settings" "actions-secondary-encryption-cert-thumbprint" "actions-service-principal-cert" "actions-sps-validation-cert-thumbprint" + + "actions-launch-secrets-private-key" + "actions-launch-credz-hmac" + "actions-launch-deployer-hmac" + "actions-launch-client-id" + "actions-launch-client-secret" + "actions-launch-receiver-webhook-secret" + "actions-launch-app-private-key" + "actions-launch-app-public-key" + "actions-launch-app-id" + "actions-launch-app-relay-id" + "actions-launch-action-runner-secret" + "actions-launch-azp-app-cert" + "actions-launch-app-app-private-key" ) for file in "${required_files[@]}"; do @@ -358,6 +372,22 @@ begin_test "ghe-restore with Actions settings" "secrets.actions.SecondaryEncryptionCertificateThumbprint" "secrets.actions.ServicePrincipalCertificate" "secrets.actions.SpsValidationCertThumbprint" + + "secrets.launch.actions-secrets-private-key" + "secrets.launch.credz-hmac-secret" + "secrets.launch.deployer-hmac-secret" + "secrets.launch.client-id" + "secrets.launch.client-secret" + "secrets.launch.receiver-webhook-secret" + "secrets.launch.app-private-key" + "secrets.launch.app-public-key" + "secrets.launch.app-id" + "secrets.launch.app-relay-id" + "secrets.launch.action-runner-secret" + "secrets.launch.token-oauth-key" + "secrets.launch.token-oauth-cert" + "secrets.launch.azp-app-cert" + "secrets.launch.azp-app-private-key" ) for secret in "${required_secrets[@]}"; do From e86484d92a30d70b6aa3c40b482d582da6cfd841 Mon Sep 17 00:00:00 2001 From: John Claus Date: Sat, 1 Aug 2020 11:28:16 -0600 Subject: [PATCH 1219/2421] Added basic timing around the ghe-restore process --- bin/ghe-restore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 87f3acb18..f9e574b3a 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -174,6 +174,8 @@ if $instance_configured && ! $force; then fi # Log restore start message locally and in /var/log/syslog on remote instance +START_TIME=$(date +%s) +echo 'Start time:' $START_TIME echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." @@ -400,6 +402,10 @@ else ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi +END_TIME=$(date +%s) +echo 'End time:' $END_TIME +echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' + echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." if ! $instance_configured; then From 9b93037572fc2de2957ca936f1f99a4d526f6f1e Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Tue, 4 Aug 2020 16:55:35 +0000 Subject: [PATCH 1220/2421] add PR to actions trigger --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fa0475149..a0e20e432 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ name: Test and build -on: [push] +on: [push, pull_request] jobs: build: From 7918f34841ed8125cc60bcc1b30b4c744d9c1f33 Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Tue, 4 Aug 2020 17:15:44 +0000 Subject: [PATCH 1221/2421] use only pull_request trigger for CI actions --- .github/workflows/lint.yml | 2 +- .github/workflows/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f7f72df90..be36955c0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,7 @@ name: Lint Code Base on: - push: + pull_reqeust: branches-ignore: - 'master' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a0e20e432..e4bd39880 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ name: Test and build -on: [push, pull_request] +on: [pull_request] jobs: build: From e0a08726defb494417cf6de231aeb533a57ee11e Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Tue, 4 Aug 2020 17:25:29 +0000 Subject: [PATCH 1222/2421] update shellcheck location --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e4bd39880..9ff7964f3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz - wget "https://storage.googleapis.com/shellcheck/shellcheck-v0.7.0.linux.x86_64.tar.xz" + wget "https://github.com/koalaman/shellcheck/releases/download/v0.7.0/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck if: matrix.os == 'ubuntu-latest' From 0331e9edbb14b8de8c74749497c907cac313409d Mon Sep 17 00:00:00 2001 From: Evgenii Khramkov Date: Tue, 4 Aug 2020 10:26:03 -0700 Subject: [PATCH 1223/2421] Update .github/workflows/lint.yml Co-authored-by: Katie Simmons --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index be36955c0..4a38ba869 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,7 +1,7 @@ name: Lint Code Base on: - pull_reqeust: + pull_request: branches-ignore: - 'master' From 0c6642cc442dabf30098839e52577943a4f7904a Mon Sep 17 00:00:00 2001 From: John Claus Date: Tue, 4 Aug 2020 13:28:58 -0600 Subject: [PATCH 1224/2421] Bump --- bin/ghe-restore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index f9e574b3a..17749e12b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -411,3 +411,4 @@ echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." if ! $instance_configured; then echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." fi + From a4fe8f842e000230ec57d5efd53bdedea877f77a Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Mon, 17 Aug 2020 09:30:09 -0700 Subject: [PATCH 1225/2421] added a wait for mysql via haproxy after external restore script --- share/github-backup-utils/ghe-restore-mysql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 21dc01144..4f7a43893 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -32,6 +32,11 @@ snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" if is_external_database_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT + # ensure that haproxy and mysql are accepting connections before continuining + if ! ghe-ssh "$GHE_HOSTNAME" -- /usr/local/share/enterprise/ghe-service-wait-mysql; then + error_message "Failed to connect to MySQL service!" + exit 2 + fi bm_end "$(basename $0)" exit 0 else From dbffdeed002ed3f27a537d2c2769b6831e684b9c Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Mon, 17 Aug 2020 10:29:46 -0700 Subject: [PATCH 1226/2421] added quotes around call to ghe-service-wait-mysql --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 4f7a43893..6c0a0499b 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -33,7 +33,7 @@ if is_external_database_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT # ensure that haproxy and mysql are accepting connections before continuining - if ! ghe-ssh "$GHE_HOSTNAME" -- /usr/local/share/enterprise/ghe-service-wait-mysql; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-service-wait-mysql"; then error_message "Failed to connect to MySQL service!" exit 2 fi From 0e54e3604a7e1c4173fd0cf2c01ea89c5de7aab7 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Mon, 17 Aug 2020 10:30:30 -0700 Subject: [PATCH 1227/2421] Update share/github-backup-utils/ghe-restore-mysql Co-authored-by: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> --- share/github-backup-utils/ghe-restore-mysql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 6c0a0499b..9b368d94c 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -32,7 +32,7 @@ snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" if is_external_database_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT - # ensure that haproxy and mysql are accepting connections before continuining + # ensure that haproxy and mysql are ready to accept connections before continuing if ! ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-service-wait-mysql"; then error_message "Failed to connect to MySQL service!" exit 2 From bb2f1b5723895e4992a40c7b5e95b1d035270163 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Mon, 17 Aug 2020 10:35:17 -0700 Subject: [PATCH 1228/2421] stubbed ghe-service-wait-mysql and fixed typo in other test file --- test/bin/ghe-es-snapshot | 2 +- test/bin/ghe-service-wait-mysql | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100755 test/bin/ghe-service-wait-mysql diff --git a/test/bin/ghe-es-snapshot b/test/bin/ghe-es-snapshot index a7991564b..eb27be1ca 100755 --- a/test/bin/ghe-es-snapshot +++ b/test/bin/ghe-es-snapshot @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Usage: ghe-es-snapshot -# Emulates the remote GitHub ghe-service-ensure-mysql command. Tests use this +# Emulates the remote GitHub ghe-service-es-mysql command. Tests use this # to assert that the command was executed. set -e echo "ghe-es-snapshot OK" diff --git a/test/bin/ghe-service-wait-mysql b/test/bin/ghe-service-wait-mysql new file mode 100755 index 000000000..6706020fa --- /dev/null +++ b/test/bin/ghe-service-wait-mysql @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# Usage: ghe-service-wait-mysql +# Emulates the remote GitHub ghe-service-wait-mysql command. Tests use this +# to assert that the command was executed. +set -e +echo "ghe-service-wait-mysql OK" From 75154a7e2fd9f8b4617ae349b321d52cfce4ec9c Mon Sep 17 00:00:00 2001 From: Courtney Oka Date: Mon, 17 Aug 2020 17:39:06 -0400 Subject: [PATCH 1229/2421] formatting + shellcheck --- share/github-backup-utils/ghe-backup-config | 63 ++++++++++----------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 176ecdc17..e7bd731fd 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -15,10 +15,10 @@ # # Assume this script lives in share/github-backup-utils/ when setting the root -GHE_BACKUP_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" +GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" # Get the version from the version file. -BACKUP_UTILS_VERSION="$(cat $GHE_BACKUP_ROOT/share/github-backup-utils/version)" +BACKUP_UTILS_VERSION="$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/version")" # If a version check was requested, show the current version and exit if [ -n "$GHE_SHOW_VERSION" ]; then @@ -28,9 +28,9 @@ fi # Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage # shellcheck disable=SC2120 # the script name is always referenced -print_usage () { +print_usage() { grep '^#/' <"$0" | cut -c 4- - exit ${1:-1} + exit "${1:-1}" } if [ -n "$GHE_SHOW_HELP" ]; then @@ -46,7 +46,7 @@ fi # Add the bin and share/github-backup-utils dirs to PATH PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # shellcheck source=share/github-backup-utils/bm.sh -. $GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh +. "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" # Save off GHE_HOSTNAME from the environment since we want it to override the # backup.config value when set. @@ -87,7 +87,7 @@ ghe_parallel_check() { GHE_PARALLEL_COMMAND_OPTIONS="-j $GHE_PARALLEL_MAX_JOBS" # Default to the number of max rsync jobs to the same as GHE_PARALLEL_MAX_JOBS, if not set. # This is only applicable to ghe-restore-repositories currently. - : ${GHE_PARALLEL_RSYNC_MAX_JOBS:="$GHE_PARALLEL_MAX_JOBS"} + : "${GHE_PARALLEL_RSYNC_MAX_JOBS:="$GHE_PARALLEL_MAX_JOBS"}" fi if [ -n "$GHE_PARALLEL_RSYNC_MAX_JOBS" ]; then @@ -115,14 +115,14 @@ fi if [ -n "$GHE_VERBOSE" ]; then if [ -n "$GHE_VERBOSE_LOG" ]; then if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then - exec 3>> "$GHE_VERBOSE_LOG" + exec 3>>"$GHE_VERBOSE_LOG" else if ! echo | awk '{ print strftime("%b %d %H:%M:%S"); fflush(); }' &>/dev/null; then echo "Error: awk command failed. Please install https://www.gnu.org/software/gawk" 1>&2 exit 1 fi calling_script_name="$(caller | sed 's:.*/::')" - exec 3> >(awk -v c=$calling_script_name '{ print strftime("%b %d %H:%M:%S"), c":", $0; fflush(); }' >> "$GHE_VERBOSE_LOG") + exec 3> >(awk -v c="$calling_script_name" '{ print strftime("%b %d %H:%M:%S"), c":", $0; fflush(); }' >>"$GHE_VERBOSE_LOG") fi else exec 3>&1 @@ -149,12 +149,12 @@ fi # Convert the data directory path to an absolute path, basing any relative # paths on the backup-utils root, and using readlink, if available, to # canonicalize the path. -if [ ${GHE_DATA_DIR:0:1} != "/" ]; then - GHE_DATA_DIR="$( cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR" 2> /dev/null || echo "$GHE_BACKUP_ROOT/$GHE_DATA_DIR" )" +if [ "${GHE_DATA_DIR:0:1}" != "/" ]; then + GHE_DATA_DIR="$(cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR" 2>/dev/null || echo "$GHE_BACKUP_ROOT/$GHE_DATA_DIR")" fi # Assign the Release File path if it hasn't been provided (eg: by test suite) -: ${GHE_RELEASE_FILE:="/etc/github/enterprise-release"} +: "${GHE_RELEASE_FILE:="/etc/github/enterprise-release"}" # Check that utils are not being run directly on GHE appliance. if [ -f "$GHE_RELEASE_FILE" ]; then @@ -238,7 +238,7 @@ export GHE_SNAPSHOT_DIR # Adjusts remote paths based on the version of the remote appliance. This is # called immediately after the remote version is obtained by # ghe_remote_version_required(). Child processes inherit the values set here. -ghe_remote_version_config () { +ghe_remote_version_config() { GHE_REMOTE_DATA_USER_DIR="$GHE_REMOTE_DATA_DIR/user" export GHE_REMOTE_DATA_DIR GHE_REMOTE_DATA_USER_DIR export GHE_REMOTE_LICENSE_FILE @@ -249,7 +249,7 @@ ghe_remote_version_config () { # If we don't have a readlink command, parse ls -l output. if ! type readlink 1>/dev/null 2>&1; then - readlink () { + readlink() { if [ -x "$1" ]; then ls -ld "$1" | sed 's/.*-> //' else @@ -264,7 +264,7 @@ fi # that need the remote version should use this function instead of calling # ghe-host-check directly to reduce ssh roundtrips. The top-level ghe-backup and # ghe-restore commands establish the version for all subcommands. -ghe_remote_version_required () { +ghe_remote_version_required() { if [ -z "$GHE_REMOTE_VERSION" ]; then _out=$(ghe-host-check "$@") echo "$_out" @@ -287,8 +287,8 @@ ghe_remote_version_required () { ghe_parse_version() { local version_major version_minor version_patch version_major=$(echo "${1#v}" | cut -f 1 -d .) - version_minor=$(echo "$1" | cut -f 2 -d .) - version_patch=$(echo "$1" | cut -f 3 -d .) + version_minor=$(echo "$1" | cut -f 2 -d .) + version_patch=$(echo "$1" | cut -f 3 -d .) version_patch=${version_patch%%[a-zA-Z]*} echo "$version_major $version_minor $version_patch" @@ -300,7 +300,7 @@ ghe_parse_version() { # # Scripts use these variables to alter behavior based on what's supported on the # appliance version. -ghe_parse_remote_version () { +ghe_parse_remote_version() { # shellcheck disable=SC2046 # Word splitting is required to populate the variables read -r GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH <<<$(ghe_parse_version $1) export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH @@ -309,23 +309,23 @@ ghe_parse_remote_version () { # Parses the part out of a ":" or just "" string. # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. -ssh_host_part () { +ssh_host_part() { [ "${1##*:}" = "$1" ] && echo "$1" || echo "${1%:*}" } # Parses the part out of a ":" or just "" string. # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. -ssh_port_part () { +ssh_port_part() { [ "${1##*:}" = "$1" ] && echo 22 || echo "${1##*:}" } # Usage: ghe_remote_logger ... # Log a message to /var/log/syslog on the remote instance. # Note: Use sparingly. Remote logging requires an ssh connection per invocation. -ghe_remote_logger () { +ghe_remote_logger() { echo "$@" | - ghe-ssh "$GHE_HOSTNAME" -- logger -t backup-utils || true + ghe-ssh "$GHE_HOSTNAME" -- logger -t backup-utils || true } # Usage: ghe_verbose @@ -345,15 +345,14 @@ ghe_debug() { echo -e "Debug: $*" 1>&3 elif [ -p /dev/stdin ]; then echo "\n" 1>&3 - while read line - do + while read line; do echo -e "Debug: $line" 1>&3 - done < /dev/stdin + done Date: Tue, 18 Aug 2020 17:54:07 +0000 Subject: [PATCH 1230/2421] turn off posix --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 176ecdc17..7bbd10b38 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -13,7 +13,7 @@ # # . $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config # - +set +o posix # Assume this script lives in share/github-backup-utils/ when setting the root GHE_BACKUP_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )" From c429a46f0b90e038d285e968f4ceaf7ed768016a Mon Sep 17 00:00:00 2001 From: Logan MacLaren Date: Tue, 8 Sep 2020 13:46:41 -0400 Subject: [PATCH 1231/2421] Adding parallelized restore capability to ghe-restore-storage. --- share/github-backup-utils/ghe-restore-storage | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 292db7659..a890ca741 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -11,6 +11,9 @@ set -e # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +# Check to make sure moreutils parallel is installed and working properly +ghe_parallel_check + # Show usage and bail with no arguments [ -z "$*" ] && print_usage @@ -128,17 +131,32 @@ for file_list in $tempdir/*.rsync; do else server=$host fi + storage_user=$(ghe-ssh $ssh_config_file_opt $server:$port -- stat -c %U /data/user/storage || echo git) - ghe_verbose "* Transferring data to $server ..." + rsync_commands+=(" + if [ -n \"$GHE_VERBOSE\" ]; then + echo \"* Transferring data to $server ...\" 1>&3 + fi + ghe-rsync -arvHR --delete \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - --rsync-path="sudo -u $storage_user rsync" \ + -e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \ + --rsync-path=\"sudo -u $storage_user rsync\" \ --files-from=$file_list \ --size-only \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./" \ - "$server:$GHE_REMOTE_DATA_USER_DIR/storage/" 1>&3 + \"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./\" \ + \"$server:$GHE_REMOTE_DATA_USER_DIR/storage/\" 1>&3 + ") done + +if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then + $GHE_PARALLEL_COMMAND $GHE_PARALLEL_RSYNC_COMMAND_OPTIONS -- "${rsync_commands[@]}" +else + for c in "${rsync_commands[@]}"; do + eval "$c" + done +fi + bm_end "$(basename $0) - Restoring objects" if $CLUSTER; then From c01f12e212fe2764abfbdd73475a0cc0559d1e01 Mon Sep 17 00:00:00 2001 From: Javier Li Sam Date: Wed, 16 Sep 2020 13:08:20 -0700 Subject: [PATCH 1232/2421] Replace redis-cli with ghe-redis-cli --- share/github-backup-utils/ghe-backup-redis | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index 2e7d7dfd4..7259488dd 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -22,21 +22,21 @@ ghe-ssh "$GHE_HOSTNAME" /bin/bash </dev/null || echo "localhost") - timestamp=\$(redis-cli -h \$redis_host LASTSAVE) + timestamp=\$(ghe-redis-cli -h \$redis_host LASTSAVE) for i in \$(seq 10); do - if ! redis-cli -h \$redis_host BGSAVE | grep -q ERR; then + if ! ghe-redis-cli -h \$redis_host BGSAVE | grep -q ERR; then break fi sleep 15 done for n in \$(seq 3600); do - if [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then + if [ "\$(ghe-redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then break fi sleep 1 done - [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work + [ "\$(ghe-redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work if [ "\$redis_host" != "localhost" ]; then ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' From 52538d97ee885784d8aba76834d62eceee29f8ec Mon Sep 17 00:00:00 2001 From: Javier Li Sam Date: Fri, 18 Sep 2020 11:11:32 -0700 Subject: [PATCH 1233/2421] Rename redis-cli to ghe-redis-cli --- share/github-backup-utils/ghe-backup-redis | 8 ++++---- test/bin/{redis-cli => ghe-redis-cli} | 0 2 files changed, 4 insertions(+), 4 deletions(-) rename test/bin/{redis-cli => ghe-redis-cli} (100%) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index 2e7d7dfd4..7259488dd 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -22,21 +22,21 @@ ghe-ssh "$GHE_HOSTNAME" /bin/bash </dev/null || echo "localhost") - timestamp=\$(redis-cli -h \$redis_host LASTSAVE) + timestamp=\$(ghe-redis-cli -h \$redis_host LASTSAVE) for i in \$(seq 10); do - if ! redis-cli -h \$redis_host BGSAVE | grep -q ERR; then + if ! ghe-redis-cli -h \$redis_host BGSAVE | grep -q ERR; then break fi sleep 15 done for n in \$(seq 3600); do - if [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then + if [ "\$(ghe-redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then break fi sleep 1 done - [ "\$(redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work + [ "\$(ghe-redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work if [ "\$redis_host" != "localhost" ]; then ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' diff --git a/test/bin/redis-cli b/test/bin/ghe-redis-cli similarity index 100% rename from test/bin/redis-cli rename to test/bin/ghe-redis-cli From ede6c7e27803b51cdc8c81482ff3aeb2a5b03360 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sun, 2 Aug 2020 22:58:11 -0700 Subject: [PATCH 1234/2421] test/bin/python: support Python3 Signed-off-by: Robin H. Johnson --- test/bin/python | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/bin/python b/test/bin/python index 3fbe8b163..9f0eb047f 100755 --- a/test/bin/python +++ b/test/bin/python @@ -17,8 +17,12 @@ cat >/dev/null # verify the python compiles at least. if this fails then the python code passed # to -c failed basic syntax checks. +# Compiler package ws removed in Py3 +# see https://www.python.org/dev/peps/pep-3108/#id53 +# The closest replacement is the ast package +# https://docs.python.org/3/library/ast.html echo "$2" | -/usr/bin/python2.7 -c "import sys; __import__('compiler').parse(sys.stdin.read())" +/usr/bin/python3 -c "import sys; __import__('ast').parse(sys.stdin.read())" # pretend we found zero processes. echo 0 From 483298bfbd5c940ebb1ab03274d04bc695f4105c Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sun, 2 Aug 2020 23:24:12 -0700 Subject: [PATCH 1235/2421] Support more Linux distros moreutils parallel choices Signed-off-by: Robin H. Johnson --- share/github-backup-utils/ghe-backup-config | 16 +++++++++++--- test/test-ghe-restore.sh | 20 ++++-------------- test/testlib.sh | 23 +++++++++++++++++++++ 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index eb1022982..5aa701ee0 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -72,10 +72,20 @@ ghe_parallel_check() { fi # Some machines may have both moreutils parallel and GNU parallel installed. + # Check some variants to find it GHE_PARALLEL_COMMAND="parallel" - if [ -x "/usr/bin/parallel.moreutils" ]; then - GHE_PARALLEL_COMMAND="/usr/bin/parallel.moreutils" - fi + local x + for x in \ + /usr/bin/parallel.moreutils \ + /usr/bin/parallel_moreutils \ + /usr/bin/moreutils.parallel \ + /usr/bin/moreutils_parallel \ + ; do + if [ -x "${x}" ]; then + GHE_PARALLEL_COMMAND="${x}" + break + fi + done # Check that the GHE_PARALLEL_COMMAND is pointing to moreutils parallel if ! $GHE_PARALLEL_COMMAND -h | grep -q "parallel \[OPTIONS\] command -- arguments"; then diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index b9feaa398..ae2a0b701 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -391,6 +391,7 @@ begin_test "ghe-restore cluster" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_moreutils_parallel setup_remote_metadata setup_remote_cluster echo "cluster" > "$GHE_DATA_DIR/current/strategy" @@ -402,11 +403,6 @@ begin_test "ghe-restore cluster" GHE_RESTORE_HOST=127.0.0.1 export GHE_RESTORE_HOST - # CI servers may have moreutils parallel and GNU parallel installed. We need moreutils parallel. - if [ -x "/usr/bin/parallel.moreutils" ]; then - ln -sf /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel" - fi - # run ghe-restore and write output to file for asserting against if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then cat "$TRASHDIR/restore-out" @@ -414,9 +410,7 @@ begin_test "ghe-restore cluster" false fi - if [ -h "$ROOTDIR/test/bin/parallel" ]; then - unlink "$ROOTDIR/test/bin/parallel" - fi + cleanup_moreutils_parallel # for debugging cat "$TRASHDIR/restore-out" @@ -461,6 +455,7 @@ begin_test "ghe-restore missing directories or files from source snapshot displa # Tests the scenario where something exists in the database, but not on disk. set -e rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_moreutils_parallel setup_remote_metadata setup_remote_cluster echo "cluster" > "$GHE_DATA_DIR/current/strategy" @@ -472,11 +467,6 @@ begin_test "ghe-restore missing directories or files from source snapshot displa GHE_RESTORE_HOST=127.0.0.1 export GHE_RESTORE_HOST - # CI servers may have moreutils parallel and GNU parallel installed. We need moreutils parallel. - if [ -x "/usr/bin/parallel.moreutils" ]; then - ln -sf /usr/bin/parallel.moreutils "$ROOTDIR/test/bin/parallel" - fi - # Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1 export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1 @@ -488,9 +478,7 @@ begin_test "ghe-restore missing directories or files from source snapshot displa false fi - if [ -h "$ROOTDIR/test/bin/parallel" ]; then - unlink "$ROOTDIR/test/bin/parallel" - fi + cleanup_moreutils_parallel # for debugging cat "$TRASHDIR/restore-out" diff --git a/test/testlib.sh b/test/testlib.sh index 222b8dd9f..865f21f0a 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -431,3 +431,26 @@ verify_all_restored_data() { # verify common data verify_common_data } + +setup_moreutils_parallel() { + # CI servers may have moreutils parallel and GNU parallel installed. + # We need moreutils parallel + local x + for x in \ + /usr/bin/parallel.moreutils \ + /usr/bin/parallel_moreutils \ + /usr/bin/moreutils.parallel \ + /usr/bin/moreutils_parallel \ + ; do + if [ -x "${x}" ]; then + ln -sf "${x}" "$ROOTDIR/test/bin/parallel" + break + fi + done +} + +cleanup_moreutils_parallel() { + if [ -h "$ROOTDIR/test/bin/parallel" ]; then + unlink "$ROOTDIR/test/bin/parallel" + fi +} From 4727f7bfa220286b7baa90b8224605580116d89d Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 23 Sep 2020 15:48:54 +0000 Subject: [PATCH 1236/2421] Bump version: 2.22.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 10 ++++++++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 94f235e51..3edc22a6b 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -113,7 +113,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.19.0" +supported_minimum_version="2.20.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index dfd337512..1ceb900af 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +github-backup-utils (2.22.0) UNRELEASED; urgency=medium + + * Added basic timing around the ghe-restore process #625 + * Improve python3 & finding moreutils parallel #627 + * Turn off POSIX for ghe-backup-config #632 + * Add parallelized restore capability to ghe-restore-storage #635 + * Update backup-utils for new features in 2.22 #641 + + -- jianghao0718@github.com Wed, 23 Sep 2020 15:48:54 +0000 + github-backup-utils (2.21.0) UNRELEASED; urgency=medium * Introduce option to skip restoring of audit logs #596 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index db65e2167..f48f82fa2 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.21.0 +2.22.0 diff --git a/test/testlib.sh b/test/testlib.sh index 7d6bdbf9b..1ab168a3f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.21.0} +: ${GHE_TEST_REMOTE_VERSION:=2.22.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 29aa722d1480965bff4182ccb9308bcec7dc71d4 Mon Sep 17 00:00:00 2001 From: Ahraz Asif Date: Mon, 28 Sep 2020 10:58:37 +0200 Subject: [PATCH 1237/2421] Building Docker image from git source --- .dockerignore | 2 -- Dockerfile | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 988d907c9..e69de29bb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +0,0 @@ -* -!share/github-backup-utils/ghe-docker-init diff --git a/Dockerfile b/Dockerfile index 4cf1ef888..00067263c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,10 +11,8 @@ RUN apt-get -q -y update && \ gawk \ && rm -rf /var/lib/apt/lists/* +COPY ./ /backup-utils/ WORKDIR /backup-utils -ADD https://github.com/github/backup-utils/archive/stable.tar.gz / -RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils && \ - rm -r /stable.tar.gz RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init From d79f238ac7dc452139334891affabf393c2674b1 Mon Sep 17 00:00:00 2001 From: Nathan Witmer Date: Fri, 2 Oct 2020 11:47:07 -0600 Subject: [PATCH 1238/2421] Connect to remote redis port when specifying hostname --- share/github-backup-utils/ghe-backup-redis | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index 7259488dd..e5a1048ff 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -22,21 +22,21 @@ ghe-ssh "$GHE_HOSTNAME" /bin/bash </dev/null || echo "localhost") - timestamp=\$(ghe-redis-cli -h \$redis_host LASTSAVE) + timestamp=\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE) for i in \$(seq 10); do - if ! ghe-redis-cli -h \$redis_host BGSAVE | grep -q ERR; then + if ! ghe-redis-cli --remote -h \$redis_host BGSAVE | grep -q ERR; then break fi sleep 15 done for n in \$(seq 3600); do - if [ "\$(ghe-redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then + if [ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then break fi sleep 1 done - [ "\$(ghe-redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work + [ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work if [ "\$redis_host" != "localhost" ]; then ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' From 52e14c6d75bd7be86d6f43d161af4c60cb014071 Mon Sep 17 00:00:00 2001 From: Javier Li Sam Date: Thu, 8 Oct 2020 16:04:38 -0700 Subject: [PATCH 1239/2421] Rename redis-cli for ghe-redis-cli in test --- test/bin/{redis-cli => ghe-redis-cli} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/bin/{redis-cli => ghe-redis-cli} (100%) diff --git a/test/bin/redis-cli b/test/bin/ghe-redis-cli similarity index 100% rename from test/bin/redis-cli rename to test/bin/ghe-redis-cli From 82dcb2dbef518b9c646807589268c359c281ee25 Mon Sep 17 00:00:00 2001 From: Javier Li Sam Date: Thu, 8 Oct 2020 16:41:21 -0700 Subject: [PATCH 1240/2421] Fake --remote flag --- test/bin/ghe-redis-cli | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/bin/ghe-redis-cli b/test/bin/ghe-redis-cli index 761d87204..df6caff7e 100755 --- a/test/bin/ghe-redis-cli +++ b/test/bin/ghe-redis-cli @@ -18,12 +18,12 @@ while true; do echo "fake redis data" > "$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb" break ;; - -h) - # Fake accepting hostname argument - shift 2 + --remote) + # Fake accepting remote flag argument + shift 3 ;; *) - echo "unexpected redis-cli command: $1" 1>&2 + echo "unexpected ghe-redis-cli command: $1" 1>&2 exit 1 ;; esac From 4f4015767ffe4992b3efeeeb582b03f13b9fc1f6 Mon Sep 17 00:00:00 2001 From: Javier Li Sam Date: Thu, 8 Oct 2020 17:02:39 -0700 Subject: [PATCH 1241/2421] Fake --remote flag --- share/github-backup-utils/ghe-backup-redis | 8 ++++---- test/bin/ghe-redis-cli | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index 7259488dd..e5a1048ff 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -22,21 +22,21 @@ ghe-ssh "$GHE_HOSTNAME" /bin/bash </dev/null || echo "localhost") - timestamp=\$(ghe-redis-cli -h \$redis_host LASTSAVE) + timestamp=\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE) for i in \$(seq 10); do - if ! ghe-redis-cli -h \$redis_host BGSAVE | grep -q ERR; then + if ! ghe-redis-cli --remote -h \$redis_host BGSAVE | grep -q ERR; then break fi sleep 15 done for n in \$(seq 3600); do - if [ "\$(ghe-redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then + if [ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then break fi sleep 1 done - [ "\$(ghe-redis-cli -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work + [ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work if [ "\$redis_host" != "localhost" ]; then ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' diff --git a/test/bin/ghe-redis-cli b/test/bin/ghe-redis-cli index 761d87204..f017b2e5b 100755 --- a/test/bin/ghe-redis-cli +++ b/test/bin/ghe-redis-cli @@ -18,9 +18,9 @@ while true; do echo "fake redis data" > "$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb" break ;; - -h) + --remote) # Fake accepting hostname argument - shift 2 + shift 3 ;; *) echo "unexpected redis-cli command: $1" 1>&2 From 8100fb6e7eac761609aa57ab4a192f330dcf44dd Mon Sep 17 00:00:00 2001 From: Nathan Witmer Date: Fri, 9 Oct 2020 13:40:31 -0600 Subject: [PATCH 1242/2421] Add support for both ghe-redis-cli and redis-cli To support backward compatibility --- share/github-backup-utils/ghe-backup-redis | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index e5a1048ff..b0eb44949 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -21,22 +21,29 @@ ghe_remote_version_required "$GHE_HOSTNAME" ghe-ssh "$GHE_HOSTNAME" /bin/bash < /dev/null; then + redis_cli=ghe-redis-cli + redis_arg=--remote + else + redis_cli=redis-cli + redis_arg= + fi redis_host=\$(ghe-config cluster.redis-master 2>/dev/null || echo "localhost") - timestamp=\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE) + timestamp=\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE) for i in \$(seq 10); do - if ! ghe-redis-cli --remote -h \$redis_host BGSAVE | grep -q ERR; then + if ! \$redis_cli \$redis_arg -h \$redis_host BGSAVE | grep -q ERR; then break fi sleep 15 done for n in \$(seq 3600); do - if [ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then + if [ "\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then break fi sleep 1 done - [ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work + [ "\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work if [ "\$redis_host" != "localhost" ]; then ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' From 76741f7dc5cfa6d0b6dce2d1152bf9ff8b3ccc3e Mon Sep 17 00:00:00 2001 From: Nathan Witmer Date: Wed, 14 Oct 2020 15:45:33 -0600 Subject: [PATCH 1243/2421] Update ghe-backup-redis with flexible redis cli handling So it can use either redis-cli or ghe-redis-cli depending on availability --- share/github-backup-utils/ghe-backup-redis | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis index e5a1048ff..b0eb44949 100755 --- a/share/github-backup-utils/ghe-backup-redis +++ b/share/github-backup-utils/ghe-backup-redis @@ -21,22 +21,29 @@ ghe_remote_version_required "$GHE_HOSTNAME" ghe-ssh "$GHE_HOSTNAME" /bin/bash < /dev/null; then + redis_cli=ghe-redis-cli + redis_arg=--remote + else + redis_cli=redis-cli + redis_arg= + fi redis_host=\$(ghe-config cluster.redis-master 2>/dev/null || echo "localhost") - timestamp=\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE) + timestamp=\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE) for i in \$(seq 10); do - if ! ghe-redis-cli --remote -h \$redis_host BGSAVE | grep -q ERR; then + if ! \$redis_cli \$redis_arg -h \$redis_host BGSAVE | grep -q ERR; then break fi sleep 15 done for n in \$(seq 3600); do - if [ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then + if [ "\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then break fi sleep 1 done - [ "\$(ghe-redis-cli --remote -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work + [ "\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work if [ "\$redis_host" != "localhost" ]; then ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' From eddedacdf66fd4d57af8cf75c2598b2452407e54 Mon Sep 17 00:00:00 2001 From: Ahraz Date: Sun, 18 Oct 2020 14:17:39 +0200 Subject: [PATCH 1244/2421] Alpine dockerfile also builds from local files --- Dockerfile.alpine | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 203952fe8..315c390ee 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -10,11 +10,8 @@ RUN apk --update --no-cache add \ gawk \ procps +COPY ./ /backup-utils/ WORKDIR /backup-utils -ADD https://github.com/github/backup-utils/archive/stable.tar.gz / -RUN tar xzvf /stable.tar.gz --strip-components=1 -C /backup-utils && \ - mv /usr/bin/gawk /usr/bin/awk && \ - rm -r /stable.tar.gz RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init From 2ab1a29b39d9d516e1b32dcac2c9ae75b168cfbd Mon Sep 17 00:00:00 2001 From: Ahraz Date: Sun, 18 Oct 2020 14:19:44 +0200 Subject: [PATCH 1245/2421] Added git related dockerignore entries --- .dockerignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.dockerignore b/.dockerignore index e69de29bb..53028715a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git/ +.github/ +.gitattributes +.gitignore From e798eae44a5fc98a2b5586ac2b8a8da7f25ba136 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 21 Oct 2020 16:09:41 -0700 Subject: [PATCH 1246/2421] remove whitespace Co-authored-by: Courtney (CJ) Oka <16140724+oakeyc@users.noreply.github.com> --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b75c2291a..ffdbac327 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,4 +34,4 @@ jobs: shell: bash - name: Build (Linux) run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc - if: matrix.os != 'macos-latest' + if: matrix.os != 'macos-latest' From 53148ccf74ac6c447f1cf7c33f720a5e3751aeae Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 21 Oct 2020 16:09:52 -0700 Subject: [PATCH 1247/2421] remove whitespace Co-authored-by: Courtney (CJ) Oka <16140724+oakeyc@users.noreply.github.com> --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ffdbac327..f59ccbba7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,6 @@ jobs: os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest'] fail-fast: false runs-on: ${{ matrix.os }} - steps: - name: Install Dependencies (Linux) run: | From 2ecff334a65e114104b414a714a822c6fec29ae2 Mon Sep 17 00:00:00 2001 From: Xin Wu Date: Tue, 3 Nov 2020 11:38:19 +0100 Subject: [PATCH 1248/2421] remove ghe-service-ensure-mysql as the file is deleted from https://github.com/github/enterprise2/pull/23694 --- bin/ghe-restore | 2 +- test/bin/ghe-service-ensure-elasticsearch | 4 ++-- test/bin/ghe-service-ensure-mysql | 6 ------ 3 files changed, 3 insertions(+), 9 deletions(-) delete mode 100755 test/bin/ghe-service-ensure-mysql diff --git a/bin/ghe-restore b/bin/ghe-restore index cb119262a..d3c3c2859 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -273,7 +273,7 @@ fi # These services will not have been started on appliances that have not been # configured yet. if ! $CLUSTER; then - echo "sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" | + echo "sudo ghe-service-ensure-elasticsearch" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi diff --git a/test/bin/ghe-service-ensure-elasticsearch b/test/bin/ghe-service-ensure-elasticsearch index c844e79b4..d0bd6aaa3 100755 --- a/test/bin/ghe-service-ensure-elasticsearch +++ b/test/bin/ghe-service-ensure-elasticsearch @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Usage: ghe-service-ensure-mysql -# Emulates the remote GitHub ghe-service-ensure-mysql command. Tests use this +# Usage: ghe-service-ensure-elasticsearch +# Emulates the remote GitHub ghe-service-ensure-elasticsearch command. Tests use this # to assert that the command was executed. set -e echo "ghe-service-ensure-elasticsearch OK" diff --git a/test/bin/ghe-service-ensure-mysql b/test/bin/ghe-service-ensure-mysql deleted file mode 100755 index a9fa342d0..000000000 --- a/test/bin/ghe-service-ensure-mysql +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -# Usage: ghe-service-ensure-mysql -# Emulates the remote GitHub ghe-service-ensure-mysql command. Tests use this -# to assert that the command was executed. -set -e -echo "ghe-service-ensure-mysql OK" From af0949e8817acafc27e634554e9768ad62bc9f22 Mon Sep 17 00:00:00 2001 From: Yunlei Liu Date: Thu, 12 Nov 2020 14:50:16 -0600 Subject: [PATCH 1249/2421] github-env -> github-env-dispatch --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- share/github-backup-utils/ghe-restore-pages | 4 ++-- share/github-backup-utils/ghe-restore-repositories | 4 ++-- share/github-backup-utils/ghe-restore-repositories-gist | 4 ++-- share/github-backup-utils/ghe-restore-storage | 4 ++-- test/bin/{github-env => github-env-dispatch} | 0 7 files changed, 10 insertions(+), 10 deletions(-) rename test/bin/{github-env => github-env-dispatch} (100%) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index a66934d0d..bb5d4f168 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -123,7 +123,7 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "github-env ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "github-env-dispatch ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index db49bc8e7..dbfaf1ab7 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -91,7 +91,7 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "github-env ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "github-env-dispatch ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 17f80ae79..fb8d21927 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -108,7 +108,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring pages list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +echo "cat $remote_tmp_list | github-env-dispatch ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -150,7 +150,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | github-env-dispatch ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -183,7 +183,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks + parallel -i /bin/sh -c "cat {} | github-env-dispatch ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 946dbc50d..0b4c54a77 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -110,7 +110,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring gist list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | github-env-dispatch ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -155,7 +155,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks + parallel -i /bin/sh -c "cat {} | github-env-dispatch ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index a890ca741..d9893033d 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -103,7 +103,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring object list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +echo "cat $remote_tmp_list | github-env-dispatch ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -165,7 +165,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Fri, 13 Nov 2020 13:44:05 -0600 Subject: [PATCH 1250/2421] add condition check for github-env-dispatch and fall back to use github-env --- bin/ghe-backup | 10 ++++++++++ bin/ghe-restore | 10 ++++++++++ share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- share/github-backup-utils/ghe-restore-pages | 4 ++-- share/github-backup-utils/ghe-restore-repositories | 4 ++-- .../github-backup-utils/ghe-restore-repositories-gist | 4 ++-- share/github-backup-utils/ghe-restore-storage | 4 ++-- 8 files changed, 30 insertions(+), 10 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 1135db7f0..56eb32661 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -137,6 +137,16 @@ if [ -f ../in-progress ]; then fi fi +# Figure out which github-env we should use during backup +GITHUB_ENV_SHELL= +if ghe-ssh "$GHE_HOSTNAME" -- \ + '[ -x "$(command -v github-env-dispatch)" ]'; then + GITHUB_ENV_SHELL=github-env-dispatch +else + GITHUB_ENV_SHELL=github-env +fi +export GITHUB_ENV_SHELL + echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" diff --git a/bin/ghe-restore b/bin/ghe-restore index d3c3c2859..fe108d5f1 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -144,6 +144,16 @@ if ghe-ssh "$GHE_HOSTNAME" -- \ fi export CLUSTER +# Figure out which github-env we should use during restore +GITHUB_ENV_SHELL= +if ghe-ssh "$GHE_HOSTNAME" -- \ + '[ -x "$(command -v github-env-dispatch)" ]'; then + GITHUB_ENV_SHELL=github-env-dispatch +else + GITHUB_ENV_SHELL=github-env +fi +export GITHUB_ENV_SHELL + # Restoring a cluster backup to a standalone appliance is not supported if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \ diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index bb5d4f168..d446b03f1 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -123,7 +123,7 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "github-env-dispatch ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "$GITHUB_ENV_SHELL ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index dbfaf1ab7..d542d18ec 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -91,7 +91,7 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "github-env-dispatch ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "$GITHUB_ENV_SHELL ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index fb8d21927..307008c00 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -108,7 +108,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring pages list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env-dispatch ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -150,7 +150,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -183,7 +183,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks + parallel -i /bin/sh -c "cat {} | $GITHUB_ENV_SHELL ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 0b4c54a77..ccad7fd8e 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -110,7 +110,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring gist list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env-dispatch ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -155,7 +155,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks + parallel -i /bin/sh -c "cat {} | $GITHUB_ENV_SHELL ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index d9893033d..0471a3393 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -103,7 +103,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring object list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env-dispatch ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -165,7 +165,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Mon, 16 Nov 2020 17:28:03 +0100 Subject: [PATCH 1251/2421] Backup and restore password pepper For built in authentication the upcoming release will have a password pepper (see https://en.wikipedia.org/wiki/Pepper_(cryptography)). This needs to be backed up and restored to ensure passwords keep working across backup / restore cycles. --- share/github-backup-utils/ghe-backup-settings | 1 + share/github-backup-utils/ghe-restore-settings | 2 ++ test/test-ghe-backup.sh | 11 +++++++++++ test/testlib.sh | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index e38eb7ad5..a44edf925 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -40,6 +40,7 @@ backup-secret() { } backup-secret "management console password" "manage-password" "secrets.manage" +backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" # Backup external MySQL password if running external MySQL DB. if is_service_external 'mysql'; then diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 5e90e863d..e952c3067 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -40,6 +40,8 @@ restore-secret "external MySQL password" "external-mysql-password" "secrets.exte # Restore management console password hash if present. restore-secret "management console password" "manage-password" "secrets.manage" +# Restore password pepper if present +restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index ff7831f48..1894e83e2 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -121,6 +121,17 @@ begin_test "ghe-backup without management console password" ) end_test +begin_test "ghe-backup without password pepper" +( + set -e + + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.github.user-password-secrets "" + ghe-backup + + [ ! -f "$GHE_DATA_DIR/current/password-pepper" ] +) +end_test + begin_test "ghe-backup empty hookshot directory" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index 1ab168a3f..a03e56603 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -197,6 +197,10 @@ setup_test_data () { mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "fake password hash data" + # Create a fake password pepper file + mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.github.user-password-secrets "fake password pepper data" + # Create some fake hooks in the remote data directory mkdir -p "$loc/git-hooks/environments/tarballs" mkdir -p "$loc/git-hooks/repos" @@ -311,6 +315,7 @@ setup_test_data () { echo "fake ghe-export-ssl-ca-certificates data" > "$loc/ssl-ca-certificates.tar" echo "fake license data" > "$loc/enterprise.ghl" echo "fake password hash data" > "$loc/manage-password" + echo "fake password pepper data" > "$loc/password-pepper" echo "rsync" > "$loc/strategy" echo "$GHE_REMOTE_VERSION" > "$loc/version" fi @@ -415,6 +420,9 @@ verify_all_backedup_data() { # verify manage-password file was backed up [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] + # verify password pepper file was backed up + [ "$(cat "$GHE_DATA_DIR/current/password-pepper")" = "fake password pepper data" ] + # check that ca certificates were backed up [ "$(cat "$GHE_DATA_DIR/current/ssl-ca-certificates.tar")" = "fake ghe-export-ssl-ca-certificates data" ] From c71ecccb933244b4832baad77b86786f28fbc17c Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Mon, 16 Nov 2020 13:02:19 -0500 Subject: [PATCH 1252/2421] Revert "remove ghe-service-ensure-mysql" --- bin/ghe-restore | 2 +- test/bin/ghe-service-ensure-elasticsearch | 4 ++-- test/bin/ghe-service-ensure-mysql | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100755 test/bin/ghe-service-ensure-mysql diff --git a/bin/ghe-restore b/bin/ghe-restore index fe108d5f1..e0f22264b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -283,7 +283,7 @@ fi # These services will not have been started on appliances that have not been # configured yet. if ! $CLUSTER; then - echo "sudo ghe-service-ensure-elasticsearch" | + echo "sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi diff --git a/test/bin/ghe-service-ensure-elasticsearch b/test/bin/ghe-service-ensure-elasticsearch index d0bd6aaa3..c844e79b4 100755 --- a/test/bin/ghe-service-ensure-elasticsearch +++ b/test/bin/ghe-service-ensure-elasticsearch @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Usage: ghe-service-ensure-elasticsearch -# Emulates the remote GitHub ghe-service-ensure-elasticsearch command. Tests use this +# Usage: ghe-service-ensure-mysql +# Emulates the remote GitHub ghe-service-ensure-mysql command. Tests use this # to assert that the command was executed. set -e echo "ghe-service-ensure-elasticsearch OK" diff --git a/test/bin/ghe-service-ensure-mysql b/test/bin/ghe-service-ensure-mysql new file mode 100755 index 000000000..a9fa342d0 --- /dev/null +++ b/test/bin/ghe-service-ensure-mysql @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# Usage: ghe-service-ensure-mysql +# Emulates the remote GitHub ghe-service-ensure-mysql command. Tests use this +# to assert that the command was executed. +set -e +echo "ghe-service-ensure-mysql OK" From 354dad7e885ef12fb8893c617730926b720f2143 Mon Sep 17 00:00:00 2001 From: Ryan Simmen Date: Mon, 16 Nov 2020 13:02:48 -0500 Subject: [PATCH 1253/2421] Update ghe-service-ensure-elasticsearch --- test/bin/ghe-service-ensure-elasticsearch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bin/ghe-service-ensure-elasticsearch b/test/bin/ghe-service-ensure-elasticsearch index c844e79b4..d0bd6aaa3 100755 --- a/test/bin/ghe-service-ensure-elasticsearch +++ b/test/bin/ghe-service-ensure-elasticsearch @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Usage: ghe-service-ensure-mysql -# Emulates the remote GitHub ghe-service-ensure-mysql command. Tests use this +# Usage: ghe-service-ensure-elasticsearch +# Emulates the remote GitHub ghe-service-ensure-elasticsearch command. Tests use this # to assert that the command was executed. set -e echo "ghe-service-ensure-elasticsearch OK" From 9eebf1921e246c2dc0e865fd60ec9aa0f2257d8b Mon Sep 17 00:00:00 2001 From: Yunlei Liu Date: Tue, 17 Nov 2020 14:47:09 -0600 Subject: [PATCH 1254/2421] stop github-timerd based on its running environment --- bin/ghe-restore | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index e0f22264b..c39f04394 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -259,16 +259,28 @@ if $CLUSTER; then ghe_verbose "* Warning: Failed to stop cron on one or more nodes" fi - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + fi + else + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + fi fi else if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then ghe_verbose "* Warning: Failed to stop cron" fi - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd" + if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then + ghe_verbose "* Warning: Failed to stop github-timerd" + fi + else + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd" + fi fi fi From ab6c14a473bcdfd242d4ac6cabdcac07841e130f Mon Sep 17 00:00:00 2001 From: djdefi Date: Fri, 20 Nov 2020 07:25:10 -0800 Subject: [PATCH 1255/2421] note how to test symlink / hardlink support --- docs/requirements.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index f6a1ba3d8..d646e4981 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -27,6 +27,15 @@ Backup Utilities use [hard links][5] to store data efficiently, and the repositories on GitHub Enterprise Server use [symbolic links][6] so the backup snapshots must be written to a filesystem with support for symbolic and hard links. +To check if your filesystem supports creating hardlinks of symbolic links, you can run the following within your backup destination directory: + +```bash +touch file +ln -s file symlink +ln symlink hardlink +ls -la +``` + Using a [case sensitive][7] file system is also required to avoid conflicts. ## GitHub Enterprise Server version requirements @@ -61,4 +70,4 @@ be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapsh [7]: https://en.wikipedia.org/wiki/Case_sensitivity [8]: https://help.github.com/enterprise/admin/guides/installation/upgrade-requirements/ [9]: https://joeyh.name/code/moreutils -[10]: https://www.gnu.org/software/gawk \ No newline at end of file +[10]: https://www.gnu.org/software/gawk From ced6a6ddf97edbc4b1e4429a6760be00552414a0 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 20 Nov 2020 15:30:11 +0000 Subject: [PATCH 1256/2421] Revert "add condition check for github-env-dispatch and fall back to use github-env" This reverts commit 70c92bf6f2dc2ecbebf25912a48cd65549729883. --- bin/ghe-backup | 10 ---------- bin/ghe-restore | 10 ---------- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- share/github-backup-utils/ghe-restore-pages | 4 ++-- share/github-backup-utils/ghe-restore-repositories | 4 ++-- .../github-backup-utils/ghe-restore-repositories-gist | 4 ++-- share/github-backup-utils/ghe-restore-storage | 4 ++-- 8 files changed, 10 insertions(+), 30 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 56eb32661..1135db7f0 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -137,16 +137,6 @@ if [ -f ../in-progress ]; then fi fi -# Figure out which github-env we should use during backup -GITHUB_ENV_SHELL= -if ghe-ssh "$GHE_HOSTNAME" -- \ - '[ -x "$(command -v github-env-dispatch)" ]'; then - GITHUB_ENV_SHELL=github-env-dispatch -else - GITHUB_ENV_SHELL=github-env -fi -export GITHUB_ENV_SHELL - echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" diff --git a/bin/ghe-restore b/bin/ghe-restore index c39f04394..96691c84a 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -144,16 +144,6 @@ if ghe-ssh "$GHE_HOSTNAME" -- \ fi export CLUSTER -# Figure out which github-env we should use during restore -GITHUB_ENV_SHELL= -if ghe-ssh "$GHE_HOSTNAME" -- \ - '[ -x "$(command -v github-env-dispatch)" ]'; then - GITHUB_ENV_SHELL=github-env-dispatch -else - GITHUB_ENV_SHELL=github-env -fi -export GITHUB_ENV_SHELL - # Restoring a cluster backup to a standalone appliance is not supported if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \ diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index d446b03f1..bb5d4f168 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -123,7 +123,7 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "$GITHUB_ENV_SHELL ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "github-env-dispatch ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index d542d18ec..dbfaf1ab7 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -91,7 +91,7 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "$GITHUB_ENV_SHELL ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "github-env-dispatch ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 307008c00..fb8d21927 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -108,7 +108,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring pages list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +echo "cat $remote_tmp_list | github-env-dispatch ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -150,7 +150,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | github-env-dispatch ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -183,7 +183,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks + parallel -i /bin/sh -c "cat {} | github-env-dispatch ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index ccad7fd8e..0b4c54a77 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -110,7 +110,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring gist list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | github-env-dispatch ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -155,7 +155,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks + parallel -i /bin/sh -c "cat {} | github-env-dispatch ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 0471a3393..d9893033d 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -103,7 +103,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring object list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | $GITHUB_ENV_SHELL ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +echo "cat $remote_tmp_list | github-env-dispatch ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -165,7 +165,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Fri, 20 Nov 2020 15:30:20 +0000 Subject: [PATCH 1257/2421] Revert "github-env -> github-env-dispatch" This reverts commit af0949e8817acafc27e634554e9768ad62bc9f22. --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- share/github-backup-utils/ghe-restore-pages | 4 ++-- share/github-backup-utils/ghe-restore-repositories | 4 ++-- share/github-backup-utils/ghe-restore-repositories-gist | 4 ++-- share/github-backup-utils/ghe-restore-storage | 4 ++-- test/bin/{github-env-dispatch => github-env} | 0 7 files changed, 10 insertions(+), 10 deletions(-) rename test/bin/{github-env-dispatch => github-env} (100%) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index bb5d4f168..a66934d0d 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -123,7 +123,7 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "github-env-dispatch ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "github-env ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index dbfaf1ab7..db49bc8e7 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -91,7 +91,7 @@ fi # more performant than performing over an SSH pipe. # bm_start "$(basename $0) - Generating routes" -echo "github-env-dispatch ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "github-env ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index fb8d21927..17f80ae79 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -108,7 +108,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring pages list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env-dispatch ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +echo "cat $remote_tmp_list | github-env ./bin/dpages-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -150,7 +150,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | github-env ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -183,7 +183,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks + parallel -i /bin/sh -c "cat {} | github-env ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 0b4c54a77..946dbc50d 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -110,7 +110,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring gist list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env-dispatch ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | github-env ./bin/gist-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -155,7 +155,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks + parallel -i /bin/sh -c "cat {} | github-env ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index d9893033d..a890ca741 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -103,7 +103,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring object list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env-dispatch ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash +echo "cat $remote_tmp_list | github-env ./bin/storage-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" @@ -165,7 +165,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Mon, 23 Nov 2020 02:09:56 +0000 Subject: [PATCH 1258/2421] Check if timerd is running before stopping it --- bin/ghe-restore | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 96691c84a..53dabf56b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -250,8 +250,10 @@ if $CLUSTER; then fi if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then - ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + if ghe-ssh "$GHE_HOSTNAME" -- "nomad job status --short github-timerd >/dev/null"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + fi fi else if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then @@ -264,8 +266,10 @@ else fi if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then - ghe_verbose "* Warning: Failed to stop github-timerd" + if ghe-ssh "$GHE_HOSTNAME" -- "nomad job status --short github-timerd >/dev/null"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then + ghe_verbose "* Warning: Failed to stop github-timerd" + fi fi else if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then From 4a834159bcd61864edb5a8ec6566e855cfbf034a Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 23 Nov 2020 02:12:52 +0000 Subject: [PATCH 1259/2421] reduce output noise --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 53dabf56b..716bd2c40 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -251,7 +251,7 @@ if $CLUSTER; then if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then if ghe-ssh "$GHE_HOSTNAME" -- "nomad job status --short github-timerd >/dev/null"; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" fi fi @@ -267,7 +267,7 @@ else if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then if ghe-ssh "$GHE_HOSTNAME" -- "nomad job status --short github-timerd >/dev/null"; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then ghe_verbose "* Warning: Failed to stop github-timerd" fi fi From e1df794d98c15e6a05d67fee17b9fa538386af2c Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 23 Nov 2020 15:06:05 +0000 Subject: [PATCH 1260/2421] additional fixes on the check --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 716bd2c40..bbdcd103c 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -250,7 +250,7 @@ if $CLUSTER; then fi if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - if ghe-ssh "$GHE_HOSTNAME" -- "nomad job status --short github-timerd >/dev/null"; then + if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" fi @@ -266,7 +266,7 @@ else fi if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - if ghe-ssh "$GHE_HOSTNAME" -- "nomad job status --short github-timerd >/dev/null"; then + if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then ghe_verbose "* Warning: Failed to stop github-timerd" fi From 9b7d209ac3d838336ed4a887889ae9db274374a7 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 23 Nov 2020 17:02:03 +0000 Subject: [PATCH 1261/2421] cleanup nomad before apply config --- bin/ghe-restore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index bbdcd103c..e1800e1d1 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -408,9 +408,11 @@ echo "sudo restart -q memcached 2>/dev/null || true" | # config run to perform data migrations. if $CLUSTER; then echo "Configuring cluster ..." + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then echo "Configuring appliance ..." + ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 fi From 6c1de3b36c4bd23c1e9d6ba7dd838d42e00790b6 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 23 Nov 2020 19:40:15 +0000 Subject: [PATCH 1262/2421] move ghe-nomad-cleanup to bin and make a stub --- bin/ghe-restore | 4 ++-- test/bin/ghe-nomad-cleanup | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100755 test/bin/ghe-nomad-cleanup diff --git a/bin/ghe-restore b/bin/ghe-restore index e1800e1d1..8d4a2159e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -408,11 +408,11 @@ echo "sudo restart -q memcached 2>/dev/null || true" | # config run to perform data migrations. if $CLUSTER; then echo "Configuring cluster ..." - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- ghe-nomad-cleanup" ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then echo "Configuring appliance ..." - ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 fi diff --git a/test/bin/ghe-nomad-cleanup b/test/bin/ghe-nomad-cleanup new file mode 100755 index 000000000..05b8505c9 --- /dev/null +++ b/test/bin/ghe-nomad-cleanup @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Usage: ghe-nomad-cleanup +# Emulates the remote GitHub ghe-nomad-cleanup command. Tests use this +# to assert that the command was executed. +echo "$(basename $0)" "'$(cat)'" "OK" From 613e73ec0123c0f11d7cd32d814dbcc70a5e9dee Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Mon, 23 Nov 2020 14:57:49 -0500 Subject: [PATCH 1263/2421] Only run ghe-nomad-cleanup in 3.0 --- bin/ghe-restore | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 8d4a2159e..682ff54c4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -408,11 +408,15 @@ echo "sudo restart -q memcached 2>/dev/null || true" | # config run to perform data migrations. if $CLUSTER; then echo "Configuring cluster ..." - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- ghe-nomad-cleanup" + if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- ghe-nomad-cleanup" + fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then echo "Configuring appliance ..." - ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" + if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" + fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 fi From 3a5678ab41dacdc0ba529d54ff330b4b220a2f6e Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 24 Nov 2020 02:56:35 +0000 Subject: [PATCH 1264/2421] Call ghe-cluster-nomad-cleanup --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 682ff54c4..58056b145 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -409,7 +409,7 @@ echo "sudo restart -q memcached 2>/dev/null || true" | if $CLUSTER; then echo "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- ghe-nomad-cleanup" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then From 9c60b0f5885a7b17992eb86a7da68a13c77fd1d5 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 24 Nov 2020 16:28:40 +0000 Subject: [PATCH 1265/2421] Output to verbose log --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 58056b145..cc3598ac3 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -409,13 +409,13 @@ echo "sudo restart -q memcached 2>/dev/null || true" | if $CLUSTER; then echo "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then echo "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" + ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 fi From 9c5c4d34310515d0684de409595925e8c7c49453 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 24 Nov 2020 21:20:41 +0000 Subject: [PATCH 1266/2421] redirect error stream as well --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index cc3598ac3..852f206e7 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -409,13 +409,13 @@ echo "sudo restart -q memcached 2>/dev/null || true" | if $CLUSTER; then echo "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then echo "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 fi From bdb277944e90ae112e711ec41efb0a405f74e60d Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Wed, 16 Dec 2020 21:19:37 +0000 Subject: [PATCH 1267/2421] added node version check and fail out if they don't match --- bin/ghe-host-check | 86 +++++++++++++++++++++++++++------------------- 1 file changed, 51 insertions(+), 35 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3edc22a6b..c5bc54a6a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -15,32 +15,48 @@ set -e while true; do case "$1" in - -h|--help) - export GHE_SHOW_HELP=true - shift - ;; - --version) - export GHE_SHOW_VERSION=true - shift - ;; - -*) - echo "Error: invalid argument: '$1'" 1>&2 - exit 1 - ;; - *) - break - ;; + -h | --help) + export GHE_SHOW_HELP=true + shift + ;; + --version) + export GHE_SHOW_VERSION=true + shift + ;; + -*) + echo "Error: invalid argument: '$1'" 1>&2 + exit 1 + ;; + *) + break + ;; esac done # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" +. "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-backup-config" # Use the host provided on the command line if provided, or fallback on the # $GHE_HOSTNAME configured in backup.config when not present. host="${1:-$GHE_HOSTNAME}" +node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) +first_node_version="" +( + IFS=$'\n' + for node_version in $node_version_list; do + if [ -z "$first_node_version" ]; then + first_node_version=$(echo "$node_version" | cut -f2 -d":") + fi + current_node_version=$(echo "$node_version" | cut -f2 -d":") + if [ "$first_node_version" != "$current_node_version" ]; then + echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 + exit 1 + fi + done +) + # Options to pass to SSH during connection check options=" -o PasswordAuthentication=no @@ -59,26 +75,26 @@ set -e if [ $rc -ne 0 ]; then case $rc in - 255) - if echo "$output" | grep -i "port 22: Network is unreachable\|port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then - exec "$(basename $0)" "$hostname:122" - fi - + 255) + if echo "$output" | grep -i "port 22: Network is unreachable\|port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then + exec "$(basename $0)" "$hostname:122" + fi + + echo "$output" 1>&2 + echo "Error: ssh connection with '$host' failed" 1>&2 + echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2 + echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2 + ;; + 101) + echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 + ;; + 1) + if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then + exec "$(basename $0)" "$hostname:122" + else echo "$output" 1>&2 - echo "Error: ssh connection with '$host' failed" 1>&2 - echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2 - echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2 - ;; - 101) - echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 - ;; - 1) - if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then - exec "$(basename $0)" "$hostname:122" - else - echo "$output" 1>&2 - fi - ;; + fi + ;; esac exit $rc From 722476ad51a1921bbbc1a8547986934836135f52 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Wed, 16 Dec 2020 21:32:14 +0000 Subject: [PATCH 1268/2421] add debug statement for test fail --- bin/ghe-host-check | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index c5bc54a6a..35dfb301f 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -46,6 +46,7 @@ first_node_version="" ( IFS=$'\n' for node_version in $node_version_list; do + echo "$node_version" if [ -z "$first_node_version" ]; then first_node_version=$(echo "$node_version" | cut -f2 -d":") fi From a4391214e837bcec5cb48d09d80752577590484c Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Wed, 16 Dec 2020 21:38:18 +0000 Subject: [PATCH 1269/2421] add cluster check --- bin/ghe-host-check | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 35dfb301f..f02c2021a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -41,22 +41,30 @@ done # $GHE_HOSTNAME configured in backup.config when not present. host="${1:-$GHE_HOSTNAME}" -node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) -first_node_version="" -( - IFS=$'\n' - for node_version in $node_version_list; do - echo "$node_version" - if [ -z "$first_node_version" ]; then - first_node_version=$(echo "$node_version" | cut -f2 -d":") - fi - current_node_version=$(echo "$node_version" | cut -f2 -d":") - if [ "$first_node_version" != "$current_node_version" ]; then - echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 - exit 1 - fi - done -) +CLUSTER=false +if ghe-ssh "$host" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then + CLUSTER=true +fi + +if "$CLUSTER"; then + node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) + first_node_version="" + ( + IFS=$'\n' + for node_version in $node_version_list; do + echo "$node_version" + if [ -z "$first_node_version" ]; then + first_node_version=$(echo "$node_version" | cut -f2 -d":") + fi + current_node_version=$(echo "$node_version" | cut -f2 -d":") + if [ "$first_node_version" != "$current_node_version" ]; then + echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 + exit 1 + fi + done + ) +fi # Options to pass to SSH during connection check options=" From 31dd96fba4bb80e114e2d027e05b16c959a0eb80 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Wed, 16 Dec 2020 21:45:58 +0000 Subject: [PATCH 1270/2421] try a different debug print --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index f02c2021a..6aa133568 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -49,11 +49,11 @@ fi if "$CLUSTER"; then node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) + echo "$node_version_list" first_node_version="" ( IFS=$'\n' for node_version in $node_version_list; do - echo "$node_version" if [ -z "$first_node_version" ]; then first_node_version=$(echo "$node_version" | cut -f2 -d":") fi From 3805d847d60ec753527aadf2cd0bb7e1dad4324a Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Wed, 16 Dec 2020 21:51:00 +0000 Subject: [PATCH 1271/2421] more debugging --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 6aa133568..6f5718282 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -49,7 +49,7 @@ fi if "$CLUSTER"; then node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) - echo "$node_version_list" + echo "$node_version_list" 1>&2 first_node_version="" ( IFS=$'\n' From 743065de60caee5cccbb7d3904845f286e2a6d89 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Thu, 17 Dec 2020 18:54:12 +0000 Subject: [PATCH 1272/2421] try fixing up host-check error --- test/bin/ghe-cluster-each | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 129d8e739..0ea1f902c 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -26,10 +26,10 @@ if $SHOW_UUID; then if [ -z "$hosts" ]; then # Mimic `ghe-cluster-each $role -u` - echo "fake-uuid - fake-uuid1 - fake-uuid2 - " + echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602 +fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602 +fake-uuid2: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602 +" else for hostname in $hosts; do [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue From 487e1f8fc119e90936d093adf9b06e9af502a5b2 Mon Sep 17 00:00:00 2001 From: Ray Xu Date: Thu, 17 Dec 2020 11:05:43 -0800 Subject: [PATCH 1273/2421] Clarify which MSSQL backup files to remove --- share/github-backup-utils/ghe-backup-mssql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index d878f76b3..99c5e2c30 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -81,9 +81,9 @@ ensure_same_dbs() { if [[ "${#locals[@]}" -ne 0 ]]; then ghe_verbose "Warning: Found following ${#locals[@]} backup files that can't be traced back to the specified GHES host." - ghe_verbose "Warning: Did you recently reconfigure the GHES host? Consider deleting these backup files if no longer needed." + ghe_verbose "Warning: Did you recently reconfigure the GHES host? Move or delete these backup files if no longer needed." for local in "${locals[@]}"; do - ghe_verbose "$local" + ghe_verbose "$1/$local" done exit 1 From 53db0a16b2e06840b4de992781fd7cd4201cfe8f Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Thu, 17 Dec 2020 12:15:13 -0800 Subject: [PATCH 1274/2421] Update bin/ghe-host-check Co-authored-by: Caine Jette --- bin/ghe-host-check | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 6f5718282..895a1b688 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -50,20 +50,11 @@ fi if "$CLUSTER"; then node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) echo "$node_version_list" 1>&2 - first_node_version="" - ( - IFS=$'\n' - for node_version in $node_version_list; do - if [ -z "$first_node_version" ]; then - first_node_version=$(echo "$node_version" | cut -f2 -d":") - fi - current_node_version=$(echo "$node_version" | cut -f2 -d":") - if [ "$first_node_version" != "$current_node_version" ]; then - echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 - exit 1 - fi - done - ) + distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | uniq | wc -l) + if [ $distinct_versions -ne 1 ]; then + echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 + exit 1 + fi fi # Options to pass to SSH during connection check From becf68e25e089303a70a0b79d5ee3ec15f5c79e2 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Thu, 17 Dec 2020 20:23:30 +0000 Subject: [PATCH 1275/2421] see if tests pass now --- bin/ghe-host-check | 18 +++++++++--------- test/bin/ghe-cluster-each | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 895a1b688..17fe954b7 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -47,15 +47,15 @@ if ghe-ssh "$host" -- \ CLUSTER=true fi -if "$CLUSTER"; then - node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) - echo "$node_version_list" 1>&2 - distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | uniq | wc -l) - if [ $distinct_versions -ne 1 ]; then - echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 - exit 1 - fi -fi +# if "$CLUSTER"; then +# node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) +# echo "$node_version_list" 1>&2 +# distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | uniq | wc -l) +# if [ "$distinct_versions" -ne 1 ]; then +# echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 +# exit 1 +# fi +# fi # Options to pass to SSH during connection check options=" diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 0ea1f902c..129d8e739 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -26,10 +26,10 @@ if $SHOW_UUID; then if [ -z "$hosts" ]; then # Mimic `ghe-cluster-each $role -u` - echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602 -fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602 -fake-uuid2: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602 -" + echo "fake-uuid + fake-uuid1 + fake-uuid2 + " else for hostname in $hosts; do [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue From 386954b058f5530690d682497374a9c72d94ad2e Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Thu, 17 Dec 2020 21:38:42 +0000 Subject: [PATCH 1276/2421] add ghe-version mock logic --- bin/ghe-host-check | 18 +++++++++--------- test/bin/ghe-cluster-each | 7 +++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 17fe954b7..3a971fcee 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -47,15 +47,15 @@ if ghe-ssh "$host" -- \ CLUSTER=true fi -# if "$CLUSTER"; then -# node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) -# echo "$node_version_list" 1>&2 -# distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | uniq | wc -l) -# if [ "$distinct_versions" -ne 1 ]; then -# echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 -# exit 1 -# fi -# fi +if "$CLUSTER"; then + node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) + echo "$node_version_list" 1>&2 + distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | uniq | wc -l) + if [ "$distinct_versions" -ne 1 ]; then + echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 + exit 1 + fi +fi # Options to pass to SSH during connection check options=" diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 129d8e739..5e02ea51f 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -19,6 +19,13 @@ for _ in "$@"; do esac done +if [ "$2" == "ghe-version" ]; then + echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" + echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" + echo "fake-uuid2: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" + exit 0 +fi + if $SHOW_UUID; then CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" From 2bea41c97855a5581f737bb1da801a0d94a23926 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Thu, 17 Dec 2020 22:24:31 +0000 Subject: [PATCH 1277/2421] add test for nodes with different versions --- test/bin/ghe-cluster-each | 13 +- test/test-ghe-restore.sh | 1181 +++++++++++++++++++------------------ 2 files changed, 614 insertions(+), 580 deletions(-) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 5e02ea51f..16f610562 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -20,9 +20,16 @@ for _ in "$@"; do done if [ "$2" == "ghe-version" ]; then - echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" - echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" - echo "fake-uuid2: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" + if [ -n "$MATCHING_VERSIONS" ]; then + echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" + echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" + echo "fake-uuid2: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" + else + echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" + echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" + echo "fake-uuid2: GitHub Enterprise Server 2.19 lxc 2020-12-13 5e97c07622" + fi + exit 0 fi diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 1ff89a963..ffe035681 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -10,532 +10,599 @@ setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" -begin_test "ghe-restore-snapshot-path reports an error when current symlink doesn't exist" -( - set -e - rm "$GHE_DATA_DIR/current" - - ghe-restore-snapshot-path > "$TRASHDIR/restore-out" 2>&1 || true - ln -s 1 "$GHE_DATA_DIR/current" - grep -q "Error: Snapshot 'current' doesn't exist." "$TRASHDIR/restore-out" -) -end_test - -begin_test "ghe-restore-snapshot-path reports an error when specified snapshot doesn't exist" -( - set -e - rm "$GHE_DATA_DIR/current" - - ghe-restore-snapshot-path foo > "$TRASHDIR/restore-out" 2>&1 || true - ln -s 1 "$GHE_DATA_DIR/current" - grep -q "Error: Snapshot 'foo' doesn't exist." "$TRASHDIR/restore-out" -) -end_test - -begin_test "ghe-restore into configured vm" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata +# begin_test "ghe-restore-snapshot-path reports an error when current symlink doesn't exist" +# ( +# set -e +# rm "$GHE_DATA_DIR/current" + +# ghe-restore-snapshot-path > "$TRASHDIR/restore-out" 2>&1 || true +# ln -s 1 "$GHE_DATA_DIR/current" +# grep -q "Error: Snapshot 'current' doesn't exist." "$TRASHDIR/restore-out" +# ) +# end_test + +# begin_test "ghe-restore-snapshot-path reports an error when specified snapshot doesn't exist" +# ( +# set -e +# rm "$GHE_DATA_DIR/current" + +# ghe-restore-snapshot-path foo > "$TRASHDIR/restore-out" 2>&1 || true +# ln -s 1 "$GHE_DATA_DIR/current" +# grep -q "Error: Snapshot 'foo' doesn't exist." "$TRASHDIR/restore-out" +# ) +# end_test + +# begin_test "ghe-restore into configured vm" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST + +# # run ghe-restore and write output to file for asserting against +# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi + +# # for debugging +# cat "$TRASHDIR/restore-out" + +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + +# # verify stale servers were cleared +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + +# # Verify all the data we've restored is as expected +# verify_all_restored_data +# ) +# end_test + +# begin_test "ghe-restore logs the benchmark" +# ( +# set -e + +# export BM_TIMESTAMP=foo +# export GHE_RESTORE_HOST=127.0.0.1 +# ghe-restore -v -f +# [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] +# ) +# end_test + +# begin_test "ghe-restore aborts without user verification" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST + +# # run ghe-restore and write output to file for asserting against +# if echo "no" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then +# cat "$TRASHDIR/restore-out" +# false # ghe-restore should have exited non-zero +# fi + +# grep -q "Restore aborted" "$TRASHDIR/restore-out" +# ) +# end_test + +# begin_test "ghe-restore accepts user verification" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST + +# # run ghe-restore and write output to file for asserting against +# if ! echo "yes" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then +# cat "$TRASHDIR/restore-out" +# false # ghe-restore should have accepted the input +# fi +# ) +# end_test + +# begin_test "ghe-restore -c into unconfigured vm" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST + +# # leave unconfigured, enable maintenance mode and create required directories +# setup_maintenance_mode + +# # run ghe-restore and write output to file for asserting against +# if ! ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then +# cat "$TRASHDIR/restore-out" +# false +# fi + +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + +# # verify attempt to clear stale servers was not made +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { +# echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." +# exit 1 +# } + +# # Verify all the data we've restored is as expected +# verify_all_restored_data +# ) +# end_test + +# begin_test "ghe-restore into unconfigured vm" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST + +# # leave unconfigured, enable maintenance mode and create required directories +# setup_maintenance_mode + +# # ghe-restore into an unconfigured vm implies -c +# ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 +# cat "$TRASHDIR/restore-out" + +# # verify no config run after restore on unconfigured instance +# ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" + +# # verify connect to right host +# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + +# # verify attempt to clear stale servers was not made +# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { +# echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." +# exit 1 +# } + +# # Verify all the data we've restored is as expected +# verify_all_restored_data +# ) +# end_test + +# begin_test "ghe-restore with host arg and config value" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# # set restore host environ var (which we shouldn't see) +# GHE_RESTORE_HOST="broken.config.restore.host" +# export GHE_RESTORE_HOST + +# # set restore host config var (which we shouldn't see) +# GHE_BACKUP_CONFIG_TEMP="$TRASHDIR/backup.config.temp" +# cp "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_CONFIG_TEMP" +# echo 'GHE_RESTORE_HOST="broken.config.restore.host"' >> "$GHE_BACKUP_CONFIG_TEMP" +# GHE_BACKUP_CONFIG="$GHE_BACKUP_CONFIG_TEMP" +# export GHE_BACKUP_CONFIG + +# # run it +# output="$(ghe-restore -f localhost)" || false + +# # clean up the config file +# rm "$GHE_BACKUP_CONFIG_TEMP" + +# # verify host arg overrides configured restore host +# echo "$output" | grep -q 'Connect localhost:22 OK' + +# # Verify all the data we've restored is as expected +# verify_all_restored_data +# ) +# end_test + +# begin_test "ghe-restore with host arg" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# # set restore host environ var +# GHE_RESTORE_HOST="broken.environ.restore.host" +# export GHE_RESTORE_HOST + +# # run it +# output="$(ghe-restore -f localhost)" || false + +# # verify host arg overrides configured restore host +# echo "$output" | grep -q 'Connect localhost:22 OK' + +# # Verify all the data we've restored is as expected +# verify_all_restored_data +# ) +# end_test + +# begin_test "ghe-restore no host arg or configured restore host" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# # unset configured restore host +# unset GHE_RESTORE_HOST + +# # verify running ghe-restore fails +# ! ghe-restore -f +# ) +# end_test + +# begin_test "ghe-restore with no pages backup" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# # remove pages data +# rm -rf "$GHE_DATA_DIR/1/pages" + +# # run it +# ghe-restore -v -f localhost +# ) +# end_test + +# # Setup Actions data for the subsequent tests +# setup_actions_test_data "$GHE_DATA_DIR/1" + +# begin_test "ghe-restore invokes ghe-import-mssql" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata +# enable_actions + +# # enable maintenance mode and create required directories +# setup_maintenance_mode + +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST + +# # run ghe-restore and write output to file for asserting against +# if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi + +# grep -q "Restoring MSSQL database" "$TRASHDIR/restore-out" +# grep -q "ghe-import-mssql .* OK" "$TRASHDIR/restore-out" +# ) +# end_test + +# begin_test "ghe-restore with Actions settings" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata +# enable_actions + +# required_files=( +# "actions-config-db-login" +# "actions-config-db-password" +# "actions-framework-access-token" +# "actions-url-signing-hmac-key-primary" +# "actions-url-signing-hmac-key-secondary" +# "actions-oauth-s2s-signing-cert" +# "actions-oauth-s2s-signing-key" +# "actions-oauth-s2s-signing-cert-thumbprint" +# "actions-primary-encryption-cert-thumbprint" +# "actions-aad-cert-thumbprint" +# "actions-delegated-auth-cert-thumbprint" +# "actions-runtime-service-principal-cert" +# "actions-s2s-encryption-cert" +# "actions-secondary-encryption-cert-thumbprint" +# "actions-service-principal-cert" +# "actions-sps-validation-cert-thumbprint" + +# "actions-launch-secrets-private-key" +# "actions-launch-credz-hmac" +# "actions-launch-deployer-hmac" +# "actions-launch-client-id" +# "actions-launch-client-secret" +# "actions-launch-receiver-webhook-secret" +# "actions-launch-app-private-key" +# "actions-launch-app-public-key" +# "actions-launch-app-id" +# "actions-launch-app-relay-id" +# "actions-launch-action-runner-secret" +# "actions-launch-azp-app-cert" +# "actions-launch-app-app-private-key" +# ) + +# for file in "${required_files[@]}"; do +# echo "foo" > "$GHE_DATA_DIR/current/$file" +# done + +# ghe-restore -v -f localhost + +# required_secrets=( +# "secrets.actions.ConfigurationDatabaseSqlLogin" +# "secrets.actions.ConfigurationDatabaseSqlPassword" +# "secrets.actions.FrameworkAccessTokenKeySecret" +# "secrets.actions.UrlSigningHmacKeyPrimary" +# "secrets.actions.UrlSigningHmacKeySecondary" +# "secrets.actions.OAuthS2SSigningCert" +# "secrets.actions.OAuthS2SSigningKey" +# "secrets.actions.OAuthS2SSigningCertThumbprint" +# "secrets.actions.PrimaryEncryptionCertificateThumbprint" +# "secrets.actions.AADCertThumbprint" +# "secrets.actions.DelegatedAuthCertThumbprint" +# "secrets.actions.RuntimeServicePrincipalCertificate" +# "secrets.actions.S2SEncryptionCertificate" +# "secrets.actions.SecondaryEncryptionCertificateThumbprint" +# "secrets.actions.ServicePrincipalCertificate" +# "secrets.actions.SpsValidationCertThumbprint" + +# "secrets.launch.actions-secrets-private-key" +# "secrets.launch.credz-hmac-secret" +# "secrets.launch.deployer-hmac-secret" +# "secrets.launch.client-id" +# "secrets.launch.client-secret" +# "secrets.launch.receiver-webhook-secret" +# "secrets.launch.app-private-key" +# "secrets.launch.app-public-key" +# "secrets.launch.app-id" +# "secrets.launch.app-relay-id" +# "secrets.launch.action-runner-secret" +# "secrets.launch.token-oauth-key" +# "secrets.launch.token-oauth-cert" +# "secrets.launch.azp-app-cert" +# "secrets.launch.azp-app-private-key" +# ) + +# for secret in "${required_secrets[@]}"; do +# [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] +# done +# ) +# end_test + +# begin_test "ghe-restore with Actions data" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata +# enable_actions + +# setup_maintenance_mode "configured" + +# output=$(ghe-restore -v -f localhost 2>&1) + +# echo "$output" | grep -q "Transferring Actions files to" + +# diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" +# ) +# end_test + +# begin_test "ghe-restore fails if Actions is disabled but the snapshot contains Actions data" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# setup_maintenance_mode "configured" + +# ! ghe-restore -v -f localhost +# ) +# end_test + +# # Delete Actions test data before subsequent tests +# cleanup_actions_test_data "$GHE_DATA_DIR/1" + +# begin_test "ghe-restore cluster backup to non-cluster appliance" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# echo "cluster" > "$GHE_DATA_DIR/current/strategy" +# ! output=$(ghe-restore -v -f localhost 2>&1) + +# echo $output | grep -q "Snapshot from a GitHub Enterprise cluster cannot be restored" +# ) +# end_test + +# begin_test "ghe-restore no leaked ssh host keys detected" +# ( +# set -e + +# # No leaked key message test +# ! ghe-restore -v -f localhost | grep -q "Leaked key" +# ) +# end_test + +# begin_test "ghe-restore with current backup leaked key detection" +# ( +# set -e + +# # Add a custom ssh key that will be used as part of the backup and fingerprint injection for the tests +# cat < "$GHE_DATA_DIR/ssh_host_dsa_key.pub" +# ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils +# EOF + +# # Add custom key to tar file +# tar -cf "$GHE_DATA_DIR/current/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub + +# # Inject the fingerprint into the blacklist +# export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" + +# # Running it and ignoring the actual script status but testing that the ssh host detection still happens +# output=$(ghe-restore -v -f localhost) || true + +# # Clean up, putting it back to its initial state +# echo "fake ghe-export-ssh-host-keys data" > "$GHE_DATA_DIR/current/ssh-host-keys.tar" + +# # Test for leaked key messages +# echo $output | grep -q "Leaked key found in current backup snapshot" +# echo $output | grep -q "The snapshot that is being restored contains a leaked SSH host key." +# ) +# end_test + +# begin_test "ghe-restore fails when restore to an active HA pair" +# ( +# set -e + +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_remote_metadata - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST +# echo "rsync" > "$GHE_DATA_DIR/current/strategy" +# touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" - # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi +# ! output=$(ghe-restore -v -f localhost 2>&1) - # for debugging - cat "$TRASHDIR/restore-out" +# echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." +# ) +# end_test - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# begin_test "ghe-restore honours --version flag" +# ( +# set -e - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" +# # Make sure a partial version string is returned +# ghe-restore --version | grep "GitHub backup-utils v" - # Verify all the data we've restored is as expected - verify_all_restored_data -) -end_test +# ) +# end_test -begin_test "ghe-restore logs the benchmark" -( - set -e +# begin_test "ghe-restore honours --help and -h flags" +# ( +# set -e - export BM_TIMESTAMP=foo - export GHE_RESTORE_HOST=127.0.0.1 - ghe-restore -v -f - [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] -) -end_test +# arg_help=$(ghe-restore --help | grep -o 'Usage: ghe-restore') +# arg_h=$(ghe-restore -h | grep -o 'Usage: ghe-restore') -begin_test "ghe-restore aborts without user verification" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata +# # Make sure a Usage: string is returned and that it's the same for -h and --help +# [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-restore" +# ) +# end_test - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" +# begin_test "ghe-restore exits early on unsupported version" +# ( +# set -e +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST +# ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-restore -v +# ) +# end_test - # run ghe-restore and write output to file for asserting against - if echo "no" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - false # ghe-restore should have exited non-zero - fi +# # Reset data for sub-subsequent tests +# rm -rf "$GHE_DATA_DIR/1" +# setup_test_data "$GHE_DATA_DIR/1" - grep -q "Restore aborted" "$TRASHDIR/restore-out" -) -end_test +# # Make the current symlink +# ln -s 1 "$GHE_DATA_DIR/current" -begin_test "ghe-restore accepts user verification" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata +# begin_test "ghe-restore cluster with matching node versions" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_moreutils_parallel +# setup_remote_metadata +# setup_remote_cluster +# echo "cluster" > "$GHE_DATA_DIR/current/strategy" - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" +# # set that versions should match for this test +# MATCHING_VERSIONS=1 +# export MATCHING_VERSIONS - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" - # run ghe-restore and write output to file for asserting against - if ! echo "yes" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - false # ghe-restore should have accepted the input - fi -) -end_test +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST -begin_test "ghe-restore -c into unconfigured vm" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata +# # run ghe-restore and write output to file for asserting against +# if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST +# cleanup_moreutils_parallel - # leave unconfigured, enable maintenance mode and create required directories - setup_maintenance_mode +# # for debugging +# cat "$TRASHDIR/restore-out" - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - false - fi +# # verify data was copied from multiple nodes +# # repositories +# grep -q "networks to git-server-fake-uuid" "$TRASHDIR/restore-out" +# grep -q "networks to git-server-fake-uuid1" "$TRASHDIR/restore-out" +# grep -q "networks to git-server-fake-uuid2" "$TRASHDIR/restore-out" +# grep -q "dgit-cluster-restore-finalize OK" "$TRASHDIR/restore-out" - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" +# # gists +# grep -q "gists to git-server-fake-uuid" "$TRASHDIR/restore-out" +# grep -q "gists to git-server-fake-uuid1" "$TRASHDIR/restore-out" +# grep -q "gists to git-server-fake-uuid2" "$TRASHDIR/restore-out" +# grep -q "gist-cluster-restore-finalize OK" "$TRASHDIR/restore-out" - # verify attempt to clear stale servers was not made - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { - echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." - exit 1 - } - # Verify all the data we've restored is as expected - verify_all_restored_data -) -end_test +# # storage +# grep -q "data to git-server-fake-uuid" "$TRASHDIR/restore-out" +# grep -q "data to git-server-fake-uuid1" "$TRASHDIR/restore-out" +# grep -q "data to git-server-fake-uuid2" "$TRASHDIR/restore-out" +# grep -q "storage-cluster-restore-finalize OK" "$TRASHDIR/restore-out" -begin_test "ghe-restore into unconfigured vm" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # leave unconfigured, enable maintenance mode and create required directories - setup_maintenance_mode - - # ghe-restore into an unconfigured vm implies -c - ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 - cat "$TRASHDIR/restore-out" - - # verify no config run after restore on unconfigured instance - ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" - - # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - - # verify attempt to clear stale servers was not made - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { - echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." - exit 1 - } - - # Verify all the data we've restored is as expected - verify_all_restored_data -) -end_test - -begin_test "ghe-restore with host arg and config value" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var (which we shouldn't see) - GHE_RESTORE_HOST="broken.config.restore.host" - export GHE_RESTORE_HOST - - # set restore host config var (which we shouldn't see) - GHE_BACKUP_CONFIG_TEMP="$TRASHDIR/backup.config.temp" - cp "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_CONFIG_TEMP" - echo 'GHE_RESTORE_HOST="broken.config.restore.host"' >> "$GHE_BACKUP_CONFIG_TEMP" - GHE_BACKUP_CONFIG="$GHE_BACKUP_CONFIG_TEMP" - export GHE_BACKUP_CONFIG - - # run it - output="$(ghe-restore -f localhost)" || false - - # clean up the config file - rm "$GHE_BACKUP_CONFIG_TEMP" - - # verify host arg overrides configured restore host - echo "$output" | grep -q 'Connect localhost:22 OK' - - # Verify all the data we've restored is as expected - verify_all_restored_data -) -end_test - -begin_test "ghe-restore with host arg" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var - GHE_RESTORE_HOST="broken.environ.restore.host" - export GHE_RESTORE_HOST - - # run it - output="$(ghe-restore -f localhost)" || false - - # verify host arg overrides configured restore host - echo "$output" | grep -q 'Connect localhost:22 OK' - - # Verify all the data we've restored is as expected - verify_all_restored_data -) -end_test - -begin_test "ghe-restore no host arg or configured restore host" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # unset configured restore host - unset GHE_RESTORE_HOST - - # verify running ghe-restore fails - ! ghe-restore -f -) -end_test - -begin_test "ghe-restore with no pages backup" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # remove pages data - rm -rf "$GHE_DATA_DIR/1/pages" - - # run it - ghe-restore -v -f localhost -) -end_test - -# Setup Actions data for the subsequent tests -setup_actions_test_data "$GHE_DATA_DIR/1" - -begin_test "ghe-restore invokes ghe-import-mssql" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - enable_actions - - # enable maintenance mode and create required directories - setup_maintenance_mode - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Restoring MSSQL database" "$TRASHDIR/restore-out" - grep -q "ghe-import-mssql .* OK" "$TRASHDIR/restore-out" -) -end_test - -begin_test "ghe-restore with Actions settings" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - enable_actions - - required_files=( - "actions-config-db-login" - "actions-config-db-password" - "actions-framework-access-token" - "actions-url-signing-hmac-key-primary" - "actions-url-signing-hmac-key-secondary" - "actions-oauth-s2s-signing-cert" - "actions-oauth-s2s-signing-key" - "actions-oauth-s2s-signing-cert-thumbprint" - "actions-primary-encryption-cert-thumbprint" - "actions-aad-cert-thumbprint" - "actions-delegated-auth-cert-thumbprint" - "actions-runtime-service-principal-cert" - "actions-s2s-encryption-cert" - "actions-secondary-encryption-cert-thumbprint" - "actions-service-principal-cert" - "actions-sps-validation-cert-thumbprint" - - "actions-launch-secrets-private-key" - "actions-launch-credz-hmac" - "actions-launch-deployer-hmac" - "actions-launch-client-id" - "actions-launch-client-secret" - "actions-launch-receiver-webhook-secret" - "actions-launch-app-private-key" - "actions-launch-app-public-key" - "actions-launch-app-id" - "actions-launch-app-relay-id" - "actions-launch-action-runner-secret" - "actions-launch-azp-app-cert" - "actions-launch-app-app-private-key" - ) - - for file in "${required_files[@]}"; do - echo "foo" > "$GHE_DATA_DIR/current/$file" - done - - ghe-restore -v -f localhost - - required_secrets=( - "secrets.actions.ConfigurationDatabaseSqlLogin" - "secrets.actions.ConfigurationDatabaseSqlPassword" - "secrets.actions.FrameworkAccessTokenKeySecret" - "secrets.actions.UrlSigningHmacKeyPrimary" - "secrets.actions.UrlSigningHmacKeySecondary" - "secrets.actions.OAuthS2SSigningCert" - "secrets.actions.OAuthS2SSigningKey" - "secrets.actions.OAuthS2SSigningCertThumbprint" - "secrets.actions.PrimaryEncryptionCertificateThumbprint" - "secrets.actions.AADCertThumbprint" - "secrets.actions.DelegatedAuthCertThumbprint" - "secrets.actions.RuntimeServicePrincipalCertificate" - "secrets.actions.S2SEncryptionCertificate" - "secrets.actions.SecondaryEncryptionCertificateThumbprint" - "secrets.actions.ServicePrincipalCertificate" - "secrets.actions.SpsValidationCertThumbprint" - - "secrets.launch.actions-secrets-private-key" - "secrets.launch.credz-hmac-secret" - "secrets.launch.deployer-hmac-secret" - "secrets.launch.client-id" - "secrets.launch.client-secret" - "secrets.launch.receiver-webhook-secret" - "secrets.launch.app-private-key" - "secrets.launch.app-public-key" - "secrets.launch.app-id" - "secrets.launch.app-relay-id" - "secrets.launch.action-runner-secret" - "secrets.launch.token-oauth-key" - "secrets.launch.token-oauth-cert" - "secrets.launch.azp-app-cert" - "secrets.launch.azp-app-private-key" - ) - - for secret in "${required_secrets[@]}"; do - [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] - done -) -end_test - -begin_test "ghe-restore with Actions data" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - enable_actions - - setup_maintenance_mode "configured" - - output=$(ghe-restore -v -f localhost 2>&1) - - echo "$output" | grep -q "Transferring Actions files to" - - diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" -) -end_test - -begin_test "ghe-restore fails if Actions is disabled but the snapshot contains Actions data" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - setup_maintenance_mode "configured" - - ! ghe-restore -v -f localhost -) -end_test - -# Delete Actions test data before subsequent tests -cleanup_actions_test_data "$GHE_DATA_DIR/1" - -begin_test "ghe-restore cluster backup to non-cluster appliance" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - echo "cluster" > "$GHE_DATA_DIR/current/strategy" - ! output=$(ghe-restore -v -f localhost 2>&1) - - echo $output | grep -q "Snapshot from a GitHub Enterprise cluster cannot be restored" -) -end_test - -begin_test "ghe-restore no leaked ssh host keys detected" -( - set -e - - # No leaked key message test - ! ghe-restore -v -f localhost | grep -q "Leaked key" -) -end_test - -begin_test "ghe-restore with current backup leaked key detection" -( - set -e - - # Add a custom ssh key that will be used as part of the backup and fingerprint injection for the tests - cat < "$GHE_DATA_DIR/ssh_host_dsa_key.pub" -ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils -EOF - - # Add custom key to tar file - tar -cf "$GHE_DATA_DIR/current/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub - - # Inject the fingerprint into the blacklist - export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" - - # Running it and ignoring the actual script status but testing that the ssh host detection still happens - output=$(ghe-restore -v -f localhost) || true - - # Clean up, putting it back to its initial state - echo "fake ghe-export-ssh-host-keys data" > "$GHE_DATA_DIR/current/ssh-host-keys.tar" - - # Test for leaked key messages - echo $output | grep -q "Leaked key found in current backup snapshot" - echo $output | grep -q "The snapshot that is being restored contains a leaked SSH host key." -) -end_test - -begin_test "ghe-restore fails when restore to an active HA pair" -( - set -e - - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - echo "rsync" > "$GHE_DATA_DIR/current/strategy" - touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" - - ! output=$(ghe-restore -v -f localhost 2>&1) - - echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." -) -end_test - -begin_test "ghe-restore honours --version flag" -( - set -e - - # Make sure a partial version string is returned - ghe-restore --version | grep "GitHub backup-utils v" - -) -end_test - -begin_test "ghe-restore honours --help and -h flags" -( - set -e - - arg_help=$(ghe-restore --help | grep -o 'Usage: ghe-restore') - arg_h=$(ghe-restore -h | grep -o 'Usage: ghe-restore') - - # Make sure a Usage: string is returned and that it's the same for -h and --help - [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-restore" -) -end_test - -begin_test "ghe-restore exits early on unsupported version" -( - set -e - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-restore -v -) -end_test - -# Reset data for sub-subsequent tests -rm -rf "$GHE_DATA_DIR/1" -setup_test_data "$GHE_DATA_DIR/1" - -# Make the current symlink -ln -s 1 "$GHE_DATA_DIR/current" - -begin_test "ghe-restore cluster" + +# # pages +# grep -q "Pages to git-server-fake-uuid" "$TRASHDIR/restore-out" +# grep -q "Pages to git-server-fake-uuid1" "$TRASHDIR/restore-out" +# grep -q "Pages to git-server-fake-uuid2" "$TRASHDIR/restore-out" +# grep -q "dpages-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + +# # verify no warnings printed +# ! grep -q "Warning" "$TRASHDIR/restore-out" + +# # Verify all the data we've restored is as expected +# verify_all_restored_data +# ) +# end_test + +begin_test "ghe-restore cluster with different node versions should fail at ghe-host-check" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -551,90 +618,50 @@ begin_test "ghe-restore cluster" GHE_RESTORE_HOST=127.0.0.1 export GHE_RESTORE_HOST - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi + ! output=$(ghe-restore -v -f 2>&1) - cleanup_moreutils_parallel + echo "$output" | grep -q "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." +) +end_test - # for debugging - cat "$TRASHDIR/restore-out" - # verify data was copied from multiple nodes - # repositories - grep -q "networks to git-server-fake-uuid" "$TRASHDIR/restore-out" - grep -q "networks to git-server-fake-uuid1" "$TRASHDIR/restore-out" - grep -q "networks to git-server-fake-uuid2" "$TRASHDIR/restore-out" - grep -q "dgit-cluster-restore-finalize OK" "$TRASHDIR/restore-out" +# begin_test "ghe-restore missing directories or files from source snapshot displays warning" +# ( +# # Tests the scenario where something exists in the database, but not on disk. +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_moreutils_parallel +# setup_remote_metadata +# setup_remote_cluster +# echo "cluster" > "$GHE_DATA_DIR/current/strategy" - # gists - grep -q "gists to git-server-fake-uuid" "$TRASHDIR/restore-out" - grep -q "gists to git-server-fake-uuid1" "$TRASHDIR/restore-out" - grep -q "gists to git-server-fake-uuid2" "$TRASHDIR/restore-out" - grep -q "gist-cluster-restore-finalize OK" "$TRASHDIR/restore-out" +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST - # storage - grep -q "data to git-server-fake-uuid" "$TRASHDIR/restore-out" - grep -q "data to git-server-fake-uuid1" "$TRASHDIR/restore-out" - grep -q "data to git-server-fake-uuid2" "$TRASHDIR/restore-out" - grep -q "storage-cluster-restore-finalize OK" "$TRASHDIR/restore-out" +# # Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings +# export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1 +# export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1 +# # run ghe-restore and write output to file for asserting against +# if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi - # pages - grep -q "Pages to git-server-fake-uuid" "$TRASHDIR/restore-out" - grep -q "Pages to git-server-fake-uuid1" "$TRASHDIR/restore-out" - grep -q "Pages to git-server-fake-uuid2" "$TRASHDIR/restore-out" - grep -q "dpages-cluster-restore-finalize OK" "$TRASHDIR/restore-out" +# cleanup_moreutils_parallel - # verify no warnings printed - ! grep -q "Warning" "$TRASHDIR/restore-out" +# # for debugging +# cat "$TRASHDIR/restore-out" - # Verify all the data we've restored is as expected - verify_all_restored_data -) -end_test +# grep -q "Warning: One or more repository networks failed to restore successfully." "$TRASHDIR/restore-out" +# grep -q "Warning: One or more Gists failed to restore successfully." "$TRASHDIR/restore-out" -begin_test "ghe-restore missing directories or files from source snapshot displays warning" -( - # Tests the scenario where something exists in the database, but not on disk. - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_moreutils_parallel - setup_remote_metadata - setup_remote_cluster - echo "cluster" > "$GHE_DATA_DIR/current/strategy" - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings - export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1 - export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1 - - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - cleanup_moreutils_parallel - - # for debugging - cat "$TRASHDIR/restore-out" - - grep -q "Warning: One or more repository networks failed to restore successfully." "$TRASHDIR/restore-out" - grep -q "Warning: One or more Gists failed to restore successfully." "$TRASHDIR/restore-out" - - # Verify all the data we've restored is as expected - verify_all_restored_data -) -end_test +# # Verify all the data we've restored is as expected +# verify_all_restored_data +# ) +# end_test From 6c0797b45e478e454dab30207586f8c6795afd56 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Thu, 17 Dec 2020 22:28:04 +0000 Subject: [PATCH 1278/2421] remove extra new line and uncomment tests --- test/bin/ghe-cluster-each | 1 - test/test-ghe-restore.sh | 1204 ++++++++++++++++++------------------- 2 files changed, 602 insertions(+), 603 deletions(-) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 16f610562..835ea181f 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -29,7 +29,6 @@ if [ "$2" == "ghe-version" ]; then echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" echo "fake-uuid2: GitHub Enterprise Server 2.19 lxc 2020-12-13 5e97c07622" fi - exit 0 fi diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index ffe035681..358f2cd7a 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -10,599 +10,532 @@ setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" -# begin_test "ghe-restore-snapshot-path reports an error when current symlink doesn't exist" -# ( -# set -e -# rm "$GHE_DATA_DIR/current" - -# ghe-restore-snapshot-path > "$TRASHDIR/restore-out" 2>&1 || true -# ln -s 1 "$GHE_DATA_DIR/current" -# grep -q "Error: Snapshot 'current' doesn't exist." "$TRASHDIR/restore-out" -# ) -# end_test - -# begin_test "ghe-restore-snapshot-path reports an error when specified snapshot doesn't exist" -# ( -# set -e -# rm "$GHE_DATA_DIR/current" - -# ghe-restore-snapshot-path foo > "$TRASHDIR/restore-out" 2>&1 || true -# ln -s 1 "$GHE_DATA_DIR/current" -# grep -q "Error: Snapshot 'foo' doesn't exist." "$TRASHDIR/restore-out" -# ) -# end_test - -# begin_test "ghe-restore into configured vm" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" - -# # set restore host environ var -# GHE_RESTORE_HOST=127.0.0.1 -# export GHE_RESTORE_HOST - -# # run ghe-restore and write output to file for asserting against -# if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi - -# # for debugging -# cat "$TRASHDIR/restore-out" - -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - -# # verify stale servers were cleared -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - -# # Verify all the data we've restored is as expected -# verify_all_restored_data -# ) -# end_test - -# begin_test "ghe-restore logs the benchmark" -# ( -# set -e - -# export BM_TIMESTAMP=foo -# export GHE_RESTORE_HOST=127.0.0.1 -# ghe-restore -v -f -# [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] -# ) -# end_test - -# begin_test "ghe-restore aborts without user verification" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" - -# # set restore host environ var -# GHE_RESTORE_HOST=127.0.0.1 -# export GHE_RESTORE_HOST - -# # run ghe-restore and write output to file for asserting against -# if echo "no" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then -# cat "$TRASHDIR/restore-out" -# false # ghe-restore should have exited non-zero -# fi - -# grep -q "Restore aborted" "$TRASHDIR/restore-out" -# ) -# end_test - -# begin_test "ghe-restore accepts user verification" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" - -# # set restore host environ var -# GHE_RESTORE_HOST=127.0.0.1 -# export GHE_RESTORE_HOST - -# # run ghe-restore and write output to file for asserting against -# if ! echo "yes" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then -# cat "$TRASHDIR/restore-out" -# false # ghe-restore should have accepted the input -# fi -# ) -# end_test - -# begin_test "ghe-restore -c into unconfigured vm" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set restore host environ var -# GHE_RESTORE_HOST=127.0.0.1 -# export GHE_RESTORE_HOST - -# # leave unconfigured, enable maintenance mode and create required directories -# setup_maintenance_mode - -# # run ghe-restore and write output to file for asserting against -# if ! ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then -# cat "$TRASHDIR/restore-out" -# false -# fi - -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - -# # verify attempt to clear stale servers was not made -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { -# echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." -# exit 1 -# } - -# # Verify all the data we've restored is as expected -# verify_all_restored_data -# ) -# end_test - -# begin_test "ghe-restore into unconfigured vm" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set restore host environ var -# GHE_RESTORE_HOST=127.0.0.1 -# export GHE_RESTORE_HOST - -# # leave unconfigured, enable maintenance mode and create required directories -# setup_maintenance_mode - -# # ghe-restore into an unconfigured vm implies -c -# ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 -# cat "$TRASHDIR/restore-out" - -# # verify no config run after restore on unconfigured instance -# ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" - -# # verify connect to right host -# grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - -# # verify attempt to clear stale servers was not made -# grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { -# echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." -# exit 1 -# } - -# # Verify all the data we've restored is as expected -# verify_all_restored_data -# ) -# end_test - -# begin_test "ghe-restore with host arg and config value" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" - -# # set restore host environ var (which we shouldn't see) -# GHE_RESTORE_HOST="broken.config.restore.host" -# export GHE_RESTORE_HOST - -# # set restore host config var (which we shouldn't see) -# GHE_BACKUP_CONFIG_TEMP="$TRASHDIR/backup.config.temp" -# cp "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_CONFIG_TEMP" -# echo 'GHE_RESTORE_HOST="broken.config.restore.host"' >> "$GHE_BACKUP_CONFIG_TEMP" -# GHE_BACKUP_CONFIG="$GHE_BACKUP_CONFIG_TEMP" -# export GHE_BACKUP_CONFIG - -# # run it -# output="$(ghe-restore -f localhost)" || false - -# # clean up the config file -# rm "$GHE_BACKUP_CONFIG_TEMP" - -# # verify host arg overrides configured restore host -# echo "$output" | grep -q 'Connect localhost:22 OK' - -# # Verify all the data we've restored is as expected -# verify_all_restored_data -# ) -# end_test - -# begin_test "ghe-restore with host arg" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" - -# # set restore host environ var -# GHE_RESTORE_HOST="broken.environ.restore.host" -# export GHE_RESTORE_HOST - -# # run it -# output="$(ghe-restore -f localhost)" || false - -# # verify host arg overrides configured restore host -# echo "$output" | grep -q 'Connect localhost:22 OK' - -# # Verify all the data we've restored is as expected -# verify_all_restored_data -# ) -# end_test - -# begin_test "ghe-restore no host arg or configured restore host" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" - -# # unset configured restore host -# unset GHE_RESTORE_HOST - -# # verify running ghe-restore fails -# ! ghe-restore -f -# ) -# end_test - -# begin_test "ghe-restore with no pages backup" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" - -# # remove pages data -# rm -rf "$GHE_DATA_DIR/1/pages" - -# # run it -# ghe-restore -v -f localhost -# ) -# end_test - -# # Setup Actions data for the subsequent tests -# setup_actions_test_data "$GHE_DATA_DIR/1" - -# begin_test "ghe-restore invokes ghe-import-mssql" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata -# enable_actions - -# # enable maintenance mode and create required directories -# setup_maintenance_mode - -# # set restore host environ var -# GHE_RESTORE_HOST=127.0.0.1 -# export GHE_RESTORE_HOST - -# # run ghe-restore and write output to file for asserting against -# if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi - -# grep -q "Restoring MSSQL database" "$TRASHDIR/restore-out" -# grep -q "ghe-import-mssql .* OK" "$TRASHDIR/restore-out" -# ) -# end_test - -# begin_test "ghe-restore with Actions settings" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata -# enable_actions - -# required_files=( -# "actions-config-db-login" -# "actions-config-db-password" -# "actions-framework-access-token" -# "actions-url-signing-hmac-key-primary" -# "actions-url-signing-hmac-key-secondary" -# "actions-oauth-s2s-signing-cert" -# "actions-oauth-s2s-signing-key" -# "actions-oauth-s2s-signing-cert-thumbprint" -# "actions-primary-encryption-cert-thumbprint" -# "actions-aad-cert-thumbprint" -# "actions-delegated-auth-cert-thumbprint" -# "actions-runtime-service-principal-cert" -# "actions-s2s-encryption-cert" -# "actions-secondary-encryption-cert-thumbprint" -# "actions-service-principal-cert" -# "actions-sps-validation-cert-thumbprint" - -# "actions-launch-secrets-private-key" -# "actions-launch-credz-hmac" -# "actions-launch-deployer-hmac" -# "actions-launch-client-id" -# "actions-launch-client-secret" -# "actions-launch-receiver-webhook-secret" -# "actions-launch-app-private-key" -# "actions-launch-app-public-key" -# "actions-launch-app-id" -# "actions-launch-app-relay-id" -# "actions-launch-action-runner-secret" -# "actions-launch-azp-app-cert" -# "actions-launch-app-app-private-key" -# ) - -# for file in "${required_files[@]}"; do -# echo "foo" > "$GHE_DATA_DIR/current/$file" -# done - -# ghe-restore -v -f localhost - -# required_secrets=( -# "secrets.actions.ConfigurationDatabaseSqlLogin" -# "secrets.actions.ConfigurationDatabaseSqlPassword" -# "secrets.actions.FrameworkAccessTokenKeySecret" -# "secrets.actions.UrlSigningHmacKeyPrimary" -# "secrets.actions.UrlSigningHmacKeySecondary" -# "secrets.actions.OAuthS2SSigningCert" -# "secrets.actions.OAuthS2SSigningKey" -# "secrets.actions.OAuthS2SSigningCertThumbprint" -# "secrets.actions.PrimaryEncryptionCertificateThumbprint" -# "secrets.actions.AADCertThumbprint" -# "secrets.actions.DelegatedAuthCertThumbprint" -# "secrets.actions.RuntimeServicePrincipalCertificate" -# "secrets.actions.S2SEncryptionCertificate" -# "secrets.actions.SecondaryEncryptionCertificateThumbprint" -# "secrets.actions.ServicePrincipalCertificate" -# "secrets.actions.SpsValidationCertThumbprint" - -# "secrets.launch.actions-secrets-private-key" -# "secrets.launch.credz-hmac-secret" -# "secrets.launch.deployer-hmac-secret" -# "secrets.launch.client-id" -# "secrets.launch.client-secret" -# "secrets.launch.receiver-webhook-secret" -# "secrets.launch.app-private-key" -# "secrets.launch.app-public-key" -# "secrets.launch.app-id" -# "secrets.launch.app-relay-id" -# "secrets.launch.action-runner-secret" -# "secrets.launch.token-oauth-key" -# "secrets.launch.token-oauth-cert" -# "secrets.launch.azp-app-cert" -# "secrets.launch.azp-app-private-key" -# ) - -# for secret in "${required_secrets[@]}"; do -# [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] -# done -# ) -# end_test - -# begin_test "ghe-restore with Actions data" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata -# enable_actions - -# setup_maintenance_mode "configured" - -# output=$(ghe-restore -v -f localhost 2>&1) - -# echo "$output" | grep -q "Transferring Actions files to" - -# diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" -# ) -# end_test - -# begin_test "ghe-restore fails if Actions is disabled but the snapshot contains Actions data" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# setup_maintenance_mode "configured" - -# ! ghe-restore -v -f localhost -# ) -# end_test - -# # Delete Actions test data before subsequent tests -# cleanup_actions_test_data "$GHE_DATA_DIR/1" - -# begin_test "ghe-restore cluster backup to non-cluster appliance" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata - -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" - -# echo "cluster" > "$GHE_DATA_DIR/current/strategy" -# ! output=$(ghe-restore -v -f localhost 2>&1) - -# echo $output | grep -q "Snapshot from a GitHub Enterprise cluster cannot be restored" -# ) -# end_test - -# begin_test "ghe-restore no leaked ssh host keys detected" -# ( -# set -e - -# # No leaked key message test -# ! ghe-restore -v -f localhost | grep -q "Leaked key" -# ) -# end_test - -# begin_test "ghe-restore with current backup leaked key detection" -# ( -# set -e - -# # Add a custom ssh key that will be used as part of the backup and fingerprint injection for the tests -# cat < "$GHE_DATA_DIR/ssh_host_dsa_key.pub" -# ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils -# EOF - -# # Add custom key to tar file -# tar -cf "$GHE_DATA_DIR/current/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub - -# # Inject the fingerprint into the blacklist -# export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" - -# # Running it and ignoring the actual script status but testing that the ssh host detection still happens -# output=$(ghe-restore -v -f localhost) || true - -# # Clean up, putting it back to its initial state -# echo "fake ghe-export-ssh-host-keys data" > "$GHE_DATA_DIR/current/ssh-host-keys.tar" - -# # Test for leaked key messages -# echo $output | grep -q "Leaked key found in current backup snapshot" -# echo $output | grep -q "The snapshot that is being restored contains a leaked SSH host key." -# ) -# end_test - -# begin_test "ghe-restore fails when restore to an active HA pair" -# ( -# set -e - -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_remote_metadata +begin_test "ghe-restore-snapshot-path reports an error when current symlink doesn't exist" +( + set -e + rm "$GHE_DATA_DIR/current" -# echo "rsync" > "$GHE_DATA_DIR/current/strategy" -# touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + ghe-restore-snapshot-path > "$TRASHDIR/restore-out" 2>&1 || true + ln -s 1 "$GHE_DATA_DIR/current" + grep -q "Error: Snapshot 'current' doesn't exist." "$TRASHDIR/restore-out" +) +end_test -# ! output=$(ghe-restore -v -f localhost 2>&1) +begin_test "ghe-restore-snapshot-path reports an error when specified snapshot doesn't exist" +( + set -e + rm "$GHE_DATA_DIR/current" + + ghe-restore-snapshot-path foo > "$TRASHDIR/restore-out" 2>&1 || true + ln -s 1 "$GHE_DATA_DIR/current" + grep -q "Error: Snapshot 'foo' doesn't exist." "$TRASHDIR/restore-out" +) +end_test -# echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." -# ) -# end_test +begin_test "ghe-restore into configured vm" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata -# begin_test "ghe-restore honours --version flag" -# ( -# set -e + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" -# # Make sure a partial version string is returned -# ghe-restore --version | grep "GitHub backup-utils v" + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST -# ) -# end_test + # run ghe-restore and write output to file for asserting against + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + # for debugging + cat "$TRASHDIR/restore-out" + + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" + + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test + +begin_test "ghe-restore logs the benchmark" +( + set -e + + export BM_TIMESTAMP=foo + export GHE_RESTORE_HOST=127.0.0.1 + ghe-restore -v -f + [ "$(grep took $GHE_DATA_DIR/current/benchmarks/benchmark.foo.log | wc -l)" -gt 1 ] +) +end_test + +begin_test "ghe-restore aborts without user verification" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata -# begin_test "ghe-restore honours --help and -h flags" -# ( -# set -e + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" -# arg_help=$(ghe-restore --help | grep -o 'Usage: ghe-restore') -# arg_h=$(ghe-restore -h | grep -o 'Usage: ghe-restore') + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST -# # Make sure a Usage: string is returned and that it's the same for -h and --help -# [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-restore" -# ) -# end_test + # run ghe-restore and write output to file for asserting against + if echo "no" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + false # ghe-restore should have exited non-zero + fi -# begin_test "ghe-restore exits early on unsupported version" -# ( -# set -e -# GHE_RESTORE_HOST=127.0.0.1 -# export GHE_RESTORE_HOST + grep -q "Restore aborted" "$TRASHDIR/restore-out" +) +end_test -# ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-restore -v -# ) -# end_test +begin_test "ghe-restore accepts user verification" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata -# # Reset data for sub-subsequent tests -# rm -rf "$GHE_DATA_DIR/1" -# setup_test_data "$GHE_DATA_DIR/1" + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" -# # Make the current symlink -# ln -s 1 "$GHE_DATA_DIR/current" + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST -# begin_test "ghe-restore cluster with matching node versions" -# ( -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_moreutils_parallel -# setup_remote_metadata -# setup_remote_cluster -# echo "cluster" > "$GHE_DATA_DIR/current/strategy" + # run ghe-restore and write output to file for asserting against + if ! echo "yes" | ghe-restore -v > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + false # ghe-restore should have accepted the input + fi +) +end_test -# # set that versions should match for this test -# MATCHING_VERSIONS=1 -# export MATCHING_VERSIONS +begin_test "ghe-restore -c into unconfigured vm" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST -# # set restore host environ var -# GHE_RESTORE_HOST=127.0.0.1 -# export GHE_RESTORE_HOST + # leave unconfigured, enable maintenance mode and create required directories + setup_maintenance_mode -# # run ghe-restore and write output to file for asserting against -# if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f -c > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + false + fi -# cleanup_moreutils_parallel + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" -# # for debugging -# cat "$TRASHDIR/restore-out" + # verify attempt to clear stale servers was not made + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { + echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." + exit 1 + } -# # verify data was copied from multiple nodes -# # repositories -# grep -q "networks to git-server-fake-uuid" "$TRASHDIR/restore-out" -# grep -q "networks to git-server-fake-uuid1" "$TRASHDIR/restore-out" -# grep -q "networks to git-server-fake-uuid2" "$TRASHDIR/restore-out" -# grep -q "dgit-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test -# # gists -# grep -q "gists to git-server-fake-uuid" "$TRASHDIR/restore-out" -# grep -q "gists to git-server-fake-uuid1" "$TRASHDIR/restore-out" -# grep -q "gists to git-server-fake-uuid2" "$TRASHDIR/restore-out" -# grep -q "gist-cluster-restore-finalize OK" "$TRASHDIR/restore-out" +begin_test "ghe-restore into unconfigured vm" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST -# # storage -# grep -q "data to git-server-fake-uuid" "$TRASHDIR/restore-out" -# grep -q "data to git-server-fake-uuid1" "$TRASHDIR/restore-out" -# grep -q "data to git-server-fake-uuid2" "$TRASHDIR/restore-out" -# grep -q "storage-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + # leave unconfigured, enable maintenance mode and create required directories + setup_maintenance_mode + # ghe-restore into an unconfigured vm implies -c + ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 + cat "$TRASHDIR/restore-out" -# # pages -# grep -q "Pages to git-server-fake-uuid" "$TRASHDIR/restore-out" -# grep -q "Pages to git-server-fake-uuid1" "$TRASHDIR/restore-out" -# grep -q "Pages to git-server-fake-uuid2" "$TRASHDIR/restore-out" -# grep -q "dpages-cluster-restore-finalize OK" "$TRASHDIR/restore-out" - -# # verify no warnings printed -# ! grep -q "Warning" "$TRASHDIR/restore-out" - -# # Verify all the data we've restored is as expected -# verify_all_restored_data -# ) -# end_test + # verify no config run after restore on unconfigured instance + ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" -begin_test "ghe-restore cluster with different node versions should fail at ghe-host-check" + # verify connect to right host + grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + + # verify attempt to clear stale servers was not made + grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { + echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." + exit 1 + } + + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test + +begin_test "ghe-restore with host arg and config value" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var (which we shouldn't see) + GHE_RESTORE_HOST="broken.config.restore.host" + export GHE_RESTORE_HOST + + # set restore host config var (which we shouldn't see) + GHE_BACKUP_CONFIG_TEMP="$TRASHDIR/backup.config.temp" + cp "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_CONFIG_TEMP" + echo 'GHE_RESTORE_HOST="broken.config.restore.host"' >> "$GHE_BACKUP_CONFIG_TEMP" + GHE_BACKUP_CONFIG="$GHE_BACKUP_CONFIG_TEMP" + export GHE_BACKUP_CONFIG + + # run it + output="$(ghe-restore -f localhost)" || false + + # clean up the config file + rm "$GHE_BACKUP_CONFIG_TEMP" + + # verify host arg overrides configured restore host + echo "$output" | grep -q 'Connect localhost:22 OK' + + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test + +begin_test "ghe-restore with host arg" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST="broken.environ.restore.host" + export GHE_RESTORE_HOST + + # run it + output="$(ghe-restore -f localhost)" || false + + # verify host arg overrides configured restore host + echo "$output" | grep -q 'Connect localhost:22 OK' + + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test + +begin_test "ghe-restore no host arg or configured restore host" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # unset configured restore host + unset GHE_RESTORE_HOST + + # verify running ghe-restore fails + ! ghe-restore -f +) +end_test + +begin_test "ghe-restore with no pages backup" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # remove pages data + rm -rf "$GHE_DATA_DIR/1/pages" + + # run it + ghe-restore -v -f localhost +) +end_test + +# Setup Actions data for the subsequent tests +setup_actions_test_data "$GHE_DATA_DIR/1" + +begin_test "ghe-restore invokes ghe-import-mssql" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + # enable maintenance mode and create required directories + setup_maintenance_mode + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Restoring MSSQL database" "$TRASHDIR/restore-out" + grep -q "ghe-import-mssql .* OK" "$TRASHDIR/restore-out" +) +end_test + +begin_test "ghe-restore with Actions settings" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + required_files=( + "actions-config-db-login" + "actions-config-db-password" + "actions-framework-access-token" + "actions-url-signing-hmac-key-primary" + "actions-url-signing-hmac-key-secondary" + "actions-oauth-s2s-signing-cert" + "actions-oauth-s2s-signing-key" + "actions-oauth-s2s-signing-cert-thumbprint" + "actions-primary-encryption-cert-thumbprint" + "actions-aad-cert-thumbprint" + "actions-delegated-auth-cert-thumbprint" + "actions-runtime-service-principal-cert" + "actions-s2s-encryption-cert" + "actions-secondary-encryption-cert-thumbprint" + "actions-service-principal-cert" + "actions-sps-validation-cert-thumbprint" + + "actions-launch-secrets-private-key" + "actions-launch-credz-hmac" + "actions-launch-deployer-hmac" + "actions-launch-client-id" + "actions-launch-client-secret" + "actions-launch-receiver-webhook-secret" + "actions-launch-app-private-key" + "actions-launch-app-public-key" + "actions-launch-app-id" + "actions-launch-app-relay-id" + "actions-launch-action-runner-secret" + "actions-launch-azp-app-cert" + "actions-launch-app-app-private-key" + ) + + for file in "${required_files[@]}"; do + echo "foo" > "$GHE_DATA_DIR/current/$file" + done + + ghe-restore -v -f localhost + + required_secrets=( + "secrets.actions.ConfigurationDatabaseSqlLogin" + "secrets.actions.ConfigurationDatabaseSqlPassword" + "secrets.actions.FrameworkAccessTokenKeySecret" + "secrets.actions.UrlSigningHmacKeyPrimary" + "secrets.actions.UrlSigningHmacKeySecondary" + "secrets.actions.OAuthS2SSigningCert" + "secrets.actions.OAuthS2SSigningKey" + "secrets.actions.OAuthS2SSigningCertThumbprint" + "secrets.actions.PrimaryEncryptionCertificateThumbprint" + "secrets.actions.AADCertThumbprint" + "secrets.actions.DelegatedAuthCertThumbprint" + "secrets.actions.RuntimeServicePrincipalCertificate" + "secrets.actions.S2SEncryptionCertificate" + "secrets.actions.SecondaryEncryptionCertificateThumbprint" + "secrets.actions.ServicePrincipalCertificate" + "secrets.actions.SpsValidationCertThumbprint" + + "secrets.launch.actions-secrets-private-key" + "secrets.launch.credz-hmac-secret" + "secrets.launch.deployer-hmac-secret" + "secrets.launch.client-id" + "secrets.launch.client-secret" + "secrets.launch.receiver-webhook-secret" + "secrets.launch.app-private-key" + "secrets.launch.app-public-key" + "secrets.launch.app-id" + "secrets.launch.app-relay-id" + "secrets.launch.action-runner-secret" + "secrets.launch.token-oauth-key" + "secrets.launch.token-oauth-cert" + "secrets.launch.azp-app-cert" + "secrets.launch.azp-app-private-key" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done +) +end_test + +begin_test "ghe-restore with Actions data" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + setup_maintenance_mode "configured" + + output=$(ghe-restore -v -f localhost 2>&1) + + echo "$output" | grep -q "Transferring Actions files to" + + diff -ru "$GHE_REMOTE_DATA_USER_DIR/actions" "$GHE_DATA_DIR/current/actions" +) +end_test + +begin_test "ghe-restore fails if Actions is disabled but the snapshot contains Actions data" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + setup_maintenance_mode "configured" + + ! ghe-restore -v -f localhost +) +end_test + +# Delete Actions test data before subsequent tests +cleanup_actions_test_data "$GHE_DATA_DIR/1" + +begin_test "ghe-restore cluster backup to non-cluster appliance" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + echo "cluster" > "$GHE_DATA_DIR/current/strategy" + ! output=$(ghe-restore -v -f localhost 2>&1) + + echo $output | grep -q "Snapshot from a GitHub Enterprise cluster cannot be restored" +) +end_test + +begin_test "ghe-restore no leaked ssh host keys detected" +( + set -e + + # No leaked key message test + ! ghe-restore -v -f localhost | grep -q "Leaked key" +) +end_test + +begin_test "ghe-restore with current backup leaked key detection" +( + set -e + + # Add a custom ssh key that will be used as part of the backup and fingerprint injection for the tests + cat < "$GHE_DATA_DIR/ssh_host_dsa_key.pub" +ssh-dss AAAAB3NzaC1kc3MAAACBAMv7O3YNWyAOj6Oa6QhG2qL67FSDoR96cYILilsQpn1j+f21uXOYBRdqauP+8XS2sPYZy6p/T3gJhCeC6ppQWY8n8Wjs/oS8j+nl5KX7JbIqzvSIb0tAKnMI67pqCHTHWx+LGvslgRALJuGxOo7Bp551bNN02Y2gfm2TlHOv6DarAAAAFQChqAK2KkHI+WNkFj54GwGYdX+GCQAAAIEApmXYiT7OYXfmiHzhJ/jfT1ZErPAOwqLbhLTeKL34DkAH9J/DImLAC0tlSyDXjlMzwPbmECdu6LNYh4OZq7vAN/mcM2+Sue1cuJRmkt5B1NYox4fRs3o9RO+DGOcbogUUUQu7OIM/o95zF6dFEfxIWnSsmYvl+Ync4fEgN6ZLjtMAAACBAMRYjDs0g1a9rocKzUQ7fazaXnSNHxZADQW6SIodt7ic1fq4OoO0yUoBf/DSOF8MC/XTSLn33awI9SrbQ5Kk0oGxmV1waoFkqW/MDlypC8sHG0/gxzeJICkwjh/1OVwF6+e0C/6bxtUwV/I+BeMtZ6U2tKy15FKp5Mod7bLBgiee test@backup-utils +EOF + + # Add custom key to tar file + tar -cf "$GHE_DATA_DIR/current/ssh-host-keys.tar" --directory="$GHE_DATA_DIR" ssh_host_dsa_key.pub + + # Inject the fingerprint into the blacklist + export FINGERPRINT_BLACKLIST="98:d8:99:d3:be:c0:55:05:db:b0:53:2f:1f:ad:b3:60" + + # Running it and ignoring the actual script status but testing that the ssh host detection still happens + output=$(ghe-restore -v -f localhost) || true + + # Clean up, putting it back to its initial state + echo "fake ghe-export-ssh-host-keys data" > "$GHE_DATA_DIR/current/ssh-host-keys.tar" + + # Test for leaked key messages + echo $output | grep -q "Leaked key found in current backup snapshot" + echo $output | grep -q "The snapshot that is being restored contains a leaked SSH host key." +) +end_test + +begin_test "ghe-restore fails when restore to an active HA pair" +( + set -e + + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + echo "rsync" > "$GHE_DATA_DIR/current/strategy" + touch "$GHE_REMOTE_ROOT_DIR/etc/github/repl-state" + + ! output=$(ghe-restore -v -f localhost 2>&1) + + echo $output | grep -q "Error: Restoring to an appliance with replication enabled is not supported." +) +end_test + +begin_test "ghe-restore honours --version flag" +( + set -e + + # Make sure a partial version string is returned + ghe-restore --version | grep "GitHub backup-utils v" + +) +end_test + +begin_test "ghe-restore honours --help and -h flags" +( + set -e + + arg_help=$(ghe-restore --help | grep -o 'Usage: ghe-restore') + arg_h=$(ghe-restore -h | grep -o 'Usage: ghe-restore') + + # Make sure a Usage: string is returned and that it's the same for -h and --help + [ "$arg_help" = "$arg_h" ] && echo $arg_help | grep -q "Usage: ghe-restore" +) +end_test + +begin_test "ghe-restore exits early on unsupported version" +( + set -e + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + ! GHE_TEST_REMOTE_VERSION=2.10.0 ghe-restore -v +) +end_test + +# Reset data for sub-subsequent tests +rm -rf "$GHE_DATA_DIR/1" +setup_test_data "$GHE_DATA_DIR/1" + +# Make the current symlink +ln -s 1 "$GHE_DATA_DIR/current" + +begin_test "ghe-restore cluster with matching node versions" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -611,6 +544,10 @@ begin_test "ghe-restore cluster with different node versions should fail at ghe- setup_remote_cluster echo "cluster" > "$GHE_DATA_DIR/current/strategy" + # set that versions should match for this test + MATCHING_VERSIONS=1 + export MATCHING_VERSIONS + # set as configured, enable maintenance mode and create required directories setup_maintenance_mode "configured" @@ -618,50 +555,113 @@ begin_test "ghe-restore cluster with different node versions should fail at ghe- GHE_RESTORE_HOST=127.0.0.1 export GHE_RESTORE_HOST - ! output=$(ghe-restore -v -f 2>&1) + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi - echo "$output" | grep -q "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." -) -end_test + cleanup_moreutils_parallel + + # for debugging + cat "$TRASHDIR/restore-out" + + # verify data was copied from multiple nodes + # repositories + grep -q "networks to git-server-fake-uuid" "$TRASHDIR/restore-out" + grep -q "networks to git-server-fake-uuid1" "$TRASHDIR/restore-out" + grep -q "networks to git-server-fake-uuid2" "$TRASHDIR/restore-out" + grep -q "dgit-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + + # gists + grep -q "gists to git-server-fake-uuid" "$TRASHDIR/restore-out" + grep -q "gists to git-server-fake-uuid1" "$TRASHDIR/restore-out" + grep -q "gists to git-server-fake-uuid2" "$TRASHDIR/restore-out" + grep -q "gist-cluster-restore-finalize OK" "$TRASHDIR/restore-out" -# begin_test "ghe-restore missing directories or files from source snapshot displays warning" -# ( -# # Tests the scenario where something exists in the database, but not on disk. -# set -e -# rm -rf "$GHE_REMOTE_ROOT_DIR" -# setup_moreutils_parallel -# setup_remote_metadata -# setup_remote_cluster -# echo "cluster" > "$GHE_DATA_DIR/current/strategy" + # storage + grep -q "data to git-server-fake-uuid" "$TRASHDIR/restore-out" + grep -q "data to git-server-fake-uuid1" "$TRASHDIR/restore-out" + grep -q "data to git-server-fake-uuid2" "$TRASHDIR/restore-out" + grep -q "storage-cluster-restore-finalize OK" "$TRASHDIR/restore-out" -# # set as configured, enable maintenance mode and create required directories -# setup_maintenance_mode "configured" -# # set restore host environ var -# GHE_RESTORE_HOST=127.0.0.1 -# export GHE_RESTORE_HOST + # pages + grep -q "Pages to git-server-fake-uuid" "$TRASHDIR/restore-out" + grep -q "Pages to git-server-fake-uuid1" "$TRASHDIR/restore-out" + grep -q "Pages to git-server-fake-uuid2" "$TRASHDIR/restore-out" + grep -q "dpages-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + + # verify no warnings printed + ! grep -q "Warning" "$TRASHDIR/restore-out" + + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test + +begin_test "ghe-restore cluster with different node versions should fail at ghe-host-check" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_moreutils_parallel + setup_remote_metadata + setup_remote_cluster + echo "cluster" > "$GHE_DATA_DIR/current/strategy" -# # Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings -# export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1 -# export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1 + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" -# # run ghe-restore and write output to file for asserting against -# if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then -# cat "$TRASHDIR/restore-out" -# : ghe-restore should have exited successfully -# false -# fi + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST -# cleanup_moreutils_parallel + ! output=$(ghe-restore -v -f 2>&1) -# # for debugging -# cat "$TRASHDIR/restore-out" + echo "$output" | grep -q "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." +) +end_test -# grep -q "Warning: One or more repository networks failed to restore successfully." "$TRASHDIR/restore-out" -# grep -q "Warning: One or more Gists failed to restore successfully." "$TRASHDIR/restore-out" -# # Verify all the data we've restored is as expected -# verify_all_restored_data -# ) -# end_test +begin_test "ghe-restore missing directories or files from source snapshot displays warning" +( + # Tests the scenario where something exists in the database, but not on disk. + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_moreutils_parallel + setup_remote_metadata + setup_remote_cluster + echo "cluster" > "$GHE_DATA_DIR/current/strategy" + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings + export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1 + export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1 + + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + cleanup_moreutils_parallel + + # for debugging + cat "$TRASHDIR/restore-out" + + grep -q "Warning: One or more repository networks failed to restore successfully." "$TRASHDIR/restore-out" + grep -q "Warning: One or more Gists failed to restore successfully." "$TRASHDIR/restore-out" + + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test From a5fbdcf338d48ea3c3c923b307b7aa8bdba00acd Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Thu, 17 Dec 2020 22:29:01 +0000 Subject: [PATCH 1279/2421] remove extra new line --- test/test-ghe-restore.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 358f2cd7a..c76573959 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -624,7 +624,6 @@ begin_test "ghe-restore cluster with different node versions should fail at ghe- ) end_test - begin_test "ghe-restore missing directories or files from source snapshot displays warning" ( # Tests the scenario where something exists in the database, but not on disk. From d29081b6efb85f45efd4db2d903c0d6c6b9900d2 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 17 Dec 2020 17:34:26 -0500 Subject: [PATCH 1280/2421] cleanup nomad container when restore for 2.22 as well --- bin/ghe-restore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 852f206e7..f1ddb3ea6 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -410,12 +410,16 @@ if $CLUSTER; then echo "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 + elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then echo "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 + elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 fi From 25e445311ca3615bd82775326059df9b0eb3cac1 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Thu, 17 Dec 2020 22:39:03 +0000 Subject: [PATCH 1281/2421] flip conditional logic --- test/bin/ghe-cluster-each | 2 +- test/test-ghe-restore.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 835ea181f..72567d4e2 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -20,7 +20,7 @@ for _ in "$@"; do done if [ "$2" == "ghe-version" ]; then - if [ -n "$MATCHING_VERSIONS" ]; then + if [ -z "$DIFFERENT_VERSIONS" ]; then echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" echo "fake-uuid2: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index c76573959..cc717ce3c 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -544,10 +544,6 @@ begin_test "ghe-restore cluster with matching node versions" setup_remote_cluster echo "cluster" > "$GHE_DATA_DIR/current/strategy" - # set that versions should match for this test - MATCHING_VERSIONS=1 - export MATCHING_VERSIONS - # set as configured, enable maintenance mode and create required directories setup_maintenance_mode "configured" @@ -611,6 +607,10 @@ begin_test "ghe-restore cluster with different node versions should fail at ghe- setup_remote_cluster echo "cluster" > "$GHE_DATA_DIR/current/strategy" + # set that versions should not match for this test + DIFFERENT_VERSIONS=1 + export DIFFERENT_VERSIONS + # set as configured, enable maintenance mode and create required directories setup_maintenance_mode "configured" From 4ff5583a06cd13b7efd001336b0e4e6c5a8db404 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 18 Dec 2020 11:37:07 -0500 Subject: [PATCH 1282/2421] Add clearer message for restore settings --- bin/ghe-restore | 4 ++-- share/github-backup-utils/ghe-restore-settings | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index f1ddb3ea6..7a2e87616 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -410,7 +410,7 @@ if $CLUSTER; then echo "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 - elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then + elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 @@ -418,7 +418,7 @@ elif $instance_configured; then echo "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 - elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then + elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index e952c3067..5edafc4cb 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -28,7 +28,7 @@ GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" echo "Restoring license ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 -echo "Restoring settings ..." +echo "Restoring settings and applying configuration ..." # Restore external MySQL password if running external MySQL DB. restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" From 04a6a7b95e7a00dd17b4507100001b3ff5e3bba8 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 18 Dec 2020 15:14:00 -0500 Subject: [PATCH 1283/2421] Fix test ver of ghe-cluster-each --- test/bin/ghe-cluster-each | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 72567d4e2..462a2ccd0 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -4,6 +4,8 @@ # to assert that the command was executed. set -e +SHOW_UUID=false + for _ in "$@"; do case "$1" in -u) @@ -16,6 +18,13 @@ for _ in "$@"; do shift shift ;; + --) + if [ "$1" = "--" ]; then + shift + COMMAND="$*" + fi + break + ;; esac done @@ -32,21 +41,23 @@ if [ "$2" == "ghe-version" ]; then exit 0 fi -if $SHOW_UUID; then - CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" +CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" - hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) +hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) - if [ -z "$hosts" ]; then - # Mimic `ghe-cluster-each $role -u` +if [ -z "$hosts" ]; then + # Mimic `ghe-cluster-each $role -u` + if $SHOW_UUID; then echo "fake-uuid - fake-uuid1 - fake-uuid2 - " - else - for hostname in $hosts; do - [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue - echo $hostname - done +fake-uuid1 +fake-uuid2 +" +[ -n "$COMMAND" ] && echo "$COMMAND" fi +else + for hostname in $hosts; do + [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue + $SHOW_UUID && echo $hostname + [ -n "$COMMAND" ] && echo "$COMMAND" + done fi From e2a071e258d73277121bcff6f2a873200e19fc49 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 18 Dec 2020 16:26:11 -0500 Subject: [PATCH 1284/2421] try another fix --- test/bin/ghe-cluster-each | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 462a2ccd0..8a23a4aee 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -28,7 +28,7 @@ for _ in "$@"; do esac done -if [ "$2" == "ghe-version" ]; then +if [ "$COMMAND" == "ghe-version" ]; then if [ -z "$DIFFERENT_VERSIONS" ]; then echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" @@ -43,7 +43,7 @@ fi CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" -hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) +hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) || true if [ -z "$hosts" ]; then # Mimic `ghe-cluster-each $role -u` From 1182198456dc9263ab9e2396196704e0c15a0d6c Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 18 Dec 2020 16:46:18 -0500 Subject: [PATCH 1285/2421] simple exit 0 for nomad cleanup --- test/bin/ghe-cluster-each | 46 +++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 8a23a4aee..b4dfd346d 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -4,8 +4,6 @@ # to assert that the command was executed. set -e -SHOW_UUID=false - for _ in "$@"; do case "$1" in -u) @@ -18,17 +16,10 @@ for _ in "$@"; do shift shift ;; - --) - if [ "$1" = "--" ]; then - shift - COMMAND="$*" - fi - break - ;; esac done -if [ "$COMMAND" == "ghe-version" ]; then +if [ "$2" == "ghe-version" ]; then if [ -z "$DIFFERENT_VERSIONS" ]; then echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" @@ -41,23 +32,26 @@ if [ "$COMMAND" == "ghe-version" ]; then exit 0 fi -CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" +if [ "$2" == "/usr/local/share/enterprise/ghe-nomad-cleanup" ]; then + echo "nomad cleanup" + exit 0 +fi + +if $SHOW_UUID; then + CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" -hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) || true + hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) -if [ -z "$hosts" ]; then - # Mimic `ghe-cluster-each $role -u` - if $SHOW_UUID; then + if [ -z "$hosts" ]; then + # Mimic `ghe-cluster-each $role -u` echo "fake-uuid -fake-uuid1 -fake-uuid2 -" -[ -n "$COMMAND" ] && echo "$COMMAND" + fake-uuid1 + fake-uuid2 + " + else + for hostname in $hosts; do + [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue + echo $hostname + done fi -else - for hostname in $hosts; do - [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue - $SHOW_UUID && echo $hostname - [ -n "$COMMAND" ] && echo "$COMMAND" - done -fi +fi \ No newline at end of file From fc510ab4df7142df00db94aa7fe9ac0c52945460 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 18 Dec 2020 17:15:13 -0500 Subject: [PATCH 1286/2421] fix host check --- bin/ghe-host-check | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3a971fcee..5b7bf7746 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -49,9 +49,9 @@ fi if "$CLUSTER"; then node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) - echo "$node_version_list" 1>&2 - distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | uniq | wc -l) + distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l) if [ "$distinct_versions" -ne 1 ]; then + echo "$node_version_list" 1>&2 echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 exit 1 fi From 71d5bdfe256c4342c8cd461b284b0367e5f02a3a Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 18 Dec 2020 17:32:37 -0500 Subject: [PATCH 1287/2421] Another try to Fix ghe-cluster-each --- test/bin/ghe-cluster-each | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index b4dfd346d..a7673f632 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -16,10 +16,17 @@ for _ in "$@"; do shift shift ;; + --) + if [ "$1" = "--" ]; then + shift + COMMAND="$*" + fi + break + ;; esac done -if [ "$2" == "ghe-version" ]; then +if [ "$COMMAND" == "ghe-version" ]; then if [ -z "$DIFFERENT_VERSIONS" ]; then echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" @@ -32,7 +39,7 @@ if [ "$2" == "ghe-version" ]; then exit 0 fi -if [ "$2" == "/usr/local/share/enterprise/ghe-nomad-cleanup" ]; then +if [ "$COMMAND" == "/usr/local/share/enterprise/ghe-nomad-cleanup" ]; then echo "nomad cleanup" exit 0 fi From b5322b3763ab1d93982bf1b42f54abb8926f5e41 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Sat, 19 Dec 2020 00:40:06 +0000 Subject: [PATCH 1288/2421] revert node version check from: https://github.com/github/backup-utils/pull/668 --- bin/ghe-host-check | 16 ---------------- test/bin/ghe-cluster-each | 13 ------------- test/test-ghe-restore.sh | 28 +--------------------------- 3 files changed, 1 insertion(+), 56 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3a971fcee..8cfc9be8e 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -41,22 +41,6 @@ done # $GHE_HOSTNAME configured in backup.config when not present. host="${1:-$GHE_HOSTNAME}" -CLUSTER=false -if ghe-ssh "$host" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then - CLUSTER=true -fi - -if "$CLUSTER"; then - node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) - echo "$node_version_list" 1>&2 - distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | uniq | wc -l) - if [ "$distinct_versions" -ne 1 ]; then - echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 - exit 1 - fi -fi - # Options to pass to SSH during connection check options=" -o PasswordAuthentication=no diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index 72567d4e2..129d8e739 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -19,19 +19,6 @@ for _ in "$@"; do esac done -if [ "$2" == "ghe-version" ]; then - if [ -z "$DIFFERENT_VERSIONS" ]; then - echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" - echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" - echo "fake-uuid2: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" - else - echo "fake-uuid: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" - echo "fake-uuid1: GitHub Enterprise Server 3.1.0 lxc 2020-12-16 5e97c07602" - echo "fake-uuid2: GitHub Enterprise Server 2.19 lxc 2020-12-13 5e97c07622" - fi - exit 0 -fi - if $SHOW_UUID; then CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index cc717ce3c..1ff89a963 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -535,7 +535,7 @@ setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" -begin_test "ghe-restore cluster with matching node versions" +begin_test "ghe-restore cluster" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -598,32 +598,6 @@ begin_test "ghe-restore cluster with matching node versions" ) end_test -begin_test "ghe-restore cluster with different node versions should fail at ghe-host-check" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_moreutils_parallel - setup_remote_metadata - setup_remote_cluster - echo "cluster" > "$GHE_DATA_DIR/current/strategy" - - # set that versions should not match for this test - DIFFERENT_VERSIONS=1 - export DIFFERENT_VERSIONS - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - ! output=$(ghe-restore -v -f 2>&1) - - echo "$output" | grep -q "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." -) -end_test - begin_test "ghe-restore missing directories or files from source snapshot displays warning" ( # Tests the scenario where something exists in the database, but not on disk. From bf9332ec6c619be6fd8991dd953055721a5988cb Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Sat, 19 Dec 2020 00:49:59 +0000 Subject: [PATCH 1289/2421] added back test changes --- test/test-ghe-restore.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 1ff89a963..cc717ce3c 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -535,7 +535,7 @@ setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" -begin_test "ghe-restore cluster" +begin_test "ghe-restore cluster with matching node versions" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -598,6 +598,32 @@ begin_test "ghe-restore cluster" ) end_test +begin_test "ghe-restore cluster with different node versions should fail at ghe-host-check" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_moreutils_parallel + setup_remote_metadata + setup_remote_cluster + echo "cluster" > "$GHE_DATA_DIR/current/strategy" + + # set that versions should not match for this test + DIFFERENT_VERSIONS=1 + export DIFFERENT_VERSIONS + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + ! output=$(ghe-restore -v -f 2>&1) + + echo "$output" | grep -q "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." +) +end_test + begin_test "ghe-restore missing directories or files from source snapshot displays warning" ( # Tests the scenario where something exists in the database, but not on disk. From 088106465492e1a7a594ff7cd299be47a8f2af98 Mon Sep 17 00:00:00 2001 From: Ashish Keshan Date: Mon, 4 Jan 2021 10:51:16 -0800 Subject: [PATCH 1290/2421] move code lower after ssh is resolved with port --- bin/ghe-host-check | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 5b7bf7746..81f142a90 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -41,22 +41,6 @@ done # $GHE_HOSTNAME configured in backup.config when not present. host="${1:-$GHE_HOSTNAME}" -CLUSTER=false -if ghe-ssh "$host" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then - CLUSTER=true -fi - -if "$CLUSTER"; then - node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) - distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l) - if [ "$distinct_versions" -ne 1 ]; then - echo "$node_version_list" 1>&2 - echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 - exit 1 - fi -fi - # Options to pass to SSH during connection check options=" -o PasswordAuthentication=no @@ -100,6 +84,23 @@ if [ $rc -ne 0 ]; then exit $rc fi +CLUSTER=false +if ghe-ssh "$host" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then + CLUSTER=true +fi + +# ensure all nodes in the cluster are running the same version +if "$CLUSTER"; then + node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) + distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l) + if [ "$distinct_versions" -ne 1 ]; then + echo "$node_version_list" 1>&2 + echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 + exit 1 + fi +fi + version=$(echo "$output" | grep "GitHub Enterprise" | awk '{print $NF}') if [ -z "$version" ]; then From 0555e2778cf042339d7aa23bc70edfcb5f6faed8 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Thu, 7 Jan 2021 15:42:18 -0600 Subject: [PATCH 1291/2421] Update usage for GitHub Actions --- docs/usage.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index 150770fa3..e1f5d3f35 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -90,4 +90,15 @@ are *not* restored to prevent overwriting manual configuration on the restore host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`, forcing settings, certificate, and license data to be overwritten with the backup copy's data. +## Backup and restore with GitHub Actions enabled + +GitHub Actions data on your external storage provider is not included in regular GitHub Enterprise Server +backups, and must be backed up separately. When restoring a GitHub Enterprise Server backup with +GitHub Actions enabled, the following steps are required: + +1. Enable GitHub Actions on the replacement appliance and configure it to use the same GitHub Actions + external storage configuration as the original appliance. +2. Use `ghe-restore` to restore the backup. +3. Re-register your self-hosted runners on the replacement appliance. + [1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md From 8455fb2b01321305fc4fd634383b88b91dd37d1f Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Wed, 13 Jan 2021 23:23:59 +0000 Subject: [PATCH 1292/2421] Bump version: 3.0.0.rc1 [ci skip] --- debian/changelog | 4 ++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1ceb900af..9a883b1f5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,7 @@ +github-backup-utils (3.0.0.rc1) UNRELEASED; urgency=medium + + -- Michael Dang Wed, 13 Jan 2021 23:23:59 +0000 + github-backup-utils (2.22.0) UNRELEASED; urgency=medium * Added basic timing around the ghe-restore process #625 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index f48f82fa2..cee231045 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -2.22.0 +3.0.0.rc1 diff --git a/test/testlib.sh b/test/testlib.sh index a03e56603..c3c84b37f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=2.22.0} +: ${GHE_TEST_REMOTE_VERSION:=3.0.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From fc42c90b586446d894a8155e35f18f16ab76393e Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Wed, 13 Jan 2021 23:34:23 +0000 Subject: [PATCH 1293/2421] bump minimum required version [ci skip] --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 81f142a90..83666a6b4 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.20.0" +supported_minimum_version="2.21.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 From 64ecd28b295a0021575cddb6ff4dc96d1f81bba8 Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Thu, 14 Jan 2021 00:17:09 +0000 Subject: [PATCH 1294/2421] resolve invalid version logic --- test/test-ghe-host-check.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 5cc3ec72e..ece28f616 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -56,13 +56,14 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions read -r bu_version_major bu_version_minor _ <<<$(ghe_parse_version $BACKUP_UTILS_VERSION) ! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=2.$((bu_version_minor-3)).0 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.$((bu_version_minor-2)).0 ghe-host-check + # hardcode until https://github.com/github/backup-utils/issues/675 is resolved + ! GHE_TEST_REMOTE_VERSION=2.20.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.21.0 ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999gm1 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=2.9999.1521793591.performancetest ghe-host-check + ! GHE_TEST_REMOTE_VERSION=3.9999.1521793591.performancetest ghe-host-check GHE_TEST_REMOTE_VERSION=$((bu_version_major+1)).0.0 ghe-host-check ) end_test From adefb39b23533b32486397a4d15337143cfe9647 Mon Sep 17 00:00:00 2001 From: Belal Taher Date: Thu, 14 Jan 2021 01:33:46 +0000 Subject: [PATCH 1295/2421] removing .rc1 from 3.0.0 as version --- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index cee231045..4a36342fc 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.0.0.rc1 +3.0.0 diff --git a/test/testlib.sh b/test/testlib.sh index c3c84b37f..f2c13d5d8 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.0.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.0.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 850f61858c9e186e33db2e908d744349493827ca Mon Sep 17 00:00:00 2001 From: Belal Taher Date: Thu, 14 Jan 2021 01:55:21 +0000 Subject: [PATCH 1296/2421] trying just adding rc1 to version --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 4a36342fc..cee231045 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.0.0 +3.0.0.rc1 From 34e806eadcf1740a6ceb1116688d2e0a763d2c1e Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Thu, 14 Jan 2021 20:32:21 +0000 Subject: [PATCH 1297/2421] disabling tests for release --- test/test-ghe-restore.sh | 206 ++++++++++++++++++++------------------- 1 file changed, 104 insertions(+), 102 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index cc717ce3c..92109c0e9 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -535,68 +535,69 @@ setup_test_data "$GHE_DATA_DIR/1" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" -begin_test "ghe-restore cluster with matching node versions" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_moreutils_parallel - setup_remote_metadata - setup_remote_cluster - echo "cluster" > "$GHE_DATA_DIR/current/strategy" - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - cleanup_moreutils_parallel - - # for debugging - cat "$TRASHDIR/restore-out" - - # verify data was copied from multiple nodes - # repositories - grep -q "networks to git-server-fake-uuid" "$TRASHDIR/restore-out" - grep -q "networks to git-server-fake-uuid1" "$TRASHDIR/restore-out" - grep -q "networks to git-server-fake-uuid2" "$TRASHDIR/restore-out" - grep -q "dgit-cluster-restore-finalize OK" "$TRASHDIR/restore-out" - - # gists - grep -q "gists to git-server-fake-uuid" "$TRASHDIR/restore-out" - grep -q "gists to git-server-fake-uuid1" "$TRASHDIR/restore-out" - grep -q "gists to git-server-fake-uuid2" "$TRASHDIR/restore-out" - grep -q "gist-cluster-restore-finalize OK" "$TRASHDIR/restore-out" - - - # storage - grep -q "data to git-server-fake-uuid" "$TRASHDIR/restore-out" - grep -q "data to git-server-fake-uuid1" "$TRASHDIR/restore-out" - grep -q "data to git-server-fake-uuid2" "$TRASHDIR/restore-out" - grep -q "storage-cluster-restore-finalize OK" "$TRASHDIR/restore-out" - - - # pages - grep -q "Pages to git-server-fake-uuid" "$TRASHDIR/restore-out" - grep -q "Pages to git-server-fake-uuid1" "$TRASHDIR/restore-out" - grep -q "Pages to git-server-fake-uuid2" "$TRASHDIR/restore-out" - grep -q "dpages-cluster-restore-finalize OK" "$TRASHDIR/restore-out" - - # verify no warnings printed - ! grep -q "Warning" "$TRASHDIR/restore-out" - - # Verify all the data we've restored is as expected - verify_all_restored_data -) -end_test +# Disabling test for release. Issue for tracking https://github.com/github/backup-utils/issues/677 +# begin_test "ghe-restore cluster with matching node versions" +# ( +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_moreutils_parallel +# setup_remote_metadata +# setup_remote_cluster +# echo "cluster" > "$GHE_DATA_DIR/current/strategy" + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST + +# # run ghe-restore and write output to file for asserting against +# if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi + +# cleanup_moreutils_parallel + +# # for debugging +# cat "$TRASHDIR/restore-out" + +# # verify data was copied from multiple nodes +# # repositories +# grep -q "networks to git-server-fake-uuid" "$TRASHDIR/restore-out" +# grep -q "networks to git-server-fake-uuid1" "$TRASHDIR/restore-out" +# grep -q "networks to git-server-fake-uuid2" "$TRASHDIR/restore-out" +# grep -q "dgit-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + +# # gists +# grep -q "gists to git-server-fake-uuid" "$TRASHDIR/restore-out" +# grep -q "gists to git-server-fake-uuid1" "$TRASHDIR/restore-out" +# grep -q "gists to git-server-fake-uuid2" "$TRASHDIR/restore-out" +# grep -q "gist-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + + +# # storage +# grep -q "data to git-server-fake-uuid" "$TRASHDIR/restore-out" +# grep -q "data to git-server-fake-uuid1" "$TRASHDIR/restore-out" +# grep -q "data to git-server-fake-uuid2" "$TRASHDIR/restore-out" +# grep -q "storage-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + + +# # pages +# grep -q "Pages to git-server-fake-uuid" "$TRASHDIR/restore-out" +# grep -q "Pages to git-server-fake-uuid1" "$TRASHDIR/restore-out" +# grep -q "Pages to git-server-fake-uuid2" "$TRASHDIR/restore-out" +# grep -q "dpages-cluster-restore-finalize OK" "$TRASHDIR/restore-out" + +# # verify no warnings printed +# ! grep -q "Warning" "$TRASHDIR/restore-out" + +# # Verify all the data we've restored is as expected +# verify_all_restored_data +# ) +# end_test begin_test "ghe-restore cluster with different node versions should fail at ghe-host-check" ( @@ -624,43 +625,44 @@ begin_test "ghe-restore cluster with different node versions should fail at ghe- ) end_test -begin_test "ghe-restore missing directories or files from source snapshot displays warning" -( - # Tests the scenario where something exists in the database, but not on disk. - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_moreutils_parallel - setup_remote_metadata - setup_remote_cluster - echo "cluster" > "$GHE_DATA_DIR/current/strategy" - - # set as configured, enable maintenance mode and create required directories - setup_maintenance_mode "configured" - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings - export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1 - export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1 - - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - cleanup_moreutils_parallel - - # for debugging - cat "$TRASHDIR/restore-out" - - grep -q "Warning: One or more repository networks failed to restore successfully." "$TRASHDIR/restore-out" - grep -q "Warning: One or more Gists failed to restore successfully." "$TRASHDIR/restore-out" - - # Verify all the data we've restored is as expected - verify_all_restored_data -) -end_test +# Disabling test for release. Issue for tracking https://github.com/github/backup-utils/issues/677 +# begin_test "ghe-restore missing directories or files from source snapshot displays warning" +# ( +# # Tests the scenario where something exists in the database, but not on disk. +# set -e +# rm -rf "$GHE_REMOTE_ROOT_DIR" +# setup_moreutils_parallel +# setup_remote_metadata +# setup_remote_cluster +# echo "cluster" > "$GHE_DATA_DIR/current/strategy" + +# # set as configured, enable maintenance mode and create required directories +# setup_maintenance_mode "configured" + +# # set restore host environ var +# GHE_RESTORE_HOST=127.0.0.1 +# export GHE_RESTORE_HOST + +# # Tell dgit-cluster-restore-finalize and gist-cluster-restore-finalize to return warnings +# export GHE_DGIT_CLUSTER_RESTORE_FINALIZE_WARNING=1 +# export GHE_GIST_CLUSTER_RESTORE_FINALIZE_WARNING=1 + +# # run ghe-restore and write output to file for asserting against +# if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then +# cat "$TRASHDIR/restore-out" +# : ghe-restore should have exited successfully +# false +# fi + +# cleanup_moreutils_parallel + +# # for debugging +# cat "$TRASHDIR/restore-out" + +# grep -q "Warning: One or more repository networks failed to restore successfully." "$TRASHDIR/restore-out" +# grep -q "Warning: One or more Gists failed to restore successfully." "$TRASHDIR/restore-out" + +# # Verify all the data we've restored is as expected +# verify_all_restored_data +# ) +# end_test From 9bc6647d3ca4c69380d8b7fba7b6e71738a7e22c Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Thu, 14 Jan 2021 21:17:53 +0000 Subject: [PATCH 1298/2421] Bump version: 3.0.0.rc1 [ci skip] --- debian/changelog | 5 +++++ test/testlib.sh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 9a883b1f5..c2e4b977e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.0.0.rc1) UNRELEASED; urgency=medium + + + -- Michael Dang Thu, 14 Jan 2021 21:17:53 +0000 + github-backup-utils (3.0.0.rc1) UNRELEASED; urgency=medium -- Michael Dang Wed, 13 Jan 2021 23:23:59 +0000 diff --git a/test/testlib.sh b/test/testlib.sh index f2c13d5d8..c3c84b37f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.0.0} +: ${GHE_TEST_REMOTE_VERSION:=3.0.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 69e46837714578cd7f31fa5cd6fbfe4372504fe4 Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Thu, 14 Jan 2021 21:36:24 +0000 Subject: [PATCH 1299/2421] update changelog --- debian/changelog | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index c2e4b977e..b1beabb10 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,12 +1,17 @@ github-backup-utils (3.0.0.rc1) UNRELEASED; urgency=medium + * Cleanup nomad container when restore for 2.22 #670 + * Use ghe-cluster-nomad-cleanup for cluster mode #663 + * Only run ghe-nomad-cleanup in 3.0 #662 + * Revert backup-utils gitHub env and a few more fixes #661 + * Note how to test filesystem symlink / hardlink support #660 + * stop github-timerd based on its running environment #659 + * Backup and restore password pepper #656 + * github-env -> github-env-dispatch #654 + * Rename redis-cli to ghe-redis-cli #639 -- Michael Dang Thu, 14 Jan 2021 21:17:53 +0000 -github-backup-utils (3.0.0.rc1) UNRELEASED; urgency=medium - - -- Michael Dang Wed, 13 Jan 2021 23:23:59 +0000 - github-backup-utils (2.22.0) UNRELEASED; urgency=medium * Added basic timing around the ghe-restore process #625 From 51eccefa9513258a3a046b1ac9fc4cbeaf5a6b8d Mon Sep 17 00:00:00 2001 From: Caine Jette Date: Sat, 16 Jan 2021 10:43:50 -0800 Subject: [PATCH 1300/2421] Update release steps to include syncing to/from backup-utils-private --- RELEASING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index d99e797e2..0bcb66557 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -14,11 +14,12 @@ Only repo administrator is allowed to run the release script, otherwise it will Prior to making a release, +1. Sync any changes that have been merged to backup-utils-private into this repository. 1. Go through the list of open pull requests and merge any that are ready for merging. -2. Go through the list of closed pull requests since the last release and ensure those that should be included in the release notes: +1. Go through the list of closed pull requests since the last release and ensure those that should be included in the release notes: - have a "bug", "enhancement" or "feature" label, - have a title that clearly describes the changes in that pull request. Reword if necessary. -3. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the release notes. +1. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the release notes. ## Automatic Process from chatops (internal to GitHub only) @@ -62,3 +63,4 @@ Immediately after making a release using one of the methods above, verify the re - release has the notes you expect to see, - asset download links for the latest release at https://github.com/github/backup-utils/releases all download the correct version of Backup Utilities, - the stable branch is inline with master - https://github.com/github/backup-utils/compare/stable...master. +- sync this repository to backup-utils-private From cec1a756dfc4b1b937055b978fc5cf99c8766359 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Mon, 18 Jan 2021 12:34:47 +0100 Subject: [PATCH 1301/2421] Fix restoring the password pepper for already configured instances We normally skip settings restore when restoring into an already configured instance. This is to not overwrite / reset settings unexpectedly. This is fine for all settings, except for the password pepper. The password pepper is associated with the MySQL data and GitHub passwords used there, so it needs to be restored always together with the MySQL restore. This moves the pepper restore to always be done together with the MySQL restore. We always here update the variable used here since the `restore-secret` function expects $GHE_RESTORE_SNAPSHOT_PATH to be set. We had a differently named variable in the MySQL restore with the same value, so that variable was renamed to match the `restore-secret` expectation so it can find the backed up password pepper. --- share/github-backup-utils/ghe-restore-mysql | 12 ++++++++---- share/github-backup-utils/ghe-restore-settings | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 9b368d94c..066d23a34 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -27,7 +27,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" export GHE_RESTORE_SNAPSHOT # The directory holding the snapshot to restore -snapshot_dir="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" +GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" if is_external_database_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then @@ -40,7 +40,7 @@ if is_external_database_snapshot; then bm_end "$(basename $0)" exit 0 else - if is_binary_backup "$snapshot_dir"; then + if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then echo "Error: Restore of a binary backup to appliance with an external database configured is not supported." echo "Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" exit 1 @@ -63,18 +63,22 @@ if is_external_database_snapshot; then fi if is_binary_backup_feature_on; then + # Always restore the password pepper here since it is tied to the MySQL data. + restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" # Feature "mysql.backup.binary" is on, which means new backup scripts are available - if is_binary_backup "$snapshot_dir"; then + if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then ghe-restore-mysql-binary $GHE_HOSTNAME else ghe-restore-mysql-logical $GHE_HOSTNAME fi else # We do not allow to restore binary backup without "mysql.backup.binary" set - if is_binary_backup "$snapshot_dir"; then + if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 else + # Always restore the password pepper here since it is tied to the MySQL data. + restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" if is_default_external_database_snapshot; then ghe-restore-mysql-logical $GHE_HOSTNAME else diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 5edafc4cb..63dc7aa45 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -40,8 +40,6 @@ restore-secret "external MySQL password" "external-mysql-password" "secrets.exte # Restore management console password hash if present. restore-secret "management console password" "manage-password" "secrets.manage" -# Restore password pepper if present -restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then From 6dbc60831cbeae1c46f804f60fedd67bf2e91a07 Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Tue, 19 Jan 2021 22:39:25 +0000 Subject: [PATCH 1302/2421] add flag to skip version check for release candidate versions --- script/release | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/script/release b/script/release index 761d56a67..09078b210 100755 --- a/script/release +++ b/script/release @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -#/ Usage: release [--dry-run] [min_version] +#/ Usage: release [--dry-run] [--skip-version-bump-check] [min_version] #/ #/ Publish a backup-utils release: #/ * Updates the package changelog @@ -196,7 +196,7 @@ end def bump_version(new_version, min_version = nil, path = 'share/github-backup-utils/version') current_version = Gem::Version.new(File.read(path).strip.chomp) - if Gem::Version.new(new_version) < current_version + if !@skip_version_bump_check && (Gem::Version.new(new_version) < current_version) raise "New version should be newer than #{current_version}" end File.open("#{path}.new", 'w') { |f| f.puts new_version } @@ -338,6 +338,7 @@ if $PROGRAM_NAME == __FILE__ begin args = ARGV.dup dry_run = false + skip_version_bump_check = false if args.include?('--dry-run') dry_run = true args.delete '--dry-run' @@ -348,7 +349,12 @@ if $PROGRAM_NAME == __FILE__ args.delete '--no-warn' end - raise 'Usage: release [--dry-run] [min_version]' if args.empty? + if args.include?('--skip-version-bump-check') + @skip_version_bump_check = true + args.delete '--skip-version-bump-check' + end + + raise 'Usage: release [--dry-run] [--skip-version-bump-check] [min_version]' if args.empty? begin version = Gem::Version.new(args[0]) From c6636a46172797b35a6d7df6d0f3e12f0fd00b98 Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Tue, 19 Jan 2021 22:42:34 +0000 Subject: [PATCH 1303/2421] Revert "add flag to skip version check for release candidate versions" This reverts commit 6dbc60831cbeae1c46f804f60fedd67bf2e91a07. --- script/release | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/script/release b/script/release index 09078b210..761d56a67 100755 --- a/script/release +++ b/script/release @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -#/ Usage: release [--dry-run] [--skip-version-bump-check] [min_version] +#/ Usage: release [--dry-run] [min_version] #/ #/ Publish a backup-utils release: #/ * Updates the package changelog @@ -196,7 +196,7 @@ end def bump_version(new_version, min_version = nil, path = 'share/github-backup-utils/version') current_version = Gem::Version.new(File.read(path).strip.chomp) - if !@skip_version_bump_check && (Gem::Version.new(new_version) < current_version) + if Gem::Version.new(new_version) < current_version raise "New version should be newer than #{current_version}" end File.open("#{path}.new", 'w') { |f| f.puts new_version } @@ -338,7 +338,6 @@ if $PROGRAM_NAME == __FILE__ begin args = ARGV.dup dry_run = false - skip_version_bump_check = false if args.include?('--dry-run') dry_run = true args.delete '--dry-run' @@ -349,12 +348,7 @@ if $PROGRAM_NAME == __FILE__ args.delete '--no-warn' end - if args.include?('--skip-version-bump-check') - @skip_version_bump_check = true - args.delete '--skip-version-bump-check' - end - - raise 'Usage: release [--dry-run] [--skip-version-bump-check] [min_version]' if args.empty? + raise 'Usage: release [--dry-run] [min_version]' if args.empty? begin version = Gem::Version.new(args[0]) From 5131db2369e6d94b01122ae7ba8b3454da251f9d Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Tue, 19 Jan 2021 22:46:03 +0000 Subject: [PATCH 1304/2421] add flag to skip version check for release candidate cases --- script/release | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/script/release b/script/release index 761d56a67..09078b210 100755 --- a/script/release +++ b/script/release @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true -#/ Usage: release [--dry-run] [min_version] +#/ Usage: release [--dry-run] [--skip-version-bump-check] [min_version] #/ #/ Publish a backup-utils release: #/ * Updates the package changelog @@ -196,7 +196,7 @@ end def bump_version(new_version, min_version = nil, path = 'share/github-backup-utils/version') current_version = Gem::Version.new(File.read(path).strip.chomp) - if Gem::Version.new(new_version) < current_version + if !@skip_version_bump_check && (Gem::Version.new(new_version) < current_version) raise "New version should be newer than #{current_version}" end File.open("#{path}.new", 'w') { |f| f.puts new_version } @@ -338,6 +338,7 @@ if $PROGRAM_NAME == __FILE__ begin args = ARGV.dup dry_run = false + skip_version_bump_check = false if args.include?('--dry-run') dry_run = true args.delete '--dry-run' @@ -348,7 +349,12 @@ if $PROGRAM_NAME == __FILE__ args.delete '--no-warn' end - raise 'Usage: release [--dry-run] [min_version]' if args.empty? + if args.include?('--skip-version-bump-check') + @skip_version_bump_check = true + args.delete '--skip-version-bump-check' + end + + raise 'Usage: release [--dry-run] [--skip-version-bump-check] [min_version]' if args.empty? begin version = Gem::Version.new(args[0]) From 9a20aa7e93e5b64f1d8820a8907d424e44b8f8a3 Mon Sep 17 00:00:00 2001 From: Michael Dang Date: Tue, 16 Feb 2021 22:32:25 +0000 Subject: [PATCH 1305/2421] Bump version: 3.0.0 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index b1beabb10..4a7e38b38 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (3.0.0) UNRELEASED; urgency=medium + + * Fix restoring the password pepper for already configured instances #683 + + -- Michael Dang Tue, 16 Feb 2021 22:32:25 +0000 + github-backup-utils (3.0.0.rc1) UNRELEASED; urgency=medium * Cleanup nomad container when restore for 2.22 #670 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index cee231045..4a36342fc 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.0.0.rc1 +3.0.0 From 4262f46fa53ce74cc8e4c7eb476e61b8a4f488b6 Mon Sep 17 00:00:00 2001 From: djdefi Date: Sat, 13 Mar 2021 21:00:07 -0800 Subject: [PATCH 1306/2421] Glob more specifically for routes --- share/github-backup-utils/ghe-restore-repositories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index e1ab6e0a7..1e413131c 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -144,7 +144,7 @@ fi # One rsync invocation per server available. bm_start "$(basename $0) - Restoring repository networks" rsync_commands=() -for file_list in $tempdir/*.rsync; do +for file_list in $tempdir/git-server-*.rsync; do if $CLUSTER; then server=$(basename $file_list .rsync) else From 1f8dc051174ecc7c6f595dccf2742435144357e2 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Sun, 14 Mar 2021 09:20:10 -0700 Subject: [PATCH 1307/2421] filter restore routes --- share/github-backup-utils/ghe-restore-repositories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 1e413131c..5938a55eb 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -120,7 +120,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring network list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env ./bin/dgit-cluster-restore-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | github-env ./bin/dgit-cluster-restore-routes | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" From 4cea249f2014d0ceaa2189df23199ea4ad06b434 Mon Sep 17 00:00:00 2001 From: Jordan Sussman Date: Wed, 24 Mar 2021 09:02:16 -0500 Subject: [PATCH 1308/2421] fix(docker): add coreutils to get flags for date --- Dockerfile.alpine | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 203952fe8..1f69996f1 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -8,7 +8,8 @@ RUN apk --update --no-cache add \ git \ bash \ gawk \ - procps + procps \ + coreutils WORKDIR /backup-utils ADD https://github.com/github/backup-utils/archive/stable.tar.gz / From 49a012185528f1194e643bea9936cb39d95451e6 Mon Sep 17 00:00:00 2001 From: Logan MacLaren Date: Tue, 30 Mar 2021 09:01:02 -0400 Subject: [PATCH 1309/2421] Clarifying that backups cannot be restored to older versions of GitHub Enterprise Server --- docs/requirements.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/requirements.md b/docs/requirements.md index d646e4981..797eb96cf 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -61,6 +61,8 @@ snapshot of GitHub Enterprise Server 2.11, the target GitHub Enterprise Server a be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapshot from 2.10 to 2.13, because that's three releases ahead. +**Note**: You _cannot_ restore a backup created from a newer verison of GitHub Enterprise Server to an older version. For example, an attempt to restore a snapshot of GitHub Enterprise Server 2.21 to a GitHub Enterprise Server 2.20 environment will fail with an error of `Error: Snapshot can not be restored to an older release of GitHub Enterprise Server.`. + [1]: https://www.gnu.org/software/bash/ [2]: https://git-scm.com/ [3]: https://www.openssh.com/ From 7681d248edeaea424f68c86d57d678b5e215c59b Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:31:15 -0500 Subject: [PATCH 1310/2421] Update ghe-backup-config --- share/github-backup-utils/ghe-backup-config | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 0ddb283eb..f40b41eaa 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -243,6 +243,15 @@ export GHE_SNAPSHOT_DIR # Base path for temporary directories and files. : ${TMPDIR:="/tmp"} +# Backup cadence for MS SQL. Determines the kind of backup taken, either full, differential, +# or transaction log, based on when the last backup of that kind was taken. This defaults to +# taking a full backup once a week, a differential backup once a day, and transaction logs every +# 15 minutes. +: ${GHE_MSSQL_BACKUP_CADENCE:=10080,1440,15} + += + + ############################################################################### ### Dynamic remote version config From e0c403e09fdefffa4acca15dc3ab227924ace918 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:37:39 -0500 Subject: [PATCH 1311/2421] Update test-ghe-backup.sh --- test/test-ghe-backup.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index ff7831f48..3377ad982 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -341,6 +341,15 @@ begin_test "ghe-backup missing directories or files on source appliance" ) end_test +begin_test "ghe-backup has default cadence configured" +( + set -e + enable_actions + + [ -n "$GHE_MSSQL_BACKUP_CADENCE ] +) +end_test + GHE_MSSQL_BACKUP_CADENCE=10,5,1 export GHE_MSSQL_BACKUP_CADENCE setup_actions_test_data $GHE_REMOTE_DATA_USER_DIR From a9a808b9ae238c1938c36aeee6f2074858e8d9dc Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:38:42 -0500 Subject: [PATCH 1312/2421] Update backup.config-example --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 9b0231146..61ccbb055 100644 --- a/backup.config-example +++ b/backup.config-example @@ -60,7 +60,7 @@ GHE_NUM_SNAPSHOTS=10 # - Differential backup every day (1440 minutes) # - Transactionlog backup every 15 minutes # -GHE_MSSQL_BACKUP_CADENCE=10080,1440,15 +#GHE_MSSQL_BACKUP_CADENCE=10080,1440,15 # If set to 'yes', ghe-backup jobs will run in parallel. Defaults to 'no'. # From f37afbba4a0323277824c3734bc8c5b42be36b3c Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:42:00 -0500 Subject: [PATCH 1313/2421] Update ghe-backup-config --- share/github-backup-utils/ghe-backup-config | 3 --- 1 file changed, 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index f40b41eaa..8b7c00aed 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -249,9 +249,6 @@ export GHE_SNAPSHOT_DIR # 15 minutes. : ${GHE_MSSQL_BACKUP_CADENCE:=10080,1440,15} -= - - ############################################################################### ### Dynamic remote version config From 508f1169e782918efc99b08f9b8c82aa75dc8527 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:43:08 -0500 Subject: [PATCH 1314/2421] Update test-ghe-backup.sh --- test/test-ghe-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 3377ad982..df384b9fe 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -346,7 +346,7 @@ begin_test "ghe-backup has default cadence configured" set -e enable_actions - [ -n "$GHE_MSSQL_BACKUP_CADENCE ] + [ -n "$GHE_MSSQL_BACKUP_CADENCE" ] ) end_test From 031d37ea929100b20beafd76406d0f338d98b5fa Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:44:09 -0500 Subject: [PATCH 1315/2421] Update test-ghe-backup.sh --- test/test-ghe-backup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index df384b9fe..61aaa78f6 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -350,6 +350,7 @@ begin_test "ghe-backup has default cadence configured" ) end_test +# Override backup cadence for testing purposes GHE_MSSQL_BACKUP_CADENCE=10,5,1 export GHE_MSSQL_BACKUP_CADENCE setup_actions_test_data $GHE_REMOTE_DATA_USER_DIR From e96caa58964dfab067760f1bfda4a358d8b5578f Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:52:49 -0500 Subject: [PATCH 1316/2421] Update Dockerfile.alpine --- Dockerfile.alpine | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 203952fe8..1f69996f1 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -8,7 +8,8 @@ RUN apk --update --no-cache add \ git \ bash \ gawk \ - procps + procps \ + coreutils WORKDIR /backup-utils ADD https://github.com/github/backup-utils/archive/stable.tar.gz / From 83bba2ed8928580687011c7f7e5f8f14ff96a6d6 Mon Sep 17 00:00:00 2001 From: Joshua Brooks Date: Fri, 9 Apr 2021 13:17:00 -0400 Subject: [PATCH 1317/2421] Add backup cadence variable to the appliance --- share/github-backup-utils/ghe-backup-mssql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index d878f76b3..7edf74898 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -180,6 +180,9 @@ if [ -n "$backup_command" ]; then ghe-ssh "$GHE_HOSTNAME" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename $0)" + # Configure the backup cadence on the appliance, which is used for diagnostics + ghe-ssh "$GHE_HOSTNAME" -- "ghe-config mssql.backup.cadence $cadence" + # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then \ From dff2d6e125499b952ac6a5d0d0bda0516ff10279 Mon Sep 17 00:00:00 2001 From: Joshua Brooks Date: Fri, 9 Apr 2021 14:33:04 -0400 Subject: [PATCH 1318/2421] Fix syntax --- share/github-backup-utils/ghe-backup-mssql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 7edf74898..2f48ce6af 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -181,7 +181,7 @@ if [ -n "$backup_command" ]; then bm_end "$(basename $0)" # Configure the backup cadence on the appliance, which is used for diagnostics - ghe-ssh "$GHE_HOSTNAME" -- "ghe-config mssql.backup.cadence $cadence" + ghe-ssh "$GHE_HOSTNAME" "ghe-config mssql.backup.cadence $cadence" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" From db857c0dbcae503504d3696857a2aff2a9ba7207 Mon Sep 17 00:00:00 2001 From: Joshua Brooks Date: Fri, 9 Apr 2021 14:55:05 -0400 Subject: [PATCH 1319/2421] Fix again --- share/github-backup-utils/ghe-backup-mssql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 2f48ce6af..cfb50bd9a 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -181,7 +181,7 @@ if [ -n "$backup_command" ]; then bm_end "$(basename $0)" # Configure the backup cadence on the appliance, which is used for diagnostics - ghe-ssh "$GHE_HOSTNAME" "ghe-config mssql.backup.cadence $cadence" + ghe-ssh "$GHE_HOSTNAME" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" From 7be51d729134a1c49eca39ff79264c4dbb2cd064 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Mon, 12 Apr 2021 12:16:22 -0500 Subject: [PATCH 1320/2421] Exclude the tmp folder from backups --- share/github-backup-utils/ghe-backup-actions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index 1c5149a40..f19777930 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -42,7 +42,7 @@ ghe_verbose "* Transferring Actions files from $host ..." ghe-rsync -avz \ -e "ghe-ssh -p $port" \ --rsync-path='sudo -u actions rsync' \ - --exclude "mutexes" --exclude "dumps" \ + --exclude "mutexes" --exclude "dumps" --exclude "tmp" \ $link_dest \ "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" \ "$GHE_SNAPSHOT_DIR/actions" 1>&3 From 1be167b12be4ddcb891c371bd6151b17c133aa46 Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Mon, 12 Apr 2021 23:06:56 -0700 Subject: [PATCH 1321/2421] fix is_default_external_database_snapshot function This function tries to access an argument ($1) but no invocations of this function pass in an argument. The implementation has been changed to rely on variables from the environment which allow it correctly find the appropriate sentinel file. --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 0ddb283eb..c19eee3b1 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -462,7 +462,7 @@ is_external_database_snapshot(){ # This file exists if this is a backup for an external database AND the backup was # taken via our logical backup strategy. is_default_external_database_snapshot(){ - is_external_database_snapshot && test -f "$1/logical-external-database-backup-sentinel" + is_external_database_snapshot && test -f "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/logical-external-database-backup-sentinel" } prompt_for_confirmation(){ From 5e16aa04f0148d78c4dfd24a835119a2c85a5a3c Mon Sep 17 00:00:00 2001 From: Ray Xu Date: Thu, 17 Dec 2020 11:05:43 -0800 Subject: [PATCH 1322/2421] Clarify which MSSQL backup files to remove --- share/github-backup-utils/ghe-backup-mssql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index d878f76b3..99c5e2c30 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -81,9 +81,9 @@ ensure_same_dbs() { if [[ "${#locals[@]}" -ne 0 ]]; then ghe_verbose "Warning: Found following ${#locals[@]} backup files that can't be traced back to the specified GHES host." - ghe_verbose "Warning: Did you recently reconfigure the GHES host? Consider deleting these backup files if no longer needed." + ghe_verbose "Warning: Did you recently reconfigure the GHES host? Move or delete these backup files if no longer needed." for local in "${locals[@]}"; do - ghe_verbose "$local" + ghe_verbose "$1/$local" done exit 1 From 4b9cc05d40ec73be76e57521c6a70af59eb3d3d6 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Thu, 7 Jan 2021 15:42:18 -0600 Subject: [PATCH 1323/2421] Update usage for GitHub Actions --- docs/usage.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index 150770fa3..e1f5d3f35 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -90,4 +90,15 @@ are *not* restored to prevent overwriting manual configuration on the restore host. This behavior can be overridden by passing the `-c` argument to `ghe-restore`, forcing settings, certificate, and license data to be overwritten with the backup copy's data. +## Backup and restore with GitHub Actions enabled + +GitHub Actions data on your external storage provider is not included in regular GitHub Enterprise Server +backups, and must be backed up separately. When restoring a GitHub Enterprise Server backup with +GitHub Actions enabled, the following steps are required: + +1. Enable GitHub Actions on the replacement appliance and configure it to use the same GitHub Actions + external storage configuration as the original appliance. +2. Use `ghe-restore` to restore the backup. +3. Re-register your self-hosted runners on the replacement appliance. + [1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md From 5fadd6306be96b0d83ad1a809e29f01e23081a74 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:31:15 -0500 Subject: [PATCH 1324/2421] Update ghe-backup-config --- share/github-backup-utils/ghe-backup-config | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 0ddb283eb..f40b41eaa 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -243,6 +243,15 @@ export GHE_SNAPSHOT_DIR # Base path for temporary directories and files. : ${TMPDIR:="/tmp"} +# Backup cadence for MS SQL. Determines the kind of backup taken, either full, differential, +# or transaction log, based on when the last backup of that kind was taken. This defaults to +# taking a full backup once a week, a differential backup once a day, and transaction logs every +# 15 minutes. +: ${GHE_MSSQL_BACKUP_CADENCE:=10080,1440,15} + += + + ############################################################################### ### Dynamic remote version config From b2e7426ed682dc79ef73ba0153172d0546aa389e Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:37:39 -0500 Subject: [PATCH 1325/2421] Update test-ghe-backup.sh --- test/test-ghe-backup.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 1894e83e2..5790ef3fe 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -352,6 +352,15 @@ begin_test "ghe-backup missing directories or files on source appliance" ) end_test +begin_test "ghe-backup has default cadence configured" +( + set -e + enable_actions + + [ -n "$GHE_MSSQL_BACKUP_CADENCE ] +) +end_test + GHE_MSSQL_BACKUP_CADENCE=10,5,1 export GHE_MSSQL_BACKUP_CADENCE setup_actions_test_data $GHE_REMOTE_DATA_USER_DIR From 5465f4070c15e8964582dba5fd3760aa5c3e9a6c Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:38:42 -0500 Subject: [PATCH 1326/2421] Update backup.config-example --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 9b0231146..61ccbb055 100644 --- a/backup.config-example +++ b/backup.config-example @@ -60,7 +60,7 @@ GHE_NUM_SNAPSHOTS=10 # - Differential backup every day (1440 minutes) # - Transactionlog backup every 15 minutes # -GHE_MSSQL_BACKUP_CADENCE=10080,1440,15 +#GHE_MSSQL_BACKUP_CADENCE=10080,1440,15 # If set to 'yes', ghe-backup jobs will run in parallel. Defaults to 'no'. # From 25ae7d8d7e3a54214f0d4b1a6f16c82ca85346a6 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:42:00 -0500 Subject: [PATCH 1327/2421] Update ghe-backup-config --- share/github-backup-utils/ghe-backup-config | 3 --- 1 file changed, 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index f40b41eaa..8b7c00aed 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -249,9 +249,6 @@ export GHE_SNAPSHOT_DIR # 15 minutes. : ${GHE_MSSQL_BACKUP_CADENCE:=10080,1440,15} -= - - ############################################################################### ### Dynamic remote version config From 51af0edcd1f8a9d582bdcc11088661b53fc0169b Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:43:08 -0500 Subject: [PATCH 1328/2421] Update test-ghe-backup.sh --- test/test-ghe-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 5790ef3fe..caf55b36e 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -357,7 +357,7 @@ begin_test "ghe-backup has default cadence configured" set -e enable_actions - [ -n "$GHE_MSSQL_BACKUP_CADENCE ] + [ -n "$GHE_MSSQL_BACKUP_CADENCE" ] ) end_test From b5a44838a2da20f23863479947537adc0daed587 Mon Sep 17 00:00:00 2001 From: David Hadka Date: Wed, 7 Apr 2021 09:44:09 -0500 Subject: [PATCH 1329/2421] Update test-ghe-backup.sh --- test/test-ghe-backup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index caf55b36e..42f83d132 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -361,6 +361,7 @@ begin_test "ghe-backup has default cadence configured" ) end_test +# Override backup cadence for testing purposes GHE_MSSQL_BACKUP_CADENCE=10,5,1 export GHE_MSSQL_BACKUP_CADENCE setup_actions_test_data $GHE_REMOTE_DATA_USER_DIR From 47696320a8f740f8c65065ccfa7096667f7152df Mon Sep 17 00:00:00 2001 From: David Hadka Date: Mon, 12 Apr 2021 12:16:22 -0500 Subject: [PATCH 1330/2421] Exclude the tmp folder from backups --- share/github-backup-utils/ghe-backup-actions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index 1c5149a40..f19777930 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -42,7 +42,7 @@ ghe_verbose "* Transferring Actions files from $host ..." ghe-rsync -avz \ -e "ghe-ssh -p $port" \ --rsync-path='sudo -u actions rsync' \ - --exclude "mutexes" --exclude "dumps" \ + --exclude "mutexes" --exclude "dumps" --exclude "tmp" \ $link_dest \ "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" \ "$GHE_SNAPSHOT_DIR/actions" 1>&3 From 20d7f0070c392671dff0e614c7df074feedebe8f Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 14 Apr 2021 04:10:58 -0700 Subject: [PATCH 1331/2421] Add initial minio backup script --- bin/ghe-backup | 5 +++ share/github-backup-utils/ghe-backup-minio | 49 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 share/github-backup-utils/ghe-backup-minio diff --git a/bin/ghe-backup b/bin/ghe-backup index 1135db7f0..c36863c9e 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -190,6 +190,11 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then ghe-backup-actions 1>&3 || failures="$failures actions" fi +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then + echo "Backing up Minio data ..." + ghe-backup-minio 1>&3 || failures="$failures minio" +fi + commands=(" echo \"Backing up Redis database ...\" ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"") diff --git a/share/github-backup-utils/ghe-backup-minio b/share/github-backup-utils/ghe-backup-minio new file mode 100755 index 000000000..8d2ae4c71 --- /dev/null +++ b/share/github-backup-utils/ghe-backup-minio @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-minio +#/ Take an online, incremental snapshot of all minio data +#/ +#/ Note: This command typically isn't called directly. It's invoked by +#/ ghe-backup. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config" + +bm_start "$(basename $0)" + +# Set up remote host and root backup snapshot directory based on config +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") +backup_dir="$GHE_SNAPSHOT_DIR/minio" + +# Verify rsync is available. +if ! command -v rsync 1> /dev/null 2>&1; then + echo "Error: rsync not found." 1>&2 + exit 1 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$host" + +# Make sure root backup dir exists if this is the first run +mkdir -p "$backup_dir" + +# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's +# --link-dest support. This also decreases physical space usage considerably. +if [ -d "$GHE_DATA_DIR/current/minio" ] && [ "$(ls -A $GHE_DATA_DIR/current/minio)" ]; then + link_dest="--link-dest=$GHE_DATA_DIR/current/minio" +fi + +# Transfer all minio data from the user data directory using rsync. +ghe_verbose "* Transferring minio files from $host ..." + +ghe-rsync -avz \ + -e "ghe-ssh -p $port" \ + --rsync-path='sudo -u minio rsync' \ + --exclude ".minio.sys" \ + $link_dest \ + "$host:$GHE_REMOTE_DATA_USER_DIR/minio/" \ + "$GHE_SNAPSHOT_DIR/minio" 1>&3 + +bm_end "$(basename $0)" From 2c661db8e4aaa1b9e5fbc51d635d69746173c012 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Thu, 15 Apr 2021 16:51:50 -0700 Subject: [PATCH 1332/2421] Styling fixups Expanded short flags into long flags whenever possible, and double-quoted bare variable interpolations. Also added a comment about why one of the variables in ghe-backup-minio needs to stay unquoted. --- share/github-backup-utils/ghe-backup-minio | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-minio b/share/github-backup-utils/ghe-backup-minio index 8d2ae4c71..59dc7f8b3 100755 --- a/share/github-backup-utils/ghe-backup-minio +++ b/share/github-backup-utils/ghe-backup-minio @@ -10,12 +10,12 @@ set -e # shellcheck source=share/github-backup-utils/ghe-backup-config . "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config" -bm_start "$(basename $0)" +bm_start "$(basename "${0}")" # Set up remote host and root backup snapshot directory based on config -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") -backup_dir="$GHE_SNAPSHOT_DIR/minio" +port="$(ssh_port_part "${GHE_HOSTNAME}")" +host="$(ssh_host_part "${GHE_HOSTNAME}")" +backup_dir="${GHE_SNAPSHOT_DIR}/minio" # Verify rsync is available. if ! command -v rsync 1> /dev/null 2>&1; then @@ -24,26 +24,33 @@ if ! command -v rsync 1> /dev/null 2>&1; then fi # Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" +ghe_remote_version_required "${host}" # Make sure root backup dir exists if this is the first run -mkdir -p "$backup_dir" +mkdir -p "${backup_dir}" # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. -if [ -d "$GHE_DATA_DIR/current/minio" ] && [ "$(ls -A $GHE_DATA_DIR/current/minio)" ]; then - link_dest="--link-dest=$GHE_DATA_DIR/current/minio" +# Hilariously, this HAS to stay unquoted when you call `rsync` further +# down because when the shell interpolates this out, `rsync` will throw +# an absolute fit if this variable is quoted. Surprise! +if [[ -d "${GHE_DATA_DIR}/current/minio" ]] && + [[ "$(ls -A "${GHE_DATA_DIR}/current/minio")" ]]; then + link_dest="--link-dest=${GHE_DATA_DIR}/current/minio" fi # Transfer all minio data from the user data directory using rsync. -ghe_verbose "* Transferring minio files from $host ..." +ghe_verbose "* Transferring minio files from ${host} ..." -ghe-rsync -avz \ - -e "ghe-ssh -p $port" \ +ghe-rsync \ + --archive \ + --verbose \ + --compress \ + --rsh="ghe-ssh -p ${port}" \ --rsync-path='sudo -u minio rsync' \ - --exclude ".minio.sys" \ - $link_dest \ - "$host:$GHE_REMOTE_DATA_USER_DIR/minio/" \ - "$GHE_SNAPSHOT_DIR/minio" 1>&3 + --exclude=".minio.sys" \ + ${link_dest} \ + "${host}:${GHE_REMOTE_DATA_USER_DIR}/minio/" \ + "${GHE_SNAPSHOT_DIR}/minio" 1>&3 -bm_end "$(basename $0)" +bm_end "$(basename "${0}")" From f9c7a725adf9e626ecc57bf9f6bf55a82c98db16 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Thu, 15 Apr 2021 17:40:39 -0700 Subject: [PATCH 1333/2421] Add minio restore script --- bin/ghe-restore | 5 ++ share/github-backup-utils/ghe-restore-minio | 57 +++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100755 share/github-backup-utils/ghe-restore-minio diff --git a/bin/ghe-restore b/bin/ghe-restore index cb119262a..2844fe812 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -320,6 +320,11 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then + echo "Restoring MinIO data ..." + ghe-restore-minio "$GHE_HOSTNAME" 1>&3 +fi + commands=(" echo \"Restoring Redis database ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") diff --git a/share/github-backup-utils/ghe-restore-minio b/share/github-backup-utils/ghe-restore-minio new file mode 100755 index 000000000..a3daa9843 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-minio @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-minio +#/ Restore additional minio files from an rsync snapshot. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config" + +# Show usage and bail with no arguments +[[ -z ${*} ]] && print_usage + +bm_start "$(basename "${0}")" + +# Grab host arg +GHE_HOSTNAME="${1}" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: "${GHE_RESTORE_SNAPSHOT:=current}" + +# Path to snapshot dir we're restoring from +GHE_RESTORE_SNAPSHOT_PATH="${GHE_DATA_DIR}/${GHE_RESTORE_SNAPSHOT}" + +port="$(ssh_port_part "${GHE_HOSTNAME}")" +host="$(ssh_host_part "${GHE_HOSTNAME}")" + +# No need to restore anything, early exit +if [ ! -d "${GHE_RESTORE_SNAPSHOT_PATH}/minio" ]; then + echo "Warning: minio backup missing. Skipping ..." + exit 0 +fi + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "${host}" + +# Transfer all minio data from the snapshot to the user data directory using rsync. +ghe_verbose "* Transferring minio files to ${host} ..." + +ghe-ssh -p "${port}" "${host}" -- sudo mkdir -p "${GHE_REMOTE_DATA_USER_DIR}/minio" +ghe-ssh -p "${port}" "${host}" -- sudo chown -R minio:minio "${GHE_REMOTE_DATA_USER_DIR}/minio" + +ghe-rsync \ + --verbose \ + --archive \ + --hard-links \ + --relative \ + --delete \ + --rsh="ghe-ssh -p ${port}" \ + --rsync-path='sudo -u minio rsync' \ + "${GHE_RESTORE_SNAPSHOT_PATH}/minio/./" \ + "${host}:${GHE_REMOTE_DATA_USER_DIR}/minio/" 1>&3 + +bm_end "$(basename "${0}")" From 9c61305854fa120aff070aa258cbbdad0b60da69 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Fri, 16 Apr 2021 17:35:05 -0700 Subject: [PATCH 1334/2421] The first half of testing minio backups Creating test data, and getting the service enabled in testing --- test/test-ghe-backup.sh | 8 ++++++-- test/testlib.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 61aaa78f6..7ea2e6111 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -345,7 +345,7 @@ begin_test "ghe-backup has default cadence configured" ( set -e enable_actions - + [ -n "$GHE_MSSQL_BACKUP_CADENCE" ] ) end_test @@ -353,7 +353,8 @@ end_test # Override backup cadence for testing purposes GHE_MSSQL_BACKUP_CADENCE=10,5,1 export GHE_MSSQL_BACKUP_CADENCE -setup_actions_test_data $GHE_REMOTE_DATA_USER_DIR +setup_actions_test_data "$GHE_REMOTE_DATA_USER_DIR" +setup_minio_test_data "$GHE_REMOTE_DATA_USER_DIR" begin_test "ghe-backup takes full backup on first run" ( @@ -362,6 +363,7 @@ begin_test "ghe-backup takes full backup on first run" # setup_mssql_backup_file uses "current" set -e enable_actions + enable_minio rm -rf "$GHE_REMOTE_DATA_USER_DIR"/mssql/backups/* rm -rf "$GHE_DATA_DIR"/current/mssql/* @@ -375,6 +377,7 @@ begin_test "ghe-backup takes full backup upon expiration" ( set -e enable_actions + enable_minio export REMOTE_DBS="full_mssql" setup_mssql_backup_file "full_mssql" 11 "bak" @@ -389,6 +392,7 @@ begin_test "ghe-backup takes diff backup upon expiration" ( set -e enable_actions + enable_minio export REMOTE_DBS="full_mssql" setup_mssql_backup_file "full_mssql" 7 "bak" diff --git a/test/testlib.sh b/test/testlib.sh index 7d6bdbf9b..903d2d665 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -345,6 +345,23 @@ cleanup_actions_test_data() { rm -rf "$loc/actions" } +setup_minio_test_data() { + local loc=$1 + + mkdir -p "$loc/minio/" + cd "$loc/minio/" + bucket="packages" + + mkdir -p "$bucket" + echo "an example blob" "$bucket/91dfa09f-1801-4e00-95ee-6b763d7da3e2" +} + +cleanup_minio_test_data() { + local loc=$1 + + rm -rf "$loc/minio" +} + # A unified method to check everything backed up or restored during testing. # Everything tested here should pass regardless of whether we're testing a backup # or a restore. @@ -369,6 +386,11 @@ verify_common_data() { diff -ru "$GHE_REMOTE_DATA_USER_DIR/mssql/backups" "$GHE_DATA_DIR/current/mssql" fi + if is_minio_enabled; then + # verify minio object storge backups were transferred + diff -ru "$GHE_REMOTE_DATA_USER_DIR/minio" "$GHE_DATA_DIR/minio" + fi + # tests that differ for cluster and single node backups and restores if [ "$(cat $GHE_DATA_DIR/current/strategy)" = "rsync" ]; then # verify the UUID was transferred @@ -520,6 +542,14 @@ is_actions_enabled() { ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled' } +enable_minio() { + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config app.minio.enabled true' +} + +is_minio_enabled() { + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled' +} + setup_moreutils_parallel() { # CI servers may have moreutils parallel and GNU parallel installed. # We need moreutils parallel From 96c48832817ed66ae5b93ba77fef6b5e9a552265 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 21 Apr 2021 00:33:08 -0700 Subject: [PATCH 1335/2421] The second half of minio testing Ensure minio data is created during backup restoration testing --- test/testlib.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/testlib.sh b/test/testlib.sh index 903d2d665..b683e0224 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -314,6 +314,8 @@ setup_test_data () { echo "rsync" > "$loc/strategy" echo "$GHE_REMOTE_VERSION" > "$loc/version" fi + + setup_minio_test_data "$GHE_DATA_DIR" } setup_actions_test_data() { From f8d810945ca8b6ba64941284e98bd4b666061b49 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Wed, 21 Apr 2021 01:59:22 -0700 Subject: [PATCH 1336/2421] Add fake `stat` stub for macOS workaround This is an attempt to work around the BSD/GNU `stat` incompatibility for the two calls during storage tests. $ ./test/bin/stat -c %U /Users/GitHub GitHub $ ./test/bin/stat -c %U ./data ryan $ ./test/bin/stat -f '%Su' ./data ryan --- test/bin/stat | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 test/bin/stat diff --git a/test/bin/stat b/test/bin/stat new file mode 100755 index 000000000..11fece575 --- /dev/null +++ b/test/bin/stat @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +# this is an unbelievably narrowly constrained used case: +# there's a single use of `stat` in this codebase: +# calling `stat -c %U` to find the username that owns +# a given path. +# But this fails on macOS because macOS uses BSD stat, +# not GNU stat. This very, VERY basic, very brittle +# wrapper is just to work around this one specific +# call to stat. + +import sys +from os import stat +from pwd import getpwuid + +def find_owner(filename): + return getpwuid(stat(filename).st_uid).pw_name + + +print(find_owner(sys.argv[-1])) From e683cef430f827dc9d4428c988d06e989595f5c6 Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Thu, 22 Apr 2021 02:04:35 -0700 Subject: [PATCH 1337/2421] Use python as interpreter This works in Python 2 or 3, and this will provide broader compatibility. --- test/bin/stat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bin/stat b/test/bin/stat index 11fece575..fb7cdfadb 100755 --- a/test/bin/stat +++ b/test/bin/stat @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # this is an unbelievably narrowly constrained used case: # there's a single use of `stat` in this codebase: From 4ed84cea7e4494bf74ecb3145a42683bbc32da9d Mon Sep 17 00:00:00 2001 From: Ryan McKern Date: Thu, 22 Apr 2021 15:27:08 -0700 Subject: [PATCH 1338/2421] Remove stat fakebin Better to target adding a new fakebin in its own PR --- test/bin/stat | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100755 test/bin/stat diff --git a/test/bin/stat b/test/bin/stat deleted file mode 100755 index fb7cdfadb..000000000 --- a/test/bin/stat +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python - -# this is an unbelievably narrowly constrained used case: -# there's a single use of `stat` in this codebase: -# calling `stat -c %U` to find the username that owns -# a given path. -# But this fails on macOS because macOS uses BSD stat, -# not GNU stat. This very, VERY basic, very brittle -# wrapper is just to work around this one specific -# call to stat. - -import sys -from os import stat -from pwd import getpwuid - -def find_owner(filename): - return getpwuid(stat(filename).st_uid).pw_name - - -print(find_owner(sys.argv[-1])) From afeb809bd9449d56e15adda81276cb061d0af321 Mon Sep 17 00:00:00 2001 From: Zachary Mark Date: Thu, 6 May 2021 17:11:18 +0000 Subject: [PATCH 1339/2421] Bump version: 3.1.0.rc1 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 11 +++++++++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 83666a6b4..60520916b 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.21.0" +supported_minimum_version="2.22.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 4a7e38b38..69cc82857 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +github-backup-utils (3.1.0.rc1) UNRELEASED; urgency=medium + + * Update repository backups to use ghe-gc-* for lock file management #188 + * A faster way to restore storage blobs (clusters) #212 + * Bug fix: Be more specific in restore routes globbing #715 + * fix(docker): add coreutils to get flags for date #717 + * Add backup cadence variable to the appliance #719 + * Fix is_default_external_database_snapshot function #720 + + -- Zachary Mark Thu, 06 May 2021 17:11:18 +0000 + github-backup-utils (3.0.0) UNRELEASED; urgency=medium * Fix restoring the password pepper for already configured instances #683 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 4a36342fc..90040cdc4 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.0.0 +3.1.0.rc1 diff --git a/test/testlib.sh b/test/testlib.sh index 211c65b27..798c49d0d 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.0.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.1.0.rc1.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 6d0998664a5a0fbf68fa8546d5dd452ef35c97b9 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Sat, 8 May 2021 05:34:46 +0900 Subject: [PATCH 1340/2421] Fix debian package versioning version number 3.0.1.rc1 is bigger than 3.0.1 official release, so we should use ~ for it $ dpkg --compare-versions 3.0.1.rc1 gt 3.0.1 $ echo $? 0 gt means "greater than" --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 69cc82857..c0d6da181 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -github-backup-utils (3.1.0.rc1) UNRELEASED; urgency=medium +github-backup-utils (3.1.0~rc1) UNRELEASED; urgency=medium * Update repository backups to use ghe-gc-* for lock file management #188 * A faster way to restore storage blobs (clusters) #212 From ead260b910ade53a7d4e5e86c02c26e6ba6e87e9 Mon Sep 17 00:00:00 2001 From: Zachary Mark Date: Fri, 7 May 2021 17:27:39 -0500 Subject: [PATCH 1341/2421] Fix CI builds that broke due to the new 3.1.0 release --- test/test-ghe-host-check.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index ece28f616..d9d0904b2 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -58,7 +58,9 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions ! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check # hardcode until https://github.com/github/backup-utils/issues/675 is resolved ! GHE_TEST_REMOTE_VERSION=2.20.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.21.0 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=2.21.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=2.22.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check From a4a1b9302f47707b0a365bb85580ee2288f43e80 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Mon, 10 May 2021 21:45:05 -0700 Subject: [PATCH 1342/2421] Remove deprecated es-hookshot backup and restore --- bin/ghe-backup | 4 -- bin/ghe-restore | 5 +- .../ghe-backup-es-hookshot | 49 --------------- .../ghe-restore-es-hookshot | 63 ------------------- test/bin/curl | 2 +- test/test-ghe-backup.sh | 13 ---- test/testlib.sh | 6 -- 7 files changed, 2 insertions(+), 140 deletions(-) delete mode 100755 share/github-backup-utils/ghe-backup-es-hookshot delete mode 100755 share/github-backup-utils/ghe-restore-es-hookshot diff --git a/bin/ghe-backup b/bin/ghe-backup index c36863c9e..8d9be333c 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -203,10 +203,6 @@ commands+=(" echo \"Backing up audit log ...\" ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"") -commands+=(" -echo \"Backing up hookshot logs ...\" -ghe-backup-es-hookshot || printf %s \"hookshot \" >> \"$failures_file\"") - commands+=(" echo \"Backing up Git repositories ...\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") diff --git a/bin/ghe-restore b/bin/ghe-restore index ee1f47ed6..645d93324 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -380,7 +380,7 @@ if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" fi -# Restore exported audit and hookshot logs to 2.12.9 and newer single nodes and +# Restore exported audit logs to 2.12.9 and newer single nodes and # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then @@ -391,9 +391,6 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi - commands+=(" - echo \"Restoring hookshot logs ...\" - ghe-restore-es-hookshot \"$GHE_HOSTNAME\" 1>&3") fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then diff --git a/share/github-backup-utils/ghe-backup-es-hookshot b/share/github-backup-utils/ghe-backup-es-hookshot deleted file mode 100755 index 678928d3b..000000000 --- a/share/github-backup-utils/ghe-backup-es-hookshot +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-es-hookshot -#/ Take a backup of hookshot logs in Elasticsearch. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Set up remote host and root elastic backup directory based on config -host="$GHE_HOSTNAME" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Make sure root backup dir exists if this is the first run -mkdir -p "$GHE_SNAPSHOT_DIR/hookshot" - -if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:9201/_cat/indices/hookshot-logs-*?h=index,pri.store.size&bytes=b\""); then - echo "Error: failed to retrieve hookshot log indices." 1>&2 - exit 1 -fi - -# Hookshot indices may not exist if no recent webhook deliveries have occured. -[ -z "$indices" ] && exit - -IFS=$'\n' -for index in $indices; do - IFS=' ' - set $index - index_name=$1 - index_size=$2 - - if [[ -f $GHE_DATA_DIR/current/hookshot/$index_name.gz && $(cat $GHE_DATA_DIR/current/hookshot/$index_name.gz.size 2>/dev/null || true) -eq $index_size ]]; then - # Hard link any indices that have not changed since the last backup - ln $GHE_DATA_DIR/current/hookshot/$index_name.gz $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz - ln $GHE_DATA_DIR/current/hookshot/$index_name.gz.size $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size - else - echo "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\" | gzip" | ghe-ssh "$host" -- /bin/bash > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz - echo $index_size > $GHE_SNAPSHOT_DIR/hookshot/$index_name.gz.size - fi -done - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-es-hookshot b/share/github-backup-utils/ghe-restore-es-hookshot deleted file mode 100755 index 0faeb52b9..000000000 --- a/share/github-backup-utils/ghe-restore-es-hookshot +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-es-hookshot -#/ Restores a backup of hookshot logs to Elasticsearch. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-restore. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Show usage and bail with no arguments -[ $# -lt 1 ] && print_usage - -bm_start "$(basename $0)" - -GHE_HOSTNAME="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -last_index=$(ghe-ssh "$GHE_HOSTNAME" 'curl -s "localhost:9201/_cat/indices/hookshot-logs-*"' | cut -d ' ' -f 3 | sort | tail -2 | head -1) - -indices=$(find $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/*.gz -print0 2>/dev/null | xargs -0 -I{} -n1 basename {} .gz) -tmp_list="$(mktemp -t backup-utils-restore-XXXXXX)" -if is_instance_configured; then - configured=true -fi - -for index in $indices; do - if [ -z "$last_index" ] || ! [ $index \< $last_index ]; then - echo "$index.gz" >> $tmp_list - fi -done - -if [ -s "$tmp_list" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 - ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 - - ghe-rsync -avz --delete \ - -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ - --rsync-path="sudo -u elasticsearch rsync" \ - --files-from=$tmp_list \ - "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/hookshot/" \ - "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/" 1>&3 - - if $CLUSTER || [ -n "$configured" ]; then - for index in $(cat $tmp_list | sed 's/\.gz$//g'); do - ghe_verbose "* Restoring $index" - echo "export PATH=\$PATH:/usr/local/share/enterprise && sudo gzip -dc $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/$index | ghe-es-load-json 'http://localhost:9201/$index'" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash 1>&3 - done - else - ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'mv $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/* $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/'" 1>&3 - fi - - ghe-ssh "$GHE_HOSTNAME" -- "sudo sh -c 'rm -rf $GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/hookshot/'" 1>&3 - - rm $tmp_list -fi - -bm_end "$(basename $0)" diff --git a/test/bin/curl b/test/bin/curl index 9d52f6fe7..a2caee08c 100755 --- a/test/bin/curl +++ b/test/bin/curl @@ -3,7 +3,7 @@ # Fake curl command stub for tests. set -e -# Return empty list of indexes for ghe-backup-es-audit-log and ghe-backup-es-hookshot +# Return empty list of indexes for ghe-backup-es-audit-log if echo "$@" | grep -q '_cat/indices/'; then exit 0 # Exit with non-zero code to mimic a non-existant index diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index aa7f2e1cc..dec117378 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -132,19 +132,6 @@ begin_test "ghe-backup without password pepper" ) end_test -begin_test "ghe-backup empty hookshot directory" -( - set -e - - rm -rf $GHE_REMOTE_DATA_USER_DIR/hookshot/repository-* - rm -rf $GHE_DATA_DIR/current/hookshot/repository-* - ghe-backup - - # Check that the "--link-dest arg does not exist" message hasn't occurred. - [ ! "$(grep "[l]ink-dest arg does not exist" $TRASHDIR/out)" ] -) -end_test - begin_test "ghe-backup empty git-hooks directory" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index 798c49d0d..94fee24fb 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -261,11 +261,6 @@ setup_test_data () { echo "fake audit log this yr this mth" | gzip > audit_log-1-$this_yr-$this_mth-1.gz echo "1" > audit_log-1-$this_yr-$this_mth-1.size - # Create hookshot logs - mkdir -p "$loc/hookshot/" - cd "$loc/hookshot/" - echo "fake hookshot log" | gzip > hookshot-logs-2018-03-05.gz - # Create some test repositories in the remote repositories dir mkdir -p "$loc/repositories/info" mkdir -p "$TRASHDIR/hooks" @@ -497,7 +492,6 @@ verify_all_restored_data() { else grep -q "fake audit log last yr last mth" "$TRASHDIR/restore-out" grep -q "fake audit log this yr this mth" "$TRASHDIR/restore-out" - grep -q "fake hookshot log" "$TRASHDIR/restore-out" fi # verify settings import was *not* run due to instance already being From cf674b4e1ead553b1e2622aee5447a80463e0f67 Mon Sep 17 00:00:00 2001 From: Logan MacLaren Date: Tue, 11 May 2021 08:50:30 -0400 Subject: [PATCH 1343/2421] clarifying moreutils parallel requirement --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de483cf5f..7f97454c2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository includes backup and recovery utilities for [GitHub Enterprise Server][1]. -**UPDATE**: The new parallel backup and restore beta feature will require [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils) to be installed. +**UPDATE**: The new parallel backup and restore beta feature will require [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils) to be installed. Note that on some distributions/platforms, the `moreutils-parallel` package is separate from `moreutils` and must be installed on its own. **Note**: the [GitHub Enterprise Server version requirements][2] have changed starting with Backup Utilities v2.13.0, released on 27 March 2018. From 189c2b2fca4aeb30f5f0f850d67c4fe4c65e8b2e Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Fri, 7 May 2021 02:59:27 +0900 Subject: [PATCH 1344/2421] Remove meaningless build-indep: line from debian/rules Specifying empty build-indep: target does not have any meanings. --- debian/rules | 1 - 1 file changed, 1 deletion(-) diff --git a/debian/rules b/debian/rules index 290fed548..818f48510 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,4 @@ #!/usr/bin/make -f -build-indep: override_dh_auto_build: From e18d0332dbdddd09a6d3d7a20ff2b59e2f58b3fc Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 15:20:33 +0900 Subject: [PATCH 1345/2421] Format debian/copyright with Machine-readable debian/copyright format 1.0 Write it as more Debian way, use copyright format 1.0 See https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ --- debian/copyright | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) mode change 120000 => 100644 debian/copyright diff --git a/debian/copyright b/debian/copyright deleted file mode 120000 index ea5b60640..000000000 --- a/debian/copyright +++ /dev/null @@ -1 +0,0 @@ -../LICENSE \ No newline at end of file diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 000000000..36df4903a --- /dev/null +++ b/debian/copyright @@ -0,0 +1,25 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: GitHub Enterprise Server Backup Utilities +Source: https://github.com/github/backup-utils + +Files: * +Copyright: 2014-2021, GitHub Inc. +License: MIT + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + . + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From e73d6691023885631b662d48d08925b8c2291780 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 15:10:28 +0900 Subject: [PATCH 1346/2421] Upgrade to newer source format 3.0 (native). Changes-By: lintian-brush Fixes: lintian: missing-debian-source-format See-also: https://lintian.debian.org/tags/missing-debian-source-format.html Fixes: lintian: older-source-format See-also: https://lintian.debian.org/tags/older-source-format.html --- debian/source/format | 1 + 1 file changed, 1 insertion(+) create mode 100644 debian/source/format diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 000000000..89ae9db8f --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) From 0f1f32c79df92aa9bee02c71c733308ec1ef7f9e Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Fri, 7 May 2021 03:20:22 +0900 Subject: [PATCH 1347/2421] fix lintian warnings in debian/changelog W: github-backup-utils: syntax-error-in-debian-changelog line 144 "found trailer where expected start of change data" W: github-backup-utils: syntax-error-in-debian-changelog line 155 "found trailer where expected start of change data" W: github-backup-utils: syntax-error-in-debian-changelog line 160 "found trailer where expected start of change data" W: github-backup-utils: syntax-error-in-debian-changelog line 45 "badly formatted trailer line" W: github-backup-utils: syntax-error-in-debian-changelog line 47 "found start of entry where expected more change data or trailer" --- debian/changelog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index c0d6da181..2e2351364 100644 --- a/debian/changelog +++ b/debian/changelog @@ -37,7 +37,7 @@ github-backup-utils (2.22.0) UNRELEASED; urgency=medium * Add parallelized restore capability to ghe-restore-storage #635 * Update backup-utils for new features in 2.22 #641 - -- jianghao0718@github.com Wed, 23 Sep 2020 15:48:54 +0000 + -- Hao Jiang Wed, 23 Sep 2020 15:48:54 +0000 github-backup-utils (2.21.0) UNRELEASED; urgency=medium @@ -135,6 +135,7 @@ github-backup-utils (2.16.1) UNRELEASED; urgency=medium github-backup-utils (2.16.0) UNRELEASED; urgency=medium + * (There was no descriptions) -- Colin Seymour Tue, 22 Jan 2019 20:25:34 +0000 @@ -146,11 +147,13 @@ github-backup-utils (2.15.1) UNRELEASED; urgency=medium github-backup-utils (2.15.0) UNRELEASED; urgency=medium + * (There was no descriptions) -- Colin Seymour Tue, 16 Oct 2018 16:40:03 +0000 github-backup-utils (2.15.0) UNRELEASED; urgency=medium + * (There was no descriptions) -- Colin Seymour Tue, 16 Oct 2018 16:07:36 +0000 From f156d4224731bbff84ea17e3003a28c7489255c2 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 15:28:38 +0900 Subject: [PATCH 1348/2421] Update descriptions in debian/control As debian package, "Runs under most Linux/Unix environments." comment is unnecessary, "MIT licensed, open source software maintained by GitHub, Inc." is also no meaning for users (It should be documented on other file/items on debian/control). --- debian/control | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/debian/control b/debian/control index 4ccf03654..9b1f52be5 100644 --- a/debian/control +++ b/debian/control @@ -14,20 +14,15 @@ Description: Backup and recovery utilities for GitHub Enterprise Server GitHub Enterprise Server. . These advanced features include: - . - Complete GitHub Enterprise Server backup and recovery system via two simple - utilities: - `ghe-backup` and `ghe-restore`. - Online backups. The GitHub appliance need not be put in maintenance mode for - the duration of the backup run. - Incremental backup of Git repository data. Only changes since the last - snapshot are transferred, leading to faster backup runs and lower network - bandwidth and machine utilization. - Efficient snapshot storage. Only data added since the previous snapshot - consumes new space on the backup host. - Multiple backup snapshots with configurable retention periods. - Backup commands run under the lowest CPU/IO priority on the GitHub appliance, - reducing performance impact while backups are in progress. - Runs under most Linux/Unix environments. - MIT licensed, open source software maintained by GitHub, Inc. - + - Complete GitHub Enterprise Server backup and recovery system via two simple + utilities: `ghe-backup` and `ghe-restore`. + - Online backups. The GitHub appliance need not be put in maintenance mode for + the duration of the backup run. + - Incremental backup of Git repository data. Only changes since the last + snapshot are transferred, leading to faster backup runs and lower network + bandwidth and machine utilization. + - Efficient snapshot storage. Only data added since the previous snapshot + consumes new space on the backup host. + - Multiple backup snapshots with configurable retention periods. + - Backup runs under the lowest CPU/IO priority on the GitHub appliance, + reducing performance impact while backups are in progress. From bca61e4c45a6b60e2b6b3fbb956a55240c4d4883 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 15:47:50 +0900 Subject: [PATCH 1349/2421] Fix "Architecture: all", instead of "any" "Architecture:" field shows it depends which architecture, if you specify it as "any" it would be converted on build host arch. "all" means architecture independs. Well, this package does not contain any architecture depend files. No .so files, and /usr/bin/* files are shellscripts. > $ file ghe-* > ghe-backup: Bourne-Again shell script, ASCII text executable > ghe-host-check: Bourne-Again shell script, ASCII text executable > ghe-restore: Bourne-Again shell script, ASCII text executable So it should be "Architecture: all", not "any". --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 9b1f52be5..47de66fad 100644 --- a/debian/control +++ b/debian/control @@ -6,7 +6,7 @@ Standards-Version: 3.9.2 Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq, rsync (>= 2.6.4) Package: github-backup-utils -Architecture: any +Architecture: all Depends: ${misc:Depends}, rsync (>= 2.6.4), moreutils, jq, git Description: Backup and recovery utilities for GitHub Enterprise Server The backup utilities implement a number of advanced capabilities for backup From ea688e433b89094397003b0afcc05f3d937caf49 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 15:54:52 +0900 Subject: [PATCH 1350/2421] Declare its Homepage as https://github.com/github/backup-utils See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-homepage --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index 47de66fad..4b73e7ff8 100644 --- a/debian/control +++ b/debian/control @@ -4,6 +4,7 @@ Section: misc Priority: optional Standards-Version: 3.9.2 Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq, rsync (>= 2.6.4) +Homepage: https://github.com/github/backup-utils Package: github-backup-utils Architecture: all From f8a6d0cf5edc0ed44e9c1f5716af6bd328a9dbb6 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 15:56:12 +0900 Subject: [PATCH 1351/2421] Add Vcs-* metadata field. See https://www.debian.org/doc/debian-policy/ch-controlfields.html#version-control-system-vcs-fields --- debian/control | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/control b/debian/control index 4b73e7ff8..116ee176c 100644 --- a/debian/control +++ b/debian/control @@ -5,6 +5,8 @@ Priority: optional Standards-Version: 3.9.2 Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq, rsync (>= 2.6.4) Homepage: https://github.com/github/backup-utils +Vcs-Git: https://github.com/github/backup-utils.git +Vcs-Browser: https://github.com/github/backup-utils Package: github-backup-utils Architecture: all From b35d4de371f52bed5135ca6ba3d6c1542875a0a0 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 15:56:55 +0900 Subject: [PATCH 1352/2421] Specify "Rules-Requires-Root: no" This does not require access to root (or fakeroot), so set it as. --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index 116ee176c..8605daf29 100644 --- a/debian/control +++ b/debian/control @@ -7,6 +7,7 @@ Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq, rsync (>= 2.6.4 Homepage: https://github.com/github/backup-utils Vcs-Git: https://github.com/github/backup-utils.git Vcs-Browser: https://github.com/github/backup-utils +Rules-Requires-Root: no Package: github-backup-utils Architecture: all From bd00d0dd2691a9d3029dc7579a4d3c6468c9806b Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 16:03:00 +0900 Subject: [PATCH 1353/2421] Drop "Build-Depends: devscripts" > commit 1de3dd46132cf76536b6bf5eb037ef336fe595e3 > Author: Twan Wolthof > Date: Wed Feb 4 16:34:19 2015 +0100 > > Add devscripts to debian's build-depends for checkbashisms However, not necessary to build package itself, so it should be removed. --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 8605daf29..e00c1d320 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Maintainer: Twan Wolthof Section: misc Priority: optional Standards-Version: 3.9.2 -Build-Depends: debhelper (>= 9), git, devscripts, moreutils, jq, rsync (>= 2.6.4) +Build-Depends: debhelper (>= 9), git, moreutils, jq, rsync (>= 2.6.4) Homepage: https://github.com/github/backup-utils Vcs-Git: https://github.com/github/backup-utils.git Vcs-Browser: https://github.com/github/backup-utils From 02312b148ffb2fa01f13fbb36394a81d388e2557 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 17:32:11 +0900 Subject: [PATCH 1354/2421] Bump debhelper 10 from 9 to reduce lintian warning current oldstable "stretch" has debhelper v10, so we can use 10. --- debian/compat | 2 +- debian/control | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/compat b/debian/compat index ec635144f..f599e28b8 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -9 +10 diff --git a/debian/control b/debian/control index e00c1d320..3ac5715e0 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Maintainer: Twan Wolthof Section: misc Priority: optional Standards-Version: 3.9.2 -Build-Depends: debhelper (>= 9), git, moreutils, jq, rsync (>= 2.6.4) +Build-Depends: debhelper (>= 10), git, moreutils, jq, rsync (>= 2.6.4) Homepage: https://github.com/github/backup-utils Vcs-Git: https://github.com/github/backup-utils.git Vcs-Browser: https://github.com/github/backup-utils From abbbdd787f2f613f52a5c94877e938090eea7e40 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 17:33:23 +0900 Subject: [PATCH 1355/2421] Set Standards-Version: 4.5.1 We can improve deb package with current debian-policy 4.5.1, so declare it. --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 3ac5715e0..5543a1bbd 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: github-backup-utils Maintainer: Twan Wolthof Section: misc Priority: optional -Standards-Version: 3.9.2 +Standards-Version: 4.5.1 Build-Depends: debhelper (>= 10), git, moreutils, jq, rsync (>= 2.6.4) Homepage: https://github.com/github/backup-utils Vcs-Git: https://github.com/github/backup-utils.git From aa8a232fa8b82069468db498491474adf34193b9 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 17:35:21 +0900 Subject: [PATCH 1356/2421] Update Maintainer as Zachary Mark It seems that Twan Wolthof does not have any responsibility for maintaining this package now. someone@github.com should be specified as Maintainer in fact. If other than Zachary would update this package too, just add it as "Uploaders: foobar " or so. --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 5543a1bbd..ae302aaa3 100644 --- a/debian/control +++ b/debian/control @@ -1,5 +1,5 @@ Source: github-backup-utils -Maintainer: Twan Wolthof +Maintainer: Zachary Mark Section: misc Priority: optional Standards-Version: 4.5.1 From 17bd14f9aab0f6c4dec1ec7b4f53672985d6ba3b Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 19:22:10 +0900 Subject: [PATCH 1357/2421] Update debian/copyright for debian/* --- debian/copyright | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/debian/copyright b/debian/copyright index 36df4903a..8879cfae8 100644 --- a/debian/copyright +++ b/debian/copyright @@ -4,6 +4,14 @@ Source: https://github.com/github/backup-utils Files: * Copyright: 2014-2021, GitHub Inc. +License: MIT + +Files: debian/* +Copyright: 2014-2021, GitHub Inc. + 2014 Twan Wolthof + 2021 Hideki Yamane +License: MIT + License: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the From 345fa879f541d0f9a5f203ad6fab5b7a0104afd5 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Tue, 11 May 2021 19:50:14 +0900 Subject: [PATCH 1358/2421] Use help2man to generate each manpages for commands 1. Add help2man as Build dependency via debian/control 2. Run it on build time via debian/rules 3. Install it via debian/manpages 4. Add clean target via debian/clean --- debian/clean | 1 + debian/control | 2 +- debian/manpages | 1 + debian/rules | 12 ++++++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 debian/clean create mode 100644 debian/manpages diff --git a/debian/clean b/debian/clean new file mode 100644 index 000000000..0f651869c --- /dev/null +++ b/debian/clean @@ -0,0 +1 @@ +debian/*.1 diff --git a/debian/control b/debian/control index ae302aaa3..87c70b12f 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Maintainer: Zachary Mark Section: misc Priority: optional Standards-Version: 4.5.1 -Build-Depends: debhelper (>= 10), git, moreutils, jq, rsync (>= 2.6.4) +Build-Depends: debhelper (>= 10), git, moreutils, jq, rsync (>= 2.6.4), help2man, Homepage: https://github.com/github/backup-utils Vcs-Git: https://github.com/github/backup-utils.git Vcs-Browser: https://github.com/github/backup-utils diff --git a/debian/manpages b/debian/manpages new file mode 100644 index 000000000..0f651869c --- /dev/null +++ b/debian/manpages @@ -0,0 +1 @@ +debian/*.1 diff --git a/debian/rules b/debian/rules index 818f48510..af3d39d08 100755 --- a/debian/rules +++ b/debian/rules @@ -1,6 +1,18 @@ #!/usr/bin/make -f +VERSION=$$(cat $(CURDIR)/share/github-backup-utils/version) + override_dh_auto_build: + # generate manpages for ghe-backup, ghe-host-check and ghe-restore + help2man $(CURDIR)/bin/ghe-backup -N -o $(CURDIR)/debian/ghe-backup.1 \ + -n "Take snapshots of all GitHub Enterprise data" \ + --version-string="ghe-backup $(VERSION)" + help2man $(CURDIR)/bin/ghe-host-check -N -o $(CURDIR)/debian/ghe-host-check.1 \ + -n "Restores a GitHub instance from local backup snapshots" \ + --version-string="ghe-host-check $(VERSION)" + help2man $(CURDIR)/bin/ghe-restore -N -o $(CURDIR)/debian/ghe-restore.1 \ + -n "Verify connectivity with the GitHub Enterprise Server host" \ + --version-string="ghe-restore $(VERSION)" %: dh $@ From 84a8cc85f405119f43e1051a4cc9f68900f431fd Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Wed, 12 May 2021 23:14:48 +0900 Subject: [PATCH 1359/2421] Update debian/changelog entries for changes --- debian/changelog | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/debian/changelog b/debian/changelog index 2e2351364..ed6b337f5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ github-backup-utils (3.1.0~rc1) UNRELEASED; urgency=medium + [ Zachary Mark ] * Update repository backups to use ghe-gc-* for lock file management #188 * A faster way to restore storage blobs (clusters) #212 * Bug fix: Be more specific in restore routes globbing #715 @@ -7,6 +8,33 @@ github-backup-utils (3.1.0~rc1) UNRELEASED; urgency=medium * Add backup cadence variable to the appliance #719 * Fix is_default_external_database_snapshot function #720 + [ Hideki Yamane ] + * debian/rules + - Drop unnecessary build-indep: + - Add manpages generation. + * debian/changelog + - Fix some lintian warnings for old entries. + * debian/source/format + - Upgrade to newer source format 3.0 (native). + * debian/copyright + - Format it as Machine-readable debian/copyright format 1.0 + - Add entries Twan Wolthof and me for debian/* since + enough code was written by non-github.com employees, at least. + * debian/control + - Update descriptions in debian/control + - Fix "Architecture: all", instead of "any". + - Declare its Homepage as https://github.com/github/backup-utils + - Add Vcs-* metadata field. + - Specify "Rules-Requires-Root: no" + - Drop unnecessary "Build-Depends: devscripts" + - Bump debhelper 10 from 9 to reduce lintian warning. + - Set Standards-Version: 4.5.1 + - Update Maintainer as Zachary Mark + * debian/compat + - Set 10 as above debhelper changes. + * debian/{clean,manpages} + - Add files to support manpages handles. + -- Zachary Mark Thu, 06 May 2021 17:11:18 +0000 github-backup-utils (3.0.0) UNRELEASED; urgency=medium From 46d05a01d92576f0264868af21cc7704172e18d8 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Thu, 13 May 2021 11:51:48 +0900 Subject: [PATCH 1360/2421] Add help2man dependency for workflow --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 032df3919..66d37fbff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: - name: Install Dependencies (Linux) run: | sudo apt-get update -y - sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz + sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man wget "https://github.com/koalaman/shellcheck/releases/download/v0.7.0/shellcheck-v0.7.0.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck From b83f7360b66e84ba6681cfe2eddb4421951be124 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Thu, 13 May 2021 12:37:12 +0900 Subject: [PATCH 1361/2421] Once revert debhelper version change Well, GitHub workflow specifies ubuntu 16.04 as test env. It is now under EMS stage (https://lists.ubuntu.com/archives/ubuntu-announce/2021-March/000266.html) but is still there. We can ignore that as "package build" env, but once revert changes --- debian/changelog | 3 --- debian/compat | 2 +- debian/control | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/debian/changelog b/debian/changelog index ed6b337f5..361c096d8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -27,11 +27,8 @@ github-backup-utils (3.1.0~rc1) UNRELEASED; urgency=medium - Add Vcs-* metadata field. - Specify "Rules-Requires-Root: no" - Drop unnecessary "Build-Depends: devscripts" - - Bump debhelper 10 from 9 to reduce lintian warning. - Set Standards-Version: 4.5.1 - Update Maintainer as Zachary Mark - * debian/compat - - Set 10 as above debhelper changes. * debian/{clean,manpages} - Add files to support manpages handles. diff --git a/debian/compat b/debian/compat index f599e28b8..ec635144f 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -10 +9 diff --git a/debian/control b/debian/control index 87c70b12f..b2cd7c945 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Maintainer: Zachary Mark Section: misc Priority: optional Standards-Version: 4.5.1 -Build-Depends: debhelper (>= 10), git, moreutils, jq, rsync (>= 2.6.4), help2man, +Build-Depends: debhelper (>= 9), git, moreutils, jq, rsync (>= 2.6.4), help2man, Homepage: https://github.com/github/backup-utils Vcs-Git: https://github.com/github/backup-utils.git Vcs-Browser: https://github.com/github/backup-utils From 2bc31a99174a9f6ab3de361d3fca18f4bcf2c254 Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Mon, 17 May 2021 23:24:37 +0900 Subject: [PATCH 1362/2421] Fix redirection bug (SC2259) in test/testlib.sh ShellCheck 0.7.2 says > In test/testlib.sh line 149: > grep -a -v -e '^\+ end_test' -e '^+ set +x' <"$TRASHDIR/out" | > ^-- SC2259: This redirection overrides piped input. To use both, merge or pass filenames. > >For more information: > https://www.shellcheck.net/wiki/SC2259 -- This redirection overrides piped ... --- test/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 94fee24fb..15755e878 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -146,7 +146,7 @@ report_failure () { printf "test: %-73s $msg\\n" "$desc ..." ( sed 's/^/ /' <"$TRASHDIR/out" | - grep -a -v -e '^\+ end_test' -e '^+ set +x' <"$TRASHDIR/out" | + grep -a -v -e '^\+ end_test' -e '^+ set +x' - "$TRASHDIR/out" | sed 's/[+] test_status=/test failed. last command exited with /' | sed 's/^/ /' ) 1>&2 From 6b1dc195de3b6798bf83e729dcec0db70180050b Mon Sep 17 00:00:00 2001 From: Hideki Yamane Date: Thu, 13 May 2021 13:00:43 +0900 Subject: [PATCH 1363/2421] Get and use latest shellcheck for tests Now we use shellcheck 0.7.0 on Ubuntu hosts for test, but also use 0.7.2 or later on macOS host via brew. So, not specifying version and always fetch & run latest version of shellcheck on Ubuntu host is better. We don't have a reason to stick to 0.7.0, IMHO. --- .github/workflows/main.yml | 6 +++--- test/test-shellcheck.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 032df3919..e3c42de2e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,9 +14,9 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz - wget "https://github.com/koalaman/shellcheck/releases/download/v0.7.0/shellcheck-v0.7.0.linux.x86_64.tar.xz" - tar --xz -xvf "shellcheck-v0.7.0.linux.x86_64.tar.xz" - sudo cp shellcheck-v0.7.0/shellcheck /usr/bin/shellcheck + wget "https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz" + tar --xz -xvf "shellcheck-latest.linux.x86_64.tar.xz" + sudo cp shellcheck-latest/shellcheck /usr/bin/shellcheck if: matrix.os != 'macos-latest' - name: Install Dependencies (macOS) run: | diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh index c270d5781..92ac538cc 100755 --- a/test/test-shellcheck.sh +++ b/test/test-shellcheck.sh @@ -9,10 +9,10 @@ BASE_PATH=$(cd "$(dirname "$0")/../" && pwd) begin_test "shellcheck: reports no errors or warnings" ( set -e - # We manually install Shellcheck 0.7.0 on Linux builds as other options + # We manually install the latest Shellcheck on Linux builds as other options # are too old. - if [ -x "$BASE_PATH/shellcheck-v0.7.0/shellcheck" ]; then - shellcheck() { "$BASE_PATH/shellcheck-v0.7.0/shellcheck" "$@"; } + if [ -x "$BASE_PATH/shellcheck-latest/shellcheck" ]; then + shellcheck() { "$BASE_PATH/shellcheck-latest/shellcheck" "$@"; } fi if ! type shellcheck 1>/dev/null 2>&1; then From edf54fed351e7f1de7af1e39e5212ea3ca8f744d Mon Sep 17 00:00:00 2001 From: Zachary Mark Date: Tue, 25 May 2021 16:41:31 -0500 Subject: [PATCH 1364/2421] Update remote version with comment from @qnordic --- test/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 15755e878..52e6f8f56 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.1.0.rc1.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.1.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From a589710c1b2f96a504e5aa2817cf3d0193b8707c Mon Sep 17 00:00:00 2001 From: Zachary Mark Date: Thu, 3 Jun 2021 16:55:16 +0000 Subject: [PATCH 1365/2421] Bump version: 3.1.0 [ci skip] --- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index c0d6da181..45d51af70 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.1.0) UNRELEASED; urgency=medium + + + -- Zachary Mark Thu, 03 Jun 2021 16:55:16 +0000 + github-backup-utils (3.1.0~rc1) UNRELEASED; urgency=medium * Update repository backups to use ghe-gc-* for lock file management #188 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 90040cdc4..fd2a01863 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.1.0.rc1 +3.1.0 From aeb986586fa926dbebebc70a07dfc801784dee8f Mon Sep 17 00:00:00 2001 From: Andy Jones Date: Fri, 18 Jun 2021 11:39:52 +1000 Subject: [PATCH 1366/2421] Leaked host key check: Avoid false positives from FIPS mode Enabling FIPS (Federal Information Processing Standards) mode may cause ssh-keygen's MD5-based fingerprint generation to fail, resulting in a message on stderr and a blank fingerprint string. A grep search for an empty string succeeds so a blank fingerprint is reported as a leaked host key. --- share/github-backup-utils/ghe-detect-leaked-ssh-keys | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 75b65a98f..79978ddf0 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -69,6 +69,7 @@ if [ -L "$GHE_DATA_DIR/current" ]; then fi leaked_keys_found=false +leaked_keys_skippedcheck=false current_bkup=false for tar_file in $ssh_tars; do for key in $keys; do @@ -79,7 +80,9 @@ for tar_file in $ssh_tars; do else fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) fi - if echo "$FINGERPRINT_BLACKLIST" | grep -q "$fingerprint"; then + if [ -z "$fingerprint" ]; then + leaked_keys_skippedcheck=true + elif echo "$FINGERPRINT_BLACKLIST" | grep -q "$fingerprint"; then leaked_keys_found=true if [ "$current_dir" == "$(dirname "$tar_file")" ]; then current_bkup=true @@ -126,7 +129,11 @@ if $leaked_keys_found; then echo fi else - echo "* No leaked keys found" + if $leaked_keys_skippedcheck; then + echo "* No result - check not performed since host key fingerprint was empty" + else + echo "* No leaked keys found" + fi fi # Cleanup temp dir From ea49354ad6c580228ee185951b730e2ce53f5dec Mon Sep 17 00:00:00 2001 From: "github-service-catalog[bot]" <66641770+github-service-catalog[bot]@users.noreply.github.com> Date: Wed, 14 Jul 2021 19:18:19 +0000 Subject: [PATCH 1367/2421] Update service ownership data Co-authored-by: jianghao0718 <45571951+jianghao0718@users.noreply.github.com> --- ownership.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 ownership.yaml diff --git a/ownership.yaml b/ownership.yaml new file mode 100644 index 000000000..3d5fa96cf --- /dev/null +++ b/ownership.yaml @@ -0,0 +1,11 @@ +--- +version: 1 +ownership: +- name: backup-utils + long_name: backup-utils + description: backup-utils is backup and restore tooling for Github enterprise server + (GHES) + kind: logical + repo: https://github.com/github/backup-utils + qos: critical + component_of: ghes-infra From 781ad21d6481e6b01b2ef1a3b6173cb404ef5968 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Wed, 14 Jul 2021 15:20:35 -0400 Subject: [PATCH 1368/2421] Update ownership.yaml --- ownership.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ownership.yaml b/ownership.yaml index 3d5fa96cf..6970dbedb 100644 --- a/ownership.yaml +++ b/ownership.yaml @@ -5,7 +5,7 @@ ownership: long_name: backup-utils description: backup-utils is backup and restore tooling for Github enterprise server (GHES) - kind: logical + kind: code repo: https://github.com/github/backup-utils qos: critical component_of: ghes-infra From 0da5e3fb272cd2c84146a0fc7332e844dc81633d Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Wed, 14 Jul 2021 15:22:23 -0400 Subject: [PATCH 1369/2421] Update ownership.yaml --- ownership.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ownership.yaml b/ownership.yaml index 6970dbedb..3d7ca2039 100644 --- a/ownership.yaml +++ b/ownership.yaml @@ -1,6 +1,13 @@ --- version: 1 ownership: +- name: backup-utils-private + long_name: backup-utils-private + description: backup-utils-private is the private fork of backup-utils + kind: code + repo: https://github.com/github/backup-utils-private + qos: critical + component_of: ghes-infra - name: backup-utils long_name: backup-utils description: backup-utils is backup and restore tooling for Github enterprise server From c0663150c2644b78594c143696345e2b71912045 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Wed, 4 Aug 2021 15:52:08 -0400 Subject: [PATCH 1370/2421] Create stale-support-escalation.yml --- .../workflows/stale-support-escalation.yml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/stale-support-escalation.yml diff --git a/.github/workflows/stale-support-escalation.yml b/.github/workflows/stale-support-escalation.yml new file mode 100644 index 000000000..63df54628 --- /dev/null +++ b/.github/workflows/stale-support-escalation.yml @@ -0,0 +1,24 @@ + +name: 'Close stale support escalation issues' +on: + push: + branches: + - master + schedule: + - cron: '30 1 * * *' # Run each day at 1:30 UTC + +jobs: + stale: + if: github.repository == 'github/ghes' || github.repository == 'github/enterprise2' || github.repository == 'github/backup-utils-private' + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v4 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This support escalation issue is stale because it has been open 30 days with no activity. To make it never stale, add a label never-stale.' + close-issue-message: 'This support escalation issue is closed because it has been open 60 days with no activity. To make it never stale, add a label never-stale.' + days-before-stale: 30 + days-before-close: 60 + only-labels: 'support-escalation' + stale-issue-label: 'stale' + exempt-issue-labels: 'never-stale,P1,P2,P3' From 8fb420449e8f23256cd94391329b80b12a944930 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Wed, 4 Aug 2021 15:55:55 -0400 Subject: [PATCH 1371/2421] Add permissions for write issues --- .github/workflows/stale-support-escalation.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/stale-support-escalation.yml b/.github/workflows/stale-support-escalation.yml index 63df54628..d83dc56b8 100644 --- a/.github/workflows/stale-support-escalation.yml +++ b/.github/workflows/stale-support-escalation.yml @@ -7,6 +7,9 @@ on: schedule: - cron: '30 1 * * *' # Run each day at 1:30 UTC +permissions: + issues: write + jobs: stale: if: github.repository == 'github/ghes' || github.repository == 'github/enterprise2' || github.repository == 'github/backup-utils-private' From a789466d55c1ca44bf6e4853f7fd408f5c9903dc Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Mon, 16 Aug 2021 15:50:56 -0400 Subject: [PATCH 1372/2421] Update stale-support-escalation.yml --- .github/workflows/stale-support-escalation.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale-support-escalation.yml b/.github/workflows/stale-support-escalation.yml index d83dc56b8..2bb01ab53 100644 --- a/.github/workflows/stale-support-escalation.yml +++ b/.github/workflows/stale-support-escalation.yml @@ -19,9 +19,9 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This support escalation issue is stale because it has been open 30 days with no activity. To make it never stale, add a label never-stale.' - close-issue-message: 'This support escalation issue is closed because it has been open 60 days with no activity. To make it never stale, add a label never-stale.' + close-issue-message: 'This support escalation issue is closed because it has been open 45 days with no activity. To make it never stale, add a label never-stale.' days-before-stale: 30 - days-before-close: 60 + days-before-close: 45 only-labels: 'support-escalation' stale-issue-label: 'stale' exempt-issue-labels: 'never-stale,P1,P2,P3' From d6d8fd1239d7c6ea843487b7147b39958b558c4f Mon Sep 17 00:00:00 2001 From: Zachary Mark Date: Tue, 17 Aug 2021 09:56:56 -0500 Subject: [PATCH 1373/2421] Add example of how to sync two git repositories --- RELEASING.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/RELEASING.md b/RELEASING.md index 0bcb66557..345a6311e 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -15,11 +15,24 @@ Only repo administrator is allowed to run the release script, otherwise it will Prior to making a release, 1. Sync any changes that have been merged to backup-utils-private into this repository. -1. Go through the list of open pull requests and merge any that are ready for merging. -1. Go through the list of closed pull requests since the last release and ensure those that should be included in the release notes: - - have a "bug", "enhancement" or "feature" label, - - have a title that clearly describes the changes in that pull request. Reword if necessary. -1. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the release notes. + + One possible way to accomplish this is to add the other repository as a remote and merge the changes from the default branch of that remote. + ``` + git clone git@github.com:github/backup-utils + cd backup-utils + git checkout master + git checkout -b sync-private-to-public + git remote add private + git fetch private + git merge private/master + git push origin HEAD + ``` + Then open a pull request on this repository with the changes. +2. Go through the list of open pull requests and merge any that are ready for merging. +3. Go through the list of closed pull requests since the last release and ensure those that should be included in the release notes: + - have a "bug", "enhancement" or "feature" label, + - have a title that clearly describes the changes in that pull request. Reword if necessary. +4. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the release notes. ## Automatic Process from chatops (internal to GitHub only) From c6b84bf37179736c742c9e010c10f93ecf6ddc78 Mon Sep 17 00:00:00 2001 From: mokrz <5460522+mokrz@users.noreply.github.com> Date: Tue, 17 Aug 2021 16:47:07 -0700 Subject: [PATCH 1374/2421] Always restore user-password-secrets --- share/github-backup-utils/ghe-restore-mysql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 066d23a34..6885e98ab 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -29,6 +29,9 @@ export GHE_RESTORE_SNAPSHOT # The directory holding the snapshot to restore GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" +# Always restore the password pepper here since it is tied to the MySQL data. +restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" + if is_external_database_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT @@ -63,8 +66,6 @@ if is_external_database_snapshot; then fi if is_binary_backup_feature_on; then - # Always restore the password pepper here since it is tied to the MySQL data. - restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" # Feature "mysql.backup.binary" is on, which means new backup scripts are available if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then ghe-restore-mysql-binary $GHE_HOSTNAME @@ -77,8 +78,6 @@ else echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 else - # Always restore the password pepper here since it is tied to the MySQL data. - restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" if is_default_external_database_snapshot; then ghe-restore-mysql-logical $GHE_HOSTNAME else From e9eff7596c2b237987268c111cfa94c701bae63c Mon Sep 17 00:00:00 2001 From: boxofyellow Date: Tue, 24 Aug 2021 14:58:10 -0400 Subject: [PATCH 1375/2421] Make some of the actions setting best effort --- share/github-backup-utils/ghe-backup-settings | 59 +++++++++++++++---- test/test-ghe-backup.sh | 34 +++++++---- 2 files changed, 71 insertions(+), 22 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index a44edf925..e28725113 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -26,16 +26,51 @@ echo "* Transferring license data ..." 1>&3 ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl # Function to backup a secret setting to a file. -# backup-secret +# backup-secret backup-secret() { - echo "* Transferring $1 ..." 1>&3 - ghe-ssh "$host" -- ghe-config "$3" > "$2+" || ( - echo "Warning: $1 not set" >&2 + + best_effort=false + label="" + file="" + setting="" + count=0 + + while [ $# -gt 0 ]; do + case "$1" in + --best-effort) + shift 1 + best_effort=true + ;; + *) + case $count in + 0) + label=$1 + ;; + 1) + file=$1 + ;; + 2) + setting=$1 + ;; + *) + >&2 echo "To many arguments" + ;; + esac + count=$((count+1)) + shift 1 + esac + done + + echo "* Transferring $label ..." 1>&3 + ghe-ssh "$host" -- ghe-config "$setting" > "$file+" || ( + if [ "$best_effort" = "false" ]; then + echo "Warning: $label not set" >&2 + fi ) - if [ -n "$(cat "$2+")" ]; then - mv "$2+" "$2" + if [ -n "$(cat "$file+")" ]; then + mv "$file+" "$file" else - unlink "$2+" + unlink "$file+" fi } @@ -51,19 +86,19 @@ fi if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then backup-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" backup-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" - backup-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" + backup-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" --best-effort backup-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" backup-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" backup-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" backup-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" backup-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" backup-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" - backup-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" - backup-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" - backup-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" + backup-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" --best-effort + backup-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" --best-effort + backup-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" --best-effort backup-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" backup-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" - backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" + backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" --best-effort backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" backup-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index dec117378..ba94ab208 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -449,19 +449,14 @@ begin_test "ghe-backup takes backup of Actions settings" required_secrets=( "secrets.actions.ConfigurationDatabaseSqlLogin" "secrets.actions.ConfigurationDatabaseSqlPassword" - "secrets.actions.FrameworkAccessTokenKeySecret" "secrets.actions.UrlSigningHmacKeyPrimary" "secrets.actions.UrlSigningHmacKeySecondary" "secrets.actions.OAuthS2SSigningCert" "secrets.actions.OAuthS2SSigningKey" "secrets.actions.OAuthS2SSigningCertThumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" - "secrets.actions.AADCertThumbprint" - "secrets.actions.DelegatedAuthCertThumbprint" - "secrets.actions.RuntimeServicePrincipalCertificate" "secrets.actions.S2SEncryptionCertificate" "secrets.actions.SecondaryEncryptionCertificateThumbprint" - "secrets.actions.ServicePrincipalCertificate" "secrets.actions.SpsValidationCertThumbprint" "secrets.launch.actions-secrets-private-key" @@ -481,6 +476,15 @@ begin_test "ghe-backup takes backup of Actions settings" "secrets.launch.azp-app-private-key" ) + # these 5 were removed in later versions, so we extract them as best effort + # - secrets.actions.FrameworkAccessTokenKeySecret + # - secrets.actions.AADCertThumbprint + # - secrets.actions.DelegatedAuthCertThumbprint + # - secrets.actions.RuntimeServicePrincipalCertificate + # - secrets.actions.ServicePrincipalCertificate + # add one, to make sure it still gets copied + required_secrets+=("secrets.actions.FrameworkAccessTokenKeySecret") + for secret in "${required_secrets[@]}"; do ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" done @@ -490,19 +494,14 @@ begin_test "ghe-backup takes backup of Actions settings" required_files=( "actions-config-db-login" "actions-config-db-password" - "actions-framework-access-token" "actions-url-signing-hmac-key-primary" "actions-url-signing-hmac-key-secondary" "actions-oauth-s2s-signing-cert" "actions-oauth-s2s-signing-key" "actions-oauth-s2s-signing-cert-thumbprint" "actions-primary-encryption-cert-thumbprint" - "actions-aad-cert-thumbprint" - "actions-delegated-auth-cert-thumbprint" - "actions-runtime-service-principal-cert" "actions-s2s-encryption-cert" "actions-secondary-encryption-cert-thumbprint" - "actions-service-principal-cert" "actions-sps-validation-cert-thumbprint" "actions-launch-secrets-private-key" @@ -520,9 +519,24 @@ begin_test "ghe-backup takes backup of Actions settings" "actions-launch-app-app-private-key" ) + # Add the one options file we included tests for + required_files+=("actions-framework-access-token") + for file in "${required_files[@]}"; do [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] done + + other_best_effort_files=( + "actions-aad-cert-thumbprint" + "actions-delegated-auth-cert-thumbprint" + "actions-runtime-service-principal-cert" + "actions-service-principal-cert" + ) + + for file in "${other_best_effort_files[@]}"; do + [ ! -f "$GHE_DATA_DIR/current/$file" ] + done + ) end_test From a330c7579d1441d486f70e2bc5f534580acf091a Mon Sep 17 00:00:00 2001 From: boxofyellow Date: Wed, 25 Aug 2021 07:34:31 -0400 Subject: [PATCH 1376/2421] PR Feedback --- share/github-backup-utils/ghe-backup-settings | 12 ++++++------ test/test-ghe-backup.sh | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index e28725113..d4ef7d019 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -26,11 +26,11 @@ echo "* Transferring license data ..." 1>&3 ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl # Function to backup a secret setting to a file. -# backup-secret +# backup-secret [--best-effort] backup-secret() { best_effort=false - label="" + description="" file="" setting="" count=0 @@ -44,7 +44,7 @@ backup-secret() { *) case $count in 0) - label=$1 + description=$1 ;; 1) file=$1 @@ -53,7 +53,7 @@ backup-secret() { setting=$1 ;; *) - >&2 echo "To many arguments" + >&2 echo "Too many arguments" ;; esac count=$((count+1)) @@ -61,10 +61,10 @@ backup-secret() { esac done - echo "* Transferring $label ..." 1>&3 + echo "* Transferring $description ..." 1>&3 ghe-ssh "$host" -- ghe-config "$setting" > "$file+" || ( if [ "$best_effort" = "false" ]; then - echo "Warning: $label not set" >&2 + echo "Warning: $description not set" >&2 fi ) if [ -n "$(cat "$file+")" ]; then diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index ba94ab208..41be3be5f 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -519,7 +519,7 @@ begin_test "ghe-backup takes backup of Actions settings" "actions-launch-app-app-private-key" ) - # Add the one options file we included tests for + # Add the one optional file we included tests for required_files+=("actions-framework-access-token") for file in "${required_files[@]}"; do From eceda51150aa670e7d8d0e4d082ad2b567f31b8d Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 10:34:32 -0700 Subject: [PATCH 1377/2421] Attempt to manually cleanup cluster nodes. ghe-cluster-cleanup-node is being removed in later versions of GHES, so we should remove its reference in backup-utils as well. This will run the same set of commands that the script did. --- bin/ghe-restore | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 645d93324..c8186bef0 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -451,7 +451,19 @@ if ! $CLUSTER && $instance_configured; then if [ -n "$other_nodes" ]; then echo "Cleaning up stale nodes ..." for uuid in $other_nodes; do - ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-cluster-cleanup-node $uuid" 1>&3 + 1>&3 ghe-ssh "$GHE_HOSTNAME" <<-EOF + if [ -z "$uuid" ]; then + echo "Node UUID required." + exit 2 + fi + ghe-spokes server evacuate git-server-$uuid 'Removing replica' + ghe-spokes server destroy git-server-$uuid + ghe-storage destroy-host storage-server-$uuid --force + ghe-dpages offline pages-server-$uuid + ghe-dpages remove pages-server-$uuid + ghe-redis-cli del resque:queue:maint_git-server-$uuid + ghe-redis-cli srem resque:queues maint_git-server-$uuid + EOF done fi fi From 34319a1fa61f3f96ca73a180ab80b48d80015ee3 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 11:32:36 -0700 Subject: [PATCH 1378/2421] Use << Here Document redirection instead of <<- I originally wanted to use the <<- redirection format here to strip the leading whitespace, but apparently only tab characters are stripped from the beginning of the lines in a here document; not spaces. For simplicity sake (and to avoid mixing indentation in our scripts) I'll just use the regular << redirection syntax to avoid issues. --- bin/ghe-restore | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index c8186bef0..df1c119b5 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -451,19 +451,19 @@ if ! $CLUSTER && $instance_configured; then if [ -n "$other_nodes" ]; then echo "Cleaning up stale nodes ..." for uuid in $other_nodes; do - 1>&3 ghe-ssh "$GHE_HOSTNAME" <<-EOF - if [ -z "$uuid" ]; then - echo "Node UUID required." - exit 2 - fi - ghe-spokes server evacuate git-server-$uuid 'Removing replica' - ghe-spokes server destroy git-server-$uuid - ghe-storage destroy-host storage-server-$uuid --force - ghe-dpages offline pages-server-$uuid - ghe-dpages remove pages-server-$uuid - ghe-redis-cli del resque:queue:maint_git-server-$uuid - ghe-redis-cli srem resque:queues maint_git-server-$uuid - EOF + 1>&3 ghe-ssh "$GHE_HOSTNAME" < Date: Wed, 25 Aug 2021 13:48:52 -0700 Subject: [PATCH 1379/2421] Remove the mock `ghe-cluster-cleanup-node` script. This doesn't replace it with anything, so we might want to look into if we want to preseve this sort of check in the tests in the future. --- test/bin/ghe-cluster-cleanup-node | 1 - 1 file changed, 1 deletion(-) delete mode 120000 test/bin/ghe-cluster-cleanup-node diff --git a/test/bin/ghe-cluster-cleanup-node b/test/bin/ghe-cluster-cleanup-node deleted file mode 120000 index 9a9fbee29..000000000 --- a/test/bin/ghe-cluster-cleanup-node +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-finalize-command \ No newline at end of file From 646e028998f4896916228e3454eda1602b41d68e Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 16:21:25 -0700 Subject: [PATCH 1380/2421] Remove log checks for `ghe-cluster-cleanup-node`. --- test/test-ghe-restore-external-database.sh | 3 --- test/test-ghe-restore.sh | 15 --------------- 2 files changed, 18 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index c33106c2a..77a36f36d 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -62,9 +62,6 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in # verify connect to right host check_restore_output_for "Connect 127.0.0.1:22 OK" - # verify stale servers were cleared - check_restore_output_for "ghe-cluster-cleanup-node OK" - verify_all_restored_data ) end_test diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 92109c0e9..7e4d8b622 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -58,9 +58,6 @@ begin_test "ghe-restore into configured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # verify stale servers were cleared - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" - # Verify all the data we've restored is as expected verify_all_restored_data ) @@ -143,12 +140,6 @@ begin_test "ghe-restore -c into unconfigured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # verify attempt to clear stale servers was not made - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { - echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." - exit 1 - } - # Verify all the data we've restored is as expected verify_all_restored_data ) @@ -177,12 +168,6 @@ begin_test "ghe-restore into unconfigured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" - # verify attempt to clear stale servers was not made - grep -q "ghe-cluster-cleanup-node OK" "$TRASHDIR/restore-out" && { - echo "ghe-cluster-cleanup-node should not run on unconfigured nodes." - exit 1 - } - # Verify all the data we've restored is as expected verify_all_restored_data ) From e091de1c125336d9b62047484173a657b3e132e4 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 16:34:54 -0700 Subject: [PATCH 1381/2421] Removed a few more checks for `ghe-cluster-cleanup-node`. --- test/test-ghe-restore-external-database.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 77a36f36d..2398fbad7 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -155,9 +155,6 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D # verify connect to right host check_restore_output_for "Connect 127.0.0.1:22 OK" - # verify stale servers were cleared - check_restore_output_for "ghe-cluster-cleanup-node OK" - # ghe-restore sets this when --skip-mysql is passed, but that won't propagate back to this shell and it affects what we validate SKIP_MYSQL=true verify_all_restored_data ) @@ -181,9 +178,6 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D # verify connect to right host check_restore_output_for "Connect 127.0.0.1:22 OK" - # verify stale servers were cleared - check_restore_output_for "ghe-cluster-cleanup-node OK" - # ghe-restore sets SKIP_MYSQL=true when --skip-mysql is passed, but that won't propagate back to this shell and it affects what we validate SKIP_MYSQL=true verify_all_restored_data ) From 3182d4c90b2f07e998941be234d0ba1c77fe6437 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 17:10:55 -0700 Subject: [PATCH 1382/2421] Use `typeset -f` to "copy" function definition onto GHES host. `typeset -f` will output the entire function definition of `cleanup_cluster_nodes` (defined in the `ghe-restore` script now), which then gets executed on the GHES appliance; effectively defining the function on the appliance and then invoking it. --- bin/ghe-restore | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index df1c119b5..073e666ea 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -95,6 +95,24 @@ cleanup () { ghe-ssh --clean } +cleanup_cluster_nodes() { + if [ -z "$uuid" ]; then + echo "Node UUID required." + exit 2 + fi + + ghe-spokes server evacuate git-server-$uuid 'Removing replica' + ghe-spokes server destroy git-server-$uuid + + ghe-storage destroy-host storage-server-$uuid --force + + ghe-dpages offline pages-server-$uuid + ghe-dpages remove pages-server-$uuid + + ghe-redis-cli del resque:queue:maint_git-server-$uuid + ghe-redis-cli srem resque:queues maint_git-server-$uuid +} + # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" @@ -451,19 +469,7 @@ if ! $CLUSTER && $instance_configured; then if [ -n "$other_nodes" ]; then echo "Cleaning up stale nodes ..." for uuid in $other_nodes; do - 1>&3 ghe-ssh "$GHE_HOSTNAME" <&3 ghe-ssh "$GHE_HOSTNAME" -- "$(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" done fi fi From 276ec44fe739eb206f6d402a76fad40f77ae53f1 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 17:21:32 -0700 Subject: [PATCH 1383/2421] Re-add the tests, but check for different output. --- test/test-ghe-restore-external-database.sh | 9 +++++++++ test/test-ghe-restore.sh | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 2398fbad7..ea0d04059 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -62,6 +62,9 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in # verify connect to right host check_restore_output_for "Connect 127.0.0.1:22 OK" + # verify stale servers were cleared + check_restore_output_for "Cleaning up stale nodes ..." + verify_all_restored_data ) end_test @@ -155,6 +158,9 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D # verify connect to right host check_restore_output_for "Connect 127.0.0.1:22 OK" + # verify stale servers were cleared + check_restore_output_for "Cleaning up stale nodes ..." + # ghe-restore sets this when --skip-mysql is passed, but that won't propagate back to this shell and it affects what we validate SKIP_MYSQL=true verify_all_restored_data ) @@ -178,6 +184,9 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D # verify connect to right host check_restore_output_for "Connect 127.0.0.1:22 OK" + # verify stale servers were cleared + check_restore_output_for "Cleaning up stale nodes ..." + # ghe-restore sets SKIP_MYSQL=true when --skip-mysql is passed, but that won't propagate back to this shell and it affects what we validate SKIP_MYSQL=true verify_all_restored_data ) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 7e4d8b622..d9ed4a561 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -58,6 +58,9 @@ begin_test "ghe-restore into configured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify stale servers were cleared + grep -q "Cleaning up stale nodes ..." "$TRASHDIR/restore-out" + # Verify all the data we've restored is as expected verify_all_restored_data ) @@ -140,6 +143,12 @@ begin_test "ghe-restore -c into unconfigured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify attempt to clear stale servers was not made + grep -q "Cleaning up stale nodes ..." "$TRASHDIR/restore-out" && { + echo "Unconfigured nodes should not be cleaned up." + exit 1 + } + # Verify all the data we've restored is as expected verify_all_restored_data ) @@ -168,6 +177,12 @@ begin_test "ghe-restore into unconfigured vm" # verify connect to right host grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + # verify attempt to clear stale servers was not made + grep -q "Cleaning up stale nodes ..." "$TRASHDIR/restore-out" && { + echo "Unconfigured nodes should not be cleaned up." + exit 1 + } + # Verify all the data we've restored is as expected verify_all_restored_data ) From e27b2d7caf60c786cd07801bb3758586473bc5a9 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 17:30:02 -0700 Subject: [PATCH 1384/2421] Use complex form for `ghe-ssh`, as specified in its help doc. --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 073e666ea..e2f16d067 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -469,7 +469,7 @@ if ! $CLUSTER && $instance_configured; then if [ -n "$other_nodes" ]; then echo "Cleaning up stale nodes ..." for uuid in $other_nodes; do - 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "$(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" + echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 done fi fi From d7ad8e1732fb5f34a8931e9cda5c2a443de5c57c Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 17:39:46 -0700 Subject: [PATCH 1385/2421] Ignore shellcheck rule; this function just isn't used locally. --- bin/ghe-restore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index e2f16d067..8bf47a11e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -95,6 +95,8 @@ cleanup () { ghe-ssh --clean } +# This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. +# shellcheck disable=SC2034 cleanup_cluster_nodes() { if [ -z "$uuid" ]; then echo "Node UUID required." From 38706c145419f84219a5a0e0cb7646c5fe5d556c Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 17:50:56 -0700 Subject: [PATCH 1386/2421] Ignore unused function shellcheck. --- bin/ghe-restore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 8bf47a11e..737ac9d4e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -471,6 +471,7 @@ if ! $CLUSTER && $instance_configured; then if [ -n "$other_nodes" ]; then echo "Cleaning up stale nodes ..." for uuid in $other_nodes; do + # shellcheck disable=SC2034 echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 done fi From ca539d5cdf9a9f46da3e2c9f6e70e514e49e6c05 Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 18:00:51 -0700 Subject: [PATCH 1387/2421] Symlink a few files to `ghe-fake-true`. --- test/bin/ghe-dpages | 1 + test/bin/ghe-storage | 1 + 2 files changed, 2 insertions(+) create mode 120000 test/bin/ghe-dpages create mode 120000 test/bin/ghe-storage diff --git a/test/bin/ghe-dpages b/test/bin/ghe-dpages new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/ghe-dpages @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file diff --git a/test/bin/ghe-storage b/test/bin/ghe-storage new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/ghe-storage @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From d24b060a12b48c4a27b33e57d24f24c8e080e58d Mon Sep 17 00:00:00 2001 From: Cameron Smith Date: Wed, 25 Aug 2021 18:03:50 -0700 Subject: [PATCH 1388/2421] Define variable name. --- bin/ghe-restore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 737ac9d4e..4fc761f01 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -98,6 +98,7 @@ cleanup () { # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. # shellcheck disable=SC2034 cleanup_cluster_nodes() { + uuid="$1" if [ -z "$uuid" ]; then echo "Node UUID required." exit 2 From d7802b90b39d7b291a1a2c04003be62483c5c7c5 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Wed, 1 Sep 2021 16:44:04 -0700 Subject: [PATCH 1389/2421] Stop/Restart Actions in ghe-restore --- bin/ghe-restore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 4fc761f01..6d0dedddf 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -91,6 +91,11 @@ cleanup () { update_restore_status "$1" fi + if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + echo "Restarting Actions after restore ..." + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start' 1>&3 + fi + # Cleanup SSH multiplexing ghe-ssh --clean } @@ -348,6 +353,9 @@ else fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + echo "Stopping Actions before restoring databases ..." + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 + echo "Restoring MSSQL databases ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 From caef3fa7ea8108f83b0ce45388a33b681080090d Mon Sep 17 00:00:00 2001 From: ritchxu Date: Wed, 1 Sep 2021 16:54:19 -0700 Subject: [PATCH 1390/2421] Add extra emulated scripts --- test/bin/ghe-actions-start | 1 + test/bin/ghe-actions-stop | 1 + 2 files changed, 2 insertions(+) create mode 100755 test/bin/ghe-actions-start create mode 100755 test/bin/ghe-actions-stop diff --git a/test/bin/ghe-actions-start b/test/bin/ghe-actions-start new file mode 100755 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/ghe-actions-start @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file diff --git a/test/bin/ghe-actions-stop b/test/bin/ghe-actions-stop new file mode 100755 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/ghe-actions-stop @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From 21c1f0905c8c32530ab467b54cca805ea735337c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 3 Sep 2021 17:03:05 +0000 Subject: [PATCH 1391/2421] Clear GitHub Connect settings when not restoring settings --- bin/ghe-restore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 4fc761f01..c2ac7b281 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -345,6 +345,10 @@ if is_external_database_target_or_snapshot && $SKIP_MYSQL; then else echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 + # Clear GitHub Connect settings stored in the restored database + if ! $RESTORE_SETTINGS; then + ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-reset-gh-connect -y" + fi fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then From 9e8ef4ab4258edb0872a472c05da39155cb167f2 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 3 Sep 2021 17:18:23 +0000 Subject: [PATCH 1392/2421] Add test stub --- test/bin/ghe-reset-gh-connect | 1 + 1 file changed, 1 insertion(+) create mode 120000 test/bin/ghe-reset-gh-connect diff --git a/test/bin/ghe-reset-gh-connect b/test/bin/ghe-reset-gh-connect new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/ghe-reset-gh-connect @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From 5a89796931882188d504941e784b199c1bc5a965 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Fri, 3 Sep 2021 11:19:30 -0700 Subject: [PATCH 1393/2421] Add test --- test/bin/ghe-actions-start | 2 +- test/bin/ghe-actions-stop | 2 +- test/test-ghe-restore.sh | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) mode change 100755 => 120000 test/bin/ghe-actions-start mode change 100755 => 120000 test/bin/ghe-actions-stop diff --git a/test/bin/ghe-actions-start b/test/bin/ghe-actions-start deleted file mode 100755 index a5ed742f4..000000000 --- a/test/bin/ghe-actions-start +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-true \ No newline at end of file diff --git a/test/bin/ghe-actions-start b/test/bin/ghe-actions-start new file mode 120000 index 000000000..db4e1a71b --- /dev/null +++ b/test/bin/ghe-actions-start @@ -0,0 +1 @@ +ghe-fake-import \ No newline at end of file diff --git a/test/bin/ghe-actions-stop b/test/bin/ghe-actions-stop deleted file mode 100755 index a5ed742f4..000000000 --- a/test/bin/ghe-actions-stop +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-true \ No newline at end of file diff --git a/test/bin/ghe-actions-stop b/test/bin/ghe-actions-stop new file mode 120000 index 000000000..db4e1a71b --- /dev/null +++ b/test/bin/ghe-actions-stop @@ -0,0 +1 @@ +ghe-fake-import \ No newline at end of file diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index d9ed4a561..083908f2d 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -396,6 +396,30 @@ begin_test "ghe-restore with Actions settings" ) end_test +begin_test "ghe-restore stops and starts Actions" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + setup_maintenance_mode "configured" + + output=$(ghe-restore -v -f localhost 2>&1) + + echo "$output" | grep -q "ghe-actions-stop .* OK" "$TRASHDIR/restore-out" + + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "ghe-actions-stop .* OK" "$TRASHDIR/restore-out" + grep -q "ghe-actions-start .* OK" "$TRASHDIR/restore-out" +) + begin_test "ghe-restore with Actions data" ( set -e From cdbabb06073f0847330d2191b6072489561eaba6 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Fri, 3 Sep 2021 11:36:28 -0700 Subject: [PATCH 1394/2421] Re-add ghe-actions-start/stop --- test/bin/ghe-actions-start | 2 +- test/bin/ghe-actions-stop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bin/ghe-actions-start b/test/bin/ghe-actions-start index db4e1a71b..bc329368a 120000 --- a/test/bin/ghe-actions-start +++ b/test/bin/ghe-actions-start @@ -1 +1 @@ -ghe-fake-import \ No newline at end of file +ghe-fake-import-command \ No newline at end of file diff --git a/test/bin/ghe-actions-stop b/test/bin/ghe-actions-stop index db4e1a71b..bc329368a 120000 --- a/test/bin/ghe-actions-stop +++ b/test/bin/ghe-actions-stop @@ -1 +1 @@ -ghe-fake-import \ No newline at end of file +ghe-fake-import-command \ No newline at end of file From 9e07152a0ef05f0d7cf1728394220d6c04825cdd Mon Sep 17 00:00:00 2001 From: ritchxu Date: Fri, 3 Sep 2021 11:47:20 -0700 Subject: [PATCH 1395/2421] Fix test --- test/test-ghe-restore.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 083908f2d..698879788 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -405,10 +405,6 @@ begin_test "ghe-restore stops and starts Actions" setup_maintenance_mode "configured" - output=$(ghe-restore -v -f localhost 2>&1) - - echo "$output" | grep -q "ghe-actions-stop .* OK" "$TRASHDIR/restore-out" - # run ghe-restore and write output to file for asserting against if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then cat "$TRASHDIR/restore-out" From c7f3854850df949ecf8befd343fe80b063cdfa23 Mon Sep 17 00:00:00 2001 From: ritchxu Date: Fri, 3 Sep 2021 13:25:43 -0700 Subject: [PATCH 1396/2421] Fix test --- test/test-ghe-restore.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 698879788..27377111f 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -405,15 +405,10 @@ begin_test "ghe-restore stops and starts Actions" setup_maintenance_mode "configured" - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi + output=$(ghe-restore -v -f localhost 2>&1) - grep -q "ghe-actions-stop .* OK" "$TRASHDIR/restore-out" - grep -q "ghe-actions-start .* OK" "$TRASHDIR/restore-out" + echo "$output" | grep -q "ghe-actions-stop .* OK" + echo "$output" | grep -q "ghe-actions-start .* OK" ) begin_test "ghe-restore with Actions data" From 4d6ddb4089e7695e1f94d6c420dfee14f2950cfc Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 8 Sep 2021 08:36:02 +0000 Subject: [PATCH 1397/2421] Only attempt to cleanup Connect if script exists on instance --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index c2ac7b281..b626ab505 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -347,7 +347,7 @@ else ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 # Clear GitHub Connect settings stored in the restored database if ! $RESTORE_SETTINGS; then - ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-reset-gh-connect -y" + ghe-ssh "$GHE_HOSTNAME" -- "[ -x '/usr/local/share/enterprise/ghe-reset-gh-connect' ] && /usr/local/share/enterprise/ghe-reset-gh-connect -y" fi fi From f6c475096486aa1b9d226e389fc8d3e30983d753 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 8 Sep 2021 09:04:21 +0000 Subject: [PATCH 1398/2421] Better handle test env --- bin/ghe-restore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b626ab505..ba4a1b8b6 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -347,7 +347,8 @@ else ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 # Clear GitHub Connect settings stored in the restored database if ! $RESTORE_SETTINGS; then - ghe-ssh "$GHE_HOSTNAME" -- "[ -x '/usr/local/share/enterprise/ghe-reset-gh-connect' ] && /usr/local/share/enterprise/ghe-reset-gh-connect -y" + echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; else ghe-reset-gh-connect -y; fi" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi fi From b0da14862c7fceecbd5a903b3f189c6fed940d75 Mon Sep 17 00:00:00 2001 From: Brett Westover Date: Thu, 9 Sep 2021 16:42:24 +0000 Subject: [PATCH 1399/2421] Bump version: 3.2.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 11 +++++++++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 60520916b..3a02885e3 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="2.22.0" +supported_minimum_version="3.0.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index b91a40b7a..eefb5076e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +github-backup-utils (3.2.0) UNRELEASED; urgency=medium + + * Leaked host key check: Avoid false positives from FIPS mode #748 + * Always restore user-password-secrets #762 + * Make some of the actions setting best effort #767 + * Remove reference to `ghe-cluster-cleanup-nodes` #768 + * Stop/Restart Actions in ghe-restore #769 + * Clear GitHub Connect settings when not restoring settings #770 + + -- Brett Westover Thu, 09 Sep 2021 16:42:24 +0000 + github-backup-utils (3.1.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index fd2a01863..944880fa1 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.1.0 +3.2.0 diff --git a/test/testlib.sh b/test/testlib.sh index 52e6f8f56..d06c3d8c6 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.1.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.2.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 194bb3e8956284d6746a428e0f18a338216dbfa3 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Thu, 9 Sep 2021 14:54:37 -0400 Subject: [PATCH 1400/2421] change amd64.deb to all.deb --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index 09078b210..71dc31e39 100755 --- a/script/release +++ b/script/release @@ -447,7 +447,7 @@ if $PROGRAM_NAME == __FILE__ puts 'Attaching Debian pkg and tarball to release...' base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] - attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_amd64.deb"] + attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_all.deb"] puts 'Publishing release...' publish_release res['id'] From b532cd41475e147015a2ccc22c640fc861d0cf0c Mon Sep 17 00:00:00 2001 From: Brett Westover Date: Thu, 9 Sep 2021 19:21:55 +0000 Subject: [PATCH 1401/2421] Increment test versions for host check --- test/test-ghe-host-check.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index d9d0904b2..df17b9d08 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -59,8 +59,9 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions # hardcode until https://github.com/github/backup-utils/issues/675 is resolved ! GHE_TEST_REMOTE_VERSION=2.20.0 ghe-host-check ! GHE_TEST_REMOTE_VERSION=2.21.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=2.22.0 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=2.22.0 ghe-host-check GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=3.1.0 ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check From 24170d6920c7f9febb926d3c21755dec82be9fc2 Mon Sep 17 00:00:00 2001 From: Brett Westover Date: Thu, 9 Sep 2021 17:07:16 -0700 Subject: [PATCH 1402/2421] Drop 16.04 from OS tests 16.04 went EOL in April of this year, and will no longer be supported in workflows on 2021-09-20 https://github.com/actions/virtual-environments/issues/3287 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5b268aed7..cdbb4f4f0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ jobs: build: strategy: matrix: - os: ['ubuntu-20.04', 'ubuntu-18.04', 'ubuntu-16.04', 'macos-latest'] + os: ['ubuntu-20.04', 'ubuntu-18.04', 'macos-latest'] fail-fast: false runs-on: ${{ matrix.os }} steps: From 490f3fc64c35184a7af7e21966c135234e0e91e4 Mon Sep 17 00:00:00 2001 From: Jose Javier De Leon Date: Fri, 10 Sep 2021 10:02:37 -0700 Subject: [PATCH 1403/2421] remove else in restore_settings --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 3c91c46bd..7d4b13a9e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -352,7 +352,7 @@ else ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 # Clear GitHub Connect settings stored in the restored database if ! $RESTORE_SETTINGS; then - echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; else ghe-reset-gh-connect -y; fi" | + echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi fi From e06f5cf697476d3c2e58171207d28e559dfe7985 Mon Sep 17 00:00:00 2001 From: Brett Westover Date: Fri, 10 Sep 2021 20:10:07 +0000 Subject: [PATCH 1404/2421] Bump version: 3.2.0.rc1 [ci skip] --- debian/changelog | 12 ++++++++++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index eefb5076e..143ec0607 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +github-backup-utils (3.2.0.rc1) UNRELEASED; urgency=medium + + * Leaked host key check: Avoid false positives from FIPS mode #748 + * Always restore user-password-secrets #762 + * Make some of the actions setting best effort #767 + * Remove reference to `ghe-cluster-cleanup-nodes` #768 + * Stop/Restart Actions in ghe-restore #769 + * Clear GitHub Connect settings when not restoring settings #770 + * GitHub Connect Reset Issue #776 + + -- Brett Westover Fri, 10 Sep 2021 20:10:07 +0000 + github-backup-utils (3.2.0) UNRELEASED; urgency=medium * Leaked host key check: Avoid false positives from FIPS mode #748 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 944880fa1..8733761b5 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.2.0 +3.2.0.rc1 diff --git a/test/testlib.sh b/test/testlib.sh index d06c3d8c6..e2c857f9b 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.2.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.2.0.rc1.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From d7ccf7d2cbbaf3368512eb521a8c7a9b5273d790 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Thu, 16 Sep 2021 08:54:19 +0000 Subject: [PATCH 1405/2421] Move GitHub Connect reset to after config-apply --- bin/ghe-restore | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7d4b13a9e..b4a34e746 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -350,11 +350,6 @@ if is_external_database_target_or_snapshot && $SKIP_MYSQL; then else echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 - # Clear GitHub Connect settings stored in the restored database - if ! $RESTORE_SETTINGS; then - echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 - fi fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then @@ -460,6 +455,13 @@ elif $instance_configured; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 fi +# Clear GitHub Connect settings stored in the restored database. +# This needs to happen after `ghe-config-apply` to ensure all migrations have run. +if ! $RESTORE_SETTINGS; then + echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 +fi + # Start cron. Timerd will start automatically as part of the config run. echo "Starting cron ..." if $CLUSTER; then From af16aa81caf5159516951e9836e01a67c16a7ced Mon Sep 17 00:00:00 2001 From: Brett Westover Date: Fri, 17 Sep 2021 00:44:59 +0000 Subject: [PATCH 1406/2421] Bump version: 3.2.0.rc3 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 143ec0607..49ab8693f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (3.2.0.rc3) UNRELEASED; urgency=medium + + * Move GitHub Connect reset to after ghe-config-apply #783 + + -- Brett Westover Fri, 17 Sep 2021 00:44:59 +0000 + github-backup-utils (3.2.0.rc1) UNRELEASED; urgency=medium * Leaked host key check: Avoid false positives from FIPS mode #748 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 8733761b5..3760a13d2 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.2.0.rc1 +3.2.0.rc3 From 94478959c87066f169627ffe334f95718ada793a Mon Sep 17 00:00:00 2001 From: Brett Westover Date: Thu, 16 Sep 2021 18:14:28 -0700 Subject: [PATCH 1407/2421] Update testlib.sh --- test/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index e2c857f9b..78681bbd6 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.2.0.rc1.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.2.0.rc3} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 518b739717e1262f0aad4529b08d56b0eda39a02 Mon Sep 17 00:00:00 2001 From: Brett Westover Date: Tue, 28 Sep 2021 16:50:00 +0000 Subject: [PATCH 1408/2421] Bump version: 3.2.0 [ci skip] --- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 49ab8693f..2b253fea1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.2.0) UNRELEASED; urgency=medium + + + -- Brett Westover Tue, 28 Sep 2021 16:50:00 +0000 + github-backup-utils (3.2.0.rc3) UNRELEASED; urgency=medium * Move GitHub Connect reset to after ghe-config-apply #783 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 3760a13d2..944880fa1 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.2.0.rc3 +3.2.0 From 037101544f1d41e78b7f3e844105b1f389506540 Mon Sep 17 00:00:00 2001 From: Brett Westover Date: Tue, 28 Sep 2021 16:58:43 +0000 Subject: [PATCH 1409/2421] update testlib version --- test/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 78681bbd6..095727a29 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.2.0.rc3} +: ${GHE_TEST_REMOTE_VERSION:=3.2.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From eedb9fd8ead108e13f8bde69729a130dad0b17fa Mon Sep 17 00:00:00 2001 From: Kiyo <11631217+Kiyokazu-g@users.noreply.github.com> Date: Sun, 7 Nov 2021 06:20:53 +0900 Subject: [PATCH 1410/2421] fixed the problem that memory overflows when there are too many files (#1) Fix such an error: ``` Restoring storage data ... /data/user/_ghe_backup/backup-utils/share/github-backup-utils/ghe-restore-storage: xrealloc: cannot allocate 18446744072682251136 bytes ```` --- share/github-backup-utils/ghe-restore-storage | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index a890ca741..3422ad444 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -26,15 +26,6 @@ GHE_HOSTNAME="$1" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} -# Find the objects to restore -storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindepth 4 -maxdepth 4 -type f -exec wc -c {} \;) - -# No need to restore anything, early exit -if [ -z "$storage_paths" ]; then - echo "Warning: Storage backup missing. Skipping ..." - exit 0 -fi - # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" @@ -51,11 +42,22 @@ tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file_opt= opts="$GHE_EXTRA_SSH_OPTS" +storage_paths=$tempdir/storage_paths tmp_list=$tempdir/tmp_list remote_tmp_list=$remote_tempdir/remote_tmp_list routes_list=$tempdir/routes_list remote_routes_list=$remote_tempdir/remote_routes_list +# Find the objects to restore +cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ +find storage -mindepth 4 -maxdepth 4 -type f | xargs -n 1 -P 0 wc -c > $storage_paths + +# No need to restore anything, early exit +if [ -s $storage_paths ]; then + echo "Warning: Storage backup missing. Skipping ..." + exit 0 +fi + if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $tempdir/ssh_config" @@ -82,7 +84,7 @@ trap 'cleanup' EXIT # b63c30f6f885e59282c2aa22cfca846516b5e72621c10a58140fb04d133e2c17 5592492 # ... bm_start "$(basename $0) - Building object list" -echo "$storage_paths" | awk '{print $2 " " $1}' | awk -F/ '{print $NF }' > $tmp_list +cat $storage_paths | awk '{print $2 " " $1}' | awk -F/ '{print $NF }' > $tmp_list bm_end "$(basename $0) - Building object list" # The server returns the list of servers where the objects will be sent: From be5ea64e7027a48cec450d408ac024710e5955de Mon Sep 17 00:00:00 2001 From: Nick Iodice <82975681+nick-iodice@users.noreply.github.com> Date: Tue, 9 Nov 2021 19:08:29 +0000 Subject: [PATCH 1411/2421] Bump version: 3.3.0.rc1 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3a02885e3..ebc3f9341 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.0.0" +supported_minimum_version="3.1.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 2b253fea1..75629cfd7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium + + + -- Nick Iodice Tue, 09 Nov 2021 19:08:29 +0000 + github-backup-utils (3.2.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 944880fa1..5c0fc7a4b 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.2.0 +3.3.0.rc1 diff --git a/test/testlib.sh b/test/testlib.sh index 095727a29..b15f55d12 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.2.0} +: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 0e44f432f36c2a4e95573f663e46134e82a866cb Mon Sep 17 00:00:00 2001 From: Nick Iodice <82975681+nick-iodice@users.noreply.github.com> Date: Tue, 9 Nov 2021 12:20:25 -0700 Subject: [PATCH 1412/2421] Revert "Bump version: 3.3.0.rc1" --- bin/ghe-host-check | 2 +- debian/changelog | 5 ----- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index ebc3f9341..3a02885e3 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.1.0" +supported_minimum_version="3.0.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 75629cfd7..2b253fea1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,3 @@ -github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium - - - -- Nick Iodice Tue, 09 Nov 2021 19:08:29 +0000 - github-backup-utils (3.2.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 5c0fc7a4b..944880fa1 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.3.0.rc1 +3.2.0 diff --git a/test/testlib.sh b/test/testlib.sh index b15f55d12..095727a29 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.2.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 35a34da3e3a48fcd8871e8073b0574d6b440a4cc Mon Sep 17 00:00:00 2001 From: Nick Iodice Date: Tue, 9 Nov 2021 19:26:07 +0000 Subject: [PATCH 1413/2421] Bump version: 3.3.0.rc1 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3a02885e3..ebc3f9341 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.0.0" +supported_minimum_version="3.1.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 2b253fea1..8cc6ab83f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium + + + -- Nick Iodice Tue, 09 Nov 2021 19:26:07 +0000 + github-backup-utils (3.2.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 944880fa1..5c0fc7a4b 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.2.0 +3.3.0.rc1 diff --git a/test/testlib.sh b/test/testlib.sh index 095727a29..b15f55d12 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.2.0} +: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 75f35d072b4e0ecf06f04da16d789793a7c49650 Mon Sep 17 00:00:00 2001 From: Nick Iodice <82975681+nick-iodice@users.noreply.github.com> Date: Tue, 9 Nov 2021 12:26:52 -0700 Subject: [PATCH 1414/2421] Revert "Bump version: 3.3.0.rc1" --- bin/ghe-host-check | 2 +- debian/changelog | 5 ----- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index ebc3f9341..3a02885e3 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.1.0" +supported_minimum_version="3.0.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 8cc6ab83f..2b253fea1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,3 @@ -github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium - - - -- Nick Iodice Tue, 09 Nov 2021 19:26:07 +0000 - github-backup-utils (3.2.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 5c0fc7a4b..944880fa1 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.3.0.rc1 +3.2.0 diff --git a/test/testlib.sh b/test/testlib.sh index b15f55d12..095727a29 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.2.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From ce639ae0b875559709714ae9e832f5d6557bac64 Mon Sep 17 00:00:00 2001 From: Nick Iodice Date: Tue, 9 Nov 2021 19:27:51 +0000 Subject: [PATCH 1415/2421] Bump version: 3.3.0.rc1 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3a02885e3..ebc3f9341 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.0.0" +supported_minimum_version="3.1.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 2b253fea1..a49f1ed30 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium + + + -- Nick Iodice Tue, 09 Nov 2021 19:27:51 +0000 + github-backup-utils (3.2.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 944880fa1..5c0fc7a4b 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.2.0 +3.3.0.rc1 diff --git a/test/testlib.sh b/test/testlib.sh index 095727a29..b15f55d12 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.2.0} +: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 572bb6771e37ecaa44dee820d6ddacb22fec9ee4 Mon Sep 17 00:00:00 2001 From: Nick Iodice <82975681+nick-iodice@users.noreply.github.com> Date: Tue, 9 Nov 2021 12:28:15 -0700 Subject: [PATCH 1416/2421] Revert "Bump version: 3.3.0.rc1" --- bin/ghe-host-check | 2 +- debian/changelog | 5 ----- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index ebc3f9341..3a02885e3 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.1.0" +supported_minimum_version="3.0.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index a49f1ed30..2b253fea1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,3 @@ -github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium - - - -- Nick Iodice Tue, 09 Nov 2021 19:27:51 +0000 - github-backup-utils (3.2.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 5c0fc7a4b..944880fa1 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.3.0.rc1 +3.2.0 diff --git a/test/testlib.sh b/test/testlib.sh index b15f55d12..095727a29 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.2.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 37bea0bf065cb683040468f16b095e350bf9a1ec Mon Sep 17 00:00:00 2001 From: Nick Iodice Date: Tue, 9 Nov 2021 19:31:52 +0000 Subject: [PATCH 1417/2421] Bump version: 3.3.0.rc1 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3a02885e3..ebc3f9341 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.0.0" +supported_minimum_version="3.1.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 2b253fea1..97707c9bf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium + + + -- Nick Iodice Tue, 09 Nov 2021 19:31:52 +0000 + github-backup-utils (3.2.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 944880fa1..5c0fc7a4b 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.2.0 +3.3.0.rc1 diff --git a/test/testlib.sh b/test/testlib.sh index 095727a29..b15f55d12 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.2.0} +: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 84135110702fb0fb6b29aeb51598196033ab298a Mon Sep 17 00:00:00 2001 From: Nick Iodice <82975681+nick-iodice@users.noreply.github.com> Date: Tue, 9 Nov 2021 12:52:16 -0700 Subject: [PATCH 1418/2421] Revert "Bump version: 3.3.0.rc1" --- bin/ghe-host-check | 2 +- debian/changelog | 5 ----- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index ebc3f9341..3a02885e3 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.1.0" +supported_minimum_version="3.0.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 97707c9bf..2b253fea1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,3 @@ -github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium - - - -- Nick Iodice Tue, 09 Nov 2021 19:31:52 +0000 - github-backup-utils (3.2.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 5c0fc7a4b..944880fa1 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.3.0.rc1 +3.2.0 diff --git a/test/testlib.sh b/test/testlib.sh index b15f55d12..095727a29 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.2.0} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From cd6ccf41848b2b226e1c4d793893f24b4512cdf1 Mon Sep 17 00:00:00 2001 From: Nick Iodice <82975681+nick-iodice@users.noreply.github.com> Date: Tue, 9 Nov 2021 19:55:35 +0000 Subject: [PATCH 1419/2421] update test versions --- test/test-ghe-host-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index df17b9d08..f064d312f 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -60,7 +60,7 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions ! GHE_TEST_REMOTE_VERSION=2.20.0 ghe-host-check ! GHE_TEST_REMOTE_VERSION=2.21.0 ghe-host-check ! GHE_TEST_REMOTE_VERSION=2.22.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check GHE_TEST_REMOTE_VERSION=3.1.0 ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check From d4b0cf4f6292eaac5fac289fd2a4232eaa3da956 Mon Sep 17 00:00:00 2001 From: Nick Iodice <82975681+nick-iodice@users.noreply.github.com> Date: Tue, 9 Nov 2021 19:56:08 +0000 Subject: [PATCH 1420/2421] Bump version: 3.3.0.rc1 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3a02885e3..ebc3f9341 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -130,7 +130,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.0.0" +supported_minimum_version="3.1.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 2b253fea1..e58c8dddd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium + + + -- Nick Iodice Tue, 09 Nov 2021 19:56:08 +0000 + github-backup-utils (3.2.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 944880fa1..5c0fc7a4b 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.2.0 +3.3.0.rc1 diff --git a/test/testlib.sh b/test/testlib.sh index 095727a29..b15f55d12 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.2.0} +: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 8112fa8059e0e22834585c835c30fac6cfee15c7 Mon Sep 17 00:00:00 2001 From: Kiyo <11631217+Kiyokazu-g@users.noreply.github.com> Date: Fri, 12 Nov 2021 14:36:51 +0900 Subject: [PATCH 1421/2421] my mistake z option is correct. --- share/github-backup-utils/ghe-restore-storage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 3422ad444..24d057eeb 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -53,7 +53,7 @@ cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ find storage -mindepth 4 -maxdepth 4 -type f | xargs -n 1 -P 0 wc -c > $storage_paths # No need to restore anything, early exit -if [ -s $storage_paths ]; then +if [ -z $storage_paths ]; then echo "Warning: Storage backup missing. Skipping ..." exit 0 fi From 7964cdee053c3e138b506222be74c92a35ebc801 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 16 Nov 2021 17:05:05 -0700 Subject: [PATCH 1422/2421] Always default port to 122 --- bin/ghe-host-check | 31 +-------------------- share/github-backup-utils/ghe-backup-config | 7 ++++- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index ebc3f9341..3e9664a30 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -52,37 +52,8 @@ options=" port=$(ssh_port_part "$host") hostname=$(ssh_host_part "$host") -set +e +# ghe-negotiate-version verifies if the target is a Github Enterprise Server instance output=$(echo "ghe-negotiate-version backup-utils $BACKUP_UTILS_VERSION" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1) -rc=$? -set -e - -if [ $rc -ne 0 ]; then - case $rc in - 255) - if echo "$output" | grep -i "port 22: Network is unreachable\|port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then - exec "$(basename $0)" "$hostname:122" - fi - - echo "$output" 1>&2 - echo "Error: ssh connection with '$host' failed" 1>&2 - echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2 - echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2 - ;; - 101) - echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 - ;; - 1) - if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then - exec "$(basename $0)" "$hostname:122" - else - echo "$output" 1>&2 - fi - ;; - - esac - exit $rc -fi CLUSTER=false if ghe-ssh "$host" -- \ diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 67f0fd534..e180f8013 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -334,7 +334,12 @@ ssh_host_part() { # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. ssh_port_part() { - [ "${1##*:}" = "$1" ] && echo 22 || echo "${1##*:}" + if [ "${1##*:}" != "$1" ] && [ "${1##*:}" -ne "122" ]; then + echo "Error: SSH port has to be 122 connecting to Github Enterprise Server, current value is ${1##*:} for $1." 1>&2 + exit 1 + fi + + echo 122 } # Usage: ghe_remote_logger ... From 3b58d8f4900fcc5d366fff87aff4bb2f51e74e38 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 17 Nov 2021 10:49:20 -0700 Subject: [PATCH 1423/2421] Update tests --- test/test-ghe-restore-external-database.sh | 6 +++--- test/test-ghe-restore.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index ea0d04059..0db05a873 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -60,7 +60,7 @@ begin_test "ghe-restore allows restore of external DB snapshot to external DB in fi # verify connect to right host - check_restore_output_for "Connect 127.0.0.1:22 OK" + check_restore_output_for "Connect 127.0.0.1:122 OK" # verify stale servers were cleared check_restore_output_for "Cleaning up stale nodes ..." @@ -156,7 +156,7 @@ begin_test "ghe-restore allows restore of external DB snapshot to non-external D check_restore_output_for "Skipping MySQL restore." # verify connect to right host - check_restore_output_for "Connect 127.0.0.1:22 OK" + check_restore_output_for "Connect 127.0.0.1:122 OK" # verify stale servers were cleared check_restore_output_for "Cleaning up stale nodes ..." @@ -182,7 +182,7 @@ begin_test "ghe-restore allows restore of non external DB snapshot to external D check_restore_output_for "Skipping MySQL restore." # verify connect to right host - check_restore_output_for "Connect 127.0.0.1:22 OK" + check_restore_output_for "Connect 127.0.0.1:122 OK" # verify stale servers were cleared check_restore_output_for "Cleaning up stale nodes ..." diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 27377111f..15cf13046 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -56,7 +56,7 @@ begin_test "ghe-restore into configured vm" cat "$TRASHDIR/restore-out" # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + grep -q "Connect 127.0.0.1:122 OK" "$TRASHDIR/restore-out" # verify stale servers were cleared grep -q "Cleaning up stale nodes ..." "$TRASHDIR/restore-out" @@ -141,7 +141,7 @@ begin_test "ghe-restore -c into unconfigured vm" fi # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + grep -q "Connect 127.0.0.1:122 OK" "$TRASHDIR/restore-out" # verify attempt to clear stale servers was not made grep -q "Cleaning up stale nodes ..." "$TRASHDIR/restore-out" && { @@ -175,7 +175,7 @@ begin_test "ghe-restore into unconfigured vm" ! grep -q "ghe-config-apply OK" "$TRASHDIR/restore-out" # verify connect to right host - grep -q "Connect 127.0.0.1:22 OK" "$TRASHDIR/restore-out" + grep -q "Connect 127.0.0.1:122 OK" "$TRASHDIR/restore-out" # verify attempt to clear stale servers was not made grep -q "Cleaning up stale nodes ..." "$TRASHDIR/restore-out" && { From e480e391d9637e1f43fc25b2dae575e5b2094171 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 17 Nov 2021 11:25:44 -0700 Subject: [PATCH 1424/2421] Fix test/test-ghe-backup-config.sh --- test/test-ghe-backup-config.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index 16656e798..ac3aee1a3 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -89,10 +89,10 @@ end_test begin_test "ghe-backup-config ssh_port_part" ( set -e - [ "$(ssh_port_part 'github.example.com')" = "22" ] - [ "$(ssh_port_part 'github.example.com:22')" = "22" ] - [ "$(ssh_port_part 'github.example.com:5000')" = "5000" ] - [ "$(ssh_port_part 'git@github.example.com:5000')" = "5000" ] + [ "$(ssh_port_part 'github.example.com')" = "122" ] + [ ! "$(ssh_port_part 'github.example.com:22' 2>/dev/null)" ] + [ ! "$(ssh_port_part 'github.example.com:5000' 2>/dev/null)" ] + [ "$(ssh_port_part 'git@github.example.com:122')" = "122" ] ) end_test From 923390374332db03cbde1e1fcc254020e2536219 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 17 Nov 2021 11:36:38 -0700 Subject: [PATCH 1425/2421] another test fix --- test/test-ghe-restore.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 15cf13046..6a202f1d3 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -215,7 +215,7 @@ begin_test "ghe-restore with host arg and config value" rm "$GHE_BACKUP_CONFIG_TEMP" # verify host arg overrides configured restore host - echo "$output" | grep -q 'Connect localhost:22 OK' + echo "$output" | grep -q 'Connect localhost:122 OK' # Verify all the data we've restored is as expected verify_all_restored_data @@ -239,7 +239,7 @@ begin_test "ghe-restore with host arg" output="$(ghe-restore -f localhost)" || false # verify host arg overrides configured restore host - echo "$output" | grep -q 'Connect localhost:22 OK' + echo "$output" | grep -q 'Connect localhost:122 OK' # Verify all the data we've restored is as expected verify_all_restored_data From 7d1db1ac15753d59d38a3161082a177db08344fe Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 17 Nov 2021 13:05:23 -0700 Subject: [PATCH 1426/2421] fix ghe-ssh-config tests --- test/test-ghe-ssh-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-ssh-config.sh b/test/test-ghe-ssh-config.sh index 7b0fc5bb6..499f98b3f 100755 --- a/test/test-ghe-ssh-config.sh +++ b/test/test-ghe-ssh-config.sh @@ -20,7 +20,7 @@ begin_test "ghe-ssh-config returns config for multiple nodes" # Confirm multiplexing enabled echo "$output" | grep -q "ControlMaster=auto" # Confirm ControlPath returns correct hash for admin@host1:122 - echo "$output" | grep -q ".ghe-sshmux-84f6bdcf" + echo "$output" | grep -q ".ghe-sshmux-7cb77002" ) end_test From ea34a13d24c972c0239750f62ecb4518d61e27a0 Mon Sep 17 00:00:00 2001 From: djdefi Date: Mon, 22 Nov 2021 10:21:46 -0800 Subject: [PATCH 1427/2421] Update support and product links. Reflects the deprecation of the Legacy GitHub Enterprise support portal: https://support.github.com/about-support-portal-enterprise --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f97454c2..7d38558c2 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,6 @@ to your specific GitHub Enterprise Server setup or would like assistance with backup site setup or recovery, please contact our [Enterprise support team][3] instead. -[1]: https://enterprise.github.com +[1]: https://github.com/enterprise [2]: docs/requirements.md#github-enterprise-version-requirements -[3]: https://enterprise.github.com/support/ +[3]: https://support.github.com/ From 857a8bb2c7ee0be6b5b11e4efcf5a127a91e66eb Mon Sep 17 00:00:00 2001 From: Ryan Delany Date: Tue, 23 Nov 2021 20:59:24 +0100 Subject: [PATCH 1428/2421] Add -u to date command in ghe-backup-mssql to fix daylight savings bug --- share/github-backup-utils/ghe-backup-mssql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index bb60a7035..c1b8e661d 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -42,7 +42,7 @@ add_minute() { echo "$(date -v +$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S)" else dt=$1 - echo "$(date '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes")" + echo "$(date -u '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes")" fi } From 604843a9bcace3179c6b1ee7d7227a56bd70d9de Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 22 Nov 2021 19:30:24 -0700 Subject: [PATCH 1429/2421] SSH to appliance with no proxy backcompat with non-uuid host Fix some issues Fix a few tests additional test fix --- share/github-backup-utils/ghe-ssh-config | 71 ++++++++++++++++++++---- test/cluster.conf | 65 ++++++++++++++++++++++ test/test-ghe-ssh-config.sh | 70 ++++++++++++++++++++--- 3 files changed, 187 insertions(+), 19 deletions(-) create mode 100644 test/cluster.conf diff --git a/share/github-backup-utils/ghe-ssh-config b/share/github-backup-utils/ghe-ssh-config index 39247682a..5ace041c9 100755 --- a/share/github-backup-utils/ghe-ssh-config +++ b/share/github-backup-utils/ghe-ssh-config @@ -1,7 +1,8 @@ #!/usr/bin/env bash -#/ Usage: ghe-ssh-config [...] +#/ Usage: ghe-ssh-config [...] #/ -#/ Returns a SSH configuration file. +#/ Returns a SSH configuration file which configures the connections either through proxy +#/ using or connect directly by fetching the IP to list of by #/ #/ Note: This script typically isn't called directly. It's invoked by the #/ ghe-[backup|restore]-* commands. @@ -18,20 +19,68 @@ GHE_HOSTNAME="$1" shift hosts="$*" - -proxy_host=$(ssh_host_part "$GHE_HOSTNAME") -proxy_port=$(ssh_port_part "$GHE_HOSTNAME") -proxy_user="${proxy_host%@*}" -[ "$proxy_user" = "$proxy_host" ] && proxy_user="admin" - +ghe_host=$(ssh_host_part "$GHE_HOSTNAME") +ghe_port=$(ssh_port_part "$GHE_HOSTNAME") +ghe_user="${ghe_host%@*}" +[ "$ghe_user" = "$ghe_host" ] && ghe_user="admin" opts="$GHE_EXTRA_SSH_OPTS" +# In case we are connecting to node without -server- format, revert back to proxy mode +[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$ghe_user@$ghe_host:$ghe_port" | git hash-object --stdin | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" -[ -z "$GHE_DISABLE_SSH_MUX" ] && opts="-o ControlMaster=auto -o ControlPath=\"$TMPDIR/.ghe-sshmux-$(echo -n "$proxy_user@$proxy_host:$proxy_port" | git hash-object --stdin | cut -c 1-8)\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" +# Allow GIT_CONFIG to be specified manually for CI. +if [ -z "$GIT_CONFIG" ]; then + # If an individual backup step is being run directly, or this is a restore + # then ghe-backup-settings won't have ran, which transfers cluster.conf. + if ! $GHE_RESTORE_SNAPSHOT_PATH && [ -f "$GHE_SNAPSHOT_DIR/cluster.conf" ]; then + GIT_CONFIG="$GHE_SNAPSHOT_DIR/cluster.conf" + else + cluster_config_file="$(mktemp -t ".ghe-cluster-conf-XXXXXX")" + ghe-ssh "$GHE_HOSTNAME" -- "sudo cat $GHE_REMOTE_CLUSTER_CONF_FILE 2>/dev/null" > "$cluster_config_file" + GIT_CONFIG="$cluster_config_file" + fi +fi +export GIT_CONFIG_NOSYSTEM=1 GIT_CONFIG for host in $hosts; do - cat <-server- host has been specified, and if so + # generate the relevant SSH configuration. + if [[ "$host" =~ [A-Za-z]+-server-[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12} ]]; then + for cluster_host in $(git config --get-regexp cluster.*.hostname | cut -d ' ' -f2); do + uuid=$(git config cluster.$cluster_host.uuid) + if [[ "$host" =~ [A-Za-z]+-server-$uuid ]]; then + if [ -n "$(git config cluster.$cluster_host.ipv6)" ]; then + ip=$(git config "cluster.$cluster_host.ipv6") + elif [ -n "$(git config cluster.$cluster_host.ipv4)" ]; then + ip=$(git config "cluster.$cluster_host.ipv4") + fi + + if [ -z "$temp_ssh_config_file" ]; then + temp_ssh_config_file="$(mktemp -t ".hostfile-XXXXXX")" + echo "Host * +User $ghe_user +Port $ghe_port +BatchMode yes" >> "$temp_ssh_config_file" + fi + + echo "Host git-server-$uuid pages-server-$uuid storage-server-$uuid +HostName $ip +Port $ghe_port +StrictHostKeyChecking no" >> "$temp_ssh_config_file" + # If proxy mode is set + if [ -n "$GHE_SSH_PROXY" ]; then + echo "ProxyCommand ssh -q $opts -p $ghe_port $ghe_user@$ghe_host nc.openbsd %h %p" >> "$temp_ssh_config_file" + fi + fi + done + else + cat < entries + echo "$output" | grep -Eq "^Host git-server-[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}" + echo "$output" | grep -Eq "pages-server-[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}" + echo "$output" | grep -Eq "storage-server-[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}" + [ "$(echo "$output" | grep -Ec "^Host git-server-[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}")" -eq 2 ] + # Confirm the git-server entries has right IP + echo "$output" | grep -q "HostName 172.31.22.90" + echo "$output" | grep -q "HostName 172.31.26.173" + # Confirm No proxy enabled + [ "$(echo "$output" | grep -c "ProxyCommand")" -eq 0 ] +) +end_test + +begin_test "ghe-ssh-config returns config for git-server nodes with GHE_SSH_PROXY=1" +( + set -e + + output=$(GIT_CONFIG=$CLUSTER_CONF GHE_SSH_PROXY=1 ghe-ssh-config host1 git-server-1451687c-4be0-11ec-8684-02c387bd966b git-server-16089d52-4be0-11ec-b892-026c4c5e5bb1) + # Confirm we don't have a host1 entry as this is the proxy host + [ "$(echo "$output" | grep -c "^Host host1")" -eq 0 ] + # Confirm we have git-server- entries + echo "$output" | grep -Eq "^Host git-server-[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}" + echo "$output" | grep -Eq "pages-server-[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}" + echo "$output" | grep -Eq "storage-server-[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}" + [ "$(echo "$output" | grep -Ec "^Host git-server-[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}")" -eq 2 ] + # Confirm the git-server entries has right IP + echo "$output" | grep -q "HostName 172.31.22.90" + echo "$output" | grep -q "HostName 172.31.26.173" + # Confirm proxy enabled + [ "$(echo "$output" | grep -c "ProxyCommand")" -eq 2 ] + + # Confirm ControlPath returns correct hash for admin@host1:122 + echo "$output" | grep -q "admin@host1 nc.openbsd" + # Confirm multiplexing enabled + echo "$output" | grep -q "ControlMaster=auto" + # Confirm ControlPath returns correct hash for admin@host1:122 + echo "$output" | grep -q ".ghe-sshmux-7cb77002" +) +end_test + + +begin_test "ghe-ssh-config returns config for non-server-uuid nodes" ( set -e - output=$(ghe-ssh-config host1 git-server1 git-server2) + output=$(GIT_CONFIG=$CLUSTER_CONF ghe-ssh-config host1 mysql-node1 mysql-node2) # Confirm we don't have a host1 entry as this is the proxy host echo "$output" | grep -Evq "^Host host1" # Confirm we have a host2 and host3 entry - echo "$output" | grep -Eq "^Host git-server[12]" - [ "$(echo "$output" | grep -E "^Host git-server[12]" | wc -l)" -eq 2 ] + echo "$output" | grep -Eq "^Host mysql-node[12]" + [ "$(echo "$output" | grep -c "^Host mysql-node[12]")" -eq 2 ] # Confirm the host2 and host3 entries proxy though host1 echo "$output" | grep -q "admin@host1 nc.openbsd" # Confirm multiplexing enabled @@ -28,11 +78,15 @@ begin_test "ghe-ssh-config multiplexing disabled" ( set -e - output=$(GHE_DISABLE_SSH_MUX=1 ghe-ssh-config host1 git-server1) + output=$(GIT_CONFIG=$CLUSTER_CONF GHE_DISABLE_SSH_MUX=1 ghe-ssh-config host1 git-server1) echo "$output" | grep -vq "ControlMaster=auto" - output=$(GHE_DISABLE_SSH_MUX=1 ghe-ssh-config host1 git-server1 git-server2) + output=$(GIT_CONFIG=$CLUSTER_CONF GHE_DISABLE_SSH_MUX=1 ghe-ssh-config host1 git-server1 git-server2) echo "$output" | grep -vq "ControlMaster=auto" + + # Confirm multiplexing disabled + [ "$(echo "$output" | grep -c "ControlMaster=auto")" -eq 0 ] + [ "$(echo "$output" | grep -c ".ghe-sshmux-7cb77002")" -eq 0 ] ) end_test @@ -40,10 +94,10 @@ begin_test "ghe-ssh-config with extra SSH opts" ( set -e - output=$(GHE_EXTRA_SSH_OPTS="-o foo=bar" ghe-ssh-config host1 git-server1) + output=$(GIT_CONFIG=$CLUSTER_CONF GHE_EXTRA_SSH_OPTS="-o foo=bar" ghe-ssh-config host1 git-server1) echo "$output" | grep -q "foo=bar" - output=$(GHE_EXTRA_SSH_OPTS="-o foo=bar" ghe-ssh-config host1 git-server1 git-server2) + output=$(GIT_CONFIG=$CLUSTER_CONF GHE_EXTRA_SSH_OPTS="-o foo=bar" ghe-ssh-config host1 git-server1 git-server2) echo "$output" | grep -q "foo=bar" ) end_test From 0bab95bce63137141d1d6b21987fc244ace842d3 Mon Sep 17 00:00:00 2001 From: Shruti Corbett <90784253+shcorbett@users.noreply.github.com> Date: Mon, 6 Dec 2021 18:57:19 -0500 Subject: [PATCH 1430/2421] Create stale.yml Adding this check for this repo to clean up old issues if they are no longer relevant by adding 'stale' label. Copied this from another repo that uses this same process. --- .github/workflows/stale.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 000000000..828182457 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,25 @@ + +name: Mark stale issues and pull requests + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + stale: + + runs-on: ubuntu-latest + + steps: + - uses: actions/stale@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: "👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot." + stale-issue-label: "Stale" + exempt-issue-labels: "Keep" + stale-pr-message: "👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot." + stale-pr-label: "Stale" + exempt-pr-labels: "Keep, epic, initiative, GHAE" + days-before-stale: 30 # 1 month, which accounts for "now" and "next", but anything beyond is "never" + days-before-close: 5 + ascending: true From 09e690fcd74bec1e185cfbc8695a61b065f51566 Mon Sep 17 00:00:00 2001 From: Kamil Grzebien Date: Tue, 7 Dec 2021 18:12:54 +0000 Subject: [PATCH 1431/2421] Add details how to enable Actions in new appliance --- bin/ghe-restore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index b4a34e746..0b60e8b05 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -258,6 +258,7 @@ fi if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then if ! ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 + echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@3.3/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi From 44f4cc41de13d7a647281521a21775218d0a6872 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Wed, 8 Dec 2021 01:25:12 +0000 Subject: [PATCH 1432/2421] Bump version: 3.3.0 [ci skip] --- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index e58c8dddd..ef8e4a237 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.3.0) UNRELEASED; urgency=medium + + + -- bonsohi@github.com Wed, 08 Dec 2021 01:25:12 +0000 + github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 5c0fc7a4b..15a279981 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.3.0.rc1 +3.3.0 From e4c494dc2f9edec0b58131e6cedb1428582e93a0 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Wed, 8 Dec 2021 01:56:26 +0000 Subject: [PATCH 1433/2421] Bump version: 3.3.0 [ci skip] --- debian/changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/changelog b/debian/changelog index ef8e4a237..22513b393 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,11 @@ github-backup-utils (3.3.0) UNRELEASED; urgency=medium + -- bonsohi@github.com Wed, 08 Dec 2021 01:56:26 +0000 + +github-backup-utils (3.3.0) UNRELEASED; urgency=medium + + -- bonsohi@github.com Wed, 08 Dec 2021 01:25:12 +0000 github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium From f57ed8a265f2fbb8bc1ce36f34f0d042015ba7c6 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Wed, 8 Dec 2021 02:02:25 +0000 Subject: [PATCH 1434/2421] Bump version: 3.3.0 [ci skip] --- debian/changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/changelog b/debian/changelog index 22513b393..c3d8970f4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,11 @@ github-backup-utils (3.3.0) UNRELEASED; urgency=medium + -- bonsohi@github.com Wed, 08 Dec 2021 02:02:25 +0000 + +github-backup-utils (3.3.0) UNRELEASED; urgency=medium + + -- bonsohi@github.com Wed, 08 Dec 2021 01:56:26 +0000 github-backup-utils (3.3.0) UNRELEASED; urgency=medium From 60c2a75bdc3955d906b4016f9d6f418c4521c508 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Wed, 8 Dec 2021 02:51:06 +0000 Subject: [PATCH 1435/2421] Bump version: 3.3.0 [ci skip] --- debian/changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/changelog b/debian/changelog index c3d8970f4..43660fa9d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,11 @@ github-backup-utils (3.3.0) UNRELEASED; urgency=medium + -- bonsohi@github.com Wed, 08 Dec 2021 02:51:06 +0000 + +github-backup-utils (3.3.0) UNRELEASED; urgency=medium + + -- bonsohi@github.com Wed, 08 Dec 2021 02:02:25 +0000 github-backup-utils (3.3.0) UNRELEASED; urgency=medium From 524215fb06983eaf4e881718c3796afc19563bb1 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Wed, 8 Dec 2021 02:56:47 +0000 Subject: [PATCH 1436/2421] Bump version: 3.3.0 [ci skip] --- debian/changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/changelog b/debian/changelog index 43660fa9d..a52ec83cf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,11 @@ github-backup-utils (3.3.0) UNRELEASED; urgency=medium + -- bonsohi@github.com Wed, 08 Dec 2021 02:56:47 +0000 + +github-backup-utils (3.3.0) UNRELEASED; urgency=medium + + -- bonsohi@github.com Wed, 08 Dec 2021 02:51:06 +0000 github-backup-utils (3.3.0) UNRELEASED; urgency=medium From 1523a9f9fa8788264f7c821f19bf5c32d10d3b11 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Wed, 8 Dec 2021 03:10:21 +0000 Subject: [PATCH 1437/2421] Bump version: 3.3.0 [ci skip] --- debian/changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/changelog b/debian/changelog index a52ec83cf..8c12f93cf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,11 @@ github-backup-utils (3.3.0) UNRELEASED; urgency=medium + -- bonsohi@github.com Wed, 08 Dec 2021 03:10:21 +0000 + +github-backup-utils (3.3.0) UNRELEASED; urgency=medium + + -- bonsohi@github.com Wed, 08 Dec 2021 02:56:47 +0000 github-backup-utils (3.3.0) UNRELEASED; urgency=medium From 2b9ea060f8669ea00f72e600614d7400df7a396c Mon Sep 17 00:00:00 2001 From: bonsohi Date: Wed, 8 Dec 2021 03:12:53 +0000 Subject: [PATCH 1438/2421] Bump version: 3.3.0 [ci skip] --- debian/changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian/changelog b/debian/changelog index 8c12f93cf..6d0f4a17c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,11 @@ github-backup-utils (3.3.0) UNRELEASED; urgency=medium + -- bonsohi@github.com Wed, 08 Dec 2021 03:12:53 +0000 + +github-backup-utils (3.3.0) UNRELEASED; urgency=medium + + -- bonsohi@github.com Wed, 08 Dec 2021 03:10:21 +0000 github-backup-utils (3.3.0) UNRELEASED; urgency=medium From af5ef890295258db93c9bba36f93b4ea8fdaabb9 Mon Sep 17 00:00:00 2001 From: Kiyo <11631217+Kiyokazu-g@users.noreply.github.com> Date: Wed, 8 Dec 2021 14:57:14 +0900 Subject: [PATCH 1439/2421] for shellcheck SC2038 --- share/github-backup-utils/ghe-restore-storage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 24d057eeb..5704164af 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -50,7 +50,7 @@ remote_routes_list=$remote_tempdir/remote_routes_list # Find the objects to restore cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ -find storage -mindepth 4 -maxdepth 4 -type f | xargs -n 1 -P 0 wc -c > $storage_paths +find storage -mindepth 4 -maxdepth 4 -type f | xargs -0 -n 1 -P 0 wc -c > $storage_paths # No need to restore anything, early exit if [ -z $storage_paths ]; then From 96b50d0fe8e4868e855945c9cd2e694080178ca9 Mon Sep 17 00:00:00 2001 From: Kamil Grzebien Date: Wed, 8 Dec 2021 09:54:29 +0000 Subject: [PATCH 1440/2421] Remove version specific from URL link --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 0b60e8b05..a20a9d467 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -258,7 +258,7 @@ fi if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then if ! ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 - echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@3.3/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi From 05525aeb3be9697711a52c20d3cef8523d01aa06 Mon Sep 17 00:00:00 2001 From: Kiyo <11631217+Kiyokazu-g@users.noreply.github.com> Date: Thu, 9 Dec 2021 19:02:05 +0900 Subject: [PATCH 1441/2421] Fix test evaluation --- share/github-backup-utils/ghe-restore-storage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 5704164af..f15b01858 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -53,7 +53,7 @@ cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ find storage -mindepth 4 -maxdepth 4 -type f | xargs -0 -n 1 -P 0 wc -c > $storage_paths # No need to restore anything, early exit -if [ -z $storage_paths ]; then +if [ ! -s $storage_paths ]; then echo "Warning: Storage backup missing. Skipping ..." exit 0 fi From 5ccbb87269f0af7bb471e3a8fe8a713f3100dcfb Mon Sep 17 00:00:00 2001 From: Kiyo <11631217+Kiyokazu-g@users.noreply.github.com> Date: Thu, 9 Dec 2021 21:06:48 +0900 Subject: [PATCH 1442/2421] Needed to write shellcheck more correctly --- share/github-backup-utils/ghe-restore-storage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index f15b01858..2935a8f8c 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -50,7 +50,7 @@ remote_routes_list=$remote_tempdir/remote_routes_list # Find the objects to restore cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ -find storage -mindepth 4 -maxdepth 4 -type f | xargs -0 -n 1 -P 0 wc -c > $storage_paths +find storage -mindepth 4 -maxdepth 4 -type f -print0 | xargs -0 -n 1 -P 0 wc -c > $storage_paths # No need to restore anything, early exit if [ ! -s $storage_paths ]; then From 42375713a0df059b6092dd01633fefc79c00b4f8 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Fri, 10 Dec 2021 17:46:28 -0500 Subject: [PATCH 1443/2421] =?UTF-8?q?Revert=20"fixed=20the=20problem=20tha?= =?UTF-8?q?t=20memory=20overflows=20when=20there=20are=20too=20many=20file?= =?UTF-8?q?s=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- share/github-backup-utils/ghe-restore-storage | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 2935a8f8c..a890ca741 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -26,6 +26,15 @@ GHE_HOSTNAME="$1" # us run this script directly. : ${GHE_RESTORE_SNAPSHOT:=current} +# Find the objects to restore +storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindepth 4 -maxdepth 4 -type f -exec wc -c {} \;) + +# No need to restore anything, early exit +if [ -z "$storage_paths" ]; then + echo "Warning: Storage backup missing. Skipping ..." + exit 0 +fi + # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" @@ -42,22 +51,11 @@ tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-restore-XXXXXX) ssh_config_file_opt= opts="$GHE_EXTRA_SSH_OPTS" -storage_paths=$tempdir/storage_paths tmp_list=$tempdir/tmp_list remote_tmp_list=$remote_tempdir/remote_tmp_list routes_list=$tempdir/routes_list remote_routes_list=$remote_tempdir/remote_routes_list -# Find the objects to restore -cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ -find storage -mindepth 4 -maxdepth 4 -type f -print0 | xargs -0 -n 1 -P 0 wc -c > $storage_paths - -# No need to restore anything, early exit -if [ ! -s $storage_paths ]; then - echo "Warning: Storage backup missing. Skipping ..." - exit 0 -fi - if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $tempdir/ssh_config" @@ -84,7 +82,7 @@ trap 'cleanup' EXIT # b63c30f6f885e59282c2aa22cfca846516b5e72621c10a58140fb04d133e2c17 5592492 # ... bm_start "$(basename $0) - Building object list" -cat $storage_paths | awk '{print $2 " " $1}' | awk -F/ '{print $NF }' > $tmp_list +echo "$storage_paths" | awk '{print $2 " " $1}' | awk -F/ '{print $NF }' > $tmp_list bm_end "$(basename $0) - Building object list" # The server returns the list of servers where the objects will be sent: From fbd4becea62f5ca4deac70b7137982667f5c1c4d Mon Sep 17 00:00:00 2001 From: Kamil Grzebien Date: Mon, 13 Dec 2021 14:35:57 +0100 Subject: [PATCH 1444/2421] Add release specific version to documentation URL --- bin/ghe-restore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index a20a9d467..ace6b0aba 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -257,8 +257,11 @@ fi # Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data. if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then if ! ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + # Get GHES release version in major.minor format + RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2) + echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 - echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi From 02dc2dacc6eda6673484a857c98c2b3f223f49d2 Mon Sep 17 00:00:00 2001 From: Ryan Delany Date: Thu, 16 Dec 2021 18:26:59 -0500 Subject: [PATCH 1445/2421] Fix compat issue with ghe-actions-start during maintenance mode --- bin/ghe-restore | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index ace6b0aba..a66ae31db 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -93,7 +93,14 @@ cleanup () { if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Restarting Actions after restore ..." - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start' 1>&3 + # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the + # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists + # in the --help output + if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start --help' | grep -q force ; then + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start -f' 1>&3 + else + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start' 1>&3 + fi fi # Cleanup SSH multiplexing From cc3dddd09e91b6547cfcb69eac1dc81a70c63f18 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Tue, 21 Dec 2021 23:38:01 +0000 Subject: [PATCH 1446/2421] Bump version: 3.3.1 [ci skip] --- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 6d0f4a17c..ced0ad044 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (3.3.1) UNRELEASED; urgency=medium + + * Fix compat issue with ghe-actions-start during maintenance mode #836 + + -- bonsohi@github.com Tue, 21 Dec 2021 23:38:01 +0000 + github-backup-utils (3.3.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 15a279981..bea438e9a 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.3.0 +3.3.1 From 95be384c822ed90160643c36322a8783b49c7bf1 Mon Sep 17 00:00:00 2001 From: Zach Renner Date: Mon, 27 Dec 2021 11:59:01 -0800 Subject: [PATCH 1447/2421] Unlinking gnu parallel on macOS build no longer necessary --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cdbb4f4f0..d880d33dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -21,7 +21,6 @@ jobs: - name: Install Dependencies (macOS) run: | brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt - brew unlink parallel brew install moreutils gawk if: matrix.os == 'macos-latest' - name: Get Sources From b86df4b232dc3a38e7ab147f24de15748747b9e5 Mon Sep 17 00:00:00 2001 From: Zach Renner Date: Mon, 27 Dec 2021 13:23:15 -0800 Subject: [PATCH 1448/2421] Add systemctl stub --- test/bin/systemctl | 1 + 1 file changed, 1 insertion(+) create mode 120000 test/bin/systemctl diff --git a/test/bin/systemctl b/test/bin/systemctl new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/systemctl @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From 3ee502fb36f378cda6baae2aa5887c6db507ba34 Mon Sep 17 00:00:00 2001 From: Zach Renner Date: Mon, 27 Dec 2021 18:26:51 -0800 Subject: [PATCH 1449/2421] Disable test-ghe-restore-parallel tests on macOS --- test/test-ghe-restore-parallel.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test-ghe-restore-parallel.sh b/test/test-ghe-restore-parallel.sh index 35d85d2d0..e0c8a0caa 100755 --- a/test/test-ghe-restore-parallel.sh +++ b/test/test-ghe-restore-parallel.sh @@ -2,6 +2,12 @@ # ghe-restore command tests run in parallel set -e +# Currently disabled on macOS due to rsync issues +if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Skipping $(basename "$0") tests as they are temporarily disabled on macOS: https://github.com/github/backup-utils/issues/841" + exit 0 +fi + export GHE_PARALLEL_ENABLED=yes # use temp dir to fix rsync file issues in parallel execution: From 506e1ad13401632d18124dcedb76abd808d1a1a4 Mon Sep 17 00:00:00 2001 From: Zach Renner Date: Wed, 22 Dec 2021 15:52:41 -0800 Subject: [PATCH 1450/2421] Take full mssql backup if other backup mechanisms have interfered --- share/github-backup-utils/ghe-backup-mssql | 175 ++++++++++++++++++--- test/bin/ghe-mssql-console | 21 ++- test/test-ghe-backup.sh | 39 ++++- test/testlib.sh | 12 ++ 4 files changed, 219 insertions(+), 28 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index c1b8e661d..18e0e6e20 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -14,8 +14,7 @@ set -e backup_dir="$GHE_SNAPSHOT_DIR/mssql" last_mssql= backup_command= -take_full= -take_diff= +backup_type= full_expire= diff_expire= tran_expire= @@ -53,23 +52,23 @@ find_timestamp() { echo $datetime_part } -ensure_same_dbs() { +actions_dbs() { all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) - - remotes=() for db in $all_dbs; do if [[ ! "$db" =~ ^(master|tempdb|model|msdb)$ ]] && [[ "$db" =~ ^[a-zA-Z0-9_-]+$ ]]; then - remotes+=("$db") + echo "$db" fi done +} +ensure_same_dbs() { locals=() while read -r file; do filename=$(basename "$file") locals+=("$filename") done < <(find "$1" \( -name "*.bak" -o -name "*.diff" -o -name "*.log" \)) - for remote in "${remotes[@]}"; do + for remote in $(actions_dbs); do remaining_locals=() for local in "${locals[@]}"; do if ! [[ "$local" == "$remote"* ]]; then @@ -90,13 +89,67 @@ ensure_same_dbs() { fi } +run_query() { + echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh "$GHE_HOSTNAME" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' +} + +get_latest_backup_file() { + backups_dir=$1 + db=$2 + ext=$3 + + latest_full_backup=$(find "$backups_dir" -type f -name "$db*.$ext" | egrep '[0-9]{8}T[0-9]{6}' | sort | tail -n 1) + latest_full_backup_file="${latest_full_backup##*/}" + echo "$latest_full_backup_file" +} + +get_backup_val() { + db=$1 + filename=$2 + column=$3 + run_query " + SELECT s.$column + FROM msdb.dbo.backupset s + JOIN msdb.dbo.backupmediafamily f + ON s.media_set_id = f.media_set_id + WHERE s.database_name = '$db' AND f.physical_device_name LIKE '%$filename'" +} + +get_backup_checkpoint_lsn() { + get_backup_val "$1" "$2" "checkpoint_lsn" +} + +get_backup_last_lsn() { + get_backup_val "$1" "$2" "last_lsn" +} + +get_next_log_backup_starting_lsn() { + db=$1 + # last_log_backup_lsn: The starting log sequence number of the next log backup + # https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-database-recovery-status-transact-sql + run_query " + SELECT last_log_backup_lsn + FROM sys.database_recovery_status drs + JOIN sys.databases db on drs.database_id = db.database_id + WHERE db.name = '$db'" +} + +get_next_diff_backup_base_lsn() { + db=$1 + # differential_base_lsn: Base for differential backups. Data extents changed after this LSN will be included in a differential backup. + # https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-master-files-transact-sql + run_query " + SELECT differential_base_lsn + FROM sys.master_files mf + WHERE mf.name = '$db'" +} + last_mssql=$GHE_DATA_DIR/current/mssql if [ ! -d $last_mssql ] \ || [ -z "$(find $last_mssql -type f -name '*.bak' | head -n 1)" ]; then ghe_verbose "Taking first full backup" - take_full=1 - backup_command='ghe-export-mssql' + backup_type="full" else ensure_same_dbs "$last_mssql" @@ -128,25 +181,89 @@ else ghe_verbose "current $current, full expire $full_expire, \ diff expire $diff_expire, tran expire $tran_expire" - # Determine the type of backup to take + # Determine the type of backup to take based on expiry time if [ $current -gt $full_expire ]; then - ghe_verbose "Taking full backup" - take_full=1 - backup_command='ghe-export-mssql' + backup_type='full' elif [ $current -gt $diff_expire ]; then - ghe_verbose "Taking diff backup" - take_diff=1 - backup_command='ghe-export-mssql -d' + backup_type='diff' elif [ $current -gt $tran_expire ]; then - ghe_verbose "Taking transaction backup" - backup_command='ghe-export-mssql -t' + backup_type='transaction' fi + + # Upgrade to a full backup if the diff/transaction backup might not be restorable due to other backup mechanisms interfering + # with the transaction LSN chain or differential base LSN. + if [ "$backup_type" == 'diff' ] || [ "$backup_type" == 'transaction' ]; then + ghe_verbose "Checking for conflicting backups to ensure a $backup_type backup is sufficient" + + for db in $(actions_dbs); do + # Ensure that a diff backup will be based on the full backup file we have (rather than one another backup mechanism took) + if [ "$backup_type" == 'diff' ]; then + full_backup_file=$(get_latest_backup_file "$last_mssql" "$db" "bak") + if [[ "$full_backup_file" == "" ]]; then + ghe_verbose "Taking a full backup instead of a diff backup because for $db a full backup file wasn't found" + backup_type="full" + break + fi + + full_backup_file_checkpoint_lsn=$(get_backup_checkpoint_lsn "$db" "$full_backup_file") + if [[ "$full_backup_file_checkpoint_lsn" = "NULL" ]] || [[ "$full_backup_file_checkpoint_lsn" == "" ]]; then + ghe_verbose "Taking a full backup instead of a diff backup because for $db the checkpoint LSN for $full_backup_file couldn't be determined" + backup_type="full" + break + fi + + next_diff_backup_base_lsn=$(get_next_diff_backup_base_lsn "$db") + if [[ "$next_diff_backup_base_lsn" = "NULL" ]] || [[ "$next_diff_backup_base_lsn" == "" ]]; then + ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db the base LSN for the next diff backup couldn't be determined" + backup_type="full" + break + fi + + # The base of the diff backup we're about to take must exactly match the checkpoint LSN of the full backup file we have + if [[ "$next_diff_backup_base_lsn" -ne "$full_backup_file_checkpoint_lsn" ]]; then + ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db the diff would have base LSN $next_diff_backup_base_lsn yet our full backup has checkpoint LSN $full_backup_file_checkpoint_lsn" + backup_type="full" + break + fi + fi + + # Ensure that a transaction log backup will immediately follow the previous one + latest_log_backup_file=$(get_latest_backup_file "$last_mssql" "$db" "log") + if [[ "$latest_log_backup_file" == "" ]]; then + ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db a previous transaction log backup wasn't found" + backup_type="full" + break + fi + + latest_log_backup_last_lsn=$(get_backup_last_lsn "$db" "$latest_log_backup_file") + if [[ "$latest_log_backup_last_lsn" = "NULL" ]] || [[ "$latest_log_backup_last_lsn" == "" ]]; then + ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db the LSN range for $latest_log_backup_file couldn't be determined" + backup_type="full" + break + fi + + next_log_backup_starting_lsn=$(get_next_log_backup_starting_lsn "$db") + if [[ "$next_log_backup_starting_lsn" = "NULL" ]] || [[ "$next_log_backup_starting_lsn" == "" ]]; then + ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db the starting LSN for the next log backup couldn't be determined" + backup_type="full" + break + fi + + # The starting LSN of the backup we're about to take must be equal to (or before) the last LSN from the last backup, + # otherwise there'll be a gap and the logfiles won't be restorable + if [[ "$next_log_backup_starting_lsn" -gt "$latest_log_backup_last_lsn" ]]; then + ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db a gap would exist between the last backup ending at LSN $latest_log_backup_last_lsn and next backup starting at $next_log_backup_starting_lsn" + backup_type="full" + break + fi + done + fi fi # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" -# Create hard links to save disk space and time +# Use hard links to "copy" over previous applicable backups to the new snapshot folder to save disk space and time if [ -d $last_mssql ]; then for p in $last_mssql/* do @@ -156,15 +273,18 @@ if [ -d $last_mssql ]; then extension="${filename##*.}" transfer= - if [ $extension = "bak" ] && [ -z $take_full ]; then + # Copy full backups unless we're taking a new full backup + if [ $extension = "bak" ] && [ "$backup_type" != 'full' ]; then transfer=1 fi - if [ $extension = "diff" ] && [ -z $take_full ] && [ -z $take_diff ]; then + # Copy diff backups unless we're taking a new full or diff backup + if [ $extension = "diff" ] && [ "$backup_type" != 'full' ] && [ "$backup_type" != 'diff' ]; then transfer=1 fi - if [ $extension = "log" ] && [ -z $take_full ] && [ -z $take_diff ]; then + # Copy transaction log backups unless we're taking a new full or diff backup + if [ $extension = "log" ] && [ "$backup_type" != 'full' ] && [ "$backup_type" != 'diff' ]; then transfer=1 fi @@ -175,7 +295,16 @@ if [ -d $last_mssql ]; then done fi -if [ -n "$backup_command" ]; then +if [ -n "$backup_type" ]; then + ghe_verbose "Taking $backup_type backup" + + backup_command='ghe-export-mssql' + if [ "$backup_type" = "diff" ]; then + backup_command='ghe-export-mssql -d' + elif [ "$backup_type" = "transaction" ]; then + backup_command='ghe-export-mssql -t' + fi + bm_start "$(basename $0)" ghe-ssh "$GHE_HOSTNAME" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename $0)" diff --git a/test/bin/ghe-mssql-console b/test/bin/ghe-mssql-console index 6f1145ddc..b31cf8a00 100755 --- a/test/bin/ghe-mssql-console +++ b/test/bin/ghe-mssql-console @@ -1,4 +1,21 @@ #!/usr/bin/env bash -# Returns environment variable REMOTE_DBS, the variable should be set as space-delimited string # Tests use this to emulate ghe-mssql-console from a remote GitHub Enterprise Server -echo $REMOTE_DBS +if [[ "$*" == *"SELECT name FROM sys.databases"* ]]; then + # REMOTE_DBS should be set as space-delimited string with the test database names + echo "$REMOTE_DBS" +elif [[ "$*" == *"last_log_backup_lsn"* ]]; then + # Starting log sequence number of the next log backup. + # Should match the most recent log backup last_lsn. + echo "$NEXT_LOG_BACKUP_STARTING_LSN" +elif [[ "$*" == *"last_lsn"* ]]; then + # Last LSN of the transaction log backup file being looked up. + echo "$LOG_BACKUP_FILE_LAST_LSN" +elif [[ "$*" == *"differential_base_lsn"* ]]; then + # Next diff backup base LSN. Should match full checkpoint LSN. + echo "$DIFFERENTIAL_BASE_LSN" +elif [[ "$*" == *"checkpoint_lsn"* ]]; then + # Checkpoint LSN of the full backup file being looked up. + echo "$FULL_BACKUP_FILE_LSN" +else + echo "UNKNOWN QUERY: ghe-mssql-console test stub failed on: $*" +fi \ No newline at end of file diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 41be3be5f..bd0e63a3f 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -376,7 +376,7 @@ begin_test "ghe-backup takes full backup upon expiration" set -e enable_actions enable_minio - export REMOTE_DBS="full_mssql" + setup_mssql_stubs setup_mssql_backup_file "full_mssql" 11 "bak" @@ -391,7 +391,7 @@ begin_test "ghe-backup takes diff backup upon expiration" set -e enable_actions enable_minio - export REMOTE_DBS="full_mssql" + setup_mssql_stubs setup_mssql_backup_file "full_mssql" 7 "bak" @@ -406,7 +406,7 @@ begin_test "ghe-backup takes transaction backup upon expiration" ( set -e enable_actions - export REMOTE_DBS="full_mssql" + setup_mssql_stubs setup_mssql_backup_file "full_mssql" 3 "bak" @@ -425,6 +425,7 @@ begin_test "ghe-backup warns if database names mismatched" rm -rf "$GHE_DATA_DIR/current/mssql" mkdir -p "$GHE_DATA_DIR/current/mssql" + setup_mssql_stubs export REMOTE_DBS="full_mssql_1 full_mssql_2 full_mssql_3" add_mssql_backup_file "full_mssql_1" 3 "bak" @@ -437,6 +438,38 @@ begin_test "ghe-backup warns if database names mismatched" ) end_test +begin_test "ghe-backup upgrades diff backup to full if diff base mismatch" +( + set -e + enable_actions + setup_mssql_stubs + export FULL_BACKUP_FILE_LSN=100 + export DIFFERENTIAL_BASE_LSN=101 # some other full backup interfered and moved up the diff base! + + setup_mssql_backup_file "full_mssql" 7 "bak" + + output=$(ghe-backup -v) + echo "$output" | grep "Taking a full backup instead of a diff backup" + echo "$output" | grep "Taking full backup" +) +end_test + +begin_test "ghe-backup upgrades transaction backup to full if LSN chain break" +( + set -e + enable_actions + setup_mssql_stubs + export LOG_BACKUP_FILE_LAST_LSN=100 + export NEXT_LOG_BACKUP_STARTING_LSN=101 # some other log backup interfered and stole 1 LSN! + + setup_mssql_backup_file "full_mssql" 3 "bak" + + output=$(ghe-backup -v) + echo "$output" | grep "Taking a full backup instead of a transaction backup" + echo "$output" | grep "Taking full backup" +) +end_test + begin_test "ghe-backup takes backup of Actions settings" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index b15f55d12..69411bf1b 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -528,6 +528,18 @@ setup_mssql_backup_file() { fi } +setup_mssql_stubs() { + export REMOTE_DBS="full_mssql" + + # Transaction log LSN checks + export NEXT_LOG_BACKUP_STARTING_LSN=100 + export LOG_BACKUP_FILE_LAST_LSN=100 + + # Differential backup LSN checks + export DIFFERENTIAL_BASE_LSN=100 + export FULL_BACKUP_FILE_LSN=100 +} + add_mssql_backup_file() { # $1 name: @... # $2 minutes ago From 840adfe707d9908c816bd570e43eecd2f0098732 Mon Sep 17 00:00:00 2001 From: Zach Renner <13670625+zarenner@users.noreply.github.com> Date: Wed, 29 Dec 2021 13:09:48 -0800 Subject: [PATCH 1451/2421] Recommend against using multiple backup hosts --- docs/requirements.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/requirements.md b/docs/requirements.md index 797eb96cf..a9a1e6da0 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -63,6 +63,12 @@ be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapsh **Note**: You _cannot_ restore a backup created from a newer verison of GitHub Enterprise Server to an older version. For example, an attempt to restore a snapshot of GitHub Enterprise Server 2.21 to a GitHub Enterprise Server 2.20 environment will fail with an error of `Error: Snapshot can not be restored to an older release of GitHub Enterprise Server.`. +## Multiple backup hosts + +Using multiple backup hosts or backup configurations is not currently recommended. + +Due to how some components of Backup Utiltiies (e.g. MSSQL) take incremental backups, running another instance of Backup Utilities may result in unrestorable snapshots as data may be split across backup hosts. If you still wish to have multiple instances of Backup Utilties for redundancy purposes or to run at different frequencies, ensure that they share the same `GHE_DATA_DIR` backup directory. + [1]: https://www.gnu.org/software/bash/ [2]: https://git-scm.com/ [3]: https://www.openssh.com/ From b146df54512d3e62172ca10aafad658a658f29d9 Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 13 Jan 2022 12:02:34 -0800 Subject: [PATCH 1452/2421] Bump super linter Resolves #232 --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4a38ba869..6ac0adc8d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,6 +13,6 @@ jobs: - name: Checkout Code uses: actions/checkout@v2 - name: Lint Code Base - uses: docker://github/super-linter:v2.1.1 + uses: github/super-linter@b8641364ca9a79b3cf07f3c4c59a82709cd39094 env: VALIDATE_ALL_CODEBASE: false From 1859fdb0af94f36e60270a048b7c087f145ddbaa Mon Sep 17 00:00:00 2001 From: bonsohi <31749534+bonsohi@users.noreply.github.com> Date: Thu, 13 Jan 2022 18:08:40 -0800 Subject: [PATCH 1453/2421] Update lint.yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6ac0adc8d..46017ce29 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,6 +13,6 @@ jobs: - name: Checkout Code uses: actions/checkout@v2 - name: Lint Code Base - uses: github/super-linter@b8641364ca9a79b3cf07f3c4c59a82709cd39094 + uses: docker://github/super-linter:latest env: VALIDATE_ALL_CODEBASE: false From 50406e6bc0e758c62bde57acc00de9ed7844c3e7 Mon Sep 17 00:00:00 2001 From: djdefi Date: Fri, 14 Jan 2022 11:21:53 -0800 Subject: [PATCH 1454/2421] Add some performance notes to faq Resolves #440 --- docs/faq.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/faq.md b/docs/faq.md index fc8d53bb0..ee3b07c24 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -19,4 +19,11 @@ snapshots of all major datastores. These snapshots are used to restore an instan to a prior state or set up a new instance without having another always-on GitHub Enterprise instance (like the High Availability replica). +### Does taking or restoring a backup impact the GitHub Enterprise Server's performance or operation? + +Git background maintenance and garbage collection jobs become paused during the repositories stage of a backup and restore, and the storage stage of a backup. This may result in a backlog of queued maintenance or storage jobs observable in the GitHub Enterprise Server metrics for the duration of those steps. We suggest allowing any backlog to process and drain to 0 before starting another backup run. Repositories that are frequently pushed to may experience performance degradation over time if queued maintenance jobs are not processed. + +Backup processes triggered by `backup-utils` running on the GitHub Enterprise Server instance run at a low CPU and IO priority to reduce any user facing impact. You may observe elevated levels of CPU usage, disk IO, and network IO for the duration of a backup run. + + [1]: https://help.github.com/enterprise/admin/guides/installation/high-availability-cluster-configuration/ From 5b1cd03d3d3a3d75b613b0ac727c7f49047e79aa Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 24 Jan 2022 20:04:31 -0700 Subject: [PATCH 1455/2421] Revert logic for host check --- bin/ghe-host-check | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3e9664a30..b1f72dd0b 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -52,8 +52,38 @@ options=" port=$(ssh_port_part "$host") hostname=$(ssh_host_part "$host") +set +e # ghe-negotiate-version verifies if the target is a Github Enterprise Server instance output=$(echo "ghe-negotiate-version backup-utils $BACKUP_UTILS_VERSION" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1) +rc=$? +set -e + +if [ $rc -ne 0 ]; then + case $rc in + 255) + if echo "$output" | grep -i "port 22: Network is unreachable\|port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then + exec "$(basename $0)" "$hostname:122" + fi + + echo "$output" 1>&2 + echo "Error: ssh connection with '$host' failed" 1>&2 + echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2 + echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2 + ;; + 101) + echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 + ;; + 1) + if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then + exec "$(basename $0)" "$hostname:122" + else + echo "$output" 1>&2 + fi + ;; + + esac + exit $rc +fi CLUSTER=false if ghe-ssh "$host" -- \ From c5c4e596e539fb361d3350e7e12b12823d7c8383 Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Fri, 28 Jan 2022 14:45:13 +0000 Subject: [PATCH 1456/2421] Prevent GitHub Connect jobs running until config has been reset --- bin/ghe-restore | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index a66ae31db..c079d2ebc 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -446,6 +446,14 @@ echo "Restarting memcached ..." 1>&3 echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh +# Prevent GitHub Connect jobs running before we've had a chance to reset +# the configuration by setting the last run date to now. +if ! $RESTORE_SETTINGS; then + echo "Setting last run date for GitHub Connect jobs ..." 1>&3 + echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 +fi + # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. if $CLUSTER; then From feea728ee541df8450bf31965a6267416e08f70c Mon Sep 17 00:00:00 2001 From: Colin Seymour Date: Wed, 2 Feb 2022 10:21:07 +0000 Subject: [PATCH 1457/2421] Fake mset arg for tests --- test/bin/ghe-redis-cli | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/bin/ghe-redis-cli b/test/bin/ghe-redis-cli index f017b2e5b..a2bbbc218 100755 --- a/test/bin/ghe-redis-cli +++ b/test/bin/ghe-redis-cli @@ -18,6 +18,11 @@ while true; do echo "fake redis data" > "$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb" break ;; + mset) + # Fake accepting of mset command + shift 9 + break + ;; --remote) # Fake accepting hostname argument shift 3 From 7dee326f0bda465b3c16b21cf3a46291321e3787 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 8 Feb 2022 13:27:31 -0800 Subject: [PATCH 1458/2421] Add anchor to usage doc for settings restore --- docs/usage.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index e1f5d3f35..27a2aa969 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -80,6 +80,8 @@ The `ghe-backup` and `ghe-restore` commands also have a verbose output mode (`-v`) that lists files as they're being transferred. It's often useful to enable when output is logged to a file. +### Restoring settings, TLS certificate, and license + When restoring to a new GitHub Enterprise Server instance, settings, certificate, and license data *are* restored. These settings must be reviewed and saved before using the GitHub Enterprise Server to ensure all migrations take place and all required From 6353de412d9a4c088bcf09a7601287e2859a92e4 Mon Sep 17 00:00:00 2001 From: Kerry Hatcher Date: Thu, 10 Feb 2022 10:15:15 -0500 Subject: [PATCH 1459/2421] Update usage.md --- docs/usage.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 27a2aa969..9f09eee54 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -100,7 +100,8 @@ GitHub Actions enabled, the following steps are required: 1. Enable GitHub Actions on the replacement appliance and configure it to use the same GitHub Actions external storage configuration as the original appliance. -2. Use `ghe-restore` to restore the backup. -3. Re-register your self-hosted runners on the replacement appliance. +2. Put replacement appliance into maintaince mode. +3. Use `ghe-restore` to restore the backup. +4. Re-register your self-hosted runners on the replacement appliance. [1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md From ee5afbbd9a9ef0776ced009a2f9ba53c1d80ef1a Mon Sep 17 00:00:00 2001 From: Kerry Hatcher Date: Thu, 10 Feb 2022 10:37:29 -0500 Subject: [PATCH 1460/2421] Update usage.md --- docs/usage.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index 9f09eee54..1a5b76811 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -104,4 +104,6 @@ GitHub Actions enabled, the following steps are required: 3. Use `ghe-restore` to restore the backup. 4. Re-register your self-hosted runners on the replacement appliance. +Please refer to [GHES Documentation](https://docs.github.com/en/enterprise-server/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled) for more details + [1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md From c219c8c0fd7ab7ac8889c9fc84093395d18c2b19 Mon Sep 17 00:00:00 2001 From: Steve Culver Date: Tue, 15 Feb 2022 19:25:09 +0000 Subject: [PATCH 1461/2421] Bump version: 3.4.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 6 ++++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index b1f72dd0b..545aa2c55 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -131,7 +131,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.1.0" +supported_minimum_version="3.2.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index ced0ad044..01ef01085 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +github-backup-utils (3.4.0) UNRELEASED; urgency=medium + + * Add anchor to usage doc for settings restore #865 + + -- Steve Culver Tue, 15 Feb 2022 19:25:09 +0000 + github-backup-utils (3.3.1) UNRELEASED; urgency=medium * Fix compat issue with ghe-actions-start during maintenance mode #836 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index bea438e9a..18091983f 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.3.1 +3.4.0 diff --git a/test/testlib.sh b/test/testlib.sh index 69411bf1b..5a276f3bc 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.3.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.4.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From edcb284c2c1168432b35f92b408a44179b2115bb Mon Sep 17 00:00:00 2001 From: Zachary Mark Date: Tue, 15 Feb 2022 20:06:07 +0000 Subject: [PATCH 1462/2421] Check for .tar.xz instead of .tar.gz when publishing Debian package In #726 we moved to a more modern Debian package format but failed to take into account the necessary changes to the package-deb script, which now needed to expect a `.tar.xz` instead of a `.tar.gz`. --- script/package-deb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/package-deb b/script/package-deb index b42f0d5fd..dda90cbe3 100755 --- a/script/package-deb +++ b/script/package-deb @@ -26,6 +26,6 @@ git checkout -q "$PKG_HEAD" debuild -uc -us 1>&2 cd .. -files=$(ls -1 *.deb *.tar.gz *.dsc *.changes) +files=$(ls -1 *.deb *.tar.xz *.dsc *.changes) mv $files ../ for f in $files; do echo "dist/$f"; done From a70b93d99e4a03feff015f7be35d08ba84c239db Mon Sep 17 00:00:00 2001 From: Zachary Mark Date: Tue, 15 Feb 2022 20:31:19 +0000 Subject: [PATCH 1463/2421] Bump the hardcoded check values in the host check test to unbreak CI --- test/test-ghe-host-check.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index f064d312f..8ac5970f0 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -61,7 +61,8 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions ! GHE_TEST_REMOTE_VERSION=2.21.0 ghe-host-check ! GHE_TEST_REMOTE_VERSION=2.22.0 ghe-host-check ! GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=3.1.0 ghe-host-check + ! GHE_TEST_REMOTE_VERSION=3.1.0 ghe-host-check + GHE_TEST_REMOTE_VERSION=3.2.0 ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check From 0431ced3c3229b60212c8a20144225927ded5ea7 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 24 Feb 2022 09:52:02 -0700 Subject: [PATCH 1464/2421] trap INT for ghe-backup-repository cleanup --- share/github-backup-utils/ghe-backup-repositories | 7 ++++--- share/github-backup-utils/ghe-backup-storage | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index a66934d0d..5185f63d9 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -90,14 +90,15 @@ cleanup() { # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port || true + ghe-gc-enable $ssh_config_file_opt $hostname:$port || { + echo "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 + } done ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir rm -rf $tempdir } -trap 'cleanup' EXIT -trap 'exit $?' INT # ^C always terminate +trap 'cleanup' EXIT INT # Disable remote GC operations for hostname in $hostnames; do diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index db49bc8e7..67517512b 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -59,7 +59,9 @@ mkdir -p "$backup_dir" cleanup() { # Enable remote maintenance operations for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port || true + ghe-gc-enable $ssh_config_file_opt $hostname:$port || { + echo "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 + } done ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir From bbfc42f23e85cd0523ea0ef5d3be6ce457a95a35 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari <64764738+tiwarishub@users.noreply.github.com> Date: Thu, 17 Mar 2022 15:52:25 +0530 Subject: [PATCH 1465/2421] Added support for AC databases (#878) * repair login for ac * added ac condition in restore * reverted new line * comment update * added qute * Update ghe-restore-actions * Update ghe-restore-actions * ci * revert deleted file * Update ghe-restore * Update ghe-restore-actions * Update ghe-restore * Update ghe-restore * Update ghe-restore * added doc link * added doc link --- bin/ghe-restore | 18 ++++++++++++++---- share/github-backup-utils/ghe-restore-actions | 6 ++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index c079d2ebc..b69ab5e89 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -261,12 +261,22 @@ if $instance_configured; then fi fi +# Get GHES release version in major.minor format +RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2) + # Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data. +# If above is true, also check if ac is present in appliance then snapshot should also contains ac databases if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then - if ! ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - # Get GHES release version in major.minor format - RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2) - + if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) + ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") + if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then + echo "Error: $GHE_HOSTNAME contains ArtifactCache databases but no ArtifactCache databases are present in snapshot. Aborting" 1>&2 + echo "Please delete ArtifactCache databases from $GHE_HOSTNAME and retry" 1>&2 + echo "Steps to delete ArtifactCache databases can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/deleting-artifact-cache-databases" 1>&2 + exit 1 + fi + else echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 62832b24f..e231d7ce7 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -93,4 +93,10 @@ ghe-ssh -p "$port" "$host" -- ghe-actions-console -s mps -c "Repair-DatabaseLogi ghe-ssh -p "$port" "$host" -- ghe-actions-console -s token -c "Repair-DatabaseLogins" ghe-ssh -p "$port" "$host" -- ghe-actions-console -s actions -c "Repair-DatabaseLogins" +if [ ! -z "$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache_Configuration*.bak')" ]; then + ghe-ssh -p "$port" "$host" -- ghe-actions-console -s artifactcache -c "Repair-DatabaseLogins" + else + echo "ArtifactCache is not present in mssql backup. Skipping Repair-DatabaseLogins for it." +fi + bm_end "$(basename $0)" From 3a54d0fde9485b81efdcc732a913cb45acc03eba Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Tue, 22 Mar 2022 13:03:19 +0900 Subject: [PATCH 1466/2421] simplify complex redirects for rsync >= 3.x --- share/github-backup-utils/ghe-rsync | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index fa212e8f0..698a0f6c0 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -11,11 +11,6 @@ set -o pipefail # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -# Filter vanished file warnings from both stdout (rsync versions < 3.x) and -# stderr (rsync versions >= 3.x). The complex redirections are necessary to -# filter stderr while also keeping stdout and stderr separated. -ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' - # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") @@ -25,9 +20,9 @@ else done fi -(rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | - (egrep -v "$ignoreout" || true)) 3>&1 1>&2 2>&3 3>&- | - (egrep -v "$ignoreout" || true) +# Rsync >=3.x sends errors to stderr, so we must combine with stdout before the pipe so we can grep properly. +ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' +rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) res=$? # Suppress exits with 24. From 10c7bbecf1231414c23beea9a5cb7daf913a05b7 Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Fri, 25 Mar 2022 14:05:42 +0900 Subject: [PATCH 1467/2421] keep supportability for rsync2.x with a version check --- share/github-backup-utils/ghe-rsync | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 698a0f6c0..36a478510 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -20,9 +20,15 @@ else done fi -# Rsync >=3.x sends errors to stderr, so we must combine with stdout before the pipe so we can grep properly. ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) +rsync_version_check=`rsync --version | egrep "version 2.[0-9]*.[0-9]*"` +if [ -z "$rsync_version_check" ]; then + # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe + rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) +else + # rsync <3.x sends errors to stdout. + rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS | (egrep -v "$ignoreout" || true) +fi res=$? # Suppress exits with 24. From 58fdc26044dfbf07da436f4304c6b8f603b66430 Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Fri, 25 Mar 2022 14:08:02 +0900 Subject: [PATCH 1468/2421] check for 3.x instead --- share/github-backup-utils/ghe-rsync | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 36a478510..c50835072 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -21,8 +21,8 @@ else fi ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -rsync_version_check=`rsync --version | egrep "version 2.[0-9]*.[0-9]*"` -if [ -z "$rsync_version_check" ]; then +rsync_version_check=`rsync --version | egrep "version 3.[0-9]*.[0-9]*"` +if [ ! -z "$rsync_version_check" ]; then # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) else From 6a94437881e1049690085b23fdd80fbd53caa1cf Mon Sep 17 00:00:00 2001 From: donal Date: Thu, 24 Mar 2022 23:21:14 +1100 Subject: [PATCH 1469/2421] track if cron is running and try to restart on failure --- bin/ghe-restore | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b69ab5e89..c3c2efa63 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -86,6 +86,19 @@ while true; do esac done +start_cron () { + echo "Starting cron ..." + if $CLUSTER; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then + echo "* Warning: Failed to start cron on one or more nodes" + fi + else + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then + echo "* Warning: Failed to start cron" + fi + fi +} + cleanup () { if [ -n "$1" ]; then update_restore_status "$1" @@ -103,6 +116,10 @@ cleanup () { fi fi + if ! $CRON_RUNNING; then + start_cron + fi + # Cleanup SSH multiplexing ghe-ssh --clean } @@ -249,6 +266,7 @@ update_restore_status () { fi } +CRON_RUNNING=true # Update remote restore state file and setup failure trap trap "cleanup failed" EXIT update_restore_status "restoring" @@ -324,7 +342,7 @@ else fi fi fi - +CRON_RUNNING=false # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. @@ -492,16 +510,8 @@ if ! $RESTORE_SETTINGS; then fi # Start cron. Timerd will start automatically as part of the config run. -echo "Starting cron ..." -if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then - echo "* Warning: Failed to start cron on one or more nodes" - fi -else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then - echo "* Warning: Failed to start cron" - fi -fi +start_cron +CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then From 231cc6624fd37671869be3f62bf5db299d8cdfca Mon Sep 17 00:00:00 2001 From: Aparna Ravindra <82894348+aparna-ravindra@users.noreply.github.com> Date: Mon, 11 Apr 2022 12:54:36 +0530 Subject: [PATCH 1470/2421] error message (#886) --- bin/ghe-restore | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index c3c2efa63..d5cb872a2 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -289,9 +289,15 @@ if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - echo "Error: $GHE_HOSTNAME contains ArtifactCache databases but no ArtifactCache databases are present in snapshot. Aborting" 1>&2 - echo "Please delete ArtifactCache databases from $GHE_HOSTNAME and retry" 1>&2 - echo "Steps to delete ArtifactCache databases can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/deleting-artifact-cache-databases" 1>&2 + echo "Error: $GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" 1>&2 + echo "Please disable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 + echo "To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 + exit 1 + fi + if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then + echo "Error: $GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting" 1>&2 + echo "Please enable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 + echo "To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 exit 1 fi else From ee4a19a2f9516bfd9572f7f5d24ea2bdff3ec77c Mon Sep 17 00:00:00 2001 From: donal Date: Thu, 24 Mar 2022 23:21:14 +1100 Subject: [PATCH 1471/2421] track if cron is running and try to restart on failure --- bin/ghe-restore | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index a66ae31db..bdcdf1c71 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -86,6 +86,19 @@ while true; do esac done +start_cron () { + echo "Starting cron ..." + if $CLUSTER; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then + echo "* Warning: Failed to start cron on one or more nodes" + fi + else + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then + echo "* Warning: Failed to start cron" + fi + fi +} + cleanup () { if [ -n "$1" ]; then update_restore_status "$1" @@ -103,6 +116,10 @@ cleanup () { fi fi + if ! $CRON_RUNNING; then + start_cron + fi + # Cleanup SSH multiplexing ghe-ssh --clean } @@ -249,6 +266,7 @@ update_restore_status () { fi } +CRON_RUNNING=true # Update remote restore state file and setup failure trap trap "cleanup failed" EXIT update_restore_status "restoring" @@ -314,7 +332,7 @@ else fi fi fi - +CRON_RUNNING=false # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. @@ -474,16 +492,8 @@ if ! $RESTORE_SETTINGS; then fi # Start cron. Timerd will start automatically as part of the config run. -echo "Starting cron ..." -if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then - echo "* Warning: Failed to start cron on one or more nodes" - fi -else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then - echo "* Warning: Failed to start cron" - fi -fi +start_cron +CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then From 668660aa9afc340cbd858eccb001a4db4e836719 Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Tue, 22 Mar 2022 13:03:19 +0900 Subject: [PATCH 1472/2421] simplify complex redirects for rsync >= 3.x --- share/github-backup-utils/ghe-rsync | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index fa212e8f0..698a0f6c0 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -11,11 +11,6 @@ set -o pipefail # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -# Filter vanished file warnings from both stdout (rsync versions < 3.x) and -# stderr (rsync versions >= 3.x). The complex redirections are necessary to -# filter stderr while also keeping stdout and stderr separated. -ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' - # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") @@ -25,9 +20,9 @@ else done fi -(rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 3>&1 1>&2 2>&3 3>&- | - (egrep -v "$ignoreout" || true)) 3>&1 1>&2 2>&3 3>&- | - (egrep -v "$ignoreout" || true) +# Rsync >=3.x sends errors to stderr, so we must combine with stdout before the pipe so we can grep properly. +ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' +rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) res=$? # Suppress exits with 24. From 55d50aecd67a0680090e474e90a666e96823ccc8 Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Fri, 25 Mar 2022 14:05:42 +0900 Subject: [PATCH 1473/2421] keep supportability for rsync2.x with a version check --- share/github-backup-utils/ghe-rsync | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 698a0f6c0..36a478510 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -20,9 +20,15 @@ else done fi -# Rsync >=3.x sends errors to stderr, so we must combine with stdout before the pipe so we can grep properly. ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) +rsync_version_check=`rsync --version | egrep "version 2.[0-9]*.[0-9]*"` +if [ -z "$rsync_version_check" ]; then + # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe + rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) +else + # rsync <3.x sends errors to stdout. + rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS | (egrep -v "$ignoreout" || true) +fi res=$? # Suppress exits with 24. From 573fc42e43ae7b0621218e127df76e3b56091f3e Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Fri, 25 Mar 2022 14:08:02 +0900 Subject: [PATCH 1474/2421] check for 3.x instead --- share/github-backup-utils/ghe-rsync | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 36a478510..c50835072 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -21,8 +21,8 @@ else fi ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -rsync_version_check=`rsync --version | egrep "version 2.[0-9]*.[0-9]*"` -if [ -z "$rsync_version_check" ]; then +rsync_version_check=`rsync --version | egrep "version 3.[0-9]*.[0-9]*"` +if [ ! -z "$rsync_version_check" ]; then # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) else From 65d654b6d7474dd1fc319d877cba1d7b2bc7b44f Mon Sep 17 00:00:00 2001 From: donal Date: Thu, 21 Apr 2022 09:52:06 +0000 Subject: [PATCH 1475/2421] Bump version: 3.4.1 [ci skip] --- debian/changelog | 7 +++++++ share/github-backup-utils/version | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 01ef01085..d2aadc3e7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (3.4.1) UNRELEASED; urgency=medium + + * On restore failure, restart cron on target host #900 + * Simplify complex redirects for ghe-rsync #901 + + -- Donal Ellis Thu, 21 Apr 2022 09:52:06 +0000 + github-backup-utils (3.4.0) UNRELEASED; urgency=medium * Add anchor to usage doc for settings restore #865 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 18091983f..47b322c97 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.4.0 +3.4.1 From efc116fd4df49dcf7e268397566d4a14fc793eee Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 21 Apr 2022 15:39:46 -0400 Subject: [PATCH 1476/2421] Updated instances of 'cat' to redirections to prevent broken pipe failures --- share/github-backup-utils/ghe-backup-repositories | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index a66934d0d..7eb17e366 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -129,14 +129,14 @@ bm_end "$(basename $0) - Generating routes" bm_start "$(basename $0) - Fetching routes" ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list -cat $routes_list | ghe_debug +< $routes_list ghe_debug bm_end "$(basename $0) - Fetching routes" bm_start "$(basename $0) - Processing routes" if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then server=$host fi -cat $routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' +< $routes_list awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" @@ -324,7 +324,7 @@ bm_start "$(basename $0) - Repo sync" for file_list in $tempdir/*.rsync; do hostname=$(basename $file_list .rsync) - repo_num=$(cat $file_list | wc -l) + repo_num=$(< $file_list wc -l) ghe_verbose "* Transferring $repo_num repositories from $hostname" sync_data $hostname $file_list & @@ -366,7 +366,7 @@ bm_end "$(basename $0) - Special Data Directories Sync" if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then bm_start "$(basename $0) - Verifying Routes" - cat $tempdir/*.rsync | uniq | sort | uniq > $tempdir/source_routes + < $tempdir/*.rsync uniq | sort | uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | fix_paths_for_ghe_version | uniq | sort | uniq) > $tempdir/destination_routes git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." From 547226a0b3b2386dcb92d6ca4f148f859ce8d6df Mon Sep 17 00:00:00 2001 From: donal Date: Fri, 22 Apr 2022 18:52:03 +1000 Subject: [PATCH 1477/2421] manually add 3.3.2 to changelog --- debian/changelog | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index d2aadc3e7..32c0ae34f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,16 @@ github-backup-utils (3.4.1) UNRELEASED; urgency=medium - * On restore failure, restart cron on target host #900 - * Simplify complex redirects for ghe-rsync #901 + * Simplify complex redirects for ghe-rsync #881 + * On restore failure, restart cron on target host #883 - -- Donal Ellis Thu, 21 Apr 2022 09:52:06 +0000 + -- Donal Ellis Fri, 22 Apr 2022 04:00:00 +0000 + +github-backup-utils (3.3.2) UNRELEASED; urgency=medium + + * Simplify complex redirects for ghe-rsync #881 + * On restore failure, restart cron on target host #883 + + -- Donal Ellis Fri, 22 Apr 2022 00:53:45 +0000 github-backup-utils (3.4.0) UNRELEASED; urgency=medium From ea3a50e6b949c091817117e428187abd48aef941 Mon Sep 17 00:00:00 2001 From: Anupam <83457710+s-anupam@users.noreply.github.com> Date: Mon, 2 May 2022 10:51:23 +0530 Subject: [PATCH 1478/2421] backup restore packages settings --- share/github-backup-utils/ghe-backup-settings | 10 +++++ .../github-backup-utils/ghe-restore-packages | 44 +++++++++++++++++++ .../github-backup-utils/ghe-restore-settings | 3 ++ 3 files changed, 57 insertions(+) create mode 100755 share/github-backup-utils/ghe-restore-packages diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index d4ef7d019..f2e14d88d 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -116,6 +116,16 @@ if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then backup-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" fi +if ghe-ssh "$host" -- ghe-config --true app.packages.enabled; then + backup-secret "Packages aws access key" "packages-aws-access-key" "secrets.packages.aws-access-key" + backup-secret "Packages aws secret key" "packages-aws-secret-key" "secrets.packages.aws-secret-key" + backup-secret "Packages s3 bucket" "packages-s3-bucket" "secrets.packages.s3-bucket" + backup-secret "Packages storage service url" "packages-service-url" "secrets.packages.service-url" + backup-secret "Packages blob storage type" "packages-blob-storage-type" "secrets.packages.blob-storage-type" + backup-secret "Packages azure connection string" "packages-azure-connection-string" "secrets.packages.azure-connection-string" + backup-secret "Packages azure container name" "packages-azure-container-name" "secrets.packages.azure-container-name" +fi + if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then echo "* Transferring SAML keys ..." 1>&3 ghe-ssh $host -- sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -cf - "idp.crt saml-sp.p12" > saml-keys.tar diff --git a/share/github-backup-utils/ghe-restore-packages b/share/github-backup-utils/ghe-restore-packages new file mode 100755 index 000000000..0a60b9cc3 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-packages @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-packages +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# Path to snapshot dir we're restoring from +GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + +port=$(ssh_port_part "$GHE_HOSTNAME") +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$host" + +# Restore Packages settings. +ghe_verbose "Restoring Packages settings ..." + +restore-secret "Packages aws access key" "packages-aws-access-key" "secrets.packages.aws-access-key" +restore-secret "Packages aws secret key" "packages-aws-secret-key" "secrets.packages.aws-secret-key" +restore-secret "Packages s3 bucket" "packages-s3-bucket" "secrets.packages.s3-bucket" +restore-secret "Packages storage service url" "packages-service-url" "secrets.packages.service-url" +restore-secret "Packages blob storage type" "packages-blob-storage-type" "secrets.packages.blob-storage-type" +restore-secret "Packages azure connection string" "packages-azure-connection-string" "secrets.packages.azure-connection-string" +restore-secret "Packages azure container name" "packages-azure-container-name" "secrets.packages.azure-container-name" + +bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 63dc7aa45..927b7a370 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -33,6 +33,9 @@ echo "Restoring settings and applying configuration ..." # Restore external MySQL password if running external MySQL DB. restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" +echo "Restoring packages settings ..." +ghe-restore-packages "$GHE_HOSTNAME" 1>&3 + # work around issue importing settings with bad storage mode values ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | From 6e2d98bf87c7fbbd0d547c2cb5c9444702b1bcb6 Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Tue, 3 May 2022 12:53:13 +0100 Subject: [PATCH 1479/2421] Fix spelling mistake on requirements.md I noticed a small spelling mistake when sending this documentation out to a customer. It's only minor, but I thought it would be worth fixing. --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index a9a1e6da0..94e5c5701 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -61,7 +61,7 @@ snapshot of GitHub Enterprise Server 2.11, the target GitHub Enterprise Server a be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapshot from 2.10 to 2.13, because that's three releases ahead. -**Note**: You _cannot_ restore a backup created from a newer verison of GitHub Enterprise Server to an older version. For example, an attempt to restore a snapshot of GitHub Enterprise Server 2.21 to a GitHub Enterprise Server 2.20 environment will fail with an error of `Error: Snapshot can not be restored to an older release of GitHub Enterprise Server.`. +**Note**: You _cannot_ restore a backup created from a newer version of GitHub Enterprise Server to an older version. For example, an attempt to restore a snapshot of GitHub Enterprise Server 2.21 to a GitHub Enterprise Server 2.20 environment will fail with an error of `Error: Snapshot can not be restored to an older release of GitHub Enterprise Server.`. ## Multiple backup hosts From 08e68fe88fbe81d2fc622d0a25126633ef28d7d2 Mon Sep 17 00:00:00 2001 From: Anupam <83457710+s-anupam@users.noreply.github.com> Date: Wed, 4 May 2022 02:24:05 +0530 Subject: [PATCH 1480/2421] fix shell warning --- share/github-backup-utils/ghe-restore-packages | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-packages b/share/github-backup-utils/ghe-restore-packages index 0a60b9cc3..e9842d095 100755 --- a/share/github-backup-utils/ghe-restore-packages +++ b/share/github-backup-utils/ghe-restore-packages @@ -22,9 +22,10 @@ GHE_HOSTNAME="$1" : ${GHE_RESTORE_SNAPSHOT:=current} # Path to snapshot dir we're restoring from -GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" +export GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" port=$(ssh_port_part "$GHE_HOSTNAME") +export port host=$(ssh_host_part "$GHE_HOSTNAME") # Perform a host-check and establish GHE_REMOTE_XXX variables. From 7f323b5dad9e4a95d5481a80c21b96371055a567 Mon Sep 17 00:00:00 2001 From: donal Date: Thu, 28 Apr 2022 12:07:52 +1000 Subject: [PATCH 1481/2421] manually fix debian changelog --- debian/changelog | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/debian/changelog b/debian/changelog index 32c0ae34f..0a0d4e411 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,51 +22,18 @@ github-backup-utils (3.3.1) UNRELEASED; urgency=medium * Fix compat issue with ghe-actions-start during maintenance mode #836 - -- bonsohi@github.com Tue, 21 Dec 2021 23:38:01 +0000 + -- Balwinder Sohi Tue, 21 Dec 2021 23:38:01 +0000 github-backup-utils (3.3.0) UNRELEASED; urgency=medium - - -- bonsohi@github.com Wed, 08 Dec 2021 03:12:53 +0000 - -github-backup-utils (3.3.0) UNRELEASED; urgency=medium - - - -- bonsohi@github.com Wed, 08 Dec 2021 03:10:21 +0000 - -github-backup-utils (3.3.0) UNRELEASED; urgency=medium - - - -- bonsohi@github.com Wed, 08 Dec 2021 02:56:47 +0000 - -github-backup-utils (3.3.0) UNRELEASED; urgency=medium - - - -- bonsohi@github.com Wed, 08 Dec 2021 02:51:06 +0000 - -github-backup-utils (3.3.0) UNRELEASED; urgency=medium - - - -- bonsohi@github.com Wed, 08 Dec 2021 02:02:25 +0000 - -github-backup-utils (3.3.0) UNRELEASED; urgency=medium - - - -- bonsohi@github.com Wed, 08 Dec 2021 01:56:26 +0000 - -github-backup-utils (3.3.0) UNRELEASED; urgency=medium - - - -- bonsohi@github.com Wed, 08 Dec 2021 01:25:12 +0000 + -- Balwinder Sohi Wed, 08 Dec 2021 03:12:53 +0000 github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium - -- Nick Iodice Tue, 09 Nov 2021 19:56:08 +0000 github-backup-utils (3.2.0) UNRELEASED; urgency=medium - -- Brett Westover Tue, 28 Sep 2021 16:50:00 +0000 github-backup-utils (3.2.0.rc3) UNRELEASED; urgency=medium @@ -100,7 +67,6 @@ github-backup-utils (3.2.0) UNRELEASED; urgency=medium github-backup-utils (3.1.0) UNRELEASED; urgency=medium - -- Zachary Mark Thu, 03 Jun 2021 16:55:16 +0000 github-backup-utils (3.1.0~rc1) UNRELEASED; urgency=medium From 1d3688fdf12a9f9a5cea28dc431cf97872f4274c Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Tue, 10 May 2022 13:47:18 -0400 Subject: [PATCH 1482/2421] Update ghe-backup-repositories Updated rsync file sorting to loop through, to overcome `ambiguous redirect` error in Debian. --- share/github-backup-utils/ghe-backup-repositories | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 7eb17e366..10e1e9239 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -366,7 +366,9 @@ bm_end "$(basename $0) - Special Data Directories Sync" if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then bm_start "$(basename $0) - Verifying Routes" - < $tempdir/*.rsync uniq | sort | uniq > $tempdir/source_routes + for file_lst in $tempdir/*.rsync; do + < $file_lst sort | uniq + done |sort|uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | fix_paths_for_ghe_version | uniq | sort | uniq) > $tempdir/destination_routes git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." From 8ed75d4d9a678d51a3e84f9fa1051add17b38934 Mon Sep 17 00:00:00 2001 From: bonsohi <31749534+bonsohi@users.noreply.github.com> Date: Tue, 10 May 2022 13:33:29 -0700 Subject: [PATCH 1483/2421] Update usage.md --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 1a5b76811..30954c01a 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -104,6 +104,6 @@ GitHub Actions enabled, the following steps are required: 3. Use `ghe-restore` to restore the backup. 4. Re-register your self-hosted runners on the replacement appliance. -Please refer to [GHES Documentation](https://docs.github.com/en/enterprise-server/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled) for more details +Please refer to [GHES Documentation](https://docs.github.com/en/enterprise-server/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled) for more details. [1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md From 581817dd07a67509722db5855f73d912a3e32b3e Mon Sep 17 00:00:00 2001 From: bonsohi Date: Thu, 12 May 2022 21:06:56 +0000 Subject: [PATCH 1484/2421] Bump version: 3.5.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 7 +++++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 545aa2c55..4d934386c 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -131,7 +131,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.2.0" +supported_minimum_version="3.3.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 0a0d4e411..3cf6c0d25 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +github-backup-utils (3.5.0) UNRELEASED; urgency=medium + + * Simplify complex redirects for ghe-rsync #881 + * On restore failure, restart cron on target host #883 + + -- Bon Sohi Thu, 12 May 2022 21:06:56 +0000 + github-backup-utils (3.4.1) UNRELEASED; urgency=medium * Simplify complex redirects for ghe-rsync #881 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 47b322c97..1545d9665 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.4.1 +3.5.0 diff --git a/test/testlib.sh b/test/testlib.sh index 5a276f3bc..f19fc9649 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.4.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.5.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 206c5d88f2485fe449d4982d5d511bb78cfba31a Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 25 May 2022 14:37:09 -0400 Subject: [PATCH 1485/2421] Updated mkdir to use -p to be consistent with GHE*DIR and handle create dir failures --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 8d9be333c..783ea9980 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -63,7 +63,7 @@ touch "incomplete" # Exit early if the snapshot filesystem doesn't support hard links, symlinks and # if rsync doesn't support hardlinking of dangling symlinks trap 'rm -rf src dest1 dest2' EXIT -mkdir src +mkdir -p src touch src/testfile if ! ln -s /data/does/not/exist/hooks/ src/ >/dev/null 2>&1; then echo "Error: the filesystem containing $GHE_DATA_DIR does not support symbolic links." 1>&2 From f2e8ca9d50aa5dadad10ee58de4638212aee65fb Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 25 May 2022 20:53:46 -0400 Subject: [PATCH 1486/2421] spelling: file Signed-off-by: Josh Soref --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index e180f8013..309644326 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -232,7 +232,7 @@ export GHE_SNAPSHOT_DIR # Set "true" to get verbose logging of all ssh commands on stderr : ${GHE_VERBOSE_SSH:=false} -# The location of the cluster configuration file file on the remote side. +# The location of the cluster configuration file on the remote side. # This is always "/data/user/common/cluster.conf" for GitHub Cluster instances. # Use of this variable allows the location to be overridden in tests. : ${GHE_REMOTE_CLUSTER_CONF_FILE:="$GHE_REMOTE_DATA_DIR/user/common/cluster.conf"} From 4109b5fd5afb37c0f0f84a1757f4794e23c9741d Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 25 May 2022 20:54:02 -0400 Subject: [PATCH 1487/2421] spelling: github Signed-off-by: Josh Soref --- bin/ghe-host-check | 2 +- share/github-backup-utils/ghe-backup-config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 4d934386c..fc418920e 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -53,7 +53,7 @@ port=$(ssh_port_part "$host") hostname=$(ssh_host_part "$host") set +e -# ghe-negotiate-version verifies if the target is a Github Enterprise Server instance +# ghe-negotiate-version verifies if the target is a GitHub Enterprise Server instance output=$(echo "ghe-negotiate-version backup-utils $BACKUP_UTILS_VERSION" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1) rc=$? set -e diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 309644326..b9271cf6b 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -335,7 +335,7 @@ ssh_host_part() { # rsync commands. ssh_port_part() { if [ "${1##*:}" != "$1" ] && [ "${1##*:}" -ne "122" ]; then - echo "Error: SSH port has to be 122 connecting to Github Enterprise Server, current value is ${1##*:} for $1." 1>&2 + echo "Error: SSH port has to be 122 connecting to GitHub Enterprise Server, current value is ${1##*:} for $1." 1>&2 exit 1 fi From 5e3193e34d88303b5dad98285ac9c1d27a4e9b66 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 25 May 2022 20:50:26 -0400 Subject: [PATCH 1488/2421] spelling: maintenance Signed-off-by: Josh Soref --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 30954c01a..b4db45e73 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -100,7 +100,7 @@ GitHub Actions enabled, the following steps are required: 1. Enable GitHub Actions on the replacement appliance and configure it to use the same GitHub Actions external storage configuration as the original appliance. -2. Put replacement appliance into maintaince mode. +2. Put replacement appliance into maintenance mode. 3. Use `ghe-restore` to restore the backup. 4. Re-register your self-hosted runners on the replacement appliance. From 65e3404ea0ed48b4c77398ec835bce67af63fd00 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 25 May 2022 20:50:27 -0400 Subject: [PATCH 1489/2421] spelling: packaging Signed-off-by: Josh Soref --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index 71dc31e39..a27194d4b 100755 --- a/script/release +++ b/script/release @@ -330,7 +330,7 @@ def clean_up(version) `git pull --quiet origin #{GH_BASE_BRANCH} --prune` `git branch --quiet -D release-#{version} >/dev/null 2>&1` `git push --quiet origin :release-#{version} >/dev/null 2>&1` - `git branch --quiet -D tmp-packging >/dev/null 2>&1` + `git branch --quiet -D tmp-packaging >/dev/null 2>&1` end #### All the action starts #### From 559716fae7556d5990c71e5f85c0b8af3c113a18 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 25 May 2022 20:53:30 -0400 Subject: [PATCH 1490/2421] spelling: that Signed-off-by: Josh Soref --- RELEASING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASING.md b/RELEASING.md index 0bcb66557..b54df7845 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -6,7 +6,7 @@ For example, Backup Utilities 2.13.0 can be used to backup and restore all patch There is no need to align Backup Utilities patch releases with GitHub Enterprise Server patch releases. -When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise Server that that release supports. +When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise Server that release supports. Only repo administrator is allowed to run the release script, otherwise it will fail. From a81400b8461c06271d5a3a474f2a76f51655dbc7 Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 25 May 2022 20:50:27 -0400 Subject: [PATCH 1491/2421] spelling: utilities Signed-off-by: Josh Soref --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index 94e5c5701..4f5427bda 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -67,7 +67,7 @@ be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapsh Using multiple backup hosts or backup configurations is not currently recommended. -Due to how some components of Backup Utiltiies (e.g. MSSQL) take incremental backups, running another instance of Backup Utilities may result in unrestorable snapshots as data may be split across backup hosts. If you still wish to have multiple instances of Backup Utilties for redundancy purposes or to run at different frequencies, ensure that they share the same `GHE_DATA_DIR` backup directory. +Due to how some components of Backup Utilities (e.g. MSSQL) take incremental backups, running another instance of Backup Utilities may result in unrestorable snapshots as data may be split across backup hosts. If you still wish to have multiple instances of Backup Utilities for redundancy purposes or to run at different frequencies, ensure that they share the same `GHE_DATA_DIR` backup directory. [1]: https://www.gnu.org/software/bash/ [2]: https://git-scm.com/ From e40faede00a831eaa9c5e490838eef076bcbf1dc Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Wed, 25 May 2022 20:50:28 -0400 Subject: [PATCH 1492/2421] spelling: variables Signed-off-by: Josh Soref --- STYLEGUIDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index f2f6c8782..9c1fc1e86 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -165,7 +165,7 @@ rsync /data/user/db remote:/data/user/db --- ##### Use lowercase and uppercase variable names -Use lowercase variables for locals and internal veriables, and uppercase for variables inherited or exported via the environment +Use lowercase variables for locals and internal variables, and uppercase for variables inherited or exported via the environment ```bash #!/usr/bin/env bash From 167bd728efaf687ca32b032076b1acc9424ac40c Mon Sep 17 00:00:00 2001 From: alejndr0 Date: Fri, 27 May 2022 11:02:22 +0000 Subject: [PATCH 1493/2421] Updates test-ghe-host-check fix quotes debug curl Update dependencies replace curl with wget fix spellcheck update test --- .github/workflows/main.yml | 4 ++-- test/test-ghe-host-check.sh | 39 +++++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d880d33dd..e4bad3bd5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,14 +13,14 @@ jobs: - name: Install Dependencies (Linux) run: | sudo apt-get update -y - sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man + sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man wget wget "https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-latest.linux.x86_64.tar.xz" sudo cp shellcheck-latest/shellcheck /usr/bin/shellcheck if: matrix.os != 'macos-latest' - name: Install Dependencies (macOS) run: | - brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt + brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt wget brew install moreutils gawk if: matrix.os == 'macos-latest' - name: Get Sources diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 8ac5970f0..6b5721175 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -54,21 +54,40 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions set -e # shellcheck disable=SC2046 # Word splitting is required to populate the variables read -r bu_version_major bu_version_minor _ <<<$(ghe_parse_version $BACKUP_UTILS_VERSION) - + bu_major_minor="$bu_version_major.$bu_version_minor" + releases=$(wget -qO- https://github-enterprise.s3.amazonaws.com/release/latest.json) + supported=$(echo $releases | jq -r 'select(."'${bu_major_minor}'")') + # shellcheck disable=SC2207 # Command required as alternatives fail + keys=($(echo $releases | jq -r 'keys[]')) + + if [ -z "$supported" ] + then + #BACKUP_UTILS_VERSION WAS NOT FOUND IN LATEST.JSON, CHECK IF ITS GREATER THAN LAST VERSION + if [ "$(version $bu_major_minor)" -ge "$(version ${keys[$((${#keys[@]} - 2 ))]})" ]; then + GHE_TEST_REMOTE_VERSION="$bu_major_minor.0" ghe-host-check + GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]} - 2 ))]}.0" ghe-host-check + GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]} - 3 ))]}.0" ghe-host-check + fi + else + #BACKUP_UTILS_VERSION WAS FOUND IN LATEST.JSON + ix=0 + for i in "${keys[@]}";do + if [ "$i" == "$bu_major_minor" ];then + break + fi + ix=$(( $ix + 1 )) + done + GHE_TEST_REMOTE_VERSION="${keys[$ix]}.0" ghe-host-check + GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 1 ))]}.0" ghe-host-check + GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 2 ))]}.0" ghe-host-check + + fi ! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check - # hardcode until https://github.com/github/backup-utils/issues/675 is resolved - ! GHE_TEST_REMOTE_VERSION=2.20.0 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=2.21.0 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=2.22.0 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=3.0.0 ghe-host-check - ! GHE_TEST_REMOTE_VERSION=3.1.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=3.2.0 ghe-host-check - GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check - GHE_TEST_REMOTE_VERSION=$BACKUP_UTILS_VERSION ghe-host-check GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999gm1 ghe-host-check ! GHE_TEST_REMOTE_VERSION=3.9999.1521793591.performancetest ghe-host-check GHE_TEST_REMOTE_VERSION=$((bu_version_major+1)).0.0 ghe-host-check + ) end_test From b78590dc9637ae19c9c9d848fd7ed9dce6db446d Mon Sep 17 00:00:00 2001 From: alejndr0 Date: Tue, 31 May 2022 08:19:17 +0000 Subject: [PATCH 1494/2421] replace wget with curl --- .github/workflows/main.yml | 2 +- test/test-ghe-host-check.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e4bad3bd5..f10f64e5e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: - name: Install Dependencies (Linux) run: | sudo apt-get update -y - sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man wget + sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man wget "https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-latest.linux.x86_64.tar.xz" sudo cp shellcheck-latest/shellcheck /usr/bin/shellcheck diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 6b5721175..6bfa12a69 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -55,7 +55,7 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions # shellcheck disable=SC2046 # Word splitting is required to populate the variables read -r bu_version_major bu_version_minor _ <<<$(ghe_parse_version $BACKUP_UTILS_VERSION) bu_major_minor="$bu_version_major.$bu_version_minor" - releases=$(wget -qO- https://github-enterprise.s3.amazonaws.com/release/latest.json) + releases=$(/usr/bin/curl -s https://github-enterprise.s3.amazonaws.com/release/latest.json) supported=$(echo $releases | jq -r 'select(."'${bu_major_minor}'")') # shellcheck disable=SC2207 # Command required as alternatives fail keys=($(echo $releases | jq -r 'keys[]')) From 20db671238089abd45ac32d4ef468639fee273ac Mon Sep 17 00:00:00 2001 From: Joel Ambass Date: Thu, 16 Jun 2022 07:01:21 +0000 Subject: [PATCH 1495/2421] Only Start Actions if they have been Stopped This patch adds a check to guard the starting of actions to only happen if we actually reached the step where we stop actions. Closes https://github.com/github/backup-utils/issues/859 --- bin/ghe-restore | 8 +++++++- test/test-ghe-restore.sh | 19 +++++++++++++++++++ test/testlib.sh | 6 ++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d5cb872a2..c06f85071 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -104,7 +104,7 @@ cleanup () { update_restore_status "$1" fi - if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Restarting Actions after restore ..." # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists @@ -161,6 +161,9 @@ hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :) # Show usage with no [ -z "$GHE_HOSTNAME" ] && print_usage +# Flag to indicate if this script has stopped Actions. +ACTIONS_STOPPED=false + # ghe-restore-snapshot-path validates it exists, determines what current is, # and if there's any problem, exit for us GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" @@ -399,6 +402,9 @@ fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Stopping Actions before restoring databases ..." + # We mark Actions as stopped even if the `ghe-actions-stop` + # fails to ensure that we cleanly start actions when performing cleanup. + ACTIONS_STOPPED=true ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 echo "Restoring MSSQL databases ..." diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 6a202f1d3..2e9ee3b12 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -410,6 +410,25 @@ begin_test "ghe-restore stops and starts Actions" echo "$output" | grep -q "ghe-actions-stop .* OK" echo "$output" | grep -q "ghe-actions-start .* OK" ) +end_test + +begin_test "ghe-restore does not attempt to start Actions during cleanup if they never have been stopped" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + setup_maintenance_mode "configured" + # We are not in maintance mode which means that we don't stop Actions and abort early. + disable_maintenance_mode + + ! output=$(ghe-restore -v -f localhost 2>&1) + + ! echo "$output" | grep -q "ghe-actions-stop" + ! echo "$output" | grep -q "ghe-actions-start" +) +end_test begin_test "ghe-restore with Actions data" ( diff --git a/test/testlib.sh b/test/testlib.sh index f19fc9649..74fe6faec 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -120,6 +120,12 @@ setup_maintenance_mode () { mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" } +# Moves the instance out of maintenance mode. +disable_maintenance_mode () { + # Remove file used to determine if instance is in maintenance mode. + rm "$GHE_REMOTE_DATA_DIR/github/current/public/system/maintenance.html" +} + # Mark the beginning of a test. A subshell should immediately follow this # statement. begin_test () { From cc0fe1f85a486cca947c347870b6e3c357e1bd18 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Fri, 17 Jun 2022 09:38:14 +0000 Subject: [PATCH 1496/2421] GHE Kredz related --- share/github-backup-utils/ghe-backup-settings | 3 ++- share/github-backup-utils/ghe-restore-actions | 3 ++- test/test-ghe-backup.sh | 6 ++++-- test/test-ghe-restore.sh | 6 ++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index d4ef7d019..49570ff0c 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -102,7 +102,6 @@ if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" backup-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" - backup-secret "Actions Launch credz HMAC key" "actions-launch-credz-hmac" "secrets.launch.credz-hmac-secret" backup-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" backup-secret "Actions Launch Client id" "actions-launch-client-id" "secrets.launch.client-id" backup-secret "Actions Launch Client secret" "actions-launch-client-secret" "secrets.launch.client-secret" @@ -114,6 +113,8 @@ if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then backup-secret "Actions Launch action runner secret" "actions-launch-action-runner-secret" "secrets.launch.action-runner-secret" backup-secret "Actions Launch service cert" "actions-launch-azp-app-cert" "secrets.launch.azp-app-cert" backup-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" + + backup-secret "Kredz credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" fi if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 62832b24f..dbab46738 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -70,7 +70,6 @@ restore-secret "Actions service principal cert" "actions-service-principal-cert" restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" restore-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" -restore-secret "Actions Launch credz HMAC key" "actions-launch-credz-hmac" "secrets.launch.credz-hmac-secret" restore-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" restore-secret "Actions Launch Client id" "actions-launch-client-id" "secrets.launch.client-id" restore-secret "Actions Launch Client secret" "actions-launch-client-secret" "secrets.launch.client-secret" @@ -86,6 +85,8 @@ restore-secret "Actions Launch service private key" "actions-launch-app-app-priv restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" "secrets.launch.token-oauth-key" restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert" +restore-secret "Kredz credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" + # Setup the database logins. ghe_verbose "* Restoring database logins and users to $host ..." diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index bd0e63a3f..6ae1a3533 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -493,7 +493,6 @@ begin_test "ghe-backup takes backup of Actions settings" "secrets.actions.SpsValidationCertThumbprint" "secrets.launch.actions-secrets-private-key" - "secrets.launch.credz-hmac-secret" "secrets.launch.deployer-hmac-secret" "secrets.launch.client-id" "secrets.launch.client-secret" @@ -507,6 +506,8 @@ begin_test "ghe-backup takes backup of Actions settings" "secrets.launch.token-oauth-cert" "secrets.launch.azp-app-cert" "secrets.launch.azp-app-private-key" + + "secrets.kredz.credz-hmac-secret" ) # these 5 were removed in later versions, so we extract them as best effort @@ -538,7 +539,6 @@ begin_test "ghe-backup takes backup of Actions settings" "actions-sps-validation-cert-thumbprint" "actions-launch-secrets-private-key" - "actions-launch-credz-hmac" "actions-launch-deployer-hmac" "actions-launch-client-id" "actions-launch-client-secret" @@ -550,6 +550,8 @@ begin_test "ghe-backup takes backup of Actions settings" "actions-launch-action-runner-secret" "actions-launch-azp-app-cert" "actions-launch-app-app-private-key" + + "kredz-credz-hmac" ) # Add the one optional file we included tests for diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 6a202f1d3..3152f9de6 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -335,7 +335,6 @@ begin_test "ghe-restore with Actions settings" "actions-sps-validation-cert-thumbprint" "actions-launch-secrets-private-key" - "actions-launch-credz-hmac" "actions-launch-deployer-hmac" "actions-launch-client-id" "actions-launch-client-secret" @@ -347,6 +346,8 @@ begin_test "ghe-restore with Actions settings" "actions-launch-action-runner-secret" "actions-launch-azp-app-cert" "actions-launch-app-app-private-key" + + "kredz-credz-hmac" ) for file in "${required_files[@]}"; do @@ -374,7 +375,6 @@ begin_test "ghe-restore with Actions settings" "secrets.actions.SpsValidationCertThumbprint" "secrets.launch.actions-secrets-private-key" - "secrets.launch.credz-hmac-secret" "secrets.launch.deployer-hmac-secret" "secrets.launch.client-id" "secrets.launch.client-secret" @@ -388,6 +388,8 @@ begin_test "ghe-restore with Actions settings" "secrets.launch.token-oauth-cert" "secrets.launch.azp-app-cert" "secrets.launch.azp-app-private-key" + + "secrets.kredz.credz-hmac-secret" ) for secret in "${required_secrets[@]}"; do From 7e2f77d115fc8885cb12d7258cee2c807677e73e Mon Sep 17 00:00:00 2001 From: Matt Burke Date: Fri, 17 Jun 2022 08:20:02 -0400 Subject: [PATCH 1497/2421] Use spokesctl instead of dgit-cluster-restore-routes --- share/github-backup-utils/ghe-restore-repositories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 5938a55eb..ce9a26030 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -120,7 +120,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring network list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | github-env ./bin/dgit-cluster-restore-routes | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | ghe-spokesctl backup-utils restore-routes | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" From 79e18f75add2f53e2b6b21ebe7f89eab080b10a5 Mon Sep 17 00:00:00 2001 From: Matt Burke Date: Tue, 21 Jun 2022 09:36:17 -0400 Subject: [PATCH 1498/2421] Let the GHES instance decide how to restore routes --- share/github-backup-utils/ghe-restore-repositories | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index ce9a26030..b1fcf5386 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -120,7 +120,7 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring network list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | ghe-spokesctl backup-utils restore-routes | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +echo "cat $remote_tmp_list | /usr/local/share/enterprise/ghe-restore-network-routes | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" From cb62ad128417d78a7360cee5304e102c4db61ab1 Mon Sep 17 00:00:00 2001 From: Matt Burke Date: Wed, 22 Jun 2022 15:03:29 -0400 Subject: [PATCH 1499/2421] Use ghe-restore-network-routes, if it's available Otherwise, dgit-cluster-restore-routes the old way. --- share/github-backup-utils/ghe-restore-repositories | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index b1fcf5386..f56454ce9 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -120,7 +120,11 @@ cat $tmp_list | ghe_debug bm_end "$(basename $0) - Transferring network list" bm_start "$(basename $0) - Generating routes" -echo "cat $remote_tmp_list | /usr/local/share/enterprise/ghe-restore-network-routes | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash +restore_routes_script="github-env ./bin/dgit-cluster-restore-routes" +if ghe-ssh "$GHE_HOSTNAME" test -e /usr/local/share/enterprise/ghe-restore-network-routes; then + restore_routes_script="/usr/local/share/enterprise/ghe-restore-network-routes" +fi +echo "cat $remote_tmp_list | $restore_routes_script | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug bm_end "$(basename $0) - Generating routes" From b408e20e2ce4aeea6742d1652c2748417ca7f73a Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Thu, 28 Jul 2022 15:27:33 +0000 Subject: [PATCH 1500/2421] backup --- share/github-backup-utils/ghe-backup-settings | 3 +-- share/github-backup-utils/ghe-restore-actions | 1 - .../github-backup-utils/ghe-restore-settings | 1 + test/test-ghe-backup.sh | 27 +++++++++++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 49570ff0c..162409b17 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -76,6 +76,7 @@ backup-secret() { backup-secret "management console password" "manage-password" "secrets.manage" backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" +backup-secret "Kredz credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" # Backup external MySQL password if running external MySQL DB. if is_service_external 'mysql'; then @@ -113,8 +114,6 @@ if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then backup-secret "Actions Launch action runner secret" "actions-launch-action-runner-secret" "secrets.launch.action-runner-secret" backup-secret "Actions Launch service cert" "actions-launch-azp-app-cert" "secrets.launch.azp-app-cert" backup-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" - - backup-secret "Kredz credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" fi if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index dbab46738..fa9541137 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -85,7 +85,6 @@ restore-secret "Actions Launch service private key" "actions-launch-app-app-priv restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" "secrets.launch.token-oauth-key" restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert" -restore-secret "Kredz credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" # Setup the database logins. ghe_verbose "* Restoring database logins and users to $host ..." diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 63dc7aa45..ccd36689a 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -40,6 +40,7 @@ restore-secret "external MySQL password" "external-mysql-password" "secrets.exte # Restore management console password hash if present. restore-secret "management console password" "manage-password" "secrets.manage" +restore-secret "Kredz credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6ae1a3533..0ece437b8 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -470,6 +470,31 @@ begin_test "ghe-backup upgrades transaction backup to full if LSN chain break" ) end_test +begin_test "ghe-backup takes backup of Kredz settings" +( + set -e + + required_secrets=( + "secrets.kredz.credz-hmac-secret" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + ghe-backup + + required_files=( + "kredz-credz-hmac" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done + +) +end_test + begin_test "ghe-backup takes backup of Actions settings" ( set -e @@ -507,7 +532,6 @@ begin_test "ghe-backup takes backup of Actions settings" "secrets.launch.azp-app-cert" "secrets.launch.azp-app-private-key" - "secrets.kredz.credz-hmac-secret" ) # these 5 were removed in later versions, so we extract them as best effort @@ -551,7 +575,6 @@ begin_test "ghe-backup takes backup of Actions settings" "actions-launch-azp-app-cert" "actions-launch-app-app-private-key" - "kredz-credz-hmac" ) # Add the one optional file we included tests for From aadb8b955d3e9636bebb41397a716435f1be1668 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Thu, 28 Jul 2022 17:39:56 +0000 Subject: [PATCH 1501/2421] restore 1 --- .../github-backup-utils/ghe-restore-settings | 4 ++- test/test-ghe-restore.sh | 28 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index ccd36689a..f3bf7cb9b 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -40,7 +40,9 @@ restore-secret "external MySQL password" "external-mysql-password" "secrets.exte # Restore management console password hash if present. restore-secret "management console password" "manage-password" "secrets.manage" -restore-secret "Kredz credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" + +# Restore kredz.credz HMAC key if present. +restore-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 3152f9de6..6b6da2548 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -309,6 +309,32 @@ begin_test "ghe-restore invokes ghe-import-mssql" ) end_test +begin_test "ghe-restore with Kredz settings" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + required_files=( + "kredz-credz-hmac" + ) + + for file in "${required_files[@]}"; do + echo "foo" > "$GHE_DATA_DIR/current/$file" + done + + ghe-restore -v -f localhost + required_secrets=( + "secrets.kredz.credz-hmac-secret" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done +) +end_test + begin_test "ghe-restore with Actions settings" ( set -e @@ -347,7 +373,6 @@ begin_test "ghe-restore with Actions settings" "actions-launch-azp-app-cert" "actions-launch-app-app-private-key" - "kredz-credz-hmac" ) for file in "${required_files[@]}"; do @@ -389,7 +414,6 @@ begin_test "ghe-restore with Actions settings" "secrets.launch.azp-app-cert" "secrets.launch.azp-app-private-key" - "secrets.kredz.credz-hmac-secret" ) for secret in "${required_secrets[@]}"; do From 634d313c8c64bbf1b0612734eadc25980ce43ea0 Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 28 Jul 2022 21:01:39 -0700 Subject: [PATCH 1502/2421] Update Dockerfile to bullseye --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 00067263c..94d461c46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:stretch-slim +FROM debian:bullseye-slim RUN apt-get -q -y update && \ apt-get install -y --no-install-recommends \ From 3b081203481042bd7b07be0d7cd9a477259ca854 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Fri, 29 Jul 2022 09:39:44 +0530 Subject: [PATCH 1503/2421] Update ghe-backup-settings --- share/github-backup-utils/ghe-backup-settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 162409b17..1fbbb55f6 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -76,7 +76,7 @@ backup-secret() { backup-secret "management console password" "manage-password" "secrets.manage" backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" -backup-secret "Kredz credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" +backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" # Backup external MySQL password if running external MySQL DB. if is_service_external 'mysql'; then From 69242c087c6825a15c94a750870beb9d9744b84f Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 28 Jul 2022 21:11:43 -0700 Subject: [PATCH 1504/2421] Use preferred v3 checkout Action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f10f64e5e..df25ff87e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,7 @@ jobs: brew install moreutils gawk if: matrix.os == 'macos-latest' - name: Get Sources - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Test run: | export PATH="$PATH:/snap/bin" From e0e257e96fe35d824452a88c395e94ce62539fa6 Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 28 Jul 2022 21:13:49 -0700 Subject: [PATCH 1505/2421] Bump actions versions --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4a38ba869..5629c6abd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,8 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Lint Code Base - uses: docker://github/super-linter:v2.1.1 + uses: github/super-linter@v4 env: VALIDATE_ALL_CODEBASE: false From 0db5bc546987ea90f6058d1a64a3a707fab76254 Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 28 Jul 2022 21:16:54 -0700 Subject: [PATCH 1506/2421] Enable Dependabot for Actions and Docker ecosystems --- .github/dependabot.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..fab2f101d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "docker" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + + - package-ecosystem: "github-actions" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From f17c9c7a078c49cdef2bc1d2e325bf8e3b6e378e Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 2 Aug 2022 16:30:51 -0700 Subject: [PATCH 1507/2421] Add a Docker build and test Action --- .github/workflows/docker-image.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 000000000..71396f736 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,24 @@ +name: Docker Image CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build-docker: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Debian Docker image + run: docker build . --file Dockerfile --tag backup-utils-debian:$(date +%s) + - name: Build the Alpine Docker image + run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:$(date +%s) + - name: Run tests in Debian Docker image + run: docker run -it backup-utils-debian:$(date +%s) make test + - name: Run tests in Alpine Docker image + run: docker run -it backup-utils-alpine:$(date +%s) make test From 5aa5ab972608aaaeeea9bd90f0d2a0ff82ecf2e1 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 2 Aug 2022 16:35:03 -0700 Subject: [PATCH 1508/2421] Add ubuntu-22.04 runner to Actions Matrix The new runner version is going GA https://github.com/actions/virtual-environments/issues/5998 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f10f64e5e..db7b90db6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ jobs: build: strategy: matrix: - os: ['ubuntu-20.04', 'ubuntu-18.04', 'macos-latest'] + os: ['ubuntu-22.04', 'ubuntu-20.04', 'ubuntu-18.04', 'macos-latest'] fail-fast: false runs-on: ${{ matrix.os }} steps: From 7c01a409c1a03f198ac0af7d243e8312bd0652c0 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 2 Aug 2022 20:44:17 -0700 Subject: [PATCH 1509/2421] non-interactive --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 71396f736..a176df872 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -19,6 +19,6 @@ jobs: - name: Build the Alpine Docker image run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:$(date +%s) - name: Run tests in Debian Docker image - run: docker run -it backup-utils-debian:$(date +%s) make test + run: docker run backup-utils-debian:$(date +%s) script/cibuild --no-package - name: Run tests in Alpine Docker image - run: docker run -it backup-utils-alpine:$(date +%s) make test + run: docker run backup-utils-alpine:$(date +%s) script/cibuild --no-package From 0e15f56dcdb927372a9710c9653ba23e809cd4a3 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 2 Aug 2022 20:54:29 -0700 Subject: [PATCH 1510/2421] tag with run id instead of date --- .github/workflows/docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a176df872..45878c64c 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build the Debian Docker image - run: docker build . --file Dockerfile --tag backup-utils-debian:$(date +%s) + run: docker build . --file Dockerfile --tag backup-utils-debian:${{ env. GITHUB_RUN_ID }} - name: Build the Alpine Docker image - run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:$(date +%s) + run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${{ env. GITHUB_RUN_ID }} - name: Run tests in Debian Docker image - run: docker run backup-utils-debian:$(date +%s) script/cibuild --no-package + run: docker run backup-utils-debian:${{ env. GITHUB_RUN_ID }} script/cibuild --no-package - name: Run tests in Alpine Docker image - run: docker run backup-utils-alpine:$(date +%s) script/cibuild --no-package + run: docker run backup-utils-alpine:${{ env. GITHUB_RUN_ID }} script/cibuild --no-package From 58698235166cee33a2d33bb135b1bc8f73e1ea74 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 2 Aug 2022 20:56:19 -0700 Subject: [PATCH 1511/2421] fix syntax issue --- .github/workflows/docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 45878c64c..0acc6471c 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build the Debian Docker image - run: docker build . --file Dockerfile --tag backup-utils-debian:${{ env. GITHUB_RUN_ID }} + run: docker build . --file Dockerfile --tag backup-utils-debian:${GITHUB_RUN_ID} - name: Build the Alpine Docker image - run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${{ env. GITHUB_RUN_ID }} + run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID} - name: Run tests in Debian Docker image - run: docker run backup-utils-debian:${{ env. GITHUB_RUN_ID }} script/cibuild --no-package + run: docker run backup-utils-debian:${GITHUB_RUN_ID} script/cibuild --no-package - name: Run tests in Alpine Docker image - run: docker run backup-utils-alpine:${{ env. GITHUB_RUN_ID }} script/cibuild --no-package + run: docker run backup-utils-alpine:${GITHUB_RUN_ID} script/cibuild --no-package From 86037e4c46090366d8e95906795ca5df10d5fa14 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 2 Aug 2022 21:16:12 -0700 Subject: [PATCH 1512/2421] simple version check --- .github/workflows/docker-image.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0acc6471c..3904b1e6c 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -19,6 +19,7 @@ jobs: - name: Build the Alpine Docker image run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID} - name: Run tests in Debian Docker image - run: docker run backup-utils-debian:${GITHUB_RUN_ID} script/cibuild --no-package + run: docker run backup-utils-debian:${GITHUB_RUN_ID} ghe-backup --version - name: Run tests in Alpine Docker image - run: docker run backup-utils-alpine:${GITHUB_RUN_ID} script/cibuild --no-package + run: docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version + From 059eb5948be86e42f4a7c57cb7bf87ffc214b709 Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 4 Aug 2022 09:41:27 -0700 Subject: [PATCH 1513/2421] Buster to align with GHES --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 94d461c46..3b66b5020 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:bullseye-slim +FROM debian:buster-slim RUN apt-get -q -y update && \ apt-get install -y --no-install-recommends \ From d3125df10d827bd167f3ef14b78aa02dbe794a4e Mon Sep 17 00:00:00 2001 From: djdefi Date: Fri, 5 Aug 2022 09:57:42 -0700 Subject: [PATCH 1514/2421] Lint PRs --- .github/workflows/lint.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5629c6abd..3cc52f4a1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,9 +1,10 @@ name: Lint Code Base on: + push: + branches-ignore: [master] pull_request: - branches-ignore: - - 'master' + branches: [master] jobs: build: From 72857dcfcc7a24ed45651f14cad12f4aee4bba2f Mon Sep 17 00:00:00 2001 From: djdefi Date: Fri, 5 Aug 2022 10:13:16 -0700 Subject: [PATCH 1515/2421] Full history for linter --- .github/workflows/lint.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3cc52f4a1..d2599fbd1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,12 +7,15 @@ on: branches: [master] jobs: - build: + lint: name: Lint Code Base runs-on: ubuntu-latest steps: - name: Checkout Code uses: actions/checkout@v3 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 - name: Lint Code Base uses: github/super-linter@v4 env: From 3e4b93aebb607e20aaab49189b2b5949dffc3eba Mon Sep 17 00:00:00 2001 From: djdefi Date: Fri, 5 Aug 2022 10:22:40 -0700 Subject: [PATCH 1516/2421] Add token per linter docs --- .github/workflows/lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d2599fbd1..9d97805de 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,3 +20,4 @@ jobs: uses: github/super-linter@v4 env: VALIDATE_ALL_CODEBASE: false + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 079e1cceecb8453f35360717bb9edcc6eb57bf16 Mon Sep 17 00:00:00 2001 From: Luca Cavallin <14332663+lucavallin@users.noreply.github.com> Date: Mon, 8 Aug 2022 09:16:01 +0200 Subject: [PATCH 1517/2421] Stop restore when a backup without Actions is being restored onto an appliance with Actions enabled (#946) * throw error and abort when restoring a backup with Actions disabled onto an appliance with Actions enabled * set ACTIONS_ENABLED_IN_BACKUP to false if the value is not found in settings.json * use git config to grab app.actions.enabled directly * add bash function to enable and disable actions in settings.json * enable actions in settings for part of other tests that require it * use git config to set initial value for actions in settings.json * empty settings.json before using git config --- bin/ghe-restore | 8 ++++++++ test/test-ghe-restore.sh | 15 +++++++++++++++ test/testlib.sh | 8 ++++++++ 3 files changed, 31 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index c06f85071..42fe6cd57 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -285,6 +285,14 @@ fi # Get GHES release version in major.minor format RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2) +# If the backup being restored is from an appliance with Actions disabled, restoring it onto an appliance with Actions enabled will cause +# mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace +ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) +if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + echo "Error: Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 + exit 1 +fi + # Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data. # If above is true, also check if ac is present in appliance then snapshot should also contains ac databases if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 2e9ee3b12..6bef6bdc7 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -6,6 +6,7 @@ . "$(dirname "$0")/testlib.sh" setup_test_data "$GHE_DATA_DIR/1" +setup_actions_enabled_settings_for_restore true # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" @@ -700,3 +701,17 @@ end_test # verify_all_restored_data # ) # end_test + +begin_test "ghe-restore fails if Actions is disabled in the backup but enabled on the appliance" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + setup_actions_enabled_settings_for_restore false + enable_actions + + setup_maintenance_mode "configured" + + ! ghe-restore -v -f localhost +) +end_test diff --git a/test/testlib.sh b/test/testlib.sh index 74fe6faec..32b57579e 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -594,3 +594,11 @@ cleanup_moreutils_parallel() { unlink "$ROOTDIR/test/bin/parallel" fi } + +# setup_actions_enabled_in_settings_json writes settings for the Actions app to settings.json +# it accepts true or false as first argument to enable or disable actions in settings.json +setup_actions_enabled_settings_for_restore() { + # Empty the file, it now contains "fake ghe-export-settings data" + echo > "$GHE_DATA_DIR/1/settings.json" + git config -f "$GHE_DATA_DIR/1/settings.json" --bool app.actions.enabled $1 +} From f83c3eaa129a3eb1c217232d700e1606ccb84452 Mon Sep 17 00:00:00 2001 From: Joseph Franks Date: Wed, 17 Aug 2022 19:20:54 +0000 Subject: [PATCH 1518/2421] Bump version: 3.6.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 4d934386c..1f8a51847 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -131,7 +131,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.3.0" +supported_minimum_version="3.4.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 3cf6c0d25..bf6ca9e03 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.6.0) UNRELEASED; urgency=medium + + + -- Joe Franks Wed, 17 Aug 2022 19:20:54 +0000 + github-backup-utils (3.5.0) UNRELEASED; urgency=medium * Simplify complex redirects for ghe-rsync #881 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 1545d9665..40c341bdc 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.5.0 +3.6.0 diff --git a/test/testlib.sh b/test/testlib.sh index 32b57579e..64f00e0f6 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.5.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.6.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 96f735f161aedb969fd8b739453e74327477c15d Mon Sep 17 00:00:00 2001 From: Tyler Chong Date: Fri, 19 Aug 2022 12:45:55 -1000 Subject: [PATCH 1519/2421] refactor: ghe-cluster-each --print, --ip, --uuid flags --- share/github-backup-utils/ghe-cluster-nodes | 2 +- test/bin/ghe-cluster-each | 33 ++----------------- test/bin/ghe-cluster-nodes | 35 +++++++++++++++++++++ 3 files changed, 38 insertions(+), 32 deletions(-) create mode 100755 test/bin/ghe-cluster-nodes diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index a4d29247b..43e7416ee 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -28,7 +28,7 @@ prefix="$2" role=$(echo "$prefix" | cut -d '-' -f1) if ghe-ssh "$GHE_HOSTNAME" test -f $GHE_REMOTE_ROOT_DIR/etc/github/cluster; then - node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -u) + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" /usr/local/bin/ghe-cluster-nodes -r "$role" -u | cut -f 2) hostnames='' for uuid in $node_uuids; do hostnames+="$prefix-$uuid " diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index a7673f632..e503f2806 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -1,21 +1,11 @@ #!/usr/bin/env bash -# Usage: ghe-config -# Emulates the remote GitHub ghe-config command. Tests use this +# Usage: ghe-cluster-each +# Emulates the remote GitHub ghe-cluster-each command. Tests use this # to assert that the command was executed. set -e for _ in "$@"; do case "$1" in - -u) - SHOW_UUID=true - shift - ;; - -r|--role) - # fake change last save timestamp every 1s - ROLE=$2 - shift - shift - ;; --) if [ "$1" = "--" ]; then shift @@ -43,22 +33,3 @@ if [ "$COMMAND" == "/usr/local/share/enterprise/ghe-nomad-cleanup" ]; then echo "nomad cleanup" exit 0 fi - -if $SHOW_UUID; then - CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" - - hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) - - if [ -z "$hosts" ]; then - # Mimic `ghe-cluster-each $role -u` - echo "fake-uuid - fake-uuid1 - fake-uuid2 - " - else - for hostname in $hosts; do - [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue - echo $hostname - done - fi -fi \ No newline at end of file diff --git a/test/bin/ghe-cluster-nodes b/test/bin/ghe-cluster-nodes new file mode 100755 index 000000000..b43604145 --- /dev/null +++ b/test/bin/ghe-cluster-nodes @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Usage: ghe-cluster-nodes +# Emulates the remote GitHub ghe-cluster-nodes command. Tests use this +# to assert that the command was executed. +set -e + +for _ in "$@"; do + case "$1" in + -r|--role) + MATCH_ROLE=$2 + shift + ;; + -u|--uuid) + PRINT_UUIDS=true + shift + ;; + esac +done + +CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" + +hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) + +for hostname in $hosts; do + [ -n "$MATCH_ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$MATCH_ROLE-server)" != "true" ] && continue + + print_line="$hostname" + + if [ -n "$PRINT_UUIDS" ]; then + uuid="$(ghe-config cluster.$hostname.uuid || true)" + print_line="$print_line\t$uuid" + fi + + echo -e "${print_line#\\t}" +done From 56192d3037cfdf87bfa07839093e0cace3aa847f Mon Sep 17 00:00:00 2001 From: Tyler Chong Date: Tue, 23 Aug 2022 12:38:57 -1000 Subject: [PATCH 1520/2421] t --- share/github-backup-utils/ghe-cluster-nodes | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index 43e7416ee..d103d963d 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -28,6 +28,12 @@ prefix="$2" role=$(echo "$prefix" | cut -d '-' -f1) if ghe-ssh "$GHE_HOSTNAME" test -f $GHE_REMOTE_ROOT_DIR/etc/github/cluster; then + test_output=$(ghe-ssh "GHE_HOSTNAME" ls -lah /) + echo $test_output + + test_output=$(ghe-ssh "GHE_HOSTNAME" ls -lah /usr/local/bin) + echo $test_output + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" /usr/local/bin/ghe-cluster-nodes -r "$role" -u | cut -f 2) hostnames='' for uuid in $node_uuids; do From 7fee9a21beb172914661bab1b3148a4cc6544d41 Mon Sep 17 00:00:00 2001 From: Tyler Chong Date: Tue, 23 Aug 2022 12:40:54 -1000 Subject: [PATCH 1521/2421] t --- share/github-backup-utils/ghe-cluster-nodes | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-nodes index d103d963d..6dc596666 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-nodes @@ -34,6 +34,12 @@ if ghe-ssh "$GHE_HOSTNAME" test -f $GHE_REMOTE_ROOT_DIR/etc/github/cluster; then test_output=$(ghe-ssh "GHE_HOSTNAME" ls -lah /usr/local/bin) echo $test_output + test_output=$(ghe-ssh "GHE_HOSTNAME" whereis ghe-cluster-each) + echo $test_output + + test_output=$(ghe-ssh "GHE_HOSTNAME" whereis ghe-cluster-nodes) + echo $test_output + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" /usr/local/bin/ghe-cluster-nodes -r "$role" -u | cut -f 2) hostnames='' for uuid in $node_uuids; do From 58568a496ce5d2be0722d9ee6c924c4e93c10671 Mon Sep 17 00:00:00 2001 From: Tyler Chong Date: Tue, 23 Aug 2022 13:00:06 -1000 Subject: [PATCH 1522/2421] t --- share/github-backup-utils/ghe-backup-git-hooks | 2 +- share/github-backup-utils/ghe-backup-pages | 2 +- .../github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- ...{ghe-cluster-nodes => ghe-cluster-find-nodes} | 16 ++-------------- share/github-backup-utils/ghe-restore-git-hooks | 2 +- share/github-backup-utils/ghe-restore-pages | 2 +- .../github-backup-utils/ghe-restore-repositories | 2 +- .../ghe-restore-repositories-gist | 2 +- share/github-backup-utils/ghe-restore-storage | 2 +- ...r-nodes.sh => test-ghe-cluster-find-nodes.sh} | 10 +++++----- 11 files changed, 16 insertions(+), 28 deletions(-) rename share/github-backup-utils/{ghe-cluster-nodes => ghe-cluster-find-nodes} (71%) rename test/{test-ghe-cluster-nodes.sh => test-ghe-cluster-find-nodes.sh} (69%) diff --git a/share/github-backup-utils/ghe-backup-git-hooks b/share/github-backup-utils/ghe-backup-git-hooks index c7bd5429e..3229ee009 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks +++ b/share/github-backup-utils/ghe-backup-git-hooks @@ -43,7 +43,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index e6445c812..634e7a417 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -43,7 +43,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "pages-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 10e1e9239..1b711df37 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -74,7 +74,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index db49bc8e7..cbc05428c 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -47,7 +47,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "storage-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-find-nodes similarity index 71% rename from share/github-backup-utils/ghe-cluster-nodes rename to share/github-backup-utils/ghe-cluster-find-nodes index 6dc596666..c2a3cf0e1 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-find-nodes @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#/ Usage: ghe-cluster-nodes +#/ Usage: ghe-cluster-find-nodes #/ #/ Finds all nodes of the cluster using the config on . #/ If it is a 2.8 and later cluster version the results are returned as @@ -28,19 +28,7 @@ prefix="$2" role=$(echo "$prefix" | cut -d '-' -f1) if ghe-ssh "$GHE_HOSTNAME" test -f $GHE_REMOTE_ROOT_DIR/etc/github/cluster; then - test_output=$(ghe-ssh "GHE_HOSTNAME" ls -lah /) - echo $test_output - - test_output=$(ghe-ssh "GHE_HOSTNAME" ls -lah /usr/local/bin) - echo $test_output - - test_output=$(ghe-ssh "GHE_HOSTNAME" whereis ghe-cluster-each) - echo $test_output - - test_output=$(ghe-ssh "GHE_HOSTNAME" whereis ghe-cluster-nodes) - echo $test_output - - node_uuids=$(ghe-ssh "$GHE_HOSTNAME" /usr/local/bin/ghe-cluster-nodes -r "$role" -u | cut -f 2) + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -r "$role" -u | cut -f 2) hostnames='' for uuid in $node_uuids; do hostnames+="$prefix-$uuid " diff --git a/share/github-backup-utils/ghe-restore-git-hooks b/share/github-backup-utils/ghe-restore-git-hooks index b9c9555f0..67081a921 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks +++ b/share/github-backup-utils/ghe-restore-git-hooks @@ -42,7 +42,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 17f80ae79..800eb14d3 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -56,7 +56,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "pages-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index f56454ce9..3d522be0b 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -61,7 +61,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 946dbc50d..5080b964f 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -60,7 +60,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index a890ca741..408d0e237 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -60,7 +60,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $tempdir/ssh_config" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "storage-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-find-nodes.sh similarity index 69% rename from test/test-ghe-cluster-nodes.sh rename to test/test-ghe-cluster-find-nodes.sh index cdff8ad1e..20ce7fdbb 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-find-nodes.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# ghe-cluster-nodes command tests +# ghe-cluster-find-nodes command tests # Bring in testlib # shellcheck source=test/testlib.sh @@ -14,25 +14,25 @@ export GHE_DATA_DIR GHE_REMOTE_DATA_DIR mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" echo "fake-uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" -begin_test "ghe-cluster-nodes should return both uuids for git-server" +begin_test "ghe-cluster-find-nodes should return both uuids for git-server" ( set -e setup_remote_cluster - output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + output="$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server")" echo "$output" [ "git-server-fake-uuid git-server-fake-uuid1 git-server-fake-uuid2 " = "$output" ] ) end_test -begin_test "ghe-cluster-nodes should return one uuid for a single node" +begin_test "ghe-cluster-find-nodes should return one uuid for a single node" ( set -e # Ensure not a cluster rm -rf "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" - output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + output="$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server")" echo "$output" [ "git-server-fake-uuid" = "$output" ] ) From 5e2068e4bf4f73d002a01e63434af3e3b85d8874 Mon Sep 17 00:00:00 2001 From: donal Date: Thu, 8 Sep 2022 09:52:49 +1000 Subject: [PATCH 1523/2421] minor fixes --- test/bin/ghe-cluster-nodes | 2 +- test/test-ghe-backup.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/bin/ghe-cluster-nodes b/test/bin/ghe-cluster-nodes index b43604145..3dde1a884 100755 --- a/test/bin/ghe-cluster-nodes +++ b/test/bin/ghe-cluster-nodes @@ -7,7 +7,7 @@ set -e for _ in "$@"; do case "$1" in -r|--role) - MATCH_ROLE=$2 + ROLE=$2 shift ;; -u|--uuid) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 0ece437b8..f50963fd9 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -265,7 +265,7 @@ begin_test "ghe-backup cluster" if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then cat "$TRASHDIR/backup-out" - : ghe-restore should have exited successfully + : ghe-backup should have exited successfully false fi From 7307f1f46cea64c0b1175d047ea14c5930fb6ffd Mon Sep 17 00:00:00 2001 From: donal Date: Thu, 8 Sep 2022 10:02:43 +1000 Subject: [PATCH 1524/2421] return fake uuids when cluster.conf doesn't exist Or it's invalid, which it is for most of these tests. --- test/bin/ghe-cluster-nodes | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/test/bin/ghe-cluster-nodes b/test/bin/ghe-cluster-nodes index 3dde1a884..29e4beb3e 100755 --- a/test/bin/ghe-cluster-nodes +++ b/test/bin/ghe-cluster-nodes @@ -21,15 +21,21 @@ CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) -for hostname in $hosts; do - [ -n "$MATCH_ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$MATCH_ROLE-server)" != "true" ] && continue +if $PRINT_UUIDS; then + CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" - print_line="$hostname" + hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) - if [ -n "$PRINT_UUIDS" ]; then - uuid="$(ghe-config cluster.$hostname.uuid || true)" - print_line="$print_line\t$uuid" - fi - - echo -e "${print_line#\\t}" -done + if [ -z "$hosts" ]; then + # Mimic `ghe-cluster-each $role -u` + echo "fake-uuid + fake-uuid1 + fake-uuid2 + " + else + for hostname in $hosts; do + [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue + echo $hostname + done + fi +fi From 36003ea776cb45a853164c167260fc8abc7e5a6f Mon Sep 17 00:00:00 2001 From: Tyler Chong Date: Thu, 8 Sep 2022 12:41:33 -1000 Subject: [PATCH 1525/2421] refactor: ghe-cluster-each --print, --ip, --uuid flags --- .../github-backup-utils/ghe-backup-git-hooks | 2 +- share/github-backup-utils/ghe-backup-pages | 2 +- .../ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- ...e-cluster-nodes => ghe-cluster-find-nodes} | 4 +- .../github-backup-utils/ghe-restore-git-hooks | 2 +- share/github-backup-utils/ghe-restore-pages | 2 +- .../ghe-restore-repositories | 2 +- .../ghe-restore-repositories-gist | 2 +- share/github-backup-utils/ghe-restore-storage | 2 +- test/bin/ghe-cluster-each | 33 +-------------- test/bin/ghe-cluster-nodes | 41 +++++++++++++++++++ test/test-ghe-backup.sh | 2 +- ...odes.sh => test-ghe-cluster-find-nodes.sh} | 10 ++--- 14 files changed, 60 insertions(+), 48 deletions(-) rename share/github-backup-utils/{ghe-cluster-nodes => ghe-cluster-find-nodes} (89%) create mode 100644 test/bin/ghe-cluster-nodes rename test/{test-ghe-cluster-nodes.sh => test-ghe-cluster-find-nodes.sh} (69%) diff --git a/share/github-backup-utils/ghe-backup-git-hooks b/share/github-backup-utils/ghe-backup-git-hooks index c7bd5429e..3229ee009 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks +++ b/share/github-backup-utils/ghe-backup-git-hooks @@ -43,7 +43,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index e6445c812..634e7a417 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -43,7 +43,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "pages-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 5185f63d9..35b751b12 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -74,7 +74,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 67517512b..bb8117021 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -47,7 +47,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "storage-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-cluster-nodes b/share/github-backup-utils/ghe-cluster-find-nodes similarity index 89% rename from share/github-backup-utils/ghe-cluster-nodes rename to share/github-backup-utils/ghe-cluster-find-nodes index a4d29247b..c2a3cf0e1 100755 --- a/share/github-backup-utils/ghe-cluster-nodes +++ b/share/github-backup-utils/ghe-cluster-find-nodes @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#/ Usage: ghe-cluster-nodes +#/ Usage: ghe-cluster-find-nodes #/ #/ Finds all nodes of the cluster using the config on . #/ If it is a 2.8 and later cluster version the results are returned as @@ -28,7 +28,7 @@ prefix="$2" role=$(echo "$prefix" | cut -d '-' -f1) if ghe-ssh "$GHE_HOSTNAME" test -f $GHE_REMOTE_ROOT_DIR/etc/github/cluster; then - node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-each -r "$role" -u) + node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -r "$role" -u | cut -f 2) hostnames='' for uuid in $node_uuids; do hostnames+="$prefix-$uuid " diff --git a/share/github-backup-utils/ghe-restore-git-hooks b/share/github-backup-utils/ghe-restore-git-hooks index b9c9555f0..67081a921 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks +++ b/share/github-backup-utils/ghe-restore-git-hooks @@ -42,7 +42,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 17f80ae79..800eb14d3 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -56,7 +56,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "pages-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "pages-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 5938a55eb..b42193cf7 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -61,7 +61,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 946dbc50d..5080b964f 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -60,7 +60,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index a890ca741..408d0e237 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -60,7 +60,7 @@ if $CLUSTER; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $tempdir/ssh_config" opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-nodes "$GHE_HOSTNAME" "storage-server") + hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "storage-server") ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi diff --git a/test/bin/ghe-cluster-each b/test/bin/ghe-cluster-each index a7673f632..e503f2806 100755 --- a/test/bin/ghe-cluster-each +++ b/test/bin/ghe-cluster-each @@ -1,21 +1,11 @@ #!/usr/bin/env bash -# Usage: ghe-config -# Emulates the remote GitHub ghe-config command. Tests use this +# Usage: ghe-cluster-each +# Emulates the remote GitHub ghe-cluster-each command. Tests use this # to assert that the command was executed. set -e for _ in "$@"; do case "$1" in - -u) - SHOW_UUID=true - shift - ;; - -r|--role) - # fake change last save timestamp every 1s - ROLE=$2 - shift - shift - ;; --) if [ "$1" = "--" ]; then shift @@ -43,22 +33,3 @@ if [ "$COMMAND" == "/usr/local/share/enterprise/ghe-nomad-cleanup" ]; then echo "nomad cleanup" exit 0 fi - -if $SHOW_UUID; then - CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" - - hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) - - if [ -z "$hosts" ]; then - # Mimic `ghe-cluster-each $role -u` - echo "fake-uuid - fake-uuid1 - fake-uuid2 - " - else - for hostname in $hosts; do - [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue - echo $hostname - done - fi -fi \ No newline at end of file diff --git a/test/bin/ghe-cluster-nodes b/test/bin/ghe-cluster-nodes new file mode 100644 index 000000000..5cc98341f --- /dev/null +++ b/test/bin/ghe-cluster-nodes @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Usage: ghe-cluster-nodes +# Emulates the remote GitHub ghe-cluster-nodes command. Tests use this +# to assert that the command was executed. +set -e + +for _ in "$@"; do + case "$1" in + -r|--role) + ROLE=$2 + shift + ;; + -u|--uuid) + PRINT_UUIDS=true + shift + ;; + esac +done + +CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" + +hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) + +if $PRINT_UUIDS; then + CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" + + hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) + + if [ -z "$hosts" ]; then + # Mimic `ghe-cluster-each $role -u` + echo "fake-uuid + fake-uuid1 + fake-uuid2 + " + else + for hostname in $hosts; do + [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue + echo $hostname + done + fi +fi \ No newline at end of file diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index bd0e63a3f..da9a8d686 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -265,7 +265,7 @@ begin_test "ghe-backup cluster" if ! ghe-backup -v > "$TRASHDIR/backup-out" 2>&1; then cat "$TRASHDIR/backup-out" - : ghe-restore should have exited successfully + : ghe-backup should have exited successfully false fi diff --git a/test/test-ghe-cluster-nodes.sh b/test/test-ghe-cluster-find-nodes.sh similarity index 69% rename from test/test-ghe-cluster-nodes.sh rename to test/test-ghe-cluster-find-nodes.sh index cdff8ad1e..20ce7fdbb 100755 --- a/test/test-ghe-cluster-nodes.sh +++ b/test/test-ghe-cluster-find-nodes.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# ghe-cluster-nodes command tests +# ghe-cluster-find-nodes command tests # Bring in testlib # shellcheck source=test/testlib.sh @@ -14,25 +14,25 @@ export GHE_DATA_DIR GHE_REMOTE_DATA_DIR mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" echo "fake-uuid" > "$GHE_REMOTE_DATA_USER_DIR/common/uuid" -begin_test "ghe-cluster-nodes should return both uuids for git-server" +begin_test "ghe-cluster-find-nodes should return both uuids for git-server" ( set -e setup_remote_cluster - output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + output="$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server")" echo "$output" [ "git-server-fake-uuid git-server-fake-uuid1 git-server-fake-uuid2 " = "$output" ] ) end_test -begin_test "ghe-cluster-nodes should return one uuid for a single node" +begin_test "ghe-cluster-find-nodes should return one uuid for a single node" ( set -e # Ensure not a cluster rm -rf "$GHE_REMOTE_ROOT_DIR/etc/github/cluster" - output="$(ghe-cluster-nodes "$GHE_HOSTNAME" "git-server")" + output="$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server")" echo "$output" [ "git-server-fake-uuid" = "$output" ] ) From 7e8c207275b1f7be38c1ad7aa407b9c9a268e616 Mon Sep 17 00:00:00 2001 From: donal Date: Fri, 9 Sep 2022 09:49:54 +1000 Subject: [PATCH 1526/2421] make stub script executable and quiet linter --- test/bin/ghe-cluster-nodes | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 test/bin/ghe-cluster-nodes diff --git a/test/bin/ghe-cluster-nodes b/test/bin/ghe-cluster-nodes old mode 100644 new mode 100755 index 5cc98341f..cbdefdb69 --- a/test/bin/ghe-cluster-nodes +++ b/test/bin/ghe-cluster-nodes @@ -19,12 +19,12 @@ done CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" -hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) +hosts=$(git config -f "$CONFIG" --get-regexp cluster.*.hostname | cut -d ' ' -f2) if $PRINT_UUIDS; then CONFIG="$GHE_REMOTE_DATA_USER_DIR/common/cluster.conf" - hosts=$(git config -f $CONFIG --get-regexp cluster.*.hostname | cut -d ' ' -f2) + hosts=$(git config -f "$CONFIG" --get-regexp cluster.*.hostname | cut -d ' ' -f2) if [ -z "$hosts" ]; then # Mimic `ghe-cluster-each $role -u` @@ -34,8 +34,8 @@ if $PRINT_UUIDS; then " else for hostname in $hosts; do - [ -n "$ROLE" ] && [ "$(git config -f $CONFIG cluster.$hostname.$ROLE-server)" != "true" ] && continue - echo $hostname + [ -n "$ROLE" ] && [ "$(git config -f "$CONFIG" cluster."$hostname"."$ROLE"-server)" != "true" ] && continue + echo "$hostname" done fi -fi \ No newline at end of file +fi From 46329455297ecf68cf66c2f59f07e75293bc7241 Mon Sep 17 00:00:00 2001 From: Stoney <19228888+ThatStoney@users.noreply.github.com> Date: Thu, 15 Sep 2022 14:17:08 -0400 Subject: [PATCH 1527/2421] Update broken link --- docs/getting-started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 80e141218..64a1b14ed 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -32,7 +32,7 @@ with the `-i ` SSH option. 3. Add the backup host's SSH key to the GitHub appliance as an *Authorized SSH - key*. See [Adding an SSH key for shell access][4] for instructions. + key*. See [Adding your SSH key to the ssh-agent][4] for instructions. 4. Run `bin/ghe-host-check` to verify SSH connectivity with the GitHub appliance. @@ -42,4 +42,4 @@ [1]: https://github.com/github/backup-utils/releases [2]: https://github.com/github/backup-utils/releases/tag/v2.11.4 [3]: https://github.com/github/enterprise-backup-site/blob/master/backup.config-example -[4]: https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access +[4]: https://docs.github.com/en/enterprise-server@3.6/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent From 060d001eca7614b738ca03ac4716349440a00f56 Mon Sep 17 00:00:00 2001 From: Stoney <19228888+ThatStoney@users.noreply.github.com> Date: Thu, 15 Sep 2022 14:29:39 -0400 Subject: [PATCH 1528/2421] Fix link Co-authored-by: djdefi --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 64a1b14ed..baf949ad0 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -42,4 +42,4 @@ [1]: https://github.com/github/backup-utils/releases [2]: https://github.com/github/backup-utils/releases/tag/v2.11.4 [3]: https://github.com/github/enterprise-backup-site/blob/master/backup.config-example -[4]: https://docs.github.com/en/enterprise-server@3.6/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent +[4]: https://docs.github.com/enterprise-server/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent From 907b70bd120949a590bd3cebbd6a4a16ca7cf646 Mon Sep 17 00:00:00 2001 From: Stoney <19228888+ThatStoney@users.noreply.github.com> Date: Thu, 15 Sep 2022 14:38:36 -0400 Subject: [PATCH 1529/2421] Linter dragon --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index baf949ad0..58420639b 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -22,7 +22,7 @@ * Backup Utilities will attempt to load the backup configuration from the following locations, in this order: - ``` + ```bash $GHE_BACKUP_CONFIG (User configurable environment variable) $GHE_BACKUP_ROOT/backup.config (Root directory of backup-utils install) $HOME/.github-backup-utils/backup.config From 54396f98128a90a7470eae75b062e251b422c24d Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 15 Sep 2022 13:13:45 -0700 Subject: [PATCH 1530/2421] Update getting-started.md --- docs/getting-started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 58420639b..c80873d0e 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -13,7 +13,7 @@ 2. Copy the [`backup.config-example`][3] file to `backup.config` and modify as necessary. The `GHE_HOSTNAME` value must be set to the primary GitHub Enterprise Server - host name. Additional options are available and documented in the + hostname. Additional options are available and documented in the configuration file but none are required for basic backup functionality. As the data on a High Availability replica may be in a transient state at the time of backup, From 592d8a1970f4f2a2973df3d32f51863decbf4a94 Mon Sep 17 00:00:00 2001 From: Vipin Deshmukh <39809415+vn0bbin@users.noreply.github.com> Date: Fri, 16 Sep 2022 13:42:15 -0500 Subject: [PATCH 1531/2421] Adding start, end and run time for backup --- bin/ghe-backup | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index 8d9be333c..9d44ddb5d 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -139,6 +139,8 @@ fi echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress +START_TIME=$(date +%s) +echo 'Start time:' $START_TIME echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" # Perform a host connection check and establish the remote appliance version. @@ -270,5 +272,9 @@ fi echo "Checking for leaked ssh keys ..." ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true +END_TIME=$(date +%s) +echo 'End time:' $END_TIME +echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' + # Make sure we exit zero after the conditional true From 9e2b52e3ac6abf818851c5c7bb9c39e1fc07c90c Mon Sep 17 00:00:00 2001 From: Vipin Deshmukh <39809415+vn0bbin@users.noreply.github.com> Date: Fri, 16 Sep 2022 13:44:08 -0500 Subject: [PATCH 1532/2421] Update ghe-backup --- bin/ghe-backup | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index 9d44ddb5d..8e235d4b1 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -141,6 +141,7 @@ echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress START_TIME=$(date +%s) echo 'Start time:' $START_TIME + echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" # Perform a host connection check and establish the remote appliance version. From 1a5a1073d937cd27744a14eb6d43a43712ca0b25 Mon Sep 17 00:00:00 2001 From: Vipin Deshmukh <39809415+vn0bbin@users.noreply.github.com> Date: Tue, 20 Sep 2022 10:29:33 -0500 Subject: [PATCH 1533/2421] Update ghe-backup Making suggested changes [here](https://github.com/github/backup-utils/pull/956#pullrequestreview-1113113580) --- bin/ghe-backup | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 8e235d4b1..65e0c53b8 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -141,7 +141,6 @@ echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress START_TIME=$(date +%s) echo 'Start time:' $START_TIME - echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" # Perform a host connection check and establish the remote appliance version. @@ -257,6 +256,10 @@ if [ -z "$failures" ]; then ghe-prune-snapshots fi +END_TIME=$(date +%s) +echo 'End time:' $END_TIME +echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' + echo "Completed backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP at $(date +"%H:%M:%S")" # Exit non-zero and list the steps that failed. @@ -273,9 +276,5 @@ fi echo "Checking for leaked ssh keys ..." ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true -END_TIME=$(date +%s) -echo 'End time:' $END_TIME -echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' - # Make sure we exit zero after the conditional true From 0a39e169f5c7087b9a86428fed4f3cc52d06e24d Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 21 Sep 2022 11:02:18 -0700 Subject: [PATCH 1534/2421] Add verbose output for audit log output Assist with determining if incremental hard linking occurred for an index, or if a full dump was required. --- share/github-backup-utils/ghe-backup-es-audit-log | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index e28525e5d..42ef9314a 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -44,10 +44,12 @@ for index in $indices; do index_size=$2 if [[ -f $GHE_DATA_DIR/current/audit-log/$index_name.gz && $(cat $GHE_DATA_DIR/current/audit-log/$index_name.gz.size 2>/dev/null || true) -eq $index_size ]]; then + ghe_verbose "* Linking unchanged audit log index: $index_name" # Hard link any indices that have not changed since the last backup ln $GHE_DATA_DIR/current/audit-log/$index_name.gz $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz ln $GHE_DATA_DIR/current/audit-log/$index_name.gz.size $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size else + ghe_verbose "* Performing audit log export for index: $index_name" echo "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\" | gzip" | ghe-ssh "$host" -- /bin/bash > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz echo $index_size > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size fi From c828d1f27a88947b573bdc56bc1b443e95814ae4 Mon Sep 17 00:00:00 2001 From: gitulisca <107976350+gitulisca@users.noreply.github.com> Date: Wed, 28 Sep 2022 10:48:16 +1000 Subject: [PATCH 1535/2421] Update instructions on granting backup host access to GHES (#959) --- docs/getting-started.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index c80873d0e..58054f3bf 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -31,8 +31,8 @@ * In a clustering environment, the `GHE_EXTRA_SSH_OPTS` key must be configured with the `-i ` SSH option. - 3. Add the backup host's SSH key to the GitHub appliance as an *Authorized SSH - key*. See [Adding your SSH key to the ssh-agent][4] for instructions. + 3. Add the backup host's SSH public key to the GitHub Enterprise Server appliance, in order to grant it administrative shell access. + See [Accessing the GitHub Enterprise Server administrative shell (SSH)][4] for instructions. 4. Run `bin/ghe-host-check` to verify SSH connectivity with the GitHub appliance. @@ -42,4 +42,4 @@ [1]: https://github.com/github/backup-utils/releases [2]: https://github.com/github/backup-utils/releases/tag/v2.11.4 [3]: https://github.com/github/enterprise-backup-site/blob/master/backup.config-example -[4]: https://docs.github.com/enterprise-server/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent +[4]: https://docs.github.com/enterprise-server/admin/configuration/configuring-your-enterprise/accessing-the-administrative-shell-ssh From 3247ad8db5c5fb3bb86d0783f07a5f098b6b7293 Mon Sep 17 00:00:00 2001 From: Shruti Corbett Date: Thu, 13 Oct 2022 09:26:40 -0400 Subject: [PATCH 1536/2421] Update README.md Removed beta terminology for parallel backup feature since this has now been in place for a while. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d38558c2..735a74dbe 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This repository includes backup and recovery utilities for [GitHub Enterprise Server][1]. -**UPDATE**: The new parallel backup and restore beta feature will require [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils) to be installed. Note that on some distributions/platforms, the `moreutils-parallel` package is separate from `moreutils` and must be installed on its own. +**Note**: The parallel backup and restore feature will require [GNU awk](https://www.gnu.org/software/gawk) and [moreutils](https://joeyh.name/code/moreutils) to be installed. Note that on some distributions/platforms, the `moreutils-parallel` package is separate from `moreutils` and must be installed on its own. **Note**: the [GitHub Enterprise Server version requirements][2] have changed starting with Backup Utilities v2.13.0, released on 27 March 2018. From 18b1e7948be253bb70bf4fa61e1a1019859050e6 Mon Sep 17 00:00:00 2001 From: Shruti Corbett Date: Thu, 13 Oct 2022 09:27:50 -0400 Subject: [PATCH 1537/2421] Update backup.config-example Removed lines with "Warning this is a beta feature" since this is no longer referenced as beta --- backup.config-example | 4 ---- 1 file changed, 4 deletions(-) diff --git a/backup.config-example b/backup.config-example index 61ccbb055..8c98655ab 100644 --- a/backup.config-example +++ b/backup.config-example @@ -64,27 +64,23 @@ GHE_NUM_SNAPSHOTS=10 # If set to 'yes', ghe-backup jobs will run in parallel. Defaults to 'no'. # -# WARNING: this feature is in beta. #GHE_PARALLEL_ENABLED=yes # Sets the maximum number of jobs to run in parallel. Defaults to the number # of available processing units on the machine. # -# WARNING: this feature is in beta. #GHE_PARALLEL_MAX_JOBS=2 # Sets the maximum number of rsync jobs to run in parallel. Defaults to the # configured GHE_PARALLEL_MAX_JOBS, or the number of available processing # units on the machine. # -# WARNING: this feature is in beta. # GHE_PARALLEL_RSYNC_MAX_JOBS=3 # When jobs are running in parallel wait as needed to avoid starting new jobs # when the system's load average is not below the specified percentage. Defaults to # unrestricted. # -# WARNING: this feature is in beta. #GHE_PARALLEL_MAX_LOAD=50 # When running an external mysql database, run this script to trigger a MySQL backup From 73ab611dea072c3a8b516fd55989ed8f6d4ab25a Mon Sep 17 00:00:00 2001 From: Shruti Corbett Date: Thu, 13 Oct 2022 09:29:16 -0400 Subject: [PATCH 1538/2421] Update requirements.md Removed reference of beta for parallel feature --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index 94e5c5701..e4d7f42d3 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -8,7 +8,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app Backup host software requirements are modest: Linux or other modern Unix operating system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. -The new parallel backup and restore beta feature will require [GNU awk][10] and [moreutils][9] to be installed. +The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. We encourage the use of [Docker](docker.md) if your backup host doesn't meet these requirements, or if Docker is your preferred platform. From d6af82b9aaf77a95be517190df627dc9d48fdc21 Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 13 Oct 2022 11:16:59 -0700 Subject: [PATCH 1539/2421] Fix minor README linter warnings Fixing a few of the warnings that occur on the README.md --- README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 735a74dbe..4ee951f58 100644 --- a/README.md +++ b/README.md @@ -8,28 +8,28 @@ This repository includes backup and recovery utilities for **Note**: the [GitHub Enterprise Server version requirements][2] have changed starting with Backup Utilities v2.13.0, released on 27 March 2018. -### Features +## Features Backup Utilities implement a number of advanced capabilities for backup hosts, built on top of the backup and restore features already included in GitHub Enterprise Server. - - Complete GitHub Enterprise Server backup and recovery system via two simple +- Complete GitHub Enterprise Server backup and recovery system via two simple utilities:
`ghe-backup` and `ghe-restore`. - - Online backups. The GitHub appliance need not be put in maintenance mode for +- Online backups. The GitHub appliance need not be put in maintenance mode for the duration of the backup run. - - Incremental backup of Git repository data. Only changes since the last +- Incremental backup of Git repository data. Only changes since the last snapshot are transferred, leading to faster backup runs and lower network bandwidth and machine utilization. - - Efficient snapshot storage. Only data added since the previous snapshot +- Efficient snapshot storage. Only data added since the previous snapshot consumes new space on the backup host. - - Multiple backup snapshots with configurable retention periods. - - Backup commands run under the lowest CPU/IO priority on the GitHub appliance, +- Multiple backup snapshots with configurable retention periods. +- Backup commands run under the lowest CPU/IO priority on the GitHub appliance, reducing performance impact while backups are in progress. - - Runs under most Linux/Unix environments. - - MIT licensed, open source software maintained by GitHub, Inc. +- Runs under most Linux/Unix environments. +- MIT licensed, open source software maintained by GitHub, Inc. -### Documentation +## Documentation - **[Requirements](docs/requirements.md)** - **[Backup host requirements](docs/requirements.md#backup-host-requirements)** @@ -42,7 +42,7 @@ GitHub Enterprise Server. - **[How does Backup Utilities differ from a High Availability replica?](docs/faq.md)** - **[Docker](docs/docker.md)** -### Support +## Support If you find a bug or would like to request a feature in Backup Utilities, please open an issue or pull request on this repository. If you have a question related @@ -53,3 +53,4 @@ instead. [1]: https://github.com/enterprise [2]: docs/requirements.md#github-enterprise-version-requirements [3]: https://support.github.com/ + From 4f2c96f572ca6f97debb3a6be428b7cf7a1437d1 Mon Sep 17 00:00:00 2001 From: Devin Dooley Date: Tue, 25 Oct 2022 00:35:38 +0000 Subject: [PATCH 1540/2421] Bump version: 3.7.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 5 +++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 1f8a51847..6cb8bc72c 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -131,7 +131,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.4.0" +supported_minimum_version="3.5.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index bf6ca9e03..965b4d01d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,8 @@ +github-backup-utils (3.7.0) UNRELEASED; urgency=medium + + + -- Devin Dooley Tue, 25 Oct 2022 00:35:38 +0000 + github-backup-utils (3.6.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 40c341bdc..7c69a55db 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.6.0 +3.7.0 diff --git a/test/testlib.sh b/test/testlib.sh index 64f00e0f6..332fc672f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.6.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.7.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From fc82ee1a7ca73c06faaab6953a8ed08bcbcfb3e9 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Mon, 7 Nov 2022 17:18:47 -0500 Subject: [PATCH 1541/2421] Firming up requirements --- docs/requirements.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index 5595699e6..59683b8a9 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -6,12 +6,11 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements Backup host software requirements are modest: Linux or other modern Unix operating -system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. +system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. -We encourage the use of [Docker](docker.md) if your backup host doesn't meet these -requirements, or if Docker is your preferred platform. +We encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are availablt to backup-utils. The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. From b9d248fd5d735bb57dd865af275990db26cf9d60 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Nov 2022 20:40:54 +0000 Subject: [PATCH 1542/2421] Bump actions/stale from 4 to 6 Bumps [actions/stale](https://github.com/actions/stale) from 4 to 6. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v4...v6) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/stale-support-escalation.yml | 2 +- .github/workflows/stale.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale-support-escalation.yml b/.github/workflows/stale-support-escalation.yml index 2bb01ab53..a2e885f7c 100644 --- a/.github/workflows/stale-support-escalation.yml +++ b/.github/workflows/stale-support-escalation.yml @@ -15,7 +15,7 @@ jobs: if: github.repository == 'github/ghes' || github.repository == 'github/enterprise2' || github.repository == 'github/backup-utils-private' runs-on: ubuntu-latest steps: - - uses: actions/stale@v4 + - uses: actions/stale@v6 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This support escalation issue is stale because it has been open 30 days with no activity. To make it never stale, add a label never-stale.' diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 828182457..e5a67d2b6 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/stale@v3 + - uses: actions/stale@v6 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: "👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot." From 722ebb059dc0554ec442ee2c07c76fbc473aedc5 Mon Sep 17 00:00:00 2001 From: Manuel Bergler Date: Wed, 9 Nov 2022 17:26:02 +0100 Subject: [PATCH 1543/2421] Add management console argon2 secret to backup/restore settings --- share/github-backup-utils/ghe-backup-settings | 1 + share/github-backup-utils/ghe-restore-settings | 3 +++ 2 files changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 605c5ce78..f1f1a3f91 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -75,6 +75,7 @@ backup-secret() { } backup-secret "management console password" "manage-password" "secrets.manage" +backup-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index ec668bbb6..7c46d73c1 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -44,6 +44,9 @@ ghe-restore-packages "$GHE_HOSTNAME" 1>&3 # Restore management console password hash if present. restore-secret "management console password" "manage-password" "secrets.manage" +# Restore management console argon2 secret if present. +restore-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" + # Restore kredz.credz HMAC key if present. restore-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" From 24b1d328c68b23eea88c4fde0855a5dedd677855 Mon Sep 17 00:00:00 2001 From: Manuel Bergler Date: Wed, 9 Nov 2022 17:32:18 +0100 Subject: [PATCH 1544/2421] Cover argon2 secret in backup test --- test/test-ghe-backup.sh | 11 +++++++++++ test/testlib.sh | 1 + 2 files changed, 12 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index f50963fd9..55a5e67d2 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -132,6 +132,17 @@ begin_test "ghe-backup without password pepper" ) end_test +begin_test "ghe-backup without management console argon2 secret" +( + set -e + + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage-auth.argon-secret "" + ghe-backup + + [ ! -f "$GHE_DATA_DIR/current/manage-argon-secret" ] +) +end_test + begin_test "ghe-backup empty git-hooks directory" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index 332fc672f..e5ffca72a 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -202,6 +202,7 @@ setup_test_data () { # Create a fake manage password file§ mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage "fake password hash data" + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage-auth.argon-secret "fake argon2 secret" # Create a fake password pepper file mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" From 7636d05236cfde2b4fd4ba451d95bb66d0068147 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 15 Nov 2022 09:10:45 -0800 Subject: [PATCH 1545/2421] Add jq to requirements --- docs/requirements.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index 59683b8a9..7cdcb8722 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -6,7 +6,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements Backup host software requirements are modest: Linux or other modern Unix operating -system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, and [rsync][4] v2.6.4 or newer. +system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. @@ -78,3 +78,4 @@ Due to how some components of Backup Utilities (e.g. MSSQL) take incremental bac [8]: https://help.github.com/enterprise/admin/guides/installation/upgrade-requirements/ [9]: https://joeyh.name/code/moreutils [10]: https://www.gnu.org/software/gawk +[11]: https://stedolan.github.io/jq/ From 74c8951a295790c40b0f9d6751a4dfb1d9a831d8 Mon Sep 17 00:00:00 2001 From: Brian Date: Tue, 22 Nov 2022 17:11:16 -0500 Subject: [PATCH 1546/2421] Fix misspelling --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index 59683b8a9..15c94614a 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -10,7 +10,7 @@ system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. -We encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are availablt to backup-utils. +We encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. From 9a606f45df771404d39efc9c056a1990f5e5b9d5 Mon Sep 17 00:00:00 2001 From: Anupam Kumar Date: Thu, 24 Nov 2022 04:20:49 +0000 Subject: [PATCH 1547/2421] add backup-restore for varz --- share/github-backup-utils/ghe-backup-settings | 1 + .../github-backup-utils/ghe-restore-settings | 3 +++ test/test-ghe-backup.sh | 25 ++++++++++++++++++ test/test-ghe-restore.sh | 26 +++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 605c5ce78..0711fe3d5 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -77,6 +77,7 @@ backup-secret() { backup-secret "management console password" "manage-password" "secrets.manage" backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" +backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" # Backup external MySQL password if running external MySQL DB. if is_service_external 'mysql'; then diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index ec668bbb6..8461e0e89 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -47,6 +47,9 @@ restore-secret "management console password" "manage-password" "secrets.manage" # Restore kredz.credz HMAC key if present. restore-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" +# Restore kredz.varz HMAC key if present. +restore-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" + # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then echo "Restoring SAML keys ..." diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index f50963fd9..b81a98bc1 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -495,6 +495,31 @@ begin_test "ghe-backup takes backup of Kredz settings" ) end_test +begin_test "ghe-backup takes backup of kredz-varz settings" +( + set -e + + required_secrets=( + "secrets.kredz.varz-hmac-secret" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + ghe-backup + + required_files=( + "kredz-varz-hmac" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done + +) +end_test + begin_test "ghe-backup takes backup of Actions settings" ( set -e diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 6e092970e..b9e6acfb3 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -336,6 +336,32 @@ begin_test "ghe-restore with Kredz settings" ) end_test +begin_test "ghe-restore with kredz-varz settings" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + required_files=( + "kredz-varz-hmac" + ) + + for file in "${required_files[@]}"; do + echo "foo" > "$GHE_DATA_DIR/current/$file" + done + + ghe-restore -v -f localhost + required_secrets=( + "secrets.kredz.varz-hmac-secret" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done +) +end_test + begin_test "ghe-restore with Actions settings" ( set -e From 945dfc0330f6a881ea10e49f604c9c5804d3f486 Mon Sep 17 00:00:00 2001 From: Manuel Bergler Date: Mon, 28 Nov 2022 15:33:28 +0100 Subject: [PATCH 1548/2421] Add argon2 secret to verified restore data function --- test/testlib.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/testlib.sh b/test/testlib.sh index e5ffca72a..d821ff3c1 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -508,6 +508,9 @@ verify_all_restored_data() { # verify management console password was *not* restored ! grep -q "fake password hash data" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" + # verify management console argon2 secret was *not* restored + ! grep -q "fake argon2 secret" "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" + # verify common data verify_common_data } From e018e4c8d10fe1b66642bb0eb69a656c5ac27228 Mon Sep 17 00:00:00 2001 From: Manuel Bergler Date: Mon, 28 Nov 2022 15:34:06 +0100 Subject: [PATCH 1549/2421] Add argon2 secret to list of verified backup data --- test/testlib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/testlib.sh b/test/testlib.sh index d821ff3c1..4abbc3281 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -317,6 +317,7 @@ setup_test_data () { echo "fake ghe-export-ssl-ca-certificates data" > "$loc/ssl-ca-certificates.tar" echo "fake license data" > "$loc/enterprise.ghl" echo "fake password hash data" > "$loc/manage-password" + echo "fake argon2 secret" > "$loc/manage-argon-secret" echo "fake password pepper data" > "$loc/password-pepper" echo "rsync" > "$loc/strategy" echo "$GHE_REMOTE_VERSION" > "$loc/version" @@ -446,6 +447,9 @@ verify_all_backedup_data() { # verify manage-password file was backed up [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] + # verify manage-argon-secret file was backed up + [ "$(cat "$GHE_DATA_DIR/current/manage-argon-secret")" = "fake argon2 secret" ] + # verify password pepper file was backed up [ "$(cat "$GHE_DATA_DIR/current/password-pepper")" = "fake password pepper data" ] From e44d51677780a529df93f81d263b26f68e401663 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 1 Dec 2022 16:50:31 +0000 Subject: [PATCH 1550/2421] Co-authored-by: Chuck Pathanjali --- bin/ghe-backup | 8 +++ bin/ghe-restore | 12 +++- share/github-backup-utils/ghe-backup-config | 61 +++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 783ea9980..d3f6ded7a 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -44,6 +44,10 @@ done # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check + +echo "We got here without any problems" +exit 1 + # Used to record failed backup steps failures= failures_file="$(mktemp -t backup-utils-backup-failures-XXXXXX)" @@ -114,6 +118,10 @@ cleanup () { trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate + +# Check to see if there is a running restore +ghe_restore_check + if [ -h ../in-progress ]; then echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 echo "If there is no backup in progress anymore, please remove" 1>&2 diff --git a/bin/ghe-restore b/bin/ghe-restore index 42fe6cd57..2c1edac68 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -122,6 +122,8 @@ cleanup () { # Cleanup SSH multiplexing ghe-ssh --clean + # Remove in-progress file + ghe_restore_finished } # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. @@ -152,6 +154,9 @@ cleanup_cluster_nodes() { # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check +# Check to make sure a restore or backup is not in progress + + # Grab the host arg GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" @@ -159,7 +164,7 @@ GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :) # Show usage with no -[ -z "$GHE_HOSTNAME" ] && print_usage +#[ -z "$GHE_HOSTNAME" ] && print_usage # Flag to indicate if this script has stopped Actions. ACTIONS_STOPPED=false @@ -170,6 +175,11 @@ GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") export GHE_RESTORE_SNAPSHOT +ghe_restore_check +ghe_restore_started $GHE_RESTORE_SNAPSHOT +#ghe_restore_finished +echo "This happened without any problems!" +exit 1 # Detect if the backup we are restoring has a leaked ssh key echo "Checking for leaked keys in the backup snapshot that is being restored ..." ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b9271cf6b..3b6be4782 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,6 +66,67 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done +GHE_RESTORE_IN_PROGRESS="${GHE_DATA_DIR}/.in-progress-restore" +GHE_BACKUP_IN_PROGRESS="${GHE_DATA_DIR}/.in-progress" +export GHE_RESTORE_IN_PROGRESS +export GHE_BACKUP_IN_PROGRESS + +ghe_restore_started() { +echo "$1 $$" > $GHE_RESTORE_IN_PROGRESS +} + +ghe_restore_check() { +if [ -h $GHE_RESTORE_IN_PROGRESS ]; then + echo "Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2 + echo "If there is no restore in progress anymore, please remove" 1>&2 + echo "the $GHE_DATA_DIR/in-progress-restore file." 1>&2 + exit 1 +fi + +if [ -f $GHE_RESTORE_IN_PROGRESS ]; then + progress=$(cat $GHE_RESTORE_IN_PROGRESS) + snapshot=$(echo "$progress" | cut -d ' ' -f 1) + pid=$(echo "$progress" | cut -d ' ' -f 2) + echo "Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 + echo "If PID $pid is not a process related to the restore utilities, please remove" 1>&2 + echo "the $GHE_DATA_DIR/in-progress-restore file and try again." 1>&2 + exit 1 + fi +} + +ghe_backup_check() { +if [ -h $GHE_BACKUP_IN_PROGRESS ]; then + echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 + echo "If there is no backup in progress anymore, please remove" 1>&2 + echo "the $GHE_DATA_DIR/in-progress-backup file." 1>&2 + exit 1 +fi + +if [ -f $GHE_BACKUP_IN_PROGRESS ]; then + progress=$(cat $GHE_BACKUP_IN_PROGRESS) + snapshot=$(echo "$progress" | cut -d ' ' -f 1) + pid=$(echo "$progress" | cut -d ' ' -f 2) + echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 + echo "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 + echo "the $GHE_DATA_DIR/in-progress file and try again." 1>&2 + exit 1 + fi +} + +ghe_restore_finished() { + echo "$GHE_RESTORE_IN_PROGRESS" + if [ -f $GHE_RESTORE_IN_PROGRESS ]; then + echo "$GHE_RESTORE_IN_PROGRESS exists!" 1>&2 + rm -f $GHE_RESTORE_IN_PROGRESS + fi +} + +ghe_backup_finished() { + if [ ! -f $GHE_BACKUP_IN_PROGRESS ]; then + rm -f $GHE_BACKUP_IN_PROGRESS + fi +} + ghe_parallel_check() { if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then return 0 From dcfe6cc379cf8ac5993bc527171d252398a8a61f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 1 Dec 2022 17:00:42 +0000 Subject: [PATCH 1551/2421] Revising POC for testing Co-authored-by: Chuck Pathanjali --- bin/ghe-backup | 1 + bin/ghe-restore | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index d3f6ded7a..499d178db 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -122,6 +122,7 @@ trap 'exit $?' INT # ^C always terminate # Check to see if there is a running restore ghe_restore_check +# Check to see if there is a running backup if [ -h ../in-progress ]; then echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 echo "If there is no backup in progress anymore, please remove" 1>&2 diff --git a/bin/ghe-restore b/bin/ghe-restore index 2c1edac68..0a4866239 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -164,7 +164,7 @@ GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :) # Show usage with no -#[ -z "$GHE_HOSTNAME" ] && print_usage +[ -z "$GHE_HOSTNAME" ] && print_usage # Flag to indicate if this script has stopped Actions. ACTIONS_STOPPED=false @@ -175,11 +175,9 @@ GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") export GHE_RESTORE_SNAPSHOT +ghe_backup_check ghe_restore_check -ghe_restore_started $GHE_RESTORE_SNAPSHOT -#ghe_restore_finished -echo "This happened without any problems!" -exit 1 + # Detect if the backup we are restoring has a leaked ssh key echo "Checking for leaked keys in the backup snapshot that is being restored ..." ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true @@ -262,6 +260,7 @@ START_TIME=$(date +%s) echo 'Start time:' $START_TIME echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." +ghe_restore_started $START_TIME # Keep other processes on the VM or cluster in the loop about the restore status. # @@ -589,6 +588,7 @@ echo 'End time:' $END_TIME echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." +ghe_restore_finished if ! $instance_configured; then echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." From f4663b15f4cee82fded845b7642655019c87ed30 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 1 Dec 2022 21:02:34 +0000 Subject: [PATCH 1552/2421] Working but rough version of changes Co-authored-by: Chuck Pathanjali --- bin/ghe-backup | 25 +++++------ bin/ghe-restore | 49 ++++++++++++++++++--- share/github-backup-utils/ghe-backup-config | 12 ++--- 3 files changed, 61 insertions(+), 25 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 499d178db..d70200428 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -45,9 +45,6 @@ done ghe_parallel_check -echo "We got here without any problems" -exit 1 - # Used to record failed backup steps failures= failures_file="$(mktemp -t backup-utils-backup-failures-XXXXXX)" @@ -99,12 +96,12 @@ rm -rf src dest1 dest2 # The cleanup trap also handles disabling maintenance mode on the appliance if # it was automatically enabled. cleanup () { - if [ -f ../in-progress ]; then - progress=$(cat ../in-progress) + if [ -f ../.in-progress ]; then + progress=$(cat ../.in-progress) snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) if [ "$snapshot" = "$GHE_SNAPSHOT_TIMESTAMP" ] && [ "$$" = $pid ]; then - unlink ../in-progress + unlink ../.in-progress fi fi @@ -123,30 +120,30 @@ trap 'exit $?' INT # ^C always terminate ghe_restore_check # Check to see if there is a running backup -if [ -h ../in-progress ]; then +if [ -h ../.in-progress ]; then echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 echo "If there is no backup in progress anymore, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress file." 1>&2 + echo "the $GHE_DATA_DIR/.in-progress file." 1>&2 exit 1 fi -if [ -f ../in-progress ]; then - progress=$(cat ../in-progress) +if [ -f ../.in-progress ]; then + progress=$(cat ../.in-progress) snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) if ! ps -p "$pid" >/dev/null 2>&1; then - # We can safely remove in-progress, ghe-prune-snapshots + # We can safely remove .in-progress, ghe-prune-snapshots # will clean up the failed backup. - unlink ../in-progress + unlink ../.in-progress else echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 echo "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress file and try again." 1>&2 + echo "the $GHE_DATA_DIR/.in-progress file and try again." 1>&2 exit 1 fi fi -echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress +echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../.in-progress echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" diff --git a/bin/ghe-restore b/bin/ghe-restore index 0a4866239..d7e14b770 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -123,7 +123,7 @@ cleanup () { # Cleanup SSH multiplexing ghe-ssh --clean # Remove in-progress file - ghe_restore_finished + rm -f ${GHE_DATA_DIR}/.in-progress-restore } # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. @@ -154,6 +154,25 @@ cleanup_cluster_nodes() { # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check +# ghe_restore_check +if [ -h ${GHE_DATA_DIR}/.in-progress-restore ]; then + echo "Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2 + echo "If there is no restore in progress anymore, please remove" 1>&2 + echo "the $GHE_DATA_DIR/in-progress-restore file." 1>&2 + exit 1 +fi + +echo "${GHE_DATA_DIR}/.in-progress-restore" +if [ -f ${GHE_DATA_DIR}/.in-progress-restore ]; then + progress=$(cat ${GHE_DATA_DIR}/.in-progress-restore) + snapshot=$(echo "$progress" | cut -d ' ' -f 1) + pid=$(echo "$progress" | cut -d ' ' -f 2) + echo "Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 + echo "If PID $pid is not a process related to the restore utilities, please remove" 1>&2 + echo "the $GHE_DATA_DIR/in-progress-restore file and try again." 1>&2 + exit 1 + fi + # Check to make sure a restore or backup is not in progress @@ -175,8 +194,23 @@ GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") export GHE_RESTORE_SNAPSHOT -ghe_backup_check -ghe_restore_check +#ghe_backup_check +if [ -h ${GHE_DATA_DIR}/.in-progress ]; then + echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 + echo "If there is no backup in progress anymore, please remove" 1>&2 + echo "the $GHE_DATA_DIR/.in-progress-backup file." 1>&2 + exit 1 +fi + +if [ -f ${GHE_DATA_DIR}/.in-progress ]; then + progress=$(cat ${GHE_DATA_DIR}/.in-progress) + snapshot=$(echo "$progress" | cut -d ' ' -f 1) + pid=$(echo "$progress" | cut -d ' ' -f 2) + echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 + echo "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 + echo "the $GHE_DATA_DIR/.in-progress file and try again." 1>&2 + exit 1 + fi # Detect if the backup we are restoring has a leaked ssh key echo "Checking for leaked keys in the backup snapshot that is being restored ..." @@ -260,8 +294,13 @@ START_TIME=$(date +%s) echo 'Start time:' $START_TIME echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." -ghe_restore_started $START_TIME +# Create an in-progress-restore file to prevent simultaneous backup or restore runs +echo "${START_TIME} $$" > ${GHE_DATA_DIR}/.in-progress-restore +sleep 120 +rm -f ${GHE_DATA_DIR}/.in-progress-restore +echo "finished with fake restore" +exit 1 # Keep other processes on the VM or cluster in the loop about the restore status. # # Other processes will look for these states: @@ -588,7 +627,7 @@ echo 'End time:' $END_TIME echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." -ghe_restore_finished +rm -f ${GHE_DATA_DIR}/.in-progress-restore if ! $instance_configured; then echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 3b6be4782..1bd3293b7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,14 +66,14 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done -GHE_RESTORE_IN_PROGRESS="${GHE_DATA_DIR}/.in-progress-restore" -GHE_BACKUP_IN_PROGRESS="${GHE_DATA_DIR}/.in-progress" +GHE_RESTORE_IN_PROGRESS="../../${GHE_DATA_DIR}/.in-progress-restore" +GHE_BACKUP_IN_PROGRESS="../../${GHE_DATA_DIR}/.in-progress" export GHE_RESTORE_IN_PROGRESS export GHE_BACKUP_IN_PROGRESS -ghe_restore_started() { -echo "$1 $$" > $GHE_RESTORE_IN_PROGRESS -} +#ghe_restore_started() { +#echo "$1 $$" >> $GHE_RESTORE_IN_PROGRESS +#} ghe_restore_check() { if [ -h $GHE_RESTORE_IN_PROGRESS ]; then @@ -122,7 +122,7 @@ ghe_restore_finished() { } ghe_backup_finished() { - if [ ! -f $GHE_BACKUP_IN_PROGRESS ]; then + if [ -f $GHE_BACKUP_IN_PROGRESS ]; then rm -f $GHE_BACKUP_IN_PROGRESS fi } From 8b83e560281292aa5023fef35262da8d8aca0354 Mon Sep 17 00:00:00 2001 From: djdefi Date: Mon, 12 Dec 2022 12:02:00 -0800 Subject: [PATCH 1553/2421] Test Focal for Docker image to better match Actions CI --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3b66b5020..9e016dc03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM debian:buster-slim +FROM ubuntu:focal RUN apt-get -q -y update && \ apt-get install -y --no-install-recommends \ From d42ccdfe3155ce8160af771bc3f2edc562a6f8f1 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 14 Dec 2022 14:16:58 +0000 Subject: [PATCH 1554/2421] Moved function to ghe-backup-config --- bin/ghe-backup | 25 ++++----- bin/ghe-restore | 48 ++--------------- share/github-backup-utils/ghe-backup-config | 60 ++++++++++----------- 3 files changed, 45 insertions(+), 88 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index d70200428..3b162177e 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -96,12 +96,12 @@ rm -rf src dest1 dest2 # The cleanup trap also handles disabling maintenance mode on the appliance if # it was automatically enabled. cleanup () { - if [ -f ../.in-progress ]; then - progress=$(cat ../.in-progress) + if [ -f ../in-progress ]; then + progress=$(cat ../in-progress) snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) if [ "$snapshot" = "$GHE_SNAPSHOT_TIMESTAMP" ] && [ "$$" = $pid ]; then - unlink ../.in-progress + unlink ../in-progress fi fi @@ -120,30 +120,31 @@ trap 'exit $?' INT # ^C always terminate ghe_restore_check # Check to see if there is a running backup -if [ -h ../.in-progress ]; then +if [ -h ../in-progress ]; then echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 echo "If there is no backup in progress anymore, please remove" 1>&2 - echo "the $GHE_DATA_DIR/.in-progress file." 1>&2 + echo "the \"$GHE_DATA_DIR/in-progress\" file and try again." 1>&2 exit 1 fi -if [ -f ../.in-progress ]; then - progress=$(cat ../.in-progress) +if [ -f ../in-progress ]; then + progress=$(cat ../in-progress) snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) if ! ps -p "$pid" >/dev/null 2>&1; then - # We can safely remove .in-progress, ghe-prune-snapshots + # We can safely remove in-progress, ghe-prune-snapshots # will clean up the failed backup. - unlink ../.in-progress + unlink ../in-progress else echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 - echo "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 - echo "the $GHE_DATA_DIR/.in-progress file and try again." 1>&2 + echo 1>&2 + echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2 + echo " the \"$GHE_DATA_DIR/in-progress\" file and try again." 1>&2 exit 1 fi fi -echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../.in-progress +echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" diff --git a/bin/ghe-restore b/bin/ghe-restore index d7e14b770..600a0b976 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -123,7 +123,7 @@ cleanup () { # Cleanup SSH multiplexing ghe-ssh --clean # Remove in-progress file - rm -f ${GHE_DATA_DIR}/.in-progress-restore + rm -f ${GHE_DATA_DIR}/in-progress-restore } # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. @@ -155,26 +155,6 @@ cleanup_cluster_nodes() { ghe_parallel_check # ghe_restore_check -if [ -h ${GHE_DATA_DIR}/.in-progress-restore ]; then - echo "Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2 - echo "If there is no restore in progress anymore, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress-restore file." 1>&2 - exit 1 -fi - -echo "${GHE_DATA_DIR}/.in-progress-restore" -if [ -f ${GHE_DATA_DIR}/.in-progress-restore ]; then - progress=$(cat ${GHE_DATA_DIR}/.in-progress-restore) - snapshot=$(echo "$progress" | cut -d ' ' -f 1) - pid=$(echo "$progress" | cut -d ' ' -f 2) - echo "Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 - echo "If PID $pid is not a process related to the restore utilities, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress-restore file and try again." 1>&2 - exit 1 - fi - -# Check to make sure a restore or backup is not in progress - # Grab the host arg GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" @@ -194,23 +174,7 @@ GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") export GHE_RESTORE_SNAPSHOT -#ghe_backup_check -if [ -h ${GHE_DATA_DIR}/.in-progress ]; then - echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 - echo "If there is no backup in progress anymore, please remove" 1>&2 - echo "the $GHE_DATA_DIR/.in-progress-backup file." 1>&2 - exit 1 -fi - -if [ -f ${GHE_DATA_DIR}/.in-progress ]; then - progress=$(cat ${GHE_DATA_DIR}/.in-progress) - snapshot=$(echo "$progress" | cut -d ' ' -f 1) - pid=$(echo "$progress" | cut -d ' ' -f 2) - echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 - echo "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 - echo "the $GHE_DATA_DIR/.in-progress file and try again." 1>&2 - exit 1 - fi +ghe_backup_check # Detect if the backup we are restoring has a leaked ssh key echo "Checking for leaked keys in the backup snapshot that is being restored ..." @@ -295,12 +259,8 @@ echo 'Start time:' $START_TIME echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Create an in-progress-restore file to prevent simultaneous backup or restore runs -echo "${START_TIME} $$" > ${GHE_DATA_DIR}/.in-progress-restore +echo "${START_TIME} $$" > ${GHE_DATA_DIR}/in-progress-restore -sleep 120 -rm -f ${GHE_DATA_DIR}/.in-progress-restore -echo "finished with fake restore" -exit 1 # Keep other processes on the VM or cluster in the loop about the restore status. # # Other processes will look for these states: @@ -627,7 +587,7 @@ echo 'End time:' $END_TIME echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." -rm -f ${GHE_DATA_DIR}/.in-progress-restore +rm -f ${GHE_DATA_DIR}/in-progress-restore if ! $instance_configured; then echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 1bd3293b7..5f034e644 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,49 +66,45 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done -GHE_RESTORE_IN_PROGRESS="../../${GHE_DATA_DIR}/.in-progress-restore" -GHE_BACKUP_IN_PROGRESS="../../${GHE_DATA_DIR}/.in-progress" +GHE_RESTORE_IN_PROGRESS=$(readlink -f "${GHE_DATA_DIR}/in-progress-restore") +GHE_BACKUP_IN_PROGRESS=$(readlink -f "${GHE_DATA_DIR}/in-progress-backup") export GHE_RESTORE_IN_PROGRESS export GHE_BACKUP_IN_PROGRESS -#ghe_restore_started() { -#echo "$1 $$" >> $GHE_RESTORE_IN_PROGRESS -#} - ghe_restore_check() { -if [ -h $GHE_RESTORE_IN_PROGRESS ]; then - echo "Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2 - echo "If there is no restore in progress anymore, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress-restore file." 1>&2 - exit 1 -fi + if [ -h $GHE_RESTORE_IN_PROGRESS ]; then + echo " Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2 + echo " If there is no restore in progress anymore, please remove" 1>&2 + echo " the \"$GHE_RESTORE_IN_PROGRESS\" file and try again." 1>&2 + exit 1 + fi -if [ -f $GHE_RESTORE_IN_PROGRESS ]; then - progress=$(cat $GHE_RESTORE_IN_PROGRESS) - snapshot=$(echo "$progress" | cut -d ' ' -f 1) - pid=$(echo "$progress" | cut -d ' ' -f 2) - echo "Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 - echo "If PID $pid is not a process related to the restore utilities, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress-restore file and try again." 1>&2 + if [ -f $GHE_RESTORE_IN_PROGRESS ]; then + progress=$(cat $GHE_RESTORE_IN_PROGRESS) + snapshot=$(echo "$progress" | cut -d ' ' -f 1) + pid=$(echo "$progress" | cut -d ' ' -f 2) + echo " Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 + echo " If PID $pid is not a process related to the restore utilities, please remove" 1>&2 + echo " the \"$GHE_RESTORE_IN_PROGRESS\" file and try again." 1>&2 exit 1 fi } ghe_backup_check() { -if [ -h $GHE_BACKUP_IN_PROGRESS ]; then - echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 - echo "If there is no backup in progress anymore, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress-backup file." 1>&2 - exit 1 -fi + if [ -h $GHE_BACKUP_IN_PROGRESS ]; then + echo " Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 + echo " If there is no backup in progress anymore, please remove" 1>&2 + echo " the \"$GHE_DATA_DIR/i$GHE_BACKUP_IN_PROGRESS\" file and try again." 1>&2 + exit 1 + fi -if [ -f $GHE_BACKUP_IN_PROGRESS ]; then - progress=$(cat $GHE_BACKUP_IN_PROGRESS) - snapshot=$(echo "$progress" | cut -d ' ' -f 1) - pid=$(echo "$progress" | cut -d ' ' -f 2) - echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 - echo "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress file and try again." 1>&2 + if [ -f $GHE_BACKUP_IN_PROGRESS ]; then + progress=$(cat $GHE_BACKUP_IN_PROGRESS) + snapshot=$(echo "$progress" | cut -d ' ' -f 1) + pid=$(echo "$progress" | cut -d ' ' -f 2) + echo " Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 + echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2 + echo " the \"$GHE_BACKUP_IN_PROGRESS\" file and try again." 1>&2 exit 1 fi } From c88f8e03189a885ad15f41c4ad09c3e72e3a72b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Dec 2022 20:08:04 +0000 Subject: [PATCH 1555/2421] Bump actions/stale from 6 to 7 Bumps [actions/stale](https://github.com/actions/stale) from 6 to 7. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/stale-support-escalation.yml | 2 +- .github/workflows/stale.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stale-support-escalation.yml b/.github/workflows/stale-support-escalation.yml index a2e885f7c..276486abd 100644 --- a/.github/workflows/stale-support-escalation.yml +++ b/.github/workflows/stale-support-escalation.yml @@ -15,7 +15,7 @@ jobs: if: github.repository == 'github/ghes' || github.repository == 'github/enterprise2' || github.repository == 'github/backup-utils-private' runs-on: ubuntu-latest steps: - - uses: actions/stale@v6 + - uses: actions/stale@v7 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This support escalation issue is stale because it has been open 30 days with no activity. To make it never stale, add a label never-stale.' diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index e5a67d2b6..3b0ae345b 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/stale@v6 + - uses: actions/stale@v7 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: "👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot." From 6facf1da0060c140cf78a1d1d01f5c6f40f66416 Mon Sep 17 00:00:00 2001 From: felixrottler Date: Fri, 6 Jan 2023 12:17:05 +0100 Subject: [PATCH 1556/2421] feat: test node as hostname for mssql backup --- share/github-backup-utils/ghe-backup-mssql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 18e0e6e20..6469f4dc8 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -304,7 +304,7 @@ if [ -n "$backup_type" ]; then elif [ "$backup_type" = "transaction" ]; then backup_command='ghe-export-mssql -t' fi - + GHE_HOSTNAME="$(ghe-config cluster.mssql-master)" bm_start "$(basename $0)" ghe-ssh "$GHE_HOSTNAME" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename $0)" From a68e7927f474c946dab1dbbdead69761b5fe0679 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Fri, 6 Jan 2023 13:30:36 +0000 Subject: [PATCH 1557/2421] feat: update backup/restore mssql to always use mssql master hostname --- share/github-backup-utils/ghe-backup-mssql | 28 +++++++++++---------- share/github-backup-utils/ghe-restore-mssql | 13 ++++++---- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 6469f4dc8..597588fc4 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -22,18 +22,13 @@ tran_expire= # Check if the export tool is available in this version export_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-export-mssql" + ghe-ssh "$1" "test -e /usr/local/bin/ghe-export-mssql" else # Always return available for test return 0 fi } -if ! export_tool_available; then - ghe_verbose "ghe-export-mssql is not available" - exit -fi - add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS @@ -53,7 +48,7 @@ find_timestamp() { } actions_dbs() { - all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) + all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -p -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) for db in $all_dbs; do if [[ ! "$db" =~ ^(master|tempdb|model|msdb)$ ]] && [[ "$db" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "$db" @@ -90,7 +85,7 @@ ensure_same_dbs() { } run_query() { - echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh "$GHE_HOSTNAME" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' + echo "set -o pipefail; ghe-mssql-console -y -n -p -q \"SET NOCOUNT ON; $1\"" | ghe-ssh "$GHE_HOSTNAME" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' } get_latest_backup_file() { @@ -304,21 +299,28 @@ if [ -n "$backup_type" ]; then elif [ "$backup_type" = "transaction" ]; then backup_command='ghe-export-mssql -t' fi - GHE_HOSTNAME="$(ghe-config cluster.mssql-master)" + GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.mssql-master" || true)" + GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" + + if ! export_tool_available "$GHE_MSSQL_PRIMARY_HOST"; then + ghe_verbose "ghe-export-mssql is not available" + exit + fi + bm_start "$(basename $0)" - ghe-ssh "$GHE_HOSTNAME" -- "$backup_command" || failures="$failures mssql" + ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename $0)" # Configure the backup cadence on the appliance, which is used for diagnostics - ghe-ssh "$GHE_HOSTNAME" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" + ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then \ - sudo ls \"$appliance_dir\"; fi" | ghe-ssh "$GHE_HOSTNAME" /bin/bash) + sudo ls \"$appliance_dir\"; fi" | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) for b in $backups do ghe_verbose "Transferring to backup host $b" - ghe-ssh "$GHE_HOSTNAME" "sudo cat $appliance_dir/$b" > $backup_dir/$b + ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "sudo cat $appliance_dir/$b" > $backup_dir/$b done fi diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index dcf37fa37..aeef9dd18 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -29,8 +29,11 @@ fi # Grab host arg GHE_HOSTNAME="$1" +GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.mssql-master" || true)" +GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" + # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. -ghe_remote_version_required "$GHE_HOSTNAME" +ghe_remote_version_required "$GHE_MSSQL_PRIMARY_HOST" # The snapshot to restore should be set by the ghe-restore command but this lets # us run this script directly. @@ -41,20 +44,20 @@ snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_USER_DIR/mssql/backups" -echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh $GHE_HOSTNAME /bin/bash +echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" /bin/bash for b in $snapshot_dir_mssql/* do [[ -e "$b" ]] || break filename="${b##*/}" ghe_verbose "Transferring $filename to appliance host" - cat $snapshot_dir_mssql/$filename | ghe-ssh $GHE_HOSTNAME "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" + cat $snapshot_dir_mssql/$filename | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" done # Change owner to mssql:mssql to ready for restore -ghe-ssh $GHE_HOSTNAME "sudo chown -R mssql:mssql $appliance_dir" +ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" # Invoke restore command bm_start "$(basename $0)" -ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-mssql" < "/dev/null" 1>&3 +ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" -- "ghe-import-mssql" < "/dev/null" 1>&3 bm_end "$(basename $0)" From 14ccf9e66854d8d490c973cb72e9b75e72c7bd44 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 6 Jan 2023 14:39:27 +0000 Subject: [PATCH 1558/2421] cleanup from review --- bin/ghe-backup | 8 ++++++-- bin/ghe-restore | 6 ++++-- share/github-backup-utils/ghe-backup-config | 22 ++++++++++----------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 3b162177e..116694d15 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -123,7 +123,7 @@ ghe_restore_check if [ -h ../in-progress ]; then echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 echo "If there is no backup in progress anymore, please remove" 1>&2 - echo "the \"$GHE_DATA_DIR/in-progress\" file and try again." 1>&2 + echo "the $GHE_DATA_DIR/in-progress file and try again." 1>&2 exit 1 fi @@ -139,12 +139,13 @@ if [ -f ../in-progress ]; then echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 echo 1>&2 echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2 - echo " the \"$GHE_DATA_DIR/in-progress\" file and try again." 1>&2 + echo " the $GHE_DATA_DIR/in-progress file and try again." 1>&2 exit 1 fi fi echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress +echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ${GHE_DATA_DIR}/in-progress-backup echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" @@ -279,3 +280,6 @@ ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true # Make sure we exit zero after the conditional true + +# Remove in-progress file +ghe_backup_finished diff --git a/bin/ghe-restore b/bin/ghe-restore index 600a0b976..f91f68371 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -154,7 +154,8 @@ cleanup_cluster_nodes() { # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check -# ghe_restore_check +# Check to make sure another restore process is not running +ghe_restore_check # Grab the host arg GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" @@ -174,6 +175,7 @@ GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") export GHE_RESTORE_SNAPSHOT +# Check to make sure backup is not running ghe_backup_check # Detect if the backup we are restoring has a leaked ssh key @@ -587,7 +589,7 @@ echo 'End time:' $END_TIME echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." -rm -f ${GHE_DATA_DIR}/in-progress-restore +ghe_restore_finished if ! $instance_configured; then echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 5f034e644..6544a39f7 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -75,7 +75,7 @@ ghe_restore_check() { if [ -h $GHE_RESTORE_IN_PROGRESS ]; then echo " Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2 echo " If there is no restore in progress anymore, please remove" 1>&2 - echo " the \"$GHE_RESTORE_IN_PROGRESS\" file and try again." 1>&2 + echo " the $GHE_RESTORE_IN_PROGRESS file and try again." 1>&2 exit 1 fi @@ -85,7 +85,7 @@ ghe_restore_check() { pid=$(echo "$progress" | cut -d ' ' -f 2) echo " Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 echo " If PID $pid is not a process related to the restore utilities, please remove" 1>&2 - echo " the \"$GHE_RESTORE_IN_PROGRESS\" file and try again." 1>&2 + echo " the $GHE_RESTORE_IN_PROGRESS file and try again." 1>&2 exit 1 fi } @@ -94,7 +94,7 @@ ghe_backup_check() { if [ -h $GHE_BACKUP_IN_PROGRESS ]; then echo " Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 echo " If there is no backup in progress anymore, please remove" 1>&2 - echo " the \"$GHE_DATA_DIR/i$GHE_BACKUP_IN_PROGRESS\" file and try again." 1>&2 + echo " the $GHE_DATA_DIR/$GHE_BACKUP_IN_PROGRESS file and try again." 1>&2 exit 1 fi @@ -104,23 +104,21 @@ ghe_backup_check() { pid=$(echo "$progress" | cut -d ' ' -f 2) echo " Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2 - echo " the \"$GHE_BACKUP_IN_PROGRESS\" file and try again." 1>&2 + echo " the $GHE_BACKUP_IN_PROGRESS file and try again." 1>&2 exit 1 fi } ghe_restore_finished() { - echo "$GHE_RESTORE_IN_PROGRESS" - if [ -f $GHE_RESTORE_IN_PROGRESS ]; then - echo "$GHE_RESTORE_IN_PROGRESS exists!" 1>&2 - rm -f $GHE_RESTORE_IN_PROGRESS - fi + if [ -f $GHE_RESTORE_IN_PROGRESS ]; then + rm -f $GHE_RESTORE_IN_PROGRESS + fi } ghe_backup_finished() { - if [ -f $GHE_BACKUP_IN_PROGRESS ]; then - rm -f $GHE_BACKUP_IN_PROGRESS - fi + if [ -f $GHE_BACKUP_IN_PROGRESS ]; then + rm -f $GHE_BACKUP_IN_PROGRESS + fi } ghe_parallel_check() { From c8a0d4ebd7cfd8adef1909a72b250ad1893b3e94 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 6 Jan 2023 15:01:27 +0000 Subject: [PATCH 1559/2421] updated cleanup to remove in-progress file --- bin/ghe-backup | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index 116694d15..f8ac26e27 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -106,6 +106,7 @@ cleanup () { fi rm -rf "$failures_file" + rm -f ${GHE_DATA_DIR}/in-progress-backup # Cleanup SSH multiplexing ghe-ssh --clean From d039cfbf8043884eab199559abec0d5fc10f9f47 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Fri, 6 Jan 2023 15:34:56 +0000 Subject: [PATCH 1560/2421] feat: revert if tool available --- share/github-backup-utils/ghe-backup-mssql | 12 ++++++------ share/github-backup-utils/ghe-restore-mssql | 4 ++-- share/github-backup-utils/version | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 597588fc4..d15c4f111 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -22,13 +22,18 @@ tran_expire= # Check if the export tool is available in this version export_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh "$1" "test -e /usr/local/bin/ghe-export-mssql" + ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-export-mssql" else # Always return available for test return 0 fi } +if ! export_tool_available ; then + ghe_verbose "ghe-export-mssql is not available" + exit + fi + add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS @@ -302,11 +307,6 @@ if [ -n "$backup_type" ]; then GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.mssql-master" || true)" GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" - if ! export_tool_available "$GHE_MSSQL_PRIMARY_HOST"; then - ghe_verbose "ghe-export-mssql is not available" - exit - fi - bm_start "$(basename $0)" ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index aeef9dd18..78ca2dd3d 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -29,8 +29,8 @@ fi # Grab host arg GHE_HOSTNAME="$1" -GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.mssql-master" || true)" -GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" +GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" +GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_MSSQL_PRIMARY_HOST" diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 7c69a55db..19811903a 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.7.0 +3.8.0 From aa66220baaa527ebc9aa776fdb8824d4d204d565 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Fri, 6 Jan 2023 15:37:21 +0000 Subject: [PATCH 1561/2421] fix: revert version --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 19811903a..7c69a55db 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.8.0 +3.7.0 From 0b3e51f181f803a2055cae30fa5cddf5c6382c7f Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Fri, 6 Jan 2023 16:17:24 +0000 Subject: [PATCH 1562/2421] feat: early stopping if restore/backupp not available on target host --- share/github-backup-utils/ghe-backup-mssql | 7 ++++--- share/github-backup-utils/ghe-restore-mssql | 14 +++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index d15c4f111..0a4a6d06a 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -22,13 +22,16 @@ tran_expire= # Check if the export tool is available in this version export_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-export-mssql" + ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-export-mssql" else # Always return available for test return 0 fi } +GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.mssql-master" || true)" +GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" + if ! export_tool_available ; then ghe_verbose "ghe-export-mssql is not available" exit @@ -304,8 +307,6 @@ if [ -n "$backup_type" ]; then elif [ "$backup_type" = "transaction" ]; then backup_command='ghe-export-mssql -t' fi - GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.mssql-master" || true)" - GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" bm_start "$(basename $0)" ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 78ca2dd3d..110e2b086 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -15,23 +15,23 @@ set -e # Check if the import tool is available in this version import_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh "$GHE_HOSTNAME" "test -e /usr/local/bin/ghe-import-mssql" + ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-import-mssql" else - ghe-ssh "$GHE_HOSTNAME" "type ghe-import-mssql" + ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "type ghe-import-mssql" fi } -if ! import_tool_available; then - ghe_verbose "ghe-import-mssql is not available" - exit -fi - # Grab host arg GHE_HOSTNAME="$1" GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" +if ! import_tool_available; then + ghe_verbose "ghe-import-mssql is not available" + exit +fi + # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_MSSQL_PRIMARY_HOST" From e8ce2e6bf885696a58ff829de2378dba020f0ce3 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Fri, 6 Jan 2023 16:38:35 +0000 Subject: [PATCH 1563/2421] refactor: attempt to fix shellchecks --- share/github-backup-utils/ghe-backup-mssql | 56 +++++++++++---------- share/github-backup-utils/ghe-restore-mssql | 2 +- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 0a4a6d06a..4409a03eb 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -29,8 +29,8 @@ export_tool_available() { fi } -GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.mssql-master" || true)" -GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh $GHE_HOSTNAME -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" +GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" +GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" if ! export_tool_available ; then ghe_verbose "ghe-export-mssql is not available" @@ -41,9 +41,11 @@ add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS if date -v -1d > /dev/null 2>&1; then - echo "$(date -v +$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S)" + # shellcheck disable=SC2005 + echo "$(date -v +"$2"M -ujf'%Y%m%dT%H%M%S' "$1" +%Y%m%dT%H%M%S)" else dt=$1 + # shellcheck disable=SC2005 echo "$(date -u '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes")" fi } @@ -52,7 +54,7 @@ find_timestamp() { filename="${1##*/}" IFS='@' read -ra parts <<< "$filename" datetime_part=${parts[1]:0:15} - echo $datetime_part + echo "$datetime_part" } actions_dbs() { @@ -101,7 +103,7 @@ get_latest_backup_file() { db=$2 ext=$3 - latest_full_backup=$(find "$backups_dir" -type f -name "$db*.$ext" | egrep '[0-9]{8}T[0-9]{6}' | sort | tail -n 1) + latest_full_backup=$(find "$backups_dir" -type f -name "$db*.$ext" | grep -E '[0-9]{8}T[0-9]{6}' | sort | tail -n 1) latest_full_backup_file="${latest_full_backup##*/}" echo "$latest_full_backup_file" } @@ -149,8 +151,8 @@ get_next_diff_backup_base_lsn() { last_mssql=$GHE_DATA_DIR/current/mssql -if [ ! -d $last_mssql ] \ - || [ -z "$(find $last_mssql -type f -name '*.bak' | head -n 1)" ]; then +if [ ! -d "$last_mssql" ] \ + || [ -z "$(find "$last_mssql" -type f -name '*.bak' | head -n 1)" ]; then ghe_verbose "Taking first full backup" backup_type="full" else @@ -162,34 +164,34 @@ else current=$(date -u +%Y%m%d%H%M%S) full=$(find "$last_mssql" -type f -name "*.bak" | head -n 1) - full=$(find_timestamp $full) - full_expire=$(add_minute $full ${cadence[0]}) + full=$(find_timestamp "$full") + full_expire=$(add_minute "$full" "${cadence[0]}") full_expire="${full_expire//T}" diff=$(find "$last_mssql" -type f -name "*.diff" | head -n 1) if [ -f "$diff" ]; then - diff=$(find_timestamp $diff) - diff_expire=$(add_minute $diff ${cadence[1]}) + diff=$(find_timestamp "$diff") + diff_expire=$(add_minute "$diff" "${cadence[1]}") diff_expire="${diff_expire//T}" else - diff_expire=$(add_minute $full ${cadence[1]}) + diff_expire=$(add_minute "$full" "${cadence[1]}") diff_expire="${diff_expire//T}" fi - tran=$(find "$last_mssql" -type f -name "*.log" | egrep '[0-9]{8}T[0-9]{6}' | sort | tail -1) - tran=$(find_timestamp $tran) - tran_expire=$(add_minute $tran ${cadence[2]}) + tran=$(find "$last_mssql" -type f -name "*.log" | grep -E '[0-9]{8}T[0-9]{6}' | sort | tail -1) + tran=$(find_timestamp "$tran") + tran_expire=$(add_minute "$tran" "${cadence[2]}") tran_expire="${tran_expire//T}" ghe_verbose "current $current, full expire $full_expire, \ diff expire $diff_expire, tran expire $tran_expire" # Determine the type of backup to take based on expiry time - if [ $current -gt $full_expire ]; then + if [ "$current" -gt "$full_expire" ]; then backup_type='full' - elif [ $current -gt $diff_expire ]; then + elif [ "$current" -gt "$diff_expire" ]; then backup_type='diff' - elif [ $current -gt $tran_expire ]; then + elif [ "$current" -gt "$tran_expire" ]; then backup_type='transaction' fi @@ -267,8 +269,8 @@ fi mkdir -p "$backup_dir" # Use hard links to "copy" over previous applicable backups to the new snapshot folder to save disk space and time -if [ -d $last_mssql ]; then - for p in $last_mssql/* +if [ -d "$last_mssql" ]; then + for p in "$last_mssql"/* do [[ -e "$p" ]] || break @@ -277,23 +279,23 @@ if [ -d $last_mssql ]; then transfer= # Copy full backups unless we're taking a new full backup - if [ $extension = "bak" ] && [ "$backup_type" != 'full' ]; then + if [ "$extension" = "bak" ] && [ "$backup_type" != 'full' ]; then transfer=1 fi # Copy diff backups unless we're taking a new full or diff backup - if [ $extension = "diff" ] && [ "$backup_type" != 'full' ] && [ "$backup_type" != 'diff' ]; then + if [ "$extension" = "diff" ] && [ "$backup_type" != 'full' ] && [ "$backup_type" != 'diff' ]; then transfer=1 fi # Copy transaction log backups unless we're taking a new full or diff backup - if [ $extension = "log" ] && [ "$backup_type" != 'full' ] && [ "$backup_type" != 'diff' ]; then + if [ "$extension" = "log" ] && [ "$backup_type" != 'full' ] && [ "$backup_type" != 'diff' ]; then transfer=1 fi if [ -n "$transfer" ]; then ghe_verbose "Creating hard link to $filename" - ln $last_mssql/$filename $backup_dir/$filename + ln "$last_mssql"/"$filename" "$backup_dir"/"$filename" fi done fi @@ -308,9 +310,9 @@ if [ -n "$backup_type" ]; then backup_command='ghe-export-mssql -t' fi - bm_start "$(basename $0)" + bm_start "$(basename "$0")" ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" - bm_end "$(basename $0)" + bm_end "$(basename "$0")" # Configure the backup cadence on the appliance, which is used for diagnostics ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" @@ -322,6 +324,6 @@ if [ -n "$backup_type" ]; then for b in $backups do ghe_verbose "Transferring to backup host $b" - ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "sudo cat $appliance_dir/$b" > $backup_dir/$b + ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" done fi diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 110e2b086..48eb3f901 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -45,7 +45,7 @@ snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_USER_DIR/mssql/backups" echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" /bin/bash -for b in $snapshot_dir_mssql/* +for b in "$snapshot_dir_mssql"/* do [[ -e "$b" ]] || break From bb4fb0f69f764e1f6bb08ac5663084ead2fbd97d Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Fri, 6 Jan 2023 17:30:15 +0000 Subject: [PATCH 1564/2421] fix: standalone case --- share/github-backup-utils/ghe-backup-mssql | 4 ++++ share/github-backup-utils/ghe-restore-mssql | 4 ++++ share/github-backup-utils/ghe-rsync | 10 ++++++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 4409a03eb..67dfeaa10 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -32,6 +32,10 @@ export_tool_available() { GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" +if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then + GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" +fi + if ! export_tool_available ; then ghe_verbose "ghe-export-mssql is not available" exit diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 48eb3f901..185c98ef9 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -27,6 +27,10 @@ GHE_HOSTNAME="$1" GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" +if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then + GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" +fi + if ! import_tool_available; then ghe_verbose "ghe-import-mssql is not available" exit diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index c50835072..92fa102fd 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -10,7 +10,7 @@ set -o pipefail # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - +echo "debug 0" # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") @@ -19,18 +19,24 @@ else [[ ! $parameter == "--ignore-missing-args" ]] && parameters+=("$parameter") || ignore23=1 done fi - +echo "debug 1" ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' rsync_version_check=`rsync --version | egrep "version 3.[0-9]*.[0-9]*"` if [ ! -z "$rsync_version_check" ]; then # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe + echo "debug 1.1" rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) + else + echo "debug 1.2" # rsync <3.x sends errors to stdout. rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS | (egrep -v "$ignoreout" || true) + fi res=$? +echo "debug 2" + # Suppress exits with 24. if [ $res = 24 ]; then res=0 From c81c6fe182e4b26f320ebadd273251a1978b82c4 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 6 Jan 2023 20:55:22 +0000 Subject: [PATCH 1565/2421] Updated flags for readlink --- share/github-backup-utils/ghe-backup-config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 6544a39f7..fc769dfa6 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,8 +66,9 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done -GHE_RESTORE_IN_PROGRESS=$(readlink -f "${GHE_DATA_DIR}/in-progress-restore") -GHE_BACKUP_IN_PROGRESS=$(readlink -f "${GHE_DATA_DIR}/in-progress-backup") +GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore") +GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup") + export GHE_RESTORE_IN_PROGRESS export GHE_BACKUP_IN_PROGRESS From 0e824e9b0aee0ad40979ce43a3c9442d5fbaf6da Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Fri, 6 Jan 2023 20:55:49 +0000 Subject: [PATCH 1566/2421] feat: use proxycommand for communicating wih mssql master --- share/github-backup-utils/ghe-backup-mssql | 26 ++++++++++++++------- share/github-backup-utils/ghe-restore-mssql | 20 ++++++++++++---- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 67dfeaa10..722eb2435 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -37,9 +37,19 @@ if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then fi if ! export_tool_available ; then - ghe_verbose "ghe-export-mssql is not available" - exit - fi + ghe_verbose "ghe-export-mssql is not available" + exit +fi + +tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) +ssh_config_file_opt= +# git server hostnames under cluster +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" +fi add_minute() { # Expect date string in the format of yyyymmddTHHMMSS @@ -313,21 +323,21 @@ if [ -n "$backup_type" ]; then elif [ "$backup_type" = "transaction" ]; then backup_command='ghe-export-mssql -t' fi - + bm_start "$(basename "$0")" - ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename "$0")" # Configure the backup cadence on the appliance, which is used for diagnostics - ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then \ - sudo ls \"$appliance_dir\"; fi" | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) + sudo ls \"$appliance_dir\"; fi" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) for b in $backups do ghe_verbose "Transferring to backup host $b" - ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" done fi diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 185c98ef9..016dbf5bc 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -36,8 +36,18 @@ if ! import_tool_available; then exit fi +tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) +ssh_config_file_opt= +# git server hostnames under cluster +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" +fi + # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. -ghe_remote_version_required "$GHE_MSSQL_PRIMARY_HOST" +ghe_remote_version_required "$GHE_HOSTNAME" # The snapshot to restore should be set by the ghe-restore command but this lets # us run this script directly. @@ -48,20 +58,20 @@ snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_USER_DIR/mssql/backups" -echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" /bin/bash +echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash for b in "$snapshot_dir_mssql"/* do [[ -e "$b" ]] || break filename="${b##*/}" ghe_verbose "Transferring $filename to appliance host" - cat $snapshot_dir_mssql/$filename | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" + cat $snapshot_dir_mssql/$filename | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" done # Change owner to mssql:mssql to ready for restore -ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" +ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" # Invoke restore command bm_start "$(basename $0)" -ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" -- "ghe-import-mssql" < "/dev/null" 1>&3 +ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "ghe-import-mssql" < "/dev/null" 1>&3 bm_end "$(basename $0)" From 84ea75cecbb2d9d23bd44e8766279ec37300d67a Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Fri, 6 Jan 2023 20:58:55 +0000 Subject: [PATCH 1567/2421] fix: add missing proxy when check if tool available --- share/github-backup-utils/ghe-backup-mssql | 2 +- share/github-backup-utils/ghe-restore-mssql | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 722eb2435..acb9dd43d 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -22,7 +22,7 @@ tran_expire= # Check if the export tool is available in this version export_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-export-mssql" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-export-mssql" else # Always return available for test return 0 diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 016dbf5bc..b7e1dd7f0 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -15,9 +15,9 @@ set -e # Check if the import tool is available in this version import_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-import-mssql" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-import-mssql" else - ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" "type ghe-import-mssql" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "type ghe-import-mssql" fi } From 433e2890412e25f7d6378e65ea7f54b67d9e9a74 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Fri, 6 Jan 2023 21:12:33 +0000 Subject: [PATCH 1568/2421] fix: remove debug log --- share/github-backup-utils/ghe-rsync | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 92fa102fd..eadb79b0e 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -10,7 +10,7 @@ set -o pipefail # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -echo "debug 0" + # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") @@ -19,24 +19,20 @@ else [[ ! $parameter == "--ignore-missing-args" ]] && parameters+=("$parameter") || ignore23=1 done fi -echo "debug 1" + ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' rsync_version_check=`rsync --version | egrep "version 3.[0-9]*.[0-9]*"` if [ ! -z "$rsync_version_check" ]; then # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe - echo "debug 1.1" rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) else - echo "debug 1.2" # rsync <3.x sends errors to stdout. rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS | (egrep -v "$ignoreout" || true) fi res=$? -echo "debug 2" - # Suppress exits with 24. if [ $res = 24 ]; then res=0 From dfe3d14386fbd37d12f2a2b7d7bad59c2a8983f1 Mon Sep 17 00:00:00 2001 From: Felix Rottler <72494737+FelixRottler@users.noreply.github.com> Date: Fri, 6 Jan 2023 22:13:22 +0100 Subject: [PATCH 1569/2421] Apply suggestions from code review --- share/github-backup-utils/ghe-rsync | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index eadb79b0e..c50835072 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -25,11 +25,9 @@ rsync_version_check=`rsync --version | egrep "version 3.[0-9]*.[0-9]*"` if [ ! -z "$rsync_version_check" ]; then # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) - else # rsync <3.x sends errors to stdout. rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS | (egrep -v "$ignoreout" || true) - fi res=$? From 68aee3678ae7fd3d396d7d0c40c56930e0d78452 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Fri, 6 Jan 2023 16:24:04 -0500 Subject: [PATCH 1570/2421] Clarify OS requirements PR to clarify requirements based on discussion in https://github.com/github/ghes/issues/4511 --- docs/requirements.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index f6b9b8f31..3322ca63f 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,8 +5,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix operating -system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. +Backup host software requirements are modest: Linux operating (Ubuntu or Debian) system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From 8b88f50992b2d7700badb9ca8f3a8de6682d88d3 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Fri, 6 Jan 2023 16:28:50 -0500 Subject: [PATCH 1571/2421] Update requirements.md --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index 3322ca63f..648a25b8a 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,7 +5,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux operating (Ubuntu or Debian) system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. +Backup host software requirements are modest: Ubuntu Linux operating system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From aad7b7f51cb772a71c6160b60b72161810e19cea Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Mon, 9 Jan 2023 10:52:59 +0000 Subject: [PATCH 1572/2421] apply code review changes --- share/github-backup-utils/ghe-backup-mssql | 19 +++++++++++-------- share/github-backup-utils/ghe-restore-mssql | 7 ++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index acb9dd43d..bda8a5eb5 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -51,16 +51,19 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" fi +cleanup() { + rm -rf $tempdir +} +trap 'cleanup' EXIT INT + add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS if date -v -1d > /dev/null 2>&1; then - # shellcheck disable=SC2005 - echo "$(date -v +"$2"M -ujf'%Y%m%dT%H%M%S' "$1" +%Y%m%dT%H%M%S)" + date -v +"$2"M -ujf'%Y%m%dT%H%M%S' "$1" +%Y%m%dT%H%M%S else dt=$1 - # shellcheck disable=SC2005 - echo "$(date -u '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes")" + date -u '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes" fi } @@ -72,7 +75,7 @@ find_timestamp() { } actions_dbs() { - all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -p -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) + all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) for db in $all_dbs; do if [[ ! "$db" =~ ^(master|tempdb|model|msdb)$ ]] && [[ "$db" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "$db" @@ -109,7 +112,7 @@ ensure_same_dbs() { } run_query() { - echo "set -o pipefail; ghe-mssql-console -y -n -p -q \"SET NOCOUNT ON; $1\"" | ghe-ssh "$GHE_HOSTNAME" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' + echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' } get_latest_backup_file() { @@ -325,11 +328,11 @@ if [ -n "$backup_type" ]; then fi bm_start "$(basename "$0")" - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" + ghe-ssh "$GHE_HOSTNAME" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename "$0")" # Configure the backup cadence on the appliance, which is used for diagnostics - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" + ghe-ssh "$GHE_HOSTNAME" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index b7e1dd7f0..2d7d9c149 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -46,6 +46,11 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" fi +cleanup() { + rm -rf $tempdir +} +trap 'cleanup' EXIT INT + # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" @@ -73,5 +78,5 @@ ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssq # Invoke restore command bm_start "$(basename $0)" -ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "ghe-import-mssql" < "/dev/null" 1>&3 +ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-mssql" < "/dev/null" 1>&3 bm_end "$(basename $0)" From 8130858c9792687bbf88d421476ba1e4c6fc5334 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Tue, 10 Jan 2023 13:27:07 +0000 Subject: [PATCH 1573/2421] fix: use ssh config opts to execute ghe-import-mssql on the mssql-master because it depends on the local filesystem --- share/github-backup-utils/ghe-restore-mssql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 2d7d9c149..984284166 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -78,5 +78,5 @@ ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssq # Invoke restore command bm_start "$(basename $0)" -ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-mssql" < "/dev/null" 1>&3 +ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "ghe-import-mssql" < "/dev/null" 1>&3 bm_end "$(basename $0)" From f5dcb32fcd49bcdaa8acb1e8a294baf424121746 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 10 Jan 2023 16:35:48 +0000 Subject: [PATCH 1574/2421] updated flags for readlink --- share/github-backup-utils/ghe-backup-config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index fc769dfa6..251425d9b 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,8 +66,8 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done -GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore") -GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup") +GHE_RESTORE_IN_PROGRESS=$(readlink -m "${GHE_DATA_DIR}/in-progress-restore") +GHE_BACKUP_IN_PROGRESS=$(readlink -m "${GHE_DATA_DIR}/in-progress-backup") export GHE_RESTORE_IN_PROGRESS export GHE_BACKUP_IN_PROGRESS From aec0c96496305d9197f9b7818318383ef2946ec1 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Tue, 10 Jan 2023 17:19:42 +0000 Subject: [PATCH 1575/2421] feat: use proxycommand when communicating with mssql-master and revert shellcheck for date parsing --- share/github-backup-utils/ghe-backup-mssql | 13 +++++++------ share/github-backup-utils/ghe-restore-mssql | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index bda8a5eb5..0a28edba5 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -43,6 +43,7 @@ fi tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= +opts= # git server hostnames under cluster if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" @@ -60,10 +61,10 @@ add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS if date -v -1d > /dev/null 2>&1; then - date -v +"$2"M -ujf'%Y%m%dT%H%M%S' "$1" +%Y%m%dT%H%M%S + echo "$(date -v +$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S)" else dt=$1 - date -u '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes" + echo "$(date -u '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes")" fi } @@ -75,7 +76,7 @@ find_timestamp() { } actions_dbs() { - all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) + all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) for db in $all_dbs; do if [[ ! "$db" =~ ^(master|tempdb|model|msdb)$ ]] && [[ "$db" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "$db" @@ -112,7 +113,7 @@ ensure_same_dbs() { } run_query() { - echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh "$GHE_MSSQL_PRIMARY_HOST" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' + echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' } get_latest_backup_file() { @@ -328,11 +329,11 @@ if [ -n "$backup_type" ]; then fi bm_start "$(basename "$0")" - ghe-ssh "$GHE_HOSTNAME" -- "$backup_command" || failures="$failures mssql" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename "$0")" # Configure the backup cadence on the appliance, which is used for diagnostics - ghe-ssh "$GHE_HOSTNAME" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 984284166..3f3a7383c 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -38,6 +38,7 @@ fi tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= +opts= # git server hostnames under cluster if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" From b0701db509204cf2fd6660e1581afde1a659be09 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 10 Jan 2023 17:25:11 +0000 Subject: [PATCH 1576/2421] Removed unused variable --- share/github-backup-utils/ghe-backup-config | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 251425d9b..ab0e24d4d 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -66,8 +66,8 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done -GHE_RESTORE_IN_PROGRESS=$(readlink -m "${GHE_DATA_DIR}/in-progress-restore") -GHE_BACKUP_IN_PROGRESS=$(readlink -m "${GHE_DATA_DIR}/in-progress-backup") +GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore") +GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup") export GHE_RESTORE_IN_PROGRESS export GHE_BACKUP_IN_PROGRESS @@ -82,7 +82,6 @@ ghe_restore_check() { if [ -f $GHE_RESTORE_IN_PROGRESS ]; then progress=$(cat $GHE_RESTORE_IN_PROGRESS) - snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) echo " Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 echo " If PID $pid is not a process related to the restore utilities, please remove" 1>&2 @@ -101,7 +100,6 @@ ghe_backup_check() { if [ -f $GHE_BACKUP_IN_PROGRESS ]; then progress=$(cat $GHE_BACKUP_IN_PROGRESS) - snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) echo " Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2 From e6bd253a98ade75859f01e544ff410a32ac27369 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 10 Jan 2023 11:29:15 -0800 Subject: [PATCH 1577/2421] remove deprecated Actions runner version --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb8f775d9..8cda18493 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ jobs: build: strategy: matrix: - os: ['ubuntu-22.04', 'ubuntu-20.04', 'ubuntu-18.04', 'macos-latest'] + os: ['ubuntu-22.04', 'ubuntu-20.04', 'macos-latest'] fail-fast: false runs-on: ${{ matrix.os }} steps: From 037edd978b50029e25aa5cc8d0d81735831044f0 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Wed, 11 Jan 2023 10:32:34 +0000 Subject: [PATCH 1578/2421] fix: check import/export tool after configuring ssh --- share/github-backup-utils/ghe-backup-mssql | 13 +++++++------ share/github-backup-utils/ghe-restore-mssql | 10 +++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 0a28edba5..a61b44a18 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -36,14 +36,10 @@ if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" fi -if ! export_tool_available ; then - ghe_verbose "ghe-export-mssql is not available" - exit -fi - tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= opts= + # git server hostnames under cluster if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" @@ -52,10 +48,15 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" fi +if ! export_tool_available ; then + ghe_verbose "ghe-export-mssql is not available" + exit +fi + cleanup() { rm -rf $tempdir } -trap 'cleanup' EXIT INT +#trap 'cleanup' EXIT INT add_minute() { # Expect date string in the format of yyyymmddTHHMMSS diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 3f3a7383c..408b34f54 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -31,11 +31,6 @@ if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" fi -if ! import_tool_available; then - ghe_verbose "ghe-import-mssql is not available" - exit -fi - tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= opts= @@ -47,6 +42,11 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" fi +if ! import_tool_available; then + ghe_verbose "ghe-import-mssql is not available" + exit +fi + cleanup() { rm -rf $tempdir } From 1f84c1b91c03a4019cef42a4b2b1a9dfb4043978 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Wed, 11 Jan 2023 11:23:16 +0000 Subject: [PATCH 1579/2421] feat: add execute permission for ghe-import-mssql --- share/github-backup-utils/ghe-restore-mssql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 408b34f54..f24fbf8e5 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -76,6 +76,8 @@ done # Change owner to mssql:mssql to ready for restore ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" +# Change permission of ghe-import-mssql +ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chmod +x /usr/local/bin/ghe-import-mssql" # Invoke restore command bm_start "$(basename $0)" From efe5c8ea911c49b69efd8e9d4c03604e76bc14cd Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Wed, 11 Jan 2023 13:13:08 +0000 Subject: [PATCH 1580/2421] fix: try remote_dir for fixing tests --- share/github-backup-utils/ghe-restore-mssql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index f24fbf8e5..941a30614 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -77,7 +77,7 @@ done # Change owner to mssql:mssql to ready for restore ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" # Change permission of ghe-import-mssql -ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chmod +x /usr/local/bin/ghe-import-mssql" +ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chmod +x $GHE_REMOTE_ROOT_DIR/usr/local/bin/ghe-import-mssql" # Invoke restore command bm_start "$(basename $0)" From f8967f2e1eb7861e518cc98a0c8f710b5131fc25 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Wed, 11 Jan 2023 13:22:19 +0000 Subject: [PATCH 1581/2421] fix: add correct chmod path for testing --- test/testlib.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/testlib.sh b/test/testlib.sh index 4abbc3281..9193cfbfd 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -86,6 +86,8 @@ setup_remote_metadata () { mkdir -p "$GHE_REMOTE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" + mkdir -p "$GHE_REMOTE_ROOT_DIR/usr/local/bin" + touch "$GHE_REMOTE_ROOT_DIR/usr/local/bin/ghe-import-mssql" } setup_remote_metadata From 0337f6a122147919a6fda8e24d949218e7c4c258 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 11 Jan 2023 09:45:16 -0800 Subject: [PATCH 1582/2421] Remove "Debian" --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3904b1e6c..0ca099a7f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -15,11 +15,11 @@ jobs: steps: - uses: actions/checkout@v3 - name: Build the Debian Docker image - run: docker build . --file Dockerfile --tag backup-utils-debian:${GITHUB_RUN_ID} + run: docker build . --file Dockerfile --tag backup-utils:${GITHUB_RUN_ID} - name: Build the Alpine Docker image run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID} - name: Run tests in Debian Docker image - run: docker run backup-utils-debian:${GITHUB_RUN_ID} ghe-backup --version + run: docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version - name: Run tests in Alpine Docker image run: docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version From 9273eb4a0a6f6ff797015218023e8204daa51f39 Mon Sep 17 00:00:00 2001 From: Felix Rottler <72494737+FelixRottler@users.noreply.github.com> Date: Wed, 11 Jan 2023 20:45:26 +0100 Subject: [PATCH 1583/2421] Apply suggestions from code review --- share/github-backup-utils/ghe-restore-mssql | 1 - test/testlib.sh | 2 -- 2 files changed, 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 941a30614..13e9809b8 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -77,7 +77,6 @@ done # Change owner to mssql:mssql to ready for restore ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" # Change permission of ghe-import-mssql -ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chmod +x $GHE_REMOTE_ROOT_DIR/usr/local/bin/ghe-import-mssql" # Invoke restore command bm_start "$(basename $0)" diff --git a/test/testlib.sh b/test/testlib.sh index 9193cfbfd..4abbc3281 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -86,8 +86,6 @@ setup_remote_metadata () { mkdir -p "$GHE_REMOTE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" - mkdir -p "$GHE_REMOTE_ROOT_DIR/usr/local/bin" - touch "$GHE_REMOTE_ROOT_DIR/usr/local/bin/ghe-import-mssql" } setup_remote_metadata From 1f3d33375b5086e1c3d0c8dfd1fd0b7e2af7c3b4 Mon Sep 17 00:00:00 2001 From: Felix Rottler <72494737+FelixRottler@users.noreply.github.com> Date: Wed, 11 Jan 2023 20:45:44 +0100 Subject: [PATCH 1584/2421] Update share/github-backup-utils/ghe-restore-mssql --- share/github-backup-utils/ghe-restore-mssql | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 13e9809b8..408b34f54 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -76,7 +76,6 @@ done # Change owner to mssql:mssql to ready for restore ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" -# Change permission of ghe-import-mssql # Invoke restore command bm_start "$(basename $0)" From c0c1d81e0a74a52922d18122aa849bf53b0d91ce Mon Sep 17 00:00:00 2001 From: Felix Rottler <72494737+FelixRottler@users.noreply.github.com> Date: Wed, 11 Jan 2023 20:48:55 +0100 Subject: [PATCH 1585/2421] Apply suggestions from code review --- share/github-backup-utils/ghe-backup-mssql | 4 ++-- share/github-backup-utils/ghe-restore-mssql | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index a61b44a18..9d2159796 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -38,7 +38,7 @@ fi tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= -opts= +opts=$GHE_EXTRA_SSH_OPTS # git server hostnames under cluster if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then @@ -56,7 +56,7 @@ fi cleanup() { rm -rf $tempdir } -#trap 'cleanup' EXIT INT +trap 'cleanup' EXIT INT add_minute() { # Expect date string in the format of yyyymmddTHHMMSS diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 408b34f54..509bef1ee 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -33,7 +33,7 @@ fi tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= -opts= +opts=$GHE_EXTRA_SSH_OPTS # git server hostnames under cluster if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" From 259717907384003ddfe01271b5a555b93cc0af80 Mon Sep 17 00:00:00 2001 From: Felix Rottler <72494737+FelixRottler@users.noreply.github.com> Date: Thu, 12 Jan 2023 10:48:55 +0100 Subject: [PATCH 1586/2421] Apply suggestions from code review set options to static string b/c $GHE_EXTRA_SSH_OPTS refers to GHE_HOSTNAME and not GHE_MSSQL_PRIMARY_HOST --- share/github-backup-utils/ghe-backup-mssql | 4 ++-- share/github-backup-utils/ghe-restore-mssql | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 9d2159796..b67fdb99b 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -38,13 +38,13 @@ fi tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= -opts=$GHE_EXTRA_SSH_OPTS +opts= # git server hostnames under cluster if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" fi diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 509bef1ee..eb97220d5 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -33,12 +33,12 @@ fi tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= -opts=$GHE_EXTRA_SSH_OPTS +opts= # git server hostnames under cluster if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" fi From 167e3dc5a60775c10a0c227e16c245d7cc25d296 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Thu, 12 Jan 2023 15:21:11 +0000 Subject: [PATCH 1587/2421] apply code review changes --- share/github-backup-utils/ghe-backup-mssql | 33 +++++---------------- share/github-backup-utils/ghe-restore-mssql | 33 ++++----------------- share/github-backup-utils/ghe-ssh-mssql | 32 ++++++++++++++++++++ 3 files changed, 45 insertions(+), 53 deletions(-) create mode 100755 share/github-backup-utils/ghe-ssh-mssql diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index b67fdb99b..78b8daa04 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -22,32 +22,13 @@ tran_expire= # Check if the export tool is available in this version export_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-export-mssql" + ghe-ssh-mssql "test -e /usr/local/bin/ghe-export-mssql" else # Always return available for test return 0 fi } -GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" -GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" - -if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then - GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" -fi - -tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) -ssh_config_file_opt= -opts= - -# git server hostnames under cluster -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" -fi - if ! export_tool_available ; then ghe_verbose "ghe-export-mssql is not available" exit @@ -77,7 +58,7 @@ find_timestamp() { } actions_dbs() { - all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) + all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh-mssql /bin/bash) for db in $all_dbs; do if [[ ! "$db" =~ ^(master|tempdb|model|msdb)$ ]] && [[ "$db" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "$db" @@ -114,7 +95,7 @@ ensure_same_dbs() { } run_query() { - echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' + echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh-mssql /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' } get_latest_backup_file() { @@ -330,19 +311,19 @@ if [ -n "$backup_type" ]; then fi bm_start "$(basename "$0")" - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" + ghe-ssh-mssql -- "$backup_command" || failures="$failures mssql" bm_end "$(basename "$0")" # Configure the backup cadence on the appliance, which is used for diagnostics - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" + ghe-ssh-mssql "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then \ - sudo ls \"$appliance_dir\"; fi" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) + sudo ls \"$appliance_dir\"; fi" | ghe-ssh-mssql /bin/bash) for b in $backups do ghe_verbose "Transferring to backup host $b" - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" + ghe-ssh-mssql "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" done fi diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index eb97220d5..fd81955b4 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -15,33 +15,12 @@ set -e # Check if the import tool is available in this version import_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-import-mssql" + ghe-ssh-mssql "test -e /usr/local/bin/ghe-import-mssql" else - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "type ghe-import-mssql" + ghe-ssh-mssql "type ghe-import-mssql" fi } -# Grab host arg -GHE_HOSTNAME="$1" - -GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" -GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" - -if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then - GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" -fi - -tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) -ssh_config_file_opt= -opts= -# git server hostnames under cluster -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" -fi - if ! import_tool_available; then ghe_verbose "ghe-import-mssql is not available" exit @@ -64,20 +43,20 @@ snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_USER_DIR/mssql/backups" -echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash +echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh-mssql /bin/bash for b in "$snapshot_dir_mssql"/* do [[ -e "$b" ]] || break filename="${b##*/}" ghe_verbose "Transferring $filename to appliance host" - cat $snapshot_dir_mssql/$filename | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" + cat $snapshot_dir_mssql/$filename | ghe-ssh-mssql "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" done # Change owner to mssql:mssql to ready for restore -ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" +ghe-ssh-mssql "sudo chown -R mssql:mssql $appliance_dir" # Invoke restore command bm_start "$(basename $0)" -ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "ghe-import-mssql" < "/dev/null" 1>&3 +ghe-ssh-mssql -- "ghe-import-mssql" < "/dev/null" 1>&3 bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-ssh-mssql b/share/github-backup-utils/ghe-ssh-mssql new file mode 100755 index 000000000..653f5ea52 --- /dev/null +++ b/share/github-backup-utils/ghe-ssh-mssql @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +#/ Usage: ghe-ssh-mssql [...] +#/ +#/ Helper to ssh into the mssql master instance with the correct ssh configuration. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# use the mssql primary host if GHES cluster configuration contains a mssql-master or use the ghe server if the mssql-master is not available. +GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" +GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" + +if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then + GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" +fi + +tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) +ssh_config_file_opt= +opts= + +# proxy ssh to mssql-master via GHE_HOSTNAME +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" +fi + + +exec ghe-ssh $opts $ssh_config_file_opt $GHE_MSSQL_PRIMARY_HOST "$@" \ No newline at end of file From 1f4ca50f9211e62b11e51f88eeec5a41dde5c639 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Thu, 12 Jan 2023 15:32:58 +0000 Subject: [PATCH 1588/2421] Revert "apply code review changes" This reverts commit 167e3dc5a60775c10a0c227e16c245d7cc25d296. --- share/github-backup-utils/ghe-backup-mssql | 33 ++++++++++++++++----- share/github-backup-utils/ghe-restore-mssql | 33 +++++++++++++++++---- share/github-backup-utils/ghe-ssh-mssql | 32 -------------------- 3 files changed, 53 insertions(+), 45 deletions(-) delete mode 100755 share/github-backup-utils/ghe-ssh-mssql diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 78b8daa04..b67fdb99b 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -22,13 +22,32 @@ tran_expire= # Check if the export tool is available in this version export_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh-mssql "test -e /usr/local/bin/ghe-export-mssql" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-export-mssql" else # Always return available for test return 0 fi } +GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" +GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" + +if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then + GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" +fi + +tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) +ssh_config_file_opt= +opts= + +# git server hostnames under cluster +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" +fi + if ! export_tool_available ; then ghe_verbose "ghe-export-mssql is not available" exit @@ -58,7 +77,7 @@ find_timestamp() { } actions_dbs() { - all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh-mssql /bin/bash) + all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) for db in $all_dbs; do if [[ ! "$db" =~ ^(master|tempdb|model|msdb)$ ]] && [[ "$db" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "$db" @@ -95,7 +114,7 @@ ensure_same_dbs() { } run_query() { - echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh-mssql /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' + echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' } get_latest_backup_file() { @@ -311,19 +330,19 @@ if [ -n "$backup_type" ]; then fi bm_start "$(basename "$0")" - ghe-ssh-mssql -- "$backup_command" || failures="$failures mssql" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" bm_end "$(basename "$0")" # Configure the backup cadence on the appliance, which is used for diagnostics - ghe-ssh-mssql "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then \ - sudo ls \"$appliance_dir\"; fi" | ghe-ssh-mssql /bin/bash) + sudo ls \"$appliance_dir\"; fi" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) for b in $backups do ghe_verbose "Transferring to backup host $b" - ghe-ssh-mssql "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" done fi diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index fd81955b4..eb97220d5 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -15,12 +15,33 @@ set -e # Check if the import tool is available in this version import_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh-mssql "test -e /usr/local/bin/ghe-import-mssql" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-import-mssql" else - ghe-ssh-mssql "type ghe-import-mssql" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "type ghe-import-mssql" fi } +# Grab host arg +GHE_HOSTNAME="$1" + +GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" +GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" + +if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then + GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" +fi + +tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) +ssh_config_file_opt= +opts= +# git server hostnames under cluster +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + ssh_config_file="$tempdir/ssh_config" + ssh_config_file_opt="-F $ssh_config_file" + opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" +fi + if ! import_tool_available; then ghe_verbose "ghe-import-mssql is not available" exit @@ -43,20 +64,20 @@ snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_USER_DIR/mssql/backups" -echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh-mssql /bin/bash +echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash for b in "$snapshot_dir_mssql"/* do [[ -e "$b" ]] || break filename="${b##*/}" ghe_verbose "Transferring $filename to appliance host" - cat $snapshot_dir_mssql/$filename | ghe-ssh-mssql "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" + cat $snapshot_dir_mssql/$filename | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" done # Change owner to mssql:mssql to ready for restore -ghe-ssh-mssql "sudo chown -R mssql:mssql $appliance_dir" +ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" # Invoke restore command bm_start "$(basename $0)" -ghe-ssh-mssql -- "ghe-import-mssql" < "/dev/null" 1>&3 +ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "ghe-import-mssql" < "/dev/null" 1>&3 bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-ssh-mssql b/share/github-backup-utils/ghe-ssh-mssql deleted file mode 100755 index 653f5ea52..000000000 --- a/share/github-backup-utils/ghe-ssh-mssql +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-ssh-mssql [...] -#/ -#/ Helper to ssh into the mssql master instance with the correct ssh configuration. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# use the mssql primary host if GHES cluster configuration contains a mssql-master or use the ghe server if the mssql-master is not available. -GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" -GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" - -if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then - GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" -fi - -tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) -ssh_config_file_opt= -opts= - -# proxy ssh to mssql-master via GHE_HOSTNAME -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" -fi - - -exec ghe-ssh $opts $ssh_config_file_opt $GHE_MSSQL_PRIMARY_HOST "$@" \ No newline at end of file From 53f5b0c9203cc5edec3a2f70834a08a9190c7e15 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Thu, 12 Jan 2023 15:38:54 +0000 Subject: [PATCH 1589/2421] use local wrapper for handling ssh into mssql primary --- share/github-backup-utils/ghe-backup-mssql | 27 ++++++++++++--------- share/github-backup-utils/ghe-restore-mssql | 23 +++++++++++------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index b67fdb99b..6e44108cb 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -29,6 +29,16 @@ export_tool_available() { fi } +ghe_ssh_mssql() { + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" $@ +} + +cleanup() { + rm -rf $tempdir +} +trap 'cleanup' EXIT INT + +# use the mssql primary host if GHES cluster configuration contains a mssql-master or use the ghe server if the mssql-master is not available. GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" @@ -53,11 +63,6 @@ if ! export_tool_available ; then exit fi -cleanup() { - rm -rf $tempdir -} -trap 'cleanup' EXIT INT - add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS @@ -77,7 +82,7 @@ find_timestamp() { } actions_dbs() { - all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) + all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe_ssh_mssql /bin/bash) for db in $all_dbs; do if [[ ! "$db" =~ ^(master|tempdb|model|msdb)$ ]] && [[ "$db" =~ ^[a-zA-Z0-9_-]+$ ]]; then echo "$db" @@ -114,7 +119,7 @@ ensure_same_dbs() { } run_query() { - echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' + echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe_ssh_mssql /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' } get_latest_backup_file() { @@ -330,19 +335,19 @@ if [ -n "$backup_type" ]; then fi bm_start "$(basename "$0")" - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "$backup_command" || failures="$failures mssql" + ghe_ssh_mssql -- "$backup_command" || failures="$failures mssql" bm_end "$(basename "$0")" # Configure the backup cadence on the appliance, which is used for diagnostics - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" + ghe_ssh_mssql "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then \ - sudo ls \"$appliance_dir\"; fi" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash) + sudo ls \"$appliance_dir\"; fi" | ghe_ssh_mssql /bin/bash) for b in $backups do ghe_verbose "Transferring to backup host $b" - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" + ghe_ssh_mssql "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" done fi diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index eb97220d5..f76cf6034 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -21,9 +21,19 @@ import_tool_available() { fi } +ghe_ssh_mssql() { + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" $@ +} + +cleanup() { + rm -rf $tempdir +} +trap 'cleanup' EXIT INT + # Grab host arg GHE_HOSTNAME="$1" +# use the mssql primary host if GHES cluster configuration contains a mssql-master or use the ghe server if the mssql-master is not available. GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" @@ -47,11 +57,6 @@ if ! import_tool_available; then exit fi -cleanup() { - rm -rf $tempdir -} -trap 'cleanup' EXIT INT - # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" @@ -64,20 +69,20 @@ snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" # Transfer backup files from appliance to backup host appliance_dir="$GHE_REMOTE_DATA_USER_DIR/mssql/backups" -echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" /bin/bash +echo "set -o pipefail; sudo rm -rf $appliance_dir; sudo mkdir -p $appliance_dir" | ghe_ssh_mssql /bin/bash for b in "$snapshot_dir_mssql"/* do [[ -e "$b" ]] || break filename="${b##*/}" ghe_verbose "Transferring $filename to appliance host" - cat $snapshot_dir_mssql/$filename | ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" + cat $snapshot_dir_mssql/$filename | ghe_ssh_mssql "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" done # Change owner to mssql:mssql to ready for restore -ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "sudo chown -R mssql:mssql $appliance_dir" +ghe_ssh_mssql "sudo chown -R mssql:mssql $appliance_dir" # Invoke restore command bm_start "$(basename $0)" -ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" -- "ghe-import-mssql" < "/dev/null" 1>&3 +ghe_ssh_mssql -- "ghe-import-mssql" < "/dev/null" 1>&3 bm_end "$(basename $0)" From acd4dfabf3a6c983bd0c5b30440248ebd98f1195 Mon Sep 17 00:00:00 2001 From: Felix Rottler Date: Thu, 12 Jan 2023 15:43:02 +0000 Subject: [PATCH 1590/2421] replace remaining ghe-ssh calls with ghe_ssh_mssql --- share/github-backup-utils/ghe-backup-mssql | 2 +- share/github-backup-utils/ghe-restore-mssql | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 6e44108cb..17380b3da 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -22,7 +22,7 @@ tran_expire= # Check if the export tool is available in this version export_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-export-mssql" + ghe_ssh_mssql "test -e /usr/local/bin/ghe-export-mssql" else # Always return available for test return 0 diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index f76cf6034..d5afce0dc 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -15,9 +15,9 @@ set -e # Check if the import tool is available in this version import_tool_available() { if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "test -e /usr/local/bin/ghe-import-mssql" + ghe_ssh_mssql "test -e /usr/local/bin/ghe-import-mssql" else - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "type ghe-import-mssql" + ghe_ssh_mssql "type ghe-import-mssql" fi } From 8bb1a48d2c8a21d54a52bb9e324ff073b5f456f2 Mon Sep 17 00:00:00 2001 From: Felix Rottler <72494737+FelixRottler@users.noreply.github.com> Date: Thu, 12 Jan 2023 16:55:40 +0100 Subject: [PATCH 1591/2421] Apply suggestions from code review --- share/github-backup-utils/ghe-backup-mssql | 2 +- share/github-backup-utils/ghe-restore-mssql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 17380b3da..b40f42925 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -30,7 +30,7 @@ export_tool_available() { } ghe_ssh_mssql() { - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" $@ + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "$@" } cleanup() { diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index d5afce0dc..469397076 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -22,7 +22,7 @@ import_tool_available() { } ghe_ssh_mssql() { - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" $@ + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "$@" } cleanup() { From c1631752ab281e5efcd582f4c47b1f1f6f2cef78 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 18 Jan 2023 19:33:12 +0000 Subject: [PATCH 1592/2421] remove macos-latest from tests --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb8f775d9..b4ceacdcd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,11 +2,15 @@ name: Test and build on: [pull_request] + jobs: build: strategy: matrix: - os: ['ubuntu-22.04', 'ubuntu-20.04', 'ubuntu-18.04', 'macos-latest'] + # macos-latest references are kept here for historical purposes. removed macos-latest from the + #matrix as it is not a typical case for users and causes a lot of friction with other linux-based + # installs. Recommend developing on codespaces or using an ubuntu container. + os: ['ubuntu-22.04', 'ubuntu-20.04', 'ubuntu-18.04'] fail-fast: false runs-on: ${{ matrix.os }} steps: From 0447b39c018a3d099f15a33b91bf801d86586a20 Mon Sep 17 00:00:00 2001 From: boxofyellow Date: Wed, 18 Jan 2023 15:28:56 -0500 Subject: [PATCH 1593/2421] Fix up HA without cluster --- share/github-backup-utils/ghe-backup-mssql | 6 ++++-- share/github-backup-utils/ghe-restore-mssql | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index b40f42925..c2ab49ce4 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -50,8 +50,10 @@ tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= opts= -# git server hostnames under cluster -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then +isHA="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.ha" || true)" + +# get server hostnames under cluster and HA +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ] || [ "$isHA" = "true" ] ; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 469397076..3b62ce2c8 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -44,8 +44,11 @@ fi tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) ssh_config_file_opt= opts= -# git server hostnames under cluster -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + +isHA="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.ha" || true)" + +# get server hostnames under cluster and HA +if [ "$GHE_BACKUP_STRATEGY" = "cluster" ] || [ "$isHA" = "true" ] ; then ssh_config_file="$tempdir/ssh_config" ssh_config_file_opt="-F $ssh_config_file" opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" From 61408d189c51afc12cb5bf2a5f357f8313667815 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Mon, 23 Jan 2023 14:01:15 +0100 Subject: [PATCH 1594/2421] adding conditional check to save argon secrets only for ghes version >3.7.0 --- share/github-backup-utils/ghe-backup-settings | 6 +++++- test/test-ghe-backup.sh | 18 +++++++++++++++--- test/testlib.sh | 4 +++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 803ab9193..5516e811b 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -75,11 +75,15 @@ backup-secret() { } backup-secret "management console password" "manage-password" "secrets.manage" -backup-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" +# Backup argon secrets for multiuser from ghes version 3.8 onwards +if [ "$(version $GHE_REMOTE_VERSION)" -gt "$(version 3.7.0)" ]; then + backup-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" +fi + # Backup external MySQL password if running external MySQL DB. if is_service_external 'mysql'; then backup-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 1735504dc..f1d0fb3a9 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -132,17 +132,29 @@ begin_test "ghe-backup without password pepper" ) end_test -begin_test "ghe-backup without management console argon2 secret" +begin_test "ghe-backup without management console argon2 secret for ghes lower than 3.8" ( set -e - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage-auth.argon-secret "" - ghe-backup + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage-auth.argon-secret "fake pw" + GHE_REMOTE_VERSION=3.7.0 ghe-backup [ ! -f "$GHE_DATA_DIR/current/manage-argon-secret" ] ) end_test +# multiuser auth introduced in ghes version 3.8 +begin_test "ghe-backup management console argon2 secret" +( + set -e + + git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage-auth.argon-secret "fake pw" + GHE_REMOTE_VERSION=3.8.0 ghe-backup + + [ "$(cat "$GHE_DATA_DIR/current/manage-argon-secret")" = "fake pw" ] +) +end_test + begin_test "ghe-backup empty git-hooks directory" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index 4abbc3281..c9769b4ea 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -448,7 +448,9 @@ verify_all_backedup_data() { [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] # verify manage-argon-secret file was backed up - [ "$(cat "$GHE_DATA_DIR/current/manage-argon-secret")" = "fake argon2 secret" ] + if [ "$(version $GHE_REMOTE_VERSION)" -gt "$(version 3.7.0)" ]; then + [ "$(cat "$GHE_DATA_DIR/current/manage-argon-secret")" = "fake argon2 secret" ] + fi # verify password pepper file was backed up [ "$(cat "$GHE_DATA_DIR/current/password-pepper")" = "fake password pepper data" ] From 2c1d772781d7f6a612974be019f14831a350adf9 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Thu, 26 Jan 2023 14:59:47 -0800 Subject: [PATCH 1595/2421] Set a 2 minute timeout on starting cron --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 42fe6cd57..7195d6690 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -89,11 +89,11 @@ done start_cron () { echo "Starting cron ..." if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo timeout 120s service cron start"; then echo "* Warning: Failed to start cron on one or more nodes" fi else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo timeout 120s service cron start"; then echo "* Warning: Failed to start cron" fi fi From d41296d0d14c9e9da91245ef6f1f7e0039a6b551 Mon Sep 17 00:00:00 2001 From: Aadil Siddiqui <9424117+aasiddiq@users.noreply.github.com> Date: Sat, 28 Jan 2023 11:33:22 +0530 Subject: [PATCH 1596/2421] Backup/restore chat integration settings --- share/github-backup-utils/ghe-backup-settings | 32 +++++++++ .../ghe-restore-chat-integration | 66 +++++++++++++++++++ .../github-backup-utils/ghe-restore-settings | 3 + 3 files changed, 101 insertions(+) create mode 100755 share/github-backup-utils/ghe-restore-chat-integration diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 5516e811b..dbcd267ea 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -132,6 +132,38 @@ if ghe-ssh "$host" -- ghe-config --true app.packages.enabled; then backup-secret "Packages azure container name" "packages-azure-container-name" "secrets.packages.azure-container-name" fi +# Backup Chat Integration settings +if ghe-ssh "$host" -- ghe-config --true app.chatops.enabled; then + backup-secret "Chat Integration MSTeams app id" "chatops-msteams-app-id" "secrets.chatops.msteams.app-id" + backup-secret "Chat Integration MSTeams app password" "chatops-msteams-app-password" "secrets.chatops.msteams.app-password" + backup-secret "Chat Integration MSTeams public endpoint" "chatops-msteams-app-public-endpoint" "secrets.chatops.msteams.public-endpoint" + backup-secret "Chat Integration MSTeams bot handle" "chatops-msteams-bot-handle" "secrets.chatops.msteams.bot-handle" + backup-secret "Chat Integration MSTeams bot name" "chatops-msteams-bot-name" "secrets.chatops.msteams.bot-name" + backup-secret "Chat Integration Slack app id" "chatops-slack-app-id" "secrets.chatops.slack.app-id" + backup-secret "Chat Integration Slack client id" "chatops-slack-client-id" "secrets.chatops.slack.client-id" + backup-secret "Chat Integration Slack client secret" "chatops-slack-client-secret" "secrets.chatops.slack.client-secret" + backup-secret "Chat Integration Slack verification token" "chatops-slack-verification-token" "secrets.chatops.slack.verification-token" + backup-secret "Chat Integration Slack config token" "chatops-slack-config-token" "secrets.chatops.slack.config-token" + backup-secret "Chat Integration Slack public endpoint" "chatops-slack-public-endpoint" "secrets.chatops.slack.public-endpoint" + backup-secret "Chat Integration Slack signing secret" "chatops-slack-signing-secret" "secrets.chatops.slack.signing-secret" + backup-secret "Chat Integration Slack app level token" "chatops-slack-app-level-token" "secrets.chatops.slack.app-level-token" + backup-secret "Chat Integration Slack slack command" "chatops-slack-slash-command" "secrets.chatops.slack.slash-command" + backup-secret "Chat Integration Slack app name" "chatops-slack.app-name" "secrets.chatops.slack.app-name" + backup-secret "Chat Integration Slack socket mode" "chatops-slack.socket-mode" "secrets.chatops.slack.socket-mode" + backup-secret "Chat Integration public endpoint" "chatops-public-endpoint" "secrets.chatops.public-endpoint" + backup-secret "Chat Integration app type" "chatops-app-type" "secrets.chatops.app-type" + backup-secret "Chat Integration app id teams" "chatops-app-id-teams" "secrets.chatops.app-id-teams" + backup-secret "Chat Integration webhook secret teams" "chatops-webhook-secret-teams" "secrets.chatops.webhook-secret-teams" + backup-secret "Chat Integration client secret teams" "chatops-client-secret-teams" "secrets.chatops.client-secret-teams" + backup-secret "Chat Integration clien id teams" "chatops-client-id-teams" "secrets.chatops.client-id-teams" + backup-secret "Chat Integration storage secret" "chatops-storage-secret" "secrets.chatops.storage-secret" + backup-secret "Chat Integration session secret" "chatops-session-secret" "secrets.chatops.session-secret" + backup-secret "Chat Integration app id slack" "chatops-app-id-slack" "secrets.chatops.app-id-slack" + backup-secret "Chat Integration webhook secret slack" "chatops-webhook-secret-slack" "secrets.chatops.webhook-secret-slack" + backup-secret "Chat Integration client secret slack" "chatops-client-secret-slack" "secrets.chatops.client-secret-slack" + backup-secret "Chat Integration client id slack" "chatops-client-id-slack" "secrets.chatops.client-id-slack" +fi + if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then echo "* Transferring SAML keys ..." 1>&3 ghe-ssh $host -- sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -cf - "idp.crt saml-sp.p12" > saml-keys.tar diff --git a/share/github-backup-utils/ghe-restore-chat-integration b/share/github-backup-utils/ghe-restore-chat-integration new file mode 100755 index 000000000..0f0ba4b44 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-chat-integration @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-chat-integration +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# Path to snapshot dir we're restoring from +export GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + +port=$(ssh_port_part "$GHE_HOSTNAME") +export port +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$host" + +# Restore Chat Integration settings. +ghe_verbose "Restoring Chat Integration settings ..." + +restore-secret "Chat Integration MSTeams app id" "chatops-msteams-app-id" "secrets.chatops.msteams.app-id" +restore-secret "Chat Integration MSTeams app password" "chatops-msteams-app-password" "secrets.chatops.msteams.app-password" +restore-secret "Chat Integration MSTeams public endpoint" "chatops-msteams-app-public-endpoint" "secrets.chatops.msteams.public-endpoint" +restore-secret "Chat Integration MSTeams bot handle" "chatops-msteams-bot-handle" "secrets.chatops.msteams.bot-handle" +restore-secret "Chat Integration MSTeams bot name" "chatops-msteams-bot-name" "secrets.chatops.msteams.bot-name" +restore-secret "Chat Integration Slack app id" "chatops-slack-app-id" "secrets.chatops.slack.app-id" +restore-secret "Chat Integration Slack client id" "chatops-slack-client-id" "secrets.chatops.slack.client-id" +restore-secret "Chat Integration Slack client secret" "chatops-slack-client-secret" "secrets.chatops.slack.client-secret" +restore-secret "Chat Integration Slack verification token" "chatops-slack-verification-token" "secrets.chatops.slack.verification-token" +restore-secret "Chat Integration Slack config token" "chatops-slack-config-token" "secrets.chatops.slack.config-token" +restore-secret "Chat Integration Slack public endpoint" "chatops-slack-public-endpoint" "secrets.chatops.slack.public-endpoint" +restore-secret "Chat Integration Slack signing secret" "chatops-slack-signing-secret" "secrets.chatops.slack.signing-secret" +restore-secret "Chat Integration Slack app level token" "chatops-slack-app-level-token" "secrets.chatops.slack.app-level-token" +restore-secret "Chat Integration Slack slack command" "chatops-slack-slash-command" "secrets.chatops.slack.slash-command" +restore-secret "Chat Integration Slack app name" "chatops-slack.app-name" "secrets.chatops.slack.app-name" +restore-secret "Chat Integration Slack socket mode" "chatops-slack.socket-mode" "secrets.chatops.slack.socket-mode" +restore-secret "Chat Integration public endpoint" "chatops-public-endpoint" "secrets.chatops.public-endpoint" +restore-secret "Chat Integration app type" "chatops-app-type" "secrets.chatops.app-type" +restore-secret "Chat Integration app id teams" "chatops-app-id-teams" "secrets.chatops.app-id-teams" +restore-secret "Chat Integration webhook secret teams" "chatops-webhook-secret-teams" "secrets.chatops.webhook-secret-teams" +restore-secret "Chat Integration client secret teams" "chatops-client-secret-teams" "secrets.chatops.client-secret-teams" +restore-secret "Chat Integration clien id teams" "chatops-client-id-teams" "secrets.chatops.client-id-teams" +restore-secret "Chat Integration storage secret" "chatops-storage-secret" "secrets.chatops.storage-secret" +restore-secret "Chat Integration session secret" "chatops-session-secret" "secrets.chatops.session-secret" +restore-secret "Chat Integration app id slack" "chatops-app-id-slack" "secrets.chatops.app-id-slack" +restore-secret "Chat Integration webhook secret slack" "chatops-webhook-secret-slack" "secrets.chatops.webhook-secret-slack" +restore-secret "Chat Integration client secret slack" "chatops-client-secret-slack" "secrets.chatops.client-secret-slack" +restore-secret "Chat Integration client id slack" "chatops-client-id-slack" "secrets.chatops.client-id-slack" + +bm_end "$(basename $0)" \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 251729ba5..2bafc6ccc 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -36,6 +36,9 @@ restore-secret "external MySQL password" "external-mysql-password" "secrets.exte echo "Restoring packages settings ..." ghe-restore-packages "$GHE_HOSTNAME" 1>&3 +echo "Restoring chat integration settings ..." +ghe-restore-chat-integration "$GHE_HOSTNAME" 1>&3 + # work around issue importing settings with bad storage mode values ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | From 5ff942bd5e9ed4781a701c2471d6acccbbc63ca9 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Mon, 30 Jan 2023 11:43:25 -0700 Subject: [PATCH 1597/2421] Update ownership to lifecycle --- ownership.yaml | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/ownership.yaml b/ownership.yaml index 3d7ca2039..a28d9c918 100644 --- a/ownership.yaml +++ b/ownership.yaml @@ -7,7 +7,23 @@ ownership: kind: code repo: https://github.com/github/backup-utils-private qos: critical - component_of: ghes-infra + team: github/ghes-lifecycle + maintainer: shcorbett + exec_sponsor: scottdensmore + tier: 3 + product_manager: maya-ross + sev1: + pagerduty: https://github.pagerduty.com/escalation_policies#PBQWK20 + tta: 30 minutes + sev2: + issue: https://github.com/github/ghes/issues/new?labels=ghes-lifecycle + tta: 1 business day + sev3: + slack: ghes-dev + tta: 1 week + support_squad: + slack: support-squad-infrastructure + issue: https://github.com/github/support-squad-infrastructure/issues - name: backup-utils long_name: backup-utils description: backup-utils is backup and restore tooling for Github enterprise server @@ -15,4 +31,20 @@ ownership: kind: code repo: https://github.com/github/backup-utils qos: critical - component_of: ghes-infra + team: github/ghes-lifecycle + maintainer: shcorbett + exec_sponsor: scottdensmore + tier: 3 + product_manager: maya-ross + sev1: + pagerduty: https://github.pagerduty.com/escalation_policies#PBQWK20 + tta: 30 minutes + sev2: + issue: https://github.com/github/ghes/issues/new?labels=ghes-lifecycle + tta: 1 business day + sev3: + slack: ghes-dev + tta: 1 week + support_squad: + slack: support-squad-infrastructure + issue: https://github.com/github/support-squad-infrastructure/issues From 0dad07fd0570af5cccf1346d37e911d7edb0e8d6 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Mon, 30 Jan 2023 12:08:10 -0700 Subject: [PATCH 1598/2421] Update ownership.yaml --- ownership.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/ownership.yaml b/ownership.yaml index a28d9c918..b6c526ec7 100644 --- a/ownership.yaml +++ b/ownership.yaml @@ -27,7 +27,6 @@ ownership: - name: backup-utils long_name: backup-utils description: backup-utils is backup and restore tooling for Github enterprise server - (GHES) kind: code repo: https://github.com/github/backup-utils qos: critical From d878335016a5e6b7ddaa2972ac92c8db4a93d0a5 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Mon, 30 Jan 2023 13:02:54 -0700 Subject: [PATCH 1599/2421] Update ownership.yaml --- ownership.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ownership.yaml b/ownership.yaml index b6c526ec7..b87da5356 100644 --- a/ownership.yaml +++ b/ownership.yaml @@ -11,7 +11,7 @@ ownership: maintainer: shcorbett exec_sponsor: scottdensmore tier: 3 - product_manager: maya-ross + product_manager: davidjarzebowski sev1: pagerduty: https://github.pagerduty.com/escalation_policies#PBQWK20 tta: 30 minutes @@ -34,7 +34,7 @@ ownership: maintainer: shcorbett exec_sponsor: scottdensmore tier: 3 - product_manager: maya-ross + product_manager: davidjarzebowski sev1: pagerduty: https://github.pagerduty.com/escalation_policies#PBQWK20 tta: 30 minutes From 9661447b65b89ce2784135c2ee21cf78106349f0 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 31 Jan 2023 19:43:38 -0800 Subject: [PATCH 1600/2421] Update link to SSH key doc --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 8723afb6e..1679e727d 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -68,7 +68,7 @@ if [ $rc -ne 0 ]; then echo "$output" 1>&2 echo "Error: ssh connection with '$host' failed" 1>&2 echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2 - echo "* https://enterprise.github.com/help/articles/adding-an-ssh-key-for-shell-access" 1>&2 + echo "* https://docs.github.com/enterprise-server/admin/configuration/configuring-your-enterprise/accessing-the-administrative-shell-ssh" 1>&2 ;; 101) echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 From 391c6d41f51d3b4f23b285851e0040d26ebd7d81 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 31 Jan 2023 19:44:16 -0800 Subject: [PATCH 1601/2421] Update SSH URL in restore script also --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7195d6690..c023407fe 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -6,7 +6,7 @@ #/ Note that the GitHub Enterprise host must be reachable and your SSH key must #/ be setup as described in the following help article: #/ -#/ +#/ #/ #/ OPTIONS: #/ -c | --config Restore appliance settings and license in addition to From 4a905392d7a24d196fe7a6f128ab2de27e843e6f Mon Sep 17 00:00:00 2001 From: Daniel Johnson Date: Tue, 7 Feb 2023 11:23:54 -0800 Subject: [PATCH 1602/2421] Deleting an ownership file Doesn't make sense to exist outside our private repo. --- ownership.yaml | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 ownership.yaml diff --git a/ownership.yaml b/ownership.yaml deleted file mode 100644 index b87da5356..000000000 --- a/ownership.yaml +++ /dev/null @@ -1,49 +0,0 @@ ---- -version: 1 -ownership: -- name: backup-utils-private - long_name: backup-utils-private - description: backup-utils-private is the private fork of backup-utils - kind: code - repo: https://github.com/github/backup-utils-private - qos: critical - team: github/ghes-lifecycle - maintainer: shcorbett - exec_sponsor: scottdensmore - tier: 3 - product_manager: davidjarzebowski - sev1: - pagerduty: https://github.pagerduty.com/escalation_policies#PBQWK20 - tta: 30 minutes - sev2: - issue: https://github.com/github/ghes/issues/new?labels=ghes-lifecycle - tta: 1 business day - sev3: - slack: ghes-dev - tta: 1 week - support_squad: - slack: support-squad-infrastructure - issue: https://github.com/github/support-squad-infrastructure/issues -- name: backup-utils - long_name: backup-utils - description: backup-utils is backup and restore tooling for Github enterprise server - kind: code - repo: https://github.com/github/backup-utils - qos: critical - team: github/ghes-lifecycle - maintainer: shcorbett - exec_sponsor: scottdensmore - tier: 3 - product_manager: davidjarzebowski - sev1: - pagerduty: https://github.pagerduty.com/escalation_policies#PBQWK20 - tta: 30 minutes - sev2: - issue: https://github.com/github/ghes/issues/new?labels=ghes-lifecycle - tta: 1 business day - sev3: - slack: ghes-dev - tta: 1 week - support_squad: - slack: support-squad-infrastructure - issue: https://github.com/github/support-squad-infrastructure/issues From 367817ad194c22df04b949ceb6164373f1048d85 Mon Sep 17 00:00:00 2001 From: Daniel Johnson Date: Tue, 7 Feb 2023 12:13:04 -0800 Subject: [PATCH 1603/2421] Removing .github/workflows --- .github/workflows/docker-image.yml | 25 ------------ .github/workflows/lint.yml | 23 ----------- .github/workflows/main.yml | 39 ------------------- .../workflows/stale-support-escalation.yml | 27 ------------- .github/workflows/stale.yml | 25 ------------ 5 files changed, 139 deletions(-) delete mode 100644 .github/workflows/docker-image.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/stale-support-escalation.yml delete mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml deleted file mode 100644 index 0ca099a7f..000000000 --- a/.github/workflows/docker-image.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Docker Image CI - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - - build-docker: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Build the Debian Docker image - run: docker build . --file Dockerfile --tag backup-utils:${GITHUB_RUN_ID} - - name: Build the Alpine Docker image - run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID} - - name: Run tests in Debian Docker image - run: docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version - - name: Run tests in Alpine Docker image - run: docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version - diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 9d97805de..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Lint Code Base - -on: - push: - branches-ignore: [master] - pull_request: - branches: [master] - -jobs: - lint: - name: Lint Code Base - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - with: - # Full git history is needed to get a proper list of changed files within `super-linter` - fetch-depth: 0 - - name: Lint Code Base - uses: github/super-linter@v4 - env: - VALIDATE_ALL_CODEBASE: false - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index b4ceacdcd..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Test and build - -on: [pull_request] - - -jobs: - build: - strategy: - matrix: - # macos-latest references are kept here for historical purposes. removed macos-latest from the - #matrix as it is not a typical case for users and causes a lot of friction with other linux-based - # installs. Recommend developing on codespaces or using an ubuntu container. - os: ['ubuntu-22.04', 'ubuntu-20.04', 'ubuntu-18.04'] - fail-fast: false - runs-on: ${{ matrix.os }} - steps: - - name: Install Dependencies (Linux) - run: | - sudo apt-get update -y - sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man - wget "https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz" - tar --xz -xvf "shellcheck-latest.linux.x86_64.tar.xz" - sudo cp shellcheck-latest/shellcheck /usr/bin/shellcheck - if: matrix.os != 'macos-latest' - - name: Install Dependencies (macOS) - run: | - brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt wget - brew install moreutils gawk - if: matrix.os == 'macos-latest' - - name: Get Sources - uses: actions/checkout@v3 - - name: Test - run: | - export PATH="$PATH:/snap/bin" - make test - shell: bash - - name: Build (Linux) - run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc - if: matrix.os != 'macos-latest' diff --git a/.github/workflows/stale-support-escalation.yml b/.github/workflows/stale-support-escalation.yml deleted file mode 100644 index 276486abd..000000000 --- a/.github/workflows/stale-support-escalation.yml +++ /dev/null @@ -1,27 +0,0 @@ - -name: 'Close stale support escalation issues' -on: - push: - branches: - - master - schedule: - - cron: '30 1 * * *' # Run each day at 1:30 UTC - -permissions: - issues: write - -jobs: - stale: - if: github.repository == 'github/ghes' || github.repository == 'github/enterprise2' || github.repository == 'github/backup-utils-private' - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v7 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This support escalation issue is stale because it has been open 30 days with no activity. To make it never stale, add a label never-stale.' - close-issue-message: 'This support escalation issue is closed because it has been open 45 days with no activity. To make it never stale, add a label never-stale.' - days-before-stale: 30 - days-before-close: 45 - only-labels: 'support-escalation' - stale-issue-label: 'stale' - exempt-issue-labels: 'never-stale,P1,P2,P3' diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 3b0ae345b..000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,25 +0,0 @@ - -name: Mark stale issues and pull requests - -on: - schedule: - - cron: "0 0 * * *" - -jobs: - stale: - - runs-on: ubuntu-latest - - steps: - - uses: actions/stale@v7 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: "👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot." - stale-issue-label: "Stale" - exempt-issue-labels: "Keep" - stale-pr-message: "👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot." - stale-pr-label: "Stale" - exempt-pr-labels: "Keep, epic, initiative, GHAE" - days-before-stale: 30 # 1 month, which accounts for "now" and "next", but anything beyond is "never" - days-before-close: 5 - ascending: true From a76b9266f8ada17eda0a0d4de6e259fb76602972 Mon Sep 17 00:00:00 2001 From: Daniel Johnson Date: Tue, 7 Feb 2023 12:14:30 -0800 Subject: [PATCH 1604/2421] Revert "Removing .github/workflows" This reverts commit 367817ad194c22df04b949ceb6164373f1048d85. --- .github/workflows/docker-image.yml | 25 ++++++++++++ .github/workflows/lint.yml | 23 +++++++++++ .github/workflows/main.yml | 39 +++++++++++++++++++ .../workflows/stale-support-escalation.yml | 27 +++++++++++++ .github/workflows/stale.yml | 25 ++++++++++++ 5 files changed, 139 insertions(+) create mode 100644 .github/workflows/docker-image.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/stale-support-escalation.yml create mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 000000000..0ca099a7f --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,25 @@ +name: Docker Image CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build-docker: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Debian Docker image + run: docker build . --file Dockerfile --tag backup-utils:${GITHUB_RUN_ID} + - name: Build the Alpine Docker image + run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID} + - name: Run tests in Debian Docker image + run: docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version + - name: Run tests in Alpine Docker image + run: docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..9d97805de --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,23 @@ +name: Lint Code Base + +on: + push: + branches-ignore: [master] + pull_request: + branches: [master] + +jobs: + lint: + name: Lint Code Base + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + - name: Lint Code Base + uses: github/super-linter@v4 + env: + VALIDATE_ALL_CODEBASE: false + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..b4ceacdcd --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,39 @@ +name: Test and build + +on: [pull_request] + + +jobs: + build: + strategy: + matrix: + # macos-latest references are kept here for historical purposes. removed macos-latest from the + #matrix as it is not a typical case for users and causes a lot of friction with other linux-based + # installs. Recommend developing on codespaces or using an ubuntu container. + os: ['ubuntu-22.04', 'ubuntu-20.04', 'ubuntu-18.04'] + fail-fast: false + runs-on: ${{ matrix.os }} + steps: + - name: Install Dependencies (Linux) + run: | + sudo apt-get update -y + sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man + wget "https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz" + tar --xz -xvf "shellcheck-latest.linux.x86_64.tar.xz" + sudo cp shellcheck-latest/shellcheck /usr/bin/shellcheck + if: matrix.os != 'macos-latest' + - name: Install Dependencies (macOS) + run: | + brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt wget + brew install moreutils gawk + if: matrix.os == 'macos-latest' + - name: Get Sources + uses: actions/checkout@v3 + - name: Test + run: | + export PATH="$PATH:/snap/bin" + make test + shell: bash + - name: Build (Linux) + run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc + if: matrix.os != 'macos-latest' diff --git a/.github/workflows/stale-support-escalation.yml b/.github/workflows/stale-support-escalation.yml new file mode 100644 index 000000000..276486abd --- /dev/null +++ b/.github/workflows/stale-support-escalation.yml @@ -0,0 +1,27 @@ + +name: 'Close stale support escalation issues' +on: + push: + branches: + - master + schedule: + - cron: '30 1 * * *' # Run each day at 1:30 UTC + +permissions: + issues: write + +jobs: + stale: + if: github.repository == 'github/ghes' || github.repository == 'github/enterprise2' || github.repository == 'github/backup-utils-private' + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v7 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: 'This support escalation issue is stale because it has been open 30 days with no activity. To make it never stale, add a label never-stale.' + close-issue-message: 'This support escalation issue is closed because it has been open 45 days with no activity. To make it never stale, add a label never-stale.' + days-before-stale: 30 + days-before-close: 45 + only-labels: 'support-escalation' + stale-issue-label: 'stale' + exempt-issue-labels: 'never-stale,P1,P2,P3' diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 000000000..3b0ae345b --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,25 @@ + +name: Mark stale issues and pull requests + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + stale: + + runs-on: ubuntu-latest + + steps: + - uses: actions/stale@v7 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-issue-message: "👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot." + stale-issue-label: "Stale" + exempt-issue-labels: "Keep" + stale-pr-message: "👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot." + stale-pr-label: "Stale" + exempt-pr-labels: "Keep, epic, initiative, GHAE" + days-before-stale: 30 # 1 month, which accounts for "now" and "next", but anything beyond is "never" + days-before-close: 5 + ascending: true From 241c228366c71cee78005c4d0ec6e396bbb8d8db Mon Sep 17 00:00:00 2001 From: Daniel Johnson Date: Tue, 7 Feb 2023 12:15:14 -0800 Subject: [PATCH 1605/2421] Removing only the new workflows --- .../workflows/stale-support-escalation.yml | 27 ------------------- .github/workflows/stale.yml | 25 ----------------- 2 files changed, 52 deletions(-) delete mode 100644 .github/workflows/stale-support-escalation.yml delete mode 100644 .github/workflows/stale.yml diff --git a/.github/workflows/stale-support-escalation.yml b/.github/workflows/stale-support-escalation.yml deleted file mode 100644 index 276486abd..000000000 --- a/.github/workflows/stale-support-escalation.yml +++ /dev/null @@ -1,27 +0,0 @@ - -name: 'Close stale support escalation issues' -on: - push: - branches: - - master - schedule: - - cron: '30 1 * * *' # Run each day at 1:30 UTC - -permissions: - issues: write - -jobs: - stale: - if: github.repository == 'github/ghes' || github.repository == 'github/enterprise2' || github.repository == 'github/backup-utils-private' - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v7 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This support escalation issue is stale because it has been open 30 days with no activity. To make it never stale, add a label never-stale.' - close-issue-message: 'This support escalation issue is closed because it has been open 45 days with no activity. To make it never stale, add a label never-stale.' - days-before-stale: 30 - days-before-close: 45 - only-labels: 'support-escalation' - stale-issue-label: 'stale' - exempt-issue-labels: 'never-stale,P1,P2,P3' diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml deleted file mode 100644 index 3b0ae345b..000000000 --- a/.github/workflows/stale.yml +++ /dev/null @@ -1,25 +0,0 @@ - -name: Mark stale issues and pull requests - -on: - schedule: - - cron: "0 0 * * *" - -jobs: - stale: - - runs-on: ubuntu-latest - - steps: - - uses: actions/stale@v7 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: "👋 This issue has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this issue will be closed eventually by the stale bot." - stale-issue-label: "Stale" - exempt-issue-labels: "Keep" - stale-pr-message: "👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the `Keep` label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot." - stale-pr-label: "Stale" - exempt-pr-labels: "Keep, epic, initiative, GHAE" - days-before-stale: 30 # 1 month, which accounts for "now" and "next", but anything beyond is "never" - days-before-close: 5 - ascending: true From 16ad611595629074d585e91fa84720bed9beb389 Mon Sep 17 00:00:00 2001 From: Daniel Johnson Date: Tue, 7 Feb 2023 12:31:54 -0800 Subject: [PATCH 1606/2421] Removing from public repo since It shouldn't be needed here. --- RELEASING.md | 79 ---------------------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 RELEASING.md diff --git a/RELEASING.md b/RELEASING.md deleted file mode 100644 index 57d044e32..000000000 --- a/RELEASING.md +++ /dev/null @@ -1,79 +0,0 @@ -# Making a Backup Utilities release - -Starting with Backup Utilities v2.13.0, all major releases will follow GitHub Enterprise Server releases and the version support is inline with that of the [GitHub Enterprise Server upgrade requirements](https://help.github.com/enterprise/admin/guides/installation/about-upgrade-requirements/) and as such, support is limited to three versions of GitHub Enterprise Server: the version that corresponds with the version of Backup Utilities, and the two releases prior to it. - -For example, Backup Utilities 2.13.0 can be used to backup and restore all patch releases from 2.11.0 to the latest patch release of GitHub Enterprise 2.13. Backup utilities 2.14.0 will be released when GitHub Enterprise 2.14.0 is released and will then be used to backup all releases of GitHub Enterprise from 2.12.0 to the latest patch release of GitHub Enterprise 2.14. - -There is no need to align Backup Utilities patch releases with GitHub Enterprise Server patch releases. - -When making a `.0` release, you will need to specify the minimum supported version of GitHub Enterprise Server that release supports. - -Only repo administrator is allowed to run the release script, otherwise it will fail. - -## Pre-release Actions - -Prior to making a release, - -1. Sync any changes that have been merged to backup-utils-private into this repository. - - One possible way to accomplish this is to add the other repository as a remote and merge the changes from the default branch of that remote. - ``` - git clone git@github.com:github/backup-utils - cd backup-utils - git checkout master - git checkout -b sync-private-to-public - git remote add private - git fetch private - git merge private/master - git push origin HEAD - ``` - Then open a pull request on this repository with the changes. -2. Go through the list of open pull requests and merge any that are ready for merging. -3. Go through the list of closed pull requests since the last release and ensure those that should be included in the release notes: - - have a "bug", "enhancement" or "feature" label, - - have a title that clearly describes the changes in that pull request. Reword if necessary. -4. Perform a dry run (add `--dry-run` to one of the commands below) and verify the version strings are going to be changed and verify the release notes. - -## Automatic Process from chatops (internal to GitHub only) - -Coming :soon: - -## Automatic Process from CLI - -1. Install the Debian `devscripts` and `moreutils` packages: - `sudo apt-get install devscripts moreutils` -2. Generate a PAT through github.com with access to the `github/backup-utils` repository. This will be used for the `GH_RELEASE_TOKEN` environment variable in the next step. -3. Run... - - Feature release: - `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.0 2.11.0` - - Patch release: - `GH_AUTHOR="Bob Smith " GH_RELEASE_TOKEN=your-amazing-secure-token script/release 2.13.1` - -## Manual Process - -In the event you can't perform the automatic process, or a problem is encountered with the automatic process, these are the manual steps you need to perform for a release. - -1. Install the Debian `devscripts` and `moreutils` packages: - `sudo apt-get install devscripts moreutils` -2. Add a new version and release notes to the `debian/changelog` file: - `dch --newversion 2.13.0 --release-heuristic log` - You can use `make pending-prs` to craft the release notes. -3. Rev the `share/github-backup-utils/version` file. If this is a feature release, update `supported_minimum_version=` in `bin/ghe-host-check` too. -4. Commit your changes. -5. Tag the release: `git tag v2.13.0` -6. Build that tarball package: `make dist` -7. Build the deb package: `make deb`. All the tests should pass. -8. Draft a new release at https://github.com/github/backup-utils/releases, including the release notes and attaching the tarball and deb packages. - The dist tarball you should upload has the revision in the file name, i.e. something like `github-backup-utils-v2.13.0.tar.gz` -9. Push the head of the release to the 'stable' branch. - -## Post-release Actions - -Immediately after making a release using one of the methods above, verify the release has succeeded by checking: - -- latest release at https://github.com/github/backup-utils/releases is correct, -- release at https://github.com/github/backup-utils/releases is linked to the vX.Y.Z tag, -- release has the notes you expect to see, -- asset download links for the latest release at https://github.com/github/backup-utils/releases all download the correct version of Backup Utilities, -- the stable branch is inline with master - https://github.com/github/backup-utils/compare/stable...master. -- sync this repository to backup-utils-private From 5484cf0e42d4f3f68c4c124e1ae00d4f7290bbbe Mon Sep 17 00:00:00 2001 From: Daniel Johnson Date: Tue, 7 Feb 2023 21:48:52 +0000 Subject: [PATCH 1607/2421] Bump version: 3.8.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 4 ++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 1679e727d..ebdf12b96 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -131,7 +131,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.5.0" +supported_minimum_version="3.6.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index 965b4d01d..fb6b9940b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,7 @@ +github-backup-utils (3.8.0) focal; urgency=medium + + -- Daniel Johnson Tue, 07 Feb 2023 21:43:26 +0000 + github-backup-utils (3.7.0) UNRELEASED; urgency=medium diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 7c69a55db..19811903a 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.7.0 +3.8.0 diff --git a/test/testlib.sh b/test/testlib.sh index c9769b4ea..1a6ffa82f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -42,7 +42,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.7.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.8.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From d63243e7e873d0067e0fe9e4da9cc5859e2df4b6 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 9 Feb 2023 16:46:38 -0500 Subject: [PATCH 1608/2421] Prepend colorized input to logging data prepend ISO 8601 format timestamp and colorized loglevel to the output of ghe-backup and ghe-restore. --- bin/ghe-backup | 61 ++++++------ bin/ghe-restore | 104 ++++++++++---------- share/github-backup-utils/3 | 0 share/github-backup-utils/ghe-backup-config | 54 ++++++++++ 4 files changed, 137 insertions(+), 82 deletions(-) create mode 100644 share/github-backup-utils/3 diff --git a/bin/ghe-backup b/bin/ghe-backup index 783ea9980..c4d28fa73 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -66,21 +66,21 @@ trap 'rm -rf src dest1 dest2' EXIT mkdir -p src touch src/testfile if ! ln -s /data/does/not/exist/hooks/ src/ >/dev/null 2>&1; then - echo "Error: the filesystem containing $GHE_DATA_DIR does not support symbolic links." 1>&2 - echo "Git repositories contain symbolic links that need to be preserved during a backup." 1>&2 + logError "Error: the filesystem containing $GHE_DATA_DIR does not support symbolic links." 1>&2 + logError "Git repositories contain symbolic links that need to be preserved during a backup." 1>&2 exit 1 fi if ! output=$(rsync -a src/ dest1 2>&1 && rsync -av src/ --link-dest=../dest1 dest2 2>&1); then - echo "Error: rsync encountered an error that could indicate a problem with permissions," 1>&2 - echo "hard links, symbolic links, or another issue that may affect backups." 1>&2 + logError "Error: rsync encountered an error that could indicate a problem with permissions," 1>&2 + logError "hard links, symbolic links, or another issue that may affect backups." 1>&2 echo "$output" exit 1 fi if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile | awk '{ print $1 }')" ]; then - echo "Error: the filesystem containing $GHE_DATA_DIR does not support hard links." 1>&2 - echo "Backup Utilities use hard links to store backup data efficiently." 1>&2 + logError "Error: the filesystem containing $GHE_DATA_DIR does not support hard links." 1>&2 + logError "Backup Utilities use hard links to store backup data efficiently." 1>&2 exit 1 fi rm -rf src dest1 dest2 @@ -115,9 +115,9 @@ trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate if [ -h ../in-progress ]; then - echo "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 - echo "If there is no backup in progress anymore, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress file." 1>&2 + logError "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 + logError "If there is no backup in progress anymore, please remove" 1>&2 + logError "the $GHE_DATA_DIR/in-progress file." 1>&2 exit 1 fi @@ -130,16 +130,16 @@ if [ -f ../in-progress ]; then # will clean up the failed backup. unlink ../in-progress else - echo "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 - echo "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 - echo "the $GHE_DATA_DIR/in-progress file and try again." 1>&2 + logError "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 + logError "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 + logError "the $GHE_DATA_DIR/in-progress file and try again." 1>&2 exit 1 fi fi echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress -echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" +logInfo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" # Perform a host connection check and establish the remote appliance version. # The version is available in the GHE_REMOTE_VERSION variable and also written @@ -163,18 +163,18 @@ echo "$GHE_BACKUP_STRATEGY" > strategy bm_init > /dev/null ghe-backup-store-version || -echo "Warning: storing backup-utils version remotely failed." +logWarn "Warning: storing backup-utils version remotely failed." -echo "Backing up GitHub settings ..." +logInfo "Backing up GitHub settings ..." ghe-backup-settings || failures="$failures settings" -echo "Backing up SSH authorized keys ..." +logInfo "Backing up SSH authorized keys ..." bm_start "ghe-export-authorized-keys" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-authorized-keys' > authorized-keys.json || failures="$failures authorized-keys" bm_end "ghe-export-authorized-keys" -echo "Backing up SSH host keys ..." +logInfo "Backing up SSH host keys ..." bm_start "ghe-export-ssh-host-keys" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar || failures="$failures ssh-host-keys" @@ -183,45 +183,45 @@ bm_end "ghe-export-ssh-host-keys" ghe-backup-mysql || failures="$failures mysql" if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Backing up MSSQL databases ..." + logInfo "Backing up MSSQL databases ..." ghe-backup-mssql 1>&3 || failures="$failures mssql" - echo "Backing up Actions data ..." + logInfo "Backing up Actions data ..." ghe-backup-actions 1>&3 || failures="$failures actions" fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - echo "Backing up Minio data ..." + logInfo "Backing up Minio data ..." ghe-backup-minio 1>&3 || failures="$failures minio" fi commands=(" -echo \"Backing up Redis database ...\" +logInfo \"Backing up Redis database ...\" ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"") commands+=(" -echo \"Backing up audit log ...\" +logInfo \"Backing up audit log ...\" ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"") commands+=(" -echo \"Backing up Git repositories ...\" +logInfo \"Backing up Git repositories ...\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") commands+=(" -echo \"Backing up GitHub Pages artifacts ...\" +logInfo \"Backing up GitHub Pages artifacts ...\" ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") commands+=(" -echo \"Backing up storage data ...\" +logInfo \"Backing up storage data ...\" ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\"") commands+=(" -echo \"Backing up custom Git hooks ...\" +logInfo \"Backing up custom Git hooks ...\" ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"") if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then commands+=(" - echo \"Backing up Elasticsearch indices ...\" + logInfo \"Backing up Elasticsearch indices ...\" ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\"") fi @@ -239,6 +239,7 @@ fi # git fsck repositories after the backup if [ "$GHE_BACKUP_FSCK" = "yes" ]; then + loginfo "Running git fsck on repositories ..." ghe-backup-fsck $GHE_SNAPSHOT_DIR || failures="$failures fsck" fi @@ -254,7 +255,7 @@ if [ -z "$failures" ]; then ghe-prune-snapshots fi -echo "Completed backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP at $(date +"%H:%M:%S")" +logInfo "Completed backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP at $(date +"%H:%M:%S")" # Exit non-zero and list the steps that failed. if [ -z "$failures" ]; then @@ -262,12 +263,12 @@ if [ -z "$failures" ]; then else steps="$(echo $failures | sed 's/ /, /g')" ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP with failures: ${steps}." - echo "Error: Snapshot incomplete. Some steps failed: ${steps}. " + logError "Error: Snapshot incomplete. Some steps failed: ${steps}. " exit 1 fi # Detect if the created backup contains any leaked ssh keys -echo "Checking for leaked ssh keys ..." +logInfo "Checking for leaked ssh keys ..." ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true # Make sure we exit zero after the conditional diff --git a/bin/ghe-restore b/bin/ghe-restore index 42fe6cd57..e362e0375 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -90,11 +90,11 @@ start_cron () { echo "Starting cron ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then - echo "* Warning: Failed to start cron on one or more nodes" + logWarn "* Warning: Failed to start cron on one or more nodes" fi else if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then - echo "* Warning: Failed to start cron" + logWarn "* Warning: Failed to start cron" fi fi } @@ -105,7 +105,7 @@ cleanup () { fi if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Restarting Actions after restore ..." + logInfo "Restarting Actions after restore ..." # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists # in the --help output @@ -129,7 +129,7 @@ cleanup () { cleanup_cluster_nodes() { uuid="$1" if [ -z "$uuid" ]; then - echo "Node UUID required." + logInfo "Node UUID required." exit 2 fi @@ -171,7 +171,7 @@ GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") export GHE_RESTORE_SNAPSHOT # Detect if the backup we are restoring has a leaked ssh key -echo "Checking for leaked keys in the backup snapshot that is being restored ..." +logInfo "Checking for leaked keys in the backup snapshot that is being restored ..." ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true # Figure out whether to use the tarball or rsync restore strategy based on the @@ -199,7 +199,7 @@ export CLUSTER # Restoring a cluster backup to a standalone appliance is not supported if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \ + logError "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \ "to a standalone appliance. Aborting." >&2 exit 1 fi @@ -212,8 +212,8 @@ fi # Figure out if this appliance is in a replication pair if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - echo "Error: Restoring to an appliance with replication enabled is not supported." >&2 - echo " Please teardown replication before restoring." >&2 + logError "Error: Restoring to an appliance with replication enabled is not supported." >&2 + logError " Please teardown replication before restoring." >&2 exit 1 fi @@ -249,8 +249,8 @@ fi # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) -echo 'Start time:' $START_TIME -echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" +logInfo 'Start time:' $START_TIME +logInfo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Keep other processes on the VM or cluster in the loop about the restore status. @@ -277,7 +277,7 @@ update_restore_status "restoring" # Make sure the GitHub appliance is in maintenance mode. if $instance_configured; then if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then - echo "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 + logError "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 exit 1 fi fi @@ -289,7 +289,7 @@ RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-vers # mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Error: Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 + logError "Error: Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 exit 1 fi @@ -300,20 +300,20 @@ if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - echo "Error: $GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" 1>&2 - echo "Please disable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 - echo "To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 + logError "Error: $GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" 1>&2 + logError "Please disable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 + logError "To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 exit 1 fi if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - echo "Error: $GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting" 1>&2 - echo "Please enable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 - echo "To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 + logError "Error: $GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting" 1>&2 + logError "Please enable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 + logError "To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 exit 1 fi else - echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 - echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + logError "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 + logError "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi @@ -322,10 +322,10 @@ fi bm_init > /dev/null ghe-backup-store-version || -echo "Warning: storing backup-utils version remotely failed." +logWarn "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. -echo "Stopping cron and github-timerd ..." +logInfo "Stopping cron and github-timerd ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then ghe_verbose "* Warning: Failed to stop cron on one or more nodes" @@ -377,7 +377,7 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then - echo "Restoring UUID ..." + logInfo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true @@ -402,64 +402,64 @@ else fi if is_external_database_target_or_snapshot && $SKIP_MYSQL; then - echo "Skipping MySQL restore." + logInfo "Skipping MySQL restore." else - echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." + logInfo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Stopping Actions before restoring databases ..." + logInfo "Stopping Actions before restoring databases ..." # We mark Actions as stopped even if the `ghe-actions-stop` # fails to ensure that we cleanly start actions when performing cleanup. ACTIONS_STOPPED=true ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 - echo "Restoring MSSQL databases ..." + logInfo "Restoring MSSQL databases ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 - echo "Restoring Actions data ..." + logInfo "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 - echo "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." - echo " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." + logWarn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." + logWarn " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - echo "Restoring MinIO data ..." + logInfo "Restoring MinIO data ..." ghe-restore-minio "$GHE_HOSTNAME" 1>&3 fi commands=(" -echo \"Restoring Redis database ...\" +logInfo \"Restoring Redis database ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") commands+=(" -echo \"Restoring Git repositories ...\" +logInfo \"Restoring Git repositories ...\" ghe-restore-repositories \"$GHE_HOSTNAME\"") commands+=(" -echo \"Restoring Gists ...\" +logInfo \"Restoring Gists ...\" ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") commands+=(" -echo \"Restoring GitHub Pages artifacts ...\" +logInfo \"Restoring GitHub Pages artifacts ...\" ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") commands+=(" -echo \"Restoring SSH authorized keys ...\" +logInfo \"Restoring SSH authorized keys ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") commands+=(" -echo \"Restoring storage data ...\" +logInfo \"Restoring storage data ...\" ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") commands+=(" -echo \"Restoring custom Git hooks ...\" +logInfo \"Restoring custom Git hooks ...\" ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then commands+=(" - echo \"Restoring Elasticsearch indices ...\" + logInfo \"Restoring Elasticsearch indices ...\" ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") fi @@ -472,10 +472,10 @@ fi # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then - echo "Skipping restore of audit logs." + logInfo "Skipping restore of audit logs." else commands+=(" - echo \"Restoring Audit logs ...\" + logInfo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi @@ -497,15 +497,15 @@ echo "sudo restart -q memcached 2>/dev/null || true" | # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. if ! $RESTORE_SETTINGS; then - echo "Setting last run date for GitHub Connect jobs ..." 1>&3 - echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | + logInfo "Setting last run date for GitHub Connect jobs ..." 1>&3 + logInfo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. if $CLUSTER; then - echo "Configuring cluster ..." + logInfo "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -513,7 +513,7 @@ if $CLUSTER; then fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then - echo "Configuring appliance ..." + logInfo "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -562,25 +562,25 @@ update_restore_status "complete" ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." if ! $CLUSTER; then - echo "Restoring SSH host keys ..." + logInfo "Restoring SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 else # This will make sure that Git over SSH host keys (babeld) are # copied to all the cluster nodes so babeld uses the same keys. - echo "Restoring Git over SSH host keys ..." + logInfo "Restoring Git over SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 - echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | + logInfo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi END_TIME=$(date +%s) -echo 'End time:' $END_TIME -echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' +logInfo 'End time:' $END_TIME +logInfo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' -echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." +logInfo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." if ! $instance_configured; then - echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." + logInfo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." fi diff --git a/share/github-backup-utils/3 b/share/github-backup-utils/3 new file mode 100644 index 000000000..e69de29bb diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b9271cf6b..9296ecb91 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -507,3 +507,57 @@ restore-secret() { ghe-ssh "$GHE_HOSTNAME" -- /bin/bash fi } + +# Logging display and formatting functions + +# Terminal colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + +# Log a message to stdout +loglevel() { + local level=$1 + shift + local message=$* + local display="" + local timestamp + timestamp=$(date +"%Y-%m-%d %H:%M:%S") + + + if [ "$TERM" = "dumb" ]; then + if [ "$level" = "info" ]; then + display="INFO" + elif [ "$level" = "warn" ]; then + display="WARN" + elif [ "$level" = "error" ]; then + display="ERROR" + else + display="-" + fi + else + if [ "$level" = "info" ]; then + display="${GREEN}INFO${NC}" + elif [ "$level" = "warn" ]; then + display="${YELLOW}WARN${NC}" + elif [ "$level" = "error" ]; then + display="${RED}ERROR${NC}" + else + display="-" + fi + fi + echo -e "$timestamp | $display | $message" +} + +logInfo(){ + loglevel "info" "$1" +} + +logWarn(){ + loglevel "warn" "$1" +} + +logError(){ + loglevel "error" "$1" +} \ No newline at end of file From 45ee8758fa927c6afdf14d2868dd1b9c1497b19b Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 10 Feb 2023 06:01:14 -0500 Subject: [PATCH 1609/2421] Update bin/ghe-backup Co-authored-by: Manuel Bergler --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index c4d28fa73..a1ee6b918 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -239,7 +239,7 @@ fi # git fsck repositories after the backup if [ "$GHE_BACKUP_FSCK" = "yes" ]; then - loginfo "Running git fsck on repositories ..." + logInfo "Running git fsck on repositories ..." ghe-backup-fsck $GHE_SNAPSHOT_DIR || failures="$failures fsck" fi From f0e38f79eef08ca58e1ae33df365b40354c1f60e Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 10 Feb 2023 11:36:25 -0500 Subject: [PATCH 1610/2421] troubleshooting output --- bin/ghe-restore | 2 +- share/github-backup-utils/3 | 0 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 share/github-backup-utils/3 diff --git a/bin/ghe-restore b/bin/ghe-restore index e362e0375..dd6c88d92 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -475,7 +475,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the logInfo "Skipping restore of audit logs." else commands+=(" - logInfo \"Restoring Audit logs ...\" + echo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi diff --git a/share/github-backup-utils/3 b/share/github-backup-utils/3 deleted file mode 100644 index e69de29bb..000000000 From 4a5b4ecf760b65e58c9675c99939040a594f387c Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 10 Feb 2023 11:40:05 -0500 Subject: [PATCH 1611/2421] more troubleshooting output --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index dd6c88d92..6c5e6e541 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -475,7 +475,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the logInfo "Skipping restore of audit logs." else commands+=(" - echo \"Restoring Audit logs ...\" + logInfo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi @@ -490,7 +490,7 @@ else fi # Restart an already running memcached to reset the cache after restore -echo "Restarting memcached ..." 1>&3 +logInfo "Restarting memcached ..." 1>&3 echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh @@ -498,7 +498,7 @@ echo "sudo restart -q memcached 2>/dev/null || true" | # the configuration by setting the last run date to now. if ! $RESTORE_SETTINGS; then logInfo "Setting last run date for GitHub Connect jobs ..." 1>&3 - logInfo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | + echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi From e6aa5aacf8d8842540a2480de25928e90428091e Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 10 Feb 2023 16:58:35 +0000 Subject: [PATCH 1612/2421] Checks for backup host reqs --- bin/ghe-host-check | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 8723afb6e..aca53dbb0 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -144,4 +144,44 @@ if [ -z "$supported" ]; then exit 1 fi +#Display dir requirements for repositories and mysql +backup_dir=${GHE_DATA_DIR} +available_space=$(df $backup_dir | awk 'END{print $4}') +repo_disk_size=$(ghe-ssh "$host" sudo du -sh /data/user/repositories | awk '{print $1}') +mysql_disk_size=$(ghe-ssh "$host" sudo du -sh /data/user/mysql | awk '{print $1}') +# Convert the data size to kilobytes +case "$repo_disk_size" in + *T) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/T/000000000/') )) ;; + *G) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/G/000000/') )) ;; + *M) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/M/000/') )) ;; + *K) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/K//') )) ;; +esac +if [[ $available_space -lt $repo_disk_size ]]; then + echo "There is not enough disk space for the backup" + exit 1 +fi + +#Check rsync, openssh & jq versions +rsync_version=$(rsync --version | grep 'version' | awk '{print $3}') +if awk "BEGIN {exit !($rsync_version < 2.6.4)}" &> /dev/null; then + echo "rsync version $rsync_version in backup-host does not meet minimum requirements." + echo "Please make sure you have the minimum required version of rsync installed" + exit 2 +fi + +ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) +if awk "BEGIN {exit !($ssh_version < 5.6)}" &> /dev/null; then + echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." + echo "Please make sure the minimum required version of openSSH is installed" + exit 2 +fi + +jq_version=$(jq --version |awk -F\- '{print $2}') +if awk "BEGIN {exit !($jq_version < 1.5)}" &> /dev/null; then + echo "jq version $jq_version in backup-host does not meet minimum requirements." + echo "Please make sure you have the minimum required version of jq installed" + exit 2 +fi + + echo "Connect $hostname:$port OK (v$version)" From 10fa9ddea1c8ef3312a5d5f78c1cc36fac87d0a4 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 10 Feb 2023 22:16:39 +0000 Subject: [PATCH 1613/2421] add requirements file --- bin/ghe-host-check | 23 ++++++++++++---------- share/github-backup-utils/requirements.txt | 3 +++ 2 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 share/github-backup-utils/requirements.txt diff --git a/bin/ghe-host-check b/bin/ghe-host-check index aca53dbb0..324114048 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -144,11 +144,14 @@ if [ -z "$supported" ]; then exit 1 fi +# Bring in the requirements file +. "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/requirements.txt" + #Display dir requirements for repositories and mysql backup_dir=${GHE_DATA_DIR} available_space=$(df $backup_dir | awk 'END{print $4}') repo_disk_size=$(ghe-ssh "$host" sudo du -sh /data/user/repositories | awk '{print $1}') -mysql_disk_size=$(ghe-ssh "$host" sudo du -sh /data/user/mysql | awk '{print $1}') +#mysql_disk_size=$(ghe-ssh "$host" sudo du -sh /data/user/mysql | awk '{print $1}') # Convert the data size to kilobytes case "$repo_disk_size" in *T) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/T/000000000/') )) ;; @@ -163,24 +166,24 @@ fi #Check rsync, openssh & jq versions rsync_version=$(rsync --version | grep 'version' | awk '{print $3}') -if awk "BEGIN {exit !($rsync_version < 2.6.4)}" &> /dev/null; then +if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then echo "rsync version $rsync_version in backup-host does not meet minimum requirements." - echo "Please make sure you have the minimum required version of rsync installed" - exit 2 + echo "Please make sure you have the minimum required version of rsync: "$min_rsync" installed" + exit 1 fi ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) -if awk "BEGIN {exit !($ssh_version < 5.6)}" &> /dev/null; then +if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." - echo "Please make sure the minimum required version of openSSH is installed" - exit 2 + echo "Please make sure the minimum required version of openSSH: "$min_openssh" is installed" + exit 1 fi jq_version=$(jq --version |awk -F\- '{print $2}') -if awk "BEGIN {exit !($jq_version < 1.5)}" &> /dev/null; then +if awk "BEGIN {exit !($jq_version < $min_jq)}" &> /dev/null; then echo "jq version $jq_version in backup-host does not meet minimum requirements." - echo "Please make sure you have the minimum required version of jq installed" - exit 2 + echo "Please make sure you have the minimum required version of jq: "$min_jq" installed" + exit 1 fi diff --git a/share/github-backup-utils/requirements.txt b/share/github-backup-utils/requirements.txt new file mode 100644 index 000000000..acf767129 --- /dev/null +++ b/share/github-backup-utils/requirements.txt @@ -0,0 +1,3 @@ +min_rsync=2.6.4 +min_openssh=5.6 +min_jq=1.5 From bdcc56350febcf3ad7e7dd524a8ea51c46bd9ac1 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 10 Feb 2023 22:24:05 +0000 Subject: [PATCH 1614/2421] Remove redundant quotes --- bin/ghe-host-check | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 324114048..217920657 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -168,21 +168,21 @@ fi rsync_version=$(rsync --version | grep 'version' | awk '{print $3}') if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then echo "rsync version $rsync_version in backup-host does not meet minimum requirements." - echo "Please make sure you have the minimum required version of rsync: "$min_rsync" installed" + echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" exit 1 fi ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." - echo "Please make sure the minimum required version of openSSH: "$min_openssh" is installed" + echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" exit 1 fi jq_version=$(jq --version |awk -F\- '{print $2}') if awk "BEGIN {exit !($jq_version < $min_jq)}" &> /dev/null; then echo "jq version $jq_version in backup-host does not meet minimum requirements." - echo "Please make sure you have the minimum required version of jq: "$min_jq" installed" + echo "Please make sure you have the minimum required version of jq: $min_jq installed" exit 1 fi From f58b8b81d0020e43037ac30fa2a6cdcd09afd6f3 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 14 Feb 2023 19:47:41 +0000 Subject: [PATCH 1615/2421] Add shellcheck location --- bin/ghe-host-check | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 217920657..1f7b0cb78 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -145,6 +145,10 @@ if [ -z "$supported" ]; then fi # Bring in the requirements file +min_rsync="" +min_openssh="" +min_jq="" +# shellcheck source=share/github-backup-utils/requirements.txt . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/requirements.txt" #Display dir requirements for repositories and mysql From e2a77613b80a57377893fc799d6c31c5401cabda Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Feb 2023 12:53:42 -0500 Subject: [PATCH 1616/2421] change ghe_verbose --- bin/ghe-restore | 28 +++++++++----------- share/github-backup-utils/ghe-backup-actions | 2 +- share/github-backup-utils/ghe-backup-config | 7 +++-- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 6c5e6e541..cfa92883e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -199,8 +199,7 @@ export CLUSTER # Restoring a cluster backup to a standalone appliance is not supported if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - logError "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \ - "to a standalone appliance. Aborting." >&2 + logError "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 exit 1 fi @@ -212,8 +211,7 @@ fi # Figure out if this appliance is in a replication pair if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - logError "Error: Restoring to an appliance with replication enabled is not supported." >&2 - logError " Please teardown replication before restoring." >&2 + logError "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 exit 1 fi @@ -289,7 +287,7 @@ RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-vers # mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - logError "Error: Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 + logError "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 exit 1 fi @@ -300,20 +298,20 @@ if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - logError "Error: $GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" 1>&2 - logError "Please disable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 - logError "To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 + logError "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" \ + "\n""Please disable Actions cache service in $GHE_HOSTNAME and retry" \ + "\n""To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 exit 1 fi if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - logError "Error: $GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting" 1>&2 - logError "Please enable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 - logError "To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 + logError "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting." \ + "\n""Please enable Actions cache service in $GHE_HOSTNAME and retry" \ + "\n""To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 exit 1 fi else - logError "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 - logError "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + logError "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." \ + "\n""Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi @@ -464,7 +462,7 @@ if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then fi # Restore the audit log migration sentinel file, if it exists in the snapshot -if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then +if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" fi @@ -482,7 +480,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - $GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}" + $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" else for c in "${commands[@]}"; do eval "$c" diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index f19777930..fe41214fa 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -20,7 +20,7 @@ backup_dir="$GHE_SNAPSHOT_DIR/actions" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 + logError "Error: rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 9296ecb91..1c9b56bf3 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -354,7 +354,7 @@ ghe_remote_logger() { # Log if verbose mode is enabled (GHE_VERBOSE or `-v`). ghe_verbose() { if [ -n "$GHE_VERBOSE" ]; then - echo "$@" 1>&3 + logVerbose "$@" 1>&3 fi } @@ -560,4 +560,7 @@ logWarn(){ logError(){ loglevel "error" "$1" -} \ No newline at end of file +} +logVerbose(){ + loglevel "verbose" "$1" +} From b8396eaf02198fa0d11fc0ce6959f40927e0f9a3 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Feb 2023 15:13:02 -0500 Subject: [PATCH 1617/2421] ghe-rsync and ghe-ssh mods for logging --- share/github-backup-utils/ghe-backup-config | 21 +++++++++++++++++++++ share/github-backup-utils/ghe-rsync | 4 +++- share/github-backup-utils/ghe-ssh | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 1c9b56bf3..396b3695d 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -533,6 +533,12 @@ loglevel() { display="WARN" elif [ "$level" = "error" ]; then display="ERROR" + elif [ "$level" = "verbose" ]; then + display="VERBOSE" + elif [ "$level" = "rsync" ]; then + display="RSYNC" + elif [ "$level" = "ssh" ]; then + display="SSH" else display="-" fi @@ -543,6 +549,12 @@ loglevel() { display="${YELLOW}WARN${NC}" elif [ "$level" = "error" ]; then display="${RED}ERROR${NC}" + elif [ "$level" = "verbose" ]; then + display="${GREEN}VERBOSE${NC}" + elif [ "$level" = "rsync" ]; then + display="${GREEN}RSYNC${NC}" + elif [ "$level" = "ssh" ]; then + display="${GREEN}SSH${NC}" else display="-" fi @@ -561,6 +573,15 @@ logWarn(){ logError(){ loglevel "error" "$1" } + logVerbose(){ loglevel "verbose" "$1" } + +logRsync(){ + loglevel "rsync" "$1" +} + +logSSH(){ + loglevel "ssh" "$1" +} diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index c50835072..48caff08a 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -11,6 +11,7 @@ set -o pipefail # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +logRsync "BEGIN: rsync $@ $GHE_EXTRA_RSYNC_OPTS" 1>&3 # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") @@ -21,7 +22,7 @@ else fi ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -rsync_version_check=`rsync --version | egrep "version 3.[0-9]*.[0-9]*"` +rsync_version_check=$(rsync --version | egrep "version 3.[0-9]*.[0-9]*") if [ ! -z "$rsync_version_check" ]; then # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) @@ -41,4 +42,5 @@ if [ $res = 23 ] && [ -n "$ignore23" ]; then res=0 fi +logRsync "END: rsync $@ $GHE_EXTRA_RSYNC_OPTS | exit code $res" 1>&3 exit $res diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 54d7e4538..5fffa7542 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -81,6 +81,9 @@ fi # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x +logSSH "BEGIN: ssh $opts -p $port -o BatchMode=yes \"$host\" -- $GHE_NICE $GHE_IONICE \"$@\"" # Exec ssh command with modified host / port args and add nice to command. # shellcheck disable=SC2090 # We don't need the quote/backslashes respected exec ssh $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" + +logSSH "END: ssh $opts -p $port -o BatchMode=yes \"$host\" -- $GHE_NICE $GHE_IONICE \"$@\"" \ No newline at end of file From d71a01ef60cd624835499e84c4938751b03d5bed Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Feb 2023 15:16:00 -0500 Subject: [PATCH 1618/2421] Update ssh --- share/github-backup-utils/ghe-ssh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 5fffa7542..24a3b931d 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -81,9 +81,9 @@ fi # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x -logSSH "BEGIN: ssh $opts -p $port -o BatchMode=yes \"$host\" -- $GHE_NICE $GHE_IONICE \"$@\"" +logSSH "BEGIN: \"$@\"" 1>&3 # Exec ssh command with modified host / port args and add nice to command. # shellcheck disable=SC2090 # We don't need the quote/backslashes respected exec ssh $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" -logSSH "END: ssh $opts -p $port -o BatchMode=yes \"$host\" -- $GHE_NICE $GHE_IONICE \"$@\"" \ No newline at end of file +logSSH "END:\"$@\"" 1>&3 \ No newline at end of file From efbb06ee48a00d556b0cc0cf185ea0d412e3e835 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Feb 2023 15:32:43 -0500 Subject: [PATCH 1619/2421] ssh logging adjustments Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 24a3b931d..dfcffb5d4 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -78,12 +78,10 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then fi fi +logSSH " $host : \"$@\"" 1>&3 # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x -logSSH "BEGIN: \"$@\"" 1>&3 # Exec ssh command with modified host / port args and add nice to command. # shellcheck disable=SC2090 # We don't need the quote/backslashes respected exec ssh $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" - -logSSH "END:\"$@\"" 1>&3 \ No newline at end of file From 55ac13f9136c734c2fcd5261b15c30b5e1bcb591 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Feb 2023 15:57:14 -0500 Subject: [PATCH 1620/2421] Update logging for support --- share/github-backup-utils/ghe-backup-config | 4 ++-- .../ghe-backup-es-audit-log | 2 +- share/github-backup-utils/ghe-backup-es-rsync | 2 +- share/github-backup-utils/ghe-backup-fsck | 8 +++---- .../github-backup-utils/ghe-backup-git-hooks | 2 +- share/github-backup-utils/ghe-backup-minio | 2 +- share/github-backup-utils/ghe-backup-mssql | 22 +++++++++---------- share/github-backup-utils/ghe-backup-mysql | 9 +++----- .../ghe-backup-mysql-binary | 4 ++-- .../ghe-backup-mysql-logical | 2 +- share/github-backup-utils/ghe-backup-pages | 2 +- .../ghe-backup-repositories | 14 ++++++------ share/github-backup-utils/ghe-backup-settings | 16 +++++++------- share/github-backup-utils/ghe-backup-storage | 6 ++--- share/github-backup-utils/ghe-backup-userdata | 2 +- .../ghe-cluster-find-nodes | 2 +- 16 files changed, 48 insertions(+), 51 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 396b3695d..543d5a8a3 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -534,7 +534,7 @@ loglevel() { elif [ "$level" = "error" ]; then display="ERROR" elif [ "$level" = "verbose" ]; then - display="VERBOSE" + display="INFO" elif [ "$level" = "rsync" ]; then display="RSYNC" elif [ "$level" = "ssh" ]; then @@ -550,7 +550,7 @@ loglevel() { elif [ "$level" = "error" ]; then display="${RED}ERROR${NC}" elif [ "$level" = "verbose" ]; then - display="${GREEN}VERBOSE${NC}" + display="${GREEN}INFO${NC}" elif [ "$level" = "rsync" ]; then display="${GREEN}RSYNC${NC}" elif [ "$level" = "ssh" ]; then diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 42ef9314a..1c472c13b 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -22,7 +22,7 @@ ghe_remote_version_required "$host" mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b\""); then - echo "Error: failed to retrieve audit log indices." 1>&2 + logError "ghe-backup-es-audit-log: Failed to retrieve audit log indices." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 11fa99f70..835de076a 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -20,7 +20,7 @@ ghe_remote_version_required "$host" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 + logError "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-fsck b/share/github-backup-utils/ghe-backup-fsck index 004abe412..10d0de0b9 100755 --- a/share/github-backup-utils/ghe-backup-fsck +++ b/share/github-backup-utils/ghe-backup-fsck @@ -14,7 +14,7 @@ echo "Running git fsck on repos..." # Verify git is available. if ! git --version 1>/dev/null 2>&1; then - echo "Error: git not found." 1>&2 + logError "git not found." 1>&2 exit 1 fi @@ -26,7 +26,7 @@ t_start=$(date +%s) if git fsck -h | grep -q '\-\-dangling'; then git_cmd='git fsck --no-dangling' else - echo "Warning: old git version, --no-dangling not available" + logWarn "ghe-backup-fsck: old git version, --no-dangling not available" 1>&3 git_cmd='git fsck' fi @@ -35,7 +35,7 @@ if [ -z "$sdir" ] || [ ! -d "$sdir" ]; then fi if [ ! -d "$sdir/repositories" ]; then - echo "Error: $sdir is not a valid snapshot." >&2 + logError "ghe-backup-fsck: $sdir is not a valid snapshot." >&2 exit 1 fi @@ -84,7 +84,7 @@ for repo in $(find $sdir/repositories/ -type d -name \*.git); do done -echo "* Repos verified: $repos, Errors: $errors, Took: $(($(date +%s) - $t_start))s" +logInfo "* Repos verified: $repos, Errors: $errors, Took: $(($(date +%s) - $t_start))s" rm -f $log diff --git a/share/github-backup-utils/ghe-backup-git-hooks b/share/github-backup-utils/ghe-backup-git-hooks index 3229ee009..eda507c2b 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks +++ b/share/github-backup-utils/ghe-backup-git-hooks @@ -14,7 +14,7 @@ bm_start "$(basename $0)" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 + logError "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-minio b/share/github-backup-utils/ghe-backup-minio index 59dc7f8b3..920eaf80c 100755 --- a/share/github-backup-utils/ghe-backup-minio +++ b/share/github-backup-utils/ghe-backup-minio @@ -19,7 +19,7 @@ backup_dir="${GHE_SNAPSHOT_DIR}/minio" # Verify rsync is available. if ! command -v rsync 1> /dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 + LogError "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index c2ab49ce4..f8fa10c09 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -61,7 +61,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ] || [ "$isHA" = "true" ] ; then fi if ! export_tool_available ; then - ghe_verbose "ghe-export-mssql is not available" + logError "ghe-export-mssql is not available" 1>&2 exit fi @@ -110,8 +110,8 @@ ensure_same_dbs() { done if [[ "${#locals[@]}" -ne 0 ]]; then - ghe_verbose "Warning: Found following ${#locals[@]} backup files that can't be traced back to the specified GHES host." - ghe_verbose "Warning: Did you recently reconfigure the GHES host? Move or delete these backup files if no longer needed." + logWarn "Warning: Found following ${#locals[@]} backup files that can't be traced back to the specified GHES host." + logWarn "Warning: Did you recently reconfigure the GHES host? Move or delete these backup files if no longer needed." for local in "${locals[@]}"; do ghe_verbose "$1/$local" done @@ -231,28 +231,28 @@ diff expire $diff_expire, tran expire $tran_expire" if [ "$backup_type" == 'diff' ]; then full_backup_file=$(get_latest_backup_file "$last_mssql" "$db" "bak") if [[ "$full_backup_file" == "" ]]; then - ghe_verbose "Taking a full backup instead of a diff backup because for $db a full backup file wasn't found" + logWarn "Taking a full backup instead of a diff backup because for $db a full backup file wasn't found" backup_type="full" break fi full_backup_file_checkpoint_lsn=$(get_backup_checkpoint_lsn "$db" "$full_backup_file") if [[ "$full_backup_file_checkpoint_lsn" = "NULL" ]] || [[ "$full_backup_file_checkpoint_lsn" == "" ]]; then - ghe_verbose "Taking a full backup instead of a diff backup because for $db the checkpoint LSN for $full_backup_file couldn't be determined" + logWarn "Taking a full backup instead of a diff backup because for $db the checkpoint LSN for $full_backup_file couldn't be determined" backup_type="full" break fi next_diff_backup_base_lsn=$(get_next_diff_backup_base_lsn "$db") if [[ "$next_diff_backup_base_lsn" = "NULL" ]] || [[ "$next_diff_backup_base_lsn" == "" ]]; then - ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db the base LSN for the next diff backup couldn't be determined" + logWarn "Taking a full backup instead of a $backup_type backup because for $db the base LSN for the next diff backup couldn't be determined" backup_type="full" break fi # The base of the diff backup we're about to take must exactly match the checkpoint LSN of the full backup file we have if [[ "$next_diff_backup_base_lsn" -ne "$full_backup_file_checkpoint_lsn" ]]; then - ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db the diff would have base LSN $next_diff_backup_base_lsn yet our full backup has checkpoint LSN $full_backup_file_checkpoint_lsn" + logWarn "Taking a full backup instead of a $backup_type backup because for $db the diff would have base LSN $next_diff_backup_base_lsn yet our full backup has checkpoint LSN $full_backup_file_checkpoint_lsn" backup_type="full" break fi @@ -261,21 +261,21 @@ diff expire $diff_expire, tran expire $tran_expire" # Ensure that a transaction log backup will immediately follow the previous one latest_log_backup_file=$(get_latest_backup_file "$last_mssql" "$db" "log") if [[ "$latest_log_backup_file" == "" ]]; then - ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db a previous transaction log backup wasn't found" + logWarn "Taking a full backup instead of a $backup_type backup because for $db a previous transaction log backup wasn't found" backup_type="full" break fi latest_log_backup_last_lsn=$(get_backup_last_lsn "$db" "$latest_log_backup_file") if [[ "$latest_log_backup_last_lsn" = "NULL" ]] || [[ "$latest_log_backup_last_lsn" == "" ]]; then - ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db the LSN range for $latest_log_backup_file couldn't be determined" + logWarn "Taking a full backup instead of a $backup_type backup because for $db the LSN range for $latest_log_backup_file couldn't be determined" backup_type="full" break fi next_log_backup_starting_lsn=$(get_next_log_backup_starting_lsn "$db") if [[ "$next_log_backup_starting_lsn" = "NULL" ]] || [[ "$next_log_backup_starting_lsn" == "" ]]; then - ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db the starting LSN for the next log backup couldn't be determined" + logWarn "Taking a full backup instead of a $backup_type backup because for $db the starting LSN for the next log backup couldn't be determined" backup_type="full" break fi @@ -283,7 +283,7 @@ diff expire $diff_expire, tran expire $tran_expire" # The starting LSN of the backup we're about to take must be equal to (or before) the last LSN from the last backup, # otherwise there'll be a gap and the logfiles won't be restorable if [[ "$next_log_backup_starting_lsn" -gt "$latest_log_backup_last_lsn" ]]; then - ghe_verbose "Taking a full backup instead of a $backup_type backup because for $db a gap would exist between the last backup ending at LSN $latest_log_backup_last_lsn and next backup starting at $next_log_backup_starting_lsn" + logWarn "Taking a full backup instead of a $backup_type backup because for $db a gap would exist between the last backup ending at LSN $latest_log_backup_last_lsn and next backup starting at $next_log_backup_starting_lsn" backup_type="full" break fi diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 7e3fd57e3..3acd0919d 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -17,17 +17,14 @@ ghe_remote_version_required "$GHE_HOSTNAME" if is_external_database_target; then if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then - echo "Backing up external MySQL database using customer-provided script..." + logInfo "Backing up external MySQL database using customer-provided script..." $EXTERNAL_DATABASE_BACKUP_SCRIPT bm_end "$(basename $0)" exit 0 else if is_binary_backup_feature_on; then - echo "Warning: Binary backups are configured on the target environment." - echo "Binary backup is not supported with an external MySQL database. Backing up using logical backup strategy." - echo - echo "Please disable binary backups with 'ghe-config mysql.backup.binary false', or" - echo "provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" + logWarn "Binary backups are configured on the target environment." + logWarn "Binary backup is not supported with an external MySQL database. Backing up using logical backup strategy. Please disable binary backups with 'ghe-config mysql.backup.binary false', or provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" fi ghe-backup-mysql-logical diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary index 37218c82e..936f6dfee 100755 --- a/share/github-backup-utils/ghe-backup-mysql-binary +++ b/share/github-backup-utils/ghe-backup-mysql-binary @@ -15,10 +15,10 @@ bm_start "$(basename $0)" # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" -echo "Backing up MySQL database using binary backup strategy ..." +logVerbose "Backing up MySQL database using binary backup strategy ..." echo "set -o pipefail; ghe-export-mysql" | -ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" +logVerbose "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical index 3dc2478ec..80cac2de7 100755 --- a/share/github-backup-utils/ghe-backup-mysql-logical +++ b/share/github-backup-utils/ghe-backup-mysql-logical @@ -15,7 +15,7 @@ bm_start "$(basename $0)" # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" -echo "Backing up MySQL database using logical backup strategy ..." +logVerbose "Backing up MySQL database using logical backup strategy ..." echo "set -o pipefail; ghe-export-mysql | pigz" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index 634e7a417..9c57ab4fd 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -18,7 +18,7 @@ backup_dir="$GHE_SNAPSHOT_DIR/pages" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 + logError "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 60dd5e38e..1e0724ae8 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -46,7 +46,7 @@ backup_current="$GHE_DATA_DIR/current/repositories" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 + logError "rsync not found." 1>&2 exit 1 fi @@ -142,7 +142,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - echo "Warning: no routes found, skipping repositories backup ..." + logWarn "no routes found, skipping repositories backup ..." exit 0 fi @@ -187,7 +187,7 @@ sync_data (){ # should be transferred here. echo 1>&3 - echo "* Transferring auxiliary files ..." 1>&3 + logInfo "* Transferring auxiliary files ..." 1>&3 rsync_repository_data $1:122 $2 -z <&3 - echo "* Transferring packed-refs files ..." 1>&3 + logInfo "* Transferring packed-refs files ..." 1>&3 rsync_repository_data $1:122 $2 -z <&3 - echo "* Transferring refs and reflogs ..." 1>&3 + logInfo "* Transferring refs and reflogs ..." 1>&3 rsync_repository_data $1:122 $2 -z <&3 - echo "* Transferring objects and packs ..." 1>&3 + logInfo "* Transferring objects and packs ..." 1>&3 rsync_repository_data $1:122 $2 -H <&3 - echo "* Transferring special data directories from $h..." 1>&3 + logInfo "* Transferring special data directories from $h..." 1>&3 rsync_repository_data $h:122 -z <&3 +logInfo "* Transferring settings data ..." 1>&3 ghe-ssh "$host" -- 'ghe-export-settings' > settings.json -echo "* Transferring license data ..." 1>&3 +logInfo "* Transferring license data ..." 1>&3 ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl # Function to backup a secret setting to a file. @@ -61,7 +61,7 @@ backup-secret() { esac done - echo "* Transferring $description ..." 1>&3 + logInfo "* Transferring $description ..." 1>&3 ghe-ssh "$host" -- ghe-config "$setting" > "$file+" || ( if [ "$best_effort" = "false" ]; then echo "Warning: $description not set" >&2 @@ -133,24 +133,24 @@ if ghe-ssh "$host" -- ghe-config --true app.packages.enabled; then fi if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then - echo "* Transferring SAML keys ..." 1>&3 + logInfo "* Transferring SAML keys ..." 1>&3 ghe-ssh $host -- sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -cf - "idp.crt saml-sp.p12" > saml-keys.tar fi if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates 1>/dev/null"; then - echo "* Transferring CA certificates ..." 1>&3 + logInfo "* Transferring CA certificates ..." 1>&3 ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar fi if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - echo "* Transferring cluster configuration ..." 1>&3 + logInfo "* Transferring cluster configuration ..." 1>&3 if ! ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_CLUSTER_CONF_FILE 2>/dev/null" > cluster.conf; then - echo "Error: Enterprise Cluster is not configured yet, backup will fail" >&2 + logError "Error: Enterprise Cluster is not configured yet, backup will fail" >&2 exit 1 fi else if ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_DATA_USER_DIR/common/uuid 2>/dev/null" > uuid; then - echo "* Transferring UUID ..." 1>&3 + logInfo "* Transferring UUID ..." 1>&3 fi fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index bb8117021..bc95e5815 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -19,7 +19,7 @@ backup_dir="$GHE_SNAPSHOT_DIR/storage" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 + logError "rsync not found." 1>&2 exit 1 fi @@ -60,7 +60,7 @@ cleanup() { # Enable remote maintenance operations for hostname in $hostnames; do ghe-gc-enable $ssh_config_file_opt $hostname:$port || { - echo "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 + logWarn "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 } done @@ -111,7 +111,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - echo "Warning: no routes found, skipping storage backup ..." + logWarn "no routes found, skipping storage backup ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata index 97f71c1a9..f0660b363 100755 --- a/share/github-backup-utils/ghe-backup-userdata +++ b/share/github-backup-utils/ghe-backup-userdata @@ -13,7 +13,7 @@ bm_start "$(basename $0) - $1" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - echo "Error: rsync not found." 1>&2 + logError "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-cluster-find-nodes b/share/github-backup-utils/ghe-cluster-find-nodes index c2a3cf0e1..fe3b55689 100755 --- a/share/github-backup-utils/ghe-cluster-find-nodes +++ b/share/github-backup-utils/ghe-cluster-find-nodes @@ -16,7 +16,7 @@ set -e # Check if the REMOTE DATA USER directory is set if [ -z $GHE_REMOTE_DATA_USER_DIR ]; then - echo "Env variable GHE_REMOTE_DATA_USER_DIR is not set. Exiting" + logError "Env variable GHE_REMOTE_DATA_USER_DIR is not set. Exiting" exit 1 fi From 3bb017abb28136bdc9c33949c8eb4e0c55f552c0 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 21 Feb 2023 08:36:44 -0500 Subject: [PATCH 1621/2421] Add ghe-restore subcommand logging --- .../github-backup-utils/ghe-detect-leaked-ssh-keys | 8 ++++---- share/github-backup-utils/ghe-gc-disable | 2 +- share/github-backup-utils/ghe-prune-snapshots | 4 ++-- share/github-backup-utils/ghe-restore-actions | 4 ++-- ...he-restore-external-database-compatibility-check | 12 ++++-------- share/github-backup-utils/ghe-restore-minio | 2 +- share/github-backup-utils/ghe-restore-mysql | 13 ++++--------- share/github-backup-utils/ghe-restore-mysql-binary | 2 +- share/github-backup-utils/ghe-restore-mysql-legacy | 2 +- share/github-backup-utils/ghe-restore-mysql-logical | 2 +- share/github-backup-utils/ghe-restore-pages | 4 ++-- share/github-backup-utils/ghe-restore-repositories | 8 ++++---- .../ghe-restore-repositories-gist | 6 +++--- share/github-backup-utils/ghe-restore-settings | 10 +++++----- share/github-backup-utils/ghe-restore-snapshot-path | 2 +- share/github-backup-utils/ghe-restore-storage | 6 +++--- 16 files changed, 39 insertions(+), 48 deletions(-) diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index 79978ddf0..c57202937 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -86,9 +86,9 @@ for tar_file in $ssh_tars; do leaked_keys_found=true if [ "$current_dir" == "$(dirname "$tar_file")" ]; then current_bkup=true - echo "* Leaked key found in current backup snapshot." + logWarn "* Leaked key found in current backup snapshot." else - echo "* Leaked key found in backup snapshot." + logWarn "* Leaked key found in backup snapshot." fi echo "* Snapshot file: $tar_file" echo "* Key file: $key" @@ -130,9 +130,9 @@ if $leaked_keys_found; then fi else if $leaked_keys_skippedcheck; then - echo "* No result - check not performed since host key fingerprint was empty" + logInfo "* No result - check not performed since host key fingerprint was empty" else - echo "* No leaked keys found" + logInfo "* No leaked keys found" fi fi diff --git a/share/github-backup-utils/ghe-gc-disable b/share/github-backup-utils/ghe-gc-disable index bf37572ca..4eaff194c 100755 --- a/share/github-backup-utils/ghe-gc-disable +++ b/share/github-backup-utils/ghe-gc-disable @@ -50,7 +50,7 @@ echo " " | ghe-ssh $opts "$host" -- /bin/bash || { res=$? if [ $res = 7 ]; then - echo "Error: Git GC processes remain after $GHE_GIT_COOLDOWN_PERIOD seconds. Aborting..." 1>&2 + logError "Error: Git GC processes remain after $GHE_GIT_COOLDOWN_PERIOD seconds. Aborting..." 1>&2 fi exit $res } diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index 475f6b36e..b4c4b8a2b 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -25,7 +25,7 @@ prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) if [ $prune_num -gt 0 ]; then - echo Pruning $prune_num "failed snapshot(s) ..." + logInfo Pruning $prune_num "failed snapshot(s) ..." echo "$prune_dirs" | sed 's@/incomplete$@@' | prune_snapshot fi @@ -35,6 +35,6 @@ snapshot_count=$(ls -1d "$GHE_DATA_DIR"/[0-9]* 2>/dev/null | wc -l) if [ "$snapshot_count" -gt "$GHE_NUM_SNAPSHOTS" ]; then prune_dirs="$(ls -1d "$GHE_DATA_DIR"/[0-9]* | sort -r | awk "NR>$GHE_NUM_SNAPSHOTS")" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) - echo Pruning $prune_num "expired snapshot(s) ..." + logInfo Pruning $prune_num "expired snapshot(s) ..." echo "$prune_dirs" | prune_snapshot fi diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 66d7e0828..d469ca24f 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -30,7 +30,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") # No need to restore anything, early exit if [ ! -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then - echo "Warning: Actions backup missing. Skipping ..." + logWarn "Warning: Actions backup missing. Skipping ..." exit 0 fi @@ -96,7 +96,7 @@ ghe-ssh -p "$port" "$host" -- ghe-actions-console -s actions -c "Repair-Database if [ ! -z "$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache_Configuration*.bak')" ]; then ghe-ssh -p "$port" "$host" -- ghe-actions-console -s artifactcache -c "Repair-DatabaseLogins" else - echo "ArtifactCache is not present in mssql backup. Skipping Repair-DatabaseLogins for it." + logInfo "ArtifactCache is not present in mssql backup. Skipping Repair-DatabaseLogins for it." fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-external-database-compatibility-check b/share/github-backup-utils/ghe-restore-external-database-compatibility-check index 9a22e63a0..d538779db 100755 --- a/share/github-backup-utils/ghe-restore-external-database-compatibility-check +++ b/share/github-backup-utils/ghe-restore-external-database-compatibility-check @@ -16,15 +16,13 @@ if is_instance_configured; then # Restoring settings in this scenario would change BYODB state, which is not supported via backup-utils. if $RESTORE_SETTINGS; then - echo "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." - echo "Please reconfigure the appliance first, then run ghe-restore again." + logError "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported. Please reconfigure the appliance first, then run ghe-restore again." exit 1 fi # Restoring interal DB snapshot to BYODB appliance without passing in --skip-mysql is not supported. if ! $SKIP_MYSQL; then - echo "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported." - echo "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." + logError "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported. Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." exit 1 fi fi @@ -33,15 +31,13 @@ if is_instance_configured; then # Restoring settings in this scenario would change BYODB state, which is not supported via backup-utils. if $RESTORE_SETTINGS; then - echo "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." - echo "Please reconfigure the appliance first, then run ghe-restore again." + logError "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported. Please reconfigure the appliance first, then run ghe-restore again." exit 1 fi # Restoring BYODB snapshot to internal DB appliance without passing in --skip-mysql is not supported. if ! $SKIP_MYSQL; then - echo "Restoring a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported." - echo "Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." + echo "Restoring a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported. Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." exit 1 fi fi diff --git a/share/github-backup-utils/ghe-restore-minio b/share/github-backup-utils/ghe-restore-minio index a3daa9843..5059b644d 100755 --- a/share/github-backup-utils/ghe-restore-minio +++ b/share/github-backup-utils/ghe-restore-minio @@ -30,7 +30,7 @@ host="$(ssh_host_part "${GHE_HOSTNAME}")" # No need to restore anything, early exit if [ ! -d "${GHE_RESTORE_SNAPSHOT_PATH}/minio" ]; then - echo "Warning: minio backup missing. Skipping ..." + logWarn "Warning: minio backup missing. Skipping ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 6885e98ab..ca17ec3b9 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -44,23 +44,18 @@ if is_external_database_snapshot; then exit 0 else if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then - echo "Error: Restore of a binary backup to appliance with an external database configured is not supported." - echo "Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" + logError "Error: Restore of a binary backup to appliance with an external database configured is not supported. \nPlease provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" exit 1 fi if ! is_default_external_database_snapshot; then - echo "Error: Backup was not taken with a GitHub provided backup strategy." - echo "You must provide a custom restore script for this backup using EXTERNAL_DATABASE_BACKUP_SCRIPT" + logError "Error: Backup was not taken with a GitHub provided backup strategy. \nYou must provide a custom restore script for this backup using EXTERNAL_DATABASE_BACKUP_SCRIPT" exit 1 fi if is_binary_backup_feature_on; then - echo "Warning: Binary backups are configured on the target environment." - echo "Binary backup is not supported with an external MySQL database." - echo - echo "Please disable binary backups with 'ghe-config mysql.backup.binary false'" + logWarn "Warning: Binary backups are configured on the target environment. \nBinary backup is not supported with an external MySQL database. \n\nPlease disable binary backups with 'ghe-config mysql.backup.binary false'" fi fi fi @@ -75,7 +70,7 @@ if is_binary_backup_feature_on; then else # We do not allow to restore binary backup without "mysql.backup.binary" set if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then - echo "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 + logError "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 else if is_default_external_database_snapshot; then diff --git a/share/github-backup-utils/ghe-restore-mysql-binary b/share/github-backup-utils/ghe-restore-mysql-binary index fb0da41b0..31b2e434b 100755 --- a/share/github-backup-utils/ghe-restore-mysql-binary +++ b/share/github-backup-utils/ghe-restore-mysql-binary @@ -66,7 +66,7 @@ ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_ # Transfer MySQL data from the snapshot to the GitHub instance. cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" -echo "Restore MySQL database ..." +logInfo "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 diff --git a/share/github-backup-utils/ghe-restore-mysql-legacy b/share/github-backup-utils/ghe-restore-mysql-legacy index e3fa615f1..25d5e37e2 100755 --- a/share/github-backup-utils/ghe-restore-mysql-legacy +++ b/share/github-backup-utils/ghe-restore-mysql-legacy @@ -48,7 +48,7 @@ ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_ # Transfer MySQL data from the snapshot to the GitHub instance. cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" -echo "Restore MySQL database ..." +logInfo "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 diff --git a/share/github-backup-utils/ghe-restore-mysql-logical b/share/github-backup-utils/ghe-restore-mysql-logical index 3f7e64107..e6758a90a 100755 --- a/share/github-backup-utils/ghe-restore-mysql-logical +++ b/share/github-backup-utils/ghe-restore-mysql-logical @@ -45,7 +45,7 @@ ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_ # Transfer MySQL data from the snapshot to the GitHub instance. cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" -echo "Restore MySQL database ..." +logInfo "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 800eb14d3..748dc66a5 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -27,7 +27,7 @@ pages_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 # No need to restore anything, early exit if [ -z "$pages_paths" ]; then - echo "Warning: Pages backup missing. Skipping ..." + logWarn "Warning: Pages backup missing. Skipping ..." exit 0 fi @@ -123,7 +123,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - echo "Warning: no routes found, skipping pages restore ..." + logWarn "Warning: no routes found, skipping pages restore ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 3d522be0b..4ac4d55a1 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -28,7 +28,7 @@ GHE_HOSTNAME="$1" network_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mindepth 6 -maxdepth 7 -name \*.git -exec dirname {} \; | uniq | grep nw | cut -d / -f2-) if [ -z "$network_paths" ]; then - echo "Warning: Repositories backup missing. Skipping ..." + logWarn "Warning: Repositories backup missing. Skipping ..." exit 0 fi @@ -140,7 +140,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - echo "Warning: no routes found, skipping repositories restore ..." + logWarn "Warning: no routes found, skipping repositories restore ..." exit 0 fi @@ -157,7 +157,7 @@ for file_list in $tempdir/git-server-*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 + logInfo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 fi ghe-rsync -avrR --delete \ @@ -216,7 +216,7 @@ bm_end "$(basename $0) - Updating repository info data" restore_warnings="$(ghe-ssh "$GHE_HOSTNAME" -- cat "$remote_warnings" 2>/dev/null || true)" if [ -n "$restore_warnings" ]; then - echo "Warning: One or more repository networks failed to restore successfully. Please contact GitHub Enterprise Support for assistance." + logWarn "Warning: One or more repository networks failed to restore successfully. Please contact GitHub Enterprise Support for assistance." echo "$restore_warnings" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 5080b964f..360910151 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -27,7 +27,7 @@ gist_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mind # No need to restore anything, early exit if [ -z "$gist_paths" ]; then - echo "Warning: Gist backup missing. Skipping ..." + logWarn "Warning: Gist backup missing. Skipping ..." exit 0 fi @@ -126,7 +126,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - echo "Warning: no routes found, skipping gists restore ..." + logWarn "Warning: no routes found, skipping gists restore ..." exit 0 fi @@ -162,7 +162,7 @@ fi restore_warnings="$(ghe-ssh "$GHE_HOSTNAME" -- cat "$remote_warnings" 2>/dev/null || true)" if [ -n "$restore_warnings" ]; then - echo "Warning: One or more Gists failed to restore successfully. Please contact GitHub Enterprise Support for assistance." + logWarn "Warning: One or more Gists failed to restore successfully. Please contact GitHub Enterprise Support for assistance." echo "$restore_warnings" fi diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 251729ba5..9d8042f01 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -25,15 +25,15 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Path to snapshot dir we're restoring from GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -echo "Restoring license ..." +logInfo "Restoring license ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 -echo "Restoring settings and applying configuration ..." +logInfo "Restoring settings and applying configuration ..." # Restore external MySQL password if running external MySQL DB. restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" -echo "Restoring packages settings ..." +logInfo "Restoring packages settings ..." ghe-restore-packages "$GHE_HOSTNAME" 1>&3 # work around issue importing settings with bad storage mode values @@ -55,14 +55,14 @@ restore-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac- # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then - echo "Restoring SAML keys ..." + logInfo "Restoring SAML keys ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" | ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -xf -" fi # Restore CA certificates if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" ]; then - echo "Restoring CA certificates ..." + logInfo "Restoring CA certificates ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" | ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates" fi diff --git a/share/github-backup-utils/ghe-restore-snapshot-path b/share/github-backup-utils/ghe-restore-snapshot-path index 00bbbfcd2..6b34c3940 100755 --- a/share/github-backup-utils/ghe-restore-snapshot-path +++ b/share/github-backup-utils/ghe-restore-snapshot-path @@ -25,7 +25,7 @@ fi # Bail out if we don't have a good snapshot. if [ -z "$GHE_RESTORE_SNAPSHOT" ] || [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" ]; then : "${GHE_RESTORE_SNAPSHOT:=current}" - echo "Error: Snapshot '$GHE_RESTORE_SNAPSHOT' doesn't exist." 1>&2 + logError "Error: Snapshot '$GHE_RESTORE_SNAPSHOT' doesn't exist." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 408d0e237..0b8f28061 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -31,7 +31,7 @@ storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindept # No need to restore anything, early exit if [ -z "$storage_paths" ]; then - echo "Warning: Storage backup missing. Skipping ..." + logWarn "Warning: Storage backup missing. Skipping ..." exit 0 fi @@ -118,7 +118,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - echo "Warning: no routes found, skipping storage restore ..." + logWarn "Warning: no routes found, skipping storage restore ..." exit 0 fi @@ -136,7 +136,7 @@ for file_list in $tempdir/*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - echo \"* Transferring data to $server ...\" 1>&3 + logInfo \"* Transferring data to $server ...\" 1>&3 fi ghe-rsync -arvHR --delete \ From 93cbef87d58c7145c2451b048cb65910697a2101 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 21 Feb 2023 10:03:37 -0500 Subject: [PATCH 1622/2421] change function names Multi-line description of commit, feel free to be detailed. --- bin/ghe-backup | 61 ++++++------ bin/ghe-restore | 92 +++++++++---------- share/github-backup-utils/ghe-backup-actions | 2 +- share/github-backup-utils/ghe-backup-config | 30 +++--- .../ghe-backup-es-audit-log | 2 +- share/github-backup-utils/ghe-backup-es-rsync | 2 +- share/github-backup-utils/ghe-backup-fsck | 8 +- .../github-backup-utils/ghe-backup-git-hooks | 2 +- share/github-backup-utils/ghe-backup-minio | 2 +- share/github-backup-utils/ghe-backup-mssql | 22 ++--- share/github-backup-utils/ghe-backup-mysql | 6 +- .../ghe-backup-mysql-binary | 4 +- .../ghe-backup-mysql-logical | 2 +- share/github-backup-utils/ghe-backup-pages | 2 +- .../ghe-backup-repositories | 14 +-- share/github-backup-utils/ghe-backup-settings | 16 ++-- share/github-backup-utils/ghe-backup-storage | 6 +- share/github-backup-utils/ghe-backup-userdata | 2 +- .../ghe-cluster-find-nodes | 2 +- .../ghe-detect-leaked-ssh-keys | 8 +- share/github-backup-utils/ghe-gc-disable | 2 +- share/github-backup-utils/ghe-prune-snapshots | 4 +- share/github-backup-utils/ghe-restore-actions | 4 +- ...tore-external-database-compatibility-check | 6 +- share/github-backup-utils/ghe-restore-minio | 2 +- share/github-backup-utils/ghe-restore-mysql | 8 +- .../ghe-restore-mysql-binary | 2 +- .../ghe-restore-mysql-legacy | 2 +- .../ghe-restore-mysql-logical | 2 +- share/github-backup-utils/ghe-restore-pages | 4 +- .../ghe-restore-repositories | 8 +- .../ghe-restore-repositories-gist | 6 +- .../github-backup-utils/ghe-restore-settings | 10 +- .../ghe-restore-snapshot-path | 2 +- share/github-backup-utils/ghe-restore-storage | 6 +- share/github-backup-utils/ghe-rsync | 4 +- share/github-backup-utils/ghe-ssh | 2 +- 37 files changed, 179 insertions(+), 180 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index a1ee6b918..9efa54b5c 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -66,21 +66,20 @@ trap 'rm -rf src dest1 dest2' EXIT mkdir -p src touch src/testfile if ! ln -s /data/does/not/exist/hooks/ src/ >/dev/null 2>&1; then - logError "Error: the filesystem containing $GHE_DATA_DIR does not support symbolic links." 1>&2 - logError "Git repositories contain symbolic links that need to be preserved during a backup." 1>&2 + log_error "Error: the filesystem containing $GHE_DATA_DIR does not support symbolic links. \nGit repositories contain symbolic links that need to be preserved during a backup." 1>&2 exit 1 fi if ! output=$(rsync -a src/ dest1 2>&1 && rsync -av src/ --link-dest=../dest1 dest2 2>&1); then - logError "Error: rsync encountered an error that could indicate a problem with permissions," 1>&2 - logError "hard links, symbolic links, or another issue that may affect backups." 1>&2 + log_error "Error: rsync encountered an error that could indicate a problem with permissions," 1>&2 + log_error "hard links, symbolic links, or another issue that may affect backups." 1>&2 echo "$output" exit 1 fi if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile | awk '{ print $1 }')" ]; then - logError "Error: the filesystem containing $GHE_DATA_DIR does not support hard links." 1>&2 - logError "Backup Utilities use hard links to store backup data efficiently." 1>&2 + log_error "Error: the filesystem containing $GHE_DATA_DIR does not support hard links." 1>&2 + log_error "Backup Utilities use hard links to store backup data efficiently." 1>&2 exit 1 fi rm -rf src dest1 dest2 @@ -115,9 +114,9 @@ trap 'cleanup' EXIT trap 'exit $?' INT # ^C always terminate if [ -h ../in-progress ]; then - logError "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 - logError "If there is no backup in progress anymore, please remove" 1>&2 - logError "the $GHE_DATA_DIR/in-progress file." 1>&2 + log_error "Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 + log_error "If there is no backup in progress anymore, please remove" 1>&2 + log_error "the $GHE_DATA_DIR/in-progress file." 1>&2 exit 1 fi @@ -130,16 +129,16 @@ if [ -f ../in-progress ]; then # will clean up the failed backup. unlink ../in-progress else - logError "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 - logError "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 - logError "the $GHE_DATA_DIR/in-progress file and try again." 1>&2 + log_error "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 + log_error "If PID $pid is not a process related to the backup utilities, please remove" 1>&2 + log_error "the $GHE_DATA_DIR/in-progress file and try again." 1>&2 exit 1 fi fi echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress -logInfo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" +log_info "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" # Perform a host connection check and establish the remote appliance version. # The version is available in the GHE_REMOTE_VERSION variable and also written @@ -163,18 +162,18 @@ echo "$GHE_BACKUP_STRATEGY" > strategy bm_init > /dev/null ghe-backup-store-version || -logWarn "Warning: storing backup-utils version remotely failed." +log_warn "Warning: storing backup-utils version remotely failed." -logInfo "Backing up GitHub settings ..." +log_info "Backing up GitHub settings ..." ghe-backup-settings || failures="$failures settings" -logInfo "Backing up SSH authorized keys ..." +log_info "Backing up SSH authorized keys ..." bm_start "ghe-export-authorized-keys" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-authorized-keys' > authorized-keys.json || failures="$failures authorized-keys" bm_end "ghe-export-authorized-keys" -logInfo "Backing up SSH host keys ..." +log_info "Backing up SSH host keys ..." bm_start "ghe-export-ssh-host-keys" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar || failures="$failures ssh-host-keys" @@ -183,45 +182,45 @@ bm_end "ghe-export-ssh-host-keys" ghe-backup-mysql || failures="$failures mysql" if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - logInfo "Backing up MSSQL databases ..." + log_info "Backing up MSSQL databases ..." ghe-backup-mssql 1>&3 || failures="$failures mssql" - logInfo "Backing up Actions data ..." + log_info "Backing up Actions data ..." ghe-backup-actions 1>&3 || failures="$failures actions" fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - logInfo "Backing up Minio data ..." + log_info "Backing up Minio data ..." ghe-backup-minio 1>&3 || failures="$failures minio" fi commands=(" -logInfo \"Backing up Redis database ...\" +log_info \"Backing up Redis database ...\" ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"") commands+=(" -logInfo \"Backing up audit log ...\" +log_info \"Backing up audit log ...\" ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"") commands+=(" -logInfo \"Backing up Git repositories ...\" +log_info \"Backing up Git repositories ...\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") commands+=(" -logInfo \"Backing up GitHub Pages artifacts ...\" +log_info \"Backing up GitHub Pages artifacts ...\" ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") commands+=(" -logInfo \"Backing up storage data ...\" +log_info \"Backing up storage data ...\" ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\"") commands+=(" -logInfo \"Backing up custom Git hooks ...\" +log_info \"Backing up custom Git hooks ...\" ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"") if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then commands+=(" - logInfo \"Backing up Elasticsearch indices ...\" + log_info \"Backing up Elasticsearch indices ...\" ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\"") fi @@ -239,7 +238,7 @@ fi # git fsck repositories after the backup if [ "$GHE_BACKUP_FSCK" = "yes" ]; then - logInfo "Running git fsck on repositories ..." + log_info "Running git fsck on repositories ..." ghe-backup-fsck $GHE_SNAPSHOT_DIR || failures="$failures fsck" fi @@ -255,7 +254,7 @@ if [ -z "$failures" ]; then ghe-prune-snapshots fi -logInfo "Completed backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP at $(date +"%H:%M:%S")" +log_info "Completed backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP at $(date +"%H:%M:%S")" # Exit non-zero and list the steps that failed. if [ -z "$failures" ]; then @@ -263,12 +262,12 @@ if [ -z "$failures" ]; then else steps="$(echo $failures | sed 's/ /, /g')" ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP with failures: ${steps}." - logError "Error: Snapshot incomplete. Some steps failed: ${steps}. " + log_error "Error: Snapshot incomplete. Some steps failed: ${steps}. " exit 1 fi # Detect if the created backup contains any leaked ssh keys -logInfo "Checking for leaked ssh keys ..." +log_info "Checking for leaked ssh keys ..." ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true # Make sure we exit zero after the conditional diff --git a/bin/ghe-restore b/bin/ghe-restore index cfa92883e..b8e124140 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -90,11 +90,11 @@ start_cron () { echo "Starting cron ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then - logWarn "* Warning: Failed to start cron on one or more nodes" + log_warn "* Warning: Failed to start cron on one or more nodes" fi else if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then - logWarn "* Warning: Failed to start cron" + log_warn "* Warning: Failed to start cron" fi fi } @@ -105,7 +105,7 @@ cleanup () { fi if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - logInfo "Restarting Actions after restore ..." + log_info "Restarting Actions after restore ..." # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists # in the --help output @@ -129,7 +129,7 @@ cleanup () { cleanup_cluster_nodes() { uuid="$1" if [ -z "$uuid" ]; then - logInfo "Node UUID required." + log_info "Node UUID required." exit 2 fi @@ -171,7 +171,7 @@ GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") export GHE_RESTORE_SNAPSHOT # Detect if the backup we are restoring has a leaked ssh key -logInfo "Checking for leaked keys in the backup snapshot that is being restored ..." +log_info "Checking for leaked keys in the backup snapshot that is being restored ..." ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true # Figure out whether to use the tarball or rsync restore strategy based on the @@ -199,7 +199,7 @@ export CLUSTER # Restoring a cluster backup to a standalone appliance is not supported if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - logError "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 + log_error "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 exit 1 fi @@ -211,7 +211,7 @@ fi # Figure out if this appliance is in a replication pair if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - logError "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 + log_error "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 exit 1 fi @@ -247,8 +247,8 @@ fi # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) -logInfo 'Start time:' $START_TIME -logInfo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" +log_info 'Start time:' $START_TIME +log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Keep other processes on the VM or cluster in the loop about the restore status. @@ -275,7 +275,7 @@ update_restore_status "restoring" # Make sure the GitHub appliance is in maintenance mode. if $instance_configured; then if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then - logError "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 + log_error "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 exit 1 fi fi @@ -287,7 +287,7 @@ RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-vers # mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - logError "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 + log_error "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 exit 1 fi @@ -298,19 +298,19 @@ if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - logError "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" \ + log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" \ "\n""Please disable Actions cache service in $GHE_HOSTNAME and retry" \ "\n""To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 exit 1 fi if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - logError "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting." \ + log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting." \ "\n""Please enable Actions cache service in $GHE_HOSTNAME and retry" \ "\n""To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 exit 1 fi else - logError "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." \ + log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." \ "\n""Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi @@ -320,10 +320,10 @@ fi bm_init > /dev/null ghe-backup-store-version || -logWarn "Warning: storing backup-utils version remotely failed." +log_warn "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. -logInfo "Stopping cron and github-timerd ..." +log_info "Stopping cron and github-timerd ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then ghe_verbose "* Warning: Failed to stop cron on one or more nodes" @@ -375,7 +375,7 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then - logInfo "Restoring UUID ..." + log_info "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true @@ -400,64 +400,64 @@ else fi if is_external_database_target_or_snapshot && $SKIP_MYSQL; then - logInfo "Skipping MySQL restore." + log_info "Skipping MySQL restore." else - logInfo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." + log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - logInfo "Stopping Actions before restoring databases ..." + log_info "Stopping Actions before restoring databases ..." # We mark Actions as stopped even if the `ghe-actions-stop` # fails to ensure that we cleanly start actions when performing cleanup. ACTIONS_STOPPED=true ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 - logInfo "Restoring MSSQL databases ..." + log_info "Restoring MSSQL databases ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 - logInfo "Restoring Actions data ..." + log_info "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 - logWarn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." - logWarn " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." + log_warn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." + log_warn " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - logInfo "Restoring MinIO data ..." + log_info "Restoring MinIO data ..." ghe-restore-minio "$GHE_HOSTNAME" 1>&3 fi commands=(" -logInfo \"Restoring Redis database ...\" +log_info \"Restoring Redis database ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") commands+=(" -logInfo \"Restoring Git repositories ...\" +log_info \"Restoring Git repositories ...\" ghe-restore-repositories \"$GHE_HOSTNAME\"") commands+=(" -logInfo \"Restoring Gists ...\" +log_info \"Restoring Gists ...\" ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") commands+=(" -logInfo \"Restoring GitHub Pages artifacts ...\" +log_info \"Restoring GitHub Pages artifacts ...\" ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") commands+=(" -logInfo \"Restoring SSH authorized keys ...\" +log_info \"Restoring SSH authorized keys ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") commands+=(" -logInfo \"Restoring storage data ...\" +log_info \"Restoring storage data ...\" ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") commands+=(" -logInfo \"Restoring custom Git hooks ...\" +log_info \"Restoring custom Git hooks ...\" ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then commands+=(" - logInfo \"Restoring Elasticsearch indices ...\" + log_info \"Restoring Elasticsearch indices ...\" ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") fi @@ -470,10 +470,10 @@ fi # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then - logInfo "Skipping restore of audit logs." + log_info "Skipping restore of audit logs." else commands+=(" - logInfo \"Restoring Audit logs ...\" + log_info \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi @@ -488,14 +488,14 @@ else fi # Restart an already running memcached to reset the cache after restore -logInfo "Restarting memcached ..." 1>&3 +log_info "Restarting memcached ..." 1>&3 echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. if ! $RESTORE_SETTINGS; then - logInfo "Setting last run date for GitHub Connect jobs ..." 1>&3 + log_info "Setting last run date for GitHub Connect jobs ..." 1>&3 echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi @@ -503,7 +503,7 @@ fi # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. if $CLUSTER; then - logInfo "Configuring cluster ..." + log_info "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -511,7 +511,7 @@ if $CLUSTER; then fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then - logInfo "Configuring appliance ..." + log_info "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -560,25 +560,25 @@ update_restore_status "complete" ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." if ! $CLUSTER; then - logInfo "Restoring SSH host keys ..." + log_info "Restoring SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 else # This will make sure that Git over SSH host keys (babeld) are # copied to all the cluster nodes so babeld uses the same keys. - logInfo "Restoring Git over SSH host keys ..." + log_info "Restoring Git over SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 - logInfo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | + log_info "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi END_TIME=$(date +%s) -logInfo 'End time:' $END_TIME -logInfo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' +log_info 'End time:' $END_TIME +log_info 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' -logInfo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." +log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." if ! $instance_configured; then - logInfo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." + log_info "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." fi diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index fe41214fa..8f676bcc5 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -20,7 +20,7 @@ backup_dir="$GHE_SNAPSHOT_DIR/actions" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - logError "Error: rsync not found." 1>&2 + log_error "Error: rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 543d5a8a3..50d868373 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -354,7 +354,7 @@ ghe_remote_logger() { # Log if verbose mode is enabled (GHE_VERBOSE or `-v`). ghe_verbose() { if [ -n "$GHE_VERBOSE" ]; then - logVerbose "$@" 1>&3 + log_verbose "$@" 1>&3 fi } @@ -517,13 +517,13 @@ YELLOW='\033[0;33m' NC='\033[0m' # No Color # Log a message to stdout -loglevel() { +log_level() { local level=$1 shift local message=$* local display="" local timestamp - timestamp=$(date +"%Y-%m-%d %H:%M:%S") + timestamp=$(date -u "+%FT%TZ") if [ "$TERM" = "dumb" ]; then @@ -562,26 +562,26 @@ loglevel() { echo -e "$timestamp | $display | $message" } -logInfo(){ - loglevel "info" "$1" +log_info(){ + log_level "info" "$1" } -logWarn(){ - loglevel "warn" "$1" +log_warn(){ + log_level "warn" "$1" } -logError(){ - loglevel "error" "$1" +log_error(){ + log_level "error" "$1" } -logVerbose(){ - loglevel "verbose" "$1" +log_verbose(){ + log_level "verbose" "$1" } -logRsync(){ - loglevel "rsync" "$1" +log_rsync(){ + log_level "rsync" "$1" } -logSSH(){ - loglevel "ssh" "$1" +log_ssh(){ + log_level "ssh" "$1" } diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 1c472c13b..84da8953a 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -22,7 +22,7 @@ ghe_remote_version_required "$host" mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b\""); then - logError "ghe-backup-es-audit-log: Failed to retrieve audit log indices." 1>&2 + log_error "ghe-backup-es-audit-log: Failed to retrieve audit log indices." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 835de076a..244273271 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -20,7 +20,7 @@ ghe_remote_version_required "$host" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - logError "rsync not found." 1>&2 + log_error "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-fsck b/share/github-backup-utils/ghe-backup-fsck index 10d0de0b9..d255e036f 100755 --- a/share/github-backup-utils/ghe-backup-fsck +++ b/share/github-backup-utils/ghe-backup-fsck @@ -14,7 +14,7 @@ echo "Running git fsck on repos..." # Verify git is available. if ! git --version 1>/dev/null 2>&1; then - logError "git not found." 1>&2 + log_error "git not found." 1>&2 exit 1 fi @@ -26,7 +26,7 @@ t_start=$(date +%s) if git fsck -h | grep -q '\-\-dangling'; then git_cmd='git fsck --no-dangling' else - logWarn "ghe-backup-fsck: old git version, --no-dangling not available" 1>&3 + log_warn "ghe-backup-fsck: old git version, --no-dangling not available" 1>&3 git_cmd='git fsck' fi @@ -35,7 +35,7 @@ if [ -z "$sdir" ] || [ ! -d "$sdir" ]; then fi if [ ! -d "$sdir/repositories" ]; then - logError "ghe-backup-fsck: $sdir is not a valid snapshot." >&2 + log_error "ghe-backup-fsck: $sdir is not a valid snapshot." >&2 exit 1 fi @@ -84,7 +84,7 @@ for repo in $(find $sdir/repositories/ -type d -name \*.git); do done -logInfo "* Repos verified: $repos, Errors: $errors, Took: $(($(date +%s) - $t_start))s" +log_info "* Repos verified: $repos, Errors: $errors, Took: $(($(date +%s) - $t_start))s" rm -f $log diff --git a/share/github-backup-utils/ghe-backup-git-hooks b/share/github-backup-utils/ghe-backup-git-hooks index eda507c2b..5ef02d474 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks +++ b/share/github-backup-utils/ghe-backup-git-hooks @@ -14,7 +14,7 @@ bm_start "$(basename $0)" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - logError "rsync not found." 1>&2 + log_error "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-minio b/share/github-backup-utils/ghe-backup-minio index 920eaf80c..481ee949c 100755 --- a/share/github-backup-utils/ghe-backup-minio +++ b/share/github-backup-utils/ghe-backup-minio @@ -19,7 +19,7 @@ backup_dir="${GHE_SNAPSHOT_DIR}/minio" # Verify rsync is available. if ! command -v rsync 1> /dev/null 2>&1; then - LogError "rsync not found." 1>&2 + log_error "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index f8fa10c09..ead33f6bc 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -61,7 +61,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ] || [ "$isHA" = "true" ] ; then fi if ! export_tool_available ; then - logError "ghe-export-mssql is not available" 1>&2 + log_error "ghe-export-mssql is not available" 1>&2 exit fi @@ -110,8 +110,8 @@ ensure_same_dbs() { done if [[ "${#locals[@]}" -ne 0 ]]; then - logWarn "Warning: Found following ${#locals[@]} backup files that can't be traced back to the specified GHES host." - logWarn "Warning: Did you recently reconfigure the GHES host? Move or delete these backup files if no longer needed." + log_warn "Warning: Found following ${#locals[@]} backup files that can't be traced back to the specified GHES host." + log_warn "Warning: Did you recently reconfigure the GHES host? Move or delete these backup files if no longer needed." for local in "${locals[@]}"; do ghe_verbose "$1/$local" done @@ -231,28 +231,28 @@ diff expire $diff_expire, tran expire $tran_expire" if [ "$backup_type" == 'diff' ]; then full_backup_file=$(get_latest_backup_file "$last_mssql" "$db" "bak") if [[ "$full_backup_file" == "" ]]; then - logWarn "Taking a full backup instead of a diff backup because for $db a full backup file wasn't found" + log_warn "Taking a full backup instead of a diff backup because for $db a full backup file wasn't found" backup_type="full" break fi full_backup_file_checkpoint_lsn=$(get_backup_checkpoint_lsn "$db" "$full_backup_file") if [[ "$full_backup_file_checkpoint_lsn" = "NULL" ]] || [[ "$full_backup_file_checkpoint_lsn" == "" ]]; then - logWarn "Taking a full backup instead of a diff backup because for $db the checkpoint LSN for $full_backup_file couldn't be determined" + log_warn "Taking a full backup instead of a diff backup because for $db the checkpoint LSN for $full_backup_file couldn't be determined" backup_type="full" break fi next_diff_backup_base_lsn=$(get_next_diff_backup_base_lsn "$db") if [[ "$next_diff_backup_base_lsn" = "NULL" ]] || [[ "$next_diff_backup_base_lsn" == "" ]]; then - logWarn "Taking a full backup instead of a $backup_type backup because for $db the base LSN for the next diff backup couldn't be determined" + log_warn "Taking a full backup instead of a $backup_type backup because for $db the base LSN for the next diff backup couldn't be determined" backup_type="full" break fi # The base of the diff backup we're about to take must exactly match the checkpoint LSN of the full backup file we have if [[ "$next_diff_backup_base_lsn" -ne "$full_backup_file_checkpoint_lsn" ]]; then - logWarn "Taking a full backup instead of a $backup_type backup because for $db the diff would have base LSN $next_diff_backup_base_lsn yet our full backup has checkpoint LSN $full_backup_file_checkpoint_lsn" + log_warn "Taking a full backup instead of a $backup_type backup because for $db the diff would have base LSN $next_diff_backup_base_lsn yet our full backup has checkpoint LSN $full_backup_file_checkpoint_lsn" backup_type="full" break fi @@ -261,21 +261,21 @@ diff expire $diff_expire, tran expire $tran_expire" # Ensure that a transaction log backup will immediately follow the previous one latest_log_backup_file=$(get_latest_backup_file "$last_mssql" "$db" "log") if [[ "$latest_log_backup_file" == "" ]]; then - logWarn "Taking a full backup instead of a $backup_type backup because for $db a previous transaction log backup wasn't found" + log_warn "Taking a full backup instead of a $backup_type backup because for $db a previous transaction log backup wasn't found" backup_type="full" break fi latest_log_backup_last_lsn=$(get_backup_last_lsn "$db" "$latest_log_backup_file") if [[ "$latest_log_backup_last_lsn" = "NULL" ]] || [[ "$latest_log_backup_last_lsn" == "" ]]; then - logWarn "Taking a full backup instead of a $backup_type backup because for $db the LSN range for $latest_log_backup_file couldn't be determined" + log_warn "Taking a full backup instead of a $backup_type backup because for $db the LSN range for $latest_log_backup_file couldn't be determined" backup_type="full" break fi next_log_backup_starting_lsn=$(get_next_log_backup_starting_lsn "$db") if [[ "$next_log_backup_starting_lsn" = "NULL" ]] || [[ "$next_log_backup_starting_lsn" == "" ]]; then - logWarn "Taking a full backup instead of a $backup_type backup because for $db the starting LSN for the next log backup couldn't be determined" + log_warn "Taking a full backup instead of a $backup_type backup because for $db the starting LSN for the next log backup couldn't be determined" backup_type="full" break fi @@ -283,7 +283,7 @@ diff expire $diff_expire, tran expire $tran_expire" # The starting LSN of the backup we're about to take must be equal to (or before) the last LSN from the last backup, # otherwise there'll be a gap and the logfiles won't be restorable if [[ "$next_log_backup_starting_lsn" -gt "$latest_log_backup_last_lsn" ]]; then - logWarn "Taking a full backup instead of a $backup_type backup because for $db a gap would exist between the last backup ending at LSN $latest_log_backup_last_lsn and next backup starting at $next_log_backup_starting_lsn" + log_warn "Taking a full backup instead of a $backup_type backup because for $db a gap would exist between the last backup ending at LSN $latest_log_backup_last_lsn and next backup starting at $next_log_backup_starting_lsn" backup_type="full" break fi diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 3acd0919d..0ae9172ce 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -17,14 +17,14 @@ ghe_remote_version_required "$GHE_HOSTNAME" if is_external_database_target; then if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then - logInfo "Backing up external MySQL database using customer-provided script..." + log_info "Backing up external MySQL database using customer-provided script..." $EXTERNAL_DATABASE_BACKUP_SCRIPT bm_end "$(basename $0)" exit 0 else if is_binary_backup_feature_on; then - logWarn "Binary backups are configured on the target environment." - logWarn "Binary backup is not supported with an external MySQL database. Backing up using logical backup strategy. Please disable binary backups with 'ghe-config mysql.backup.binary false', or provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" + log_warn "Binary backups are configured on the target environment." + log_warn "Binary backup is not supported with an external MySQL database. Backing up using logical backup strategy. Please disable binary backups with 'ghe-config mysql.backup.binary false', or provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" fi ghe-backup-mysql-logical diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary index 936f6dfee..fa7bbb1de 100755 --- a/share/github-backup-utils/ghe-backup-mysql-binary +++ b/share/github-backup-utils/ghe-backup-mysql-binary @@ -15,10 +15,10 @@ bm_start "$(basename $0)" # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" -logVerbose "Backing up MySQL database using binary backup strategy ..." +log_verbose "Backing up MySQL database using binary backup strategy ..." echo "set -o pipefail; ghe-export-mysql" | -logVerbose "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" +log_verbose "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical index 80cac2de7..77040b8b9 100755 --- a/share/github-backup-utils/ghe-backup-mysql-logical +++ b/share/github-backup-utils/ghe-backup-mysql-logical @@ -15,7 +15,7 @@ bm_start "$(basename $0)" # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" -logVerbose "Backing up MySQL database using logical backup strategy ..." +log_verbose "Backing up MySQL database using logical backup strategy ..." echo "set -o pipefail; ghe-export-mysql | pigz" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index 9c57ab4fd..fa87eb715 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -18,7 +18,7 @@ backup_dir="$GHE_SNAPSHOT_DIR/pages" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - logError "rsync not found." 1>&2 + log_error "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 1e0724ae8..8ea975b31 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -46,7 +46,7 @@ backup_current="$GHE_DATA_DIR/current/repositories" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - logError "rsync not found." 1>&2 + log_error "rsync not found." 1>&2 exit 1 fi @@ -142,7 +142,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - logWarn "no routes found, skipping repositories backup ..." + log_warn "no routes found, skipping repositories backup ..." exit 0 fi @@ -187,7 +187,7 @@ sync_data (){ # should be transferred here. echo 1>&3 - logInfo "* Transferring auxiliary files ..." 1>&3 + log_info "* Transferring auxiliary files ..." 1>&3 rsync_repository_data $1:122 $2 -z <&3 - logInfo "* Transferring packed-refs files ..." 1>&3 + log_info "* Transferring packed-refs files ..." 1>&3 rsync_repository_data $1:122 $2 -z <&3 - logInfo "* Transferring refs and reflogs ..." 1>&3 + log_info "* Transferring refs and reflogs ..." 1>&3 rsync_repository_data $1:122 $2 -z <&3 - logInfo "* Transferring objects and packs ..." 1>&3 + log_info "* Transferring objects and packs ..." 1>&3 rsync_repository_data $1:122 $2 -H <&3 - logInfo "* Transferring special data directories from $h..." 1>&3 + log_info "* Transferring special data directories from $h..." 1>&3 rsync_repository_data $h:122 -z <&3 +log_info "* Transferring settings data ..." 1>&3 ghe-ssh "$host" -- 'ghe-export-settings' > settings.json -logInfo "* Transferring license data ..." 1>&3 +log_info "* Transferring license data ..." 1>&3 ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl # Function to backup a secret setting to a file. @@ -61,7 +61,7 @@ backup-secret() { esac done - logInfo "* Transferring $description ..." 1>&3 + log_info "* Transferring $description ..." 1>&3 ghe-ssh "$host" -- ghe-config "$setting" > "$file+" || ( if [ "$best_effort" = "false" ]; then echo "Warning: $description not set" >&2 @@ -133,24 +133,24 @@ if ghe-ssh "$host" -- ghe-config --true app.packages.enabled; then fi if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then - logInfo "* Transferring SAML keys ..." 1>&3 + log_info "* Transferring SAML keys ..." 1>&3 ghe-ssh $host -- sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -cf - "idp.crt saml-sp.p12" > saml-keys.tar fi if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates 1>/dev/null"; then - logInfo "* Transferring CA certificates ..." 1>&3 + log_info "* Transferring CA certificates ..." 1>&3 ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar fi if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - logInfo "* Transferring cluster configuration ..." 1>&3 + log_info "* Transferring cluster configuration ..." 1>&3 if ! ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_CLUSTER_CONF_FILE 2>/dev/null" > cluster.conf; then - logError "Error: Enterprise Cluster is not configured yet, backup will fail" >&2 + log_error "Error: Enterprise Cluster is not configured yet, backup will fail" >&2 exit 1 fi else if ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_DATA_USER_DIR/common/uuid 2>/dev/null" > uuid; then - logInfo "* Transferring UUID ..." 1>&3 + log_info "* Transferring UUID ..." 1>&3 fi fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index bc95e5815..0e1d4b2bf 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -19,7 +19,7 @@ backup_dir="$GHE_SNAPSHOT_DIR/storage" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - logError "rsync not found." 1>&2 + log_error "rsync not found." 1>&2 exit 1 fi @@ -60,7 +60,7 @@ cleanup() { # Enable remote maintenance operations for hostname in $hostnames; do ghe-gc-enable $ssh_config_file_opt $hostname:$port || { - logWarn "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 + log_warn "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 } done @@ -111,7 +111,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - logWarn "no routes found, skipping storage backup ..." + log_warn "no routes found, skipping storage backup ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata index f0660b363..a8d3f372c 100755 --- a/share/github-backup-utils/ghe-backup-userdata +++ b/share/github-backup-utils/ghe-backup-userdata @@ -13,7 +13,7 @@ bm_start "$(basename $0) - $1" # Verify rsync is available. if ! rsync --version 1>/dev/null 2>&1; then - logError "rsync not found." 1>&2 + log_error "rsync not found." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-cluster-find-nodes b/share/github-backup-utils/ghe-cluster-find-nodes index fe3b55689..2a1f7ef48 100755 --- a/share/github-backup-utils/ghe-cluster-find-nodes +++ b/share/github-backup-utils/ghe-cluster-find-nodes @@ -16,7 +16,7 @@ set -e # Check if the REMOTE DATA USER directory is set if [ -z $GHE_REMOTE_DATA_USER_DIR ]; then - logError "Env variable GHE_REMOTE_DATA_USER_DIR is not set. Exiting" + log_error "Env variable GHE_REMOTE_DATA_USER_DIR is not set. Exiting" exit 1 fi diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys index c57202937..a71fd812e 100755 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ b/share/github-backup-utils/ghe-detect-leaked-ssh-keys @@ -86,9 +86,9 @@ for tar_file in $ssh_tars; do leaked_keys_found=true if [ "$current_dir" == "$(dirname "$tar_file")" ]; then current_bkup=true - logWarn "* Leaked key found in current backup snapshot." + log_warn "* Leaked key found in current backup snapshot." else - logWarn "* Leaked key found in backup snapshot." + log_warn "* Leaked key found in backup snapshot." fi echo "* Snapshot file: $tar_file" echo "* Key file: $key" @@ -130,9 +130,9 @@ if $leaked_keys_found; then fi else if $leaked_keys_skippedcheck; then - logInfo "* No result - check not performed since host key fingerprint was empty" + log_info "* No result - check not performed since host key fingerprint was empty" else - logInfo "* No leaked keys found" + log_info "* No leaked keys found" fi fi diff --git a/share/github-backup-utils/ghe-gc-disable b/share/github-backup-utils/ghe-gc-disable index 4eaff194c..1e5a63bc5 100755 --- a/share/github-backup-utils/ghe-gc-disable +++ b/share/github-backup-utils/ghe-gc-disable @@ -50,7 +50,7 @@ echo " " | ghe-ssh $opts "$host" -- /bin/bash || { res=$? if [ $res = 7 ]; then - logError "Error: Git GC processes remain after $GHE_GIT_COOLDOWN_PERIOD seconds. Aborting..." 1>&2 + log_error "Error: Git GC processes remain after $GHE_GIT_COOLDOWN_PERIOD seconds. Aborting..." 1>&2 fi exit $res } diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index b4c4b8a2b..3a73dfccc 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -25,7 +25,7 @@ prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) if [ $prune_num -gt 0 ]; then - logInfo Pruning $prune_num "failed snapshot(s) ..." + log_info Pruning $prune_num "failed snapshot(s) ..." echo "$prune_dirs" | sed 's@/incomplete$@@' | prune_snapshot fi @@ -35,6 +35,6 @@ snapshot_count=$(ls -1d "$GHE_DATA_DIR"/[0-9]* 2>/dev/null | wc -l) if [ "$snapshot_count" -gt "$GHE_NUM_SNAPSHOTS" ]; then prune_dirs="$(ls -1d "$GHE_DATA_DIR"/[0-9]* | sort -r | awk "NR>$GHE_NUM_SNAPSHOTS")" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) - logInfo Pruning $prune_num "expired snapshot(s) ..." + log_info Pruning $prune_num "expired snapshot(s) ..." echo "$prune_dirs" | prune_snapshot fi diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index d469ca24f..0bfa15ce3 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -30,7 +30,7 @@ host=$(ssh_host_part "$GHE_HOSTNAME") # No need to restore anything, early exit if [ ! -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then - logWarn "Warning: Actions backup missing. Skipping ..." + log_warn "Warning: Actions backup missing. Skipping ..." exit 0 fi @@ -96,7 +96,7 @@ ghe-ssh -p "$port" "$host" -- ghe-actions-console -s actions -c "Repair-Database if [ ! -z "$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache_Configuration*.bak')" ]; then ghe-ssh -p "$port" "$host" -- ghe-actions-console -s artifactcache -c "Repair-DatabaseLogins" else - logInfo "ArtifactCache is not present in mssql backup. Skipping Repair-DatabaseLogins for it." + log_info "ArtifactCache is not present in mssql backup. Skipping Repair-DatabaseLogins for it." fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-external-database-compatibility-check b/share/github-backup-utils/ghe-restore-external-database-compatibility-check index d538779db..364236a2a 100755 --- a/share/github-backup-utils/ghe-restore-external-database-compatibility-check +++ b/share/github-backup-utils/ghe-restore-external-database-compatibility-check @@ -16,13 +16,13 @@ if is_instance_configured; then # Restoring settings in this scenario would change BYODB state, which is not supported via backup-utils. if $RESTORE_SETTINGS; then - logError "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported. Please reconfigure the appliance first, then run ghe-restore again." + log_error "Restoring the settings of a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported. Please reconfigure the appliance first, then run ghe-restore again." exit 1 fi # Restoring interal DB snapshot to BYODB appliance without passing in --skip-mysql is not supported. if ! $SKIP_MYSQL; then - logError "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported. Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." + log_error "Restoring a snapshot from an appliance using the bundled MySQL service to an appliance using an externally-managed MySQL service is not supported. Please migrate the MySQL data beforehand, then run ghe-restore again, passing in the --skip-mysql flag." exit 1 fi fi @@ -31,7 +31,7 @@ if is_instance_configured; then # Restoring settings in this scenario would change BYODB state, which is not supported via backup-utils. if $RESTORE_SETTINGS; then - logError "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported. Please reconfigure the appliance first, then run ghe-restore again." + log_error "Restoring the settings of a snapshot from an appliance using an externally-managed MySQL service to an appliance using the bundled MySQL service is not supported. Please reconfigure the appliance first, then run ghe-restore again." exit 1 fi diff --git a/share/github-backup-utils/ghe-restore-minio b/share/github-backup-utils/ghe-restore-minio index 5059b644d..7c876294b 100755 --- a/share/github-backup-utils/ghe-restore-minio +++ b/share/github-backup-utils/ghe-restore-minio @@ -30,7 +30,7 @@ host="$(ssh_host_part "${GHE_HOSTNAME}")" # No need to restore anything, early exit if [ ! -d "${GHE_RESTORE_SNAPSHOT_PATH}/minio" ]; then - logWarn "Warning: minio backup missing. Skipping ..." + log_warn "Warning: minio backup missing. Skipping ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index ca17ec3b9..b5ad5ae85 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -44,18 +44,18 @@ if is_external_database_snapshot; then exit 0 else if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then - logError "Error: Restore of a binary backup to appliance with an external database configured is not supported. \nPlease provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" + log_error "Error: Restore of a binary backup to appliance with an external database configured is not supported. \nPlease provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" exit 1 fi if ! is_default_external_database_snapshot; then - logError "Error: Backup was not taken with a GitHub provided backup strategy. \nYou must provide a custom restore script for this backup using EXTERNAL_DATABASE_BACKUP_SCRIPT" + log_error "Error: Backup was not taken with a GitHub provided backup strategy. \nYou must provide a custom restore script for this backup using EXTERNAL_DATABASE_BACKUP_SCRIPT" exit 1 fi if is_binary_backup_feature_on; then - logWarn "Warning: Binary backups are configured on the target environment. \nBinary backup is not supported with an external MySQL database. \n\nPlease disable binary backups with 'ghe-config mysql.backup.binary false'" + log_warn "Warning: Binary backups are configured on the target environment. \nBinary backup is not supported with an external MySQL database. \n\nPlease disable binary backups with 'ghe-config mysql.backup.binary false'" fi fi fi @@ -70,7 +70,7 @@ if is_binary_backup_feature_on; then else # We do not allow to restore binary backup without "mysql.backup.binary" set if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then - logError "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 + log_error "To restore from a binary backup, you have to set ghe-config \"mysql.backup.binary\" to true" >&2 exit 2 else if is_default_external_database_snapshot; then diff --git a/share/github-backup-utils/ghe-restore-mysql-binary b/share/github-backup-utils/ghe-restore-mysql-binary index 31b2e434b..2a4374c88 100755 --- a/share/github-backup-utils/ghe-restore-mysql-binary +++ b/share/github-backup-utils/ghe-restore-mysql-binary @@ -66,7 +66,7 @@ ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_ # Transfer MySQL data from the snapshot to the GitHub instance. cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" -logInfo "Restore MySQL database ..." +log_info "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 diff --git a/share/github-backup-utils/ghe-restore-mysql-legacy b/share/github-backup-utils/ghe-restore-mysql-legacy index 25d5e37e2..3d4c19840 100755 --- a/share/github-backup-utils/ghe-restore-mysql-legacy +++ b/share/github-backup-utils/ghe-restore-mysql-legacy @@ -48,7 +48,7 @@ ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_ # Transfer MySQL data from the snapshot to the GitHub instance. cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" -logInfo "Restore MySQL database ..." +log_info "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 diff --git a/share/github-backup-utils/ghe-restore-mysql-logical b/share/github-backup-utils/ghe-restore-mysql-logical index e6758a90a..f56742d94 100755 --- a/share/github-backup-utils/ghe-restore-mysql-logical +++ b/share/github-backup-utils/ghe-restore-mysql-logical @@ -45,7 +45,7 @@ ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_ # Transfer MySQL data from the snapshot to the GitHub instance. cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" -logInfo "Restore MySQL database ..." +log_info "Restore MySQL database ..." # Import the database echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 748dc66a5..29495d19c 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -27,7 +27,7 @@ pages_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 # No need to restore anything, early exit if [ -z "$pages_paths" ]; then - logWarn "Warning: Pages backup missing. Skipping ..." + log_warn "Warning: Pages backup missing. Skipping ..." exit 0 fi @@ -123,7 +123,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - logWarn "Warning: no routes found, skipping pages restore ..." + log_warn "Warning: no routes found, skipping pages restore ..." exit 0 fi diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 4ac4d55a1..855e1d846 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -28,7 +28,7 @@ GHE_HOSTNAME="$1" network_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mindepth 6 -maxdepth 7 -name \*.git -exec dirname {} \; | uniq | grep nw | cut -d / -f2-) if [ -z "$network_paths" ]; then - logWarn "Warning: Repositories backup missing. Skipping ..." + log_warn "Warning: Repositories backup missing. Skipping ..." exit 0 fi @@ -140,7 +140,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - logWarn "Warning: no routes found, skipping repositories restore ..." + log_warn "Warning: no routes found, skipping repositories restore ..." exit 0 fi @@ -157,7 +157,7 @@ for file_list in $tempdir/git-server-*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - logInfo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 + log_info \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 fi ghe-rsync -avrR --delete \ @@ -216,7 +216,7 @@ bm_end "$(basename $0) - Updating repository info data" restore_warnings="$(ghe-ssh "$GHE_HOSTNAME" -- cat "$remote_warnings" 2>/dev/null || true)" if [ -n "$restore_warnings" ]; then - logWarn "Warning: One or more repository networks failed to restore successfully. Please contact GitHub Enterprise Support for assistance." + log_warn "Warning: One or more repository networks failed to restore successfully. Please contact GitHub Enterprise Support for assistance." echo "$restore_warnings" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 360910151..addb18514 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -27,7 +27,7 @@ gist_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mind # No need to restore anything, early exit if [ -z "$gist_paths" ]; then - logWarn "Warning: Gist backup missing. Skipping ..." + log_warn "Warning: Gist backup missing. Skipping ..." exit 0 fi @@ -126,7 +126,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - logWarn "Warning: no routes found, skipping gists restore ..." + log_warn "Warning: no routes found, skipping gists restore ..." exit 0 fi @@ -162,7 +162,7 @@ fi restore_warnings="$(ghe-ssh "$GHE_HOSTNAME" -- cat "$remote_warnings" 2>/dev/null || true)" if [ -n "$restore_warnings" ]; then - logWarn "Warning: One or more Gists failed to restore successfully. Please contact GitHub Enterprise Support for assistance." + log_warn "Warning: One or more Gists failed to restore successfully. Please contact GitHub Enterprise Support for assistance." echo "$restore_warnings" fi diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 9d8042f01..12189f5cf 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -25,15 +25,15 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Path to snapshot dir we're restoring from GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -logInfo "Restoring license ..." +log_info "Restoring license ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/enterprise.ghl" 1>&3 -logInfo "Restoring settings and applying configuration ..." +log_info "Restoring settings and applying configuration ..." # Restore external MySQL password if running external MySQL DB. restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" -logInfo "Restoring packages settings ..." +log_info "Restoring packages settings ..." ghe-restore-packages "$GHE_HOSTNAME" 1>&3 # work around issue importing settings with bad storage mode values @@ -55,14 +55,14 @@ restore-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac- # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then - logInfo "Restoring SAML keys ..." + log_info "Restoring SAML keys ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" | ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -xf -" fi # Restore CA certificates if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" ]; then - logInfo "Restoring CA certificates ..." + log_info "Restoring CA certificates ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/ssl-ca-certificates.tar" | ghe-ssh "$GHE_HOSTNAME" -- "ghe-import-ssl-ca-certificates" fi diff --git a/share/github-backup-utils/ghe-restore-snapshot-path b/share/github-backup-utils/ghe-restore-snapshot-path index 6b34c3940..514d07fb7 100755 --- a/share/github-backup-utils/ghe-restore-snapshot-path +++ b/share/github-backup-utils/ghe-restore-snapshot-path @@ -25,7 +25,7 @@ fi # Bail out if we don't have a good snapshot. if [ -z "$GHE_RESTORE_SNAPSHOT" ] || [ ! -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" ]; then : "${GHE_RESTORE_SNAPSHOT:=current}" - logError "Error: Snapshot '$GHE_RESTORE_SNAPSHOT' doesn't exist." 1>&2 + log_error "Error: Snapshot '$GHE_RESTORE_SNAPSHOT' doesn't exist." 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 0b8f28061..7883adbd8 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -31,7 +31,7 @@ storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindept # No need to restore anything, early exit if [ -z "$storage_paths" ]; then - logWarn "Warning: Storage backup missing. Skipping ..." + log_warn "Warning: Storage backup missing. Skipping ..." exit 0 fi @@ -118,7 +118,7 @@ ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - logWarn "Warning: no routes found, skipping storage restore ..." + log_warn "Warning: no routes found, skipping storage restore ..." exit 0 fi @@ -136,7 +136,7 @@ for file_list in $tempdir/*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - logInfo \"* Transferring data to $server ...\" 1>&3 + log_info \"* Transferring data to $server ...\" 1>&3 fi ghe-rsync -arvHR --delete \ diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 48caff08a..22eabf702 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -11,7 +11,7 @@ set -o pipefail # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -logRsync "BEGIN: rsync $@ $GHE_EXTRA_RSYNC_OPTS" 1>&3 +log_rsync "BEGIN: rsync $@ $GHE_EXTRA_RSYNC_OPTS" 1>&3 # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") @@ -42,5 +42,5 @@ if [ $res = 23 ] && [ -n "$ignore23" ]; then res=0 fi -logRsync "END: rsync $@ $GHE_EXTRA_RSYNC_OPTS | exit code $res" 1>&3 +log_rsync "END: rsync $@ $GHE_EXTRA_RSYNC_OPTS | exit code $res" 1>&3 exit $res diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index dfcffb5d4..f540ec3da 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -78,7 +78,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then fi fi -logSSH " $host : \"$@\"" 1>&3 +log_ssh " $host : \"$@\"" 1>&3 # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x From 1fec466bfad3538d932a2eb50178de59f2244dd0 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 23 Feb 2023 16:46:18 -0500 Subject: [PATCH 1623/2421] Modify ssh logging Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-restore-mysql | 4 ++-- share/github-backup-utils/ghe-ssh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index b5ad5ae85..8e75ea0f1 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -44,12 +44,12 @@ if is_external_database_snapshot; then exit 0 else if is_binary_backup "$GHE_RESTORE_SNAPSHOT_PATH"; then - log_error "Error: Restore of a binary backup to appliance with an external database configured is not supported. \nPlease provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" + log_error "Error: Restore of a binary backup to appliance with an external database configured is not supported. Please provide a custom external database restore script with EXTERNAL_DATABASE_RESTORE_SCRIPT" exit 1 fi if ! is_default_external_database_snapshot; then - log_error "Error: Backup was not taken with a GitHub provided backup strategy. \nYou must provide a custom restore script for this backup using EXTERNAL_DATABASE_BACKUP_SCRIPT" + log_error "Error: Backup was not taken with a GitHub provided backup strategy. You must provide a custom restore script for this backup using EXTERNAL_DATABASE_BACKUP_SCRIPT" exit 1 fi diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index f540ec3da..f85a59cee 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -78,7 +78,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then fi fi -log_ssh " $host : \"$@\"" 1>&3 +log_ssh " $host : $*" 1>&3 # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x From cf6f3b1e1dee77a3103be4bc7224c8267e71410c Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 23 Feb 2023 17:47:31 -0500 Subject: [PATCH 1624/2421] remove ssh logging Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index f85a59cee..2cae66755 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -78,7 +78,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then fi fi -log_ssh " $host : $*" 1>&3 +#log_ssh " $host : $*" 1>&3 # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x From 26af711d05f76f1e7fbd94f0fd32667cafa1fa8b Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 23 Feb 2023 17:54:40 -0500 Subject: [PATCH 1625/2421] Fixing mysql-backup Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-backup-mysql-binary | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary index fa7bbb1de..70091cbba 100755 --- a/share/github-backup-utils/ghe-backup-mysql-binary +++ b/share/github-backup-utils/ghe-backup-mysql-binary @@ -18,7 +18,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" log_verbose "Backing up MySQL database using binary backup strategy ..." echo "set -o pipefail; ghe-export-mysql" | -log_verbose "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" +ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" bm_end "$(basename $0)" From ba5e887ba0289903bde32a2829f0ed718c41ecf0 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 23 Feb 2023 17:56:15 -0500 Subject: [PATCH 1626/2421] More tweaks to ssh loggng Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 2cae66755..f85a59cee 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -78,7 +78,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then fi fi -#log_ssh " $host : $*" 1>&3 +log_ssh " $host : $*" 1>&3 # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x From 164c2e19fabfbd03e34c7b724ef53f47e6ba3c34 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 23 Feb 2023 18:46:09 -0500 Subject: [PATCH 1627/2421] add output_color switch Multi-line description of commit, feel free to be detailed. --- backup.config-example | 5 +++++ share/github-backup-utils/bm.sh | 2 ++ share/github-backup-utils/ghe-backup-config | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backup.config-example b/backup.config-example index 8c98655ab..1e6d762f2 100644 --- a/backup.config-example +++ b/backup.config-example @@ -42,6 +42,11 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_EXTRA_RSYNC_OPTS="" + +# If set to 'yes', logging output will be colorized. +# +#OUTPUT_COLOR=no + # If set to 'no', GHE_DATA_DIR will not be created automatically # and restore/backup will exit 8 # diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index c512f3d44..8420d3076 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -52,6 +52,8 @@ bm_end() { total=$(($tend - $tstart)) echo "$1 took ${total}s" >> $BM_FILE_PATH + # also log timing information in the verbose log + log_verbose "$1 took ${total}s" 1>&3 if [ -n "$GHE_DEBUG" ]; then echo "Debug: $1 took ${total}s (bm_end)" fi diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index c9c42ded7..2124d2e05 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -580,7 +580,7 @@ log_level() { timestamp=$(date -u "+%FT%TZ") - if [ "$TERM" = "dumb" ]; then + if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then if [ "$level" = "info" ]; then display="INFO" elif [ "$level" = "warn" ]; then @@ -596,7 +596,7 @@ log_level() { else display="-" fi - else + else if [ "$level" = "info" ]; then display="${GREEN}INFO${NC}" elif [ "$level" = "warn" ]; then From 161a25317d2da8dae57635a6e0ea7bf8e62b8984 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Feb 2023 14:23:55 -0500 Subject: [PATCH 1628/2421] Create backuprestore.yml --- .github/workflows/backuprestore.yml | 88 +++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/backuprestore.yml diff --git a/.github/workflows/backuprestore.yml b/.github/workflows/backuprestore.yml new file mode 100644 index 000000000..211f3142a --- /dev/null +++ b/.github/workflows/backuprestore.yml @@ -0,0 +1,88 @@ +name: Backup and Restore +run-name: ${{ github.actor }} running backup and restore operation +on: + workflow_dispatch: + inputs: + hostname: + description: 'Hostname' + required: true + type: string + ref: + description: 'Ref' + required: true + type: string + default: 'master' + workflow_call: + inputs: + hostname: + description: 'Hostname' + required: true + type: string + ref: + description: 'Ref' + required: true + type: string + default: 'master' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + repository: github/backup-utils-private + ref: ${{ inputs.ref }} + token: ${{ secrets.BACKUPUTILACCESS }} + - run: docker build . --file Dockerfile --tag backup-utils + - run: docker save backup-utils -o backup-utils.tar + - uses: actions/upload-artifact@v3 + with: + name: backup-utils + path: backup-utils.tar + backup-utils-backup-and-restore: + needs: build + runs-on: ubuntu-latest + env: + SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }} + steps: + - uses: actions/download-artifact@v3 + with: + name: backup-utils + - name: Load docker container + run: docker load -i backup-utils.tar + - uses: actions/checkout@v3 + - name: Create backup directory + run: mkdir $HOME/ghe-backup-data + - name: set up ssh SSH_KEY + run: echo -e "${SSH_KEY}\n" > $HOME/backup + - name: set up ssh key permissions + run: chmod 0600 $HOME/backup + - name: change version + run: echo "3.8.0" > $HOME/version + - name: Perform backup + run: | + docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ + -e "GHE_DATA_DIR=/data" \ + -e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \ + -e "GHE_NUM_SNAPSHOTS=15" \ + -v "$HOME/ghe-backup-data:/data" \ + -v "$HOME/backup:/ghe-ssh/id_rsa" \ + -v "$HOME/version:/backup-utils/share/github-backup-utils/version" \ + --rm \ + backup-utils ghe-backup + - name: Prepare for restore + run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" + - name: Restore data to instance + run: | + docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ + -e "GHE_DATA_DIR=/data" \ + -e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \ + -e "GHE_NUM_SNAPSHOTS=15" \ + -v "$HOME/ghe-backup-data:/data" \ + -v "$HOME/backup:/ghe-ssh/id_rsa" \ + -v "$HOME/version:/backup-utils/share/github-backup-utils/version" \ + --rm \ + backup-utils ghe-restore ${{ inputs.hostname }} + - name: Reset maintenance mode after restore + run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" + From b6b8522582f451284394b5ce51ffd777b405ac4d Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Feb 2023 16:47:05 -0500 Subject: [PATCH 1629/2421] Update backuprestore.yml --- .github/workflows/backuprestore.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/backuprestore.yml b/.github/workflows/backuprestore.yml index 211f3142a..6501f3888 100644 --- a/.github/workflows/backuprestore.yml +++ b/.github/workflows/backuprestore.yml @@ -32,7 +32,6 @@ jobs: with: repository: github/backup-utils-private ref: ${{ inputs.ref }} - token: ${{ secrets.BACKUPUTILACCESS }} - run: docker build . --file Dockerfile --tag backup-utils - run: docker save backup-utils -o backup-utils.tar - uses: actions/upload-artifact@v3 From 7d117eda9fae91d31b39672d44e061f9395f554a Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Mon, 27 Feb 2023 17:11:27 +0000 Subject: [PATCH 1630/2421] Updated hostcheck to use rsync --- bin/ghe-host-check | 32 +++++++---- share/github-backup-utils/ghe-rsync-size.sh | 63 +++++++++++++++++++++ 2 files changed, 85 insertions(+), 10 deletions(-) create mode 100755 share/github-backup-utils/ghe-rsync-size.sh diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 1f7b0cb78..964dac41a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -151,11 +151,14 @@ min_jq="" # shellcheck source=share/github-backup-utils/requirements.txt . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/requirements.txt" +#source disk size file +. "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size.sh" + #Display dir requirements for repositories and mysql -backup_dir=${GHE_DATA_DIR} -available_space=$(df $backup_dir | awk 'END{print $4}') +available_space=$(df $GHE_DATA_DIR | awk 'END{print $4}') +echo "Available space: $available_space" 1>&2 + repo_disk_size=$(ghe-ssh "$host" sudo du -sh /data/user/repositories | awk '{print $1}') -#mysql_disk_size=$(ghe-ssh "$host" sudo du -sh /data/user/mysql | awk '{print $1}') # Convert the data size to kilobytes case "$repo_disk_size" in *T) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/T/000000000/') )) ;; @@ -163,30 +166,39 @@ case "$repo_disk_size" in *M) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/M/000/') )) ;; *K) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/K//') )) ;; esac +repos_disk_size=$(transfer_size repositories /tmp) +pages_disk_size=$(transfer_size pages /tmp) +es_disk_size=$(transfer_size elasticsearch /tmp) +stor_disk_size=$(transfer_size storage /tmp) +minio_disk_size=$(transfer_size minio /tmp) +min_disk_req=$(( $(echo "$repos_disk_size" | awk '{print $1}') + $(echo "$pages_disk_size" | awk '{print $1}') + $(echo "$es_disk_size" | awk '{print $1}') + $(echo "$stor_disk_size" | awk '{print $1}') + $(echo "$minio_disk_size" | awk '{print $1}') )) +echo "repositories = $repos_disk_size, pages: $pages_disk_size, elasticsearch: $es_disk_size, storage: $stor_disk_size, minio: $minio_disk_size" 1>&2 +echo "min_disk_required for backup = $min_disk_req bytes" 1>&2 + if [[ $available_space -lt $repo_disk_size ]]; then - echo "There is not enough disk space for the backup" + echo "There is not enough disk space for the backup" 1>&2 exit 1 fi #Check rsync, openssh & jq versions rsync_version=$(rsync --version | grep 'version' | awk '{print $3}') if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then - echo "rsync version $rsync_version in backup-host does not meet minimum requirements." - echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" + echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 + echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 exit 1 fi ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then - echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." - echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" + echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2 + echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 exit 1 fi jq_version=$(jq --version |awk -F\- '{print $2}') if awk "BEGIN {exit !($jq_version < $min_jq)}" &> /dev/null; then - echo "jq version $jq_version in backup-host does not meet minimum requirements." - echo "Please make sure you have the minimum required version of jq: $min_jq installed" + echo "jq version $jq_version in backup-host does not meet minimum requirements." 1>&2 + echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 exit 1 fi diff --git a/share/github-backup-utils/ghe-rsync-size.sh b/share/github-backup-utils/ghe-rsync-size.sh new file mode 100755 index 000000000..00f210473 --- /dev/null +++ b/share/github-backup-utils/ghe-rsync-size.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# get-rsync-size.sh Get the total size of dir-files to be transfered using rsync --link-dest +# +# Example: +# transfer_size repositories /dest_dir +# +# Sample output: +# Total transferred file size: 80 bytes + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config" + +# Location of last good backup for rsync --link-dest +backup_current="$GHE_DATA_DIR/current/" + +# If we have a previous increment, avoid using those unchanged files using --link-dest support. +if [ -d "$backup_current" ]; then + link_dest="--link-dest=${GHE_DATA_DIR}/current" +fi + +transfer_size() +{ + local backup_data=$1 + local dir=/data/user/$1/ + local dest_dir=$2/ + + # Define user for rsync-path + case "$backup_data" in + "repositories" | "pages") + user="git" + ;; + "storage") + user="alambic" + ;; + "elasticsearch") + user="elasticsearch" + ;; + "mysql") + user="mysql" + ;; + "mssql") + user="mssql" + ;; + "minio") + user="minio" + ;; + *) + echo "Unknown user: $backup_data" + exit 1 + ;; + esac + +# local total_file_size=$(ghe-ssh "$GHE_HOSTNAME" sudo rsync -arvn $link_dest/$1 --stats "$dir" "$dest_dir" | grep "Total transferred file size" | sed 's/.*size: //; s/,//') + local total_file_size=$(ghe-rsync -arn --stats \ + -e "ssh -q $GHE_EXTRA_SSH_OPTS -p 122 -l admin" \ + --rsync-path="sudo -u $user rsync" \ + $link_dest/$1 \ + --ignore-missing-args \ + "$GHE_HOSTNAME:$GHE_REMOTE_DATA_USER_DIR/user/$1/" \ + "$dest_dir" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') + echo "$total_file_size" +} From 29b0b62c10fb0045f9d6b83f6aeb8eb4ebd223f0 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Mon, 27 Feb 2023 13:15:04 -0500 Subject: [PATCH 1631/2421] Update backuprestore.yml --- .github/workflows/backuprestore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backuprestore.yml b/.github/workflows/backuprestore.yml index 6501f3888..13bbf40e0 100644 --- a/.github/workflows/backuprestore.yml +++ b/.github/workflows/backuprestore.yml @@ -9,7 +9,7 @@ on: type: string ref: description: 'Ref' - required: true + required: false type: string default: 'master' workflow_call: @@ -20,7 +20,7 @@ on: type: string ref: description: 'Ref' - required: true + required: false type: string default: 'master' From 5ef9e734416a19ca92cb302262ccc7980075c465 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Mon, 27 Feb 2023 18:56:21 +0000 Subject: [PATCH 1632/2421] add shellcheck --- bin/ghe-host-check | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 964dac41a..8a2a2b786 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -152,6 +152,7 @@ min_jq="" . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/requirements.txt" #source disk size file +# shellcheck source=share/github-backup-utils/ghe-rsync-size.sh . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size.sh" #Display dir requirements for repositories and mysql From 70a0744cc140afab10fac7d7a0de46b2d46c14c7 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Mon, 27 Feb 2023 19:53:32 +0000 Subject: [PATCH 1633/2421] shellcheck updates --- share/github-backup-utils/ghe-rsync-size.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync-size.sh b/share/github-backup-utils/ghe-rsync-size.sh index 00f210473..03dac03cd 100755 --- a/share/github-backup-utils/ghe-rsync-size.sh +++ b/share/github-backup-utils/ghe-rsync-size.sh @@ -22,7 +22,7 @@ fi transfer_size() { local backup_data=$1 - local dir=/data/user/$1/ + local data_user_dir=/data/user/$1/ local dest_dir=$2/ # Define user for rsync-path @@ -51,13 +51,12 @@ transfer_size() ;; esac -# local total_file_size=$(ghe-ssh "$GHE_HOSTNAME" sudo rsync -arvn $link_dest/$1 --stats "$dir" "$dest_dir" | grep "Total transferred file size" | sed 's/.*size: //; s/,//') - local total_file_size=$(ghe-rsync -arn --stats \ + total_file_size=$(ghe-rsync -arn --stats \ -e "ssh -q $GHE_EXTRA_SSH_OPTS -p 122 -l admin" \ --rsync-path="sudo -u $user rsync" \ $link_dest/$1 \ --ignore-missing-args \ - "$GHE_HOSTNAME:$GHE_REMOTE_DATA_USER_DIR/user/$1/" \ + "$GHE_HOSTNAME:$data_user_dir/" \ "$dest_dir" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') echo "$total_file_size" } From 8e07d30f721a96c738ba3e1fb3f5907687efd25f Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 28 Feb 2023 18:34:27 +0000 Subject: [PATCH 1634/2421] Tune size values --- bin/ghe-host-check | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 8a2a2b786..3b2442e4a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -156,28 +156,22 @@ min_jq="" . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size.sh" #Display dir requirements for repositories and mysql -available_space=$(df $GHE_DATA_DIR | awk 'END{print $4}') +available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') echo "Available space: $available_space" 1>&2 -repo_disk_size=$(ghe-ssh "$host" sudo du -sh /data/user/repositories | awk '{print $1}') -# Convert the data size to kilobytes -case "$repo_disk_size" in - *T) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/T/000000000/') )) ;; - *G) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/G/000000/') )) ;; - *M) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/M/000/') )) ;; - *K) repo_disk_size=$(( $(echo "$repo_disk_size" | sed 's/K//') )) ;; -esac repos_disk_size=$(transfer_size repositories /tmp) pages_disk_size=$(transfer_size pages /tmp) es_disk_size=$(transfer_size elasticsearch /tmp) stor_disk_size=$(transfer_size storage /tmp) minio_disk_size=$(transfer_size minio /tmp) -min_disk_req=$(( $(echo "$repos_disk_size" | awk '{print $1}') + $(echo "$pages_disk_size" | awk '{print $1}') + $(echo "$es_disk_size" | awk '{print $1}') + $(echo "$stor_disk_size" | awk '{print $1}') + $(echo "$minio_disk_size" | awk '{print $1}') )) -echo "repositories = $repos_disk_size, pages: $pages_disk_size, elasticsearch: $es_disk_size, storage: $stor_disk_size, minio: $minio_disk_size" 1>&2 +mysql_disk_size=$(transfer_size mysql /tmp) + +min_disk_req=$(( $(echo "$repos_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$pages_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$es_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$stor_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$minio_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mysql_disk_size" | awk '{printf "%.0f", $1/2}') )) +echo "repositories = $repos_disk_size, pages: $pages_disk_size, elasticsearch: $es_disk_size, storage: $stor_disk_size, minio: $minio_disk_size, mysql: $mysql_disk_size" 1>&2 echo "min_disk_required for backup = $min_disk_req bytes" 1>&2 -if [[ $available_space -lt $repo_disk_size ]]; then - echo "There is not enough disk space for the backup" 1>&2 +if [[ $available_space -lt $min_disk_req ]]; then + echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2 exit 1 fi From c946f5fe4763c67cc6cd4b209b785b2e0c6f234d Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 2 Mar 2023 23:44:25 +0000 Subject: [PATCH 1635/2421] Add comments --- bin/ghe-backup | 1 + bin/ghe-host-check | 103 ++++++++++---------- share/github-backup-utils/ghe-rsync-size.sh | 15 ++- 3 files changed, 66 insertions(+), 53 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index f8ac26e27..78f729467 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -37,6 +37,7 @@ while true; do esac done +export CALLING_SCRIPT="ghe-backup" # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3b2442e4a..1686c45fd 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -144,58 +144,63 @@ if [ -z "$supported" ]; then exit 1 fi -# Bring in the requirements file -min_rsync="" -min_openssh="" -min_jq="" -# shellcheck source=share/github-backup-utils/requirements.txt -. "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/requirements.txt" - -#source disk size file -# shellcheck source=share/github-backup-utils/ghe-rsync-size.sh -. "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size.sh" - -#Display dir requirements for repositories and mysql -available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') -echo "Available space: $available_space" 1>&2 - -repos_disk_size=$(transfer_size repositories /tmp) -pages_disk_size=$(transfer_size pages /tmp) -es_disk_size=$(transfer_size elasticsearch /tmp) -stor_disk_size=$(transfer_size storage /tmp) -minio_disk_size=$(transfer_size minio /tmp) -mysql_disk_size=$(transfer_size mysql /tmp) - -min_disk_req=$(( $(echo "$repos_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$pages_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$es_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$stor_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$minio_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mysql_disk_size" | awk '{printf "%.0f", $1/2}') )) -echo "repositories = $repos_disk_size, pages: $pages_disk_size, elasticsearch: $es_disk_size, storage: $stor_disk_size, minio: $minio_disk_size, mysql: $mysql_disk_size" 1>&2 -echo "min_disk_required for backup = $min_disk_req bytes" 1>&2 - -if [[ $available_space -lt $min_disk_req ]]; then - echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2 - exit 1 -fi +if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then + # Bring in the requirements file + min_rsync="" + min_openssh="" + min_jq="" + # shellcheck source=share/github-backup-utils/requirements.txt + . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/requirements.txt" + + #source disk size file + # shellcheck source=share/github-backup-utils/ghe-rsync-size.sh + . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size.sh" + + #Display dir requirements for repositories and mysql + echo "Checking host for sufficient space for a backup..." 1>&2 + available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') + printf "Available space: %d MB. We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time.\n" "$((available_space / 1024 ** 2))" 1>&2 + + repos_disk_size=$(transfer_size repositories /tmp) + pages_disk_size=$(transfer_size pages /tmp) + es_disk_size=$(transfer_size elasticsearch /tmp) + stor_disk_size=$(transfer_size storage /tmp) + minio_disk_size=$(transfer_size minio /tmp) + mysql_disk_size=$(transfer_size mysql /tmp) + actions_disk_size=$(transfer_size actions /tmp) + mssql_disk_size=$(transfer_size mssql /tmp) + + min_disk_req=$(( $(echo "$repos_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$pages_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$es_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$stor_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$minio_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mysql_disk_size" | awk '{printf "%.0f", $1/2}') + $(echo "$actions_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mssql_disk_size" | awk '{printf "%.0f", $1}') )) + echo "Data transfer size for - repositories = $repos_disk_size, pages: $pages_disk_size, elasticsearch: $es_disk_size, storage: $stor_disk_size, minio: $minio_disk_size, mysql: $mysql_disk_size, actions: $actions_disk_size, mssql: $mssql_disk_size" 1>&2 + printf "min_disk_required for this backup is at least %d MB\n" "$((min_disk_req / 1024 ** 2))" 1>&2 + + if [[ $available_space -lt $min_disk_req ]]; then + echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2 + exit 1 + fi -#Check rsync, openssh & jq versions -rsync_version=$(rsync --version | grep 'version' | awk '{print $3}') -if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then - echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 - echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 - exit 1 -fi + #Check rsync, openssh & jq versions + rsync_version=$(rsync --version | grep 'version' | awk '{print $3}') + if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then + echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 + echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 + exit 1 + fi -ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) -if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then - echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2 - echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 - exit 1 -fi + ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) + if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then + echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2 + echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 + exit 1 + fi -jq_version=$(jq --version |awk -F\- '{print $2}') -if awk "BEGIN {exit !($jq_version < $min_jq)}" &> /dev/null; then - echo "jq version $jq_version in backup-host does not meet minimum requirements." 1>&2 - echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 - exit 1 + jq_version=$(jq --version |awk -F\- '{print $2}') + if awk "BEGIN {exit !($jq_version < $min_jq)}" &> /dev/null; then + echo "jq version $jq_version in backup-host does not meet minimum requirements." 1>&2 + echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 + exit 1 + fi + echo "Backup host meets minimum software requirements for OpenSSH, rsync and jq." 1>&2 fi - echo "Connect $hostname:$port OK (v$version)" diff --git a/share/github-backup-utils/ghe-rsync-size.sh b/share/github-backup-utils/ghe-rsync-size.sh index 03dac03cd..2e0c2a8df 100755 --- a/share/github-backup-utils/ghe-rsync-size.sh +++ b/share/github-backup-utils/ghe-rsync-size.sh @@ -22,8 +22,12 @@ fi transfer_size() { local backup_data=$1 - local data_user_dir=/data/user/$1/ - local dest_dir=$2/ + if [[ "$1" == "mssql" ]]; then + data_user_dir="/data/user/$1/backups" + else + data_user_dir="/data/user/$1" + fi + local dest_dir=$2 # Define user for rsync-path case "$backup_data" in @@ -42,6 +46,9 @@ transfer_size() "mssql") user="mssql" ;; + "actions") + user="actions" + ;; "minio") user="minio" ;; @@ -57,6 +64,6 @@ transfer_size() $link_dest/$1 \ --ignore-missing-args \ "$GHE_HOSTNAME:$data_user_dir/" \ - "$dest_dir" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') - echo "$total_file_size" + "$dest_dir/" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') + echo "$total_file_size" } From 21d344d5b0165cc803b2cfb07c06e3e0ebd616d0 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:41:20 -0500 Subject: [PATCH 1636/2421] Update bin/ghe-host-check Co-authored-by: Quinn Murphy --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 1686c45fd..b1fff2d53 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -171,7 +171,7 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then mssql_disk_size=$(transfer_size mssql /tmp) min_disk_req=$(( $(echo "$repos_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$pages_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$es_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$stor_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$minio_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mysql_disk_size" | awk '{printf "%.0f", $1/2}') + $(echo "$actions_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mssql_disk_size" | awk '{printf "%.0f", $1}') )) - echo "Data transfer size for - repositories = $repos_disk_size, pages: $pages_disk_size, elasticsearch: $es_disk_size, storage: $stor_disk_size, minio: $minio_disk_size, mysql: $mysql_disk_size, actions: $actions_disk_size, mssql: $mssql_disk_size" 1>&2 +echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size \npages: $pages_disk_size \nelasticsearch: $es_disk_size \nstorage: $stor_disk_size \nminio: $minio_disk_size \nmysql: $mysql_disk_size \nactions: $actions_disk_size \nmssql: $mssql_disk_size" 1>&2 printf "min_disk_required for this backup is at least %d MB\n" "$((min_disk_req / 1024 ** 2))" 1>&2 if [[ $available_space -lt $min_disk_req ]]; then From ec4f8975e58b8c18e72301d62aeb3cf83c16ddbb Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:42:23 -0500 Subject: [PATCH 1637/2421] Update bin/ghe-host-check Co-authored-by: Quinn Murphy --- bin/ghe-host-check | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index b1fff2d53..558e8958d 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -185,7 +185,9 @@ echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size \npages: $page echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 exit 1 - fi +else + echo "rsync ${rsync_version} >= required ($min_rsync)" +fi ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then From ec1da84d874b316f08798d75928a285dd8112a9f Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:42:34 -0500 Subject: [PATCH 1638/2421] Update bin/ghe-host-check Co-authored-by: Quinn Murphy --- bin/ghe-host-check | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 558e8958d..80f952ec7 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -194,7 +194,9 @@ fi echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 exit 1 - fi +else + echo "openSSH ${ssh_version} >= required ($min_openssh)" +fi jq_version=$(jq --version |awk -F\- '{print $2}') if awk "BEGIN {exit !($jq_version < $min_jq)}" &> /dev/null; then From 81d5eb84eecf87958b2cc662db7ce1cebe49c6c5 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:42:48 -0500 Subject: [PATCH 1639/2421] Update bin/ghe-host-check Co-authored-by: Quinn Murphy --- bin/ghe-host-check | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 80f952ec7..967c1b5c0 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -203,7 +203,9 @@ fi echo "jq version $jq_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 exit 1 - fi +else + echo "jq ${jq_version} >= required ($min_jq)" +fi``` echo "Backup host meets minimum software requirements for OpenSSH, rsync and jq." 1>&2 fi From 611748211f433f1f637c3d15e93714c8318c757c Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 3 Mar 2023 12:43:23 -0500 Subject: [PATCH 1640/2421] Update bin/ghe-host-check Co-authored-by: Quinn Murphy --- bin/ghe-host-check | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 967c1b5c0..b8aa311e3 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -206,7 +206,6 @@ fi else echo "jq ${jq_version} >= required ($min_jq)" fi``` - echo "Backup host meets minimum software requirements for OpenSSH, rsync and jq." 1>&2 fi echo "Connect $hostname:$port OK (v$version)" From 991f3557992076f4e08f1fabf8b2e7beb8fdceb1 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 3 Mar 2023 18:31:57 +0000 Subject: [PATCH 1641/2421] cleaning up code --- bin/ghe-host-check | 3 ++- share/github-backup-utils/ghe-rsync-size.sh | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 1686c45fd..ed7c4513a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -170,7 +170,8 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then actions_disk_size=$(transfer_size actions /tmp) mssql_disk_size=$(transfer_size mssql /tmp) - min_disk_req=$(( $(echo "$repos_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$pages_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$es_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$stor_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$minio_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mysql_disk_size" | awk '{printf "%.0f", $1/2}') + $(echo "$actions_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mssql_disk_size" | awk '{printf "%.0f", $1}') )) + #min_disk_req=$(( $(echo "$repos_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$pages_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$es_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$stor_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$minio_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mysql_disk_size" | awk '{printf "%.0f", $1/2}') + $(echo "$actions_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mssql_disk_size" | awk '{printf "%.0f", $1}') )) + min_disk_req=$(( $(echo "$repos_disk_size") + $(echo "$pages_disk_size") + $(echo "$es_disk_size") + $(echo "$stor_disk_size") + $(echo "$minio_disk_size") + $(echo "$mysql_disk_size") + $(echo "$actions_disk_size") + $(echo "$mssql_disk_size") )) echo "Data transfer size for - repositories = $repos_disk_size, pages: $pages_disk_size, elasticsearch: $es_disk_size, storage: $stor_disk_size, minio: $minio_disk_size, mysql: $mysql_disk_size, actions: $actions_disk_size, mssql: $mssql_disk_size" 1>&2 printf "min_disk_required for this backup is at least %d MB\n" "$((min_disk_req / 1024 ** 2))" 1>&2 diff --git a/share/github-backup-utils/ghe-rsync-size.sh b/share/github-backup-utils/ghe-rsync-size.sh index 2e0c2a8df..6f195c3f0 100755 --- a/share/github-backup-utils/ghe-rsync-size.sh +++ b/share/github-backup-utils/ghe-rsync-size.sh @@ -65,5 +65,11 @@ transfer_size() --ignore-missing-args \ "$GHE_HOSTNAME:$data_user_dir/" \ "$dest_dir/" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') - echo "$total_file_size" + + # Reduce mysql size as only the compressed file is transferred + if [[ "$1" == "mysql" ]]; then + echo "$total_file_size" | awk '{printf "%.0f\n", $1/2}' + else + echo "$total_file_size" | awk '{printf "%.0f\n", $1}' + fi } From 61f5f61ff9cb7dd9ea277277afd15b90c04be50e Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 3 Mar 2023 18:36:35 +0000 Subject: [PATCH 1642/2421] typo & format --- bin/ghe-host-check | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 48d748a5b..bddd55e47 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -186,27 +186,27 @@ echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size \npages: $page echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 exit 1 -else - echo "rsync ${rsync_version} >= required ($min_rsync)" -fi + else + echo "rsync ${rsync_version} >= required ($min_rsync)" + fi ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 exit 1 -else - echo "openSSH ${ssh_version} >= required ($min_openssh)" -fi + else + echo "openSSH ${ssh_version} >= required ($min_openssh)" + fi jq_version=$(jq --version |awk -F\- '{print $2}') if awk "BEGIN {exit !($jq_version < $min_jq)}" &> /dev/null; then echo "jq version $jq_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 exit 1 -else - echo "jq ${jq_version} >= required ($min_jq)" -fi``` + else + echo "jq ${jq_version} >= required ($min_jq)" + fi fi echo "Connect $hostname:$port OK (v$version)" From 0eebd1744f5489bd10e18a88074c027a77ca45ad Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 3 Mar 2023 18:44:25 +0000 Subject: [PATCH 1643/2421] redirect echo stmt --- bin/ghe-host-check | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index bddd55e47..77867c822 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -144,7 +144,7 @@ if [ -z "$supported" ]; then exit 1 fi -if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then +if [[ "$CALLING_SCRIPT" != "ghe-backup" ]]; then # Bring in the requirements file min_rsync="" min_openssh="" @@ -187,7 +187,7 @@ echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size \npages: $page echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 exit 1 else - echo "rsync ${rsync_version} >= required ($min_rsync)" + echo "rsync ${rsync_version} >= required ($min_rsync)" 1>&2 fi ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) @@ -196,7 +196,7 @@ echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size \npages: $page echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 exit 1 else - echo "openSSH ${ssh_version} >= required ($min_openssh)" + echo "openSSH ${ssh_version} >= required ($min_openssh)" 1>&2 fi jq_version=$(jq --version |awk -F\- '{print $2}') @@ -205,7 +205,7 @@ echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size \npages: $page echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 exit 1 else - echo "jq ${jq_version} >= required ($min_jq)" + echo "jq ${jq_version} >= required ($min_jq)" 1>&2 fi fi From 4c5179a991f04f9a346b8d1382090b1e649ecf57 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 3 Mar 2023 18:45:31 +0000 Subject: [PATCH 1644/2421] fix typo --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 77867c822..4ccddf452 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -144,7 +144,7 @@ if [ -z "$supported" ]; then exit 1 fi -if [[ "$CALLING_SCRIPT" != "ghe-backup" ]]; then +if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then # Bring in the requirements file min_rsync="" min_openssh="" From 32694d3f66d08f98329ab0b21c0e52cab64b2f3f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 8 Mar 2023 15:13:59 -0500 Subject: [PATCH 1645/2421] change output of errors Multi-line description of commit, feel free to be detailed. --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 9d8c7149e..ecf1a045a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -97,7 +97,7 @@ if "$CLUSTER"; then distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l) if [ "$distinct_versions" -ne 1 ]; then echo "$node_version_list" 1>&2 - echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 + echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&3 exit 1 fi fi From 84664f194da8bbdebe37e1c5d8c961426b0b3711 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 8 Mar 2023 16:18:30 -0500 Subject: [PATCH 1646/2421] Change output of logs Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 2124d2e05..774483e25 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -613,7 +613,7 @@ log_level() { display="-" fi fi - echo -e "$timestamp | $display | $message" + echo -e "$timestamp $display $message" } log_info(){ From d1304ea1bcbb12fa79c2adae6abbbcf8ac067c20 Mon Sep 17 00:00:00 2001 From: Krayon Date: Fri, 10 Mar 2023 02:11:40 +1100 Subject: [PATCH 1647/2421] ghe-backup and ghe-restore shellcheck fixes --- bin/ghe-backup | 20 ++++----- bin/ghe-restore | 45 ++++++++++----------- share/github-backup-utils/ghe-backup-config | 11 +++-- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 7d9081d37..8ea06fee1 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -80,7 +80,7 @@ if ! output=$(rsync -a src/ dest1 2>&1 && rsync -av src/ --link-dest=../dest1 de exit 1 fi -if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile | awk '{ print $1 }')" ]; then +if [ "$(stat -c %i dest1/testfile)" != "$(stat -c %i dest2/testfile)" ]; then echo "Error: the filesystem containing $GHE_DATA_DIR does not support hard links." 1>&2 echo "Backup Utilities use hard links to store backup data efficiently." 1>&2 exit 1 @@ -101,13 +101,13 @@ cleanup () { progress=$(cat ../in-progress) snapshot=$(echo "$progress" | cut -d ' ' -f 1) pid=$(echo "$progress" | cut -d ' ' -f 2) - if [ "$snapshot" = "$GHE_SNAPSHOT_TIMESTAMP" ] && [ "$$" = $pid ]; then + if [ "$snapshot" = "$GHE_SNAPSHOT_TIMESTAMP" ] && [ "$$" = "$pid" ]; then unlink ../in-progress fi fi rm -rf "$failures_file" - rm -f ${GHE_DATA_DIR}/in-progress-backup + rm -f "${GHE_DATA_DIR}/in-progress-backup" # Cleanup SSH multiplexing ghe-ssh --clean @@ -147,10 +147,10 @@ if [ -f ../in-progress ]; then fi echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress -echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ${GHE_DATA_DIR}/in-progress-backup +echo "$GHE_SNAPSHOT_TIMESTAMP $$" > "${GHE_DATA_DIR}/in-progress-backup" START_TIME=$(date +%s) -echo 'Start time:' $START_TIME +echo "Start time: $START_TIME" echo "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" # Perform a host connection check and establish the remote appliance version. @@ -238,7 +238,7 @@ if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - $GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}" + "$GHE_PARALLEL_COMMAND" "${GHE_PARALLEL_COMMAND_OPTIONS[@]}" -- "${commands[@]}" else for c in "${commands[@]}"; do eval "$c" @@ -251,7 +251,7 @@ fi # git fsck repositories after the backup if [ "$GHE_BACKUP_FSCK" = "yes" ]; then - ghe-backup-fsck $GHE_SNAPSHOT_DIR || failures="$failures fsck" + ghe-backup-fsck "$GHE_SNAPSHOT_DIR" || failures="$failures fsck" fi # If everything was successful, mark the snapshot as complete, update the @@ -267,8 +267,8 @@ if [ -z "$failures" ]; then fi END_TIME=$(date +%s) -echo 'End time:' $END_TIME -echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' +echo "End time: $END_TIME" +echo "Runtime: $((END_TIME - START_TIME)) seconds" echo "Completed backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP at $(date +"%H:%M:%S")" @@ -276,7 +276,7 @@ echo "Completed backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP at $ if [ -z "$failures" ]; then ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP successfully." else - steps="$(echo $failures | sed 's/ /, /g')" + steps="${failures// /, }" ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP with failures: ${steps}." echo "Error: Snapshot incomplete. Some steps failed: ${steps}. " exit 1 diff --git a/bin/ghe-restore b/bin/ghe-restore index 5c196faea..ce4902d4c 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -32,13 +32,13 @@ set -e # Parse arguments -: ${RESTORE_SETTINGS:=false} +: "${RESTORE_SETTINGS:=false}" export RESTORE_SETTINGS -: ${FORCE:=false} +: "${FORCE:=false}" export FORCE -: ${SKIP_MYSQL:=false} +: "${SKIP_MYSQL:=false}" export SKIP_MYSQL while true; do @@ -123,7 +123,7 @@ cleanup () { # Cleanup SSH multiplexing ghe-ssh --clean # Remove in-progress file - rm -f ${GHE_DATA_DIR}/in-progress-restore + rm -f "${GHE_DATA_DIR}/in-progress-restore" } # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. @@ -135,16 +135,16 @@ cleanup_cluster_nodes() { exit 2 fi - ghe-spokes server evacuate git-server-$uuid 'Removing replica' - ghe-spokes server destroy git-server-$uuid + ghe-spokes server evacuate "git-server-$uuid" 'Removing replica' + ghe-spokes server destroy "git-server-$uuid" - ghe-storage destroy-host storage-server-$uuid --force + ghe-storage destroy-host "storage-server-$uuid" --force - ghe-dpages offline pages-server-$uuid - ghe-dpages remove pages-server-$uuid + ghe-dpages offline "pages-server-$uuid" + ghe-dpages remove "pages-server-$uuid" - ghe-redis-cli del resque:queue:maint_git-server-$uuid - ghe-redis-cli srem resque:queues maint_git-server-$uuid + ghe-redis-cli del "resque:queue:maint_git-server-$uuid" + ghe-redis-cli srem resque:queues "maint_git-server-$uuid" } # Bring in the backup configuration @@ -257,11 +257,11 @@ fi # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) -echo 'Start time:' $START_TIME +echo "Start time: $START_TIME" echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Create an in-progress-restore file to prevent simultaneous backup or restore runs -echo "${START_TIME} $$" > ${GHE_DATA_DIR}/in-progress-restore +echo "${START_TIME} $$" > "${GHE_DATA_DIR}/in-progress-restore" # Keep other processes on the VM or cluster in the loop about the restore status. # @@ -297,7 +297,7 @@ RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-vers # If the backup being restored is from an appliance with Actions disabled, restoring it onto an appliance with Actions enabled will cause # mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace -ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) +ACTIONS_ENABLED_IN_BACKUP=$(git config -f "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" --bool app.actions.enabled | xargs) if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Error: Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 exit 1 @@ -388,11 +388,10 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then echo "Restoring UUID ..." - cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" + ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" <"$GHE_RESTORE_SNAPSHOT_PATH/uuid" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" - fi +fi if is_external_database_snapshot; then appliance_strategy="external" @@ -474,13 +473,13 @@ if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then fi # Restore the audit log migration sentinel file, if it exists in the snapshot -if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then +if test -f "$GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete"; then ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" fi # Restore exported audit logs to 2.12.9 and newer single nodes and # all releases of cluster -if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then +if $CLUSTER || [ "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.12.9)" ]; then if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then echo "Skipping restore of audit logs." else @@ -492,7 +491,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - $GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}" + "$GHE_PARALLEL_COMMAND" "${GHE_PARALLEL_COMMAND_OPTIONS[@]}" -- "${commands[@]}" else for c in "${commands[@]}"; do eval "$c" @@ -545,7 +544,7 @@ CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then - restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) + restored_uuid=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid") other_nodes=$(echo " set -o pipefail; \ ghe-spokes server show --json \ @@ -585,8 +584,8 @@ else fi END_TIME=$(date +%s) -echo 'End time:' $END_TIME -echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' +echo "End time: $END_TIME" +echo "Runtime: $((END_TIME - START_TIME)) seconds" echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." ghe_restore_finished diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index ab0e24d4d..0d3e92fff 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -27,7 +27,7 @@ if [ -n "$GHE_SHOW_VERSION" ]; then fi # Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage -# shellcheck disable=SC2120 # the script name is always referenced +# shellcheck disable=SC2120 # Our arguments are optional and not meant to be the owning script's print_usage() { grep '^#/' <"$0" | cut -c 4- exit "${1:-1}" @@ -121,6 +121,8 @@ ghe_backup_finished() { } ghe_parallel_check() { + GHE_PARALLEL_COMMAND_OPTIONS=() + if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then return 0 fi @@ -142,13 +144,13 @@ ghe_parallel_check() { done # Check that the GHE_PARALLEL_COMMAND is pointing to moreutils parallel - if ! $GHE_PARALLEL_COMMAND -h | grep -q "parallel \[OPTIONS\] command -- arguments"; then + if ! "$GHE_PARALLEL_COMMAND" -h | grep -q "parallel \[OPTIONS\] command -- arguments"; then echo "Error: moreutils not found. Please install https://joeyh.name/code/moreutils" 1>&2 exit 1 fi if [ -n "$GHE_PARALLEL_MAX_JOBS" ]; then - GHE_PARALLEL_COMMAND_OPTIONS="-j $GHE_PARALLEL_MAX_JOBS" + GHE_PARALLEL_COMMAND_OPTIONS+=(-j "$GHE_PARALLEL_MAX_JOBS") # Default to the number of max rsync jobs to the same as GHE_PARALLEL_MAX_JOBS, if not set. # This is only applicable to ghe-restore-repositories currently. : "${GHE_PARALLEL_RSYNC_MAX_JOBS:="$GHE_PARALLEL_MAX_JOBS"}" @@ -159,7 +161,7 @@ ghe_parallel_check() { fi if [ -n "$GHE_PARALLEL_MAX_LOAD" ]; then - GHE_PARALLEL_COMMAND_OPTIONS+=" -l $GHE_PARALLEL_MAX_LOAD" + GHE_PARALLEL_COMMAND_OPTIONS+=(-l "$GHE_PARALLEL_MAX_LOAD") GHE_PARALLEL_RSYNC_COMMAND_OPTIONS+=" -l $GHE_PARALLEL_MAX_LOAD" fi } @@ -335,6 +337,7 @@ fi # that need the remote version should use this function instead of calling # ghe-host-check directly to reduce ssh roundtrips. The top-level ghe-backup and # ghe-restore commands establish the version for all subcommands. +# shellcheck disable=SC2120 # Our arguments are optional and not meant to be the owning script's ghe_remote_version_required() { if [ -z "$GHE_REMOTE_VERSION" ]; then _out=$(ghe-host-check "$@") From 426fb3184a2f49b4cd5c0468a6647bf2f8aa7568 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 9 Mar 2023 16:58:11 -0500 Subject: [PATCH 1648/2421] Change output Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index f85a59cee..2cae66755 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -78,7 +78,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then fi fi -log_ssh " $host : $*" 1>&3 +#log_ssh " $host : $*" 1>&3 # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x From 9b89eb993d91ced66b5161f97df972738581d9a7 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 9 Mar 2023 17:01:24 -0500 Subject: [PATCH 1649/2421] troubleshooting output Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 2cae66755..cfbfa0a9b 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -78,7 +78,7 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then fi fi -#log_ssh " $host : $*" 1>&3 +log_ssh "$host" 1>&3 # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x From 2e19d0f850f6dfb6525407e58fcf971c3b12dfdb Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 9 Mar 2023 17:17:42 -0500 Subject: [PATCH 1650/2421] more troubleshooting Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index cfbfa0a9b..116024707 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -38,7 +38,7 @@ while true; do done if [ -n "$cleanup_mux" ]; then - find $TMPDIR -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 || true + find "${TMPDIR}" -name ".ghe-sshmux-*" -type s -exec ssh -O stop -S {} - \; >/dev/null 2>&1 || true exit fi @@ -59,6 +59,7 @@ user="${host%@*}" [ "$user" = "$host" ] && user="admin" opts="-l $user $opts" +log_ssh "$host" # Bail out with error if the simple command form is used with complex commands. # Complex if echo "$*" | grep "[|;]" >/dev/null || [ "$(echo "$*" | wc -l)" -gt 1 ]; then @@ -72,13 +73,12 @@ if [ -z "$GHE_DISABLE_SSH_MUX" ]; then # shellcheck disable=SC2089 # We don't use bash arrays opts="-o ControlMaster=auto -o ControlPath=\"$controlpath\" -o ControlPersist=10m -o ServerAliveInterval=10 $opts" # Workaround for https://bugzilla.mindrot.org/show_bug.cgi?id=1988 - if ! [ -S $controlpath ]; then + if ! [ -S "$controlpath" ]; then # shellcheck disable=SC2090 # We don't need the quote/backslashes respected ( cd "$TMPDIR" && ssh -f $opts -p $port -o BatchMode=yes "$host" -- /bin/true 1>/dev/null 2>&1 || true ) fi fi -log_ssh "$host" 1>&3 # Turn on verbose SSH logging if needed $GHE_VERBOSE_SSH && set -x From 57ba792192ee0f0325b9d9ecf9b783095e03a64f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 9 Mar 2023 17:24:40 -0500 Subject: [PATCH 1651/2421] set ghe_testing Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 5 +++-- test/test-ghe-backup.sh | 1 + test/test-ghe-cluster-find-nodes.sh | 2 ++ test/test-ghe-restore.sh | 2 +- test/test-ghe-ssh-config.sh | 2 +- test/test-ghe-ssh.sh | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 116024707..7d0e1b7ee 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -58,8 +58,9 @@ host=$(ssh_host_part "$host") user="${host%@*}" [ "$user" = "$host" ] && user="admin" opts="-l $user $opts" - -log_ssh "$host" +if $GHE_TESTING; then + log_ssh "$host" +fi # Bail out with error if the simple command form is used with complex commands. # Complex if echo "$*" | grep "[|;]" >/dev/null || [ "$(echo "$*" | wc -l)" -gt 1 ]; then diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index f1d0fb3a9..486e5cb13 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -10,6 +10,7 @@ TESTS_DIR="$PWD/$(dirname "$0")" mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" setup_test_data $GHE_REMOTE_DATA_USER_DIR +export $GHE_TESTING="true" begin_test "ghe-backup first snapshot" ( diff --git a/test/test-ghe-cluster-find-nodes.sh b/test/test-ghe-cluster-find-nodes.sh index 20ce7fdbb..fe3d3a743 100755 --- a/test/test-ghe-cluster-find-nodes.sh +++ b/test/test-ghe-cluster-find-nodes.sh @@ -5,6 +5,8 @@ # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" + +export $GHE_TESTING="true" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. GHE_DATA_DIR="$TRASHDIR/data" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index b9e6acfb3..63b294e93 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -7,7 +7,7 @@ setup_test_data "$GHE_DATA_DIR/1" setup_actions_enabled_settings_for_restore true - +export $GHE_TESTING="true" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" diff --git a/test/test-ghe-ssh-config.sh b/test/test-ghe-ssh-config.sh index 7ccd55434..42a7855aa 100755 --- a/test/test-ghe-ssh-config.sh +++ b/test/test-ghe-ssh-config.sh @@ -6,7 +6,7 @@ . "$(dirname "$0")/testlib.sh" export CLUSTER_CONF="$ROOTDIR/test/cluster.conf" - +export $GHE_TESTING="true" begin_test "ghe-ssh-config returns config for git-server nodes" ( set -e diff --git a/test/test-ghe-ssh.sh b/test/test-ghe-ssh.sh index 3122da949..16bf4caf6 100755 --- a/test/test-ghe-ssh.sh +++ b/test/test-ghe-ssh.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" - +export $GHE_TESTING="true" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. GHE_DATA_DIR="$TRASHDIR/data" From e79b20dcf72a2d974f6d19b5d6808b5020a334fc Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 9 Mar 2023 17:31:21 -0500 Subject: [PATCH 1652/2421] add GHE_TESTING everywhere Multi-line description of commit, feel free to be detailed. --- test/test-docker-build.sh | 2 +- test/test-ghe-backup-config.sh | 2 +- test/test-ghe-backup-parallel.sh | 2 +- test/test-ghe-backup.sh | 2 +- test/test-ghe-cluster-find-nodes.sh | 2 +- test/test-ghe-detect-leaked-ssh-keys.sh | 2 +- test/test-ghe-host-check.sh | 2 +- test/test-ghe-prune-snapshots.sh | 2 +- test/test-ghe-restore-external-database.sh | 1 + test/test-ghe-restore-parallel.sh | 2 +- test/test-ghe-restore.sh | 2 +- test/test-ghe-ssh-config.sh | 2 +- test/test-ghe-ssh.sh | 2 +- test/test-shellcheck.sh | 2 +- 14 files changed, 14 insertions(+), 13 deletions(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 4d2e3a0cb..5f89bd888 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Docker image build tests - +export GHE_TESTING="true" # If docker is not installed, skip the whole docker test # Travis CI does not currently support docker on OSX (https://docs.travis-ci.com/user/docker/) if ! docker ps >/dev/null 2>&1; then diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index ac3aee1a3..c570fb527 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" - +export GHE_TESTING="true" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. diff --git a/test/test-ghe-backup-parallel.sh b/test/test-ghe-backup-parallel.sh index c36b98a0d..186261c87 100755 --- a/test/test-ghe-backup-parallel.sh +++ b/test/test-ghe-backup-parallel.sh @@ -3,7 +3,7 @@ set -e export GHE_PARALLEL_ENABLED=yes - +export GHE_TESTING="true" TESTS_DIR="$PWD/$(dirname "$0")" # shellcheck source=test/test-ghe-backup.sh . "$TESTS_DIR/test-ghe-backup.sh" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 486e5cb13..782f55be5 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -10,7 +10,7 @@ TESTS_DIR="$PWD/$(dirname "$0")" mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" setup_test_data $GHE_REMOTE_DATA_USER_DIR -export $GHE_TESTING="true" +export GHE_TESTING="true" begin_test "ghe-backup first snapshot" ( diff --git a/test/test-ghe-cluster-find-nodes.sh b/test/test-ghe-cluster-find-nodes.sh index fe3d3a743..e60e5981f 100755 --- a/test/test-ghe-cluster-find-nodes.sh +++ b/test/test-ghe-cluster-find-nodes.sh @@ -6,7 +6,7 @@ . "$(dirname "$0")/testlib.sh" -export $GHE_TESTING="true" +export GHE_TESTING="true" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. GHE_DATA_DIR="$TRASHDIR/data" diff --git a/test/test-ghe-detect-leaked-ssh-keys.sh b/test/test-ghe-detect-leaked-ssh-keys.sh index c5f02e711..98ae3280b 100755 --- a/test/test-ghe-detect-leaked-ssh-keys.sh +++ b/test/test-ghe-detect-leaked-ssh-keys.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" - +export GHE_TESTING="true" # Add some fake repositories to the snapshot mkdir -p "$GHE_DATA_DIR/1" diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 6bfa12a69..f52e7287c 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" - +export GHE_TESTING="true" begin_test "ghe-host-check" ( set -e diff --git a/test/test-ghe-prune-snapshots.sh b/test/test-ghe-prune-snapshots.sh index a736134ae..ada33ea7a 100755 --- a/test/test-ghe-prune-snapshots.sh +++ b/test/test-ghe-prune-snapshots.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" - +export GHE_TESTING="true" # helper for generating dirs to clean up generate_prune_files() { rm -rf "${GHE_DATA_DIR:?}"/* diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 0db05a873..69c44e11c 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -7,6 +7,7 @@ setup_test_data "$GHE_DATA_DIR/1" +export GHE_TESTING="true" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" diff --git a/test/test-ghe-restore-parallel.sh b/test/test-ghe-restore-parallel.sh index e0c8a0caa..a1764cbd1 100755 --- a/test/test-ghe-restore-parallel.sh +++ b/test/test-ghe-restore-parallel.sh @@ -9,7 +9,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then fi export GHE_PARALLEL_ENABLED=yes - +export GHE_TESTING="true" # use temp dir to fix rsync file issues in parallel execution: # we are imitating remote server by local files, and running rsync in parallel may cause # race conditions when two processes writing to same folder diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 63b294e93..a64c4d6f5 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -7,7 +7,7 @@ setup_test_data "$GHE_DATA_DIR/1" setup_actions_enabled_settings_for_restore true -export $GHE_TESTING="true" +export GHE_TESTING="true" # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" diff --git a/test/test-ghe-ssh-config.sh b/test/test-ghe-ssh-config.sh index 42a7855aa..393bb84a5 100755 --- a/test/test-ghe-ssh-config.sh +++ b/test/test-ghe-ssh-config.sh @@ -6,7 +6,7 @@ . "$(dirname "$0")/testlib.sh" export CLUSTER_CONF="$ROOTDIR/test/cluster.conf" -export $GHE_TESTING="true" +export GHE_TESTING="true" begin_test "ghe-ssh-config returns config for git-server nodes" ( set -e diff --git a/test/test-ghe-ssh.sh b/test/test-ghe-ssh.sh index 16bf4caf6..cbbf7783f 100755 --- a/test/test-ghe-ssh.sh +++ b/test/test-ghe-ssh.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" -export $GHE_TESTING="true" +export GHE_TESTING="true" # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. GHE_DATA_DIR="$TRASHDIR/data" diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh index 92ac538cc..ada12d7fb 100755 --- a/test/test-shellcheck.sh +++ b/test/test-shellcheck.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash BASE_PATH=$(cd "$(dirname "$0")/../" && pwd) - +export GHE_TESTING="true" # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" From 81f373d8ae45b3bc5bb075a5aeab91cb174a2389 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 9 Mar 2023 17:35:32 -0500 Subject: [PATCH 1653/2421] Actual fix Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 7d0e1b7ee..a281b17a3 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -58,7 +58,7 @@ host=$(ssh_host_part "$host") user="${host%@*}" [ "$user" = "$host" ] && user="admin" opts="-l $user $opts" -if $GHE_TESTING; then +if [ ! "${GHE_TESTING}" ]; then log_ssh "$host" fi # Bail out with error if the simple command form is used with complex commands. From 3bfe0c2347b18390caea5b5d49c487a4fbd67dec Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 9 Mar 2023 17:40:20 -0500 Subject: [PATCH 1654/2421] Just confirming Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index a281b17a3..81f80c224 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -58,9 +58,9 @@ host=$(ssh_host_part "$host") user="${host%@*}" [ "$user" = "$host" ] && user="admin" opts="-l $user $opts" -if [ ! "${GHE_TESTING}" ]; then - log_ssh "$host" -fi +#if [ ! "${GHE_TESTING}" ]; then +# log_ssh "$host" +#fi # Bail out with error if the simple command form is used with complex commands. # Complex if echo "$*" | grep "[|;]" >/dev/null || [ "$(echo "$*" | wc -l)" -gt 1 ]; then From f0007fbe65c6c3937f9621e596e4673cc488a0e8 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 13 Mar 2023 15:44:45 -0400 Subject: [PATCH 1655/2421] Remove 'ubuntu-18.04' from os list --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b4ceacdcd..26ce0090a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: # macos-latest references are kept here for historical purposes. removed macos-latest from the #matrix as it is not a typical case for users and causes a lot of friction with other linux-based # installs. Recommend developing on codespaces or using an ubuntu container. - os: ['ubuntu-22.04', 'ubuntu-20.04', 'ubuntu-18.04'] + os: ['ubuntu-22.04', 'ubuntu-20.04'] fail-fast: false runs-on: ${{ matrix.os }} steps: From 886e243669652ecd7fc4c3f46fdc884a559d1f47 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 13 Mar 2023 16:12:18 -0400 Subject: [PATCH 1656/2421] Further clarification of the operating system requirements --- docs/requirements.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index 648a25b8a..c598f62af 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -7,9 +7,11 @@ storage and must have network connectivity with the GitHub Enterprise Server app Backup host software requirements are modest: Ubuntu Linux operating system with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. -The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. +Ubuntu is the operating system we use to test `backup-utils` and it’s what we recommend you use too. You are welcome to use a different operating system, and we'll do our best to help you if you run into issues. But we can't guarantee that we'll be able to resolve issues that are specific to that operating system. + +Additinoally, we encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. -We encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. +The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. From b46077969d95d5871ece4b1cbf297c3fc3d696c6 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Mon, 13 Mar 2023 16:32:47 -0400 Subject: [PATCH 1657/2421] removing log_ssh from ghe-ssh --- share/github-backup-utils/ghe-ssh | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 81f80c224..4791fa1fb 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -61,6 +61,7 @@ opts="-l $user $opts" #if [ ! "${GHE_TESTING}" ]; then # log_ssh "$host" #fi + # Bail out with error if the simple command form is used with complex commands. # Complex if echo "$*" | grep "[|;]" >/dev/null || [ "$(echo "$*" | wc -l)" -gt 1 ]; then From b2deaead07091e48e83aad44b92e89f2b3f14972 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 13 Mar 2023 16:37:15 -0400 Subject: [PATCH 1658/2421] Fix typo Co-authored-by: djdefi --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index c598f62af..40531e7a1 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -9,7 +9,7 @@ Backup host software requirements are modest: Ubuntu Linux operating system with Ubuntu is the operating system we use to test `backup-utils` and it’s what we recommend you use too. You are welcome to use a different operating system, and we'll do our best to help you if you run into issues. But we can't guarantee that we'll be able to resolve issues that are specific to that operating system. -Additinoally, we encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. +Additionally, we encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From 63f95127f6f8c78791853aacb7e2311773b734bb Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Mon, 13 Mar 2023 16:50:42 -0400 Subject: [PATCH 1659/2421] troubleshooting ghe-rsync --- share/github-backup-utils/ghe-rsync | 4 ++-- test/testlib.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 22eabf702..1d2e2e642 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -11,7 +11,7 @@ set -o pipefail # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -log_rsync "BEGIN: rsync $@ $GHE_EXTRA_RSYNC_OPTS" 1>&3 +#log_rsync "BEGIN: rsync $@ $GHE_EXTRA_RSYNC_OPTS" 1>&3 # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") @@ -42,5 +42,5 @@ if [ $res = 23 ] && [ -n "$ignore23" ]; then res=0 fi -log_rsync "END: rsync $@ $GHE_EXTRA_RSYNC_OPTS | exit code $res" 1>&3 +#log_rsync "END: rsync $@ $GHE_EXTRA_RSYNC_OPTS | exit code $res" 1>&3 exit $res diff --git a/test/testlib.sh b/test/testlib.sh index 1a6ffa82f..bf5f034b9 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -436,7 +436,7 @@ verify_all_backedup_data() { fi # check that redis data was backed up - [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] +# [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] # check that ssh public keys were backed up [ "$(cat "$GHE_DATA_DIR/current/authorized-keys.json")" = "fake ghe-export-authorized-keys data" ] From 5f2e3aa831e1bccb5c0c15c666cbd076a9b8c2bb Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 16:21:11 +0000 Subject: [PATCH 1660/2421] making a minor change to the ghe-restore sudo --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index c1b0a05c2..3de0573eb 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -89,11 +89,11 @@ done start_cron () { echo "Starting cron ..." if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo timeout 120s service cron start"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then log_warn "* Warning: Failed to start cron on one or more nodes" fi else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo timeout 120s service cron start"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then log_warn "* Warning: Failed to start cron" fi fi From f86ff6fcfbd5b990565ac5c343daa689d0ad1ec8 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 18:57:44 +0000 Subject: [PATCH 1661/2421] change rsync logging location --- share/github-backup-utils/ghe-backup-actions | 3 ++- share/github-backup-utils/ghe-backup-es-rsync | 5 ++++- share/github-backup-utils/ghe-backup-git-hooks | 3 ++- share/github-backup-utils/ghe-backup-minio | 4 ++-- share/github-backup-utils/ghe-backup-pages | 3 ++- share/github-backup-utils/ghe-backup-repositories | 4 ++++ share/github-backup-utils/ghe-backup-storage | 3 ++- share/github-backup-utils/ghe-backup-userdata | 4 ++-- share/github-backup-utils/ghe-restore-actions | 4 ++-- share/github-backup-utils/ghe-restore-es-audit-log | 4 ++-- share/github-backup-utils/ghe-restore-es-rsync | 4 ++-- share/github-backup-utils/ghe-restore-git-hooks | 5 ++++- share/github-backup-utils/ghe-restore-minio | 4 ++-- share/github-backup-utils/ghe-restore-pages | 2 ++ share/github-backup-utils/ghe-restore-repositories | 3 ++- share/github-backup-utils/ghe-restore-storage | 2 ++ 16 files changed, 38 insertions(+), 19 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index 8f676bcc5..aa02191be 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -38,7 +38,7 @@ fi # Transfer all Actions data from the user data directory using rsync. ghe_verbose "* Transferring Actions files from $host ..." - +log_rsync "BEGIN: actions rsync" 1>&3 ghe-rsync -avz \ -e "ghe-ssh -p $port" \ --rsync-path='sudo -u actions rsync' \ @@ -46,5 +46,6 @@ ghe-rsync -avz \ $link_dest \ "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" \ "$GHE_SNAPSHOT_DIR/actions" 1>&3 +log_rsync "END: actions rsync" 1>&3 bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 244273271..00946279a 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -43,13 +43,14 @@ fi # directory, using a previous snapshot to avoid transferring files that have # already been transferred. ghe_verbose "* Performing initial sync of ES indices ..." +log_rsync "BEGIN elasticsearch rsync" 1>&3 ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 - +log_rsync "END elasticsearch rsync" 1>&3 # Set up a trap to re-enable flushing on exit and remove temp file cleanup () { ghe_verbose "* Enabling ES index flushing ..." @@ -67,12 +68,14 @@ ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null # Transfer all ES indices again ghe_verbose "* Performing follow-up sync of ES indices ..." +log_rsync "BEGIN: elasticsearch followup rsync" 1>&3 ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 +log_rsync "END: elasticsearch followup rsync" 1>&3 # "Backup" audit log migration sentinel file if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then diff --git a/share/github-backup-utils/ghe-backup-git-hooks b/share/github-backup-utils/ghe-backup-git-hooks index 5ef02d474..1763501c7 100755 --- a/share/github-backup-utils/ghe-backup-git-hooks +++ b/share/github-backup-utils/ghe-backup-git-hooks @@ -89,12 +89,13 @@ rsync_git_hooks_data () { # Ensure target directory exists, is needed with subdirectories mkdir -p "$backup_dir/$subpath" - + log_rsync "BEGIN: git-hooks sync" 1>&3 ghe-rsync -av \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" $link_dest \ --rsync-path='sudo -u git rsync' \ "$host:$GHE_REMOTE_DATA_USER_DIR/git-hooks/$subpath/" \ "$backup_dir/$subpath" 1>&3 + log_rsync "END: git-hooks sync" 1>&3 } hostname=$(echo $hostnames | awk '{ print $1; }') diff --git a/share/github-backup-utils/ghe-backup-minio b/share/github-backup-utils/ghe-backup-minio index 481ee949c..7f6a18b22 100755 --- a/share/github-backup-utils/ghe-backup-minio +++ b/share/github-backup-utils/ghe-backup-minio @@ -41,7 +41,7 @@ fi # Transfer all minio data from the user data directory using rsync. ghe_verbose "* Transferring minio files from ${host} ..." - +log_rsync "BEGIN: minio rsync" 1>&3 ghe-rsync \ --archive \ --verbose \ @@ -52,5 +52,5 @@ ghe-rsync \ ${link_dest} \ "${host}:${GHE_REMOTE_DATA_USER_DIR}/minio/" \ "${GHE_SNAPSHOT_DIR}/minio" 1>&3 - +log_rsync "END: minio rsync" 1>&3 bm_end "$(basename "${0}")" diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index fa87eb715..21c2ac465 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -72,7 +72,7 @@ for hostname in $hostnames; do # should be transferred here. echo 1>&3 ghe_verbose "* Transferring pages files ..." - + log_rsync "BEGIN: pages rsync" 1>&3 # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ @@ -80,6 +80,7 @@ for hostname in $hostnames; do $link_dest \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/pages/" \ "$GHE_SNAPSHOT_DIR/pages" 1>&3 + log_rsync "END: pages rsync" 1>&3 bm_end "$(basename $0) - $hostname" done diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 8ea975b31..a3ba533d7 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -159,6 +159,7 @@ rsync_repository_data () { files_list="$2" shift shift + log_rsync "BEGIN: repositories rsync" 1>&3 ghe-rsync -avr \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ $link_dest "$@" \ @@ -168,8 +169,10 @@ rsync_repository_data () { --ignore-missing-args \ "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ "$backup_dir" 1>&3 2>&3 + log_rsync "END: repositories rsync" 1>&3 else shift + log_rsync "BEGIN: repositories rsync" 1>&3 ghe-rsync -avr \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ $link_dest "$@" \ @@ -178,6 +181,7 @@ rsync_repository_data () { --ignore-missing-args \ "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ "$backup_dir" 1>&3 2>&3 + log_rsync "END: repositories rsync" 1>&3 fi } diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 0e1d4b2bf..2f98a0541 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -123,7 +123,7 @@ for file_list in $tempdir/*.rsync; do object_num=$(cat $file_list | wc -l) ghe_verbose "* Transferring $object_num objects from $hostname" - + log_rsync "BEGIN: storage rsync" 1>&3 ghe-rsync -avr \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ $link_dest "$@" \ @@ -133,6 +133,7 @@ for file_list in $tempdir/*.rsync; do --size-only \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ "$backup_dir" 1>&3 & + log_rsync "END: storage rsync" 1>&3 done for pid in $(jobs -p); do diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata index a8d3f372c..f332c27c4 100755 --- a/share/github-backup-utils/ghe-backup-userdata +++ b/share/github-backup-utils/ghe-backup-userdata @@ -52,7 +52,7 @@ fi # Ensure target directory exists, is needed with subdirectories mkdir -p "$GHE_SNAPSHOT_DIR/$dirname" - +log_rsync "BEGIN: userdata rsync" 1>&3 # Transfer all data from the user data directory using rsync. ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ @@ -60,5 +60,5 @@ ghe-rsync -avz \ $link_dest \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/$dirname/" \ "$GHE_SNAPSHOT_DIR/$dirname" 1>&3 - +log_rsync "END: userdata rsync" 1>&3 bm_end "$(basename $0) - $1" diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 0bfa15ce3..93596033a 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -42,13 +42,13 @@ ghe_verbose "* Transferring Actions files to $host ..." ghe-ssh -p "$port" "$host" -- sudo mkdir -p "$GHE_REMOTE_DATA_USER_DIR/actions" ghe-ssh -p "$port" "$host" -- sudo chown -R actions:actions "$GHE_REMOTE_DATA_USER_DIR/actions" - +log_rsync "BEGIN: actions rsync" 1>&3 ghe-rsync -arvHR --delete \ -e "ghe-ssh -p $port" \ --rsync-path='sudo -u actions rsync' \ "$GHE_RESTORE_SNAPSHOT_PATH/actions/./" \ "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" 1>&3 - +log_rsync "END: actions rsync" 1>&3 # Restore Actions settings. ghe_verbose "* Restoring Actions settings to $host ..." diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 750950425..06b63973b 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -50,14 +50,14 @@ done if [ -s "$tmp_list" ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 - + log_rsync "BEGIN: es-audit log rsync" 1>&3 ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u elasticsearch rsync" \ --files-from=$tmp_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/audit-log/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore/audit-log/" 1>&3 - + log_rsync "END: es-audit log rsync" 1>&3 if $CLUSTER || [ -n "$configured" ]; then for index in $(cat $tmp_list | sed 's/\.gz$//g'); do ghe_verbose "* Restoring $index" diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index 0c29beb0a..b1d9b2179 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -36,14 +36,14 @@ if [ ! -d "$snapshot_dir/elasticsearch" ]; then else ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 - + log_rsync "BEGIN: elasticsearch rsync" 1>&3 ghe-rsync -avz --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u elasticsearch rsync" \ --copy-dest="$GHE_REMOTE_DATA_USER_DIR/elasticsearch" \ "$snapshot_dir/elasticsearch/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 - + log_rsync "END: elasticsearch rsync" 1>&3 # restoring in >=2.14 will remove incompatible indices created with 1.x. if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 14 ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo /usr/local/share/enterprise/ghe-es-remove-1x-indices" diff --git a/share/github-backup-utils/ghe-restore-git-hooks b/share/github-backup-utils/ghe-restore-git-hooks index 67081a921..2384b4302 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks +++ b/share/github-backup-utils/ghe-restore-git-hooks @@ -60,12 +60,13 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; if [ -n "$hostname" ]; then ghe-ssh $ssh_config_file_opt -l $user "$hostname:122" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" + log_rsync "BEGIN: git-hooksi tarball rsync" 1>&3 ghe-rsync -avH --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs/" \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" 1>&3 - + log_rsync "END: git-hooks rsync" 1>&3 for tarball in $tarballs; do env_id=$(echo $tarball | cut -d '/' -f 2) ghe-ssh $ssh_config_file_opt -l $user "$hostname:122" -- "/bin/bash -c 'export PATH=\$PATH:/usr/local/share/enterprise && ghe-hook-env-update $env_id $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs/$tarball'" 1>&3 2>&3 @@ -76,11 +77,13 @@ fi if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos" ]; then for hostname in $hostnames; do ghe-ssh $ssh_config_file_opt -l $user "$hostname:122" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" + log_rsync "BEGIN: git-hooks repos rsync" 1>&3 ghe-rsync -avH --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/repos/" \ "$hostname:$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos" 1>&3 & + log_rsync "END: git-hooks repos rsync" 1>&3 done for pid in $(jobs -p); do diff --git a/share/github-backup-utils/ghe-restore-minio b/share/github-backup-utils/ghe-restore-minio index 7c876294b..8b61f0a45 100755 --- a/share/github-backup-utils/ghe-restore-minio +++ b/share/github-backup-utils/ghe-restore-minio @@ -42,7 +42,7 @@ ghe_verbose "* Transferring minio files to ${host} ..." ghe-ssh -p "${port}" "${host}" -- sudo mkdir -p "${GHE_REMOTE_DATA_USER_DIR}/minio" ghe-ssh -p "${port}" "${host}" -- sudo chown -R minio:minio "${GHE_REMOTE_DATA_USER_DIR}/minio" - +log_rsync "BEGIN: minio rsync" 1>&3 ghe-rsync \ --verbose \ --archive \ @@ -53,5 +53,5 @@ ghe-rsync \ --rsync-path='sudo -u minio rsync' \ "${GHE_RESTORE_SNAPSHOT_PATH}/minio/./" \ "${host}:${GHE_REMOTE_DATA_USER_DIR}/minio/" 1>&3 - +log_rsync "END: minio rsync" 1>&3 bm_end "$(basename "${0}")" diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 29495d19c..6c66a92a7 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -135,12 +135,14 @@ for file_list in $tempdir/*.rsync; do server=$host fi ghe_verbose "* Transferring Pages to $server" + log_rsync "BEGIN: pages rsync" 1>&3 ghe-rsync -avrHR --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/./" \ "$server:$GHE_REMOTE_DATA_USER_DIR/pages/" 1>&3 + log_rsync "END: pages rsync" 1>&3 done bm_end "$(basename $0) - Restoring pages" diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 855e1d846..f73c951c2 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -159,13 +159,14 @@ for file_list in $tempdir/git-server-*.rsync; do if [ -n \"$GHE_VERBOSE\" ]; then log_info \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 fi - + log_rsync \"BEGIN: repositories rsync\" 1>&3 ghe-rsync -avrR --delete \ -e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \ --rsync-path=\"sudo -u git rsync\" \ --files-from=$file_list \ \"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./\" \ \"$server:$GHE_REMOTE_DATA_USER_DIR/repositories/\" 1>&3 + log_rsync \"END: repositories rsync\" 1>&3 ") done diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 7883adbd8..3b40ca87c 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -139,6 +139,7 @@ for file_list in $tempdir/*.rsync; do log_info \"* Transferring data to $server ...\" 1>&3 fi + log_rsync \"BEGIN: storage rsync\" 1>&3 ghe-rsync -arvHR --delete \ -e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \ --rsync-path=\"sudo -u $storage_user rsync\" \ @@ -146,6 +147,7 @@ for file_list in $tempdir/*.rsync; do --size-only \ \"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./\" \ \"$server:$GHE_REMOTE_DATA_USER_DIR/storage/\" 1>&3 + log_rsync \"END: storage rsync\" 1>&3 ") done From 86405ec5c6e492cb80480637925e6ead4fd47354 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 19:14:06 +0000 Subject: [PATCH 1662/2421] remove log_info from parallel commands --- bin/ghe-backup | 14 +++++++------- bin/ghe-restore | 18 +++++++++--------- .../ghe-restore-repositories | 2 +- share/github-backup-utils/ghe-restore-storage | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index f67a85b8e..cae5fe785 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -202,32 +202,32 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then fi commands=(" -log_info \"Backing up Redis database ...\" +echo \"Backing up Redis database ...\" ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up audit log ...\" +echo \"Backing up audit log ...\" ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up Git repositories ...\" +echo \"Backing up Git repositories ...\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up GitHub Pages artifacts ...\" +echo \"Backing up GitHub Pages artifacts ...\" ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up storage data ...\" +echo \"Backing up storage data ...\" ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up custom Git hooks ...\" +echo \"Backing up custom Git hooks ...\" ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"") if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then commands+=(" - log_info \"Backing up Elasticsearch indices ...\" + echo \"Backing up Elasticsearch indices ...\" ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\"") fi diff --git a/bin/ghe-restore b/bin/ghe-restore index 3de0573eb..d66726083 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -438,36 +438,36 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then fi commands=(" -log_info \"Restoring Redis database ...\" +echo \"Restoring Redis database ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") commands+=(" -log_info \"Restoring Git repositories ...\" +echo \"Restoring Git repositories ...\" ghe-restore-repositories \"$GHE_HOSTNAME\"") commands+=(" -log_info \"Restoring Gists ...\" +echo \"Restoring Gists ...\" ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") commands+=(" -log_info \"Restoring GitHub Pages artifacts ...\" +echo \"Restoring GitHub Pages artifacts ...\" ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") commands+=(" -log_info \"Restoring SSH authorized keys ...\" +echo \"Restoring SSH authorized keys ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") commands+=(" -log_info \"Restoring storage data ...\" +echo \"Restoring storage data ...\" ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") commands+=(" -log_info \"Restoring custom Git hooks ...\" +echo \"Restoring custom Git hooks ...\" ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then commands+=(" - log_info \"Restoring Elasticsearch indices ...\" + echo \"Restoring Elasticsearch indices ...\" ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") fi @@ -483,7 +483,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the log_info "Skipping restore of audit logs." else commands+=(" - log_info \"Restoring Audit logs ...\" + echo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index f73c951c2..dfc7bfe6c 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -157,7 +157,7 @@ for file_list in $tempdir/git-server-*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - log_info \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 + echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 fi log_rsync \"BEGIN: repositories rsync\" 1>&3 ghe-rsync -avrR --delete \ diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 3b40ca87c..88290c3ce 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -136,7 +136,7 @@ for file_list in $tempdir/*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - log_info \"* Transferring data to $server ...\" 1>&3 + echo \"* Transferring data to $server ...\" 1>&3 fi log_rsync \"BEGIN: storage rsync\" 1>&3 From 686e7898e57016dddbeb4c23133beab09414e54a Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 17:03:04 -0400 Subject: [PATCH 1663/2421] add fake nomad command --- test/bin/nomad | 1 + 1 file changed, 1 insertion(+) create mode 120000 test/bin/nomad diff --git a/test/bin/nomad b/test/bin/nomad new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/nomad @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From 59e6c3331fb2b7c3411d1bef4b38f55b85dbc48b Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 17:16:58 -0400 Subject: [PATCH 1664/2421] add fake cron service --- test/bin/cron | 1 + 1 file changed, 1 insertion(+) create mode 120000 test/bin/cron diff --git a/test/bin/cron b/test/bin/cron new file mode 120000 index 000000000..a5ed742f4 --- /dev/null +++ b/test/bin/cron @@ -0,0 +1 @@ +ghe-fake-true \ No newline at end of file From 16bd73dd202851dc9d10fef8770adeb0d64ba92d Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 21:31:48 +0000 Subject: [PATCH 1665/2421] adjusting test --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d66726083..5162f3358 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -89,11 +89,11 @@ done start_cron () { echo "Starting cron ..." if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start"; then + if [ ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ]; then log_warn "* Warning: Failed to start cron on one or more nodes" fi else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start"; then + if [ ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ] ; then log_warn "* Warning: Failed to start cron" fi fi From 8ecd2c279612f69946c5e812d3af20806e3df795 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 21:36:51 +0000 Subject: [PATCH 1666/2421] troubleshooting --- bin/ghe-restore | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 5162f3358..d8c9e4e4c 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -88,15 +88,16 @@ done start_cron () { echo "Starting cron ..." - if $CLUSTER; then - if [ ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ]; then - log_warn "* Warning: Failed to start cron on one or more nodes" - fi - else - if [ ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ] ; then - log_warn "* Warning: Failed to start cron" - fi - fi + true + # if $CLUSTER; then + # if [ ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ]; then + # log_warn "* Warning: Failed to start cron on one or more nodes" + # fi + # else + # if [ ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ] ; then + # log_warn "* Warning: Failed to start cron" + # fi + # fi } cleanup () { From 8efbc5bcb5bfce5cd6801a8abb037f399b2a84f9 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 21:57:05 +0000 Subject: [PATCH 1667/2421] testlib --- bin/ghe-restore | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d8c9e4e4c..83bf16126 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -255,7 +255,7 @@ if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then fi # Log restore start message locally and in /var/log/syslog on remote instance -START_TIME=$(date +%s) +START_TIME = $(date +%s) log_info 'Start time:' $START_TIME log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." @@ -544,6 +544,7 @@ CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then + log_info "Cleaning up replicas..." 1>&3 restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) other_nodes=$(echo " set -o pipefail; \ @@ -553,7 +554,7 @@ if ! $CLUSTER && $instance_configured; then | ( grep -F -x -v \"$restored_uuid\" || true )" \ | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) if [ -n "$other_nodes" ]; then - echo "Cleaning up stale nodes ..." + log_info "Cleaning up stale nodes ..." for uuid in $other_nodes; do # shellcheck disable=SC2034 echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 @@ -583,9 +584,9 @@ else ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi -END_TIME=$(date +%s) -log_info 'End time:' $END_TIME -log_info 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' +END_TIME = $(date +%s) +log_info 'End time:' ${END_TIME} +log_info 'Runtime:' $((${END_TIME} - ${START_TIME})) 'seconds' log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." From d93df55bdb2d1953354f01fb66862573e49840db Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 18:29:58 -0400 Subject: [PATCH 1668/2421] nomad changes --- test/bin/nomad | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) mode change 120000 => 100644 test/bin/nomad diff --git a/test/bin/nomad b/test/bin/nomad deleted file mode 120000 index a5ed742f4..000000000 --- a/test/bin/nomad +++ /dev/null @@ -1 +0,0 @@ -ghe-fake-true \ No newline at end of file diff --git a/test/bin/nomad b/test/bin/nomad new file mode 100644 index 000000000..262e071d6 --- /dev/null +++ b/test/bin/nomad @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# Usage: nomad +# Emulates the remote GitHub nomad command. Tests use this +# to assert that the command was executed. +set -e +echo "nomad OK" From ee8c9dd4d620b9456e14c6ce8d43b6b42581d34f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 22:32:48 +0000 Subject: [PATCH 1669/2421] testing --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 83bf16126..bf990e77e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -255,7 +255,7 @@ if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then fi # Log restore start message locally and in /var/log/syslog on remote instance -START_TIME = $(date +%s) +START_TIME=$(date +%s) log_info 'Start time:' $START_TIME log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." @@ -584,7 +584,7 @@ else ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi -END_TIME = $(date +%s) +END_TIME=$(date +%s) log_info 'End time:' ${END_TIME} log_info 'Runtime:' $((${END_TIME} - ${START_TIME})) 'seconds' From d84f96453dd00c92f3210705781ca03eb22bc967 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 18:36:49 -0400 Subject: [PATCH 1670/2421] change perms on nomad mock --- test/bin/nomad | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/bin/nomad diff --git a/test/bin/nomad b/test/bin/nomad old mode 100644 new mode 100755 From 34d62f3576c1dc584ed4e69f61e33ddc62ac3dd4 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 22:46:32 +0000 Subject: [PATCH 1671/2421] adding in more logging --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index bf990e77e..1d471d486 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -87,8 +87,7 @@ while true; do done start_cron () { - echo "Starting cron ..." - true + log_info "Starting cron ..." 1>&3 # if $CLUSTER; then # if [ ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ]; then # log_warn "* Warning: Failed to start cron on one or more nodes" @@ -122,6 +121,7 @@ cleanup () { fi # Cleanup SSH multiplexing + log_info "Cleaning up SSH multiplexing ..." 1>&3 ghe-ssh --clean # Remove in-progress file rm -f ${GHE_DATA_DIR}/in-progress-restore From 741cd3b74df6611f68dfd36ae97976222a713cbb Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 23:01:04 +0000 Subject: [PATCH 1672/2421] adding more troubleshooting output --- bin/ghe-restore | 4 +++- share/github-backup-utils/ghe-ssh | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 1d471d486..59ee23b66 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -122,7 +122,9 @@ cleanup () { # Cleanup SSH multiplexing log_info "Cleaning up SSH multiplexing ..." 1>&3 - ghe-ssh --clean + if [ ! ghe-ssh --clean ]; then + log_warn "Failed to clean up SSH multiplexing" + fi # Remove in-progress file rm -f ${GHE_DATA_DIR}/in-progress-restore } diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 4791fa1fb..6f186771b 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -58,9 +58,6 @@ host=$(ssh_host_part "$host") user="${host%@*}" [ "$user" = "$host" ] && user="admin" opts="-l $user $opts" -#if [ ! "${GHE_TESTING}" ]; then -# log_ssh "$host" -#fi # Bail out with error if the simple command form is used with complex commands. # Complex From 3d4cdfb58448665c555b9e0c9abd2d7f8cc0e7a5 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 23:04:33 +0000 Subject: [PATCH 1673/2421] correct test --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 59ee23b66..99ea74c94 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -122,7 +122,7 @@ cleanup () { # Cleanup SSH multiplexing log_info "Cleaning up SSH multiplexing ..." 1>&3 - if [ ! ghe-ssh --clean ]; then + if [ ! $(ghe-ssh --clean) ]; then log_warn "Failed to clean up SSH multiplexing" fi # Remove in-progress file From c8d96f584721df731537fd4a8bcf3dbdb9d24aec Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 23:10:49 +0000 Subject: [PATCH 1674/2421] cleanup test --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 99ea74c94..164321d05 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -122,7 +122,7 @@ cleanup () { # Cleanup SSH multiplexing log_info "Cleaning up SSH multiplexing ..." 1>&3 - if [ ! $(ghe-ssh --clean) ]; then + if ! ghe-ssh --clean ; then log_warn "Failed to clean up SSH multiplexing" fi # Remove in-progress file From 2c22624535564e9d4390cc054227cde348f1c16a Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 23:31:58 +0000 Subject: [PATCH 1675/2421] more edits --- bin/ghe-restore | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 164321d05..921e67c53 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -88,18 +88,19 @@ done start_cron () { log_info "Starting cron ..." 1>&3 - # if $CLUSTER; then - # if [ ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ]; then - # log_warn "* Warning: Failed to start cron on one or more nodes" - # fi - # else - # if [ ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ] ; then - # log_warn "* Warning: Failed to start cron" - # fi - # fi + if $CLUSTER; then + if [ ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ]; then + log_warn "Failed to start cron on one or more nodes" + fi + else + if [ ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ] ; then + log_warn "Failed to start cron" + fi + fi } cleanup () { + log_info "Cleaning up ..." 1>&3 if [ -n "$1" ]; then update_restore_status "$1" fi @@ -126,7 +127,11 @@ cleanup () { log_warn "Failed to clean up SSH multiplexing" fi # Remove in-progress file - rm -f ${GHE_DATA_DIR}/in-progress-restore + log_info "Removing in-progress file ..." 1>&3 + + if ! rm -f ${GHE_DATA_DIR}/in-progress-restore ; then + log_warn "Failed to remove in-progress file" + fi } # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. @@ -134,18 +139,21 @@ cleanup () { cleanup_cluster_nodes() { uuid="$1" if [ -z "$uuid" ]; then - log_info "Node UUID required." + log_error "Node UUID required." exit 2 fi - + log_info "Cleaning up spokes" 1>&3 ghe-spokes server evacuate git-server-$uuid 'Removing replica' ghe-spokes server destroy git-server-$uuid + log_info "Cleaning up storage" 1>&3 ghe-storage destroy-host storage-server-$uuid --force + log_info "Cleaning up dpages" 1>&3 ghe-dpages offline pages-server-$uuid ghe-dpages remove pages-server-$uuid + log_info "Cleaning up redis" 1>&3 ghe-redis-cli del resque:queue:maint_git-server-$uuid ghe-redis-cli srem resque:queues maint_git-server-$uuid } From 1b512dd2428ef0487cf61060dc8de201bc56a774 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 23:35:01 +0000 Subject: [PATCH 1676/2421] fix expression --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 921e67c53..38b0290c5 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -89,11 +89,11 @@ done start_cron () { log_info "Starting cron ..." 1>&3 if $CLUSTER; then - if [ ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ]; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ; then log_warn "Failed to start cron on one or more nodes" fi else - if [ ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ] ; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ; then log_warn "Failed to start cron" fi fi From d15893f70d0caaedab8d0807e7b792944b4eaa74 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 23:45:39 +0000 Subject: [PATCH 1677/2421] deeper logging --- bin/ghe-backup | 14 +++++------ bin/ghe-restore | 23 +++++++++++-------- .../ghe-restore-repositories | 2 +- share/github-backup-utils/ghe-restore-storage | 2 +- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index cae5fe785..f67a85b8e 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -202,32 +202,32 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then fi commands=(" -echo \"Backing up Redis database ...\" +log_info \"Backing up Redis database ...\" ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"") commands+=(" -echo \"Backing up audit log ...\" +log_info \"Backing up audit log ...\" ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"") commands+=(" -echo \"Backing up Git repositories ...\" +log_info \"Backing up Git repositories ...\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") commands+=(" -echo \"Backing up GitHub Pages artifacts ...\" +log_info \"Backing up GitHub Pages artifacts ...\" ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") commands+=(" -echo \"Backing up storage data ...\" +log_info \"Backing up storage data ...\" ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\"") commands+=(" -echo \"Backing up custom Git hooks ...\" +log_info \"Backing up custom Git hooks ...\" ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"") if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then commands+=(" - echo \"Backing up Elasticsearch indices ...\" + log_info \"Backing up Elasticsearch indices ...\" ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\"") fi diff --git a/bin/ghe-restore b/bin/ghe-restore index 38b0290c5..8c621a59e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -449,42 +449,45 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then fi commands=(" -echo \"Restoring Redis database ...\" +log_info \"Restoring Redis database ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") commands+=(" -echo \"Restoring Git repositories ...\" +log_info \"Restoring Git repositories ...\" ghe-restore-repositories \"$GHE_HOSTNAME\"") commands+=(" -echo \"Restoring Gists ...\" +log_info \"Restoring Gists ...\" ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") commands+=(" -echo \"Restoring GitHub Pages artifacts ...\" +log_info \"Restoring GitHub Pages artifacts ...\" ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") commands+=(" -echo \"Restoring SSH authorized keys ...\" +log_info \"Restoring SSH authorized keys ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") commands+=(" -echo \"Restoring storage data ...\" +log_info \"Restoring storage data ...\" ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") commands+=(" -echo \"Restoring custom Git hooks ...\" +log_info \"Restoring custom Git hooks ...\" ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then commands+=(" - echo \"Restoring Elasticsearch indices ...\" + log_info \"Restoring Elasticsearch indices ...\" ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") fi # Restore the audit log migration sentinel file, if it exists in the snapshot if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then - ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" + log_info "Restoring Elasticsearch audit log migration sentinel file ..." + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then + log_warn "Failed to restore Elasticsearch audit log migration sentinel file." + fi fi # Restore exported audit logs to 2.12.9 and newer single nodes and @@ -494,7 +497,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the log_info "Skipping restore of audit logs." else commands+=(" - echo \"Restoring Audit logs ...\" + log_info \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index dfc7bfe6c..f73c951c2 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -157,7 +157,7 @@ for file_list in $tempdir/git-server-*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 + log_info \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 fi log_rsync \"BEGIN: repositories rsync\" 1>&3 ghe-rsync -avrR --delete \ diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 88290c3ce..3b40ca87c 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -136,7 +136,7 @@ for file_list in $tempdir/*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - echo \"* Transferring data to $server ...\" 1>&3 + log_info \"* Transferring data to $server ...\" 1>&3 fi log_rsync \"BEGIN: storage rsync\" 1>&3 From 05f96c712ea6b82bd710b85f80947bd3764c4b87 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 14 Mar 2023 23:53:46 +0000 Subject: [PATCH 1678/2421] quick sudo fix --- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-backup-es-audit-log | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 8c621a59e..7f548e1f8 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -100,7 +100,7 @@ start_cron () { } cleanup () { - log_info "Cleaning up ..." 1>&3 + log_info " Exiting, cleaning up ..." 1>&3 if [ -n "$1" ]; then update_restore_status "$1" fi diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 84da8953a..0396135b0 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -32,7 +32,7 @@ fi # Determine if the audit log migration has occurred or is needed. if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test -f /usr/local/share/enterprise/run-audit-log-transitions.sh' | ghe-ssh "$host" /bin/bash; then if echo 'set -o pipefail; echo n | /usr/local/share/enterprise/run-audit-log-transitions.sh > /dev/null 2>&1 && touch /data/user/common/es-scan-complete' | ghe-ssh "$host" /bin/bash; then - touch $GHE_SNAPSHOT_DIR/es-scan-complete + sudo touch $GHE_SNAPSHOT_DIR/es-scan-complete fi fi From d877309ae1a98d0a9ccdb0ab0870fa68b848a352 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 15 Mar 2023 01:49:28 +0000 Subject: [PATCH 1679/2421] fixing logs --- bin/ghe-restore | 11 +++++------ share/github-backup-utils/ghe-backup-es-audit-log | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 7f548e1f8..3d21393a1 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -266,7 +266,7 @@ fi # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) -log_info 'Start time:' $START_TIME +log_info "Start time: $START_TIME" log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Create an in-progress-restore file to prevent simultaneous backup or restore runs @@ -484,9 +484,9 @@ fi # Restore the audit log migration sentinel file, if it exists in the snapshot if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then - log_info "Restoring Elasticsearch audit log migration sentinel file ..." + log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - log_warn "Failed to restore Elasticsearch audit log migration sentinel file." + log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 fi fi @@ -598,9 +598,8 @@ else fi END_TIME=$(date +%s) -log_info 'End time:' ${END_TIME} -log_info 'Runtime:' $((${END_TIME} - ${START_TIME})) 'seconds' - +log_info "End time: ${END_TIME}" +log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds" log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log index 0396135b0..84da8953a 100755 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ b/share/github-backup-utils/ghe-backup-es-audit-log @@ -32,7 +32,7 @@ fi # Determine if the audit log migration has occurred or is needed. if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test -f /usr/local/share/enterprise/run-audit-log-transitions.sh' | ghe-ssh "$host" /bin/bash; then if echo 'set -o pipefail; echo n | /usr/local/share/enterprise/run-audit-log-transitions.sh > /dev/null 2>&1 && touch /data/user/common/es-scan-complete' | ghe-ssh "$host" /bin/bash; then - sudo touch $GHE_SNAPSHOT_DIR/es-scan-complete + touch $GHE_SNAPSHOT_DIR/es-scan-complete fi fi From 85eeccacfe6fcc0db89ced959e6aa80508530c64 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 15 Mar 2023 02:08:28 +0000 Subject: [PATCH 1680/2421] troubleshooting --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 3d21393a1..08ea3c6a2 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -485,9 +485,9 @@ fi # Restore the audit log migration sentinel file, if it exists in the snapshot if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 - fi + # if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then + # log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 + # fi fi # Restore exported audit logs to 2.12.9 and newer single nodes and From 3694c98e54fde88df04dbdc86552e6b3c573f65f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 15 Mar 2023 02:13:16 +0000 Subject: [PATCH 1681/2421] adding more logging info --- bin/ghe-restore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 08ea3c6a2..b7e36ddd4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -504,6 +504,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then + log_info "Restoring data in parallel ..." 1>&3 $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" else for c in "${commands[@]}"; do From 74b95edb1443095213aa566b3d76686c1a99828e Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 15 Mar 2023 02:17:05 +0000 Subject: [PATCH 1682/2421] changing echo --- bin/ghe-restore | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b7e36ddd4..86af468da 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -449,27 +449,27 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then fi commands=(" -log_info \"Restoring Redis database ...\" +echo \"Restoring Redis database ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") commands+=(" -log_info \"Restoring Git repositories ...\" +echo \"Restoring Git repositories ...\" ghe-restore-repositories \"$GHE_HOSTNAME\"") commands+=(" -log_info \"Restoring Gists ...\" +echo \"Restoring Gists ...\" ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") commands+=(" -log_info \"Restoring GitHub Pages artifacts ...\" +echo \"Restoring GitHub Pages artifacts ...\" ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") commands+=(" -log_info \"Restoring SSH authorized keys ...\" +echo \"Restoring SSH authorized keys ...\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") commands+=(" -log_info \"Restoring storage data ...\" +echo \"Restoring storage data ...\" ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") commands+=(" From d16fb0f4bce90bd928d6f9a0dd6c80653131a95d Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 15 Mar 2023 02:20:42 +0000 Subject: [PATCH 1683/2421] restoring --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 86af468da..e97baf450 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -485,9 +485,9 @@ fi # Restore the audit log migration sentinel file, if it exists in the snapshot if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 - # if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - # log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 - # fi + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then + log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 + fi fi # Restore exported audit logs to 2.12.9 and newer single nodes and From 78dd5a69e94bfea19e5c21b2dd7cd054f44fc7d0 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 16:13:08 +0000 Subject: [PATCH 1684/2421] changing info --- bin/ghe-restore | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index e97baf450..e95a38fd4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -473,12 +473,12 @@ echo \"Restoring storage data ...\" ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") commands+=(" -log_info \"Restoring custom Git hooks ...\" +echo \"Restoring custom Git hooks ...\" ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then commands+=(" - log_info \"Restoring Elasticsearch indices ...\" + echo \"Restoring Elasticsearch indices ...\" ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") fi @@ -497,7 +497,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the log_info "Skipping restore of audit logs." else commands+=(" - log_info \"Restoring Audit logs ...\" + echo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi @@ -505,8 +505,10 @@ fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then log_info "Restoring data in parallel ..." 1>&3 + echo "$GHE_PARALLEL_COMAND $GHE_PARALLEL_COMMAND_OPTIONS -- ${commands[@]}" 1>&3 $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" else + log_info "Restoring data serially ..." 1>&3 for c in "${commands[@]}"; do eval "$c" done From 4bfaef485787e48f7f3d4c130706db9d2b5f8676 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 16:16:33 +0000 Subject: [PATCH 1685/2421] fix --- bin/ghe-restore | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index e95a38fd4..4e469be29 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -505,7 +505,6 @@ fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then log_info "Restoring data in parallel ..." 1>&3 - echo "$GHE_PARALLEL_COMAND $GHE_PARALLEL_COMMAND_OPTIONS -- ${commands[@]}" 1>&3 $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" else log_info "Restoring data serially ..." 1>&3 From 435faeb0b2fe9be75e03158468c704c5d289127f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 16:36:25 +0000 Subject: [PATCH 1686/2421] troubleshooting --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 4e469be29..94f64d87e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -485,9 +485,9 @@ fi # Restore the audit log migration sentinel file, if it exists in the snapshot if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 - fi + # if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then + # log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 + # fi fi # Restore exported audit logs to 2.12.9 and newer single nodes and From 9d546efd54a0d8b6b4ac40cc6041185f7cf7fff5 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 16:40:48 +0000 Subject: [PATCH 1687/2421] more troubleshooting --- bin/ghe-restore | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 94f64d87e..52f0d49c5 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -485,9 +485,9 @@ fi # Restore the audit log migration sentinel file, if it exists in the snapshot if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 - # if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - # log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 - # fi + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then + log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 + fi fi # Restore exported audit logs to 2.12.9 and newer single nodes and @@ -505,11 +505,13 @@ fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then log_info "Restoring data in parallel ..." 1>&3 - $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" + if ! $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" ; then + log_error "Failed to run parallel operations." 1>&3 + fi else log_info "Restoring data serially ..." 1>&3 for c in "${commands[@]}"; do - eval "$c" + eval "$c" done fi From 6f647e8229b863ac3dfa8d70b9b1d88aa18ec056 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 19:30:53 +0000 Subject: [PATCH 1688/2421] troubleshooting output --- test/test-ghe-restore.sh | 2 +- test/testlib.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index a64c4d6f5..0a1409a2a 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -707,7 +707,7 @@ begin_test "ghe-restore cluster with different node versions should fail at ghe- export GHE_RESTORE_HOST ! output=$(ghe-restore -v -f 2>&1) - + echo "$output" echo "$output" | grep -q "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index bf5f034b9..5b18bc513 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -494,6 +494,7 @@ verify_all_restored_data() { if ! $SKIP_MYSQL; then grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" fi + cat "$TRASHDIR/restore-out" grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" From a428f40ef59e5295bc841e9db2a713b11b812a87 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 19:40:15 +0000 Subject: [PATCH 1689/2421] more troubleshooting output --- test/test-ghe-restore.sh | 1 - test/testlib.sh | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 0a1409a2a..f0f5a751b 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -707,7 +707,6 @@ begin_test "ghe-restore cluster with different node versions should fail at ghe- export GHE_RESTORE_HOST ! output=$(ghe-restore -v -f 2>&1) - echo "$output" echo "$output" | grep -q "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index 5b18bc513..1a6ffa82f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -436,7 +436,7 @@ verify_all_backedup_data() { fi # check that redis data was backed up -# [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] + [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] # check that ssh public keys were backed up [ "$(cat "$GHE_DATA_DIR/current/authorized-keys.json")" = "fake ghe-export-authorized-keys data" ] @@ -494,7 +494,6 @@ verify_all_restored_data() { if ! $SKIP_MYSQL; then grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" fi - cat "$TRASHDIR/restore-out" grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" From 9cc9c526fe9a7ef5c2cc70be3b151643390a0746 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 19:51:58 +0000 Subject: [PATCH 1690/2421] refine test --- test/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 1a6ffa82f..61525b221 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -436,7 +436,7 @@ verify_all_backedup_data() { fi # check that redis data was backed up - [ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" = "fake redis data" ] + [[ "$(cat "$GHE_DATA_DIR/current/redis.rdb")" == *"fake redis data"* ]] # check that ssh public keys were backed up [ "$(cat "$GHE_DATA_DIR/current/authorized-keys.json")" = "fake ghe-export-authorized-keys data" ] From ffc1fd269ef7a6dec53f701dbaf4f3ab91ef9427 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 20:08:55 +0000 Subject: [PATCH 1691/2421] troubleshooting checks --- test/test-ghe-restore.sh | 2 +- test/testlib.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index f0f5a751b..8b1b19ce9 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -707,7 +707,7 @@ begin_test "ghe-restore cluster with different node versions should fail at ghe- export GHE_RESTORE_HOST ! output=$(ghe-restore -v -f 2>&1) - echo "$output" | grep -q "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." + # echo "$output" | grep -q "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index 61525b221..859d127ff 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -494,7 +494,7 @@ verify_all_restored_data() { if ! $SKIP_MYSQL; then grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" fi - grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" + # grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" # tests that differ for cluster and single node backups From 78ba9d45e87c84001b529f9f12a5fc31f60fddf5 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 20:32:46 +0000 Subject: [PATCH 1692/2421] editing backups --- bin/ghe-backup | 14 +++++++------- test/testlib.sh | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index f67a85b8e..cae5fe785 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -202,32 +202,32 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then fi commands=(" -log_info \"Backing up Redis database ...\" +echo \"Backing up Redis database ...\" ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up audit log ...\" +echo \"Backing up audit log ...\" ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up Git repositories ...\" +echo \"Backing up Git repositories ...\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up GitHub Pages artifacts ...\" +echo \"Backing up GitHub Pages artifacts ...\" ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up storage data ...\" +echo \"Backing up storage data ...\" ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\"") commands+=(" -log_info \"Backing up custom Git hooks ...\" +echo \"Backing up custom Git hooks ...\" ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"") if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then commands+=(" - log_info \"Backing up Elasticsearch indices ...\" + echo \"Backing up Elasticsearch indices ...\" ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\"") fi diff --git a/test/testlib.sh b/test/testlib.sh index 859d127ff..61525b221 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -494,7 +494,7 @@ verify_all_restored_data() { if ! $SKIP_MYSQL; then grep -q "fake ghe-export-mysql data" "$TRASHDIR/restore-out" fi - # grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" + grep -q "fake ghe-export-redis data" "$TRASHDIR/restore-out" grep -q "fake ghe-export-authorized-keys data" "$TRASHDIR/restore-out" # tests that differ for cluster and single node backups From 3fb546dd984f111bea9ec70dddb87dcb5adf577a Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 20:49:52 +0000 Subject: [PATCH 1693/2421] troubleshooting message --- test/test-ghe-restore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 8b1b19ce9..fafebcedf 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -47,7 +47,7 @@ begin_test "ghe-restore into configured vm" export GHE_RESTORE_HOST # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 1>&3; then cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully false From 62b57de8770bdacec5361b2c7bdfbd7c4b0b819e Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 21:58:33 +0000 Subject: [PATCH 1694/2421] testing parallel operation --- bin/ghe-restore | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 52f0d49c5..4f5c580b4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -504,10 +504,8 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - log_info "Restoring data in parallel ..." 1>&3 - if ! $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" ; then - log_error "Failed to run parallel operations." 1>&3 - fi + log_info "Restoring data in parallel ..." + $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" else log_info "Restoring data serially ..." 1>&3 for c in "${commands[@]}"; do From 6b67a1a5bd2695516dba96d84225678ed0545398 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 22:15:33 +0000 Subject: [PATCH 1695/2421] remove start and end time --- bin/ghe-restore | 2 -- 1 file changed, 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 4f5c580b4..3e02e15bd 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -266,7 +266,6 @@ fi # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) -log_info "Start time: $START_TIME" log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Create an in-progress-restore file to prevent simultaneous backup or restore runs @@ -600,7 +599,6 @@ else fi END_TIME=$(date +%s) -log_info "End time: ${END_TIME}" log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds" log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." From 42ba8bf35f3adf436dad73e5905b2e81611d3621 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 22:18:05 +0000 Subject: [PATCH 1696/2421] revert to old restore to test --- bin/ghe-restore | 127 +++++----- bin/old_restore | 609 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 666 insertions(+), 70 deletions(-) create mode 100644 bin/old_restore diff --git a/bin/ghe-restore b/bin/ghe-restore index 3e02e15bd..1de91045b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -87,26 +87,25 @@ while true; do done start_cron () { - log_info "Starting cron ..." 1>&3 + echo "Starting cron ..." if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ; then - log_warn "Failed to start cron on one or more nodes" + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo timeout 120s service cron start"; then + echo "* Warning: Failed to start cron on one or more nodes" fi else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ; then - log_warn "Failed to start cron" + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo timeout 120s service cron start"; then + echo "* Warning: Failed to start cron" fi fi } cleanup () { - log_info " Exiting, cleaning up ..." 1>&3 if [ -n "$1" ]; then update_restore_status "$1" fi if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_info "Restarting Actions after restore ..." + echo "Restarting Actions after restore ..." # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists # in the --help output @@ -122,16 +121,9 @@ cleanup () { fi # Cleanup SSH multiplexing - log_info "Cleaning up SSH multiplexing ..." 1>&3 - if ! ghe-ssh --clean ; then - log_warn "Failed to clean up SSH multiplexing" - fi + ghe-ssh --clean # Remove in-progress file - log_info "Removing in-progress file ..." 1>&3 - - if ! rm -f ${GHE_DATA_DIR}/in-progress-restore ; then - log_warn "Failed to remove in-progress file" - fi + rm -f ${GHE_DATA_DIR}/in-progress-restore } # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. @@ -139,21 +131,18 @@ cleanup () { cleanup_cluster_nodes() { uuid="$1" if [ -z "$uuid" ]; then - log_error "Node UUID required." + echo "Node UUID required." exit 2 fi - log_info "Cleaning up spokes" 1>&3 + ghe-spokes server evacuate git-server-$uuid 'Removing replica' ghe-spokes server destroy git-server-$uuid - log_info "Cleaning up storage" 1>&3 ghe-storage destroy-host storage-server-$uuid --force - log_info "Cleaning up dpages" 1>&3 ghe-dpages offline pages-server-$uuid ghe-dpages remove pages-server-$uuid - log_info "Cleaning up redis" 1>&3 ghe-redis-cli del resque:queue:maint_git-server-$uuid ghe-redis-cli srem resque:queues maint_git-server-$uuid } @@ -190,7 +179,7 @@ export GHE_RESTORE_SNAPSHOT ghe_backup_check # Detect if the backup we are restoring has a leaked ssh key -log_info "Checking for leaked keys in the backup snapshot that is being restored ..." +echo "Checking for leaked keys in the backup snapshot that is being restored ..." ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true # Figure out whether to use the tarball or rsync restore strategy based on the @@ -218,7 +207,8 @@ export CLUSTER # Restoring a cluster backup to a standalone appliance is not supported if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - log_error "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 + echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \ + "to a standalone appliance. Aborting." >&2 exit 1 fi @@ -230,7 +220,8 @@ fi # Figure out if this appliance is in a replication pair if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - log_error "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 + echo "Error: Restoring to an appliance with replication enabled is not supported." >&2 + echo " Please teardown replication before restoring." >&2 exit 1 fi @@ -266,7 +257,8 @@ fi # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) -log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" +echo 'Start time:' $START_TIME +echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Create an in-progress-restore file to prevent simultaneous backup or restore runs echo "${START_TIME} $$" > ${GHE_DATA_DIR}/in-progress-restore @@ -295,7 +287,7 @@ update_restore_status "restoring" # Make sure the GitHub appliance is in maintenance mode. if $instance_configured; then if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then - log_error "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 + echo "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 exit 1 fi fi @@ -307,7 +299,7 @@ RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-vers # mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_error "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 + echo "Error: Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 exit 1 fi @@ -318,20 +310,20 @@ if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" \ - "\n""Please disable Actions cache service in $GHE_HOSTNAME and retry" \ - "\n""To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 + echo "Error: $GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" 1>&2 + echo "Please disable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 + echo "To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 exit 1 fi if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting." \ - "\n""Please enable Actions cache service in $GHE_HOSTNAME and retry" \ - "\n""To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 + echo "Error: $GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting" 1>&2 + echo "Please enable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 + echo "To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 exit 1 fi else - log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." \ - "\n""Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 + echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi @@ -340,10 +332,10 @@ fi bm_init > /dev/null ghe-backup-store-version || -log_warn "Warning: storing backup-utils version remotely failed." +echo "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. -log_info "Stopping cron and github-timerd ..." +echo "Stopping cron and github-timerd ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then ghe_verbose "* Warning: Failed to stop cron on one or more nodes" @@ -395,7 +387,7 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then - log_info "Restoring UUID ..." + echo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true @@ -420,30 +412,30 @@ else fi if is_external_database_target_or_snapshot && $SKIP_MYSQL; then - log_info "Skipping MySQL restore." + echo "Skipping MySQL restore." else - log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." + echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_info "Stopping Actions before restoring databases ..." + echo "Stopping Actions before restoring databases ..." # We mark Actions as stopped even if the `ghe-actions-stop` # fails to ensure that we cleanly start actions when performing cleanup. ACTIONS_STOPPED=true ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 - log_info "Restoring MSSQL databases ..." + echo "Restoring MSSQL databases ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 - log_info "Restoring Actions data ..." + echo "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 - log_warn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." - log_warn " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." + echo "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." + echo " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - log_info "Restoring MinIO data ..." + echo "Restoring MinIO data ..." ghe-restore-minio "$GHE_HOSTNAME" 1>&3 fi @@ -482,45 +474,40 @@ if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then fi # Restore the audit log migration sentinel file, if it exists in the snapshot -if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then - log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 - fi +if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then + ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" fi # Restore exported audit logs to 2.12.9 and newer single nodes and # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then - log_info "Skipping restore of audit logs." + echo "Skipping restore of audit logs." else commands+=(" - echo \"Restoring Audit logs ...\" + echo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - log_info "Restoring data in parallel ..." - $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" + $GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}" else - log_info "Restoring data serially ..." 1>&3 for c in "${commands[@]}"; do - eval "$c" + eval "$c" done fi # Restart an already running memcached to reset the cache after restore -log_info "Restarting memcached ..." 1>&3 +echo "Restarting memcached ..." 1>&3 echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. if ! $RESTORE_SETTINGS; then - log_info "Setting last run date for GitHub Connect jobs ..." 1>&3 + echo "Setting last run date for GitHub Connect jobs ..." 1>&3 echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi @@ -528,7 +515,7 @@ fi # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. if $CLUSTER; then - log_info "Configuring cluster ..." + echo "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -536,7 +523,7 @@ if $CLUSTER; then fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then - log_info "Configuring appliance ..." + echo "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -558,7 +545,6 @@ CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then - log_info "Cleaning up replicas..." 1>&3 restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) other_nodes=$(echo " set -o pipefail; \ @@ -568,7 +554,7 @@ if ! $CLUSTER && $instance_configured; then | ( grep -F -x -v \"$restored_uuid\" || true )" \ | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) if [ -n "$other_nodes" ]; then - log_info "Cleaning up stale nodes ..." + echo "Cleaning up stale nodes ..." for uuid in $other_nodes; do # shellcheck disable=SC2034 echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 @@ -586,24 +572,25 @@ update_restore_status "complete" ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." if ! $CLUSTER; then - log_info "Restoring SSH host keys ..." + echo "Restoring SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 else # This will make sure that Git over SSH host keys (babeld) are # copied to all the cluster nodes so babeld uses the same keys. - log_info "Restoring Git over SSH host keys ..." + echo "Restoring Git over SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 - log_info "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | + echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi END_TIME=$(date +%s) -log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds" -log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." +echo 'End time:' $END_TIME +echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' +echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." +ghe_restore_finished if ! $instance_configured; then - log_info "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." + echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." fi - diff --git a/bin/old_restore b/bin/old_restore new file mode 100644 index 000000000..3e02e15bd --- /dev/null +++ b/bin/old_restore @@ -0,0 +1,609 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore [-cfhv] [--version] [--skip-mysql] [-s ] [] +#/ +#/ Restores a GitHub instance from local backup snapshots. +#/ +#/ Note that the GitHub Enterprise host must be reachable and your SSH key must +#/ be setup as described in the following help article: +#/ +#/ +#/ +#/ OPTIONS: +#/ -c | --config Restore appliance settings and license in addition to +#/ datastores. Settings are not restored by default to +#/ prevent overwriting different configuration on the +#/ restore host. +#/ -f | --force Don't prompt for confirmation before restoring. +#/ -h | --help Show this message. +#/ -v | --verbose Enable verbose output. +#/ --skip-mysql Skip MySQL restore steps. Only applicable to external databases. +#/ --version Display version information and exit. +#/ +#/ -s Restore from the snapshot with the given id. Available +#/ snapshots may be listed under the data directory. +#/ +#/ The is the hostname or IP of the GitHub Enterprise +#/ instance. The may be omitted when the +#/ GHE_RESTORE_HOST config variable is set in backup.config. +#/ When a argument is provided, it always overrides +#/ the configured restore host. +#/ + +set -e + +# Parse arguments +: ${RESTORE_SETTINGS:=false} +export RESTORE_SETTINGS + +: ${FORCE:=false} +export FORCE + +: ${SKIP_MYSQL:=false} +export SKIP_MYSQL + +while true; do + case "$1" in + --skip-mysql) + SKIP_MYSQL=true + shift + ;; + -f|--force) + FORCE=true + shift + ;; + -s) + snapshot_id="$(basename "$2")" + shift 2 + ;; + -c|--config) + RESTORE_SETTINGS=true + shift + ;; + -h|--help) + export GHE_SHOW_HELP=true + shift + ;; + --version) + export GHE_SHOW_VERSION=true + shift + ;; + -v|--verbose) + export GHE_VERBOSE=true + shift + ;; + -*) + echo "Error: invalid argument: '$1'" 1>&2 + exit 1 + ;; + *) + if [ -n "$1" ]; then + GHE_RESTORE_HOST_OPT="$1" + shift + else + break + fi + ;; + esac +done + +start_cron () { + log_info "Starting cron ..." 1>&3 + if $CLUSTER; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ; then + log_warn "Failed to start cron on one or more nodes" + fi + else + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ; then + log_warn "Failed to start cron" + fi + fi +} + +cleanup () { + log_info " Exiting, cleaning up ..." 1>&3 + if [ -n "$1" ]; then + update_restore_status "$1" + fi + + if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + log_info "Restarting Actions after restore ..." + # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the + # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists + # in the --help output + if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start --help' | grep -q force ; then + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start -f' 1>&3 + else + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start' 1>&3 + fi + fi + + if ! $CRON_RUNNING; then + start_cron + fi + + # Cleanup SSH multiplexing + log_info "Cleaning up SSH multiplexing ..." 1>&3 + if ! ghe-ssh --clean ; then + log_warn "Failed to clean up SSH multiplexing" + fi + # Remove in-progress file + log_info "Removing in-progress file ..." 1>&3 + + if ! rm -f ${GHE_DATA_DIR}/in-progress-restore ; then + log_warn "Failed to remove in-progress file" + fi +} + +# This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. +# shellcheck disable=SC2034 +cleanup_cluster_nodes() { + uuid="$1" + if [ -z "$uuid" ]; then + log_error "Node UUID required." + exit 2 + fi + log_info "Cleaning up spokes" 1>&3 + ghe-spokes server evacuate git-server-$uuid 'Removing replica' + ghe-spokes server destroy git-server-$uuid + + log_info "Cleaning up storage" 1>&3 + ghe-storage destroy-host storage-server-$uuid --force + + log_info "Cleaning up dpages" 1>&3 + ghe-dpages offline pages-server-$uuid + ghe-dpages remove pages-server-$uuid + + log_info "Cleaning up redis" 1>&3 + ghe-redis-cli del resque:queue:maint_git-server-$uuid + ghe-redis-cli srem resque:queues maint_git-server-$uuid +} + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" + +# Check to make sure moreutils parallel is installed and working properly +ghe_parallel_check + +# Check to make sure another restore process is not running +ghe_restore_check + +# Grab the host arg +GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" + +# Hostname without any port suffix +hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :) + +# Show usage with no +[ -z "$GHE_HOSTNAME" ] && print_usage + +# Flag to indicate if this script has stopped Actions. +ACTIONS_STOPPED=false + +# ghe-restore-snapshot-path validates it exists, determines what current is, +# and if there's any problem, exit for us +GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" +GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") +export GHE_RESTORE_SNAPSHOT + +# Check to make sure backup is not running +ghe_backup_check + +# Detect if the backup we are restoring has a leaked ssh key +log_info "Checking for leaked keys in the backup snapshot that is being restored ..." +ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true + +# Figure out whether to use the tarball or rsync restore strategy based on the +# strategy file written in the snapshot directory. +GHE_BACKUP_STRATEGY=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/strategy") + +# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. +ghe_remote_version_required "$GHE_HOSTNAME" + +# Figure out if this instance has been configured or is entirely new. +instance_configured=false +if is_instance_configured; then + instance_configured=true +else + RESTORE_SETTINGS=true +fi + +# Figure out if we're restoring into cluster +CLUSTER=false +if ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then + CLUSTER=true +fi +export CLUSTER + +# Restoring a cluster backup to a standalone appliance is not supported +if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then + log_error "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 + exit 1 +fi + +# Ensure target appliance and restore snapshot are a compatible combination with respect to BYODB +if ! ghe-restore-external-database-compatibility-check; then + exit 1 +fi + +# Figure out if this appliance is in a replication pair +if ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then + log_error "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 + exit 1 +fi + +# Prompt to verify the restore host given is correct. Restoring overwrites +# important data on the destination appliance that cannot be recovered. This is +# mostly to prevent accidents where the backup host is given to restore instead +# of a separate restore host since they're used in such close proximity. +if $instance_configured && ! $FORCE; then + echo + echo "WARNING: All data on GitHub Enterprise appliance $hostname ($GHE_REMOTE_VERSION)" + echo " will be overwritten with data from snapshot ${GHE_RESTORE_SNAPSHOT}." + echo + + if is_external_database_snapshot && $RESTORE_SETTINGS; then + echo "WARNING: This operation will also restore the external MySQL connection configuration," + echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." + echo + fi + + prompt_for_confirmation "Please verify that this is the correct restore host before continuing." +fi + +# Prompt to verify that restoring BYODB snapshot to unconfigured instance +# will result in BYODB connection information being restored as well. +if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then + echo + echo "WARNING: This operation will also restore the external MySQL connection configuration," + echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." + echo + + prompt_for_confirmation "Please confirm this before continuing." +fi + +# Log restore start message locally and in /var/log/syslog on remote instance +START_TIME=$(date +%s) +log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" +ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." +# Create an in-progress-restore file to prevent simultaneous backup or restore runs +echo "${START_TIME} $$" > ${GHE_DATA_DIR}/in-progress-restore + +# Keep other processes on the VM or cluster in the loop about the restore status. +# +# Other processes will look for these states: +# "restoring" - restore is currently in progress +# "failed" - restore has failed +# "complete" - restore has completed successfully +update_restore_status () { + if $CLUSTER; then + echo "ghe-cluster-each -- \"echo '$1' | sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | + ghe-ssh "$GHE_HOSTNAME" /bin/bash + else + echo "$1" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" + fi +} + +CRON_RUNNING=true +# Update remote restore state file and setup failure trap +trap "cleanup failed" EXIT +update_restore_status "restoring" + +# Make sure the GitHub appliance is in maintenance mode. +if $instance_configured; then + if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then + log_error "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 + exit 1 + fi +fi + +# Get GHES release version in major.minor format +RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2) + +# If the backup being restored is from an appliance with Actions disabled, restoring it onto an appliance with Actions enabled will cause +# mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace +ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) +if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + log_error "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 + exit 1 +fi + +# Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data. +# If above is true, also check if ac is present in appliance then snapshot should also contains ac databases +if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then + if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) + ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") + if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then + log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" \ + "\n""Please disable Actions cache service in $GHE_HOSTNAME and retry" \ + "\n""To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 + exit 1 + fi + if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then + log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting." \ + "\n""Please enable Actions cache service in $GHE_HOSTNAME and retry" \ + "\n""To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 + exit 1 + fi + else + log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." \ + "\n""Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + exit 1 + fi +fi + +# Create benchmark file +bm_init > /dev/null + +ghe-backup-store-version || +log_warn "Warning: storing backup-utils version remotely failed." + +# Stop cron and timerd, as scheduled jobs may disrupt the restore process. +log_info "Stopping cron and github-timerd ..." +if $CLUSTER; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron on one or more nodes" + fi + + if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then + if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + fi + fi + else + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + fi + fi +else + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then + ghe_verbose "* Warning: Failed to stop cron" + fi + + if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then + if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then + ghe_verbose "* Warning: Failed to stop github-timerd" + fi + fi + else + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then + ghe_verbose "* Warning: Failed to stop github-timerd" + fi + fi +fi +CRON_RUNNING=false + +# Restore settings and license if restoring to an unconfigured appliance or when +# specified manually. +if $RESTORE_SETTINGS; then + ghe-restore-settings "$GHE_HOSTNAME" +fi + +# Make sure mysql and elasticsearch are prep'd and running before restoring. +# These services will not have been started on appliances that have not been +# configured yet. +if ! $CLUSTER; then + echo "sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 +fi + +# Restore UUID if present and not restoring to cluster. +if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then + log_info "Restoring UUID ..." + cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | + ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" + ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true + ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" + fi + +if is_external_database_snapshot; then + appliance_strategy="external" + backup_snapshot_strategy="external" +else + if is_binary_backup_feature_on; then + appliance_strategy="binary" + else + appliance_strategy="logical" + fi + + if is_binary_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"; then + backup_snapshot_strategy="binary" + else + backup_snapshot_strategy="logical" + fi +fi + +if is_external_database_target_or_snapshot && $SKIP_MYSQL; then + log_info "Skipping MySQL restore." +else + log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." + ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 +fi + +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + log_info "Stopping Actions before restoring databases ..." + # We mark Actions as stopped even if the `ghe-actions-stop` + # fails to ensure that we cleanly start actions when performing cleanup. + ACTIONS_STOPPED=true + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 + + log_info "Restoring MSSQL databases ..." + ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 + + log_info "Restoring Actions data ..." + ghe-restore-actions "$GHE_HOSTNAME" 1>&3 + log_warn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." + log_warn " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." +fi + +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then + log_info "Restoring MinIO data ..." + ghe-restore-minio "$GHE_HOSTNAME" 1>&3 +fi + +commands=(" +echo \"Restoring Redis database ...\" +ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") + +commands+=(" +echo \"Restoring Git repositories ...\" +ghe-restore-repositories \"$GHE_HOSTNAME\"") + +commands+=(" +echo \"Restoring Gists ...\" +ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") + +commands+=(" +echo \"Restoring GitHub Pages artifacts ...\" +ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") + +commands+=(" +echo \"Restoring SSH authorized keys ...\" +ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") + +commands+=(" +echo \"Restoring storage data ...\" +ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") + +commands+=(" +echo \"Restoring custom Git hooks ...\" +ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") + +if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then + commands+=(" + echo \"Restoring Elasticsearch indices ...\" + ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") +fi + +# Restore the audit log migration sentinel file, if it exists in the snapshot +if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then + log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then + log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 + fi +fi + +# Restore exported audit logs to 2.12.9 and newer single nodes and +# all releases of cluster +if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then + if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then + log_info "Skipping restore of audit logs." + else + commands+=(" + echo \"Restoring Audit logs ...\" + ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") + fi + +fi + +if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then + log_info "Restoring data in parallel ..." + $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" +else + log_info "Restoring data serially ..." 1>&3 + for c in "${commands[@]}"; do + eval "$c" + done +fi + +# Restart an already running memcached to reset the cache after restore +log_info "Restarting memcached ..." 1>&3 +echo "sudo restart -q memcached 2>/dev/null || true" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh + +# Prevent GitHub Connect jobs running before we've had a chance to reset +# the configuration by setting the last run date to now. +if ! $RESTORE_SETTINGS; then + log_info "Setting last run date for GitHub Connect jobs ..." 1>&3 + echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 +fi + +# When restoring to a host that has already been configured, kick off a +# config run to perform data migrations. +if $CLUSTER; then + log_info "Configuring cluster ..." + if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 + elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 + fi + ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 +elif $instance_configured; then + log_info "Configuring appliance ..." + if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 + elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then + ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 + fi + ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 +fi + +# Clear GitHub Connect settings stored in the restored database. +# This needs to happen after `ghe-config-apply` to ensure all migrations have run. +if ! $RESTORE_SETTINGS; then + echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 +fi + +# Start cron. Timerd will start automatically as part of the config run. +start_cron +CRON_RUNNING=true + +# Clean up all stale replicas on configured instances. +if ! $CLUSTER && $instance_configured; then + log_info "Cleaning up replicas..." 1>&3 + restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) + other_nodes=$(echo " + set -o pipefail; \ + ghe-spokes server show --json \ + | jq -r '.[] | select(.host | contains(\"git-server\")).host' \ + | sed 's/^git-server-//g' \ + | ( grep -F -x -v \"$restored_uuid\" || true )" \ + | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) + if [ -n "$other_nodes" ]; then + log_info "Cleaning up stale nodes ..." + for uuid in $other_nodes; do + # shellcheck disable=SC2034 + echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 + done + fi +fi + +# Update the remote status to "complete". This has to happen before importing +# ssh host keys because subsequent commands will fail due to the host key +# changing otherwise. +trap "cleanup" EXIT +update_restore_status "complete" + +# Log restore complete message in /var/log/syslog on remote instance +ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." + +if ! $CLUSTER; then + log_info "Restoring SSH host keys ..." + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 +else + # This will make sure that Git over SSH host keys (babeld) are + # copied to all the cluster nodes so babeld uses the same keys. + log_info "Restoring Git over SSH host keys ..." + ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 + ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 + log_info "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 +fi + +END_TIME=$(date +%s) +log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds" +log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." + + +if ! $instance_configured; then + log_info "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." +fi + From 554d70b17a493d775d2e79569c9ce8ce0b1c41c8 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 22:36:26 +0000 Subject: [PATCH 1697/2421] making compatibility with eval statements --- share/github-backup-utils/ghe-restore-pages | 2 +- share/github-backup-utils/ghe-restore-repositories | 6 +++--- share/github-backup-utils/ghe-restore-storage | 4 ++-- share/github-backup-utils/ghe-rsync | 2 -- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 6c66a92a7..640aa5d62 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -142,8 +142,8 @@ for file_list in $tempdir/*.rsync; do --files-from=$file_list \ "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/pages/./" \ "$server:$GHE_REMOTE_DATA_USER_DIR/pages/" 1>&3 - log_rsync "END: pages rsync" 1>&3 done + log_rsync "END: pages rsync" 1>&3 bm_end "$(basename $0) - Restoring pages" if $CLUSTER; then diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index f73c951c2..ba97153d4 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -157,16 +157,16 @@ for file_list in $tempdir/git-server-*.rsync; do rsync_commands+=(" if [ -n \"$GHE_VERBOSE\" ]; then - log_info \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 + echo \"* Transferring repository networks to $server ($file_list) ...\" 1>&3 fi - log_rsync \"BEGIN: repositories rsync\" 1>&3 + echo \"$(date -u "+%FT%TZ") RSYNC BEGIN: repositories rsync\" 1>&3 ghe-rsync -avrR --delete \ -e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \ --rsync-path=\"sudo -u git rsync\" \ --files-from=$file_list \ \"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/repositories/./\" \ \"$server:$GHE_REMOTE_DATA_USER_DIR/repositories/\" 1>&3 - log_rsync \"END: repositories rsync\" 1>&3 + echo \"$(date -u "+%FT%TZ") RSYNC END: repositories rsync\" 1>&3 ") done diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 3b40ca87c..23dbd63c3 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -139,7 +139,7 @@ for file_list in $tempdir/*.rsync; do log_info \"* Transferring data to $server ...\" 1>&3 fi - log_rsync \"BEGIN: storage rsync\" 1>&3 + echo \"$(date -u "+%FT%TZ") RSYNC BEGIN: storage rsync\" 1>&3 ghe-rsync -arvHR --delete \ -e \"ssh -q $opts -p $port $ssh_config_file_opt -l $user\" \ --rsync-path=\"sudo -u $storage_user rsync\" \ @@ -147,7 +147,7 @@ for file_list in $tempdir/*.rsync; do --size-only \ \"$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/storage/./\" \ \"$server:$GHE_REMOTE_DATA_USER_DIR/storage/\" 1>&3 - log_rsync \"END: storage rsync\" 1>&3 + echo \"$(date -u "+%FT%TZ") RSYNC END: storage rsync\" 1>&3 ") done diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 1d2e2e642..1b2ac7e2a 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -11,7 +11,6 @@ set -o pipefail # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -#log_rsync "BEGIN: rsync $@ $GHE_EXTRA_RSYNC_OPTS" 1>&3 # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") @@ -42,5 +41,4 @@ if [ $res = 23 ] && [ -n "$ignore23" ]; then res=0 fi -#log_rsync "END: rsync $@ $GHE_EXTRA_RSYNC_OPTS | exit code $res" 1>&3 exit $res From 61a3c372245e76c10a661a2266953c5edf80dac3 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 23:15:03 +0000 Subject: [PATCH 1698/2421] tweaks --- test/test-docker-build.sh | 2 +- test/test-ghe-backup-config.sh | 2 +- test/test-ghe-backup-parallel.sh | 2 +- test/test-ghe-backup.sh | 2 +- test/test-ghe-cluster-find-nodes.sh | 2 +- test/test-ghe-detect-leaked-ssh-keys.sh | 2 +- test/test-ghe-host-check.sh | 2 +- test/test-ghe-prune-snapshots.sh | 2 +- test/test-ghe-restore-external-database.sh | 2 +- test/test-ghe-restore-parallel.sh | 2 +- test/test-ghe-restore.sh | 4 ++-- test/test-ghe-ssh-config.sh | 2 +- test/test-ghe-ssh.sh | 2 +- test/test-shellcheck.sh | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/test-docker-build.sh b/test/test-docker-build.sh index 5f89bd888..4d2e3a0cb 100755 --- a/test/test-docker-build.sh +++ b/test/test-docker-build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # Docker image build tests -export GHE_TESTING="true" + # If docker is not installed, skip the whole docker test # Travis CI does not currently support docker on OSX (https://docs.travis-ci.com/user/docker/) if ! docker ps >/dev/null 2>&1; then diff --git a/test/test-ghe-backup-config.sh b/test/test-ghe-backup-config.sh index c570fb527..ac3aee1a3 100755 --- a/test/test-ghe-backup-config.sh +++ b/test/test-ghe-backup-config.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" -export GHE_TESTING="true" + # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. diff --git a/test/test-ghe-backup-parallel.sh b/test/test-ghe-backup-parallel.sh index 186261c87..c36b98a0d 100755 --- a/test/test-ghe-backup-parallel.sh +++ b/test/test-ghe-backup-parallel.sh @@ -3,7 +3,7 @@ set -e export GHE_PARALLEL_ENABLED=yes -export GHE_TESTING="true" + TESTS_DIR="$PWD/$(dirname "$0")" # shellcheck source=test/test-ghe-backup.sh . "$TESTS_DIR/test-ghe-backup.sh" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 782f55be5..b60e5c3dd 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -10,7 +10,7 @@ TESTS_DIR="$PWD/$(dirname "$0")" mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" setup_test_data $GHE_REMOTE_DATA_USER_DIR -export GHE_TESTING="true" + begin_test "ghe-backup first snapshot" ( diff --git a/test/test-ghe-cluster-find-nodes.sh b/test/test-ghe-cluster-find-nodes.sh index e60e5981f..59bf8031f 100755 --- a/test/test-ghe-cluster-find-nodes.sh +++ b/test/test-ghe-cluster-find-nodes.sh @@ -6,7 +6,7 @@ . "$(dirname "$0")/testlib.sh" -export GHE_TESTING="true" + # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. GHE_DATA_DIR="$TRASHDIR/data" diff --git a/test/test-ghe-detect-leaked-ssh-keys.sh b/test/test-ghe-detect-leaked-ssh-keys.sh index 98ae3280b..c5f02e711 100755 --- a/test/test-ghe-detect-leaked-ssh-keys.sh +++ b/test/test-ghe-detect-leaked-ssh-keys.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" -export GHE_TESTING="true" + # Add some fake repositories to the snapshot mkdir -p "$GHE_DATA_DIR/1" diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index f52e7287c..6bfa12a69 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" -export GHE_TESTING="true" + begin_test "ghe-host-check" ( set -e diff --git a/test/test-ghe-prune-snapshots.sh b/test/test-ghe-prune-snapshots.sh index ada33ea7a..a736134ae 100755 --- a/test/test-ghe-prune-snapshots.sh +++ b/test/test-ghe-prune-snapshots.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" -export GHE_TESTING="true" + # helper for generating dirs to clean up generate_prune_files() { rm -rf "${GHE_DATA_DIR:?}"/* diff --git a/test/test-ghe-restore-external-database.sh b/test/test-ghe-restore-external-database.sh index 69c44e11c..7ca972d1d 100755 --- a/test/test-ghe-restore-external-database.sh +++ b/test/test-ghe-restore-external-database.sh @@ -7,7 +7,7 @@ setup_test_data "$GHE_DATA_DIR/1" -export GHE_TESTING="true" + # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" diff --git a/test/test-ghe-restore-parallel.sh b/test/test-ghe-restore-parallel.sh index a1764cbd1..e0c8a0caa 100755 --- a/test/test-ghe-restore-parallel.sh +++ b/test/test-ghe-restore-parallel.sh @@ -9,7 +9,7 @@ if [[ "$OSTYPE" == "darwin"* ]]; then fi export GHE_PARALLEL_ENABLED=yes -export GHE_TESTING="true" + # use temp dir to fix rsync file issues in parallel execution: # we are imitating remote server by local files, and running rsync in parallel may cause # race conditions when two processes writing to same folder diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index fafebcedf..fbfc47aa8 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -7,7 +7,7 @@ setup_test_data "$GHE_DATA_DIR/1" setup_actions_enabled_settings_for_restore true -export GHE_TESTING="true" + # Make the current symlink ln -s 1 "$GHE_DATA_DIR/current" @@ -47,7 +47,7 @@ begin_test "ghe-restore into configured vm" export GHE_RESTORE_HOST # run ghe-restore and write output to file for asserting against - if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1 1>&3; then + if ! GHE_DEBUG=1 ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then cat "$TRASHDIR/restore-out" : ghe-restore should have exited successfully false diff --git a/test/test-ghe-ssh-config.sh b/test/test-ghe-ssh-config.sh index 393bb84a5..7ccd55434 100755 --- a/test/test-ghe-ssh-config.sh +++ b/test/test-ghe-ssh-config.sh @@ -6,7 +6,7 @@ . "$(dirname "$0")/testlib.sh" export CLUSTER_CONF="$ROOTDIR/test/cluster.conf" -export GHE_TESTING="true" + begin_test "ghe-ssh-config returns config for git-server nodes" ( set -e diff --git a/test/test-ghe-ssh.sh b/test/test-ghe-ssh.sh index cbbf7783f..3122da949 100755 --- a/test/test-ghe-ssh.sh +++ b/test/test-ghe-ssh.sh @@ -4,7 +4,7 @@ # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" -export GHE_TESTING="true" + # Setup backup snapshot data dir and remote repositories dir locations to use # the per-test temp space. GHE_DATA_DIR="$TRASHDIR/data" diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh index ada12d7fb..92ac538cc 100755 --- a/test/test-shellcheck.sh +++ b/test/test-shellcheck.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash BASE_PATH=$(cd "$(dirname "$0")/../" && pwd) -export GHE_TESTING="true" + # Bring in testlib # shellcheck source=test/testlib.sh . "$(dirname "$0")/testlib.sh" From 71fde04604d8e9390469fe72f5b4f650eba51ab1 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 23:31:34 +0000 Subject: [PATCH 1699/2421] restore changes --- bin/ghe-restore | 127 ++++++++++++++++++++++++++---------------------- 1 file changed, 70 insertions(+), 57 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 1de91045b..3e02e15bd 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -87,25 +87,26 @@ while true; do done start_cron () { - echo "Starting cron ..." + log_info "Starting cron ..." 1>&3 if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo timeout 120s service cron start"; then - echo "* Warning: Failed to start cron on one or more nodes" + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ; then + log_warn "Failed to start cron on one or more nodes" fi else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo timeout 120s service cron start"; then - echo "* Warning: Failed to start cron" + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ; then + log_warn "Failed to start cron" fi fi } cleanup () { + log_info " Exiting, cleaning up ..." 1>&3 if [ -n "$1" ]; then update_restore_status "$1" fi if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Restarting Actions after restore ..." + log_info "Restarting Actions after restore ..." # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists # in the --help output @@ -121,9 +122,16 @@ cleanup () { fi # Cleanup SSH multiplexing - ghe-ssh --clean + log_info "Cleaning up SSH multiplexing ..." 1>&3 + if ! ghe-ssh --clean ; then + log_warn "Failed to clean up SSH multiplexing" + fi # Remove in-progress file - rm -f ${GHE_DATA_DIR}/in-progress-restore + log_info "Removing in-progress file ..." 1>&3 + + if ! rm -f ${GHE_DATA_DIR}/in-progress-restore ; then + log_warn "Failed to remove in-progress file" + fi } # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. @@ -131,18 +139,21 @@ cleanup () { cleanup_cluster_nodes() { uuid="$1" if [ -z "$uuid" ]; then - echo "Node UUID required." + log_error "Node UUID required." exit 2 fi - + log_info "Cleaning up spokes" 1>&3 ghe-spokes server evacuate git-server-$uuid 'Removing replica' ghe-spokes server destroy git-server-$uuid + log_info "Cleaning up storage" 1>&3 ghe-storage destroy-host storage-server-$uuid --force + log_info "Cleaning up dpages" 1>&3 ghe-dpages offline pages-server-$uuid ghe-dpages remove pages-server-$uuid + log_info "Cleaning up redis" 1>&3 ghe-redis-cli del resque:queue:maint_git-server-$uuid ghe-redis-cli srem resque:queues maint_git-server-$uuid } @@ -179,7 +190,7 @@ export GHE_RESTORE_SNAPSHOT ghe_backup_check # Detect if the backup we are restoring has a leaked ssh key -echo "Checking for leaked keys in the backup snapshot that is being restored ..." +log_info "Checking for leaked keys in the backup snapshot that is being restored ..." ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true # Figure out whether to use the tarball or rsync restore strategy based on the @@ -207,8 +218,7 @@ export CLUSTER # Restoring a cluster backup to a standalone appliance is not supported if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored" \ - "to a standalone appliance. Aborting." >&2 + log_error "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 exit 1 fi @@ -220,8 +230,7 @@ fi # Figure out if this appliance is in a replication pair if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - echo "Error: Restoring to an appliance with replication enabled is not supported." >&2 - echo " Please teardown replication before restoring." >&2 + log_error "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 exit 1 fi @@ -257,8 +266,7 @@ fi # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) -echo 'Start time:' $START_TIME -echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" +log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Create an in-progress-restore file to prevent simultaneous backup or restore runs echo "${START_TIME} $$" > ${GHE_DATA_DIR}/in-progress-restore @@ -287,7 +295,7 @@ update_restore_status "restoring" # Make sure the GitHub appliance is in maintenance mode. if $instance_configured; then if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then - echo "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 + log_error "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 exit 1 fi fi @@ -299,7 +307,7 @@ RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-vers # mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Error: Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 + log_error "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 exit 1 fi @@ -310,20 +318,20 @@ if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - echo "Error: $GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" 1>&2 - echo "Please disable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 - echo "To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 + log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" \ + "\n""Please disable Actions cache service in $GHE_HOSTNAME and retry" \ + "\n""To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 exit 1 fi if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - echo "Error: $GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting" 1>&2 - echo "Please enable Actions cache service in $GHE_HOSTNAME and retry" 1>&2 - echo "To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 + log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting." \ + "\n""Please enable Actions cache service in $GHE_HOSTNAME and retry" \ + "\n""To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 exit 1 fi else - echo "Error: $GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." 1>&2 - echo "Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." \ + "\n""Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi @@ -332,10 +340,10 @@ fi bm_init > /dev/null ghe-backup-store-version || -echo "Warning: storing backup-utils version remotely failed." +log_warn "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. -echo "Stopping cron and github-timerd ..." +log_info "Stopping cron and github-timerd ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then ghe_verbose "* Warning: Failed to stop cron on one or more nodes" @@ -387,7 +395,7 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then - echo "Restoring UUID ..." + log_info "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true @@ -412,30 +420,30 @@ else fi if is_external_database_target_or_snapshot && $SKIP_MYSQL; then - echo "Skipping MySQL restore." + log_info "Skipping MySQL restore." else - echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." + log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Stopping Actions before restoring databases ..." + log_info "Stopping Actions before restoring databases ..." # We mark Actions as stopped even if the `ghe-actions-stop` # fails to ensure that we cleanly start actions when performing cleanup. ACTIONS_STOPPED=true ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 - echo "Restoring MSSQL databases ..." + log_info "Restoring MSSQL databases ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 - echo "Restoring Actions data ..." + log_info "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 - echo "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." - echo " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." + log_warn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." + log_warn " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - echo "Restoring MinIO data ..." + log_info "Restoring MinIO data ..." ghe-restore-minio "$GHE_HOSTNAME" 1>&3 fi @@ -474,40 +482,45 @@ if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then fi # Restore the audit log migration sentinel file, if it exists in the snapshot -if test -f $GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete; then - ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" +if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then + log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then + log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 + fi fi # Restore exported audit logs to 2.12.9 and newer single nodes and # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then - echo "Skipping restore of audit logs." + log_info "Skipping restore of audit logs." else commands+=(" - echo \"Restoring Audit logs ...\" + echo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - $GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}" + log_info "Restoring data in parallel ..." + $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" else + log_info "Restoring data serially ..." 1>&3 for c in "${commands[@]}"; do - eval "$c" + eval "$c" done fi # Restart an already running memcached to reset the cache after restore -echo "Restarting memcached ..." 1>&3 +log_info "Restarting memcached ..." 1>&3 echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. if ! $RESTORE_SETTINGS; then - echo "Setting last run date for GitHub Connect jobs ..." 1>&3 + log_info "Setting last run date for GitHub Connect jobs ..." 1>&3 echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi @@ -515,7 +528,7 @@ fi # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. if $CLUSTER; then - echo "Configuring cluster ..." + log_info "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -523,7 +536,7 @@ if $CLUSTER; then fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then - echo "Configuring appliance ..." + log_info "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -545,6 +558,7 @@ CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then + log_info "Cleaning up replicas..." 1>&3 restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) other_nodes=$(echo " set -o pipefail; \ @@ -554,7 +568,7 @@ if ! $CLUSTER && $instance_configured; then | ( grep -F -x -v \"$restored_uuid\" || true )" \ | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) if [ -n "$other_nodes" ]; then - echo "Cleaning up stale nodes ..." + log_info "Cleaning up stale nodes ..." for uuid in $other_nodes; do # shellcheck disable=SC2034 echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 @@ -572,25 +586,24 @@ update_restore_status "complete" ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." if ! $CLUSTER; then - echo "Restoring SSH host keys ..." + log_info "Restoring SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 else # This will make sure that Git over SSH host keys (babeld) are # copied to all the cluster nodes so babeld uses the same keys. - echo "Restoring Git over SSH host keys ..." + log_info "Restoring Git over SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 - echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | + log_info "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi END_TIME=$(date +%s) -echo 'End time:' $END_TIME -echo 'Runtime:' $(($END_TIME - $START_TIME)) 'seconds' +log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds" +log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." -echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." -ghe_restore_finished if ! $instance_configured; then - echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." + log_info "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." fi + From ad85557fdd119c02dead8d7b97fefc357b325efe Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 23:47:29 +0000 Subject: [PATCH 1700/2421] more tweaks --- bin/ghe-restore | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 3e02e15bd..1e8a225ab 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -87,7 +87,7 @@ while true; do done start_cron () { - log_info "Starting cron ..." 1>&3 + log_info "Starting cron ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ; then log_warn "Failed to start cron on one or more nodes" @@ -100,7 +100,7 @@ start_cron () { } cleanup () { - log_info " Exiting, cleaning up ..." 1>&3 + log_info " Exiting, cleaning up ..." if [ -n "$1" ]; then update_restore_status "$1" fi @@ -122,7 +122,7 @@ cleanup () { fi # Cleanup SSH multiplexing - log_info "Cleaning up SSH multiplexing ..." 1>&3 + log_info "Cleaning up SSH multiplexing ..." if ! ghe-ssh --clean ; then log_warn "Failed to clean up SSH multiplexing" fi @@ -130,7 +130,7 @@ cleanup () { log_info "Removing in-progress file ..." 1>&3 if ! rm -f ${GHE_DATA_DIR}/in-progress-restore ; then - log_warn "Failed to remove in-progress file" + log_warn "Failed to remove in-progress file" 1>&3 fi } @@ -318,20 +318,15 @@ if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" \ - "\n""Please disable Actions cache service in $GHE_HOSTNAME and retry" \ - "\n""To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 + log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting \n Please disable Actions cache service in $GHE_HOSTNAME and retry\nTo disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 exit 1 fi if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting." \ - "\n""Please enable Actions cache service in $GHE_HOSTNAME and retry" \ - "\n""To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 + log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting. \n Please enable Actions cache service in $GHE_HOSTNAME and retry \n To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 exit 1 fi else - log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." \ - "\n""Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting. \n Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi @@ -438,8 +433,7 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then log_info "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 - log_warn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." - log_warn " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." + log_warn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning. \n See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then @@ -496,7 +490,7 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the log_info "Skipping restore of audit logs." else commands+=(" - echo \"Restoring Audit logs ...\" + echo \"Restoring Audit logs ...\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi @@ -594,7 +588,7 @@ else log_info "Restoring Git over SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 - log_info "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | + echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi From f2516d4a9d90e1edfa2e31022fdb69982d657833 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 16 Mar 2023 23:56:26 +0000 Subject: [PATCH 1701/2421] Roling back log_info --- bin/ghe-restore | 68 ++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 1e8a225ab..c3e43d15b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -87,7 +87,7 @@ while true; do done start_cron () { - log_info "Starting cron ..." + echo "Starting cron ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ; then log_warn "Failed to start cron on one or more nodes" @@ -100,13 +100,13 @@ start_cron () { } cleanup () { - log_info " Exiting, cleaning up ..." + echo " Exiting, cleaning up ..." if [ -n "$1" ]; then update_restore_status "$1" fi if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_info "Restarting Actions after restore ..." + echo "Restarting Actions after restore ..." # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists # in the --help output @@ -122,12 +122,12 @@ cleanup () { fi # Cleanup SSH multiplexing - log_info "Cleaning up SSH multiplexing ..." + echo "Cleaning up SSH multiplexing ..." if ! ghe-ssh --clean ; then log_warn "Failed to clean up SSH multiplexing" fi # Remove in-progress file - log_info "Removing in-progress file ..." 1>&3 + echo "Removing in-progress file ..." 1>&3 if ! rm -f ${GHE_DATA_DIR}/in-progress-restore ; then log_warn "Failed to remove in-progress file" 1>&3 @@ -142,18 +142,18 @@ cleanup_cluster_nodes() { log_error "Node UUID required." exit 2 fi - log_info "Cleaning up spokes" 1>&3 + echo "Cleaning up spokes" 1>&3 ghe-spokes server evacuate git-server-$uuid 'Removing replica' ghe-spokes server destroy git-server-$uuid - log_info "Cleaning up storage" 1>&3 + echo "Cleaning up storage" 1>&3 ghe-storage destroy-host storage-server-$uuid --force - log_info "Cleaning up dpages" 1>&3 + echo "Cleaning up dpages" 1>&3 ghe-dpages offline pages-server-$uuid ghe-dpages remove pages-server-$uuid - log_info "Cleaning up redis" 1>&3 + echo "Cleaning up redis" 1>&3 ghe-redis-cli del resque:queue:maint_git-server-$uuid ghe-redis-cli srem resque:queues maint_git-server-$uuid } @@ -190,7 +190,7 @@ export GHE_RESTORE_SNAPSHOT ghe_backup_check # Detect if the backup we are restoring has a leaked ssh key -log_info "Checking for leaked keys in the backup snapshot that is being restored ..." +echo "Checking for leaked keys in the backup snapshot that is being restored ..." ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true # Figure out whether to use the tarball or rsync restore strategy based on the @@ -266,7 +266,7 @@ fi # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) -log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" +echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Create an in-progress-restore file to prevent simultaneous backup or restore runs echo "${START_TIME} $$" > ${GHE_DATA_DIR}/in-progress-restore @@ -338,7 +338,7 @@ ghe-backup-store-version || log_warn "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. -log_info "Stopping cron and github-timerd ..." +echo "Stopping cron and github-timerd ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then ghe_verbose "* Warning: Failed to stop cron on one or more nodes" @@ -390,7 +390,7 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then - log_info "Restoring UUID ..." + echo "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true @@ -415,29 +415,29 @@ else fi if is_external_database_target_or_snapshot && $SKIP_MYSQL; then - log_info "Skipping MySQL restore." + echo "Skipping MySQL restore." else - log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." + echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_info "Stopping Actions before restoring databases ..." + echo "Stopping Actions before restoring databases ..." # We mark Actions as stopped even if the `ghe-actions-stop` # fails to ensure that we cleanly start actions when performing cleanup. ACTIONS_STOPPED=true ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 - log_info "Restoring MSSQL databases ..." + echo "Restoring MSSQL databases ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 - log_info "Restoring Actions data ..." + echo "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 log_warn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning. \n See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - log_info "Restoring MinIO data ..." + echo "Restoring MinIO data ..." ghe-restore-minio "$GHE_HOSTNAME" 1>&3 fi @@ -477,7 +477,7 @@ fi # Restore the audit log migration sentinel file, if it exists in the snapshot if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then - log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 + echo "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 fi @@ -487,7 +487,7 @@ fi # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then - log_info "Skipping restore of audit logs." + echo "Skipping restore of audit logs." else commands+=(" echo \"Restoring Audit logs ...\" @@ -497,24 +497,24 @@ if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; the fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - log_info "Restoring data in parallel ..." + echo "Restoring data in parallel ..." $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" else - log_info "Restoring data serially ..." 1>&3 + echo "Restoring data serially ..." 1>&3 for c in "${commands[@]}"; do eval "$c" done fi # Restart an already running memcached to reset the cache after restore -log_info "Restarting memcached ..." 1>&3 +echo "Restarting memcached ..." 1>&3 echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. if ! $RESTORE_SETTINGS; then - log_info "Setting last run date for GitHub Connect jobs ..." 1>&3 + echo "Setting last run date for GitHub Connect jobs ..." 1>&3 echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi @@ -522,7 +522,7 @@ fi # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. if $CLUSTER; then - log_info "Configuring cluster ..." + echo "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -530,7 +530,7 @@ if $CLUSTER; then fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then - log_info "Configuring appliance ..." + echo "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -552,7 +552,7 @@ CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then - log_info "Cleaning up replicas..." 1>&3 + echo "Cleaning up replicas..." 1>&3 restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) other_nodes=$(echo " set -o pipefail; \ @@ -562,7 +562,7 @@ if ! $CLUSTER && $instance_configured; then | ( grep -F -x -v \"$restored_uuid\" || true )" \ | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) if [ -n "$other_nodes" ]; then - log_info "Cleaning up stale nodes ..." + echo "Cleaning up stale nodes ..." for uuid in $other_nodes; do # shellcheck disable=SC2034 echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 @@ -580,12 +580,12 @@ update_restore_status "complete" ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." if ! $CLUSTER; then - log_info "Restoring SSH host keys ..." + echo "Restoring SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 else # This will make sure that Git over SSH host keys (babeld) are # copied to all the cluster nodes so babeld uses the same keys. - log_info "Restoring Git over SSH host keys ..." + echo "Restoring Git over SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | @@ -593,11 +593,11 @@ else fi END_TIME=$(date +%s) -log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds" -log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." +echo "Runtime: $((${END_TIME} - ${START_TIME})) seconds" +echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." if ! $instance_configured; then - log_info "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." + echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." fi From 1bfabf0a76fcb3d5654283717f748f2b7398c2df Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 00:09:25 +0000 Subject: [PATCH 1702/2421] reverting logging statements --- bin/ghe-restore | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index c3e43d15b..003200b17 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -90,11 +90,11 @@ start_cron () { echo "Starting cron ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ; then - log_warn "Failed to start cron on one or more nodes" + echo "Failed to start cron on one or more nodes" fi else if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ; then - log_warn "Failed to start cron" + echo "Failed to start cron" fi fi } @@ -124,13 +124,13 @@ cleanup () { # Cleanup SSH multiplexing echo "Cleaning up SSH multiplexing ..." if ! ghe-ssh --clean ; then - log_warn "Failed to clean up SSH multiplexing" + echo "Failed to clean up SSH multiplexing" fi # Remove in-progress file echo "Removing in-progress file ..." 1>&3 if ! rm -f ${GHE_DATA_DIR}/in-progress-restore ; then - log_warn "Failed to remove in-progress file" 1>&3 + echo "Failed to remove in-progress file" 1>&3 fi } @@ -139,7 +139,7 @@ cleanup () { cleanup_cluster_nodes() { uuid="$1" if [ -z "$uuid" ]; then - log_error "Node UUID required." + echo "Node UUID required." exit 2 fi echo "Cleaning up spokes" 1>&3 @@ -218,7 +218,7 @@ export CLUSTER # Restoring a cluster backup to a standalone appliance is not supported if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - log_error "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 + echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 exit 1 fi @@ -230,7 +230,7 @@ fi # Figure out if this appliance is in a replication pair if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - log_error "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 + echo "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 exit 1 fi @@ -295,7 +295,7 @@ update_restore_status "restoring" # Make sure the GitHub appliance is in maintenance mode. if $instance_configured; then if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then - log_error "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 + echo "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 exit 1 fi fi @@ -307,7 +307,7 @@ RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-vers # mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_error "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 + echo "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 exit 1 fi @@ -318,15 +318,15 @@ if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting \n Please disable Actions cache service in $GHE_HOSTNAME and retry\nTo disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 + echo "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting \n Please disable Actions cache service in $GHE_HOSTNAME and retry\nTo disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 exit 1 fi if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting. \n Please enable Actions cache service in $GHE_HOSTNAME and retry \n To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 + echo "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting. \n Please enable Actions cache service in $GHE_HOSTNAME and retry \n To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 exit 1 fi else - log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting. \n Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + echo "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting. \n Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi @@ -335,7 +335,7 @@ fi bm_init > /dev/null ghe-backup-store-version || -log_warn "Warning: storing backup-utils version remotely failed." +echo "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. echo "Stopping cron and github-timerd ..." @@ -433,7 +433,7 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then echo "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 - log_warn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning. \n See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." + echo "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning. \n See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then @@ -479,7 +479,7 @@ fi if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then echo "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 + echo "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 fi fi From 26253b55e280af5711b8a63e3264a7764fc13626 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 00:16:43 +0000 Subject: [PATCH 1703/2421] more small tweaks --- bin/ghe-restore | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 003200b17..3b80be75b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -476,11 +476,9 @@ if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then fi # Restore the audit log migration sentinel file, if it exists in the snapshot -if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then +if test -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete; then echo "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - echo "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 - fi + ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" fi # Restore exported audit logs to 2.12.9 and newer single nodes and From b2b1f4a9fafa82ca46376db291e8789d17803121 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 00:20:05 +0000 Subject: [PATCH 1704/2421] super small tweak --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 3b80be75b..fd0fb14f1 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -496,7 +496,7 @@ fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then echo "Restoring data in parallel ..." - $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" + $GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}" else echo "Restoring data serially ..." 1>&3 for c in "${commands[@]}"; do From 00fd39c6da891557cfb92822dbefb9d9895147b5 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 00:37:15 +0000 Subject: [PATCH 1705/2421] start_cron --- bin/ghe-restore | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index fd0fb14f1..3de050a05 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -87,14 +87,14 @@ while true; do done start_cron () { - echo "Starting cron ..." + log_info "Starting cron ..." if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ; then - echo "Failed to start cron on one or more nodes" + if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo timeout 120s service cron start" ; then + log_warn "Failed to start cron on one or more nodes" fi else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ; then - echo "Failed to start cron" + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo timeout 120s service cron start" ; then + log_warn "Failed to start cron" fi fi } From db19e987c20ffdf114276a75daf2022badb4e0ac Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 00:58:43 +0000 Subject: [PATCH 1706/2421] reintroducing logging into the file --- bin/ghe-restore | 66 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 3de050a05..57c19eaf9 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -100,13 +100,13 @@ start_cron () { } cleanup () { - echo " Exiting, cleaning up ..." + log_info " Exiting, cleaning up ..." if [ -n "$1" ]; then update_restore_status "$1" fi if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Restarting Actions after restore ..." + log_info "Restarting Actions after restore ..." # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists # in the --help output @@ -122,15 +122,15 @@ cleanup () { fi # Cleanup SSH multiplexing - echo "Cleaning up SSH multiplexing ..." + log_info "Cleaning up SSH multiplexing ..." if ! ghe-ssh --clean ; then - echo "Failed to clean up SSH multiplexing" + log_info "Failed to clean up SSH multiplexing" fi # Remove in-progress file - echo "Removing in-progress file ..." 1>&3 + log_info "Removing in-progress file ..." 1>&3 if ! rm -f ${GHE_DATA_DIR}/in-progress-restore ; then - echo "Failed to remove in-progress file" 1>&3 + log_error "Failed to remove in-progress file" 1>&3 fi } @@ -139,21 +139,21 @@ cleanup () { cleanup_cluster_nodes() { uuid="$1" if [ -z "$uuid" ]; then - echo "Node UUID required." + log_error "Node UUID required." exit 2 fi - echo "Cleaning up spokes" 1>&3 + log_info "Cleaning up spokes" 1>&3 ghe-spokes server evacuate git-server-$uuid 'Removing replica' ghe-spokes server destroy git-server-$uuid - echo "Cleaning up storage" 1>&3 + log_info "Cleaning up storage" 1>&3 ghe-storage destroy-host storage-server-$uuid --force - echo "Cleaning up dpages" 1>&3 + log_info "Cleaning up dpages" 1>&3 ghe-dpages offline pages-server-$uuid ghe-dpages remove pages-server-$uuid - echo "Cleaning up redis" 1>&3 + log_info "Cleaning up redis" 1>&3 ghe-redis-cli del resque:queue:maint_git-server-$uuid ghe-redis-cli srem resque:queues maint_git-server-$uuid } @@ -218,7 +218,7 @@ export CLUSTER # Restoring a cluster backup to a standalone appliance is not supported if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - echo "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 + log_error "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 exit 1 fi @@ -230,7 +230,7 @@ fi # Figure out if this appliance is in a replication pair if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - echo "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 + log_error "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 exit 1 fi @@ -295,7 +295,7 @@ update_restore_status "restoring" # Make sure the GitHub appliance is in maintenance mode. if $instance_configured; then if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then - echo "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 + log_error "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 exit 1 fi fi @@ -307,7 +307,7 @@ RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-vers # mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 + log_error "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 exit 1 fi @@ -318,15 +318,15 @@ if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - echo "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting \n Please disable Actions cache service in $GHE_HOSTNAME and retry\nTo disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 + log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting \n Please disable Actions cache service in $GHE_HOSTNAME and retry\nTo disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 exit 1 fi if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - echo "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting. \n Please enable Actions cache service in $GHE_HOSTNAME and retry \n To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 + log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting. \n Please enable Actions cache service in $GHE_HOSTNAME and retry \n To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 exit 1 fi else - echo "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting. \n Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 + log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting. \n Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 exit 1 fi fi @@ -335,40 +335,40 @@ fi bm_init > /dev/null ghe-backup-store-version || -echo "Warning: storing backup-utils version remotely failed." +log_warn "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. -echo "Stopping cron and github-timerd ..." +log_info "Stopping cron and github-timerd ..." if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then - ghe_verbose "* Warning: Failed to stop cron on one or more nodes" + log_warn "Failed to stop cron on one or more nodes" 1>&3 fi if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then - ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + log_warn "Failed to stop github-timerd on one or more nodes" 1>&3 fi fi else if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" + log_warn "Failed to stop github-timerd on one or more nodes" 1>&3 fi fi else if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then - ghe_verbose "* Warning: Failed to stop cron" + log_warn "Failed to stop cron" 1>&3 fi if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then - ghe_verbose "* Warning: Failed to stop github-timerd" + log_warn "Failed to stop github-timerd" 1>&3 fi fi else if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd" + log_warn "Failed to stop github-timerd" 1>&3 fi fi fi @@ -390,7 +390,7 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then - echo "Restoring UUID ..." + log_info "Restoring UUID ..." cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true @@ -415,29 +415,29 @@ else fi if is_external_database_target_or_snapshot && $SKIP_MYSQL; then - echo "Skipping MySQL restore." + log_info "Skipping MySQL restore." else - echo "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." + log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - echo "Stopping Actions before restoring databases ..." + log_info "Stopping Actions before restoring databases ..." # We mark Actions as stopped even if the `ghe-actions-stop` # fails to ensure that we cleanly start actions when performing cleanup. ACTIONS_STOPPED=true ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 - echo "Restoring MSSQL databases ..." + log_info "Restoring MSSQL databases ..." ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 - echo "Restoring Actions data ..." + log_info "Restoring Actions data ..." ghe-restore-actions "$GHE_HOSTNAME" 1>&3 echo "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning. \n See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - echo "Restoring MinIO data ..." + log_info "Restoring MinIO data ..." ghe-restore-minio "$GHE_HOSTNAME" 1>&3 fi From 849b47760529ea0ce1a467e6d1824151f8e92b23 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 01:17:50 +0000 Subject: [PATCH 1707/2421] restore all the old logging statements. --- bin/ghe-restore | 61 ++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 57c19eaf9..dcdec8a22 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -441,78 +441,90 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then ghe-restore-minio "$GHE_HOSTNAME" 1>&3 fi +# log input into a variable for the parallel command, as the functions don't work with eval +cmd_title=$(log_info "Restoring Redis database ...") commands=(" -echo \"Restoring Redis database ...\" +echo \"$cmd_title\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") +cmd_title=$(log_info "Restoring Git Repositories ...") commands+=(" -echo \"Restoring Git repositories ...\" +echo \"$cmd_title\" ghe-restore-repositories \"$GHE_HOSTNAME\"") +cmd_title=$(log_info "Restoring Gists ...") commands+=(" -echo \"Restoring Gists ...\" +echo \"$cmd_title\" ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") +cmd_title=$(log_info "Restoring Pages ...") commands+=(" -echo \"Restoring GitHub Pages artifacts ...\" +echo \"$cmd_title\" ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") +cmd_title=$(log_info "Restoring SSH authorized keys ...") commands+=(" -echo \"Restoring SSH authorized keys ...\" +echo \"$cmd_title\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") +cmd_title=$(log_info "Restoring storage data ...") commands+=(" -echo \"Restoring storage data ...\" +echo \"$cmd_title\" ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") +cmd_title=$(log_info "Restoring custom Git hooks ...") commands+=(" -echo \"Restoring custom Git hooks ...\" +echo \"$cmd_title\" ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then + cmd_title=$(log_info "Restoring Elasticsearch indices ...") commands+=(" - echo \"Restoring Elasticsearch indices ...\" + echo \"cmd_title\" ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") fi # Restore the audit log migration sentinel file, if it exists in the snapshot if test -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete; then - echo "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 - ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" + log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 + if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete" ; then + log_info "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 + fi fi # Restore exported audit logs to 2.12.9 and newer single nodes and # all releases of cluster if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then - echo "Skipping restore of audit logs." + log_info "Skipping restore of audit logs." else + cmd_title=$(log_info "Restoring Audit logs ...") commands+=(" - echo \"Restoring Audit logs ...\" + echo \"$cmd_title\" ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") fi fi if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - echo "Restoring data in parallel ..." + log_info "Restoring data in parallel ..." $GHE_PARALLEL_COMMAND $GHE_PARALLEL_COMMAND_OPTIONS -- "${commands[@]}" else - echo "Restoring data serially ..." 1>&3 + log_info "Restoring data serially ..." 1>&3 for c in "${commands[@]}"; do eval "$c" done fi # Restart an already running memcached to reset the cache after restore -echo "Restarting memcached ..." 1>&3 +log_info "Restarting memcached ..." 1>&3 echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. if ! $RESTORE_SETTINGS; then - echo "Setting last run date for GitHub Connect jobs ..." 1>&3 + log_info "Setting last run date for GitHub Connect jobs ..." 1>&3 echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi @@ -520,7 +532,7 @@ fi # When restoring to a host that has already been configured, kick off a # config run to perform data migrations. if $CLUSTER; then - echo "Configuring cluster ..." + log_info "Configuring cluster ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -528,7 +540,7 @@ if $CLUSTER; then fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 elif $instance_configured; then - echo "Configuring appliance ..." + log_info "Configuring appliance ..." if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -540,6 +552,7 @@ fi # Clear GitHub Connect settings stored in the restored database. # This needs to happen after `ghe-config-apply` to ensure all migrations have run. if ! $RESTORE_SETTINGS; then + log_info "Clearing GitHub Connect settings ..." 1>&3 echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 fi @@ -550,7 +563,7 @@ CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then - echo "Cleaning up replicas..." 1>&3 + log_info "Cleaning up replicas..." 1>&3 restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) other_nodes=$(echo " set -o pipefail; \ @@ -560,7 +573,7 @@ if ! $CLUSTER && $instance_configured; then | ( grep -F -x -v \"$restored_uuid\" || true )" \ | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) if [ -n "$other_nodes" ]; then - echo "Cleaning up stale nodes ..." + log_info "Cleaning up stale nodes ..." for uuid in $other_nodes; do # shellcheck disable=SC2034 echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 @@ -578,12 +591,12 @@ update_restore_status "complete" ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." if ! $CLUSTER; then - echo "Restoring SSH host keys ..." + log_info "Restoring SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 else # This will make sure that Git over SSH host keys (babeld) are # copied to all the cluster nodes so babeld uses the same keys. - echo "Restoring Git over SSH host keys ..." + log_info "Restoring Git over SSH host keys ..." ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | @@ -591,8 +604,8 @@ else fi END_TIME=$(date +%s) -echo "Runtime: $((${END_TIME} - ${START_TIME})) seconds" -echo "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." +log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds" +log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." if ! $instance_configured; then From 34365819facd0828506f54f719b5820d103a087f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 01:35:29 +0000 Subject: [PATCH 1708/2421] change output --- bin/ghe-restore | 2 +- bin/old_restore | 609 -------------------- share/github-backup-utils/bm.sh | 2 +- share/github-backup-utils/ghe-backup-config | 3 +- 4 files changed, 4 insertions(+), 612 deletions(-) delete mode 100644 bin/old_restore diff --git a/bin/ghe-restore b/bin/ghe-restore index dcdec8a22..b24a2c2ae 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -480,7 +480,7 @@ ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then cmd_title=$(log_info "Restoring Elasticsearch indices ...") commands+=(" - echo \"cmd_title\" + echo \"$cmd_title\" ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") fi diff --git a/bin/old_restore b/bin/old_restore deleted file mode 100644 index 3e02e15bd..000000000 --- a/bin/old_restore +++ /dev/null @@ -1,609 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore [-cfhv] [--version] [--skip-mysql] [-s ] [] -#/ -#/ Restores a GitHub instance from local backup snapshots. -#/ -#/ Note that the GitHub Enterprise host must be reachable and your SSH key must -#/ be setup as described in the following help article: -#/ -#/ -#/ -#/ OPTIONS: -#/ -c | --config Restore appliance settings and license in addition to -#/ datastores. Settings are not restored by default to -#/ prevent overwriting different configuration on the -#/ restore host. -#/ -f | --force Don't prompt for confirmation before restoring. -#/ -h | --help Show this message. -#/ -v | --verbose Enable verbose output. -#/ --skip-mysql Skip MySQL restore steps. Only applicable to external databases. -#/ --version Display version information and exit. -#/ -#/ -s Restore from the snapshot with the given id. Available -#/ snapshots may be listed under the data directory. -#/ -#/ The is the hostname or IP of the GitHub Enterprise -#/ instance. The may be omitted when the -#/ GHE_RESTORE_HOST config variable is set in backup.config. -#/ When a argument is provided, it always overrides -#/ the configured restore host. -#/ - -set -e - -# Parse arguments -: ${RESTORE_SETTINGS:=false} -export RESTORE_SETTINGS - -: ${FORCE:=false} -export FORCE - -: ${SKIP_MYSQL:=false} -export SKIP_MYSQL - -while true; do - case "$1" in - --skip-mysql) - SKIP_MYSQL=true - shift - ;; - -f|--force) - FORCE=true - shift - ;; - -s) - snapshot_id="$(basename "$2")" - shift 2 - ;; - -c|--config) - RESTORE_SETTINGS=true - shift - ;; - -h|--help) - export GHE_SHOW_HELP=true - shift - ;; - --version) - export GHE_SHOW_VERSION=true - shift - ;; - -v|--verbose) - export GHE_VERBOSE=true - shift - ;; - -*) - echo "Error: invalid argument: '$1'" 1>&2 - exit 1 - ;; - *) - if [ -n "$1" ]; then - GHE_RESTORE_HOST_OPT="$1" - shift - else - break - fi - ;; - esac -done - -start_cron () { - log_info "Starting cron ..." 1>&3 - if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron start" ; then - log_warn "Failed to start cron on one or more nodes" - fi - else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron start" ; then - log_warn "Failed to start cron" - fi - fi -} - -cleanup () { - log_info " Exiting, cleaning up ..." 1>&3 - if [ -n "$1" ]; then - update_restore_status "$1" - fi - - if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_info "Restarting Actions after restore ..." - # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the - # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists - # in the --help output - if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start --help' | grep -q force ; then - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start -f' 1>&3 - else - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start' 1>&3 - fi - fi - - if ! $CRON_RUNNING; then - start_cron - fi - - # Cleanup SSH multiplexing - log_info "Cleaning up SSH multiplexing ..." 1>&3 - if ! ghe-ssh --clean ; then - log_warn "Failed to clean up SSH multiplexing" - fi - # Remove in-progress file - log_info "Removing in-progress file ..." 1>&3 - - if ! rm -f ${GHE_DATA_DIR}/in-progress-restore ; then - log_warn "Failed to remove in-progress file" - fi -} - -# This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. -# shellcheck disable=SC2034 -cleanup_cluster_nodes() { - uuid="$1" - if [ -z "$uuid" ]; then - log_error "Node UUID required." - exit 2 - fi - log_info "Cleaning up spokes" 1>&3 - ghe-spokes server evacuate git-server-$uuid 'Removing replica' - ghe-spokes server destroy git-server-$uuid - - log_info "Cleaning up storage" 1>&3 - ghe-storage destroy-host storage-server-$uuid --force - - log_info "Cleaning up dpages" 1>&3 - ghe-dpages offline pages-server-$uuid - ghe-dpages remove pages-server-$uuid - - log_info "Cleaning up redis" 1>&3 - ghe-redis-cli del resque:queue:maint_git-server-$uuid - ghe-redis-cli srem resque:queues maint_git-server-$uuid -} - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" - -# Check to make sure moreutils parallel is installed and working properly -ghe_parallel_check - -# Check to make sure another restore process is not running -ghe_restore_check - -# Grab the host arg -GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" - -# Hostname without any port suffix -hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :) - -# Show usage with no -[ -z "$GHE_HOSTNAME" ] && print_usage - -# Flag to indicate if this script has stopped Actions. -ACTIONS_STOPPED=false - -# ghe-restore-snapshot-path validates it exists, determines what current is, -# and if there's any problem, exit for us -GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" -GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") -export GHE_RESTORE_SNAPSHOT - -# Check to make sure backup is not running -ghe_backup_check - -# Detect if the backup we are restoring has a leaked ssh key -log_info "Checking for leaked keys in the backup snapshot that is being restored ..." -ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true - -# Figure out whether to use the tarball or rsync restore strategy based on the -# strategy file written in the snapshot directory. -GHE_BACKUP_STRATEGY=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/strategy") - -# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. -ghe_remote_version_required "$GHE_HOSTNAME" - -# Figure out if this instance has been configured or is entirely new. -instance_configured=false -if is_instance_configured; then - instance_configured=true -else - RESTORE_SETTINGS=true -fi - -# Figure out if we're restoring into cluster -CLUSTER=false -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then - CLUSTER=true -fi -export CLUSTER - -# Restoring a cluster backup to a standalone appliance is not supported -if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - log_error "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 - exit 1 -fi - -# Ensure target appliance and restore snapshot are a compatible combination with respect to BYODB -if ! ghe-restore-external-database-compatibility-check; then - exit 1 -fi - -# Figure out if this appliance is in a replication pair -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - log_error "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 - exit 1 -fi - -# Prompt to verify the restore host given is correct. Restoring overwrites -# important data on the destination appliance that cannot be recovered. This is -# mostly to prevent accidents where the backup host is given to restore instead -# of a separate restore host since they're used in such close proximity. -if $instance_configured && ! $FORCE; then - echo - echo "WARNING: All data on GitHub Enterprise appliance $hostname ($GHE_REMOTE_VERSION)" - echo " will be overwritten with data from snapshot ${GHE_RESTORE_SNAPSHOT}." - echo - - if is_external_database_snapshot && $RESTORE_SETTINGS; then - echo "WARNING: This operation will also restore the external MySQL connection configuration," - echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." - echo - fi - - prompt_for_confirmation "Please verify that this is the correct restore host before continuing." -fi - -# Prompt to verify that restoring BYODB snapshot to unconfigured instance -# will result in BYODB connection information being restored as well. -if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then - echo - echo "WARNING: This operation will also restore the external MySQL connection configuration," - echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." - echo - - prompt_for_confirmation "Please confirm this before continuing." -fi - -# Log restore start message locally and in /var/log/syslog on remote instance -START_TIME=$(date +%s) -log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" -ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." -# Create an in-progress-restore file to prevent simultaneous backup or restore runs -echo "${START_TIME} $$" > ${GHE_DATA_DIR}/in-progress-restore - -# Keep other processes on the VM or cluster in the loop about the restore status. -# -# Other processes will look for these states: -# "restoring" - restore is currently in progress -# "failed" - restore has failed -# "complete" - restore has completed successfully -update_restore_status () { - if $CLUSTER; then - echo "ghe-cluster-each -- \"echo '$1' | sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | - ghe-ssh "$GHE_HOSTNAME" /bin/bash - else - echo "$1" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" - fi -} - -CRON_RUNNING=true -# Update remote restore state file and setup failure trap -trap "cleanup failed" EXIT -update_restore_status "restoring" - -# Make sure the GitHub appliance is in maintenance mode. -if $instance_configured; then - if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then - log_error "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 - exit 1 - fi -fi - -# Get GHES release version in major.minor format -RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2) - -# If the backup being restored is from an appliance with Actions disabled, restoring it onto an appliance with Actions enabled will cause -# mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace -ACTIONS_ENABLED_IN_BACKUP=$(git config -f $GHE_RESTORE_SNAPSHOT_PATH/settings.json --bool app.actions.enabled | xargs) -if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_error "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 - exit 1 -fi - -# Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data. -# If above is true, also check if ac is present in appliance then snapshot should also contains ac databases -if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then - if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) - ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") - if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting" \ - "\n""Please disable Actions cache service in $GHE_HOSTNAME and retry" \ - "\n""To disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 - exit 1 - fi - if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting." \ - "\n""Please enable Actions cache service in $GHE_HOSTNAME and retry" \ - "\n""To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 - exit 1 - fi - else - log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting." \ - "\n""Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 - exit 1 - fi -fi - -# Create benchmark file -bm_init > /dev/null - -ghe-backup-store-version || -log_warn "Warning: storing backup-utils version remotely failed." - -# Stop cron and timerd, as scheduled jobs may disrupt the restore process. -log_info "Stopping cron and github-timerd ..." -if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then - ghe_verbose "* Warning: Failed to stop cron on one or more nodes" - fi - - if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then - ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" - fi - fi - else - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd on one or more nodes" - fi - fi -else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then - ghe_verbose "* Warning: Failed to stop cron" - fi - - if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then - ghe_verbose "* Warning: Failed to stop github-timerd" - fi - fi - else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then - ghe_verbose "* Warning: Failed to stop github-timerd" - fi - fi -fi -CRON_RUNNING=false - -# Restore settings and license if restoring to an unconfigured appliance or when -# specified manually. -if $RESTORE_SETTINGS; then - ghe-restore-settings "$GHE_HOSTNAME" -fi - -# Make sure mysql and elasticsearch are prep'd and running before restoring. -# These services will not have been started on appliances that have not been -# configured yet. -if ! $CLUSTER; then - echo "sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 -fi - -# Restore UUID if present and not restoring to cluster. -if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then - log_info "Restoring UUID ..." - cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" - ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" - fi - -if is_external_database_snapshot; then - appliance_strategy="external" - backup_snapshot_strategy="external" -else - if is_binary_backup_feature_on; then - appliance_strategy="binary" - else - appliance_strategy="logical" - fi - - if is_binary_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"; then - backup_snapshot_strategy="binary" - else - backup_snapshot_strategy="logical" - fi -fi - -if is_external_database_target_or_snapshot && $SKIP_MYSQL; then - log_info "Skipping MySQL restore." -else - log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." - ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 -fi - -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_info "Stopping Actions before restoring databases ..." - # We mark Actions as stopped even if the `ghe-actions-stop` - # fails to ensure that we cleanly start actions when performing cleanup. - ACTIONS_STOPPED=true - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 - - log_info "Restoring MSSQL databases ..." - ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 - - log_info "Restoring Actions data ..." - ghe-restore-actions "$GHE_HOSTNAME" 1>&3 - log_warn "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." - log_warn " See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." -fi - -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - log_info "Restoring MinIO data ..." - ghe-restore-minio "$GHE_HOSTNAME" 1>&3 -fi - -commands=(" -echo \"Restoring Redis database ...\" -ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") - -commands+=(" -echo \"Restoring Git repositories ...\" -ghe-restore-repositories \"$GHE_HOSTNAME\"") - -commands+=(" -echo \"Restoring Gists ...\" -ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") - -commands+=(" -echo \"Restoring GitHub Pages artifacts ...\" -ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") - -commands+=(" -echo \"Restoring SSH authorized keys ...\" -ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") - -commands+=(" -echo \"Restoring storage data ...\" -ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") - -commands+=(" -echo \"Restoring custom Git hooks ...\" -ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") - -if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then - commands+=(" - echo \"Restoring Elasticsearch indices ...\" - ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") -fi - -# Restore the audit log migration sentinel file, if it exists in the snapshot -if [ -f "$GHE_RESTORE_SNAPSHOT_PATH"/es-scan-complete ]; then - log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - log_error "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 - fi -fi - -# Restore exported audit logs to 2.12.9 and newer single nodes and -# all releases of cluster -if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then - if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then - log_info "Skipping restore of audit logs." - else - commands+=(" - echo \"Restoring Audit logs ...\" - ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") - fi - -fi - -if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - log_info "Restoring data in parallel ..." - $GHE_PARALLEL_COMMAND "$GHE_PARALLEL_COMMAND_OPTIONS" -- "${commands[@]}" -else - log_info "Restoring data serially ..." 1>&3 - for c in "${commands[@]}"; do - eval "$c" - done -fi - -# Restart an already running memcached to reset the cache after restore -log_info "Restarting memcached ..." 1>&3 -echo "sudo restart -q memcached 2>/dev/null || true" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh - -# Prevent GitHub Connect jobs running before we've had a chance to reset -# the configuration by setting the last run date to now. -if ! $RESTORE_SETTINGS; then - log_info "Setting last run date for GitHub Connect jobs ..." 1>&3 - echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 -fi - -# When restoring to a host that has already been configured, kick off a -# config run to perform data migrations. -if $CLUSTER; then - log_info "Configuring cluster ..." - if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 - elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 - fi - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 -elif $instance_configured; then - log_info "Configuring appliance ..." - if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 - elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 - fi - ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 -fi - -# Clear GitHub Connect settings stored in the restored database. -# This needs to happen after `ghe-config-apply` to ensure all migrations have run. -if ! $RESTORE_SETTINGS; then - echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 -fi - -# Start cron. Timerd will start automatically as part of the config run. -start_cron -CRON_RUNNING=true - -# Clean up all stale replicas on configured instances. -if ! $CLUSTER && $instance_configured; then - log_info "Cleaning up replicas..." 1>&3 - restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) - other_nodes=$(echo " - set -o pipefail; \ - ghe-spokes server show --json \ - | jq -r '.[] | select(.host | contains(\"git-server\")).host' \ - | sed 's/^git-server-//g' \ - | ( grep -F -x -v \"$restored_uuid\" || true )" \ - | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) - if [ -n "$other_nodes" ]; then - log_info "Cleaning up stale nodes ..." - for uuid in $other_nodes; do - # shellcheck disable=SC2034 - echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 - done - fi -fi - -# Update the remote status to "complete". This has to happen before importing -# ssh host keys because subsequent commands will fail due to the host key -# changing otherwise. -trap "cleanup" EXIT -update_restore_status "complete" - -# Log restore complete message in /var/log/syslog on remote instance -ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." - -if ! $CLUSTER; then - log_info "Restoring SSH host keys ..." - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 -else - # This will make sure that Git over SSH host keys (babeld) are - # copied to all the cluster nodes so babeld uses the same keys. - log_info "Restoring Git over SSH host keys ..." - ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 - ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 - log_info "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 -fi - -END_TIME=$(date +%s) -log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds" -log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." - - -if ! $instance_configured; then - log_info "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." -fi - diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 8420d3076..b714d144b 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -53,7 +53,7 @@ bm_end() { echo "$1 took ${total}s" >> $BM_FILE_PATH # also log timing information in the verbose log - log_verbose "$1 took ${total}s" 1>&3 + echo "$1 took ${total}s" 1>&3 if [ -n "$GHE_DEBUG" ]; then echo "Debug: $1 took ${total}s (bm_end)" fi diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 774483e25..f8d4a4e0e 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -186,7 +186,8 @@ if [ -n "$GHE_VERBOSE" ]; then exit 1 fi calling_script_name="$(caller | sed 's:.*/::')" - exec 3> >(awk -v c="$calling_script_name" '{ print strftime("%b %d %H:%M:%S"), c":", $0; fflush(); }' >>"$GHE_VERBOSE_LOG") + date_format=$(date -u "+%FT%TZ") + exec 3> >(awk -v c="$calling_script_name" d="$date_format" '{ print d" INFO ", c":", $0; fflush(); }' >>"$GHE_VERBOSE_LOG") fi else exec 3>&1 From 0851fd3a407816485e8bc7b5e50407fa166a906d Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 01:51:27 +0000 Subject: [PATCH 1709/2421] logging tweaks --- share/github-backup-utils/ghe-backup-config | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index f8d4a4e0e..0828c444f 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -14,6 +14,12 @@ # . $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config # set +o posix +# Terminal colors +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +NC='\033[0m' # No Color + # Assume this script lives in share/github-backup-utils/ when setting the root GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" @@ -187,7 +193,7 @@ if [ -n "$GHE_VERBOSE" ]; then fi calling_script_name="$(caller | sed 's:.*/::')" date_format=$(date -u "+%FT%TZ") - exec 3> >(awk -v c="$calling_script_name" d="$date_format" '{ print d" INFO ", c":", $0; fflush(); }' >>"$GHE_VERBOSE_LOG") + exec 3> >(awk -v '{ print d" INFO ", c":", $0; fflush(); }' c="$calling_script_name" d="$date_format" >>"$GHE_VERBOSE_LOG") fi else exec 3>&1 @@ -563,13 +569,10 @@ restore-secret() { fi } -# Logging display and formatting functions -# Terminal colors -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -NC='\033[0m' # No Color + + +# Logging display and formatting functions # Log a message to stdout log_level() { From b29a5f3a51d9058bdaae894c9f232f7ca9921d01 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 01:55:59 +0000 Subject: [PATCH 1710/2421] add colorized output --- share/github-backup-utils/ghe-backup-config | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 0828c444f..86ffc36bb 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -193,7 +193,12 @@ if [ -n "$GHE_VERBOSE" ]; then fi calling_script_name="$(caller | sed 's:.*/::')" date_format=$(date -u "+%FT%TZ") - exec 3> >(awk -v '{ print d" INFO ", c":", $0; fflush(); }' c="$calling_script_name" d="$date_format" >>"$GHE_VERBOSE_LOG") + if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then + exec 3> >(awk -v '{ print d" INFO ", c":", $0; fflush(); }' c="$calling_script_name" d="$date_format" >>"$GHE_VERBOSE_LOG") + else + display_info=" ${GREEN}INFO${NC} " + exec 3> >(awk -v '{ print d, i, c":", $0; fflush(); }' c="$calling_script_name" d="$date_format" i="$display_info" >>"$GHE_VERBOSE_LOG") + fi fi else exec 3>&1 From 02ff8b2b1460fc1b90f8e10e80f134763725c0d8 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 02:04:36 +0000 Subject: [PATCH 1711/2421] awkward --- share/github-backup-utils/ghe-backup-config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 86ffc36bb..b8dc993e1 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -194,10 +194,10 @@ if [ -n "$GHE_VERBOSE" ]; then calling_script_name="$(caller | sed 's:.*/::')" date_format=$(date -u "+%FT%TZ") if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then - exec 3> >(awk -v '{ print d" INFO ", c":", $0; fflush(); }' c="$calling_script_name" d="$date_format" >>"$GHE_VERBOSE_LOG") + exec 3> >(awk '{ print d" INFO ", c":", $0; fflush(); }' -v c="$calling_script_name" d="$date_format" >>"$GHE_VERBOSE_LOG") else display_info=" ${GREEN}INFO${NC} " - exec 3> >(awk -v '{ print d, i, c":", $0; fflush(); }' c="$calling_script_name" d="$date_format" i="$display_info" >>"$GHE_VERBOSE_LOG") + exec 3> >(awk '{ print d, i, c":", $0; fflush(); }' -v c="$calling_script_name" d="$date_format" i="$display_info" >>"$GHE_VERBOSE_LOG") fi fi else From 04cfc0b5576de3dc4bf9f07ae4068b9bef886bb3 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 02:12:02 +0000 Subject: [PATCH 1712/2421] did we actually need awk??? --- share/github-backup-utils/ghe-backup-config | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b8dc993e1..dfaf1b819 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -194,10 +194,12 @@ if [ -n "$GHE_VERBOSE" ]; then calling_script_name="$(caller | sed 's:.*/::')" date_format=$(date -u "+%FT%TZ") if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then - exec 3> >(awk '{ print d" INFO ", c":", $0; fflush(); }' -v c="$calling_script_name" d="$date_format" >>"$GHE_VERBOSE_LOG") + #exec 3> >(awk -v c="$calling_script_name" d="$date_format" '{ print d" INFO ", c":", $0; fflush(); }' >>"$GHE_VERBOSE_LOG") + exec 3> >(echo -e "$date_format INFO $calling_script_name: $*" >>"$GHE_VERBOSE_LOG") else display_info=" ${GREEN}INFO${NC} " - exec 3> >(awk '{ print d, i, c":", $0; fflush(); }' -v c="$calling_script_name" d="$date_format" i="$display_info" >>"$GHE_VERBOSE_LOG") + #exec 3> >(awk '{ print d, i, c":", $0; fflush(); }' -v c="$calling_script_name" d="$date_format" i="$display_info" >>"$GHE_VERBOSE_LOG") + exec 3> >(echo -e "$date_format $display_info $calling_script_name: $*" >>"$GHE_VERBOSE_LOG") fi fi else From d2d22862bdb8c7d911290aa28b124a397b527629 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 02:19:53 +0000 Subject: [PATCH 1713/2421] more output refinements --- share/github-backup-utils/ghe-backup-config | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index dfaf1b819..0585ba283 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -18,6 +18,7 @@ set +o posix RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' +BLUE='\033[0;34m' NC='\033[0m' # No Color # Assume this script lives in share/github-backup-utils/ when setting the root @@ -187,19 +188,14 @@ if [ -n "$GHE_VERBOSE" ]; then if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then exec 3>>"$GHE_VERBOSE_LOG" else - if ! echo | awk '{ print strftime("%b %d %H:%M:%S"); fflush(); }' &>/dev/null; then - echo "Error: awk command failed. Please install https://www.gnu.org/software/gawk" 1>&2 - exit 1 - fi calling_script_name="$(caller | sed 's:.*/::')" date_format=$(date -u "+%FT%TZ") if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then - #exec 3> >(awk -v c="$calling_script_name" d="$date_format" '{ print d" INFO ", c":", $0; fflush(); }' >>"$GHE_VERBOSE_LOG") exec 3> >(echo -e "$date_format INFO $calling_script_name: $*" >>"$GHE_VERBOSE_LOG") else display_info=" ${GREEN}INFO${NC} " - #exec 3> >(awk '{ print d, i, c":", $0; fflush(); }' -v c="$calling_script_name" d="$date_format" i="$display_info" >>"$GHE_VERBOSE_LOG") - exec 3> >(echo -e "$date_format $display_info $calling_script_name: $*" >>"$GHE_VERBOSE_LOG") + display_caller="${BLUE}$calling_script_name${NC}" + exec 3> >(echo -e "$date_format $display_info $display_caller: $*" >>"$GHE_VERBOSE_LOG") fi fi else From 028faeff1842dfdeff156cc4d27efdfd697cf4df Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 15:38:21 +0000 Subject: [PATCH 1714/2421] refinements to display --- bin/ghe-backup | 33 ++++++++++++------- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-backup-config | 1 + .../github-backup-utils/ghe-restore-git-hooks | 2 +- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index cae5fe785..c694608fd 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -73,15 +73,13 @@ if ! ln -s /data/does/not/exist/hooks/ src/ >/dev/null 2>&1; then fi if ! output=$(rsync -a src/ dest1 2>&1 && rsync -av src/ --link-dest=../dest1 dest2 2>&1); then - log_error "Error: rsync encountered an error that could indicate a problem with permissions," 1>&2 - log_error "hard links, symbolic links, or another issue that may affect backups." 1>&2 + log_error "Error: rsync encountered an error that could indicate a problem with permissions,\n hard links, symbolic links, or another issue that may affect backups." 1>&2 echo "$output" exit 1 fi if [ "$(ls -il dest1/testfile | awk '{ print $1 }')" != "$(ls -il dest2/testfile | awk '{ print $1 }')" ]; then - log_error "Error: the filesystem containing $GHE_DATA_DIR does not support hard links." 1>&2 - log_error "Backup Utilities use hard links to store backup data efficiently." 1>&2 + log_error "Error: the filesystem containing $GHE_DATA_DIR does not support hard links.\n Backup Utilities use hard links to store backup data efficiently." 1>&2 exit 1 fi rm -rf src dest1 dest2 @@ -168,6 +166,9 @@ echo "$GHE_BACKUP_STRATEGY" > strategy # Create benchmark file bm_init > /dev/null +START_TIME=$(date +%s) +log_info "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION" + ghe-backup-store-version || log_warn "Warning: storing backup-utils version remotely failed." @@ -201,33 +202,40 @@ if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then ghe-backup-minio 1>&3 || failures="$failures minio" fi +cmd_title=$(log_info "Backing up Redis database ...") commands=(" -echo \"Backing up Redis database ...\" +echo \"$cmd_title\" ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"") +cmd_title=$(log_info "Backing up audit log ...") commands+=(" -echo \"Backing up audit log ...\" +echo \"$cmd_title\" ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"") +cmd_title=$(log_info "Backing up Git repositories ...") commands+=(" -echo \"Backing up Git repositories ...\" +echo \"$cmd_title\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") +cmd_title=$(log_info "Backing up GitHub Pages artifacts ...") commands+=(" -echo \"Backing up GitHub Pages artifacts ...\" +echo \"$cmd_title\" ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") +cmd_title=$(log_info "Backing up storage data ...") commands+=(" -echo \"Backing up storage data ...\" +echo \"$cmd_title\" ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\"") +cmd_title=$(log_info "Backing up custom Git hooks ...") commands+=(" -echo \"Backing up custom Git hooks ...\" +echo \"$cmd_title\" ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"") if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then + cmd_title=$(log_info "Backing up Elasticsearch indices ...") commands+=(" - echo \"Backing up Elasticsearch indices ...\" + echo \"$cmd_title\" ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\"") fi @@ -277,6 +285,9 @@ fi log_info "Checking for leaked ssh keys ..." ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true +END_TIME=$(date +%s) +log_info "Runtime: $((${END_TIME} - ${START_TIME})) seconds" +log_info "Backup of $GHE_HOSTNAME finished." # Make sure we exit zero after the conditional true diff --git a/bin/ghe-restore b/bin/ghe-restore index b24a2c2ae..ebd4d6e5e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -266,7 +266,7 @@ fi # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) -echo "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" +log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Create an in-progress-restore file to prevent simultaneous backup or restore runs echo "${START_TIME} $$" > ${GHE_DATA_DIR}/in-progress-restore diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 0585ba283..8541307f6 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -193,6 +193,7 @@ if [ -n "$GHE_VERBOSE" ]; then if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then exec 3> >(echo -e "$date_format INFO $calling_script_name: $*" >>"$GHE_VERBOSE_LOG") else + # colorize the input if supported. display_info=" ${GREEN}INFO${NC} " display_caller="${BLUE}$calling_script_name${NC}" exec 3> >(echo -e "$date_format $display_info $display_caller: $*" >>"$GHE_VERBOSE_LOG") diff --git a/share/github-backup-utils/ghe-restore-git-hooks b/share/github-backup-utils/ghe-restore-git-hooks index 2384b4302..4bad41f7a 100755 --- a/share/github-backup-utils/ghe-restore-git-hooks +++ b/share/github-backup-utils/ghe-restore-git-hooks @@ -60,7 +60,7 @@ if [ -d "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/git-hooks/environments/tarballs" ]; if [ -n "$hostname" ]; then ghe-ssh $ssh_config_file_opt -l $user "$hostname:122" -- "sudo -u git mkdir -p $GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs" - log_rsync "BEGIN: git-hooksi tarball rsync" 1>&3 + log_rsync "BEGIN: git-hooks tarball rsync" 1>&3 ghe-rsync -avH --delete \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path="sudo -u git rsync" \ From 62089de0b7cea5893cb629a1a378af042a7db354 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 16:01:26 +0000 Subject: [PATCH 1715/2421] fix broken echo --- share/github-backup-utils/ghe-backup-config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 8541307f6..5d4248e0f 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -191,12 +191,13 @@ if [ -n "$GHE_VERBOSE" ]; then calling_script_name="$(caller | sed 's:.*/::')" date_format=$(date -u "+%FT%TZ") if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then - exec 3> >(echo -e "$date_format INFO $calling_script_name: $*" >>"$GHE_VERBOSE_LOG") + exec 3>>"$GHE_VERBOSE_LOG" + log_info "$calling_script_name: $*" 1>&3 else # colorize the input if supported. - display_info=" ${GREEN}INFO${NC} " display_caller="${BLUE}$calling_script_name${NC}" - exec 3> >(echo -e "$date_format $display_info $display_caller: $*" >>"$GHE_VERBOSE_LOG") + exec 3>>"$GHE_VERBOSE_LOG" + log_info "$display_caller: $*" 1>&3 fi fi else From e787ffec14d45913e320151db29e0f54cf300a7f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 16:07:57 +0000 Subject: [PATCH 1716/2421] fix shellcheck --- share/github-backup-utils/ghe-backup-config | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 5d4248e0f..3b86fc6d5 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -189,7 +189,6 @@ if [ -n "$GHE_VERBOSE" ]; then exec 3>>"$GHE_VERBOSE_LOG" else calling_script_name="$(caller | sed 's:.*/::')" - date_format=$(date -u "+%FT%TZ") if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then exec 3>>"$GHE_VERBOSE_LOG" log_info "$calling_script_name: $*" 1>&3 From aa790732fd91063f6931a1888208f94b29004e73 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 16:12:50 +0000 Subject: [PATCH 1717/2421] fixing order --- share/github-backup-utils/ghe-backup-config | 142 ++++++++++---------- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 3b86fc6d5..340003a4c 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -19,9 +19,77 @@ RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' BLUE='\033[0;34m' -NC='\033[0m' # No Color +NC='\033[0m' # No Colo# Logging display and formatting functions -# Assume this script lives in share/github-backup-utils/ when setting the root +# Log a message to stdout +log_level() { + local level=$1 + shift + local message=$* + local display="" + local timestamp + timestamp=$(date -u "+%FT%TZ") + + + if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then + if [ "$level" = "info" ]; then + display="INFO" + elif [ "$level" = "warn" ]; then + display="WARN" + elif [ "$level" = "error" ]; then + display="ERROR" + elif [ "$level" = "verbose" ]; then + display="INFO" + elif [ "$level" = "rsync" ]; then + display="RSYNC" + elif [ "$level" = "ssh" ]; then + display="SSH" + else + display="-" + fi + else + if [ "$level" = "info" ]; then + display="${GREEN}INFO${NC}" + elif [ "$level" = "warn" ]; then + display="${YELLOW}WARN${NC}" + elif [ "$level" = "error" ]; then + display="${RED}ERROR${NC}" + elif [ "$level" = "verbose" ]; then + display="${GREEN}INFO${NC}" + elif [ "$level" = "rsync" ]; then + display="${GREEN}RSYNC${NC}" + elif [ "$level" = "ssh" ]; then + display="${GREEN}SSH${NC}" + else + display="-" + fi + fi + echo -e "$timestamp $display $message" +} + +log_info(){ + log_level "info" "$1" +} + +log_warn(){ + log_level "warn" "$1" +} + +log_error(){ + log_level "error" "$1" +} + +log_verbose(){ + log_level "verbose" "$1" +} + +log_rsync(){ + log_level "rsync" "$1" +} + +log_ssh(){ + log_level "ssh" "$1" +} Assume this script lives in share/github-backup-utils/ when setting the root GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" # Get the version from the version file. @@ -576,74 +644,4 @@ restore-secret() { -# Logging display and formatting functions -# Log a message to stdout -log_level() { - local level=$1 - shift - local message=$* - local display="" - local timestamp - timestamp=$(date -u "+%FT%TZ") - - - if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then - if [ "$level" = "info" ]; then - display="INFO" - elif [ "$level" = "warn" ]; then - display="WARN" - elif [ "$level" = "error" ]; then - display="ERROR" - elif [ "$level" = "verbose" ]; then - display="INFO" - elif [ "$level" = "rsync" ]; then - display="RSYNC" - elif [ "$level" = "ssh" ]; then - display="SSH" - else - display="-" - fi - else - if [ "$level" = "info" ]; then - display="${GREEN}INFO${NC}" - elif [ "$level" = "warn" ]; then - display="${YELLOW}WARN${NC}" - elif [ "$level" = "error" ]; then - display="${RED}ERROR${NC}" - elif [ "$level" = "verbose" ]; then - display="${GREEN}INFO${NC}" - elif [ "$level" = "rsync" ]; then - display="${GREEN}RSYNC${NC}" - elif [ "$level" = "ssh" ]; then - display="${GREEN}SSH${NC}" - else - display="-" - fi - fi - echo -e "$timestamp $display $message" -} - -log_info(){ - log_level "info" "$1" -} - -log_warn(){ - log_level "warn" "$1" -} - -log_error(){ - log_level "error" "$1" -} - -log_verbose(){ - log_level "verbose" "$1" -} - -log_rsync(){ - log_level "rsync" "$1" -} - -log_ssh(){ - log_level "ssh" "$1" -} From 9ad43084c2f9b1726ae4e9a757a89a66b29ff821 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 16:13:27 +0000 Subject: [PATCH 1718/2421] fix --- share/github-backup-utils/ghe-backup-config | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 340003a4c..b857770ac 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -89,7 +89,9 @@ log_rsync(){ log_ssh(){ log_level "ssh" "$1" -} Assume this script lives in share/github-backup-utils/ when setting the root +} + +# Assume this script lives in share/github-backup-utils/ when setting the root GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" # Get the version from the version file. From 66dcf2da85c55684389417ddc38f942922119352 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 17 Mar 2023 16:18:20 +0000 Subject: [PATCH 1719/2421] refine output --- share/github-backup-utils/ghe-backup-config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b857770ac..c8dd15813 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -261,12 +261,12 @@ if [ -n "$GHE_VERBOSE" ]; then calling_script_name="$(caller | sed 's:.*/::')" if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then exec 3>>"$GHE_VERBOSE_LOG" - log_info "$calling_script_name: $*" 1>&3 + log_info "$calling_script_name $*" 1>&3 else # colorize the input if supported. display_caller="${BLUE}$calling_script_name${NC}" exec 3>>"$GHE_VERBOSE_LOG" - log_info "$display_caller: $*" 1>&3 + log_info "$display_caller $*" 1>&3 fi fi else From 54cebd3778d7ba88957c93fe1fe54012f3557220 Mon Sep 17 00:00:00 2001 From: Krayon Date: Tue, 21 Mar 2023 03:04:12 +1100 Subject: [PATCH 1720/2421] ghe-backup-config shellcheck fixes --- share/github-backup-utils/ghe-backup-config | 108 ++++++++++++-------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 2683105fb..e28ab6d83 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -47,7 +47,7 @@ log_level() { else display="-" fi - else + else if [ "$level" = "info" ]; then display="${GREEN}INFO${NC}" elif [ "$level" = "warn" ]; then @@ -89,7 +89,7 @@ log_rsync(){ log_ssh(){ log_level "ssh" "$1" -} +} # Assume this script lives in share/github-backup-utils/ when setting the root GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" @@ -150,15 +150,15 @@ export GHE_RESTORE_IN_PROGRESS export GHE_BACKUP_IN_PROGRESS ghe_restore_check() { - if [ -h $GHE_RESTORE_IN_PROGRESS ]; then + if [ -h "$GHE_RESTORE_IN_PROGRESS" ]; then echo " Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2 echo " If there is no restore in progress anymore, please remove" 1>&2 echo " the $GHE_RESTORE_IN_PROGRESS file and try again." 1>&2 exit 1 fi - if [ -f $GHE_RESTORE_IN_PROGRESS ]; then - progress=$(cat $GHE_RESTORE_IN_PROGRESS) + if [ -f "$GHE_RESTORE_IN_PROGRESS" ]; then + progress=$(cat "$GHE_RESTORE_IN_PROGRESS") pid=$(echo "$progress" | cut -d ' ' -f 2) echo " Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 echo " If PID $pid is not a process related to the restore utilities, please remove" 1>&2 @@ -168,15 +168,15 @@ ghe_restore_check() { } ghe_backup_check() { - if [ -h $GHE_BACKUP_IN_PROGRESS ]; then + if [ -h "$GHE_BACKUP_IN_PROGRESS" ]; then echo " Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 echo " If there is no backup in progress anymore, please remove" 1>&2 echo " the $GHE_DATA_DIR/$GHE_BACKUP_IN_PROGRESS file and try again." 1>&2 exit 1 fi - if [ -f $GHE_BACKUP_IN_PROGRESS ]; then - progress=$(cat $GHE_BACKUP_IN_PROGRESS) + if [ -f "$GHE_BACKUP_IN_PROGRESS" ]; then + progress=$(cat "$GHE_BACKUP_IN_PROGRESS") pid=$(echo "$progress" | cut -d ' ' -f 2) echo " Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2 @@ -186,14 +186,14 @@ ghe_backup_check() { } ghe_restore_finished() { - if [ -f $GHE_RESTORE_IN_PROGRESS ]; then - rm -f $GHE_RESTORE_IN_PROGRESS + if [ -f "$GHE_RESTORE_IN_PROGRESS" ]; then + rm -f "$GHE_RESTORE_IN_PROGRESS" fi } ghe_backup_finished() { - if [ -f $GHE_BACKUP_IN_PROGRESS ]; then - rm -f $GHE_BACKUP_IN_PROGRESS + if [ -f "$GHE_BACKUP_IN_PROGRESS" ]; then + rm -f "$GHE_BACKUP_IN_PROGRESS" fi } @@ -265,7 +265,7 @@ if [ -n "$GHE_VERBOSE" ]; then exec 3>>"$GHE_VERBOSE_LOG" log_info "$calling_script_name $*" 1>&3 else - # colorize the input if supported. + # colorize the input if supported. display_caller="${BLUE}$calling_script_name${NC}" exec 3>>"$GHE_VERBOSE_LOG" log_info "$display_caller $*" 1>&3 @@ -327,11 +327,11 @@ if [ ! -d "$GHE_DATA_DIR" ]; then fi # Set some defaults if needed. -: ${GHE_NUM_SNAPSHOTS:=10} +: "${GHE_NUM_SNAPSHOTS:=10}" # Generate a backup timestamp if one has not already been generated. # We export the variable so the process group shares the same value. -: ${GHE_SNAPSHOT_TIMESTAMP:=$(date +"%Y%m%dT%H%M%S")} +: "${GHE_SNAPSHOT_TIMESTAMP:=$(date +"%Y%m%dT%H%M%S")}" export GHE_SNAPSHOT_TIMESTAMP # Set the current snapshot directory to /. This is where @@ -341,12 +341,12 @@ export GHE_SNAPSHOT_DIR # The root filesystem location. This must be used so that tests can override # the root as a local directory location. -: ${GHE_REMOTE_ROOT_DIR:=""} +: "${GHE_REMOTE_ROOT_DIR:=""}" # The root location of persistent data and applications on the remote side. This # is always "/data" for GitHub instances. Use of this variable allows # the location to be overridden in tests. -: ${GHE_REMOTE_DATA_DIR:="/data"} +: "${GHE_REMOTE_DATA_DIR:="/data"}" # The root location of user data stores such as git repositories, pages sites, # elasticsearch indices, etc. This is "/data" under 1.x filesystem layouts and @@ -354,37 +354,37 @@ export GHE_SNAPSHOT_DIR # dynamically in ghe_remote_version_config() immediately after obtaining the # remote version. Utilities that transfer data in and out of the appliance # should use this variable to ensure proper behavior under different versions. -: ${GHE_REMOTE_DATA_USER_DIR:="$GHE_REMOTE_DATA_DIR"} +: "${GHE_REMOTE_DATA_USER_DIR:="$GHE_REMOTE_DATA_DIR"}" # The location of the license file on the remote side. This is always # "/data/enterprise/enterprise.ghl" for GitHub instances. Use of this variable # allows the location to be overridden in tests. -: ${GHE_REMOTE_LICENSE_FILE:="$GHE_REMOTE_DATA_DIR/enterprise/enterprise.ghl"} +: "${GHE_REMOTE_LICENSE_FILE:="$GHE_REMOTE_DATA_DIR/enterprise/enterprise.ghl"}" # The number of seconds to wait for in progress git-gc processes to complete # before starting the sync of git data. See share/github-backup-utils/ghe-backup-repositories-rsync # for more information. Default: 10 minutes. -: ${GHE_GIT_COOLDOWN_PERIOD:=600} +: "${GHE_GIT_COOLDOWN_PERIOD:=600}" # Set "true" to get verbose logging of all ssh commands on stderr -: ${GHE_VERBOSE_SSH:=false} +: "${GHE_VERBOSE_SSH:=false}" # The location of the cluster configuration file on the remote side. # This is always "/data/user/common/cluster.conf" for GitHub Cluster instances. # Use of this variable allows the location to be overridden in tests. -: ${GHE_REMOTE_CLUSTER_CONF_FILE:="$GHE_REMOTE_DATA_DIR/user/common/cluster.conf"} +: "${GHE_REMOTE_CLUSTER_CONF_FILE:="$GHE_REMOTE_DATA_DIR/user/common/cluster.conf"}" # The location of the file used to disable GC operations on the remote side. -: ${SYNC_IN_PROGRESS_FILE:="$GHE_REMOTE_DATA_USER_DIR/repositories/.sync_in_progress"} +: "${SYNC_IN_PROGRESS_FILE:="$GHE_REMOTE_DATA_USER_DIR/repositories/.sync_in_progress"}" # Base path for temporary directories and files. -: ${TMPDIR:="/tmp"} +: "${TMPDIR:="/tmp"}" # Backup cadence for MS SQL. Determines the kind of backup taken, either full, differential, # or transaction log, based on when the last backup of that kind was taken. This defaults to # taking a full backup once a week, a differential backup once a day, and transaction logs every # 15 minutes. -: ${GHE_MSSQL_BACKUP_CADENCE:=10080,1440,15} +: "${GHE_MSSQL_BACKUP_CADENCE:=10080,1440,15}" ############################################################################### ### Dynamic remote version config @@ -404,11 +404,22 @@ ghe_remote_version_config() { # If we don't have a readlink command, parse ls -l output. if ! type readlink 1>/dev/null 2>&1; then readlink() { - if [ -x "$1" ]; then - ls -ld "$1" | sed 's/.*-> //' - else - return 1 - fi + local ret=0 f='' + while [ $# -gt 0 ]; do + f="$1" + shift 1 + + [ ! -e "$f" ] && [ ! -h "$f" ] && { + ret=1 + continue + } + + # shellcheck disable=SC2012 # In this specific scenario, this method is OK + f="$(ls -ld "$f")" + echo "${f//*-> /}" + done + + return $ret } fi @@ -426,10 +437,12 @@ ghe_remote_version_required() { # override hostname w/ ghe-host-check output because the port could have # been autodetected to 122. - GHE_HOSTNAME=$(echo "$_out" | sed 's/Connect \(.*:[0-9]*\) OK.*/\1/') + GHE_HOSTNAME="${_out/Connect /}" + GHE_HOSTNAME="${GHE_HOSTNAME/ OK*/}" export GHE_HOSTNAME - GHE_REMOTE_VERSION=$(echo "$_out" | sed 's/.*(\(.*\))/\1/') + GHE_REMOTE_VERSION="${GHE_HOSTNAME#*\(}" + GHE_REMOTE_VERSION="${GHE_HOSTNAME%%\)*}" export GHE_REMOTE_VERSION ghe_parse_remote_version "$GHE_REMOTE_VERSION" @@ -441,9 +454,11 @@ ghe_remote_version_required() { # Parse a version string into major, minor and patch parts and echo. ghe_parse_version() { local version_major version_minor version_patch - version_major=$(echo "${1#v}" | cut -f 1 -d .) - version_minor=$(echo "$1" | cut -f 2 -d .) - version_patch=$(echo "$1" | cut -f 3 -d .) + version_patch="${1#v}" + version_major="${version_patch%%.*}" + version_patch="${version_patch#*.}" + version_minor="${version_patch%%.*}" + version_patch="${version_patch#*.}" version_patch=${version_patch%%[a-zA-Z]*} echo "$version_major $version_minor $version_patch" @@ -457,7 +472,7 @@ ghe_parse_version() { # appliance version. ghe_parse_remote_version() { # shellcheck disable=SC2046 # Word splitting is required to populate the variables - read -r GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH <<<$(ghe_parse_version $1) + read -r GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH < <(ghe_parse_version "$1") export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH } @@ -504,15 +519,18 @@ ghe_debug() { if [ $# -ne 0 ]; then echo -e "Debug: $*" 1>&3 elif [ -p /dev/stdin ]; then - echo "\n" 1>&3 - while read line; do + echo -e "\n" 1>&3 + while read -r line; do echo -e "Debug: $line" 1>&3 done Date: Mon, 20 Mar 2023 17:30:43 -0400 Subject: [PATCH 1721/2421] Initial commit Multi-line description of commit, feel free to be detailed. --- bin/ghe-backup | 6 +- bin/ghe-restore | 4 + share/github-backup-utils/ghe-backup-config | 146 ++++++++++---------- 3 files changed, 83 insertions(+), 73 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index c694608fd..36cab279c 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -38,6 +38,9 @@ while true; do done export CALLING_SCRIPT="ghe-backup" +export BACKUP_PROGRESS=0 # Used to track progress of backup +export BACKUP_PROGRESS_TOTAL=15 # Maximum number of steps in backup +export BACKUP_PROGRESS_DESCRIPTION="" # Used to store information about current step # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" @@ -121,7 +124,7 @@ ghe_restore_check # Check to see if there is a running backup if [ -h ../in-progress ]; then - log_error "Error: detected a backup already in progress from a previous version of ghe-backup. \nIf there is no backup in progress anymore, please remove \nthe $GHE_DATA_DIR/in-progress file." 1>&2 + log_error "Detected a backup already in progress from a previous version of ghe-backup. \nIf there is no backup in progress anymore, please remove \nthe $GHE_DATA_DIR/in-progress file." 1>&2 exit 1 fi @@ -278,6 +281,7 @@ else steps="$(echo $failures | sed 's/ /, /g')" ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP with failures: ${steps}." log_error "Error: Snapshot incomplete. Some steps failed: ${steps}. " + ghe_backup_finished exit 1 fi diff --git a/bin/ghe-restore b/bin/ghe-restore index ebd4d6e5e..725c44a69 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -86,6 +86,10 @@ while true; do esac done +export GHE_RESTORE_PROGRESS=0 +export GHE_RESTORE_PROGRESS_TOTAL=15 +export GHE_RESTORE_PROGRESS_DESCRIPTION="" + start_cron () { log_info "Starting cron ..." if $CLUSTER; then diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index c8dd15813..65d4fe744 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -19,9 +19,69 @@ RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[0;33m' BLUE='\033[0;34m' -NC='\033[0m' # No Colo# Logging display and formatting functions +NC='\033[0m' # No Color + + +# Assume this script lives in share/github-backup-utils/ when setting the root +GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" + +# Get the version from the version file. +BACKUP_UTILS_VERSION="$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/version")" + +# If a version check was requested, show the current version and exit +if [ -n "$GHE_SHOW_VERSION" ]; then + echo "GitHub backup-utils v$BACKUP_UTILS_VERSION" + exit 0 +fi + +# Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage +# shellcheck disable=SC2120 # the script name is always referenced +print_usage() { + grep '^#/' <"$0" | cut -c 4- + exit "${1:-1}" +} + +if [ -n "$GHE_SHOW_HELP" ]; then + print_usage +else + for a in "$@"; do + if [ "$a" = "--help" ] || [ "$a" = "-h" ]; then + print_usage + fi + done +fi + +# Add the bin and share/github-backup-utils dirs to PATH +PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" +# shellcheck source=share/github-backup-utils/bm.sh +. "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" + +# Save off GHE_HOSTNAME from the environment since we want it to override the +# backup.config value when set. +GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" + +# Source in the backup config file from the copy specified in the environment +# first and then fall back to the backup-utils root, home directory and system. +config_found=false +for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ + "$HOME/.github-backup-utils/backup.config" "/etc/github-backup-utils/backup.config"; do + if [ -f "$f" ]; then + GHE_BACKUP_CONFIG="$f" + # shellcheck disable=SC1090 # This is a user-supplied value that can't be predicted + . "$GHE_BACKUP_CONFIG" + config_found=true + break + fi +done + +GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore") +GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup") + +export GHE_RESTORE_IN_PROGRESS +export GHE_BACKUP_IN_PROGRESS + +# Logging display and formatting functions -# Log a message to stdout log_level() { local level=$1 shift @@ -91,64 +151,6 @@ log_ssh(){ log_level "ssh" "$1" } -# Assume this script lives in share/github-backup-utils/ when setting the root -GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" - -# Get the version from the version file. -BACKUP_UTILS_VERSION="$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/version")" - -# If a version check was requested, show the current version and exit -if [ -n "$GHE_SHOW_VERSION" ]; then - echo "GitHub backup-utils v$BACKUP_UTILS_VERSION" - exit 0 -fi - -# Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage -# shellcheck disable=SC2120 # the script name is always referenced -print_usage() { - grep '^#/' <"$0" | cut -c 4- - exit "${1:-1}" -} - -if [ -n "$GHE_SHOW_HELP" ]; then - print_usage -else - for a in "$@"; do - if [ "$a" = "--help" ] || [ "$a" = "-h" ]; then - print_usage - fi - done -fi - -# Add the bin and share/github-backup-utils dirs to PATH -PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" -# shellcheck source=share/github-backup-utils/bm.sh -. "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" - -# Save off GHE_HOSTNAME from the environment since we want it to override the -# backup.config value when set. -GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" - -# Source in the backup config file from the copy specified in the environment -# first and then fall back to the backup-utils root, home directory and system. -config_found=false -for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ - "$HOME/.github-backup-utils/backup.config" "/etc/github-backup-utils/backup.config"; do - if [ -f "$f" ]; then - GHE_BACKUP_CONFIG="$f" - # shellcheck disable=SC1090 # This is a user-supplied value that can't be predicted - . "$GHE_BACKUP_CONFIG" - config_found=true - break - fi -done - -GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore") -GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup") - -export GHE_RESTORE_IN_PROGRESS -export GHE_BACKUP_IN_PROGRESS - ghe_restore_check() { if [ -h $GHE_RESTORE_IN_PROGRESS ]; then echo " Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2 @@ -325,11 +327,11 @@ if [ ! -d "$GHE_DATA_DIR" ]; then fi # Set some defaults if needed. -: ${GHE_NUM_SNAPSHOTS:=10} +: "${GHE_NUM_SNAPSHOTS:=10}" # Generate a backup timestamp if one has not already been generated. # We export the variable so the process group shares the same value. -: ${GHE_SNAPSHOT_TIMESTAMP:=$(date +"%Y%m%dT%H%M%S")} +: "${GHE_SNAPSHOT_TIMESTAMP:=$(date +"%Y%m%dT%H%M%S")}" export GHE_SNAPSHOT_TIMESTAMP # Set the current snapshot directory to /. This is where @@ -339,12 +341,12 @@ export GHE_SNAPSHOT_DIR # The root filesystem location. This must be used so that tests can override # the root as a local directory location. -: ${GHE_REMOTE_ROOT_DIR:=""} +: "${GHE_REMOTE_ROOT_DIR:=""}" # The root location of persistent data and applications on the remote side. This # is always "/data" for GitHub instances. Use of this variable allows # the location to be overridden in tests. -: ${GHE_REMOTE_DATA_DIR:="/data"} +: "${GHE_REMOTE_DATA_DIR:="/data"}" # The root location of user data stores such as git repositories, pages sites, # elasticsearch indices, etc. This is "/data" under 1.x filesystem layouts and @@ -352,37 +354,37 @@ export GHE_SNAPSHOT_DIR # dynamically in ghe_remote_version_config() immediately after obtaining the # remote version. Utilities that transfer data in and out of the appliance # should use this variable to ensure proper behavior under different versions. -: ${GHE_REMOTE_DATA_USER_DIR:="$GHE_REMOTE_DATA_DIR"} +: "${GHE_REMOTE_DATA_USER_DIR:="$GHE_REMOTE_DATA_DIR"}" # The location of the license file on the remote side. This is always # "/data/enterprise/enterprise.ghl" for GitHub instances. Use of this variable # allows the location to be overridden in tests. -: ${GHE_REMOTE_LICENSE_FILE:="$GHE_REMOTE_DATA_DIR/enterprise/enterprise.ghl"} +: "${GHE_REMOTE_LICENSE_FILE:="$GHE_REMOTE_DATA_DIR/enterprise/enterprise.ghl"}" # The number of seconds to wait for in progress git-gc processes to complete # before starting the sync of git data. See share/github-backup-utils/ghe-backup-repositories-rsync # for more information. Default: 10 minutes. -: ${GHE_GIT_COOLDOWN_PERIOD:=600} +: "${GHE_GIT_COOLDOWN_PERIOD:=600}" # Set "true" to get verbose logging of all ssh commands on stderr -: ${GHE_VERBOSE_SSH:=false} +: "${GHE_VERBOSE_SSH:=false}" # The location of the cluster configuration file on the remote side. # This is always "/data/user/common/cluster.conf" for GitHub Cluster instances. # Use of this variable allows the location to be overridden in tests. -: ${GHE_REMOTE_CLUSTER_CONF_FILE:="$GHE_REMOTE_DATA_DIR/user/common/cluster.conf"} +: "${GHE_REMOTE_CLUSTER_CONF_FILE:="$GHE_REMOTE_DATA_DIR/user/common/cluster.conf"}" # The location of the file used to disable GC operations on the remote side. -: ${SYNC_IN_PROGRESS_FILE:="$GHE_REMOTE_DATA_USER_DIR/repositories/.sync_in_progress"} +: "${SYNC_IN_PROGRESS_FILE:="$GHE_REMOTE_DATA_USER_DIR/repositories/.sync_in_progress"}" # Base path for temporary directories and files. -: ${TMPDIR:="/tmp"} +: "${TMPDIR:="/tmp"}" # Backup cadence for MS SQL. Determines the kind of backup taken, either full, differential, # or transaction log, based on when the last backup of that kind was taken. This defaults to # taking a full backup once a week, a differential backup once a day, and transaction logs every # 15 minutes. -: ${GHE_MSSQL_BACKUP_CADENCE:=10080,1440,15} +: "${GHE_MSSQL_BACKUP_CADENCE:=10080,1440,15}" ############################################################################### ### Dynamic remote version config From af872476523e762ac6d668045a05c39e7ffb895b Mon Sep 17 00:00:00 2001 From: Krayon Date: Tue, 21 Mar 2023 12:14:25 +1100 Subject: [PATCH 1722/2421] Added finished lines to ghe-backup/ghe-restore --- bin/ghe-backup | 3 +-- bin/ghe-restore | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index f026dfb45..47fa9cddc 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -284,8 +284,7 @@ fi log_info "Checking for leaked ssh keys ..." ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true -# Make sure we exit zero after the conditional -true +log_info "Restore of $GHE_HOSTNAME finished." # Remove in-progress file ghe_backup_finished diff --git a/bin/ghe-restore b/bin/ghe-restore index 565b221c6..2f789357d 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -607,7 +607,9 @@ fi END_TIME=$(date +%s) log_info "Runtime: $((END_TIME - START_TIME)) seconds" -log_info "Restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT finished." +log_info "Completed restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT at $(date +"%H:%M:%S")" + +log_info "Restore of $GHE_HOSTNAME finished." if ! $instance_configured; then echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." From 0a4e7d535033b9575cd7b9ef452b8947b0a992a3 Mon Sep 17 00:00:00 2001 From: Krayon Date: Tue, 21 Mar 2023 12:49:43 +1100 Subject: [PATCH 1723/2421] Simplified ghe_parse_version --- share/github-backup-utils/ghe-backup-config | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index e28ab6d83..521828824 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -454,11 +454,8 @@ ghe_remote_version_required() { # Parse a version string into major, minor and patch parts and echo. ghe_parse_version() { local version_major version_minor version_patch - version_patch="${1#v}" - version_major="${version_patch%%.*}" - version_patch="${version_patch#*.}" - version_minor="${version_patch%%.*}" - version_patch="${version_patch#*.}" + + IFS=. read -r version_major version_minor version_patch _ <<<"${1#v}" version_patch=${version_patch%%[a-zA-Z]*} echo "$version_major $version_minor $version_patch" From 0854d459cebd0be5849bff4b5a1ce83b0515a12a Mon Sep 17 00:00:00 2001 From: Krayon Date: Tue, 21 Mar 2023 13:15:54 +1100 Subject: [PATCH 1724/2421] Fix GHE_PARALLEL_RSYNC_COMMAND_OPTIONS --- share/github-backup-utils/ghe-backup-config | 5 +++-- share/github-backup-utils/ghe-restore-repositories | 2 +- share/github-backup-utils/ghe-restore-storage | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 521828824..b812b6872 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -199,6 +199,7 @@ ghe_backup_finished() { ghe_parallel_check() { GHE_PARALLEL_COMMAND_OPTIONS=() + GHE_PARALLEL_RSYNC_COMMAND_OPTIONS=() if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then return 0 @@ -234,12 +235,12 @@ ghe_parallel_check() { fi if [ -n "$GHE_PARALLEL_RSYNC_MAX_JOBS" ]; then - GHE_PARALLEL_RSYNC_COMMAND_OPTIONS="-j $GHE_PARALLEL_RSYNC_MAX_JOBS" + GHE_PARALLEL_RSYNC_COMMAND_OPTIONS+=(-j "$GHE_PARALLEL_RSYNC_MAX_JOBS") fi if [ -n "$GHE_PARALLEL_MAX_LOAD" ]; then GHE_PARALLEL_COMMAND_OPTIONS+=(-l "$GHE_PARALLEL_MAX_LOAD") - GHE_PARALLEL_RSYNC_COMMAND_OPTIONS+=" -l $GHE_PARALLEL_MAX_LOAD" + GHE_PARALLEL_RSYNC_COMMAND_OPTIONS+=(-l "$GHE_PARALLEL_MAX_LOAD") fi } diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index ba97153d4..d59864196 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -171,7 +171,7 @@ for file_list in $tempdir/git-server-*.rsync; do done if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - $GHE_PARALLEL_COMMAND $GHE_PARALLEL_RSYNC_COMMAND_OPTIONS -- "${rsync_commands[@]}" + "$GHE_PARALLEL_COMMAND" "${GHE_PARALLEL_RSYNC_COMMAND_OPTIONS[@]}" -- "${rsync_commands[@]}" else for c in "${rsync_commands[@]}"; do eval "$c" diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 23dbd63c3..af6c24a23 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -152,7 +152,7 @@ for file_list in $tempdir/*.rsync; do done if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - $GHE_PARALLEL_COMMAND $GHE_PARALLEL_RSYNC_COMMAND_OPTIONS -- "${rsync_commands[@]}" + "$GHE_PARALLEL_COMMAND" "${GHE_PARALLEL_RSYNC_COMMAND_OPTIONS[@]}" -- "${rsync_commands[@]}" else for c in "${rsync_commands[@]}"; do eval "$c" From 2273d84a1e463ec41f7154b3171be36c1fe150fc Mon Sep 17 00:00:00 2001 From: Krayon Date: Wed, 22 Mar 2023 02:11:24 +1100 Subject: [PATCH 1725/2421] Move readlink() so it can work --- share/github-backup-utils/ghe-backup-config | 44 ++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b812b6872..5eebd4b18 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -21,6 +21,28 @@ YELLOW='\033[0;33m' BLUE='\033[0;34m' NC='\033[0m' # No Colo# Logging display and formatting functions +# If we don't have a readlink command, parse ls -l output. +if ! type readlink 1>/dev/null 2>&1; then + readlink() { + local ret=0 f='' + while [ $# -gt 0 ]; do + f="$1" + shift 1 + + [ ! -e "$f" ] && [ ! -h "$f" ] && { + ret=1 + continue + } + + # shellcheck disable=SC2012 # In this specific scenario, this method is OK + f="$(ls -ld "$f")" + echo "${f//*-> /}" + done + + return $ret + } +fi + # Log a message to stdout log_level() { local level=$1 @@ -402,28 +424,6 @@ ghe_remote_version_config() { ############################################################################### ### Utility functions -# If we don't have a readlink command, parse ls -l output. -if ! type readlink 1>/dev/null 2>&1; then - readlink() { - local ret=0 f='' - while [ $# -gt 0 ]; do - f="$1" - shift 1 - - [ ! -e "$f" ] && [ ! -h "$f" ] && { - ret=1 - continue - } - - # shellcheck disable=SC2012 # In this specific scenario, this method is OK - f="$(ls -ld "$f")" - echo "${f//*-> /}" - done - - return $ret - } -fi - # Run ghe-host-check and establish the version of the remote GitHub instance in # the exported GHE_REMOTE_VERSION variable. If the remote version has already # been established then don't perform the host check again. Utilities in share/github-backup-utils From bfe8bfbcff312a9c542d84f316d6e887d922319b Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 21 Mar 2023 16:38:26 -0400 Subject: [PATCH 1726/2421] add in initial progress tracking code --- share/github-backup-utils/bm.sh | 2 ++ share/github-backup-utils/ghe-backup-config | 2 +- share/github-backup-utils/track-progress | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 share/github-backup-utils/track-progress diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index b714d144b..be64c03aa 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -57,4 +57,6 @@ bm_end() { if [ -n "$GHE_DEBUG" ]; then echo "Debug: $1 took ${total}s (bm_end)" fi + # track progress + progress "Completed $1 in ${total}s" } diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 65d4fe744..f46cbd26b 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -55,7 +55,7 @@ fi PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # shellcheck source=share/github-backup-utils/bm.sh . "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" - +. "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" # Save off GHE_HOSTNAME from the environment since we want it to override the # backup.config value when set. GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress new file mode 100755 index 000000000..8404db938 --- /dev/null +++ b/share/github-backup-utils/track-progress @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +#/ track-progress: track progress of backup or restore tasks + +# Current version is working solely with backups + +progress(){ +export BACKUP_PROGRESS=$((BACKUP_PROGRESS + 1)) + +BACKUP_PROGRESS_PERCENT=$(( (BACKUP_PROGRESS / BACKUP_PROGRESS_STEPS) * 100)) +export BACKUP_PROGRESS_DESCRIPTION="$1" +echo "Backup progress: $BACKUP_PROGRESS_PERCENT % - ($BACKUP_PROGRESS_DESCRIPTION))" + +} \ No newline at end of file From a786c031d4be5df8bf64945b66d302c1fa5bf3c3 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 21 Mar 2023 16:43:26 -0400 Subject: [PATCH 1727/2421] tweaking track-progress --- share/github-backup-utils/bm.sh | 2 +- share/github-backup-utils/ghe-backup-config | 2 +- share/github-backup-utils/track-progress | 7 ++----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index be64c03aa..197626248 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -58,5 +58,5 @@ bm_end() { echo "Debug: $1 took ${total}s (bm_end)" fi # track progress - progress "Completed $1 in ${total}s" + . "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" } diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index f46cbd26b..3f11a4e32 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -55,7 +55,7 @@ fi PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # shellcheck source=share/github-backup-utils/bm.sh . "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" -. "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" +#. "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" # Save off GHE_HOSTNAME from the environment since we want it to override the # backup.config value when set. GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 8404db938..0fc4930e1 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -3,11 +3,8 @@ # Current version is working solely with backups -progress(){ export BACKUP_PROGRESS=$((BACKUP_PROGRESS + 1)) -BACKUP_PROGRESS_PERCENT=$(( (BACKUP_PROGRESS / BACKUP_PROGRESS_STEPS) * 100)) -export BACKUP_PROGRESS_DESCRIPTION="$1" -echo "Backup progress: $BACKUP_PROGRESS_PERCENT % - ($BACKUP_PROGRESS_DESCRIPTION))" +BACKUP_PROGRESS_PERCENT=$(( (BACKUP_PROGRESS / BACKUP_PROGRESS_TOTAL) * 100)) -} \ No newline at end of file +echo "Backup progress: $BACKUP_PROGRESS_PERCENT %" \ No newline at end of file From 600d243f3106f26efbdb6cc901ed1dbdd14d41e8 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 21 Mar 2023 16:47:28 -0400 Subject: [PATCH 1728/2421] more tweaks --- bin/ghe-backup | 4 +++- share/github-backup-utils/track-progress | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 36cab279c..3692fbdc7 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -39,7 +39,9 @@ done export CALLING_SCRIPT="ghe-backup" export BACKUP_PROGRESS=0 # Used to track progress of backup -export BACKUP_PROGRESS_TOTAL=15 # Maximum number of steps in backup +echo "${BACKUP_PROGRESS}" > /tmp/progress +BACKUP_PROGRESS_TOTAL=15 # Maximum number of steps in backup +echo "${BACKUP_PROGRESS_TOTAL}" > /tmp/progress-total export BACKUP_PROGRESS_DESCRIPTION="" # Used to store information about current step # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 0fc4930e1..addbc94d4 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -3,8 +3,8 @@ # Current version is working solely with backups -export BACKUP_PROGRESS=$((BACKUP_PROGRESS + 1)) - +BACKUP_PROGRESS=$(($(cat /tmp/progress) + 1)) +BACKUP_PROGRESS=$(cat /tmp/progress-total) BACKUP_PROGRESS_PERCENT=$(( (BACKUP_PROGRESS / BACKUP_PROGRESS_TOTAL) * 100)) echo "Backup progress: $BACKUP_PROGRESS_PERCENT %" \ No newline at end of file From 390d49350e6e99cf7442010de33f2815e60ec9c7 Mon Sep 17 00:00:00 2001 From: Krayon Date: Thu, 23 Mar 2023 15:04:33 +1100 Subject: [PATCH 1729/2421] Removing readlink as it doesn't work and we require Ubuntu now --- share/github-backup-utils/ghe-backup-config | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 2683105fb..21a16ad35 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -143,6 +143,12 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ fi done +# If we don't have a readlink command, error out +[ ! type readlink 1>/dev/null 2>&1 ] && { + echo "Error: readlink not found. Please install readlink and ensure it is in your PATH." 1>&2 + exit 1 +} + GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore") GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup") @@ -401,17 +407,6 @@ ghe_remote_version_config() { ############################################################################### ### Utility functions -# If we don't have a readlink command, parse ls -l output. -if ! type readlink 1>/dev/null 2>&1; then - readlink() { - if [ -x "$1" ]; then - ls -ld "$1" | sed 's/.*-> //' - else - return 1 - fi - } -fi - # Run ghe-host-check and establish the version of the remote GitHub instance in # the exported GHE_REMOTE_VERSION variable. If the remote version has already # been established then don't perform the host check again. Utilities in share/github-backup-utils From 2e58c44c8e208f7606eddad710c142f8d1f108a3 Mon Sep 17 00:00:00 2001 From: Krayon Date: Thu, 23 Mar 2023 15:44:08 +1100 Subject: [PATCH 1730/2421] Typo --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 21a16ad35..0586e53dd 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -144,7 +144,7 @@ for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ done # If we don't have a readlink command, error out -[ ! type readlink 1>/dev/null 2>&1 ] && { +! type readlink 1>/dev/null 2>&1 && { echo "Error: readlink not found. Please install readlink and ensure it is in your PATH." 1>&2 exit 1 } From d2a566feb72c149ef430b2f274b8df4ad57c7d87 Mon Sep 17 00:00:00 2001 From: Krayon Date: Thu, 23 Mar 2023 23:18:33 +1100 Subject: [PATCH 1731/2421] No need to check for readlink if it's required --- share/github-backup-utils/ghe-backup-config | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 0586e53dd..1b8a7aa54 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -300,10 +300,9 @@ if [ -z "$GHE_DATA_DIR" ]; then fi # Convert the data directory path to an absolute path, basing any relative -# paths on the backup-utils root, and using readlink, if available, to -# canonicalize the path. +# paths on the backup-utils root, and use readlink to canonicalize the path. if [ "${GHE_DATA_DIR:0:1}" != "/" ]; then - GHE_DATA_DIR="$(cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR" 2>/dev/null || echo "$GHE_BACKUP_ROOT/$GHE_DATA_DIR")" + GHE_DATA_DIR="$(cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR")" fi export GHE_DATA_DIR From bba527bd6b5397c25a4cb2edea0ad5d45d266092 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 23 Mar 2023 19:41:01 +0000 Subject: [PATCH 1732/2421] Update transfer_size units --- bin/ghe-host-check | 6 +++--- share/github-backup-utils/ghe-rsync-size.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index ecf1a045a..77affa8c0 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -170,10 +170,10 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then actions_disk_size=$(transfer_size actions /tmp) mssql_disk_size=$(transfer_size mssql /tmp) - #min_disk_req=$(( $(echo "$repos_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$pages_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$es_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$stor_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$minio_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mysql_disk_size" | awk '{printf "%.0f", $1/2}') + $(echo "$actions_disk_size" | awk '{printf "%.0f", $1}') + $(echo "$mssql_disk_size" | awk '{printf "%.0f", $1}') )) min_disk_req=$(( $(echo "$repos_disk_size") + $(echo "$pages_disk_size") + $(echo "$es_disk_size") + $(echo "$stor_disk_size") + $(echo "$minio_disk_size") + $(echo "$mysql_disk_size") + $(echo "$actions_disk_size") + $(echo "$mssql_disk_size") )) -echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size \npages: $pages_disk_size \nelasticsearch: $es_disk_size \nstorage: $stor_disk_size \nminio: $minio_disk_size \nmysql: $mysql_disk_size \nactions: $actions_disk_size \nmssql: $mssql_disk_size" 1>&2 - printf "min_disk_required for this backup is at least %d MB\n" "$((min_disk_req / 1024 ** 2))" 1>&2 + + echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size MB\npages: $pages_disk_size MB\nelasticsearch: $es_disk_size MB\nstorage: $stor_disk_size MB\nminio: $minio_disk_size MB\nmysql: $mysql_disk_size MB\nactions: $actions_disk_size MB\nmssql: $mssql_disk_size MB" 1>&2 + printf "min_disk_required for this backup is at least %d MB\n" "$min_disk_req" 1>&2 if [[ $available_space -lt $min_disk_req ]]; then echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2 diff --git a/share/github-backup-utils/ghe-rsync-size.sh b/share/github-backup-utils/ghe-rsync-size.sh index 6f195c3f0..f8215a6b4 100755 --- a/share/github-backup-utils/ghe-rsync-size.sh +++ b/share/github-backup-utils/ghe-rsync-size.sh @@ -68,8 +68,8 @@ transfer_size() # Reduce mysql size as only the compressed file is transferred if [[ "$1" == "mysql" ]]; then - echo "$total_file_size" | awk '{printf "%.0f\n", $1/2}' + echo "$total_file_size" | awk '{if ($1 > 0) printf "%.0f\n", int(($1+999999.5)/2000000); else printf "0\n"}' else - echo "$total_file_size" | awk '{printf "%.0f\n", $1}' + echo "$total_file_size" | awk '{if ($1 > 0) printf "%.0f\n", int(($1+999999.5)/1000000); else printf "0\n"}' fi } From 8e3cfda6d6f86b6f608196f4445600c202ff20f2 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 23 Mar 2023 20:14:41 +0000 Subject: [PATCH 1733/2421] Tweak & typo --- bin/ghe-backup | 2 +- bin/ghe-host-check | 2 +- share/github-backup-utils/ghe-rsync-size.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 47fa9cddc..5696e9856 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -284,7 +284,7 @@ fi log_info "Checking for leaked ssh keys ..." ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true -log_info "Restore of $GHE_HOSTNAME finished." +log_info "Backup of $GHE_HOSTNAME finished." # Remove in-progress file ghe_backup_finished diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 77affa8c0..6137331fa 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -170,7 +170,7 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then actions_disk_size=$(transfer_size actions /tmp) mssql_disk_size=$(transfer_size mssql /tmp) - min_disk_req=$(( $(echo "$repos_disk_size") + $(echo "$pages_disk_size") + $(echo "$es_disk_size") + $(echo "$stor_disk_size") + $(echo "$minio_disk_size") + $(echo "$mysql_disk_size") + $(echo "$actions_disk_size") + $(echo "$mssql_disk_size") )) + min_disk_req=$(($repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size)) echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size MB\npages: $pages_disk_size MB\nelasticsearch: $es_disk_size MB\nstorage: $stor_disk_size MB\nminio: $minio_disk_size MB\nmysql: $mysql_disk_size MB\nactions: $actions_disk_size MB\nmssql: $mssql_disk_size MB" 1>&2 printf "min_disk_required for this backup is at least %d MB\n" "$min_disk_req" 1>&2 diff --git a/share/github-backup-utils/ghe-rsync-size.sh b/share/github-backup-utils/ghe-rsync-size.sh index f8215a6b4..65de3c3a7 100755 --- a/share/github-backup-utils/ghe-rsync-size.sh +++ b/share/github-backup-utils/ghe-rsync-size.sh @@ -61,7 +61,7 @@ transfer_size() total_file_size=$(ghe-rsync -arn --stats \ -e "ssh -q $GHE_EXTRA_SSH_OPTS -p 122 -l admin" \ --rsync-path="sudo -u $user rsync" \ - $link_dest/$1 \ + "$link_dest"/"$1" \ --ignore-missing-args \ "$GHE_HOSTNAME:$data_user_dir/" \ "$dest_dir/" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') From 2f9d5e092074d8387029ce504c896e05cf3d968d Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 23 Mar 2023 20:32:49 +0000 Subject: [PATCH 1734/2421] typo-2 --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 6137331fa..0c0fd83be 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -170,7 +170,7 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then actions_disk_size=$(transfer_size actions /tmp) mssql_disk_size=$(transfer_size mssql /tmp) - min_disk_req=$(($repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size)) + min_disk_req=$((repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size)) echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size MB\npages: $pages_disk_size MB\nelasticsearch: $es_disk_size MB\nstorage: $stor_disk_size MB\nminio: $minio_disk_size MB\nmysql: $mysql_disk_size MB\nactions: $actions_disk_size MB\nmssql: $mssql_disk_size MB" 1>&2 printf "min_disk_required for this backup is at least %d MB\n" "$min_disk_req" 1>&2 From 848154ada6182afc7749eeb53931a3e980c0ad59 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 23 Mar 2023 23:02:20 +0000 Subject: [PATCH 1735/2421] edits --- backup-verbose.log | 3670 +++++++++++++++++++ bin/ghe-backup | 5 +- share/github-backup-utils/bm.sh | 2 +- share/github-backup-utils/ghe-backup-config | 3 +- share/github-backup-utils/track-progress | 12 +- testfd | 0 6 files changed, 3681 insertions(+), 11 deletions(-) create mode 100644 backup-verbose.log create mode 100644 testfd diff --git a/backup-verbose.log b/backup-verbose.log new file mode 100644 index 000000000..bd430d973 --- /dev/null +++ b/backup-verbose.log @@ -0,0 +1,3670 @@ +2023-03-17T16:13:33Z INFO ghe-restore: +2023-03-17T16:13:33Z INFO ghe-restore-snapshot-path: +2023-03-17T16:13:33Z INFO ghe-detect-leaked-ssh-keys: +2023-03-17T16:13:33Z INFO ghe-host-check: 10.0.1.172 +2023-03-17T16:13:33Z INFO ghe-ssh: -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172 -- [ -f '/etc/github/cluster' ] +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172 -- cat /etc/github/repl-state +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- [ -f '/etc/github/configured' ] +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] +2023-03-17T16:13:34Z INFO ghe-restore-external-database-compatibility-check: +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- [ -f '/etc/github/configured' ] +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- [ -f '/etc/github/repl-state' ] +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- logger -t backup-utils +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- sudo sponge '/data/user/common/ghe-restore-status' >/dev/null +2023-03-17T16:13:34Z INFO ghe-maintenance-mode-status: 10.0.1.172:122 +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- test -e /data/github/current/public/system/maintenance.html +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --get core.package-version +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-17T16:13:34Z INFO ghe-backup-store-version: +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 +ghe-backup-store-version took 0s +2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- sudo service cron stop +2023-03-17T16:13:35Z INFO ghe-ssh: 10.0.1.172:122 -- systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null +2023-03-17T16:13:35Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/sh +mysql is running +Queued nomad job '/etc/nomad-jobs/elasticsearch/elasticsearch.hcl' +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo sponge '/data/user/common/uuid' 2>/dev/null +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo systemctl stop consul +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo rm -rf /data/user/consul/raft +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 ghe-config --true mysql.backup.binary +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-17T16:13:36Z INFO ghe-restore-mysql: 10.0.1.172:122 +Restoring password pepper ... +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/bash +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 ghe-config --true mysql.backup.binary +2023-03-17T16:13:36Z INFO ghe-restore-mysql-binary: 10.0.1.172:122 +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo mkdir -p '/data/user/tmp' +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo dd of=/data/user/tmp/mysql.sql.gz >/dev/null 2>&1 +2023-03-17T16:13:36Z INFO Restore MySQL database ... +2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/bash +Mar 17 16:13:36 Stop MySQL service +active +Stop MySQL via Nomad +==> 2023-03-17T16:13:36Z: Monitoring evaluation "e479e4cf" + 2023-03-17T16:13:36Z: Evaluation triggered by job "mysql" +==> 2023-03-17T16:13:37Z: Monitoring evaluation "e479e4cf" + 2023-03-17T16:13:37Z: Evaluation status changed: "pending" -> "complete" +==> 2023-03-17T16:13:37Z: Evaluation "e479e4cf" finished with status "complete" +Waiting for 60 seconds for mysql to completely shut down +mysql is not running +mysql is not running +Mar 17 16:13:37 Available space for data: 31079 (MB). Existing datadir: 794 (MB). Available ratio: 39 +Mar 17 16:13:37 Previous emergency copy /data/user/mysql-backup is deleted! +Mar 17 16:13:37 Existing MySQL directory backed up to /data/user/mysql-backup. If you need to restore from that, run "sudo rm -rf /data/user/mysql" and then "sudo mv /data/user/mysql-backup /data/user/mysql" +Mar 17 16:13:37 Purge MySQL folder +Mar 17 16:13:37 Extracting backup +Mar 17 16:13:38 Prepare backup +Mar 17 16:13:38 Using xtrabackup 2.4 for restore +Mar 17 16:13:43 Change owner to MySQL +Mar 17 16:13:43 Start MySQL service +Queued nomad job '/etc/nomad-jobs/mysql/mysql.hcl' +Wait nomad to start MySQL +MySQL is up running +Setup mysql after startup +Finish setup mysql after startup +Mar 17 16:13:59 MySQL service started +Mar 17 16:14:00 Restore succeeded +Mar 17 16:14:00 Emergency copy of /data/user/mysql is saved at /data/user/mysql-backup. After you are sure the restore was successful, please delete this copy +ghe-restore-mysql-binary took 24s +2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- sudo rm -rf /data/user/tmp/mysql.sql.gz +ghe-restore-mysql took 24s +2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true app.minio.enabled +2023-03-17T16:14:00Z INFO ghe-restore-minio: 10.0.1.172:122 +2023-03-17T16:14:00Z INFO * Transferring minio files to 10.0.1.172 ... +2023-03-17T16:14:00Z INFO ghe-ssh: -p 122 10.0.1.172 -- sudo mkdir -p /data/user/minio +2023-03-17T16:14:00Z INFO ghe-ssh: -p 122 10.0.1.172 -- sudo chown -R minio:minio /data/user/minio +2023-03-17T16:14:00Z RSYNC BEGIN: minio rsync +2023-03-17T16:14:00Z INFO ghe-rsync: --verbose --archive --hard-links --relative --delete --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync /workspace/backup-utils-private/data/20230316T212843/minio/./ 10.0.1.172:/data/user/minio/ +2023-03-17T16:14:00Z INFO ghe-ssh: -p 122 10.0.1.172 sudo -u minio rsync --server -vlHogDtprRe.iLsfxC --delete . /data/user/minio/ +sending incremental file list + +sent 94 bytes received 13 bytes 214.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-17T16:14:00Z RSYNC END: minio rsync +ghe-restore-minio took 0s +2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-import-authorized-keys +2023-03-17T16:14:00Z INFO ghe-restore-pages: 10.0.1.172:122 +2023-03-17T16:14:00Z INFO ghe-restore-es-rsync: 10.0.1.172:122 +2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-import-redis +2023-03-17T16:14:00Z INFO ghe-restore-repositories-gist: 10.0.1.172:122 +2023-03-17T16:14:00Z INFO ghe-restore-git-hooks: 10.0.1.172:122 +2023-03-17T16:14:00Z INFO ghe-restore-repositories: 10.0.1.172:122 +2023-03-17T16:14:00Z INFO ghe-restore-storage: 10.0.1.172:122 +2023-03-17T16:14:00Z WARN Warning: Pages backup missing. Skipping ... +2023-03-17T16:14:00Z WARN Warning: Storage backup missing. Skipping ... +2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- sudo mkdir -p '/data/user/elasticsearch-restore' +2023-03-17T16:14:00Z INFO ghe-ssh: -l admin 10.0.1.172:122 -- sudo -u git mkdir -p /data/user/git-hooks/repos +2023-03-17T16:14:00Z RSYNC BEGIN: git-hooks repos rsync +2023-03-17T16:14:00Z RSYNC END: git-hooks repos rsync +2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- sudo chown elasticsearch:elasticsearch '/data/user/elasticsearch-restore' +2023-03-17T16:14:00Z INFO ghe-rsync: -avH --delete -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync /workspace/backup-utils-private/data/20230316T212843/git-hooks/repos/ 10.0.1.172:/data/user/git-hooks/repos + --> Stopping redis... +2023-03-17T16:14:00Z RSYNC BEGIN: elasticsearch rsync +2023-03-17T16:14:00Z INFO ghe-rsync: -avz --delete -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --copy-dest=/data/user/elasticsearch /workspace/backup-utils-private/data/20230316T212843/elasticsearch/ 10.0.1.172:/data/user/elasticsearch-restore +2023-03-17T16:14:00Z INFO ghe-ssh: -p 122 10.0.1.172 sudo -u elasticsearch rsync --server -vlogDtprze.iLsfxC --delete --copy-dest /data/user/elasticsearch . /data/user/elasticsearch-restore +sending incremental file list +./ +deleting nodes/0/_state/node-0.st +deleting nodes/0/_state/global-3.st +deleting nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/state-0.st +deleting nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/segments_1 +deleting nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/state-3.st +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/state-0.st +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/segments_1 +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/state-0.st +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/segments_1 +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/state-0.st +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/segments_1 +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/state-0.st +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/segments_1 +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/state-0.st +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/segments_1 +deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/state-5.st +deleting nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/state-0.st +deleting nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/segments_1 +deleting nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/state-3.st +deleting nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/state-0.st +deleting nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/segments_1 +deleting nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/state-3.st +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/state-0.st +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/segments_1 +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/state-0.st +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/segments_1 +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/state-0.st +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/segments_1 +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/state-0.st +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/segments_1 +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/state-0.st +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/segments_1 +deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/state-5.st +deleting nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/state-0.st +deleting nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/segments_1 +deleting nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/state-3.st +deleting nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/state-0.st +deleting nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/segments_1 +deleting nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/state-3.st +deleting nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/state-0.st +deleting nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/segments_1 +deleting nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/state-3.st +deleting nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/state-0.st +deleting nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/segments_1 +deleting nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/state-3.st +deleting nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/state-0.st +deleting nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/segments_1 +deleting nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/state-3.st +deleting nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/state-0.st +deleting nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/segments_1 +deleting nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/state-5.st +deleting nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/state-0.st +deleting nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/segments_1 +deleting nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/state-3.st +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/state-0.st +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/segments_1 +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/state-0.st +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/segments_1 +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/state-0.st +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/segments_1 +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/state-0.st +deleting nodes/0/indices/ROa --> Importing SSH authorized keys... +Qi7QXRdOYoj6_dXARBQ/3/index/segments_1 +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/state-0.st +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/segments_1 +deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/state-5.st +deleting nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/state-0.st +deleting nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/segments_1 +deleting nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/state-3.st +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/state-0.st +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/segments_1 +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/state-0.st +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/segments_1 +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/state-0.st +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/segments_1 +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/state-0.st +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/segments_1 +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/state-0.st +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/segments_1 +deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/state-5.st +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/state-0.st +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/segments_1 +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/state-0.st +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/segments_1 +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/state-0.st +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/segments_3 +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/state-0.st +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/segments_1 +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/state-0.st +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/segments_1 +deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/state-5.st +deleting nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/state-0.st +deleting nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/segments_1 +deleting nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/state-3.st +deleting nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/state-0.st +deleting nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/segments_3 +deleting nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/state-3.st +deleting nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/state-0.st +deleting nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/segments_1 +deleting nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/state-3.st +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/state-0.st +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/segments_1 +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/state-0.st +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/segments_1 +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/state-0.st +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/segments_1 +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/state-0.st +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/segments_1 +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/state-0.st +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/segments_1 +deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/state-5.st +deleting nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/state-0.st +deleting nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/segments_1 +deleting nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/state-3.st +deleting nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/state-0.st +deleting nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/segments_1 +deleting nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/state-3.st +deleting nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/state-0.st +deleting nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/segments_3 +deleting nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/state-4.st +deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/state-0.st +deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_h +deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_7.si +deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_7.cfs +deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_7.cfe +deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-9.tlog +deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/state-4.st +deleting nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/state-0.st +deleting nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/segments_1 +deleting nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/state-3.st +deleting nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/state-0.st +deleting nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/segments_1 +deleting nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/state-3.st +deleting nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/state-0.st +deleting nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/segments_1 +deleting nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/state-3.st +nodes/0/ +nodes/0/_state/ +nodes/0/_state/global-5.st +nodes/0/_state/node-2.st +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/state-2.st +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/segments_3 +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog.ckp +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/state-9.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/state-2.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/segments_3 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/state-2.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/segments_3 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/state-2.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/segments_3 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/state-2.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/segments_3 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/state-2.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/segments_3 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/state-13.st +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/state-2.st +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/segments_3 +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog.ckp +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/state-9.st +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/state-2.st +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/segments_3 +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog.ckp +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/state-9.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/state-2.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/segments_3 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/state-2.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/segments_3 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/state-2.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/segments_3 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/state-2.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/segments_3 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/state-2.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/segments_3 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/state-13.st +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/state-2.st +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/segments_3 +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog.ckp +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/state-9.st +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/state-2.st +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/segments_3 +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog.ckp +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/state-9.st +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/state-2.st +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/segments_3 +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog.ckp +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/state-9.st +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/state-2.st +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/segments_3 +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog.ckp +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/state-9.st +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/state-2.st +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/segments_3 +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog.ckp +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/state-9.st +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/state-2.st +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/segments_3 +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog.ckp +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/state-11.st +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/state-2.st +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/segments_3 +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog.ckp +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/state-9.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/state-2.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/segments_3 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/state-2.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/segments_3 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/state-2.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/segments_3 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/state-2.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/segments_3 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/state-2.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/segments_3 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/state-13.st +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/state-2.st +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/segments_3 +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog.ckp +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/state-9.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/state-2.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/segments_3 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/state-2.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/segments_3 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/state-2.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/segments_3 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/state-2.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/segments_3 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/state-2.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/segments_3 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/state-13.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/state-2.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/segments_3 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/state-2.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/segments_3 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/state-2.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/segments_5 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/state-2.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/segments_3 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/state-2.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/segments_3 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/state-13.st +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/state-2.st +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/segments_3 +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog.ckp +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/state-9.st +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/state-2.st +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/segments_5 +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog-4.tlog +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog.ckp +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/state-9.st +nodes/0/indices/ejnFd11uQteAkjE995T2tw/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/state-2.st +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/segments_3 +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog.ckp +nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/state-9.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/state-2.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/segments_3 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/state-2.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/segments_3 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/state-2.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/segments_3 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/state-2.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/segments_3 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/state-2.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/segments_3 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/state-13.st +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/state-2.st +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/segments_3 +nodes/0/indices/kSoL8UdcRTy558OhM==> 2023-03-17T16:14:00Z: Monitoring evaluation "58730a17" + 2023-03-17T16:14:00Z: Evaluation triggered by job "redis" +RyvRw/0/translog/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog.ckp +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/state-9.st +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/state-2.st +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/segments_3 +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog.ckp +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/state-9.st +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/state-2.st +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/segments_5 +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog.ckp +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/state-10.st +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/state-2.st +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_g.cfe +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_g.cfs +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_g.si +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_v +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-18.tlog +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/state-10.st +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/state-2.st +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/segments_3 +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog.ckp +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/state-9.st +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/state-2.st +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/segments_3 +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog.ckp +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/state-9.st +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/state-2.st +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/segments_3 +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog.ckp +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/state-9.st + +sent 86,283 bytes received 13,126 bytes 198,818.00 bytes/sec +total size is 142,465 speedup is 1.43 +2023-03-17T16:14:00Z RSYNC END: elasticsearch rsync +ghe-restore-es-rsync took 0s +sending incremental file list + +sent 58 bytes received 12 bytes 140.00 bytes/sec +total size is 0 speedup is 0.00 +ghe-restore-git-hooks took 0s +==> 2023-03-17T16:14:01Z: Monitoring evaluation "58730a17" + 2023-03-17T16:14:01Z: Evaluation status changed: "pending" -> "complete" +==> 2023-03-17T16:14:01Z: Evaluation "58730a17" finished with status "complete" + --> Importing redis data... + --> Starting redis... +Queued nomad job '/etc/nomad-jobs/redis/redis.hcl' +Waiting for redis service +Status = running + --> Make sure redis is ready... + --> Remove stale resque worker entries... +2023-03-17T16:14:09Z INFO Restarting memcached ... +2023-03-17T16:14:09Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/sh +2023-03-17T16:14:09Z INFO Setting last run date for GitHub Connect jobs ... +2023-03-17T16:14:09Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/sh +2023-03-17T16:14:09Z INFO ghe-ssh: 10.0.1.172:122 -- sudo sponge '/data/user/common/ghe-restore-status' >/dev/null +2023-03-17T16:14:09Z INFO ghe-ssh: 10.0.1.172:122 -- sudo timeout 120s service cron start +2023-03-17T16:14:10Z INFO ghe-ssh: --clean +2023-03-17T16:14:10Z INFO Removing in-progress file ... +2023-03-21T20:40:04Z INFO ghe-backup +2023-03-21T20:40:04Z INFO ghe-host-check +2023-03-21T20:40:04Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh +2023-03-21T20:40:05Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] +2023-03-21T20:40:05Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state +2023-03-21T20:40:05Z INFO ghe-rsync-size.sh +2023-03-21T20:40:05Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ +2023-03-21T20:40:05Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ +2023-03-21T20:40:05Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ +2023-03-21T20:40:06Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ +2023-03-21T20:40:06Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ +2023-03-21T20:40:06Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ +2023-03-21T20:40:07Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ +2023-03-21T20:40:07Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ +2023-03-21T20:40:07Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-21T20:40:08Z INFO ghe-backup-strategy +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] +2023-03-21T20:40:08Z INFO ghe-backup-store-version +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 +ghe-backup-store-version took 0s +2023-03-21T20:40:08Z INFO ghe-backup-settings +2023-03-21T20:40:08Z INFO * Transferring settings data ... +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings +2023-03-21T20:40:08Z INFO * Transferring license data ... +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' +2023-03-21T20:40:08Z INFO * Transferring management console password ... +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage +2023-03-21T20:40:08Z INFO * Transferring password pepper ... +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets +2023-03-21T20:40:08Z INFO * Transferring kredz.credz HMAC key ... +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret +2023-03-21T20:40:08Z INFO * Transferring kredz.varz HMAC key ... +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret +2023-03-21T20:40:08Z INFO * Transferring management console argon2 secret ... +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null +2023-03-21T20:40:08Z INFO * Transferring CA certificates ... +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null +2023-03-21T20:40:08Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys +ghe-export-authorized-keys took 0s +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys +ghe-export-ssh-host-keys took 0s +2023-03-21T20:40:08Z INFO ghe-backup-mysql +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary +2023-03-21T20:40:08Z INFO ghe-backup-mysql-binary +2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +ghe-backup-mysql-binary took 3s +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled +2023-03-21T20:40:11Z INFO ghe-backup-minio +2023-03-21T20:40:11Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-21T20:40:11Z RSYNC BEGIN: minio rsync +2023-03-21T20:40:11Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230321T204004/minio +2023-03-21T20:40:11Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-21T20:40:11Z RSYNC END: minio rsync +ghe-backup-minio took 0s +2023-03-21T20:40:11Z INFO ghe-backup-es-audit-log +2023-03-21T20:40:11Z INFO ghe-backup-pages +2023-03-21T20:40:11Z INFO ghe-backup-repositories +2023-03-21T20:40:11Z INFO ghe-backup-storage +2023-03-21T20:40:11Z INFO ghe-backup-redis +2023-03-21T20:40:11Z INFO ghe-backup-es-rsync +2023-03-21T20:40:11Z INFO ghe-backup-git-hooks + +2023-03-21T20:40:11Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-21T20:40:11Z INFO * Transferring pages files ... +2023-03-21T20:40:11Z RSYNC BEGIN: pages rsync +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] +2023-03-21T20:40:11Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230321T204004/pages +2023-03-21T20:40:11Z INFO * Performing initial sync of ES indices ... +2023-03-21T20:40:11Z RSYNC BEGIN elasticsearch rsync +2023-03-21T20:40:11Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-21T20:40:11Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-21T20:40:11Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204004/elasticsearch +2023-03-21T20:40:11Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-21T20:40:11Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +2023-03-21T20:40:11Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +2023-03-21T20:40:11Z RSYNC BEGIN: git-hooks sync +ghe-backup-es-audit-log took 0s +2023-03-21T20:40:11Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230321T204004/git-hooks/repos +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +receiving incremental file list +./ +nodes/0/ +nodes/0/_state/ +nodes/0/_state/global-6.st +nodes/0/_state/node-3.st +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/state-3.st +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/segments_4 +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog-3.ckp +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog-4.tlog +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog.ckp +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/state-12.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/state-17.st +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/state-3.st +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/segments_4 +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog-3.ckp +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog-4.tlog +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog.ckp +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/state-12.st +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/state-3.st +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/segments_4 +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog-3.ckp +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog-4.tlog +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog.ckp +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/state-12.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/state-17.st +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/state-3.st +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/segments_4 +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog-3.ckp +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog-4.tlog +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog.ckp +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/state-12.st +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/state-3.st +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/segments_4 +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog-3.ckp +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog-4.tlog +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog.ckp +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/state-12.st +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/state-3.st +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/segments_4 +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog-3.ckp +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog-4.tlog +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog.ckp +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/state-12.st +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/state-3.st +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/segments_4 +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog-3.ckp +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog-4.tlog +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog.ckp +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/state-12.st +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/state-3.st +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/segments_4 +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog-3.ckp +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog-4.tlog +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog.ckp +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/state-12.st +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/state-3.st +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/segments_4 +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog-3.ckp +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog-4.tlog +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog.ckp +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/state-14.st +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/state-3.st +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/segments_4 +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog-3.ckp +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog-4.tlog +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog.ckp +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/state-12.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog-3.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog-3.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog-3.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog-3.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog-3.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/state-17.st +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/state-3.st +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/segments_4 +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog-3.ckp +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog-4.tlog +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog.ckp +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/state-12.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/state-17.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/segments_4 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog-3.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog-4.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/segments_4 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog-3.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog-4.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/segments_6 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog-4.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog-5.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/segments_4 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog-3.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog-4.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/segments_4 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog-3.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog-4.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/state-17.st +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/state-3.st +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/segments_4 +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog-3.ckp +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog-4.tlog +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog.ckp +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/state-12.st +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/state-3.st +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.cfe +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.cfs +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.si +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/segments_8 +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog-6.tlog +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog.ckp +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/state-12.st +nodes/0/indices/ejnFd11uQteAkjE995T2tw/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/state-3.st +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/segments_4 +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog-3.ckp +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog-4.tlog +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog.ckp +nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/state-12.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/state-17.st +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/state-3.st +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/segments_4 +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog-3.ckp +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog-4.tlog +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog.ckp +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/state-12.st +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/state-3.st +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/segments_4 +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog-3.ckp +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog-4.tlog +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog.ckp +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/state-12.st +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/state-3.st +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/segments_6 +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog-4.ckp +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog-5.tlog +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog.ckp +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/state-13.st +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/state-3.st +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.cfe +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.cfs +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.si +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_15 +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-24.tlog +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/state-13.st +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/state-3.st +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/segments_4 +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog-3.ckp +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog-4.tlog +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog.ckp +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/state-12.st +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/state-3.st +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/segments_4 +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog-3.ckp +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog-4.tlog +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog.ckp +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/state-12.st +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/state-3.st +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/segments_4 +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog-3.ckp +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog-4.tlog +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog.ckp +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/state-12.st + +sent 6,918 bytes received 97,851 bytes 209,538.00 bytes/sec +total size is 146,931 speedup is 1.40 +2023-03-21T20:40:11Z RSYNC END elasticsearch rsync +2023-03-21T20:40:11Z INFO * Disabling ES index flushing ... +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush +2023-03-21T20:40:11Z INFO * Performing follow-up sync of ES indices ... +2023-03-21T20:40:11Z RSYNC BEGIN: elasticsearch followup rsync +2023-03-21T20:40:11Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204004/elasticsearch +2023-03-21T20:40:11Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-21T20:40:11Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +receiving incremental file list + +sent 282 bytes received 22,566 bytes 45,696.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-21T20:40:11Z RSYNC END: elasticsearch followup rsync +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete +ghe-backup-es-rsync took 0s +2023-03-21T20:40:11Z INFO * Enabling ES index flushing ... +2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-21T20:40:11Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +ghe-backup-redis took 1s +2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-6nt2a6/remote_routes_list +ghe-backup-storage - Generating routes took 2s +2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-6nt2a6/remote_routes_list +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-21T20:40:13Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-6nt2a6 +2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-8O0hUx/remote_routes_list +ghe-backup-repositories - Generating routes took 2s +2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-8O0hUx/remote_routes_list +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s +2023-03-21T20:40:13Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-8O0hUx +2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-21T20:40:13Z INFO ghe-ssh --clean +2023-03-21T20:43:38Z INFO ghe-backup +2023-03-21T20:43:38Z INFO ghe-host-check +2023-03-21T20:43:38Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh +2023-03-21T20:43:39Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] +2023-03-21T20:43:39Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state +2023-03-21T20:43:39Z INFO ghe-rsync-size.sh +2023-03-21T20:43:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ +2023-03-21T20:43:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ +2023-03-21T20:43:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ +2023-03-21T20:43:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ +2023-03-21T20:43:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ +2023-03-21T20:43:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ +2023-03-21T20:43:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ +2023-03-21T20:43:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ +2023-03-21T20:43:41Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-21T20:43:41Z INFO ghe-backup-strategy +2023-03-21T20:43:41Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] +2023-03-21T20:43:41Z INFO ghe-backup-store-version +2023-03-21T20:43:41Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 +ghe-backup-store-version took 1s +2023-03-21T20:43:42Z INFO ghe-backup-settings +2023-03-21T20:43:42Z INFO * Transferring settings data ... +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings +2023-03-21T20:43:42Z INFO * Transferring license data ... +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' +2023-03-21T20:43:42Z INFO * Transferring management console password ... +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage +2023-03-21T20:43:42Z INFO * Transferring password pepper ... +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets +2023-03-21T20:43:42Z INFO * Transferring kredz.credz HMAC key ... +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret +2023-03-21T20:43:42Z INFO * Transferring kredz.varz HMAC key ... +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret +2023-03-21T20:43:42Z INFO * Transferring management console argon2 secret ... +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null +2023-03-21T20:43:42Z INFO * Transferring CA certificates ... +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null +2023-03-21T20:43:42Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys +ghe-export-authorized-keys took 0s +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys +ghe-export-ssh-host-keys took 0s +2023-03-21T20:43:42Z INFO ghe-backup-mysql +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary +2023-03-21T20:43:42Z INFO ghe-backup-mysql-binary +2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +ghe-backup-mysql-binary took 3s +ghe-backup-mysql took 3s +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled +2023-03-21T20:43:45Z INFO ghe-backup-minio +2023-03-21T20:43:45Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-21T20:43:45Z RSYNC BEGIN: minio rsync +2023-03-21T20:43:45Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230321T204338/minio +2023-03-21T20:43:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-21T20:43:45Z RSYNC END: minio rsync +ghe-backup-minio took 0s +Backup progress: 0 % +2023-03-21T20:43:45Z INFO ghe-backup-es-audit-log +2023-03-21T20:43:45Z INFO ghe-backup-storage +2023-03-21T20:43:45Z INFO ghe-backup-pages +2023-03-21T20:43:45Z INFO ghe-backup-repositories +2023-03-21T20:43:45Z INFO ghe-backup-redis +2023-03-21T20:43:45Z INFO ghe-backup-git-hooks +2023-03-21T20:43:45Z INFO ghe-backup-es-rsync + +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" +2023-03-21T20:43:45Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] +2023-03-21T20:43:45Z INFO * Transferring pages files ... +2023-03-21T20:43:45Z RSYNC BEGIN: pages rsync +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] +2023-03-21T20:43:45Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230321T204338/pages +2023-03-21T20:43:45Z INFO * Performing initial sync of ES indices ... +2023-03-21T20:43:45Z RSYNC BEGIN elasticsearch rsync +2023-03-21T20:43:45Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-21T20:43:45Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-21T20:43:45Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-21T20:43:45Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204338/elasticsearch +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-21T20:43:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +2023-03-21T20:43:45Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +2023-03-21T20:43:45Z RSYNC BEGIN: git-hooks sync +2023-03-21T20:43:45Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230321T204338/git-hooks/repos +receiving incremental file list +./ +nodes/0/ +nodes/0/_state/ +nodes/0/_state/global-6.st +nodes/0/_state/node-3.st +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/state-3.st +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/segments_4 +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog-3.ckp +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog-4.tlog +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog.ckp +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/ +nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/state-12.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/state-3.st +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/segments_4 +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog-3.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog-4.tlog +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog.ckp +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/ +nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/state-17.st +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/state-3.st +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/segments_4 +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog-3.ckp +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog-4.tlog +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog.ckp +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/ +nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/state-12.st +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/state-3.st +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/segments_4 +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog-3.ckp +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog-4.tlog +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog.ckp +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/ +nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/state-12.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/state-3.st +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/segments_4 +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog-3.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog-4.tlog +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog.ckp +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/ +nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/state-17.st +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/state-3.st +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/segments_4 +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog-3.ckp +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog-4.tlog +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog.ckp +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/ +nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/state-12.st +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/state-3.st +nodes/2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/segments_4 +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog-3.ckp +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog-4.tlog +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog.ckp +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/ +nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/state-12.st +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/state-3.st +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/segments_4 +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog-3.ckp +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog-4.tlog +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog.ckp +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/ +nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/state-12.st +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/state-3.st +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/segments_4 +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog-3.ckp +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog-4.tlog +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog.ckp +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/ +nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/state-12.st +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/state-3.st +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/segments_4 +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog-3.ckp +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog-4.tlog +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog.ckp +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/ +nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/state-12.st +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/state-3.st +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/segments_4 +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog-3.ckp +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog-4.tlog +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog.ckp +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/ +nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/state-14.st +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/state-3.st +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/segments_4 +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog-3.ckp +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog-4.tlog +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog.ckp +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/ +nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/state-12.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog-3.ckp +node2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +s/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog-3.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog-3.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog-3.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/state-3.st +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/segments_4 +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog-3.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog-4.tlog +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog.ckp +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/ +nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/state-17.st +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/state-3.st +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/segments_4 +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog-3.ckp +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog-4.tlog +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog.ckp +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/ +nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/state-12.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/state-3.st +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/segments_4 +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog-3.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog-4.tlog +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog.ckp +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/ +nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/state-17.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/segments_4 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog-3.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog-4.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/segments_4 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog-3.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog-4.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/segments_6 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog-4.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog-5.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/segments_4 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog-3.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog-4.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/state-3.st +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/segments_4 +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog-3.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog-4.tlog +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog.ckp +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/ +nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/state-17.st +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/state-3.st +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/segments_4 +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog-3.ckp +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog-4.tlog +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog.ckp +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/ +nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/state-12.st +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/state-3.st +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.cfe +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.cfs +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.si +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/segments_8 +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog-6.tlog +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog.ckp +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/ +nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/state-12.st +nodes/0/indices/ejnFd11uQteAkjE995T2tw/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/state-3.st +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/segments_4 +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog-3.ckp +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog-4.tlog +nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog.ckp +nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/ +nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/state-12.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/state-3.st +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/segments_4 +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog-3.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog-4.tlog +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog.ckp +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/ +nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/state-17.st +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/state-3.st +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/segments_4 +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog-3.ckp +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog-4.tlog +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog.ckp +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/ +nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/state-12.st +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/state-3.st +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/segments_4 +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog-3.ckp +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog-4.tlog +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog.ckp +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/ +nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/state-12.st +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/state-3.st +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/segments_6 +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog-4.ckp +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog-5.tlog +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog.ckp +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/ +nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/state-13.st +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/state-3.st +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.cfe +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.cfs +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.si +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_15 +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-24.tlog +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/state-13.st +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/state-3.st +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/segments_4 +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog-3.ckp +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog-4.tlog +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog.ckp +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/ +nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/state-12.st +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/state-3.st +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/segments_4 +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog-3.ckp +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog-4.tlog +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog.ckp +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/ +nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/state-12.st +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/state-3.st +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/segments_4 +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog-3.ckp +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog-4.tlog +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog.ckp +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/ +nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/state-12.st + +sent 6,918 bytes received 97,851 bytes 209,538.00 bytes/sec +total size is 146,931 speedup is 1.40 +2023-03-21T20:43:45Z RSYNC END elasticsearch rsync +2023-03-21T20:43:45Z INFO * Disabling ES index flushing ... +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush +2023-03-21T20:43:45Z INFO * Performing follow-up sync of ES indices ... +2023-03-21T20:43:45Z RSYNC BEGIN: elasticsearch followup rsync +2023-03-21T20:43:45Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204338/elasticsearch +2023-03-21T20:43:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +receiving incremental file list + +sent 286 bytes received 22,570 bytes 45,712.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-21T20:43:45Z RSYNC END: elasticsearch followup rsync +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-21T20:43:45Z RSYNC END: pages rsync +ghe-backup-es-rsync took 0s +2023-03-21T20:43:45Z INFO * Enabling ES index flushing ... +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-21T20:43:45Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +ghe-backup-redis took 1s +2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-QwYGTC/remote_routes_list +ghe-backup-storage - Generating routes took 2s +2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-QwYGTC/remote_routes_list +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-21T20:43:47Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-QwYGTC +2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-Jrpjeh/remote_routes_list +ghe-backup-repositories - Generating routes took 2s +2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-Jrpjeh/remote_routes_list +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s +2023-03-21T20:43:47Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-Jrpjeh +2023-03-21T20:43:47Z INFO ghe-prune-snapshots +2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-21T20:43:47Z INFO ghe-detect-leaked-ssh-keys +2023-03-21T20:43:47Z INFO ghe-ssh --clean +2023-03-21T20:47:38Z INFO ghe-backup +2023-03-21T20:47:38Z INFO ghe-host-check +2023-03-21T20:47:38Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh +2023-03-21T20:47:39Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] +2023-03-21T20:47:39Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state +2023-03-21T20:47:39Z INFO ghe-rsync-size.sh +2023-03-21T20:47:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ +2023-03-21T20:47:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ +2023-03-21T20:47:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ +2023-03-21T20:47:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ +2023-03-21T20:47:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ +2023-03-21T20:47:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ +2023-03-21T20:47:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ +2023-03-21T20:47:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-21T20:47:42Z INFO ghe-backup-strategy +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] +2023-03-21T20:47:42Z INFO ghe-backup-store-version +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 +ghe-backup-store-version took 0s +2023-03-21T20:47:42Z INFO ghe-backup-settings +2023-03-21T20:47:42Z INFO * Transferring settings data ... +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings +2023-03-21T20:47:42Z INFO * Transferring license data ... +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' +2023-03-21T20:47:42Z INFO * Transferring management console password ... +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage +2023-03-21T20:47:42Z INFO * Transferring password pepper ... +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets +2023-03-21T20:47:42Z INFO * Transferring kredz.credz HMAC key ... +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret +2023-03-21T20:47:42Z INFO * Transferring kredz.varz HMAC key ... +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret +2023-03-21T20:47:42Z INFO * Transferring management console argon2 secret ... +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null +2023-03-21T20:47:42Z INFO * Transferring CA certificates ... +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null +2023-03-21T20:47:42Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys +ghe-export-authorized-keys took 0s +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys +ghe-export-ssh-host-keys took 0s +2023-03-21T20:47:42Z INFO ghe-backup-mysql +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary +2023-03-21T20:47:42Z INFO ghe-backup-mysql-binary +2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +ghe-backup-mysql-binary took 3s +ghe-backup-mysql took 3s +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled +2023-03-21T20:47:45Z INFO ghe-backup-minio +2023-03-21T20:47:45Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-21T20:47:45Z RSYNC BEGIN: minio rsync +2023-03-21T20:47:45Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230321T204738/minio +2023-03-21T20:47:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-21T20:47:45Z RSYNC END: minio rsync +ghe-backup-minio took 0s +Backup progress: % +2023-03-21T20:47:45Z INFO ghe-backup-es-audit-log +2023-03-21T20:47:45Z INFO ghe-backup-es-rsync +2023-03-21T20:47:45Z INFO ghe-backup-git-hooks +2023-03-21T20:47:45Z INFO ghe-backup-repositories +2023-03-21T20:47:45Z INFO ghe-backup-redis +2023-03-21T20:47:45Z INFO ghe-backup-storage +2023-03-21T20:47:45Z INFO ghe-backup-pages + +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-21T20:47:45Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" +2023-03-21T20:47:45Z INFO * Transferring pages files ... +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] +2023-03-21T20:47:45Z RSYNC BEGIN: pages rsync +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] +2023-03-21T20:47:45Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230321T204738/pages +2023-03-21T20:47:45Z INFO * Performing initial sync of ES indices ... +2023-03-21T20:47:45Z RSYNC BEGIN elasticsearch rsync +2023-03-21T20:47:45Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-21T20:47:45Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204738/elasticsearch +2023-03-21T20:47:45Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-21T20:47:45Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-21T20:47:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +2023-03-21T20:47:45Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +2023-03-21T20:47:45Z RSYNC BEGIN: git-hooks sync +2023-03-21T20:47:45Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230321T204738/git-hooks/repos +receiving incremental file list +./ + +sent 289 bytes received 22,573 bytes 45,724.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-21T20:47:45Z RSYNC END elasticsearch rsync +2023-03-21T20:47:45Z INFO * Disabling ES index flushing ... +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush +2023-03-21T20:47:45Z INFO * Performing follow-up sync of ES indices ... +2023-03-21T20:47:45Z RSYNC BEGIN: elasticsearch followup rsync +2023-03-21T20:47:45Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204738/elasticsearch +2023-03-21T20:47:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +receiving incremental file list + +sent 282 bytes received 22,566 bytes 45,696.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-21T20:47:45Z RSYNC END: elasticsearch followup rsync +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete +ghe-backup-es-rsync took 0s +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-21T20:47:45Z RSYNC END: pages rsync +2023-03-21T20:47:45Z INFO * Enabling ES index flushing ... +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-21T20:47:45Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +ghe-backup-redis took 1s +2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-VGilqT/remote_routes_list +ghe-backup-storage - Generating routes took 2s +2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-VGilqT/remote_routes_list +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-21T20:47:47Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-VGilqT +2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-if4Tbi/remote_routes_list +ghe-backup-repositories - Generating routes took 2s +2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-if4Tbi/remote_routes_list +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s +2023-03-21T20:47:47Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-if4Tbi +2023-03-21T20:47:47Z INFO ghe-prune-snapshots +2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-21T20:47:47Z INFO ghe-detect-leaked-ssh-keys +2023-03-21T20:47:48Z INFO ghe-ssh --clean +2023-03-22T18:31:55Z INFO ghe-backup +2023-03-22T18:31:55Z INFO ghe-host-check +2023-03-22T18:31:55Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh +2023-03-22T18:31:55Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] +2023-03-22T18:31:55Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state +2023-03-22T18:31:55Z INFO ghe-rsync-size.sh +2023-03-22T18:31:55Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ +2023-03-22T18:31:56Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ +2023-03-22T18:31:56Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ +2023-03-22T18:31:56Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ +2023-03-22T18:31:56Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ +2023-03-22T18:31:57Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ +2023-03-22T18:31:57Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ +2023-03-22T18:31:57Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-22T18:31:58Z INFO ghe-backup-strategy +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] +2023-03-22T18:31:58Z INFO ghe-backup-store-version +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 +ghe-backup-store-version took 0s +2023-03-22T18:31:58Z INFO ghe-backup-settings +2023-03-22T18:31:58Z INFO * Transferring settings data ... +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings +2023-03-22T18:31:58Z INFO * Transferring license data ... +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' +2023-03-22T18:31:58Z INFO * Transferring management console password ... +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage +2023-03-22T18:31:58Z INFO * Transferring password pepper ... +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets +2023-03-22T18:31:58Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret +2023-03-22T18:31:58Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret +2023-03-22T18:31:58Z INFO * Transferring management console argon2 secret ... +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null +2023-03-22T18:31:58Z INFO * Transferring CA certificates ... +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates +2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null +2023-03-22T18:31:58Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys +ghe-export-authorized-keys took 1s +2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys +ghe-export-ssh-host-keys took 0s +2023-03-22T18:31:59Z INFO ghe-backup-mysql +2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary +2023-03-22T18:31:59Z INFO ghe-backup-mysql-binary +2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +ghe-backup-mysql-binary took 2s +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled +2023-03-22T18:32:01Z INFO ghe-backup-minio +2023-03-22T18:32:01Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T18:32:01Z RSYNC BEGIN: minio rsync +2023-03-22T18:32:01Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230322T183155/minio +2023-03-22T18:32:01Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:32:01Z RSYNC END: minio rsync +ghe-backup-minio took 0s +2023-03-22T18:32:01Z INFO ghe-backup-es-audit-log +2023-03-22T18:32:01Z INFO ghe-backup-redis +2023-03-22T18:32:01Z INFO ghe-backup-es-rsync +2023-03-22T18:32:01Z INFO ghe-backup-repositories +2023-03-22T18:32:01Z INFO ghe-backup-pages +2023-03-22T18:32:01Z INFO ghe-backup-storage +2023-03-22T18:32:01Z INFO ghe-backup-git-hooks + +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-22T18:32:01Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" +2023-03-22T18:32:01Z INFO * Transferring pages files ... +2023-03-22T18:32:01Z RSYNC BEGIN: pages rsync +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] +2023-03-22T18:32:01Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230322T183155/pages +2023-03-22T18:32:01Z INFO * Performing initial sync of ES indices ... +2023-03-22T18:32:01Z RSYNC BEGIN elasticsearch rsync +2023-03-22T18:32:01Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T18:32:01Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-22T18:32:01Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-22T18:32:01Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183155/elasticsearch +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:32:01Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +2023-03-22T18:32:01Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +ghe-backup-es-audit-log took 0s +2023-03-22T18:32:01Z RSYNC BEGIN: git-hooks sync +2023-03-22T18:32:01Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230322T183155/git-hooks/repos +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +receiving incremental file list +./ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.cfe +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.cfs +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.si +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_17 +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-25.tlog +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp + +sent 422 bytes received 24,766 bytes 50,376.00 bytes/sec +total size is 146,931 speedup is 5.83 +2023-03-22T18:32:01Z RSYNC END elasticsearch rsync +2023-03-22T18:32:01Z INFO * Disabling ES index flushing ... +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush +2023-03-22T18:32:01Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T18:32:01Z RSYNC BEGIN: elasticsearch followup rsync +2023-03-22T18:32:01Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183155/elasticsearch +2023-03-22T18:32:01Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +receiving incremental file list + +sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:32:01Z RSYNC END: elasticsearch followup rsync +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:32:01Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-es-rsync took 0s +ghe-backup-pages took 0s +2023-03-22T18:32:01Z INFO * Enabling ES index flushing ... +2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 56.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:32:02Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 1s +ghe-backup-redis took 1s +2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-B2RYgJ/remote_routes_list +ghe-backup-storage - Generating routes took 2s +2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-B2RYgJ/remote_routes_list +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T18:32:03Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-B2RYgJ +2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-xj3iWS/remote_routes_list +ghe-backup-repositories - Generating routes took 2s +2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-xj3iWS/remote_routes_list +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s +2023-03-22T18:32:03Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-xj3iWS +2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-22T18:32:04Z INFO ghe-ssh --clean +2023-03-22T18:33:39Z INFO ghe-backup +2023-03-22T18:33:39Z INFO ghe-host-check +2023-03-22T18:33:39Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh +2023-03-22T18:33:40Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] +2023-03-22T18:33:40Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state +2023-03-22T18:33:40Z INFO ghe-rsync-size.sh +2023-03-22T18:33:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ +2023-03-22T18:33:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ +2023-03-22T18:33:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ +2023-03-22T18:33:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ +2023-03-22T18:33:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ +2023-03-22T18:33:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ +2023-03-22T18:33:42Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ +2023-03-22T18:33:42Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-22T18:33:43Z INFO ghe-backup-strategy +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] +2023-03-22T18:33:43Z INFO ghe-backup-store-version +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 +ghe-backup-store-version took 0s +2023-03-22T18:33:43Z INFO ghe-backup-settings +2023-03-22T18:33:43Z INFO * Transferring settings data ... +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings +2023-03-22T18:33:43Z INFO * Transferring license data ... +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' +2023-03-22T18:33:43Z INFO * Transferring management console password ... +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage +2023-03-22T18:33:43Z INFO * Transferring password pepper ... +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets +2023-03-22T18:33:43Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret +2023-03-22T18:33:43Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret +2023-03-22T18:33:43Z INFO * Transferring management console argon2 secret ... +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null +2023-03-22T18:33:43Z INFO * Transferring CA certificates ... +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null +2023-03-22T18:33:43Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys +ghe-export-authorized-keys took 0s +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys +ghe-export-ssh-host-keys took 0s +2023-03-22T18:33:43Z INFO ghe-backup-mysql +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary +2023-03-22T18:33:43Z INFO ghe-backup-mysql-binary +2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +ghe-backup-mysql-binary took 3s +ghe-backup-mysql took 3s +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled +2023-03-22T18:33:46Z INFO ghe-backup-minio +2023-03-22T18:33:46Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T18:33:46Z RSYNC BEGIN: minio rsync +2023-03-22T18:33:46Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230322T183339/minio +2023-03-22T18:33:46Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:33:46Z RSYNC END: minio rsync +ghe-backup-minio took 0s +Backup progress: 0 % +2023-03-22T18:33:46Z INFO ghe-backup-pages +2023-03-22T18:33:46Z INFO ghe-backup-es-audit-log +2023-03-22T18:33:46Z INFO ghe-backup-redis +2023-03-22T18:33:46Z INFO ghe-backup-git-hooks +2023-03-22T18:33:46Z INFO ghe-backup-es-rsync +2023-03-22T18:33:46Z INFO ghe-backup-storage +2023-03-22T18:33:46Z INFO ghe-backup-repositories + +2023-03-22T18:33:46Z INFO * Starting backup for host: 10.0.1.172 +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 /bin/bash + +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" +2023-03-22T18:33:46Z INFO * Transferring pages files ... +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] +2023-03-22T18:33:46Z RSYNC BEGIN: pages rsync +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] +2023-03-22T18:33:46Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230322T183339/pages +2023-03-22T18:33:46Z INFO * Performing initial sync of ES indices ... +2023-03-22T18:33:46Z RSYNC BEGIN elasticsearch rsync +2023-03-22T18:33:46Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T18:33:46Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-22T18:33:46Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-22T18:33:46Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183339/elasticsearch +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:33:46Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +2023-03-22T18:33:46Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +2023-03-22T18:33:46Z RSYNC BEGIN: git-hooks sync +ghe-backup-es-audit-log took 0s +2023-03-22T18:33:46Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230322T183339/git-hooks/repos +receiving incremental file list +./ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.cfe +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.cfs +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.si +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_17 +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-25.tlog +nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp + +sent 422 bytes received 24,766 bytes 50,376.00 bytes/sec +total size is 146,931 speedup is 5.83 +2023-03-22T18:33:46Z RSYNC END elasticsearch rsync +2023-03-22T18:33:46Z INFO * Disabling ES index flushing ... +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush +2023-03-22T18:33:46Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T18:33:46Z RSYNC BEGIN: elasticsearch followup rsync +2023-03-22T18:33:46Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183339/elasticsearch +2023-03-22T18:33:46Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +receiving incremental file list + +sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:33:46Z RSYNC END: elasticsearch followup rsync +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:33:46Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +ghe-backup-es-rsync took 0s +2023-03-22T18:33:46Z INFO * Enabling ES index flushing ... +2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:33:46Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +ghe-backup-redis took 1s +2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-KShrXb/remote_routes_list +ghe-backup-storage - Generating routes took 2s +2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-KShrXb/remote_routes_list +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T18:33:48Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-KShrXb +2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-3jxmPX/remote_routes_list +ghe-backup-repositories - Generating routes took 2s +2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-3jxmPX/remote_routes_list +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s +2023-03-22T18:33:48Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-3jxmPX +2023-03-22T18:33:48Z INFO ghe-prune-snapshots +2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-22T18:33:48Z INFO ghe-detect-leaked-ssh-keys +2023-03-22T18:33:48Z INFO ghe-ssh --clean +2023-03-22T18:35:49Z INFO ghe-backup +2023-03-22T18:35:49Z INFO ghe-host-check +2023-03-22T18:35:49Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh +2023-03-22T18:35:49Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] +2023-03-22T18:35:49Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state +2023-03-22T18:35:49Z INFO ghe-rsync-size.sh +2023-03-22T18:35:49Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ +2023-03-22T18:35:49Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ +2023-03-22T18:35:50Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ +2023-03-22T18:35:50Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ +2023-03-22T18:35:50Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ +2023-03-22T18:35:51Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ +2023-03-22T18:35:51Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ +2023-03-22T18:35:51Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-22T18:35:52Z INFO ghe-backup-strategy +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] +2023-03-22T18:35:52Z INFO ghe-backup-store-version +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 +ghe-backup-store-version took 0s +2023-03-22T18:35:52Z INFO ghe-backup-settings +2023-03-22T18:35:52Z INFO * Transferring settings data ... +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings +2023-03-22T18:35:52Z INFO * Transferring license data ... +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' +2023-03-22T18:35:52Z INFO * Transferring management console password ... +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage +2023-03-22T18:35:52Z INFO * Transferring password pepper ... +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets +2023-03-22T18:35:52Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret +2023-03-22T18:35:52Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret +2023-03-22T18:35:52Z INFO * Transferring management console argon2 secret ... +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null +2023-03-22T18:35:52Z INFO * Transferring CA certificates ... +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates +2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null +2023-03-22T18:35:52Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys +ghe-export-authorized-keys took 1s +2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys +ghe-export-ssh-host-keys took 0s +2023-03-22T18:35:53Z INFO ghe-backup-mysql +2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary +2023-03-22T18:35:53Z INFO ghe-backup-mysql-binary +2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +ghe-backup-mysql-binary took 2s +ghe-backup-mysql took 2s +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled +2023-03-22T18:35:55Z INFO ghe-backup-minio +2023-03-22T18:35:55Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T18:35:55Z RSYNC BEGIN: minio rsync +2023-03-22T18:35:55Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230322T183549/minio +2023-03-22T18:35:55Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:35:55Z RSYNC END: minio rsync +ghe-backup-minio took 0s +Backup progress: 0 % +2023-03-22T18:35:55Z INFO ghe-backup-git-hooks +2023-03-22T18:35:55Z INFO ghe-backup-repositories +2023-03-22T18:35:55Z INFO ghe-backup-pages +2023-03-22T18:35:55Z INFO ghe-backup-storage +2023-03-22T18:35:55Z INFO ghe-backup-redis +2023-03-22T18:35:55Z INFO ghe-backup-es-audit-log +2023-03-22T18:35:55Z INFO ghe-backup-es-rsync + +2023-03-22T18:35:55Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T18:35:55Z INFO * Transferring pages files ... +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-22T18:35:55Z RSYNC BEGIN: pages rsync +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] +2023-03-22T18:35:55Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230322T183549/pages +2023-03-22T18:35:55Z INFO * Performing initial sync of ES indices ... +2023-03-22T18:35:55Z RSYNC BEGIN elasticsearch rsync +2023-03-22T18:35:55Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T18:35:55Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-22T18:35:55Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-22T18:35:55Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183549/elasticsearch +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:35:55Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +2023-03-22T18:35:55Z RSYNC BEGIN: git-hooks sync +2023-03-22T18:35:55Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +2023-03-22T18:35:55Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230322T183549/git-hooks/repos +receiving incremental file list +./ + +sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:35:55Z RSYNC END elasticsearch rsync +2023-03-22T18:35:55Z INFO * Disabling ES index flushing ... +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush +2023-03-22T18:35:55Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T18:35:55Z RSYNC BEGIN: elasticsearch followup rsync +2023-03-22T18:35:55Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183549/elasticsearch +2023-03-22T18:35:55Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +receiving incremental file list + +sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:35:55Z RSYNC END: elasticsearch followup rsync +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:35:55Z RSYNC END: pages rsync +ghe-backup-es-rsync took 0s +ghe-backup-pages - 10.0.1.172 took 0s +2023-03-22T18:35:55Z INFO * Enabling ES index flushing ... +ghe-backup-pages took 0s +2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 56.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:35:56Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 1s +ghe-backup-redis took 1s +2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-vwdhR7/remote_routes_list +ghe-backup-storage - Generating routes took 2s +2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-vwdhR7/remote_routes_list +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T18:35:57Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-vwdhR7 +2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-bT5RMf/remote_routes_list +ghe-backup-repositories - Generating routes took 2s +2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-bT5RMf/remote_routes_list +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s +2023-03-22T18:35:57Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-bT5RMf +2023-03-22T18:35:58Z INFO ghe-prune-snapshots +2023-03-22T18:35:58Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-22T18:35:58Z INFO ghe-detect-leaked-ssh-keys +2023-03-22T18:35:58Z INFO ghe-ssh --clean +2023-03-22T18:36:34Z INFO ghe-backup +2023-03-22T18:36:34Z INFO ghe-host-check +2023-03-22T18:36:34Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh +2023-03-22T18:36:34Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] +2023-03-22T18:36:34Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state +2023-03-22T18:36:34Z INFO ghe-rsync-size.sh +2023-03-22T18:36:34Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ +2023-03-22T18:36:35Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ +2023-03-22T18:36:35Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ +2023-03-22T18:36:35Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ +2023-03-22T18:36:36Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ +2023-03-22T18:36:36Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ +2023-03-22T18:36:36Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ +2023-03-22T18:36:37Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-22T18:36:37Z INFO ghe-backup-strategy +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] +2023-03-22T18:36:37Z INFO ghe-backup-store-version +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 +ghe-backup-store-version took 0s +2023-03-22T18:36:37Z INFO ghe-backup-settings +2023-03-22T18:36:37Z INFO * Transferring settings data ... +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings +2023-03-22T18:36:37Z INFO * Transferring license data ... +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' +2023-03-22T18:36:37Z INFO * Transferring management console password ... +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage +2023-03-22T18:36:37Z INFO * Transferring password pepper ... +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets +2023-03-22T18:36:37Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret +2023-03-22T18:36:37Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret +2023-03-22T18:36:37Z INFO * Transferring management console argon2 secret ... +2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null +2023-03-22T18:36:38Z INFO * Transferring CA certificates ... +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null +2023-03-22T18:36:38Z INFO * Transferring UUID ... +ghe-backup-settings took 1s +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys +ghe-export-authorized-keys took 0s +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys +ghe-export-ssh-host-keys took 0s +2023-03-22T18:36:38Z INFO ghe-backup-mysql +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary +2023-03-22T18:36:38Z INFO ghe-backup-mysql-binary +2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +ghe-backup-mysql-binary took 2s +ghe-backup-mysql took 2s +2023-03-22T18:36:40Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled +2023-03-22T18:36:40Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled +2023-03-22T18:36:40Z INFO ghe-backup-minio +2023-03-22T18:36:40Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T18:36:40Z RSYNC BEGIN: minio rsync +2023-03-22T18:36:40Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230322T183634/minio +2023-03-22T18:36:40Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:36:40Z RSYNC END: minio rsync +ghe-backup-minio took 0s +4 +15 +Backup progress: 0 % +2023-03-22T18:36:41Z INFO ghe-backup-redis +2023-03-22T18:36:41Z INFO ghe-backup-repositories +2023-03-22T18:36:41Z INFO ghe-backup-es-audit-log +2023-03-22T18:36:41Z INFO ghe-backup-pages +2023-03-22T18:36:41Z INFO ghe-backup-storage +2023-03-22T18:36:41Z INFO ghe-backup-es-rsync +2023-03-22T18:36:41Z INFO ghe-backup-git-hooks + +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-22T18:36:41Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" +2023-03-22T18:36:41Z INFO * Transferring pages files ... +2023-03-22T18:36:41Z RSYNC BEGIN: pages rsync +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] +2023-03-22T18:36:41Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230322T183634/pages +2023-03-22T18:36:41Z INFO * Performing initial sync of ES indices ... +2023-03-22T18:36:41Z RSYNC BEGIN elasticsearch rsync +2023-03-22T18:36:41Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T18:36:41Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-22T18:36:41Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183634/elasticsearch +2023-03-22T18:36:41Z INFO ghe-gc-disable 10.0.1.172:122 +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 /bin/bash +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:36:41Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +2023-03-22T18:36:41Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +2023-03-22T18:36:41Z RSYNC BEGIN: git-hooks sync +2023-03-22T18:36:41Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230322T183634/git-hooks/repos +receiving incremental file list +./ + +sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:36:41Z RSYNC END elasticsearch rsync +2023-03-22T18:36:41Z INFO * Disabling ES index flushing ... +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush +2023-03-22T18:36:41Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T18:36:41Z RSYNC BEGIN: elasticsearch followup rsync +2023-03-22T18:36:41Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183634/elasticsearch +2023-03-22T18:36:41Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ +receiving incremental file list + +sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:36:41Z RSYNC END: elasticsearch followup rsync +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:36:41Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-es-rsync took 0s +2023-03-22T18:36:41Z INFO * Enabling ES index flushing ... +ghe-backup-pages took 0s +2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:36:41Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +ghe-backup-redis took 1s +2023-03-22T18:36:42Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-YZgWfb/remote_routes_list +ghe-backup-storage - Generating routes took 1s +2023-03-22T18:36:42Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-YZgWfb/remote_routes_list +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T18:36:42Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-22T18:36:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-22T18:36:42Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-YZgWfb +2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-BlP7CO/remote_routes_list +ghe-backup-repositories - Generating routes took 2s +2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-BlP7CO/remote_routes_list +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s +2023-03-22T18:36:43Z INFO ghe-gc-enable 10.0.1.172:122 +2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' +2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-BlP7CO +2023-03-22T18:36:43Z INFO ghe-prune-snapshots +2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils +2023-03-22T18:36:43Z INFO ghe-detect-leaked-ssh-keys +2023-03-22T18:36:43Z INFO ghe-ssh --clean +ghe-backup-store-version took 0s +2023-03-22T18:37:30Z INFO * Transferring settings data ... +2023-03-22T18:37:30Z INFO * Transferring license data ... +2023-03-22T18:37:30Z INFO * Transferring management console password ... +2023-03-22T18:37:30Z INFO * Transferring password pepper ... +2023-03-22T18:37:30Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T18:37:30Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T18:37:30Z INFO * Transferring management console argon2 secret ... +2023-03-22T18:37:30Z INFO * Transferring CA certificates ... +2023-03-22T18:37:31Z INFO * Transferring UUID ... +ghe-backup-settings took 1s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 2s +ghe-backup-mysql took 2s +2023-03-22T18:37:33Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T18:37:33Z RSYNC BEGIN: minio rsync +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:37:33Z RSYNC END: minio rsync +ghe-backup-minio took 0s +4 +15 +Backup progress: 0 % +ghe-backup-redis took 1s +2023-03-22T18:37:34Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +ghe-backup-repositories - Generating routes took 2s +ghe-backup-repositories - Fetching routes took 1s +ghe-backup-repositories - Processing routes took 0s + +2023-03-22T18:37:37Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T18:37:37Z INFO * Transferring pages files ... +2023-03-22T18:37:37Z RSYNC BEGIN: pages rsync +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:37:37Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +ghe-backup-storage - Generating routes took 2s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T18:37:39Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T18:37:39Z RSYNC BEGIN: git-hooks sync +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:37:39Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +2023-03-22T18:37:39Z INFO * Performing initial sync of ES indices ... +2023-03-22T18:37:39Z RSYNC BEGIN elasticsearch rsync +receiving incremental file list +./ + +sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:37:39Z RSYNC END elasticsearch rsync +2023-03-22T18:37:39Z INFO * Disabling ES index flushing ... +2023-03-22T18:37:39Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T18:37:39Z RSYNC BEGIN: elasticsearch followup rsync +receiving incremental file list + +sent 286 bytes received 22,565 bytes 45,702.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:37:40Z RSYNC END: elasticsearch followup rsync +ghe-backup-es-rsync took 1s +2023-03-22T18:37:40Z INFO * Enabling ES index flushing ... +ghe-backup-store-version took 0s +2023-03-22T18:40:50Z INFO * Transferring settings data ... +2023-03-22T18:40:50Z INFO * Transferring license data ... +2023-03-22T18:40:50Z INFO * Transferring management console password ... +2023-03-22T18:40:50Z INFO * Transferring password pepper ... +2023-03-22T18:40:50Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T18:40:50Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T18:40:50Z INFO * Transferring management console argon2 secret ... +2023-03-22T18:40:50Z INFO * Transferring CA certificates ... +2023-03-22T18:40:50Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +ghe-export-authorized-keys took 0s +ghe-backup-store-version took 0s +2023-03-22T18:41:48Z INFO * Transferring settings data ... +2023-03-22T18:41:48Z INFO * Transferring license data ... +2023-03-22T18:41:48Z INFO * Transferring management console password ... +2023-03-22T18:41:48Z INFO * Transferring password pepper ... +2023-03-22T18:41:48Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T18:41:49Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T18:41:49Z INFO * Transferring management console argon2 secret ... +2023-03-22T18:41:49Z INFO * Transferring CA certificates ... +2023-03-22T18:41:49Z INFO * Transferring UUID ... +ghe-backup-settings took 1s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 2s +ghe-backup-mysql took 2s +2023-03-22T18:41:51Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T18:41:51Z RSYNC BEGIN: minio rsync +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:41:51Z RSYNC END: minio rsync +ghe-backup-minio took 0s +6 +15 +Backup progress: 0 % +ghe-backup-redis took 2s +2023-03-22T18:41:53Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +ghe-backup-repositories - Generating routes took 2s +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s + +2023-03-22T18:41:55Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T18:41:55Z INFO * Transferring pages files ... +2023-03-22T18:41:55Z RSYNC BEGIN: pages rsync +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:41:55Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +ghe-backup-storage - Generating routes took 2s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T18:41:57Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T18:41:57Z RSYNC BEGIN: git-hooks sync +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 56.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:41:58Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 1s +2023-03-22T18:41:58Z INFO * Performing initial sync of ES indices ... +2023-03-22T18:41:58Z RSYNC BEGIN elasticsearch rsync +receiving incremental file list +./ + +sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:41:58Z RSYNC END elasticsearch rsync +2023-03-22T18:41:58Z INFO * Disabling ES index flushing ... +2023-03-22T18:41:58Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T18:41:58Z RSYNC BEGIN: elasticsearch followup rsync +receiving incremental file list + +sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:41:58Z RSYNC END: elasticsearch followup rsync +ghe-backup-es-rsync took 0s +2023-03-22T18:41:58Z INFO * Enabling ES index flushing ... +ghe-backup-store-version took 0s +2023-03-22T18:47:55Z INFO * Transferring settings data ... +2023-03-22T18:47:55Z INFO * Transferring license data ... +2023-03-22T18:47:55Z INFO * Transferring management console password ... +2023-03-22T18:47:55Z INFO * Transferring password pepper ... +2023-03-22T18:47:55Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T18:47:55Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T18:47:55Z INFO * Transferring management console argon2 secret ... +2023-03-22T18:47:55Z INFO * Transferring CA certificates ... +2023-03-22T18:47:56Z INFO * Transferring UUID ... +ghe-backup-settings took 1s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 2s +2023-03-22T18:47:58Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T18:47:58Z RSYNC BEGIN: minio rsync +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:47:58Z RSYNC END: minio rsync +ghe-backup-minio took 0s +1 +18 +ghe-backup-redis took 1s +2023-03-22T18:47:59Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +ghe-backup-repositories - Generating routes took 2s +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 1s + +2023-03-22T18:48:02Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T18:48:02Z INFO * Transferring pages files ... +2023-03-22T18:48:02Z RSYNC BEGIN: pages rsync +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:48:02Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +ghe-backup-storage - Generating routes took 2s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T18:48:04Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T18:48:04Z RSYNC BEGIN: git-hooks sync +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:48:04Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +2023-03-22T18:48:04Z INFO * Performing initial sync of ES indices ... +2023-03-22T18:48:04Z RSYNC BEGIN elasticsearch rsync +receiving incremental file list +./ + +sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:48:04Z RSYNC END elasticsearch rsync +2023-03-22T18:48:04Z INFO * Disabling ES index flushing ... +2023-03-22T18:48:04Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T18:48:04Z RSYNC BEGIN: elasticsearch followup rsync +receiving incremental file list + +sent 282 bytes received 22,561 bytes 15,228.67 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:48:05Z RSYNC END: elasticsearch followup rsync +ghe-backup-es-rsync took 1s +2023-03-22T18:48:05Z INFO * Enabling ES index flushing ... +ghe-backup-store-version took 0s +2023-03-22T18:48:56Z INFO * Transferring settings data ... +2023-03-22T18:48:56Z INFO * Transferring license data ... +2023-03-22T18:48:56Z INFO * Transferring management console password ... +2023-03-22T18:48:56Z INFO * Transferring password pepper ... +2023-03-22T18:48:56Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T18:48:56Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T18:48:56Z INFO * Transferring management console argon2 secret ... +2023-03-22T18:48:56Z INFO * Transferring CA certificates ... +2023-03-22T18:48:56Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 3s +ghe-backup-mysql took 3s +2023-03-22T18:48:59Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T18:48:59Z RSYNC BEGIN: minio rsync +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:48:59Z RSYNC END: minio rsync +ghe-backup-minio took 0s +6 +18 +Backup progress: 33.00 % +ghe-backup-redis took 1s +2023-03-22T18:49:00Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +ghe-backup-repositories - Generating routes took 2s +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s + +2023-03-22T18:49:02Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T18:49:02Z INFO * Transferring pages files ... +2023-03-22T18:49:02Z RSYNC BEGIN: pages rsync +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 174.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:49:03Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 1s +ghe-backup-pages took 1s +ghe-backup-storage - Generating routes took 1s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T18:49:05Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T18:49:05Z RSYNC BEGIN: git-hooks sync +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T18:49:05Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +2023-03-22T18:49:05Z INFO * Performing initial sync of ES indices ... +2023-03-22T18:49:05Z RSYNC BEGIN elasticsearch rsync +receiving incremental file list +./ + +sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:49:05Z RSYNC END elasticsearch rsync +2023-03-22T18:49:05Z INFO * Disabling ES index flushing ... +2023-03-22T18:49:05Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T18:49:05Z RSYNC BEGIN: elasticsearch followup rsync +receiving incremental file list + +sent 286 bytes received 22,565 bytes 45,702.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T18:49:05Z RSYNC END: elasticsearch followup rsync +ghe-backup-es-rsync took 0s +2023-03-22T18:49:05Z INFO * Enabling ES index flushing ... +ghe-backup-store-version took 0s +2023-03-22T19:22:35Z INFO * Transferring settings data ... +2023-03-22T19:22:35Z INFO * Transferring license data ... +2023-03-22T19:22:35Z INFO * Transferring management console password ... +2023-03-22T19:22:35Z INFO * Transferring password pepper ... +2023-03-22T19:22:35Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T19:22:35Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T19:22:35Z INFO * Transferring management console argon2 secret ... +2023-03-22T19:22:36Z INFO * Transferring CA certificates ... +2023-03-22T19:22:36Z INFO * Transferring UUID ... +ghe-backup-settings took 1s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 2s +ghe-backup-mysql took 2s +2023-03-22T19:22:38Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T19:22:38Z RSYNC BEGIN: minio rsync +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:22:38Z RSYNC END: minio rsync +ghe-backup-minio took 0s +ghe-backup-redis took 1s +2023-03-22T19:22:39Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +ghe-backup-repositories - Generating routes took 3s +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s + +2023-03-22T19:22:42Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T19:22:42Z INFO * Transferring pages files ... +2023-03-22T19:22:42Z RSYNC BEGIN: pages rsync +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:22:42Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +ghe-backup-storage - Generating routes took 2s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T19:22:44Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T19:22:44Z RSYNC BEGIN: git-hooks sync +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:22:44Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +2023-03-22T19:22:44Z INFO * Performing initial sync of ES indices ... +2023-03-22T19:22:44Z RSYNC BEGIN elasticsearch rsync +receiving incremental file list +./ + +sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:22:44Z RSYNC END elasticsearch rsync +2023-03-22T19:22:44Z INFO * Disabling ES index flushing ... +2023-03-22T19:22:45Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T19:22:45Z RSYNC BEGIN: elasticsearch followup rsync +receiving incremental file list + +sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:22:45Z RSYNC END: elasticsearch followup rsync +ghe-backup-es-rsync took 1s +2023-03-22T19:22:45Z INFO * Enabling ES index flushing ... +ghe-backup-store-version took 0s +2023-03-22T19:28:56Z INFO * Transferring settings data ... +2023-03-22T19:28:57Z INFO * Transferring license data ... +2023-03-22T19:28:57Z INFO * Transferring management console password ... +2023-03-22T19:28:57Z INFO * Transferring password pepper ... +2023-03-22T19:28:57Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T19:28:57Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T19:28:57Z INFO * Transferring management console argon2 secret ... +2023-03-22T19:28:57Z INFO * Transferring CA certificates ... +2023-03-22T19:28:57Z INFO * Transferring UUID ... +ghe-backup-settings took 1s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 2s +ghe-backup-mysql took 2s +2023-03-22T19:29:00Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T19:29:00Z RSYNC BEGIN: minio rsync +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:29:00Z RSYNC END: minio rsync +ghe-backup-minio took 0s +ghe-backup-redis took 1s +2023-03-22T19:29:01Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +ghe-backup-repositories - Generating routes took 2s +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s + +2023-03-22T19:29:03Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T19:29:03Z INFO * Transferring pages files ... +2023-03-22T19:29:03Z RSYNC BEGIN: pages rsync +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:29:03Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +ghe-backup-storage - Generating routes took 1s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T19:29:05Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T19:29:06Z RSYNC BEGIN: git-hooks sync +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:29:06Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 1s +2023-03-22T19:29:06Z INFO * Performing initial sync of ES indices ... +2023-03-22T19:29:06Z RSYNC BEGIN elasticsearch rsync +receiving incremental file list +./ + +sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:29:06Z RSYNC END elasticsearch rsync +2023-03-22T19:29:06Z INFO * Disabling ES index flushing ... +2023-03-22T19:29:06Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T19:29:06Z RSYNC BEGIN: elasticsearch followup rsync +receiving incremental file list + +sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:29:06Z RSYNC END: elasticsearch followup rsync +ghe-backup-es-rsync took 0s +2023-03-22T19:29:06Z INFO * Enabling ES index flushing ... +ghe-backup-store-version took 0s +2023-03-22T19:31:52Z INFO * Transferring settings data ... +2023-03-22T19:31:52Z INFO * Transferring license data ... +2023-03-22T19:31:52Z INFO * Transferring management console password ... +2023-03-22T19:31:52Z INFO * Transferring password pepper ... +2023-03-22T19:31:52Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T19:31:52Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T19:31:52Z INFO * Transferring management console argon2 secret ... +2023-03-22T19:31:52Z INFO * Transferring CA certificates ... +2023-03-22T19:31:52Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 3s +ghe-backup-mysql took 3s +2023-03-22T19:31:55Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T19:31:55Z RSYNC BEGIN: minio rsync +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:31:55Z RSYNC END: minio rsync +ghe-backup-minio took 0s +ghe-backup-redis took 1s +2023-03-22T19:31:56Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +ghe-backup-repositories - Generating routes took 2s +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s + +2023-03-22T19:31:58Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T19:31:58Z INFO * Transferring pages files ... +2023-03-22T19:31:58Z RSYNC BEGIN: pages rsync +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 174.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:31:59Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 1s +ghe-backup-pages took 1s +ghe-backup-storage - Generating routes took 2s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T19:32:01Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T19:32:01Z RSYNC BEGIN: git-hooks sync +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:32:01Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +2023-03-22T19:32:01Z INFO * Performing initial sync of ES indices ... +2023-03-22T19:32:01Z RSYNC BEGIN elasticsearch rsync +receiving incremental file list +./ + +sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:32:01Z RSYNC END elasticsearch rsync +2023-03-22T19:32:01Z INFO * Disabling ES index flushing ... +2023-03-22T19:32:01Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T19:32:01Z RSYNC BEGIN: elasticsearch followup rsync +receiving incremental file list + +sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:32:01Z RSYNC END: elasticsearch followup rsync +ghe-backup-es-rsync took 0s +2023-03-22T19:32:01Z INFO * Enabling ES index flushing ... +ghe-backup-store-version took 0s +2023-03-22T19:32:25Z INFO * Transferring settings data ... +2023-03-22T19:32:25Z INFO * Transferring license data ... +2023-03-22T19:32:25Z INFO * Transferring management console password ... +2023-03-22T19:32:25Z INFO * Transferring password pepper ... +2023-03-22T19:32:25Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T19:32:25Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T19:32:26Z INFO * Transferring management console argon2 secret ... +2023-03-22T19:32:26Z INFO * Transferring CA certificates ... +2023-03-22T19:32:26Z INFO * Transferring UUID ... +ghe-backup-settings took 1s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 2s +ghe-backup-mysql took 2s +2023-03-22T19:32:28Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T19:32:28Z RSYNC BEGIN: minio rsync +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:32:28Z RSYNC END: minio rsync +ghe-backup-minio took 0s +ghe-backup-redis took 1s +2023-03-22T19:32:30Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 1s +ghe-backup-repositories - Generating routes took 2s +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s + +2023-03-22T19:32:32Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T19:32:32Z INFO * Transferring pages files ... +2023-03-22T19:32:32Z RSYNC BEGIN: pages rsync +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 522.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:32:32Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 0s +ghe-backup-pages took 0s +ghe-backup-storage - Generating routes took 2s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T19:32:34Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T19:32:34Z RSYNC BEGIN: git-hooks sync +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 56.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:32:35Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 1s +2023-03-22T19:32:35Z INFO * Performing initial sync of ES indices ... +2023-03-22T19:32:35Z RSYNC BEGIN elasticsearch rsync +receiving incremental file list +./ + +sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:32:35Z RSYNC END elasticsearch rsync +2023-03-22T19:32:35Z INFO * Disabling ES index flushing ... +2023-03-22T19:32:35Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T19:32:35Z RSYNC BEGIN: elasticsearch followup rsync +receiving incremental file list + +sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:32:35Z RSYNC END: elasticsearch followup rsync +ghe-backup-es-rsync took 0s +2023-03-22T19:32:35Z INFO * Enabling ES index flushing ... +ghe-backup-store-version took 0s +2023-03-22T19:37:31Z INFO * Transferring settings data ... +2023-03-22T19:37:31Z INFO * Transferring license data ... +2023-03-22T19:37:31Z INFO * Transferring management console password ... +2023-03-22T19:37:31Z INFO * Transferring password pepper ... +2023-03-22T19:37:31Z INFO * Transferring kredz.credz HMAC key ... +2023-03-22T19:37:31Z INFO * Transferring kredz.varz HMAC key ... +2023-03-22T19:37:31Z INFO * Transferring management console argon2 secret ... +2023-03-22T19:37:31Z INFO * Transferring CA certificates ... +2023-03-22T19:37:31Z INFO * Transferring UUID ... +ghe-backup-settings took 0s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 3s +ghe-backup-mysql took 3s +2023-03-22T19:37:34Z INFO * Transferring minio files from 10.0.1.172 ... +2023-03-22T19:37:34Z RSYNC BEGIN: minio rsync +receiving incremental file list +./ + +sent 44 bytes received 93 bytes 274.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:37:34Z RSYNC END: minio rsync +ghe-backup-minio took 0s +ghe-backup-redis took 1s +2023-03-22T19:37:35Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 +ghe-backup-es-audit-log took 0s +ghe-backup-repositories - Generating routes took 2s +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s + +2023-03-22T19:37:37Z INFO * Starting backup for host: 10.0.1.172 + +2023-03-22T19:37:37Z INFO * Transferring pages files ... +2023-03-22T19:37:37Z RSYNC BEGIN: pages rsync +receiving incremental file list +./ + +sent 35 bytes received 226 bytes 174.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:37:38Z RSYNC END: pages rsync +ghe-backup-pages - 10.0.1.172 took 1s +ghe-backup-pages took 1s +ghe-backup-storage - Generating routes took 1s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +2023-03-22T19:37:40Z INFO git-hooks environment tarballs not found. Skipping ... +2023-03-22T19:37:40Z RSYNC BEGIN: git-hooks sync +receiving incremental file list +./ + +sent 27 bytes received 57 bytes 168.00 bytes/sec +total size is 0 speedup is 0.00 +2023-03-22T19:37:40Z RSYNC END: git-hooks sync +ghe-backup-git-hooks took 0s +2023-03-22T19:37:40Z INFO * Performing initial sync of ES indices ... +2023-03-22T19:37:40Z RSYNC BEGIN elasticsearch rsync +receiving incremental file list +./ + +sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:37:40Z RSYNC END elasticsearch rsync +2023-03-22T19:37:40Z INFO * Disabling ES index flushing ... +2023-03-22T19:37:40Z INFO * Performing follow-up sync of ES indices ... +2023-03-22T19:37:40Z RSYNC BEGIN: elasticsearch followup rsync +receiving incremental file list + +sent 286 bytes received 22,565 bytes 45,702.00 bytes/sec +total size is 146,931 speedup is 6.43 +2023-03-22T19:37:40Z RSYNC END: elasticsearch followup rsync +ghe-backup-es-rsync took 0s +2023-03-22T19:37:40Z INFO * Enabling ES index flushing ... diff --git a/bin/ghe-backup b/bin/ghe-backup index 3692fbdc7..cb337645d 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -39,9 +39,8 @@ done export CALLING_SCRIPT="ghe-backup" export BACKUP_PROGRESS=0 # Used to track progress of backup -echo "${BACKUP_PROGRESS}" > /tmp/progress -BACKUP_PROGRESS_TOTAL=15 # Maximum number of steps in backup -echo "${BACKUP_PROGRESS_TOTAL}" > /tmp/progress-total +echo $BACKUP_PROGRESS > /tmp/track-progress +export BACKUP_PROGRESS_TOTAL=18 # Maximum number of steps in backup export BACKUP_PROGRESS_DESCRIPTION="" # Used to store information about current step # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 197626248..7b76ecbf7 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -58,5 +58,5 @@ bm_end() { echo "Debug: $1 took ${total}s (bm_end)" fi # track progress - . "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" + progress "$1 took ${total}s" } diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 3f11a4e32..a7d8b5f1d 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -55,7 +55,7 @@ fi PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # shellcheck source=share/github-backup-utils/bm.sh . "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" -#. "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" +. "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" # Save off GHE_HOSTNAME from the environment since we want it to override the # backup.config value when set. GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" @@ -278,6 +278,7 @@ else exec 3>/dev/null fi + # Restore saved off hostname. [ -n "$GHE_HOSTNAME_PRESERVE" ] && GHE_HOSTNAME="$GHE_HOSTNAME_PRESERVE" diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index addbc94d4..ed68307ee 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -2,9 +2,9 @@ #/ track-progress: track progress of backup or restore tasks # Current version is working solely with backups - -BACKUP_PROGRESS=$(($(cat /tmp/progress) + 1)) -BACKUP_PROGRESS=$(cat /tmp/progress-total) -BACKUP_PROGRESS_PERCENT=$(( (BACKUP_PROGRESS / BACKUP_PROGRESS_TOTAL) * 100)) - -echo "Backup progress: $BACKUP_PROGRESS_PERCENT %" \ No newline at end of file +progress(){ +BACKUP_PROGRESS=$(cat /tmp/track-progress) +BACKUP_PROGRESS_PERCENT=$( echo "scale = 2; ($BACKUP_PROGRESS / $BACKUP_PROGRESS_TOTAL) * 100" | bc) +echo "Backup progress: $BACKUP_PROGRESS_PERCENT % ($BACKUP_PROGRESS / $BACKUP_PROGRESS_TOTAL ) $1 " > /tmp/progress-info +echo $((BACKUP_PROGRESS +1)) > /tmp/track-progress +} diff --git a/testfd b/testfd new file mode 100644 index 000000000..e69de29bb From e63e26b7e0d905388644303b55b60e64cb74e909 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 23 Mar 2023 19:54:19 -0400 Subject: [PATCH 1736/2421] fleshing out code --- bin/ghe-backup | 14 ++++-- bin/ghe-progress | 49 +++++++++++++++++++++ bin/ghe-restore | 12 +++-- share/github-backup-utils/ghe-backup-config | 4 ++ share/github-backup-utils/track-progress | 9 ++-- 5 files changed, 77 insertions(+), 11 deletions(-) create mode 100644 bin/ghe-progress diff --git a/bin/ghe-backup b/bin/ghe-backup index cb337645d..2caf4dae5 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -37,15 +37,21 @@ while true; do esac done + export CALLING_SCRIPT="ghe-backup" -export BACKUP_PROGRESS=0 # Used to track progress of backup -echo $BACKUP_PROGRESS > /tmp/track-progress -export BACKUP_PROGRESS_TOTAL=18 # Maximum number of steps in backup -export BACKUP_PROGRESS_DESCRIPTION="" # Used to store information about current step + # Bring in the backup configuration # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" +# Setup progress tracking +init-progress +export PROGRESS_TYPE="Backup" +echo $PROGRESS_TYPE > /tmp/track-progress-type +export PROGRESS=0 # Used to track progress of backup +echo $PROGRESS > /tmp/track-progress +export PROGRESS_TOTAL=18 # Maximum number of steps in backup + # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check diff --git a/bin/ghe-progress b/bin/ghe-progress new file mode 100644 index 000000000..356417a37 --- /dev/null +++ b/bin/ghe-progress @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +#/ Usage: ghe-progress [--once] +#/ Tracks the completed steps of a backup or restore operation. +#/ +#/ By default the progress is printed every 5 seconds or until a key is pressed. +#/ Use the --once option to print the current progress once and exit. +#/ +#/ Options: +#/ --once Don't loop, just print the current progress once. +# + +while true; do + case "$1" in + -o|--once) + export ONCE=1; + shift + ;; + -h|--help) + export GHE_SHOW_HELP=true + shift + ;; + -*) + echo "Unknown option: $1" >&2; + exit 1 + ;; + *) + break + ;; + esac +done + +check_for_progress_file() { + if [ ! -f /tmp/progress-info ]; then + echo "No progress file found. has a backup or restore been started?" + exit 1 + fi +} + +if ONCE=1; then + cat /tmp/progress-info +else + while true; do + if ! read -r -t 5 -n 1; then + exit ; + else + cat /tmp/progress-info + fi + done +fi \ No newline at end of file diff --git a/bin/ghe-restore b/bin/ghe-restore index 725c44a69..82809ebbc 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -86,9 +86,7 @@ while true; do esac done -export GHE_RESTORE_PROGRESS=0 -export GHE_RESTORE_PROGRESS_TOTAL=15 -export GHE_RESTORE_PROGRESS_DESCRIPTION="" + start_cron () { log_info "Starting cron ..." @@ -166,6 +164,14 @@ cleanup_cluster_nodes() { # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" +# Set up progress tracking +init-progress +export PROGRESS_TYPE="Restore" +echo $PROGRESS_TYPE > /tmp/track-progress-type +export PROGRESS=0 # Used to track progress of restore +echo $PROGRESS > /tmp/track-progress +export PROGRESS_TOTAL=15 # Maximum number of steps in restore + # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index a7d8b5f1d..7733b91e9 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -646,6 +646,10 @@ restore-secret() { fi } +#initialize progress tracking by clearing out the temp files used to track +init-progress() { + rm -f /tmp/track-progress-* +} diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index ed68307ee..f3f0ddc5b 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -3,8 +3,9 @@ # Current version is working solely with backups progress(){ -BACKUP_PROGRESS=$(cat /tmp/track-progress) -BACKUP_PROGRESS_PERCENT=$( echo "scale = 2; ($BACKUP_PROGRESS / $BACKUP_PROGRESS_TOTAL) * 100" | bc) -echo "Backup progress: $BACKUP_PROGRESS_PERCENT % ($BACKUP_PROGRESS / $BACKUP_PROGRESS_TOTAL ) $1 " > /tmp/progress-info -echo $((BACKUP_PROGRESS +1)) > /tmp/track-progress + PROGRESS=$(cat /tmp/track-progress) + PROGRESS_TYPE=$(cat /tmp/track-progress-type) + PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) + echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/progress-info + echo $((BACKUP_PROGRESS +1)) > /tmp/track-progress } From d0e02f59773723fd207bc323330188f38af2b34e Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 00:19:27 +0000 Subject: [PATCH 1737/2421] Almost there --- bin/ghe-progress | 18 ++++++++++++------ share/github-backup-utils/track-progress | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) mode change 100644 => 100755 bin/ghe-progress diff --git a/bin/ghe-progress b/bin/ghe-progress old mode 100644 new mode 100755 index 356417a37..1099ad2c3 --- a/bin/ghe-progress +++ b/bin/ghe-progress @@ -2,7 +2,7 @@ #/ Usage: ghe-progress [--once] #/ Tracks the completed steps of a backup or restore operation. #/ -#/ By default the progress is printed every 5 seconds or until a key is pressed. +#/ By default the progress is printed every continuously or until a key is pressed. #/ Use the --once option to print the current progress once and exit. #/ #/ Options: @@ -12,7 +12,7 @@ while true; do case "$1" in -o|--once) - export ONCE=1; + ONCE=1; shift ;; -h|--help) @@ -36,14 +36,20 @@ check_for_progress_file() { fi } -if ONCE=1; then +if [ -n "$ONCE" ]; then + check_for_progress_file cat /tmp/progress-info else + check_for_progress_file + clear + cat /tmp/progress-info while true; do - if ! read -r -t 5 -n 1; then + if read -r -t 1 -n 1; then + clear exit ; else - cat /tmp/progress-info + clear + cat /tmp/progress-info fi done -fi \ No newline at end of file +fi diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index f3f0ddc5b..12c2fc64b 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -7,5 +7,5 @@ progress(){ PROGRESS_TYPE=$(cat /tmp/track-progress-type) PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/progress-info - echo $((BACKUP_PROGRESS +1)) > /tmp/track-progress + echo $((PROGRESS +1)) > /tmp/track-progress } From 3ab937a21fa2584f485d86b4db9f8cf62ddf86ab Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 23 Mar 2023 20:48:23 -0400 Subject: [PATCH 1738/2421] add benchamrking and progression to restore script --- bin/ghe-restore | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 82809ebbc..f0dc6b9f2 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -350,6 +350,7 @@ log_warn "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. log_info "Stopping cron and github-timerd ..." if $CLUSTER; then + bm_start "stop_cron_github_timerd" if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then log_warn "Failed to stop cron on one or more nodes" 1>&3 fi @@ -381,9 +382,11 @@ else log_warn "Failed to stop github-timerd" 1>&3 fi fi + bm_end "stop_cron_github_timerd" fi CRON_RUNNING=false + # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. if $RESTORE_SETTINGS; then @@ -401,10 +404,12 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then log_info "Restoring UUID ..." + bm_start "restore_uuid" cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" + bm_end "restore_uuid" fi if is_external_database_snapshot; then @@ -455,7 +460,9 @@ fi cmd_title=$(log_info "Restoring Redis database ...") commands=(" echo \"$cmd_title\" -ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3") +bm_start \"restore_redis\" +ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3 +bm_end \"restore_redis\"") cmd_title=$(log_info "Restoring Git Repositories ...") commands+=(" @@ -475,7 +482,9 @@ ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") cmd_title=$(log_info "Restoring SSH authorized keys ...") commands+=(" echo \"$cmd_title\" -ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3") +bm_start \"restore_authorized_keys\" +ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3 +bm_end \"restore_authorized_keys\"") cmd_title=$(log_info "Restoring storage data ...") commands+=(" @@ -528,8 +537,10 @@ fi # Restart an already running memcached to reset the cache after restore log_info "Restarting memcached ..." 1>&3 +bm_start "restart_memcached" echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh +bm_end "restart_memcached" # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. @@ -543,20 +554,24 @@ fi # config run to perform data migrations. if $CLUSTER; then log_info "Configuring cluster ..." + bm_start "configure_cluster" if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 + bm_end "configure_cluster" elif $instance_configured; then log_info "Configuring appliance ..." + bm_start "configure_appliance" if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 + bm_end "configure_appliance" fi # Clear GitHub Connect settings stored in the restored database. @@ -574,6 +589,7 @@ CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then log_info "Cleaning up replicas..." 1>&3 + bm_start "cleanup_replicas" restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) other_nodes=$(echo " set -o pipefail; \ @@ -589,6 +605,7 @@ if ! $CLUSTER && $instance_configured; then echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 done fi + bm_end "cleanup_replicas" fi # Update the remote status to "complete". This has to happen before importing From 8c91cee8bb677745828460c468dc2a41fe117ff3 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Fri, 24 Mar 2023 14:26:28 +0100 Subject: [PATCH 1739/2421] fixing argon secret backup for ghes versions below 3.8.0 --- share/github-backup-utils/ghe-backup-settings | 2 +- test/test-ghe-backup.sh | 9 ++++----- test/testlib.sh | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index cfd1b24ce..5552b2f22 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -80,7 +80,7 @@ backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hma backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" # Backup argon secrets for multiuser from ghes version 3.8 onwards -if [ "$(version $GHE_REMOTE_VERSION)" -gt "$(version 3.7.0)" ]; then +if ! [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.0)" ]; then backup-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" fi diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index b60e5c3dd..f11430e18 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -133,19 +133,18 @@ begin_test "ghe-backup without password pepper" ) end_test -begin_test "ghe-backup without management console argon2 secret for ghes lower than 3.8" +# before the introduction of multiuser auth +begin_test "ghe-backup management console does not backup argon secret" ( set -e - git config -f "$GHE_REMOTE_DATA_USER_DIR/common/secrets.conf" secrets.manage-auth.argon-secret "fake pw" - GHE_REMOTE_VERSION=3.7.0 ghe-backup - + GHE_REMOTE_VERSION=3.7.0 ghe-backup -v | grep -q "management console argon2 secret not set" && exit 1 [ ! -f "$GHE_DATA_DIR/current/manage-argon-secret" ] ) end_test # multiuser auth introduced in ghes version 3.8 -begin_test "ghe-backup management console argon2 secret" +begin_test "ghe-backup management console backs up argon secret" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index 61525b221..a4056a82f 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -448,7 +448,7 @@ verify_all_backedup_data() { [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] # verify manage-argon-secret file was backed up - if [ "$(version $GHE_REMOTE_VERSION)" -gt "$(version 3.7.0)" ]; then + if ! [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.0)" ]; then [ "$(cat "$GHE_DATA_DIR/current/manage-argon-secret")" = "fake argon2 secret" ] fi From 9329a33ff882a992d204317b73b66ca23307ffcf Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 11:21:02 -0400 Subject: [PATCH 1740/2421] add calculation of restore steps --- bin/ghe-restore | 52 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index f0dc6b9f2..d4daec008 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -164,13 +164,10 @@ cleanup_cluster_nodes() { # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" -# Set up progress tracking -init-progress -export PROGRESS_TYPE="Restore" -echo $PROGRESS_TYPE > /tmp/track-progress-type -export PROGRESS=0 # Used to track progress of restore -echo $PROGRESS > /tmp/track-progress -export PROGRESS_TOTAL=15 # Maximum number of steps in restore +# Calculate the actual amounts of steps in the restore process +# taking into account the options passed to the script and the appliance configuration + + # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check @@ -274,6 +271,47 @@ if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then prompt_for_confirmation "Please confirm this before continuing." fi +# calculate restore steps +OPTIONAL_STEPS=0 +# Cluster restores add an additional step +if $CLUSTER ; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi +# Restoring UUID +if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi +# Restoring Actions +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi +# Restoring minio +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi +# Elasticsearch is optional for cluster restores +if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi +# Restoring audit log +if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then + if [[ "$GHE_RESTORE_SKIP_AUDIT_LOG" != "yes" ]]; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) + fi +fi +# Replica cleanup +if ! $CLUSTER && $instance_configured; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi +# Maximum restore steps +export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 9)) + +init-progress +export PROGRESS_TYPE="Restore" +echo $PROGRESS_TYPE > /tmp/track-progress-type +export PROGRESS=0 # Used to track progress of restore +echo $PROGRESS > /tmp/track-progress + # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" From 29b4daeccd1c3ad6d57d49c0aad3afcd72ddc1ba Mon Sep 17 00:00:00 2001 From: Krayon Date: Sat, 25 Mar 2023 02:26:12 +1100 Subject: [PATCH 1741/2421] Removed our readlink() --- share/github-backup-utils/ghe-backup-config | 22 --------------------- 1 file changed, 22 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 60ef6014c..7cde3fb9f 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -21,28 +21,6 @@ YELLOW='\033[0;33m' BLUE='\033[0;34m' NC='\033[0m' # No Colo# Logging display and formatting functions -# If we don't have a readlink command, parse ls -l output. -if ! type readlink 1>/dev/null 2>&1; then - readlink() { - local ret=0 f='' - while [ $# -gt 0 ]; do - f="$1" - shift 1 - - [ ! -e "$f" ] && [ ! -h "$f" ] && { - ret=1 - continue - } - - # shellcheck disable=SC2012 # In this specific scenario, this method is OK - f="$(ls -ld "$f")" - echo "${f//*-> /}" - done - - return $ret - } -fi - # Log a message to stdout log_level() { local level=$1 From b6beab9a4867a11b8ea48fdb35eb1af3a288a86f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 11:30:15 -0400 Subject: [PATCH 1742/2421] troubleshooting --- bin/ghe-restore | 2 +- share/github-backup-utils/bm.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d4daec008..03143dce0 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -388,7 +388,7 @@ log_warn "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. log_info "Stopping cron and github-timerd ..." if $CLUSTER; then - bm_start "stop_cron_github_timerd" + bm_start "stop_cron" if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then log_warn "Failed to stop cron on one or more nodes" 1>&3 fi diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 7b76ecbf7..4bffe29b3 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -49,6 +49,8 @@ bm_end() { local tend tstart total tend=$(date +%s) tstart=$(eval "echo \$$(bm_desc_to_varname "$@")_start") + echo "tend: $tend" + echo "tstart: $tstart" total=$(($tend - $tstart)) echo "$1 took ${total}s" >> $BM_FILE_PATH From e082fcc5fb50336ae02dd61cb40c4f155e18224a Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:39:25 -0400 Subject: [PATCH 1743/2421] Update bin/ghe-host-check Update formatting. Co-authored-by: Krayon --- bin/ghe-host-check | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 0c0fd83be..07f57ab06 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -172,7 +172,17 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then min_disk_req=$((repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size)) - echo -e "### Data Transfer Sizes \nrepositories: $repos_disk_size MB\npages: $pages_disk_size MB\nelasticsearch: $es_disk_size MB\nstorage: $stor_disk_size MB\nminio: $minio_disk_size MB\nmysql: $mysql_disk_size MB\nactions: $actions_disk_size MB\nmssql: $mssql_disk_size MB" 1>&2 +cat <&2 +### Data Transfer Sizes +repositories: $repos_disk_size MB +pages: $pages_disk_size MB +elasticsearch: $es_disk_size MB +storage: $stor_disk_size MB +minio: $minio_disk_size MB +mysql: $mysql_disk_size MB +actions: $actions_disk_size MB +mssql: $mssql_disk_size MB +DATA_TRANSFER_SIZE printf "min_disk_required for this backup is at least %d MB\n" "$min_disk_req" 1>&2 if [[ $available_space -lt $min_disk_req ]]; then From b996dab8f034b06bc4901f6e6cac079a05488a3a Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 24 Mar 2023 11:43:50 -0400 Subject: [PATCH 1744/2421] Update bin/ghe-host-check More formatting for easier read. Co-authored-by: Krayon --- bin/ghe-host-check | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 07f57ab06..a53649a12 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -159,7 +159,8 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then #Display dir requirements for repositories and mysql echo "Checking host for sufficient space for a backup..." 1>&2 available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') - printf "Available space: %d MB. We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time.\n" "$((available_space / 1024 ** 2))" 1>&2 + echo -e "Available space: $((available_space / (1024 ** 2))) MB\n" 1>&2 + echo -e "We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time.\n" 1>&2 repos_disk_size=$(transfer_size repositories /tmp) pages_disk_size=$(transfer_size pages /tmp) From aa0617db68fda077b8b9ac4794ca32debdd04592 Mon Sep 17 00:00:00 2001 From: Krayon Date: Sat, 25 Mar 2023 02:46:23 +1100 Subject: [PATCH 1745/2421] Handle trailing alpha in version() --- share/github-backup-utils/ghe-backup-config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 7cde3fb9f..dec492870 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -510,8 +510,9 @@ ghe_debug() { version() { local v="${*#v}" + # Discard stderr and always return true as trailing alpha (eg. "v1.2.3pre") will upset printf # shellcheck disable=SC2183,SC2086 # We want to glob (SC2086) and expect 4 (fuzzy) params (SC2183) - printf "%d%03d%03d%03d\n" ${v//./ } + printf "%d%03d%03d%03d\n" ${v//./ } 2>/dev/null || true } # The list of gists returned by the source changed in 2.16.23, 2.17.14, From 1b5149ce279eb181f30426c7c4a2eb21562f57f3 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 11:55:04 -0400 Subject: [PATCH 1746/2421] restructure bm commands --- bin/ghe-restore | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 03143dce0..b35775ce5 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -388,7 +388,7 @@ log_warn "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. log_info "Stopping cron and github-timerd ..." if $CLUSTER; then - bm_start "stop_cron" + bm_start "basename($0) - Stopping cron and github-timerd on cluster" if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then log_warn "Failed to stop cron on one or more nodes" 1>&3 fi @@ -420,7 +420,7 @@ else log_warn "Failed to stop github-timerd" 1>&3 fi fi - bm_end "stop_cron_github_timerd" + bm_end "basename($0) - Stopping cron and github-timerd on cluster" fi CRON_RUNNING=false @@ -442,12 +442,12 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then log_info "Restoring UUID ..." - bm_start "restore_uuid" + bm_start "basename($0) - Restore UUID" cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" - bm_end "restore_uuid" + bm_end "basename($0) - Restore UUID" fi if is_external_database_snapshot; then @@ -498,9 +498,9 @@ fi cmd_title=$(log_info "Restoring Redis database ...") commands=(" echo \"$cmd_title\" -bm_start \"restore_redis\" +bm_start \"basename($0) - Restoring Redis\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3 -bm_end \"restore_redis\"") +bm_end \"basename($0) - Restoring Redis\"") cmd_title=$(log_info "Restoring Git Repositories ...") commands+=(" @@ -520,9 +520,9 @@ ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") cmd_title=$(log_info "Restoring SSH authorized keys ...") commands+=(" echo \"$cmd_title\" -bm_start \"restore_authorized_keys\" +bm_start \"basename($0) -Restoring SSH authorized keys\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3 -bm_end \"restore_authorized_keys\"") +bm_end \"basename($0) -Restoring SSH authorized keys\"") cmd_title=$(log_info "Restoring storage data ...") commands+=(" @@ -575,10 +575,10 @@ fi # Restart an already running memcached to reset the cache after restore log_info "Restarting memcached ..." 1>&3 -bm_start "restart_memcached" +bm_start "basename($0) - Restarting memcached" echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh -bm_end "restart_memcached" +bm_end "basename($0) - Restarting memcached" # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. @@ -592,7 +592,7 @@ fi # config run to perform data migrations. if $CLUSTER; then log_info "Configuring cluster ..." - bm_start "configure_cluster" + bm_start "basename($0) - configure cluster" if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -609,7 +609,7 @@ elif $instance_configured; then ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 - bm_end "configure_appliance" + bm_end "basename($0) - configure cluster" fi # Clear GitHub Connect settings stored in the restored database. @@ -627,7 +627,7 @@ CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then log_info "Cleaning up replicas..." 1>&3 - bm_start "cleanup_replicas" + bm_start "basename($0) - Cleanup replicas" restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) other_nodes=$(echo " set -o pipefail; \ @@ -643,7 +643,7 @@ if ! $CLUSTER && $instance_configured; then echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 done fi - bm_end "cleanup_replicas" + bm_end "basename($0) - Cleanup replicas" fi # Update the remote status to "complete". This has to happen before importing From 6e97556d1dfbd1d0a9f67a63103b3e1c089c5d3e Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 11:58:26 -0400 Subject: [PATCH 1747/2421] fix basename typo --- bin/ghe-restore | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b35775ce5..c6753c844 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -388,7 +388,7 @@ log_warn "Warning: storing backup-utils version remotely failed." # Stop cron and timerd, as scheduled jobs may disrupt the restore process. log_info "Stopping cron and github-timerd ..." if $CLUSTER; then - bm_start "basename($0) - Stopping cron and github-timerd on cluster" + bm_start "$(basename $0) - Stopping cron and github-timerd on cluster" if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then log_warn "Failed to stop cron on one or more nodes" 1>&3 fi @@ -420,7 +420,7 @@ else log_warn "Failed to stop github-timerd" 1>&3 fi fi - bm_end "basename($0) - Stopping cron and github-timerd on cluster" + bm_end "$(basename $0) - Stopping cron and github-timerd on cluster" fi CRON_RUNNING=false @@ -442,12 +442,12 @@ fi # Restore UUID if present and not restoring to cluster. if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then log_info "Restoring UUID ..." - bm_start "basename($0) - Restore UUID" + bm_start "$(basename $0) - Restore UUID" cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" - bm_end "basename($0) - Restore UUID" + bm_end "$(basename $0) - Restore UUID" fi if is_external_database_snapshot; then @@ -498,9 +498,9 @@ fi cmd_title=$(log_info "Restoring Redis database ...") commands=(" echo \"$cmd_title\" -bm_start \"basename($0) - Restoring Redis\" +bm_start \"$(basename $0) - Restoring Redis\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3 -bm_end \"basename($0) - Restoring Redis\"") +bm_end \"$(basename $0) - Restoring Redis\"") cmd_title=$(log_info "Restoring Git Repositories ...") commands+=(" @@ -520,9 +520,9 @@ ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") cmd_title=$(log_info "Restoring SSH authorized keys ...") commands+=(" echo \"$cmd_title\" -bm_start \"basename($0) -Restoring SSH authorized keys\" +bm_start \"$(basename $0) -Restoring SSH authorized keys\" ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3 -bm_end \"basename($0) -Restoring SSH authorized keys\"") +bm_end \"$(basename $0) -Restoring SSH authorized keys\"") cmd_title=$(log_info "Restoring storage data ...") commands+=(" @@ -575,10 +575,10 @@ fi # Restart an already running memcached to reset the cache after restore log_info "Restarting memcached ..." 1>&3 -bm_start "basename($0) - Restarting memcached" +bm_start "$(basename $0) - Restarting memcached" echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh -bm_end "basename($0) - Restarting memcached" +bm_end "$(basename $0) - Restarting memcached" # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. @@ -592,7 +592,7 @@ fi # config run to perform data migrations. if $CLUSTER; then log_info "Configuring cluster ..." - bm_start "basename($0) - configure cluster" + bm_start "$(basename $0) - configure cluster" if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then @@ -609,7 +609,7 @@ elif $instance_configured; then ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 - bm_end "basename($0) - configure cluster" + bm_end "$(basename $0) - configure cluster" fi # Clear GitHub Connect settings stored in the restored database. @@ -627,7 +627,7 @@ CRON_RUNNING=true # Clean up all stale replicas on configured instances. if ! $CLUSTER && $instance_configured; then log_info "Cleaning up replicas..." 1>&3 - bm_start "basename($0) - Cleanup replicas" + bm_start "$(basename $0) - Cleanup replicas" restored_uuid=$(cat $GHE_RESTORE_SNAPSHOT_PATH/uuid) other_nodes=$(echo " set -o pipefail; \ @@ -643,7 +643,7 @@ if ! $CLUSTER && $instance_configured; then echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 done fi - bm_end "basename($0) - Cleanup replicas" + bm_end "$(basename $0) - Cleanup replicas" fi # Update the remote status to "complete". This has to happen before importing From 713a5abae815b179f21a15573fe59a2205fc53b8 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 12:04:59 -0400 Subject: [PATCH 1748/2421] fix bm error --- bin/ghe-restore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index c6753c844..e8645018b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -404,7 +404,9 @@ if $CLUSTER; then log_warn "Failed to stop github-timerd on one or more nodes" 1>&3 fi fi + bm_end "$(basename $0) - Stopping cron and github-timerd on cluster" else + bm_start "$(basename $0) - Stopping cron and github-timerd" if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then log_warn "Failed to stop cron" 1>&3 fi @@ -420,7 +422,7 @@ else log_warn "Failed to stop github-timerd" 1>&3 fi fi - bm_end "$(basename $0) - Stopping cron and github-timerd on cluster" + bm_end "$(basename $0) - Stopping cron and github-timerd on" fi CRON_RUNNING=false From 853ec7c9daf6e930ecbc11aa47b04b42e232c427 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 24 Mar 2023 16:25:40 +0000 Subject: [PATCH 1749/2421] More formatting --- bin/ghe-host-check | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index a53649a12..3ad88edc7 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -159,8 +159,7 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then #Display dir requirements for repositories and mysql echo "Checking host for sufficient space for a backup..." 1>&2 available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') - echo -e "Available space: $((available_space / (1024 ** 2))) MB\n" 1>&2 - echo -e "We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time.\n" 1>&2 + echo "We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." 1>&2 repos_disk_size=$(transfer_size repositories /tmp) pages_disk_size=$(transfer_size pages /tmp) @@ -172,6 +171,8 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then mssql_disk_size=$(transfer_size mssql /tmp) min_disk_req=$((repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size)) + echo "Available space: $((available_space / (1024 ** 2))) MB" 1>&2 + echo -e "Min Disk required for this backup is at least $min_disk_req MB\n" 1>&2 cat <&2 ### Data Transfer Sizes @@ -184,7 +185,6 @@ mysql: $mysql_disk_size MB actions: $actions_disk_size MB mssql: $mssql_disk_size MB DATA_TRANSFER_SIZE - printf "min_disk_required for this backup is at least %d MB\n" "$min_disk_req" 1>&2 if [[ $available_space -lt $min_disk_req ]]; then echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2 @@ -192,6 +192,7 @@ DATA_TRANSFER_SIZE fi #Check rsync, openssh & jq versions + echo "### Software versions" 1>&2 rsync_version=$(rsync --version | grep 'version' | awk '{print $3}') if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 From 460499e046c0b69d829ff2467938b2ae964ca7a6 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 12:54:01 -0400 Subject: [PATCH 1750/2421] adding more info for tracking --- share/github-backup-utils/track-progress | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 12c2fc64b..3df09048e 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -6,6 +6,6 @@ progress(){ PROGRESS=$(cat /tmp/track-progress) PROGRESS_TYPE=$(cat /tmp/track-progress-type) PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) - echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/progress-info + echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " >> /tmp/progress-info echo $((PROGRESS +1)) > /tmp/track-progress } From 9edb995bb2b733726d9297613ef93074a1954b0f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 13:05:18 -0400 Subject: [PATCH 1751/2421] some troubleshooting output --- bin/ghe-restore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index e8645018b..ec001ab6b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -407,6 +407,7 @@ if $CLUSTER; then bm_end "$(basename $0) - Stopping cron and github-timerd on cluster" else bm_start "$(basename $0) - Stopping cron and github-timerd" + echo "$(basename $0) - Stopping cron and github-timerd" if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then log_warn "Failed to stop cron" 1>&3 fi From b39d799fb4118f7f2a1f22416a162e88beb1a42c Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 13:11:13 -0400 Subject: [PATCH 1752/2421] some troubleshooting output --- bin/ghe-restore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index ec001ab6b..dd9f7494f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -392,7 +392,7 @@ if $CLUSTER; then if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then log_warn "Failed to stop cron on one or more nodes" 1>&3 fi - + bm_end "$(basename $0) - Stopping cron and github-timerd on cluster" if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then @@ -404,14 +404,14 @@ if $CLUSTER; then log_warn "Failed to stop github-timerd on one or more nodes" 1>&3 fi fi - bm_end "$(basename $0) - Stopping cron and github-timerd on cluster" + else bm_start "$(basename $0) - Stopping cron and github-timerd" echo "$(basename $0) - Stopping cron and github-timerd" if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then log_warn "Failed to stop cron" 1>&3 fi - + bm_end "$(basename $0) - Stopping cron and github-timerd" if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then @@ -423,7 +423,7 @@ else log_warn "Failed to stop github-timerd" 1>&3 fi fi - bm_end "$(basename $0) - Stopping cron and github-timerd on" + fi CRON_RUNNING=false From ea3294c388a63a098742d0bfa724e332d9c27e28 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 15:24:29 -0400 Subject: [PATCH 1753/2421] making adjustments --- bin/ghe-restore | 4 ++-- share/github-backup-utils/track-progress | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index dd9f7494f..1b392b011 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -289,7 +289,7 @@ fi if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi -# Elasticsearch is optional for cluster restores +# Restoring Elasticsearch if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi @@ -304,7 +304,7 @@ if ! $CLUSTER && $instance_configured; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi # Maximum restore steps -export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 9)) +export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 5)) init-progress export PROGRESS_TYPE="Restore" diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 3df09048e..95e6bf6ac 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -3,9 +3,10 @@ # Current version is working solely with backups progress(){ + PROGRESS=$(cat /tmp/track-progress) PROGRESS_TYPE=$(cat /tmp/track-progress-type) PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) - echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " >> /tmp/progress-info echo $((PROGRESS +1)) > /tmp/track-progress + echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/progress-info } From 0a72be7be4a3f787e2157dfaa1dd14aa482be614 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 24 Mar 2023 15:25:37 -0400 Subject: [PATCH 1754/2421] remove troubleshooting code --- share/github-backup-utils/bm.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh index 4bffe29b3..561bcfffb 100755 --- a/share/github-backup-utils/bm.sh +++ b/share/github-backup-utils/bm.sh @@ -49,8 +49,7 @@ bm_end() { local tend tstart total tend=$(date +%s) tstart=$(eval "echo \$$(bm_desc_to_varname "$@")_start") - echo "tend: $tend" - echo "tstart: $tstart" + total=$(($tend - $tstart)) echo "$1 took ${total}s" >> $BM_FILE_PATH From e18a31efe49d6b5d9bbd6174168fd0293027c816 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Sat, 25 Mar 2023 12:50:53 +0100 Subject: [PATCH 1755/2421] fixing ambiguous/unnecessarily complex condition (#284) * fixing ambiguous/unnecessarily complex condition * adding additional test conditions --- share/github-backup-utils/ghe-backup-settings | 2 +- test/test-ghe-backup.sh | 14 +++++++++++++- test/testlib.sh | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 5552b2f22..d8bddb068 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -80,7 +80,7 @@ backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hma backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" # Backup argon secrets for multiuser from ghes version 3.8 onwards -if ! [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.0)" ]; then +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then backup-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" fi diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index f11430e18..8e49349b2 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -138,7 +138,13 @@ begin_test "ghe-backup management console does not backup argon secret" ( set -e - GHE_REMOTE_VERSION=3.7.0 ghe-backup -v | grep -q "management console argon2 secret not set" && exit 1 + GHE_REMOTE_VERSION=2.1.10 ghe-backup -v | grep -q "management console argon2 secret not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/manage-argon-secret" ] + + GHE_REMOTE_VERSION=3.6.1 ghe-backup -v | grep -q "management console argon2 secret not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/manage-argon-secret" ] + + GHE_REMOTE_VERSION=3.7.10 ghe-backup -v | grep -q "management console argon2 secret not set" && exit 1 [ ! -f "$GHE_DATA_DIR/current/manage-argon-secret" ] ) end_test @@ -152,6 +158,12 @@ begin_test "ghe-backup management console backs up argon secret" GHE_REMOTE_VERSION=3.8.0 ghe-backup [ "$(cat "$GHE_DATA_DIR/current/manage-argon-secret")" = "fake pw" ] + + rm -rf "$GHE_DATA_DIR/current" + + GHE_REMOTE_VERSION=4.1.0 ghe-backup + + [ "$(cat "$GHE_DATA_DIR/current/manage-argon-secret")" = "fake pw" ] ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index a4056a82f..af1425472 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -448,7 +448,7 @@ verify_all_backedup_data() { [ "$(cat "$GHE_DATA_DIR/current/manage-password")" = "fake password hash data" ] # verify manage-argon-secret file was backed up - if ! [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.0)" ]; then + if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then [ "$(cat "$GHE_DATA_DIR/current/manage-argon-secret")" = "fake argon2 secret" ] fi From d00194dcf62a1a31347f5253819f487f9978e9e1 Mon Sep 17 00:00:00 2001 From: Krayon Date: Mon, 27 Mar 2023 13:17:29 +1100 Subject: [PATCH 1756/2421] Fix version extraction --- share/github-backup-utils/ghe-backup-config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index dec492870..2d44a4ef3 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -425,8 +425,8 @@ ghe_remote_version_required() { GHE_HOSTNAME="${GHE_HOSTNAME/ OK*/}" export GHE_HOSTNAME - GHE_REMOTE_VERSION="${GHE_HOSTNAME#*\(}" - GHE_REMOTE_VERSION="${GHE_HOSTNAME%%\)*}" + GHE_REMOTE_VERSION="${_out#*\(}" + GHE_REMOTE_VERSION="${GHE_REMOTE_VERSION%%\)*}" export GHE_REMOTE_VERSION ghe_parse_remote_version "$GHE_REMOTE_VERSION" From 8747a6e307dd9a6682c127f58e71eb86eb87cd70 Mon Sep 17 00:00:00 2001 From: Krayon Date: Mon, 27 Mar 2023 23:38:49 +1100 Subject: [PATCH 1757/2421] (future) quote protection of GIST_FILTER param --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 2d44a4ef3..83533ee97 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -525,7 +525,7 @@ fix_paths_for_ghe_version() { [[ "$GHE_REMOTE_VERSION" =~ 2.17. && "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.17.14)" ]] || [[ "$GHE_REMOTE_VERSION" =~ 2.18. && "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.18.8)" ]] || [[ "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.19.3)" ]]; then - GIST_FILTER=(-e /gist/b) + GIST_FILTER=(-e "/gist/b") else unset GIST_FILTER fi From 91e6c6c3415e296330d0636440214677c97fc3f0 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Mon, 27 Mar 2023 17:29:36 -0400 Subject: [PATCH 1758/2421] Testing this initial portion of the workflow --- .github/workflows/restore.yml | 73 +++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/restore.yml diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml new file mode 100644 index 000000000..61084e875 --- /dev/null +++ b/.github/workflows/restore.yml @@ -0,0 +1,73 @@ +name: Restore Dataset + +on: + workflow_dispatch: + inputs: + size: + description: 'Size of the dataset to restore' + required: true + type: choice + default: 'small' + options: + - 'small' + - 'medium' + hostname: + description: 'Hostname of the server' + required: true + type: string + ref: + description: 'Branch ref to use' + required: false + type: string + default: 'master' + workflow_call: + inputs: + size: + description: 'Size of the dataset to restore' + required: true + type: string + default: 'small' + hostname: + description: 'Hostname of the server' + required: true + type: string + ref: + description: 'Branch ref to use' + required: false + type: string + default: 'master' +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + repository: github/backup-utils-private + ref: ${{ inputs.ref }} + - run: docker build . --file Dockerfile --tag backup-utils + - run: docker save backup-utils -o backup-utils.tar + - uses: actions/upload-artifact@v3 + with: + name: backup-utils + path: backup-utils.tar + restore: + needs: build + runs-on: ubuntu-latest + env: + SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }} + steps: + - uses: actions/download-artifact@v3 + with: + name: backup-utils + - name: Load docker container + run: docker load -i backup-utils.tar + - uses: actions/checkout@v3 + with: + repository: github/ghes-data + ref: main + - run: gunzip ghes-data/data/backup/${{ inputs.size }}/${{ inputs.size }}.zip + - run: ls -al ghes-data/data/backup/${{ inputs.size }} + + + + From 93f7a6206d60cc3ea3be46f3dc326dcc7a05f366 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 30 Mar 2023 12:46:50 -0400 Subject: [PATCH 1759/2421] update file names --- bin/ghe-backup | 4 ++-- bin/ghe-progress | 8 ++++---- bin/ghe-restore | 4 ++-- share/github-backup-utils/ghe-backup-config | 4 ++-- share/github-backup-utils/track-progress | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 2caf4dae5..06d096e72 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -47,9 +47,9 @@ export CALLING_SCRIPT="ghe-backup" # Setup progress tracking init-progress export PROGRESS_TYPE="Backup" -echo $PROGRESS_TYPE > /tmp/track-progress-type +echo $PROGRESS_TYPE > /tmp/backup-utils-progress-type export PROGRESS=0 # Used to track progress of backup -echo $PROGRESS > /tmp/track-progress +echo $PROGRESS > /tmp/backup-utils-progress export PROGRESS_TOTAL=18 # Maximum number of steps in backup # Check to make sure moreutils parallel is installed and working properly diff --git a/bin/ghe-progress b/bin/ghe-progress index 1099ad2c3..ef2964170 100755 --- a/bin/ghe-progress +++ b/bin/ghe-progress @@ -30,7 +30,7 @@ while true; do done check_for_progress_file() { - if [ ! -f /tmp/progress-info ]; then + if [ ! -f /tmp/backup-utils-progress-info ]; then echo "No progress file found. has a backup or restore been started?" exit 1 fi @@ -38,18 +38,18 @@ check_for_progress_file() { if [ -n "$ONCE" ]; then check_for_progress_file - cat /tmp/progress-info + cat /tmp/backup-utils-progress-info else check_for_progress_file clear - cat /tmp/progress-info + cat /tmp/backup-utils-progress-info while true; do if read -r -t 1 -n 1; then clear exit ; else clear - cat /tmp/progress-info + cat /tmp/backup-utils-progress-info fi done fi diff --git a/bin/ghe-restore b/bin/ghe-restore index 1b392b011..d03dff492 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -308,9 +308,9 @@ export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 5)) init-progress export PROGRESS_TYPE="Restore" -echo $PROGRESS_TYPE > /tmp/track-progress-type +echo $PROGRESS_TYPE > /tmp/backup-utils-progress-type export PROGRESS=0 # Used to track progress of restore -echo $PROGRESS > /tmp/track-progress +echo $PROGRESS > /tmp/backup-utils-progress # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 7733b91e9..bbfed9592 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -55,7 +55,7 @@ fi PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # shellcheck source=share/github-backup-utils/bm.sh . "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" -. "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" +. "$GHE_BACKUP_ROOT/share/github-backup-utils/backup-utils-progress" # Save off GHE_HOSTNAME from the environment since we want it to override the # backup.config value when set. GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" @@ -648,7 +648,7 @@ restore-secret() { #initialize progress tracking by clearing out the temp files used to track init-progress() { - rm -f /tmp/track-progress-* + rm -f /tmp/backup-utils-progress-* } diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 95e6bf6ac..a9930d627 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -4,9 +4,9 @@ # Current version is working solely with backups progress(){ - PROGRESS=$(cat /tmp/track-progress) - PROGRESS_TYPE=$(cat /tmp/track-progress-type) + PROGRESS=$(cat /tmp/backup-utils-progress) + PROGRESS_TYPE=$(cat /tmp/backup-utils-progress-type) PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) - echo $((PROGRESS +1)) > /tmp/track-progress - echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/progress-info + echo $((PROGRESS +1)) > /tmp/backup-utils-progress + echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress-info } From 979ababdb292c03ad7371d6aac3cde83c7d7319d Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 4 Apr 2023 13:03:13 -0400 Subject: [PATCH 1760/2421] Add correct amount of steps --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d03dff492..aa3848c07 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -304,7 +304,7 @@ if ! $CLUSTER && $instance_configured; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi # Maximum restore steps -export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 5)) +export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 6)) init-progress export PROGRESS_TYPE="Restore" From 7ee839b885ccbdbadc4c7976d80dcc4c000e3825 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 5 Apr 2023 12:15:39 -0400 Subject: [PATCH 1761/2421] Delete backup-verbose.log --- backup-verbose.log | 3670 -------------------------------------------- 1 file changed, 3670 deletions(-) delete mode 100644 backup-verbose.log diff --git a/backup-verbose.log b/backup-verbose.log deleted file mode 100644 index bd430d973..000000000 --- a/backup-verbose.log +++ /dev/null @@ -1,3670 +0,0 @@ -2023-03-17T16:13:33Z INFO ghe-restore: -2023-03-17T16:13:33Z INFO ghe-restore-snapshot-path: -2023-03-17T16:13:33Z INFO ghe-detect-leaked-ssh-keys: -2023-03-17T16:13:33Z INFO ghe-host-check: 10.0.1.172 -2023-03-17T16:13:33Z INFO ghe-ssh: -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172 -- [ -f '/etc/github/cluster' ] -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172 -- cat /etc/github/repl-state -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- [ -f '/etc/github/configured' ] -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] -2023-03-17T16:13:34Z INFO ghe-restore-external-database-compatibility-check: -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- [ -f '/etc/github/configured' ] -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- [ -f '/etc/github/repl-state' ] -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- logger -t backup-utils -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- sudo sponge '/data/user/common/ghe-restore-status' >/dev/null -2023-03-17T16:13:34Z INFO ghe-maintenance-mode-status: 10.0.1.172:122 -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- test -e /data/github/current/public/system/maintenance.html -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --get core.package-version -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-17T16:13:34Z INFO ghe-backup-store-version: -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 -ghe-backup-store-version took 0s -2023-03-17T16:13:34Z INFO ghe-ssh: 10.0.1.172:122 -- sudo service cron stop -2023-03-17T16:13:35Z INFO ghe-ssh: 10.0.1.172:122 -- systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null -2023-03-17T16:13:35Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/sh -mysql is running -Queued nomad job '/etc/nomad-jobs/elasticsearch/elasticsearch.hcl' -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo sponge '/data/user/common/uuid' 2>/dev/null -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo systemctl stop consul -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo rm -rf /data/user/consul/raft -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 ghe-config --true mysql.backup.binary -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-17T16:13:36Z INFO ghe-restore-mysql: 10.0.1.172:122 -Restoring password pepper ... -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/bash -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 ghe-config --true mysql.backup.binary -2023-03-17T16:13:36Z INFO ghe-restore-mysql-binary: 10.0.1.172:122 -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo mkdir -p '/data/user/tmp' -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- sudo dd of=/data/user/tmp/mysql.sql.gz >/dev/null 2>&1 -2023-03-17T16:13:36Z INFO Restore MySQL database ... -2023-03-17T16:13:36Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/bash -Mar 17 16:13:36 Stop MySQL service -active -Stop MySQL via Nomad -==> 2023-03-17T16:13:36Z: Monitoring evaluation "e479e4cf" - 2023-03-17T16:13:36Z: Evaluation triggered by job "mysql" -==> 2023-03-17T16:13:37Z: Monitoring evaluation "e479e4cf" - 2023-03-17T16:13:37Z: Evaluation status changed: "pending" -> "complete" -==> 2023-03-17T16:13:37Z: Evaluation "e479e4cf" finished with status "complete" -Waiting for 60 seconds for mysql to completely shut down -mysql is not running -mysql is not running -Mar 17 16:13:37 Available space for data: 31079 (MB). Existing datadir: 794 (MB). Available ratio: 39 -Mar 17 16:13:37 Previous emergency copy /data/user/mysql-backup is deleted! -Mar 17 16:13:37 Existing MySQL directory backed up to /data/user/mysql-backup. If you need to restore from that, run "sudo rm -rf /data/user/mysql" and then "sudo mv /data/user/mysql-backup /data/user/mysql" -Mar 17 16:13:37 Purge MySQL folder -Mar 17 16:13:37 Extracting backup -Mar 17 16:13:38 Prepare backup -Mar 17 16:13:38 Using xtrabackup 2.4 for restore -Mar 17 16:13:43 Change owner to MySQL -Mar 17 16:13:43 Start MySQL service -Queued nomad job '/etc/nomad-jobs/mysql/mysql.hcl' -Wait nomad to start MySQL -MySQL is up running -Setup mysql after startup -Finish setup mysql after startup -Mar 17 16:13:59 MySQL service started -Mar 17 16:14:00 Restore succeeded -Mar 17 16:14:00 Emergency copy of /data/user/mysql is saved at /data/user/mysql-backup. After you are sure the restore was successful, please delete this copy -ghe-restore-mysql-binary took 24s -2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- sudo rm -rf /data/user/tmp/mysql.sql.gz -ghe-restore-mysql took 24s -2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-config --true app.minio.enabled -2023-03-17T16:14:00Z INFO ghe-restore-minio: 10.0.1.172:122 -2023-03-17T16:14:00Z INFO * Transferring minio files to 10.0.1.172 ... -2023-03-17T16:14:00Z INFO ghe-ssh: -p 122 10.0.1.172 -- sudo mkdir -p /data/user/minio -2023-03-17T16:14:00Z INFO ghe-ssh: -p 122 10.0.1.172 -- sudo chown -R minio:minio /data/user/minio -2023-03-17T16:14:00Z RSYNC BEGIN: minio rsync -2023-03-17T16:14:00Z INFO ghe-rsync: --verbose --archive --hard-links --relative --delete --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync /workspace/backup-utils-private/data/20230316T212843/minio/./ 10.0.1.172:/data/user/minio/ -2023-03-17T16:14:00Z INFO ghe-ssh: -p 122 10.0.1.172 sudo -u minio rsync --server -vlHogDtprRe.iLsfxC --delete . /data/user/minio/ -sending incremental file list - -sent 94 bytes received 13 bytes 214.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-17T16:14:00Z RSYNC END: minio rsync -ghe-restore-minio took 0s -2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-import-authorized-keys -2023-03-17T16:14:00Z INFO ghe-restore-pages: 10.0.1.172:122 -2023-03-17T16:14:00Z INFO ghe-restore-es-rsync: 10.0.1.172:122 -2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- ghe-import-redis -2023-03-17T16:14:00Z INFO ghe-restore-repositories-gist: 10.0.1.172:122 -2023-03-17T16:14:00Z INFO ghe-restore-git-hooks: 10.0.1.172:122 -2023-03-17T16:14:00Z INFO ghe-restore-repositories: 10.0.1.172:122 -2023-03-17T16:14:00Z INFO ghe-restore-storage: 10.0.1.172:122 -2023-03-17T16:14:00Z WARN Warning: Pages backup missing. Skipping ... -2023-03-17T16:14:00Z WARN Warning: Storage backup missing. Skipping ... -2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- sudo mkdir -p '/data/user/elasticsearch-restore' -2023-03-17T16:14:00Z INFO ghe-ssh: -l admin 10.0.1.172:122 -- sudo -u git mkdir -p /data/user/git-hooks/repos -2023-03-17T16:14:00Z RSYNC BEGIN: git-hooks repos rsync -2023-03-17T16:14:00Z RSYNC END: git-hooks repos rsync -2023-03-17T16:14:00Z INFO ghe-ssh: 10.0.1.172:122 -- sudo chown elasticsearch:elasticsearch '/data/user/elasticsearch-restore' -2023-03-17T16:14:00Z INFO ghe-rsync: -avH --delete -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync /workspace/backup-utils-private/data/20230316T212843/git-hooks/repos/ 10.0.1.172:/data/user/git-hooks/repos - --> Stopping redis... -2023-03-17T16:14:00Z RSYNC BEGIN: elasticsearch rsync -2023-03-17T16:14:00Z INFO ghe-rsync: -avz --delete -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --copy-dest=/data/user/elasticsearch /workspace/backup-utils-private/data/20230316T212843/elasticsearch/ 10.0.1.172:/data/user/elasticsearch-restore -2023-03-17T16:14:00Z INFO ghe-ssh: -p 122 10.0.1.172 sudo -u elasticsearch rsync --server -vlogDtprze.iLsfxC --delete --copy-dest /data/user/elasticsearch . /data/user/elasticsearch-restore -sending incremental file list -./ -deleting nodes/0/_state/node-0.st -deleting nodes/0/_state/global-3.st -deleting nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/state-0.st -deleting nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/segments_1 -deleting nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/state-3.st -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/state-0.st -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/segments_1 -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/state-0.st -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/segments_1 -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/state-0.st -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/segments_1 -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/state-0.st -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/segments_1 -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/state-0.st -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/segments_1 -deleting nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/state-5.st -deleting nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/state-0.st -deleting nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/segments_1 -deleting nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/state-3.st -deleting nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/state-0.st -deleting nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/segments_1 -deleting nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/state-3.st -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/state-0.st -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/segments_1 -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/state-0.st -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/segments_1 -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/state-0.st -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/segments_1 -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/state-0.st -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/segments_1 -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/state-0.st -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/segments_1 -deleting nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/state-5.st -deleting nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/state-0.st -deleting nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/segments_1 -deleting nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/state-3.st -deleting nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/state-0.st -deleting nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/segments_1 -deleting nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/state-3.st -deleting nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/state-0.st -deleting nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/segments_1 -deleting nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/state-3.st -deleting nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/state-0.st -deleting nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/segments_1 -deleting nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/state-3.st -deleting nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/state-0.st -deleting nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/segments_1 -deleting nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/state-3.st -deleting nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/state-0.st -deleting nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/segments_1 -deleting nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/state-5.st -deleting nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/state-0.st -deleting nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/segments_1 -deleting nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/state-3.st -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/state-0.st -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/segments_1 -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/state-0.st -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/segments_1 -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/state-0.st -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/segments_1 -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/state-0.st -deleting nodes/0/indices/ROa --> Importing SSH authorized keys... -Qi7QXRdOYoj6_dXARBQ/3/index/segments_1 -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/state-0.st -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/segments_1 -deleting nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/state-5.st -deleting nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/state-0.st -deleting nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/segments_1 -deleting nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/state-3.st -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/state-0.st -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/segments_1 -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/state-0.st -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/segments_1 -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/state-0.st -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/segments_1 -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/state-0.st -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/segments_1 -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/state-0.st -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/segments_1 -deleting nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/state-5.st -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/state-0.st -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/segments_1 -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/state-0.st -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/segments_1 -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/state-0.st -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/segments_3 -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/state-0.st -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/segments_1 -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/state-0.st -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/segments_1 -deleting nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/state-5.st -deleting nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/state-0.st -deleting nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/segments_1 -deleting nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/state-3.st -deleting nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/state-0.st -deleting nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/segments_3 -deleting nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/state-3.st -deleting nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/state-0.st -deleting nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/segments_1 -deleting nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/state-3.st -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/state-0.st -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/segments_1 -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/state-0.st -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/segments_1 -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/state-0.st -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/segments_1 -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/state-0.st -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/segments_1 -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/state-0.st -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/segments_1 -deleting nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/state-5.st -deleting nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/state-0.st -deleting nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/segments_1 -deleting nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/state-3.st -deleting nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/state-0.st -deleting nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/segments_1 -deleting nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/state-3.st -deleting nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/state-0.st -deleting nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/segments_3 -deleting nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/state-4.st -deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/state-0.st -deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_h -deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_7.si -deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_7.cfs -deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_7.cfe -deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-9.tlog -deleting nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/state-4.st -deleting nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/state-0.st -deleting nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/segments_1 -deleting nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/state-3.st -deleting nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/state-0.st -deleting nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/segments_1 -deleting nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/state-3.st -deleting nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/state-0.st -deleting nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/segments_1 -deleting nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/state-3.st -nodes/0/ -nodes/0/_state/ -nodes/0/_state/global-5.st -nodes/0/_state/node-2.st -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/state-2.st -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/segments_3 -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog.ckp -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/state-9.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/state-2.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/segments_3 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/state-2.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/segments_3 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/state-2.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/segments_3 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/state-2.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/segments_3 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/state-2.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/segments_3 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/state-13.st -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/state-2.st -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/segments_3 -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog.ckp -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/state-9.st -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/state-2.st -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/segments_3 -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog.ckp -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/state-9.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/state-2.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/segments_3 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/state-2.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/segments_3 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/state-2.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/segments_3 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/state-2.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/segments_3 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/state-2.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/segments_3 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/state-13.st -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/state-2.st -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/segments_3 -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog.ckp -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/state-9.st -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/state-2.st -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/segments_3 -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog.ckp -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/state-9.st -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/state-2.st -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/segments_3 -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog.ckp -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/state-9.st -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/state-2.st -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/segments_3 -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog.ckp -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/state-9.st -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/state-2.st -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/segments_3 -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog.ckp -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/state-9.st -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/state-2.st -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/segments_3 -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog.ckp -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/state-11.st -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/state-2.st -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/segments_3 -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog.ckp -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/state-9.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/state-2.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/segments_3 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/state-2.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/segments_3 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/state-2.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/segments_3 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/state-2.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/segments_3 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/state-2.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/segments_3 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/state-13.st -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/state-2.st -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/segments_3 -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog.ckp -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/state-9.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/state-2.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/segments_3 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/state-2.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/segments_3 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/state-2.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/segments_3 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/state-2.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/segments_3 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/state-2.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/segments_3 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/state-13.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/state-2.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/segments_3 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/state-2.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/segments_3 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/state-2.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/segments_5 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/state-2.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/segments_3 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/state-2.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/segments_3 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/state-13.st -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/state-2.st -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/segments_3 -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog.ckp -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/state-9.st -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/state-2.st -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/segments_5 -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog-4.tlog -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog.ckp -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/state-9.st -nodes/0/indices/ejnFd11uQteAkjE995T2tw/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/state-2.st -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/segments_3 -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog.ckp -nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/state-9.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/state-2.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/segments_3 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/state-2.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/segments_3 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/state-2.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/segments_3 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/state-2.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/segments_3 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/state-2.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/segments_3 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/state-13.st -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/state-2.st -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/segments_3 -nodes/0/indices/kSoL8UdcRTy558OhM==> 2023-03-17T16:14:00Z: Monitoring evaluation "58730a17" - 2023-03-17T16:14:00Z: Evaluation triggered by job "redis" -RyvRw/0/translog/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog.ckp -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/state-9.st -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/state-2.st -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/segments_3 -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog.ckp -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/state-9.st -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/state-2.st -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/segments_5 -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog.ckp -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/state-10.st -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/state-2.st -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_g.cfe -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_g.cfs -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_g.si -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_v -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-18.tlog -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/state-10.st -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/state-2.st -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/segments_3 -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog.ckp -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/state-9.st -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/state-2.st -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/segments_3 -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog.ckp -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/state-9.st -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/state-2.st -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/segments_3 -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog.ckp -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/state-9.st - -sent 86,283 bytes received 13,126 bytes 198,818.00 bytes/sec -total size is 142,465 speedup is 1.43 -2023-03-17T16:14:00Z RSYNC END: elasticsearch rsync -ghe-restore-es-rsync took 0s -sending incremental file list - -sent 58 bytes received 12 bytes 140.00 bytes/sec -total size is 0 speedup is 0.00 -ghe-restore-git-hooks took 0s -==> 2023-03-17T16:14:01Z: Monitoring evaluation "58730a17" - 2023-03-17T16:14:01Z: Evaluation status changed: "pending" -> "complete" -==> 2023-03-17T16:14:01Z: Evaluation "58730a17" finished with status "complete" - --> Importing redis data... - --> Starting redis... -Queued nomad job '/etc/nomad-jobs/redis/redis.hcl' -Waiting for redis service -Status = running - --> Make sure redis is ready... - --> Remove stale resque worker entries... -2023-03-17T16:14:09Z INFO Restarting memcached ... -2023-03-17T16:14:09Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/sh -2023-03-17T16:14:09Z INFO Setting last run date for GitHub Connect jobs ... -2023-03-17T16:14:09Z INFO ghe-ssh: 10.0.1.172:122 -- /bin/sh -2023-03-17T16:14:09Z INFO ghe-ssh: 10.0.1.172:122 -- sudo sponge '/data/user/common/ghe-restore-status' >/dev/null -2023-03-17T16:14:09Z INFO ghe-ssh: 10.0.1.172:122 -- sudo timeout 120s service cron start -2023-03-17T16:14:10Z INFO ghe-ssh: --clean -2023-03-17T16:14:10Z INFO Removing in-progress file ... -2023-03-21T20:40:04Z INFO ghe-backup -2023-03-21T20:40:04Z INFO ghe-host-check -2023-03-21T20:40:04Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh -2023-03-21T20:40:05Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] -2023-03-21T20:40:05Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state -2023-03-21T20:40:05Z INFO ghe-rsync-size.sh -2023-03-21T20:40:05Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ -2023-03-21T20:40:05Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ -2023-03-21T20:40:05Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ -2023-03-21T20:40:06Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ -2023-03-21T20:40:06Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ -2023-03-21T20:40:06Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ -2023-03-21T20:40:07Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ -2023-03-21T20:40:07Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ -2023-03-21T20:40:07Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-21T20:40:08Z INFO ghe-backup-strategy -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] -2023-03-21T20:40:08Z INFO ghe-backup-store-version -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 -ghe-backup-store-version took 0s -2023-03-21T20:40:08Z INFO ghe-backup-settings -2023-03-21T20:40:08Z INFO * Transferring settings data ... -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings -2023-03-21T20:40:08Z INFO * Transferring license data ... -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' -2023-03-21T20:40:08Z INFO * Transferring management console password ... -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage -2023-03-21T20:40:08Z INFO * Transferring password pepper ... -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets -2023-03-21T20:40:08Z INFO * Transferring kredz.credz HMAC key ... -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret -2023-03-21T20:40:08Z INFO * Transferring kredz.varz HMAC key ... -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret -2023-03-21T20:40:08Z INFO * Transferring management console argon2 secret ... -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null -2023-03-21T20:40:08Z INFO * Transferring CA certificates ... -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null -2023-03-21T20:40:08Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys -ghe-export-authorized-keys took 0s -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys -ghe-export-ssh-host-keys took 0s -2023-03-21T20:40:08Z INFO ghe-backup-mysql -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary -2023-03-21T20:40:08Z INFO ghe-backup-mysql-binary -2023-03-21T20:40:08Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -ghe-backup-mysql-binary took 3s -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled -2023-03-21T20:40:11Z INFO ghe-backup-minio -2023-03-21T20:40:11Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-21T20:40:11Z RSYNC BEGIN: minio rsync -2023-03-21T20:40:11Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230321T204004/minio -2023-03-21T20:40:11Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-21T20:40:11Z RSYNC END: minio rsync -ghe-backup-minio took 0s -2023-03-21T20:40:11Z INFO ghe-backup-es-audit-log -2023-03-21T20:40:11Z INFO ghe-backup-pages -2023-03-21T20:40:11Z INFO ghe-backup-repositories -2023-03-21T20:40:11Z INFO ghe-backup-storage -2023-03-21T20:40:11Z INFO ghe-backup-redis -2023-03-21T20:40:11Z INFO ghe-backup-es-rsync -2023-03-21T20:40:11Z INFO ghe-backup-git-hooks - -2023-03-21T20:40:11Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-21T20:40:11Z INFO * Transferring pages files ... -2023-03-21T20:40:11Z RSYNC BEGIN: pages rsync -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] -2023-03-21T20:40:11Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230321T204004/pages -2023-03-21T20:40:11Z INFO * Performing initial sync of ES indices ... -2023-03-21T20:40:11Z RSYNC BEGIN elasticsearch rsync -2023-03-21T20:40:11Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-21T20:40:11Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-21T20:40:11Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204004/elasticsearch -2023-03-21T20:40:11Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-21T20:40:11Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -2023-03-21T20:40:11Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -2023-03-21T20:40:11Z RSYNC BEGIN: git-hooks sync -ghe-backup-es-audit-log took 0s -2023-03-21T20:40:11Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230321T204004/git-hooks/repos -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -receiving incremental file list -./ -nodes/0/ -nodes/0/_state/ -nodes/0/_state/global-6.st -nodes/0/_state/node-3.st -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/state-3.st -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/segments_4 -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog-3.ckp -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog-4.tlog -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog.ckp -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/state-12.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/state-17.st -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/state-3.st -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/segments_4 -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog-3.ckp -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog-4.tlog -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog.ckp -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/state-12.st -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/state-3.st -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/segments_4 -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog-3.ckp -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog-4.tlog -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog.ckp -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/state-12.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/state-17.st -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/state-3.st -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/segments_4 -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog-3.ckp -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog-4.tlog -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog.ckp -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/state-12.st -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/state-3.st -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/segments_4 -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog-3.ckp -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog-4.tlog -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog.ckp -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/state-12.st -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/state-3.st -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/segments_4 -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog-3.ckp -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog-4.tlog -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog.ckp -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/state-12.st -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/state-3.st -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/segments_4 -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog-3.ckp -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog-4.tlog -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog.ckp -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/state-12.st -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/state-3.st -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/segments_4 -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog-3.ckp -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog-4.tlog -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog.ckp -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/state-12.st -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/state-3.st -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/segments_4 -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog-3.ckp -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog-4.tlog -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog.ckp -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/state-14.st -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/state-3.st -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/segments_4 -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog-3.ckp -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog-4.tlog -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog.ckp -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/state-12.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog-3.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog-3.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog-3.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog-3.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog-3.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/state-17.st -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/state-3.st -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/segments_4 -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog-3.ckp -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog-4.tlog -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog.ckp -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/state-12.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/state-17.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/segments_4 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog-3.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog-4.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/segments_4 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog-3.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog-4.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/segments_6 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog-4.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog-5.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/segments_4 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog-3.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog-4.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/segments_4 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog-3.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog-4.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/state-17.st -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/state-3.st -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/segments_4 -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog-3.ckp -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog-4.tlog -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog.ckp -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/state-12.st -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/state-3.st -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.cfe -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.cfs -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.si -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/segments_8 -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog-6.tlog -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog.ckp -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/state-12.st -nodes/0/indices/ejnFd11uQteAkjE995T2tw/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/state-3.st -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/segments_4 -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog-3.ckp -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog-4.tlog -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog.ckp -nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/state-12.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/state-17.st -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/state-3.st -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/segments_4 -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog-3.ckp -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog-4.tlog -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog.ckp -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/state-12.st -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/state-3.st -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/segments_4 -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog-3.ckp -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog-4.tlog -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog.ckp -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/state-12.st -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/state-3.st -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/segments_6 -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog-4.ckp -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog-5.tlog -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog.ckp -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/state-13.st -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/state-3.st -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.cfe -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.cfs -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.si -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_15 -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-24.tlog -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/state-13.st -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/state-3.st -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/segments_4 -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog-3.ckp -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog-4.tlog -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog.ckp -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/state-12.st -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/state-3.st -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/segments_4 -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog-3.ckp -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog-4.tlog -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog.ckp -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/state-12.st -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/state-3.st -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/segments_4 -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog-3.ckp -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog-4.tlog -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog.ckp -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/state-12.st - -sent 6,918 bytes received 97,851 bytes 209,538.00 bytes/sec -total size is 146,931 speedup is 1.40 -2023-03-21T20:40:11Z RSYNC END elasticsearch rsync -2023-03-21T20:40:11Z INFO * Disabling ES index flushing ... -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush -2023-03-21T20:40:11Z INFO * Performing follow-up sync of ES indices ... -2023-03-21T20:40:11Z RSYNC BEGIN: elasticsearch followup rsync -2023-03-21T20:40:11Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204004/elasticsearch -2023-03-21T20:40:11Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-21T20:40:11Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -receiving incremental file list - -sent 282 bytes received 22,566 bytes 45,696.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-21T20:40:11Z RSYNC END: elasticsearch followup rsync -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete -ghe-backup-es-rsync took 0s -2023-03-21T20:40:11Z INFO * Enabling ES index flushing ... -2023-03-21T20:40:11Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-21T20:40:11Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -ghe-backup-redis took 1s -2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-6nt2a6/remote_routes_list -ghe-backup-storage - Generating routes took 2s -2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-6nt2a6/remote_routes_list -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-21T20:40:13Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-6nt2a6 -2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-8O0hUx/remote_routes_list -ghe-backup-repositories - Generating routes took 2s -2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-8O0hUx/remote_routes_list -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s -2023-03-21T20:40:13Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-8O0hUx -2023-03-21T20:40:13Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-21T20:40:13Z INFO ghe-ssh --clean -2023-03-21T20:43:38Z INFO ghe-backup -2023-03-21T20:43:38Z INFO ghe-host-check -2023-03-21T20:43:38Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh -2023-03-21T20:43:39Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] -2023-03-21T20:43:39Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state -2023-03-21T20:43:39Z INFO ghe-rsync-size.sh -2023-03-21T20:43:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ -2023-03-21T20:43:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ -2023-03-21T20:43:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ -2023-03-21T20:43:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ -2023-03-21T20:43:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ -2023-03-21T20:43:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ -2023-03-21T20:43:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ -2023-03-21T20:43:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ -2023-03-21T20:43:41Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-21T20:43:41Z INFO ghe-backup-strategy -2023-03-21T20:43:41Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] -2023-03-21T20:43:41Z INFO ghe-backup-store-version -2023-03-21T20:43:41Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 -ghe-backup-store-version took 1s -2023-03-21T20:43:42Z INFO ghe-backup-settings -2023-03-21T20:43:42Z INFO * Transferring settings data ... -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings -2023-03-21T20:43:42Z INFO * Transferring license data ... -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' -2023-03-21T20:43:42Z INFO * Transferring management console password ... -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage -2023-03-21T20:43:42Z INFO * Transferring password pepper ... -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets -2023-03-21T20:43:42Z INFO * Transferring kredz.credz HMAC key ... -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret -2023-03-21T20:43:42Z INFO * Transferring kredz.varz HMAC key ... -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret -2023-03-21T20:43:42Z INFO * Transferring management console argon2 secret ... -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null -2023-03-21T20:43:42Z INFO * Transferring CA certificates ... -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null -2023-03-21T20:43:42Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys -ghe-export-authorized-keys took 0s -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys -ghe-export-ssh-host-keys took 0s -2023-03-21T20:43:42Z INFO ghe-backup-mysql -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary -2023-03-21T20:43:42Z INFO ghe-backup-mysql-binary -2023-03-21T20:43:42Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -ghe-backup-mysql-binary took 3s -ghe-backup-mysql took 3s -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled -2023-03-21T20:43:45Z INFO ghe-backup-minio -2023-03-21T20:43:45Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-21T20:43:45Z RSYNC BEGIN: minio rsync -2023-03-21T20:43:45Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230321T204338/minio -2023-03-21T20:43:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-21T20:43:45Z RSYNC END: minio rsync -ghe-backup-minio took 0s -Backup progress: 0 % -2023-03-21T20:43:45Z INFO ghe-backup-es-audit-log -2023-03-21T20:43:45Z INFO ghe-backup-storage -2023-03-21T20:43:45Z INFO ghe-backup-pages -2023-03-21T20:43:45Z INFO ghe-backup-repositories -2023-03-21T20:43:45Z INFO ghe-backup-redis -2023-03-21T20:43:45Z INFO ghe-backup-git-hooks -2023-03-21T20:43:45Z INFO ghe-backup-es-rsync - -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" -2023-03-21T20:43:45Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] -2023-03-21T20:43:45Z INFO * Transferring pages files ... -2023-03-21T20:43:45Z RSYNC BEGIN: pages rsync -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] -2023-03-21T20:43:45Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230321T204338/pages -2023-03-21T20:43:45Z INFO * Performing initial sync of ES indices ... -2023-03-21T20:43:45Z RSYNC BEGIN elasticsearch rsync -2023-03-21T20:43:45Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-21T20:43:45Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-21T20:43:45Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-21T20:43:45Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204338/elasticsearch -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-21T20:43:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -2023-03-21T20:43:45Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -2023-03-21T20:43:45Z RSYNC BEGIN: git-hooks sync -2023-03-21T20:43:45Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230321T204338/git-hooks/repos -receiving incremental file list -./ -nodes/0/ -nodes/0/_state/ -nodes/0/_state/global-6.st -nodes/0/_state/node-3.st -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/_state/state-3.st -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/index/segments_4 -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog-3.ckp -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog-4.tlog -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/0/translog/translog.ckp -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/ -nodes/0/indices/CS_sFocfT6u1eFWFGzb8vw/_state/state-12.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/0/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/1/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/2/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/3/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/_state/state-3.st -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/index/segments_4 -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog-3.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog-4.tlog -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/4/translog/translog.ckp -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/ -nodes/0/indices/D13gT6mLTvGeb-ZQzc7pPA/_state/state-17.st -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/_state/state-3.st -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/index/segments_4 -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog-3.ckp -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog-4.tlog -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/0/translog/translog.ckp -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/ -nodes/0/indices/GWIMu9xGST2pbfMj9ZMxZA/_state/state-12.st -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/_state/state-3.st -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/index/segments_4 -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog-3.ckp -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog-4.tlog -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/0/translog/translog.ckp -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/ -nodes/0/indices/HUddkNYsRnml3lHHHncr8g/_state/state-12.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/0/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/1/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/2/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/3/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/_state/state-3.st -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/index/segments_4 -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog-3.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog-4.tlog -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/4/translog/translog.ckp -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/ -nodes/0/indices/INuMeFT2RcWuaDMLvxS6-g/_state/state-17.st -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/_state/state-3.st -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/index/segments_4 -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog-3.ckp -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog-4.tlog -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/0/translog/translog.ckp -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/ -nodes/0/indices/JQqbIUmfSkKFkZwHNDnAHw/_state/state-12.st -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/_state/state-3.st -nodes/2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/index/segments_4 -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog-3.ckp -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog-4.tlog -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/0/translog/translog.ckp -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/ -nodes/0/indices/JcOS8wTiTDCvEdtbJiKjAg/_state/state-12.st -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/_state/state-3.st -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/index/segments_4 -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog-3.ckp -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog-4.tlog -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/0/translog/translog.ckp -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/ -nodes/0/indices/KmdCQbP2TjS0tYM--mLt6g/_state/state-12.st -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/_state/state-3.st -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/index/segments_4 -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog-3.ckp -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog-4.tlog -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/0/translog/translog.ckp -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/ -nodes/0/indices/LrLE-iNXTZOE13QBMuuB-g/_state/state-12.st -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/_state/state-3.st -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/index/segments_4 -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog-3.ckp -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog-4.tlog -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/0/translog/translog.ckp -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/ -nodes/0/indices/NS0cQLV9RXW2c30r7wb5Ag/_state/state-12.st -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/_state/state-3.st -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/index/segments_4 -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog-3.ckp -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog-4.tlog -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/0/translog/translog.ckp -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/ -nodes/0/indices/Ptb9M-aBQmu4jouvK4gIOQ/_state/state-14.st -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/_state/state-3.st -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/index/segments_4 -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog-3.ckp -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog-4.tlog -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/0/translog/translog.ckp -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/ -nodes/0/indices/QG_HmIUwTQ2k7jSypKgcEg/_state/state-12.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog-3.ckp -node2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -s/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/0/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog-3.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/1/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog-3.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/2/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog-3.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/3/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/_state/state-3.st -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/index/segments_4 -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog-3.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog-4.tlog -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/4/translog/translog.ckp -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/ -nodes/0/indices/ROaQi7QXRdOYoj6_dXARBQ/_state/state-17.st -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/_state/state-3.st -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/index/segments_4 -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog-3.ckp -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog-4.tlog -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/0/translog/translog.ckp -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/ -nodes/0/indices/V1jY-W_WT1KsBNZbsV-OeQ/_state/state-12.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/0/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/1/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/2/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/3/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/_state/state-3.st -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/index/segments_4 -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog-3.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog-4.tlog -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/4/translog/translog.ckp -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/ -nodes/0/indices/XwzYvBVuRfCHOpRSDO81fw/_state/state-17.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/index/segments_4 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog-3.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog-4.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/0/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/index/segments_4 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog-3.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog-4.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/1/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/index/segments_6 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog-4.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog-5.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/2/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/index/segments_4 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog-3.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog-4.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/3/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/_state/state-3.st -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/index/segments_4 -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog-3.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog-4.tlog -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/4/translog/translog.ckp -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/ -nodes/0/indices/_b3C1g9OTTKwg8ap9pjo7w/_state/state-17.st -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/_state/state-3.st -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/index/segments_4 -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog-3.ckp -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog-4.tlog -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/0/translog/translog.ckp -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/ -nodes/0/indices/bQtmEnznQTeEbknCOF10sg/_state/state-12.st -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/_state/state-3.st -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.cfe -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.cfs -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/_2.si -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/index/segments_8 -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog-6.tlog -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/0/translog/translog.ckp -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/ -nodes/0/indices/dJgUvIu4Q_yUaeOCvZp37w/_state/state-12.st -nodes/0/indices/ejnFd11uQteAkjE995T2tw/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/_state/state-3.st -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/index/segments_4 -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog-3.ckp -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog-4.tlog -nodes/0/indices/ejnFd11uQteAkjE995T2tw/0/translog/translog.ckp -nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/ -nodes/0/indices/ejnFd11uQteAkjE995T2tw/_state/state-12.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/0/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/1/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/2/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/3/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/_state/state-3.st -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/index/segments_4 -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog-3.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog-4.tlog -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/4/translog/translog.ckp -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/ -nodes/0/indices/jLsz09yRTRGbZ2DRnTRZvQ/_state/state-17.st -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/_state/state-3.st -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/index/segments_4 -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog-3.ckp -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog-4.tlog -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/0/translog/translog.ckp -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/ -nodes/0/indices/kSoL8UdcRTy558OhMRyvRw/_state/state-12.st -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/_state/state-3.st -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/index/segments_4 -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog-3.ckp -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog-4.tlog -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/0/translog/translog.ckp -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/ -nodes/0/indices/koce035FTPWx0cPRGgwg1Q/_state/state-12.st -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/_state/state-3.st -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/index/segments_6 -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog-4.ckp -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog-5.tlog -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/0/translog/translog.ckp -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/ -nodes/0/indices/oVEkEoz8QICQDI5bKTdv0w/_state/state-13.st -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/_state/state-3.st -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.cfe -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.cfs -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_n.si -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_15 -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-24.tlog -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/_state/state-13.st -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/_state/state-3.st -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/index/segments_4 -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog-3.ckp -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog-4.tlog -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/0/translog/translog.ckp -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/ -nodes/0/indices/to65udU4QOmUO6NXHgrpXA/_state/state-12.st -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/_state/state-3.st -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/index/segments_4 -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog-3.ckp -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog-4.tlog -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/0/translog/translog.ckp -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/ -nodes/0/indices/uCg6nvuyS_mMotJ1mgsqdw/_state/state-12.st -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/_state/state-3.st -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/index/segments_4 -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog-3.ckp -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog-4.tlog -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/0/translog/translog.ckp -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/ -nodes/0/indices/w81vtDDNSbuBXzcC6G0oCg/_state/state-12.st - -sent 6,918 bytes received 97,851 bytes 209,538.00 bytes/sec -total size is 146,931 speedup is 1.40 -2023-03-21T20:43:45Z RSYNC END elasticsearch rsync -2023-03-21T20:43:45Z INFO * Disabling ES index flushing ... -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush -2023-03-21T20:43:45Z INFO * Performing follow-up sync of ES indices ... -2023-03-21T20:43:45Z RSYNC BEGIN: elasticsearch followup rsync -2023-03-21T20:43:45Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204338/elasticsearch -2023-03-21T20:43:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -receiving incremental file list - -sent 286 bytes received 22,570 bytes 45,712.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-21T20:43:45Z RSYNC END: elasticsearch followup rsync -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-21T20:43:45Z RSYNC END: pages rsync -ghe-backup-es-rsync took 0s -2023-03-21T20:43:45Z INFO * Enabling ES index flushing ... -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -2023-03-21T20:43:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-21T20:43:45Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -ghe-backup-redis took 1s -2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-QwYGTC/remote_routes_list -ghe-backup-storage - Generating routes took 2s -2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-QwYGTC/remote_routes_list -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-21T20:43:47Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-QwYGTC -2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-Jrpjeh/remote_routes_list -ghe-backup-repositories - Generating routes took 2s -2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-Jrpjeh/remote_routes_list -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s -2023-03-21T20:43:47Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-Jrpjeh -2023-03-21T20:43:47Z INFO ghe-prune-snapshots -2023-03-21T20:43:47Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-21T20:43:47Z INFO ghe-detect-leaked-ssh-keys -2023-03-21T20:43:47Z INFO ghe-ssh --clean -2023-03-21T20:47:38Z INFO ghe-backup -2023-03-21T20:47:38Z INFO ghe-host-check -2023-03-21T20:47:38Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh -2023-03-21T20:47:39Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] -2023-03-21T20:47:39Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state -2023-03-21T20:47:39Z INFO ghe-rsync-size.sh -2023-03-21T20:47:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ -2023-03-21T20:47:39Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ -2023-03-21T20:47:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ -2023-03-21T20:47:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ -2023-03-21T20:47:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ -2023-03-21T20:47:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ -2023-03-21T20:47:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ -2023-03-21T20:47:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-21T20:47:42Z INFO ghe-backup-strategy -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] -2023-03-21T20:47:42Z INFO ghe-backup-store-version -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 -ghe-backup-store-version took 0s -2023-03-21T20:47:42Z INFO ghe-backup-settings -2023-03-21T20:47:42Z INFO * Transferring settings data ... -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings -2023-03-21T20:47:42Z INFO * Transferring license data ... -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' -2023-03-21T20:47:42Z INFO * Transferring management console password ... -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage -2023-03-21T20:47:42Z INFO * Transferring password pepper ... -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets -2023-03-21T20:47:42Z INFO * Transferring kredz.credz HMAC key ... -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret -2023-03-21T20:47:42Z INFO * Transferring kredz.varz HMAC key ... -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret -2023-03-21T20:47:42Z INFO * Transferring management console argon2 secret ... -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null -2023-03-21T20:47:42Z INFO * Transferring CA certificates ... -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null -2023-03-21T20:47:42Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys -ghe-export-authorized-keys took 0s -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys -ghe-export-ssh-host-keys took 0s -2023-03-21T20:47:42Z INFO ghe-backup-mysql -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary -2023-03-21T20:47:42Z INFO ghe-backup-mysql-binary -2023-03-21T20:47:42Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -ghe-backup-mysql-binary took 3s -ghe-backup-mysql took 3s -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled -2023-03-21T20:47:45Z INFO ghe-backup-minio -2023-03-21T20:47:45Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-21T20:47:45Z RSYNC BEGIN: minio rsync -2023-03-21T20:47:45Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230321T204738/minio -2023-03-21T20:47:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-21T20:47:45Z RSYNC END: minio rsync -ghe-backup-minio took 0s -Backup progress: % -2023-03-21T20:47:45Z INFO ghe-backup-es-audit-log -2023-03-21T20:47:45Z INFO ghe-backup-es-rsync -2023-03-21T20:47:45Z INFO ghe-backup-git-hooks -2023-03-21T20:47:45Z INFO ghe-backup-repositories -2023-03-21T20:47:45Z INFO ghe-backup-redis -2023-03-21T20:47:45Z INFO ghe-backup-storage -2023-03-21T20:47:45Z INFO ghe-backup-pages - -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-21T20:47:45Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" -2023-03-21T20:47:45Z INFO * Transferring pages files ... -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] -2023-03-21T20:47:45Z RSYNC BEGIN: pages rsync -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] -2023-03-21T20:47:45Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230321T204738/pages -2023-03-21T20:47:45Z INFO * Performing initial sync of ES indices ... -2023-03-21T20:47:45Z RSYNC BEGIN elasticsearch rsync -2023-03-21T20:47:45Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-21T20:47:45Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204738/elasticsearch -2023-03-21T20:47:45Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-21T20:47:45Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-21T20:47:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -2023-03-21T20:47:45Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -2023-03-21T20:47:45Z RSYNC BEGIN: git-hooks sync -2023-03-21T20:47:45Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230321T204738/git-hooks/repos -receiving incremental file list -./ - -sent 289 bytes received 22,573 bytes 45,724.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-21T20:47:45Z RSYNC END elasticsearch rsync -2023-03-21T20:47:45Z INFO * Disabling ES index flushing ... -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush -2023-03-21T20:47:45Z INFO * Performing follow-up sync of ES indices ... -2023-03-21T20:47:45Z RSYNC BEGIN: elasticsearch followup rsync -2023-03-21T20:47:45Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230321T204738/elasticsearch -2023-03-21T20:47:45Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -receiving incremental file list - -sent 282 bytes received 22,566 bytes 45,696.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-21T20:47:45Z RSYNC END: elasticsearch followup rsync -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete -ghe-backup-es-rsync took 0s -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-21T20:47:45Z RSYNC END: pages rsync -2023-03-21T20:47:45Z INFO * Enabling ES index flushing ... -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -2023-03-21T20:47:45Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-21T20:47:45Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -ghe-backup-redis took 1s -2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-VGilqT/remote_routes_list -ghe-backup-storage - Generating routes took 2s -2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-VGilqT/remote_routes_list -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-21T20:47:47Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-VGilqT -2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-if4Tbi/remote_routes_list -ghe-backup-repositories - Generating routes took 2s -2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-if4Tbi/remote_routes_list -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s -2023-03-21T20:47:47Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-if4Tbi -2023-03-21T20:47:47Z INFO ghe-prune-snapshots -2023-03-21T20:47:47Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-21T20:47:47Z INFO ghe-detect-leaked-ssh-keys -2023-03-21T20:47:48Z INFO ghe-ssh --clean -2023-03-22T18:31:55Z INFO ghe-backup -2023-03-22T18:31:55Z INFO ghe-host-check -2023-03-22T18:31:55Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh -2023-03-22T18:31:55Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] -2023-03-22T18:31:55Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state -2023-03-22T18:31:55Z INFO ghe-rsync-size.sh -2023-03-22T18:31:55Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ -2023-03-22T18:31:56Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ -2023-03-22T18:31:56Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ -2023-03-22T18:31:56Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ -2023-03-22T18:31:56Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ -2023-03-22T18:31:57Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ -2023-03-22T18:31:57Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ -2023-03-22T18:31:57Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-22T18:31:58Z INFO ghe-backup-strategy -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] -2023-03-22T18:31:58Z INFO ghe-backup-store-version -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 -ghe-backup-store-version took 0s -2023-03-22T18:31:58Z INFO ghe-backup-settings -2023-03-22T18:31:58Z INFO * Transferring settings data ... -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings -2023-03-22T18:31:58Z INFO * Transferring license data ... -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' -2023-03-22T18:31:58Z INFO * Transferring management console password ... -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage -2023-03-22T18:31:58Z INFO * Transferring password pepper ... -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets -2023-03-22T18:31:58Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret -2023-03-22T18:31:58Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret -2023-03-22T18:31:58Z INFO * Transferring management console argon2 secret ... -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null -2023-03-22T18:31:58Z INFO * Transferring CA certificates ... -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates -2023-03-22T18:31:58Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null -2023-03-22T18:31:58Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys -ghe-export-authorized-keys took 1s -2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys -ghe-export-ssh-host-keys took 0s -2023-03-22T18:31:59Z INFO ghe-backup-mysql -2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary -2023-03-22T18:31:59Z INFO ghe-backup-mysql-binary -2023-03-22T18:31:59Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -ghe-backup-mysql-binary took 2s -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled -2023-03-22T18:32:01Z INFO ghe-backup-minio -2023-03-22T18:32:01Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T18:32:01Z RSYNC BEGIN: minio rsync -2023-03-22T18:32:01Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230322T183155/minio -2023-03-22T18:32:01Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:32:01Z RSYNC END: minio rsync -ghe-backup-minio took 0s -2023-03-22T18:32:01Z INFO ghe-backup-es-audit-log -2023-03-22T18:32:01Z INFO ghe-backup-redis -2023-03-22T18:32:01Z INFO ghe-backup-es-rsync -2023-03-22T18:32:01Z INFO ghe-backup-repositories -2023-03-22T18:32:01Z INFO ghe-backup-pages -2023-03-22T18:32:01Z INFO ghe-backup-storage -2023-03-22T18:32:01Z INFO ghe-backup-git-hooks - -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-22T18:32:01Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" -2023-03-22T18:32:01Z INFO * Transferring pages files ... -2023-03-22T18:32:01Z RSYNC BEGIN: pages rsync -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] -2023-03-22T18:32:01Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230322T183155/pages -2023-03-22T18:32:01Z INFO * Performing initial sync of ES indices ... -2023-03-22T18:32:01Z RSYNC BEGIN elasticsearch rsync -2023-03-22T18:32:01Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T18:32:01Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-22T18:32:01Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-22T18:32:01Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183155/elasticsearch -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:32:01Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -2023-03-22T18:32:01Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -ghe-backup-es-audit-log took 0s -2023-03-22T18:32:01Z RSYNC BEGIN: git-hooks sync -2023-03-22T18:32:01Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230322T183155/git-hooks/repos -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -receiving incremental file list -./ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.cfe -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.cfs -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.si -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_17 -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-25.tlog -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp - -sent 422 bytes received 24,766 bytes 50,376.00 bytes/sec -total size is 146,931 speedup is 5.83 -2023-03-22T18:32:01Z RSYNC END elasticsearch rsync -2023-03-22T18:32:01Z INFO * Disabling ES index flushing ... -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush -2023-03-22T18:32:01Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T18:32:01Z RSYNC BEGIN: elasticsearch followup rsync -2023-03-22T18:32:01Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183155/elasticsearch -2023-03-22T18:32:01Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -receiving incremental file list - -sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:32:01Z RSYNC END: elasticsearch followup rsync -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:32:01Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-es-rsync took 0s -ghe-backup-pages took 0s -2023-03-22T18:32:01Z INFO * Enabling ES index flushing ... -2023-03-22T18:32:01Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 56.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:32:02Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 1s -ghe-backup-redis took 1s -2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-B2RYgJ/remote_routes_list -ghe-backup-storage - Generating routes took 2s -2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-B2RYgJ/remote_routes_list -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T18:32:03Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-B2RYgJ -2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-xj3iWS/remote_routes_list -ghe-backup-repositories - Generating routes took 2s -2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-xj3iWS/remote_routes_list -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s -2023-03-22T18:32:03Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-xj3iWS -2023-03-22T18:32:03Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-22T18:32:04Z INFO ghe-ssh --clean -2023-03-22T18:33:39Z INFO ghe-backup -2023-03-22T18:33:39Z INFO ghe-host-check -2023-03-22T18:33:39Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh -2023-03-22T18:33:40Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] -2023-03-22T18:33:40Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state -2023-03-22T18:33:40Z INFO ghe-rsync-size.sh -2023-03-22T18:33:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ -2023-03-22T18:33:40Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ -2023-03-22T18:33:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ -2023-03-22T18:33:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ -2023-03-22T18:33:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ -2023-03-22T18:33:41Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ -2023-03-22T18:33:42Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ -2023-03-22T18:33:42Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-22T18:33:43Z INFO ghe-backup-strategy -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] -2023-03-22T18:33:43Z INFO ghe-backup-store-version -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 -ghe-backup-store-version took 0s -2023-03-22T18:33:43Z INFO ghe-backup-settings -2023-03-22T18:33:43Z INFO * Transferring settings data ... -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings -2023-03-22T18:33:43Z INFO * Transferring license data ... -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' -2023-03-22T18:33:43Z INFO * Transferring management console password ... -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage -2023-03-22T18:33:43Z INFO * Transferring password pepper ... -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets -2023-03-22T18:33:43Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret -2023-03-22T18:33:43Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret -2023-03-22T18:33:43Z INFO * Transferring management console argon2 secret ... -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null -2023-03-22T18:33:43Z INFO * Transferring CA certificates ... -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null -2023-03-22T18:33:43Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys -ghe-export-authorized-keys took 0s -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys -ghe-export-ssh-host-keys took 0s -2023-03-22T18:33:43Z INFO ghe-backup-mysql -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary -2023-03-22T18:33:43Z INFO ghe-backup-mysql-binary -2023-03-22T18:33:43Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -ghe-backup-mysql-binary took 3s -ghe-backup-mysql took 3s -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled -2023-03-22T18:33:46Z INFO ghe-backup-minio -2023-03-22T18:33:46Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T18:33:46Z RSYNC BEGIN: minio rsync -2023-03-22T18:33:46Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230322T183339/minio -2023-03-22T18:33:46Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:33:46Z RSYNC END: minio rsync -ghe-backup-minio took 0s -Backup progress: 0 % -2023-03-22T18:33:46Z INFO ghe-backup-pages -2023-03-22T18:33:46Z INFO ghe-backup-es-audit-log -2023-03-22T18:33:46Z INFO ghe-backup-redis -2023-03-22T18:33:46Z INFO ghe-backup-git-hooks -2023-03-22T18:33:46Z INFO ghe-backup-es-rsync -2023-03-22T18:33:46Z INFO ghe-backup-storage -2023-03-22T18:33:46Z INFO ghe-backup-repositories - -2023-03-22T18:33:46Z INFO * Starting backup for host: 10.0.1.172 -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 /bin/bash - -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" -2023-03-22T18:33:46Z INFO * Transferring pages files ... -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] -2023-03-22T18:33:46Z RSYNC BEGIN: pages rsync -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] -2023-03-22T18:33:46Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230322T183339/pages -2023-03-22T18:33:46Z INFO * Performing initial sync of ES indices ... -2023-03-22T18:33:46Z RSYNC BEGIN elasticsearch rsync -2023-03-22T18:33:46Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T18:33:46Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-22T18:33:46Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-22T18:33:46Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183339/elasticsearch -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:33:46Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -2023-03-22T18:33:46Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -2023-03-22T18:33:46Z RSYNC BEGIN: git-hooks sync -ghe-backup-es-audit-log took 0s -2023-03-22T18:33:46Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230322T183339/git-hooks/repos -receiving incremental file list -./ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.cfe -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.cfs -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/_o.si -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/index/segments_17 -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/ -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog-25.tlog -nodes/0/indices/tgr7n1BjQjSAIGtom3kGew/0/translog/translog.ckp - -sent 422 bytes received 24,766 bytes 50,376.00 bytes/sec -total size is 146,931 speedup is 5.83 -2023-03-22T18:33:46Z RSYNC END elasticsearch rsync -2023-03-22T18:33:46Z INFO * Disabling ES index flushing ... -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush -2023-03-22T18:33:46Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T18:33:46Z RSYNC BEGIN: elasticsearch followup rsync -2023-03-22T18:33:46Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183339/elasticsearch -2023-03-22T18:33:46Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -receiving incremental file list - -sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:33:46Z RSYNC END: elasticsearch followup rsync -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:33:46Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -ghe-backup-es-rsync took 0s -2023-03-22T18:33:46Z INFO * Enabling ES index flushing ... -2023-03-22T18:33:46Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:33:46Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -ghe-backup-redis took 1s -2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-KShrXb/remote_routes_list -ghe-backup-storage - Generating routes took 2s -2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-KShrXb/remote_routes_list -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T18:33:48Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-KShrXb -2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-3jxmPX/remote_routes_list -ghe-backup-repositories - Generating routes took 2s -2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-3jxmPX/remote_routes_list -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s -2023-03-22T18:33:48Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-3jxmPX -2023-03-22T18:33:48Z INFO ghe-prune-snapshots -2023-03-22T18:33:48Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-22T18:33:48Z INFO ghe-detect-leaked-ssh-keys -2023-03-22T18:33:48Z INFO ghe-ssh --clean -2023-03-22T18:35:49Z INFO ghe-backup -2023-03-22T18:35:49Z INFO ghe-host-check -2023-03-22T18:35:49Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh -2023-03-22T18:35:49Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] -2023-03-22T18:35:49Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state -2023-03-22T18:35:49Z INFO ghe-rsync-size.sh -2023-03-22T18:35:49Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ -2023-03-22T18:35:49Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ -2023-03-22T18:35:50Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ -2023-03-22T18:35:50Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ -2023-03-22T18:35:50Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ -2023-03-22T18:35:51Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ -2023-03-22T18:35:51Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ -2023-03-22T18:35:51Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-22T18:35:52Z INFO ghe-backup-strategy -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] -2023-03-22T18:35:52Z INFO ghe-backup-store-version -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 -ghe-backup-store-version took 0s -2023-03-22T18:35:52Z INFO ghe-backup-settings -2023-03-22T18:35:52Z INFO * Transferring settings data ... -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings -2023-03-22T18:35:52Z INFO * Transferring license data ... -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' -2023-03-22T18:35:52Z INFO * Transferring management console password ... -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage -2023-03-22T18:35:52Z INFO * Transferring password pepper ... -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets -2023-03-22T18:35:52Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret -2023-03-22T18:35:52Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret -2023-03-22T18:35:52Z INFO * Transferring management console argon2 secret ... -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null -2023-03-22T18:35:52Z INFO * Transferring CA certificates ... -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates -2023-03-22T18:35:52Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null -2023-03-22T18:35:52Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys -ghe-export-authorized-keys took 1s -2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys -ghe-export-ssh-host-keys took 0s -2023-03-22T18:35:53Z INFO ghe-backup-mysql -2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary -2023-03-22T18:35:53Z INFO ghe-backup-mysql-binary -2023-03-22T18:35:53Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -ghe-backup-mysql-binary took 2s -ghe-backup-mysql took 2s -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled -2023-03-22T18:35:55Z INFO ghe-backup-minio -2023-03-22T18:35:55Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T18:35:55Z RSYNC BEGIN: minio rsync -2023-03-22T18:35:55Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230322T183549/minio -2023-03-22T18:35:55Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:35:55Z RSYNC END: minio rsync -ghe-backup-minio took 0s -Backup progress: 0 % -2023-03-22T18:35:55Z INFO ghe-backup-git-hooks -2023-03-22T18:35:55Z INFO ghe-backup-repositories -2023-03-22T18:35:55Z INFO ghe-backup-pages -2023-03-22T18:35:55Z INFO ghe-backup-storage -2023-03-22T18:35:55Z INFO ghe-backup-redis -2023-03-22T18:35:55Z INFO ghe-backup-es-audit-log -2023-03-22T18:35:55Z INFO ghe-backup-es-rsync - -2023-03-22T18:35:55Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T18:35:55Z INFO * Transferring pages files ... -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-22T18:35:55Z RSYNC BEGIN: pages rsync -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] -2023-03-22T18:35:55Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230322T183549/pages -2023-03-22T18:35:55Z INFO * Performing initial sync of ES indices ... -2023-03-22T18:35:55Z RSYNC BEGIN elasticsearch rsync -2023-03-22T18:35:55Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T18:35:55Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-22T18:35:55Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-22T18:35:55Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183549/elasticsearch -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:35:55Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -2023-03-22T18:35:55Z RSYNC BEGIN: git-hooks sync -2023-03-22T18:35:55Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -2023-03-22T18:35:55Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230322T183549/git-hooks/repos -receiving incremental file list -./ - -sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:35:55Z RSYNC END elasticsearch rsync -2023-03-22T18:35:55Z INFO * Disabling ES index flushing ... -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush -2023-03-22T18:35:55Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T18:35:55Z RSYNC BEGIN: elasticsearch followup rsync -2023-03-22T18:35:55Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183549/elasticsearch -2023-03-22T18:35:55Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -receiving incremental file list - -sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:35:55Z RSYNC END: elasticsearch followup rsync -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:35:55Z RSYNC END: pages rsync -ghe-backup-es-rsync took 0s -ghe-backup-pages - 10.0.1.172 took 0s -2023-03-22T18:35:55Z INFO * Enabling ES index flushing ... -ghe-backup-pages took 0s -2023-03-22T18:35:55Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 56.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:35:56Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 1s -ghe-backup-redis took 1s -2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-vwdhR7/remote_routes_list -ghe-backup-storage - Generating routes took 2s -2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-vwdhR7/remote_routes_list -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T18:35:57Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-vwdhR7 -2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-bT5RMf/remote_routes_list -ghe-backup-repositories - Generating routes took 2s -2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-bT5RMf/remote_routes_list -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s -2023-03-22T18:35:57Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-22T18:35:57Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-bT5RMf -2023-03-22T18:35:58Z INFO ghe-prune-snapshots -2023-03-22T18:35:58Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-22T18:35:58Z INFO ghe-detect-leaked-ssh-keys -2023-03-22T18:35:58Z INFO ghe-ssh --clean -2023-03-22T18:36:34Z INFO ghe-backup -2023-03-22T18:36:34Z INFO ghe-host-check -2023-03-22T18:36:34Z INFO ghe-ssh -o BatchMode=no -o PasswordAuthentication=no -o ConnectTimeout=5 -o ConnectionAttempts=1 10.0.1.172 -- /bin/sh -2023-03-22T18:36:34Z INFO ghe-ssh 10.0.1.172 -- [ -f '/etc/github/cluster' ] -2023-03-22T18:36:34Z INFO ghe-ssh 10.0.1.172 -- cat /etc/github/repl-state -2023-03-22T18:36:34Z INFO ghe-rsync-size.sh -2023-03-22T18:36:34Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/repositories --ignore-missing-args 10.0.1.172:/data/user/repositories/ /tmp/ -2023-03-22T18:36:35Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=/workspace/backup-utils-private/data/current/pages --ignore-missing-args 10.0.1.172:/data/user/pages/ /tmp/ -2023-03-22T18:36:35Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u elasticsearch rsync --link-dest=/workspace/backup-utils-private/data/current/elasticsearch --ignore-missing-args 10.0.1.172:/data/user/elasticsearch/ /tmp/ -2023-03-22T18:36:35Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u alambic rsync --link-dest=/workspace/backup-utils-private/data/current/storage --ignore-missing-args 10.0.1.172:/data/user/storage/ /tmp/ -2023-03-22T18:36:36Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u minio rsync --link-dest=/workspace/backup-utils-private/data/current/minio --ignore-missing-args 10.0.1.172:/data/user/minio/ /tmp/ -2023-03-22T18:36:36Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mysql rsync --link-dest=/workspace/backup-utils-private/data/current/mysql --ignore-missing-args 10.0.1.172:/data/user/mysql/ /tmp/ -2023-03-22T18:36:36Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u actions rsync --link-dest=/workspace/backup-utils-private/data/current/actions --ignore-missing-args 10.0.1.172:/data/user/actions/ /tmp/ -2023-03-22T18:36:37Z INFO ghe-rsync -arn --stats -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u mssql rsync --link-dest=/workspace/backup-utils-private/data/current/mssql --ignore-missing-args 10.0.1.172:/data/user/mssql/backups/ /tmp/ -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-22T18:36:37Z INFO ghe-backup-strategy -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- [ -f '/etc/github/cluster' ] && [ ! -f '/etc/github/repl-state' ] -2023-03-22T18:36:37Z INFO ghe-backup-store-version -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- sudo dd of=/data/user/common/backup-utils-version >/dev/null 2>&1 -ghe-backup-store-version took 0s -2023-03-22T18:36:37Z INFO ghe-backup-settings -2023-03-22T18:36:37Z INFO * Transferring settings data ... -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-settings -2023-03-22T18:36:37Z INFO * Transferring license data ... -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat '/data/enterprise/enterprise.ghl' -2023-03-22T18:36:37Z INFO * Transferring management console password ... -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage -2023-03-22T18:36:37Z INFO * Transferring password pepper ... -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.github.user-password-secrets -2023-03-22T18:36:37Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.credz-hmac-secret -2023-03-22T18:36:37Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.kredz.varz-hmac-secret -2023-03-22T18:36:37Z INFO * Transferring management console argon2 secret ... -2023-03-22T18:36:37Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config secrets.manage-auth.argon-secret -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.packages.enabled -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.chatops.enabled -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/idp.crt -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- which ghe-export-ssl-ca-certificates 1>/dev/null -2023-03-22T18:36:38Z INFO * Transferring CA certificates ... -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssl-ca-certificates -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- sudo cat /data/user/common/uuid 2>/dev/null -2023-03-22T18:36:38Z INFO * Transferring UUID ... -ghe-backup-settings took 1s -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-authorized-keys -ghe-export-authorized-keys took 0s -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-export-ssh-host-keys -ghe-export-ssh-host-keys took 0s -2023-03-22T18:36:38Z INFO ghe-backup-mysql -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true mysql.external.enabled -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 ghe-config --true mysql.backup.binary -2023-03-22T18:36:38Z INFO ghe-backup-mysql-binary -2023-03-22T18:36:38Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -ghe-backup-mysql-binary took 2s -ghe-backup-mysql took 2s -2023-03-22T18:36:40Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.actions.enabled -2023-03-22T18:36:40Z INFO ghe-ssh 10.0.1.172:122 -- ghe-config --true app.minio.enabled -2023-03-22T18:36:40Z INFO ghe-backup-minio -2023-03-22T18:36:40Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T18:36:40Z RSYNC BEGIN: minio rsync -2023-03-22T18:36:40Z INFO ghe-rsync --archive --verbose --compress --rsh=ghe-ssh -p 122 --rsync-path=sudo -u minio rsync --exclude=.minio.sys --link-dest=/workspace/backup-utils-private/data/current/minio 10.0.1.172:/data/user/minio/ /workspace/backup-utils-private/data/20230322T183634/minio -2023-03-22T18:36:40Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u minio rsync --server --sender -vlogDtprze.iLsfxC . /data/user/minio/ -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:36:40Z RSYNC END: minio rsync -ghe-backup-minio took 0s -4 -15 -Backup progress: 0 % -2023-03-22T18:36:41Z INFO ghe-backup-redis -2023-03-22T18:36:41Z INFO ghe-backup-repositories -2023-03-22T18:36:41Z INFO ghe-backup-es-audit-log -2023-03-22T18:36:41Z INFO ghe-backup-pages -2023-03-22T18:36:41Z INFO ghe-backup-storage -2023-03-22T18:36:41Z INFO ghe-backup-es-rsync -2023-03-22T18:36:41Z INFO ghe-backup-git-hooks - -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-22T18:36:41Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 curl -s "localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b" -2023-03-22T18:36:41Z INFO * Transferring pages files ... -2023-03-22T18:36:41Z RSYNC BEGIN: pages rsync -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- [ -d '/data/user/elasticsearch' ] -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- mktemp -d -t backup-utils-backup-XXXXXX -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/environments/tarballs' ] -2023-03-22T18:36:41Z INFO ghe-rsync -avz -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync --link-dest=../../current/pages 10.0.1.172:/data/user/pages/ /workspace/backup-utils-private/data/20230322T183634/pages -2023-03-22T18:36:41Z INFO * Performing initial sync of ES indices ... -2023-03-22T18:36:41Z RSYNC BEGIN elasticsearch rsync -2023-03-22T18:36:41Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T18:36:41Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-22T18:36:41Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183634/elasticsearch -2023-03-22T18:36:41Z INFO ghe-gc-disable 10.0.1.172:122 -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 /bin/bash -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- sudo -u git [ -d '/data/user/git-hooks/repos' ] -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:36:41Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -2023-03-22T18:36:41Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -2023-03-22T18:36:41Z RSYNC BEGIN: git-hooks sync -2023-03-22T18:36:41Z INFO ghe-rsync -av -e ssh -q -p122 -i /workspace/enterprise2/id_test -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no -p 122 -l admin --rsync-path=sudo -u git rsync 10.0.1.172:/data/user/git-hooks/repos/ /workspace/backup-utils-private/data/20230322T183634/git-hooks/repos -receiving incremental file list -./ - -sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:36:41Z RSYNC END elasticsearch rsync -2023-03-22T18:36:41Z INFO * Disabling ES index flushing ... -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- /bin/bash -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPOST localhost:9200/_flush -2023-03-22T18:36:41Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T18:36:41Z RSYNC BEGIN: elasticsearch followup rsync -2023-03-22T18:36:41Z INFO ghe-rsync -avz -e ghe-ssh -p 122 --rsync-path=sudo -u elasticsearch rsync --link-dest=../../current/elasticsearch 10.0.1.172:/data/user/elasticsearch/ /workspace/backup-utils-private/data/20230322T183634/elasticsearch -2023-03-22T18:36:41Z INFO ghe-ssh -p 122 10.0.1.172 sudo -u elasticsearch rsync --server --sender -vlogDtprze.iLsfxC . /data/user/elasticsearch/ -receiving incremental file list - -sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:36:41Z RSYNC END: elasticsearch followup rsync -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- test -f /data/user/common/es-scan-complete -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:36:41Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-es-rsync took 0s -2023-03-22T18:36:41Z INFO * Enabling ES index flushing ... -ghe-backup-pages took 0s -2023-03-22T18:36:41Z INFO ghe-ssh 10.0.1.172:122 -- curl -s -XPUT localhost:9200/_settings -d @- -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:36:41Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -ghe-backup-redis took 1s -2023-03-22T18:36:42Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-YZgWfb/remote_routes_list -ghe-backup-storage - Generating routes took 1s -2023-03-22T18:36:42Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-YZgWfb/remote_routes_list -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T18:36:42Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-22T18:36:42Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-22T18:36:42Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-YZgWfb -2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- cat /tmp/backup-utils-backup-BlP7CO/remote_routes_list -ghe-backup-repositories - Generating routes took 2s -2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- gzip -c /tmp/backup-utils-backup-BlP7CO/remote_routes_list -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s -2023-03-22T18:36:43Z INFO ghe-gc-enable 10.0.1.172:122 -2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- sudo rm -f '/data/user/repositories/.sync_in_progress' -2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- rm -rf /tmp/backup-utils-backup-BlP7CO -2023-03-22T18:36:43Z INFO ghe-prune-snapshots -2023-03-22T18:36:43Z INFO ghe-ssh 10.0.1.172:122 -- logger -t backup-utils -2023-03-22T18:36:43Z INFO ghe-detect-leaked-ssh-keys -2023-03-22T18:36:43Z INFO ghe-ssh --clean -ghe-backup-store-version took 0s -2023-03-22T18:37:30Z INFO * Transferring settings data ... -2023-03-22T18:37:30Z INFO * Transferring license data ... -2023-03-22T18:37:30Z INFO * Transferring management console password ... -2023-03-22T18:37:30Z INFO * Transferring password pepper ... -2023-03-22T18:37:30Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T18:37:30Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T18:37:30Z INFO * Transferring management console argon2 secret ... -2023-03-22T18:37:30Z INFO * Transferring CA certificates ... -2023-03-22T18:37:31Z INFO * Transferring UUID ... -ghe-backup-settings took 1s -ghe-export-authorized-keys took 0s -ghe-export-ssh-host-keys took 0s -ghe-backup-mysql-binary took 2s -ghe-backup-mysql took 2s -2023-03-22T18:37:33Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T18:37:33Z RSYNC BEGIN: minio rsync -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:37:33Z RSYNC END: minio rsync -ghe-backup-minio took 0s -4 -15 -Backup progress: 0 % -ghe-backup-redis took 1s -2023-03-22T18:37:34Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -ghe-backup-repositories - Generating routes took 2s -ghe-backup-repositories - Fetching routes took 1s -ghe-backup-repositories - Processing routes took 0s - -2023-03-22T18:37:37Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T18:37:37Z INFO * Transferring pages files ... -2023-03-22T18:37:37Z RSYNC BEGIN: pages rsync -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:37:37Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -ghe-backup-storage - Generating routes took 2s -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T18:37:39Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T18:37:39Z RSYNC BEGIN: git-hooks sync -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:37:39Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -2023-03-22T18:37:39Z INFO * Performing initial sync of ES indices ... -2023-03-22T18:37:39Z RSYNC BEGIN elasticsearch rsync -receiving incremental file list -./ - -sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:37:39Z RSYNC END elasticsearch rsync -2023-03-22T18:37:39Z INFO * Disabling ES index flushing ... -2023-03-22T18:37:39Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T18:37:39Z RSYNC BEGIN: elasticsearch followup rsync -receiving incremental file list - -sent 286 bytes received 22,565 bytes 45,702.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:37:40Z RSYNC END: elasticsearch followup rsync -ghe-backup-es-rsync took 1s -2023-03-22T18:37:40Z INFO * Enabling ES index flushing ... -ghe-backup-store-version took 0s -2023-03-22T18:40:50Z INFO * Transferring settings data ... -2023-03-22T18:40:50Z INFO * Transferring license data ... -2023-03-22T18:40:50Z INFO * Transferring management console password ... -2023-03-22T18:40:50Z INFO * Transferring password pepper ... -2023-03-22T18:40:50Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T18:40:50Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T18:40:50Z INFO * Transferring management console argon2 secret ... -2023-03-22T18:40:50Z INFO * Transferring CA certificates ... -2023-03-22T18:40:50Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -ghe-export-authorized-keys took 0s -ghe-backup-store-version took 0s -2023-03-22T18:41:48Z INFO * Transferring settings data ... -2023-03-22T18:41:48Z INFO * Transferring license data ... -2023-03-22T18:41:48Z INFO * Transferring management console password ... -2023-03-22T18:41:48Z INFO * Transferring password pepper ... -2023-03-22T18:41:48Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T18:41:49Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T18:41:49Z INFO * Transferring management console argon2 secret ... -2023-03-22T18:41:49Z INFO * Transferring CA certificates ... -2023-03-22T18:41:49Z INFO * Transferring UUID ... -ghe-backup-settings took 1s -ghe-export-authorized-keys took 0s -ghe-export-ssh-host-keys took 0s -ghe-backup-mysql-binary took 2s -ghe-backup-mysql took 2s -2023-03-22T18:41:51Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T18:41:51Z RSYNC BEGIN: minio rsync -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:41:51Z RSYNC END: minio rsync -ghe-backup-minio took 0s -6 -15 -Backup progress: 0 % -ghe-backup-redis took 2s -2023-03-22T18:41:53Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -ghe-backup-repositories - Generating routes took 2s -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s - -2023-03-22T18:41:55Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T18:41:55Z INFO * Transferring pages files ... -2023-03-22T18:41:55Z RSYNC BEGIN: pages rsync -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:41:55Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -ghe-backup-storage - Generating routes took 2s -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T18:41:57Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T18:41:57Z RSYNC BEGIN: git-hooks sync -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 56.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:41:58Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 1s -2023-03-22T18:41:58Z INFO * Performing initial sync of ES indices ... -2023-03-22T18:41:58Z RSYNC BEGIN elasticsearch rsync -receiving incremental file list -./ - -sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:41:58Z RSYNC END elasticsearch rsync -2023-03-22T18:41:58Z INFO * Disabling ES index flushing ... -2023-03-22T18:41:58Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T18:41:58Z RSYNC BEGIN: elasticsearch followup rsync -receiving incremental file list - -sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:41:58Z RSYNC END: elasticsearch followup rsync -ghe-backup-es-rsync took 0s -2023-03-22T18:41:58Z INFO * Enabling ES index flushing ... -ghe-backup-store-version took 0s -2023-03-22T18:47:55Z INFO * Transferring settings data ... -2023-03-22T18:47:55Z INFO * Transferring license data ... -2023-03-22T18:47:55Z INFO * Transferring management console password ... -2023-03-22T18:47:55Z INFO * Transferring password pepper ... -2023-03-22T18:47:55Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T18:47:55Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T18:47:55Z INFO * Transferring management console argon2 secret ... -2023-03-22T18:47:55Z INFO * Transferring CA certificates ... -2023-03-22T18:47:56Z INFO * Transferring UUID ... -ghe-backup-settings took 1s -ghe-export-authorized-keys took 0s -ghe-export-ssh-host-keys took 0s -ghe-backup-mysql-binary took 2s -2023-03-22T18:47:58Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T18:47:58Z RSYNC BEGIN: minio rsync -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:47:58Z RSYNC END: minio rsync -ghe-backup-minio took 0s -1 -18 -ghe-backup-redis took 1s -2023-03-22T18:47:59Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -ghe-backup-repositories - Generating routes took 2s -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 1s - -2023-03-22T18:48:02Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T18:48:02Z INFO * Transferring pages files ... -2023-03-22T18:48:02Z RSYNC BEGIN: pages rsync -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:48:02Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -ghe-backup-storage - Generating routes took 2s -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T18:48:04Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T18:48:04Z RSYNC BEGIN: git-hooks sync -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:48:04Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -2023-03-22T18:48:04Z INFO * Performing initial sync of ES indices ... -2023-03-22T18:48:04Z RSYNC BEGIN elasticsearch rsync -receiving incremental file list -./ - -sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:48:04Z RSYNC END elasticsearch rsync -2023-03-22T18:48:04Z INFO * Disabling ES index flushing ... -2023-03-22T18:48:04Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T18:48:04Z RSYNC BEGIN: elasticsearch followup rsync -receiving incremental file list - -sent 282 bytes received 22,561 bytes 15,228.67 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:48:05Z RSYNC END: elasticsearch followup rsync -ghe-backup-es-rsync took 1s -2023-03-22T18:48:05Z INFO * Enabling ES index flushing ... -ghe-backup-store-version took 0s -2023-03-22T18:48:56Z INFO * Transferring settings data ... -2023-03-22T18:48:56Z INFO * Transferring license data ... -2023-03-22T18:48:56Z INFO * Transferring management console password ... -2023-03-22T18:48:56Z INFO * Transferring password pepper ... -2023-03-22T18:48:56Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T18:48:56Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T18:48:56Z INFO * Transferring management console argon2 secret ... -2023-03-22T18:48:56Z INFO * Transferring CA certificates ... -2023-03-22T18:48:56Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -ghe-export-authorized-keys took 0s -ghe-export-ssh-host-keys took 0s -ghe-backup-mysql-binary took 3s -ghe-backup-mysql took 3s -2023-03-22T18:48:59Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T18:48:59Z RSYNC BEGIN: minio rsync -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:48:59Z RSYNC END: minio rsync -ghe-backup-minio took 0s -6 -18 -Backup progress: 33.00 % -ghe-backup-redis took 1s -2023-03-22T18:49:00Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -ghe-backup-repositories - Generating routes took 2s -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s - -2023-03-22T18:49:02Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T18:49:02Z INFO * Transferring pages files ... -2023-03-22T18:49:02Z RSYNC BEGIN: pages rsync -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 174.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:49:03Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 1s -ghe-backup-pages took 1s -ghe-backup-storage - Generating routes took 1s -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T18:49:05Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T18:49:05Z RSYNC BEGIN: git-hooks sync -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T18:49:05Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -2023-03-22T18:49:05Z INFO * Performing initial sync of ES indices ... -2023-03-22T18:49:05Z RSYNC BEGIN elasticsearch rsync -receiving incremental file list -./ - -sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:49:05Z RSYNC END elasticsearch rsync -2023-03-22T18:49:05Z INFO * Disabling ES index flushing ... -2023-03-22T18:49:05Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T18:49:05Z RSYNC BEGIN: elasticsearch followup rsync -receiving incremental file list - -sent 286 bytes received 22,565 bytes 45,702.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T18:49:05Z RSYNC END: elasticsearch followup rsync -ghe-backup-es-rsync took 0s -2023-03-22T18:49:05Z INFO * Enabling ES index flushing ... -ghe-backup-store-version took 0s -2023-03-22T19:22:35Z INFO * Transferring settings data ... -2023-03-22T19:22:35Z INFO * Transferring license data ... -2023-03-22T19:22:35Z INFO * Transferring management console password ... -2023-03-22T19:22:35Z INFO * Transferring password pepper ... -2023-03-22T19:22:35Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T19:22:35Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T19:22:35Z INFO * Transferring management console argon2 secret ... -2023-03-22T19:22:36Z INFO * Transferring CA certificates ... -2023-03-22T19:22:36Z INFO * Transferring UUID ... -ghe-backup-settings took 1s -ghe-export-authorized-keys took 0s -ghe-export-ssh-host-keys took 0s -ghe-backup-mysql-binary took 2s -ghe-backup-mysql took 2s -2023-03-22T19:22:38Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T19:22:38Z RSYNC BEGIN: minio rsync -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:22:38Z RSYNC END: minio rsync -ghe-backup-minio took 0s -ghe-backup-redis took 1s -2023-03-22T19:22:39Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -ghe-backup-repositories - Generating routes took 3s -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s - -2023-03-22T19:22:42Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T19:22:42Z INFO * Transferring pages files ... -2023-03-22T19:22:42Z RSYNC BEGIN: pages rsync -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:22:42Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -ghe-backup-storage - Generating routes took 2s -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T19:22:44Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T19:22:44Z RSYNC BEGIN: git-hooks sync -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:22:44Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -2023-03-22T19:22:44Z INFO * Performing initial sync of ES indices ... -2023-03-22T19:22:44Z RSYNC BEGIN elasticsearch rsync -receiving incremental file list -./ - -sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:22:44Z RSYNC END elasticsearch rsync -2023-03-22T19:22:44Z INFO * Disabling ES index flushing ... -2023-03-22T19:22:45Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T19:22:45Z RSYNC BEGIN: elasticsearch followup rsync -receiving incremental file list - -sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:22:45Z RSYNC END: elasticsearch followup rsync -ghe-backup-es-rsync took 1s -2023-03-22T19:22:45Z INFO * Enabling ES index flushing ... -ghe-backup-store-version took 0s -2023-03-22T19:28:56Z INFO * Transferring settings data ... -2023-03-22T19:28:57Z INFO * Transferring license data ... -2023-03-22T19:28:57Z INFO * Transferring management console password ... -2023-03-22T19:28:57Z INFO * Transferring password pepper ... -2023-03-22T19:28:57Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T19:28:57Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T19:28:57Z INFO * Transferring management console argon2 secret ... -2023-03-22T19:28:57Z INFO * Transferring CA certificates ... -2023-03-22T19:28:57Z INFO * Transferring UUID ... -ghe-backup-settings took 1s -ghe-export-authorized-keys took 0s -ghe-export-ssh-host-keys took 0s -ghe-backup-mysql-binary took 2s -ghe-backup-mysql took 2s -2023-03-22T19:29:00Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T19:29:00Z RSYNC BEGIN: minio rsync -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:29:00Z RSYNC END: minio rsync -ghe-backup-minio took 0s -ghe-backup-redis took 1s -2023-03-22T19:29:01Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -ghe-backup-repositories - Generating routes took 2s -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s - -2023-03-22T19:29:03Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T19:29:03Z INFO * Transferring pages files ... -2023-03-22T19:29:03Z RSYNC BEGIN: pages rsync -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:29:03Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -ghe-backup-storage - Generating routes took 1s -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T19:29:05Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T19:29:06Z RSYNC BEGIN: git-hooks sync -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:29:06Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 1s -2023-03-22T19:29:06Z INFO * Performing initial sync of ES indices ... -2023-03-22T19:29:06Z RSYNC BEGIN elasticsearch rsync -receiving incremental file list -./ - -sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:29:06Z RSYNC END elasticsearch rsync -2023-03-22T19:29:06Z INFO * Disabling ES index flushing ... -2023-03-22T19:29:06Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T19:29:06Z RSYNC BEGIN: elasticsearch followup rsync -receiving incremental file list - -sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:29:06Z RSYNC END: elasticsearch followup rsync -ghe-backup-es-rsync took 0s -2023-03-22T19:29:06Z INFO * Enabling ES index flushing ... -ghe-backup-store-version took 0s -2023-03-22T19:31:52Z INFO * Transferring settings data ... -2023-03-22T19:31:52Z INFO * Transferring license data ... -2023-03-22T19:31:52Z INFO * Transferring management console password ... -2023-03-22T19:31:52Z INFO * Transferring password pepper ... -2023-03-22T19:31:52Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T19:31:52Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T19:31:52Z INFO * Transferring management console argon2 secret ... -2023-03-22T19:31:52Z INFO * Transferring CA certificates ... -2023-03-22T19:31:52Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -ghe-export-authorized-keys took 0s -ghe-export-ssh-host-keys took 0s -ghe-backup-mysql-binary took 3s -ghe-backup-mysql took 3s -2023-03-22T19:31:55Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T19:31:55Z RSYNC BEGIN: minio rsync -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:31:55Z RSYNC END: minio rsync -ghe-backup-minio took 0s -ghe-backup-redis took 1s -2023-03-22T19:31:56Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -ghe-backup-repositories - Generating routes took 2s -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s - -2023-03-22T19:31:58Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T19:31:58Z INFO * Transferring pages files ... -2023-03-22T19:31:58Z RSYNC BEGIN: pages rsync -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 174.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:31:59Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 1s -ghe-backup-pages took 1s -ghe-backup-storage - Generating routes took 2s -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T19:32:01Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T19:32:01Z RSYNC BEGIN: git-hooks sync -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:32:01Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -2023-03-22T19:32:01Z INFO * Performing initial sync of ES indices ... -2023-03-22T19:32:01Z RSYNC BEGIN elasticsearch rsync -receiving incremental file list -./ - -sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:32:01Z RSYNC END elasticsearch rsync -2023-03-22T19:32:01Z INFO * Disabling ES index flushing ... -2023-03-22T19:32:01Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T19:32:01Z RSYNC BEGIN: elasticsearch followup rsync -receiving incremental file list - -sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:32:01Z RSYNC END: elasticsearch followup rsync -ghe-backup-es-rsync took 0s -2023-03-22T19:32:01Z INFO * Enabling ES index flushing ... -ghe-backup-store-version took 0s -2023-03-22T19:32:25Z INFO * Transferring settings data ... -2023-03-22T19:32:25Z INFO * Transferring license data ... -2023-03-22T19:32:25Z INFO * Transferring management console password ... -2023-03-22T19:32:25Z INFO * Transferring password pepper ... -2023-03-22T19:32:25Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T19:32:25Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T19:32:26Z INFO * Transferring management console argon2 secret ... -2023-03-22T19:32:26Z INFO * Transferring CA certificates ... -2023-03-22T19:32:26Z INFO * Transferring UUID ... -ghe-backup-settings took 1s -ghe-export-authorized-keys took 0s -ghe-export-ssh-host-keys took 0s -ghe-backup-mysql-binary took 2s -ghe-backup-mysql took 2s -2023-03-22T19:32:28Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T19:32:28Z RSYNC BEGIN: minio rsync -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:32:28Z RSYNC END: minio rsync -ghe-backup-minio took 0s -ghe-backup-redis took 1s -2023-03-22T19:32:30Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 1s -ghe-backup-repositories - Generating routes took 2s -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s - -2023-03-22T19:32:32Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T19:32:32Z INFO * Transferring pages files ... -2023-03-22T19:32:32Z RSYNC BEGIN: pages rsync -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 522.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:32:32Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 0s -ghe-backup-pages took 0s -ghe-backup-storage - Generating routes took 2s -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T19:32:34Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T19:32:34Z RSYNC BEGIN: git-hooks sync -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 56.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:32:35Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 1s -2023-03-22T19:32:35Z INFO * Performing initial sync of ES indices ... -2023-03-22T19:32:35Z RSYNC BEGIN elasticsearch rsync -receiving incremental file list -./ - -sent 293 bytes received 22,572 bytes 45,730.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:32:35Z RSYNC END elasticsearch rsync -2023-03-22T19:32:35Z INFO * Disabling ES index flushing ... -2023-03-22T19:32:35Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T19:32:35Z RSYNC BEGIN: elasticsearch followup rsync -receiving incremental file list - -sent 282 bytes received 22,561 bytes 45,686.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:32:35Z RSYNC END: elasticsearch followup rsync -ghe-backup-es-rsync took 0s -2023-03-22T19:32:35Z INFO * Enabling ES index flushing ... -ghe-backup-store-version took 0s -2023-03-22T19:37:31Z INFO * Transferring settings data ... -2023-03-22T19:37:31Z INFO * Transferring license data ... -2023-03-22T19:37:31Z INFO * Transferring management console password ... -2023-03-22T19:37:31Z INFO * Transferring password pepper ... -2023-03-22T19:37:31Z INFO * Transferring kredz.credz HMAC key ... -2023-03-22T19:37:31Z INFO * Transferring kredz.varz HMAC key ... -2023-03-22T19:37:31Z INFO * Transferring management console argon2 secret ... -2023-03-22T19:37:31Z INFO * Transferring CA certificates ... -2023-03-22T19:37:31Z INFO * Transferring UUID ... -ghe-backup-settings took 0s -ghe-export-authorized-keys took 0s -ghe-export-ssh-host-keys took 0s -ghe-backup-mysql-binary took 3s -ghe-backup-mysql took 3s -2023-03-22T19:37:34Z INFO * Transferring minio files from 10.0.1.172 ... -2023-03-22T19:37:34Z RSYNC BEGIN: minio rsync -receiving incremental file list -./ - -sent 44 bytes received 93 bytes 274.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:37:34Z RSYNC END: minio rsync -ghe-backup-minio took 0s -ghe-backup-redis took 1s -2023-03-22T19:37:35Z INFO * Linking unchanged audit log index: audit_log-1-2023-02-1 -ghe-backup-es-audit-log took 0s -ghe-backup-repositories - Generating routes took 2s -ghe-backup-repositories - Fetching routes took 0s -ghe-backup-repositories - Processing routes took 0s - -2023-03-22T19:37:37Z INFO * Starting backup for host: 10.0.1.172 - -2023-03-22T19:37:37Z INFO * Transferring pages files ... -2023-03-22T19:37:37Z RSYNC BEGIN: pages rsync -receiving incremental file list -./ - -sent 35 bytes received 226 bytes 174.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:37:38Z RSYNC END: pages rsync -ghe-backup-pages - 10.0.1.172 took 1s -ghe-backup-pages took 1s -ghe-backup-storage - Generating routes took 1s -ghe-backup-storage - Fetching routes took 0s -ghe-backup-storage - Processing routes took 0s -2023-03-22T19:37:40Z INFO git-hooks environment tarballs not found. Skipping ... -2023-03-22T19:37:40Z RSYNC BEGIN: git-hooks sync -receiving incremental file list -./ - -sent 27 bytes received 57 bytes 168.00 bytes/sec -total size is 0 speedup is 0.00 -2023-03-22T19:37:40Z RSYNC END: git-hooks sync -ghe-backup-git-hooks took 0s -2023-03-22T19:37:40Z INFO * Performing initial sync of ES indices ... -2023-03-22T19:37:40Z RSYNC BEGIN elasticsearch rsync -receiving incremental file list -./ - -sent 289 bytes received 22,568 bytes 45,714.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:37:40Z RSYNC END elasticsearch rsync -2023-03-22T19:37:40Z INFO * Disabling ES index flushing ... -2023-03-22T19:37:40Z INFO * Performing follow-up sync of ES indices ... -2023-03-22T19:37:40Z RSYNC BEGIN: elasticsearch followup rsync -receiving incremental file list - -sent 286 bytes received 22,565 bytes 45,702.00 bytes/sec -total size is 146,931 speedup is 6.43 -2023-03-22T19:37:40Z RSYNC END: elasticsearch followup rsync -ghe-backup-es-rsync took 0s -2023-03-22T19:37:40Z INFO * Enabling ES index flushing ... From f009aad147b21ae1e0920f555156fc44b1cdc837 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 5 Apr 2023 12:15:56 -0400 Subject: [PATCH 1762/2421] Delete testfd --- testfd | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 testfd diff --git a/testfd b/testfd deleted file mode 100644 index e69de29bb..000000000 From a8e7eca745a738c4c02cba4ce85f51bfb97bfe6b Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 5 Apr 2023 12:17:05 -0400 Subject: [PATCH 1763/2421] Update bin/ghe-restore --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index aa3848c07..33ca1ee41 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -612,7 +612,7 @@ elif $instance_configured; then ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 - bm_end "$(basename $0) - configure cluster" + bm_end "$(basename $0) - configure appliance" fi # Clear GitHub Connect settings stored in the restored database. From b977fadab3c0030922071470efdd16d5ad043e67 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 5 Apr 2023 20:04:01 +0000 Subject: [PATCH 1764/2421] Updating data-sets --- .github/workflows/restore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 61084e875..1df6895f2 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -1,5 +1,5 @@ name: Restore Dataset - +run-name: ${{ github.actor }} retrieving data-sets on: workflow_dispatch: inputs: @@ -65,7 +65,7 @@ jobs: with: repository: github/ghes-data ref: main - - run: gunzip ghes-data/data/backup/${{ inputs.size }}/${{ inputs.size }}.zip + - run: tar zxvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz - run: ls -al ghes-data/data/backup/${{ inputs.size }} From 632fa88c52d2993cd0eeae685420fa6c7485b61a Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 5 Apr 2023 20:07:58 +0000 Subject: [PATCH 1765/2421] more updates --- .github/workflows/restore.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 1df6895f2..9d6ad97c0 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -20,6 +20,11 @@ on: required: false type: string default: 'master' + version: + description: 'GHES Version of dataset' + required: true + type: string + default: "3.8.0" workflow_call: inputs: size: @@ -36,6 +41,11 @@ on: required: false type: string default: 'master' + version: + description: 'GHES Version of dataset' + required: true + type: string + default: "3.8.0" jobs: build: runs-on: ubuntu-latest From 7894a7ba0c035faa125932078bac52405bf613e4 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 7 Apr 2023 10:42:10 -0400 Subject: [PATCH 1766/2421] Update restore.yml --- .github/workflows/restore.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 9d6ad97c0..25bb5661e 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -7,7 +7,6 @@ on: description: 'Size of the dataset to restore' required: true type: choice - default: 'small' options: - 'small' - 'medium' @@ -22,14 +21,14 @@ on: default: 'master' version: description: 'GHES Version of dataset' - required: true + required: false type: string default: "3.8.0" workflow_call: inputs: size: description: 'Size of the dataset to restore' - required: true + required: false type: string default: 'small' hostname: @@ -43,7 +42,7 @@ on: default: 'master' version: description: 'GHES Version of dataset' - required: true + required: false type: string default: "3.8.0" jobs: From 00e10a8f22733d5b688ed37677e46c8aaecd5614 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 11 Apr 2023 16:09:16 -0700 Subject: [PATCH 1767/2421] Add multi stage build Dockerfile that compiles rsync from the source repository --- Dockerfile.rsync | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Dockerfile.rsync diff --git a/Dockerfile.rsync b/Dockerfile.rsync new file mode 100644 index 000000000..f502aca87 --- /dev/null +++ b/Dockerfile.rsync @@ -0,0 +1,80 @@ +# Multi stage build for backup-utils +# Build layer is for compiling rsync from source +# Runtime layer is for running backup-utils +# https://docs.docker.com/develop/develop-images/multistage-build/ +# https://docs.docker.com/engine/userguide/eng-image/multistage-build/ + +# Build layer +FROM ubuntu:focal AS build + +# Install build dependencies +RUN apt-get update && apt-get install -y \ + gcc \ + g++ \ + gawk \ + autoconf \ + make \ + automake \ + python3-cmarkgfm \ + acl \ + libacl1-dev \ + attr \ + libattr1-dev \ + libxxhash-dev \ + libzstd-dev \ + liblz4-dev \ + libssl-dev \ + git \ + jq \ + curl \ + tar \ + gzip \ + ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +# Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag +ARG RSYNC_TAG=3.2.7 +RUN curl https://github.com/WayneD/rsync/archive/refs/tags/v${RSYNC_TAG}.tar.gz -L -o v${RSYNC_TAG}.tar.gz +RUN tar -xzf v${RSYNC_TAG}.tar.gz +# Change to the working directory of the rsync source +WORKDIR rsync-${RSYNC_TAG} +RUN ls -la && ./configure +RUN make +RUN make install + +# Reset working directory +WORKDIR / + +# Download backup-utils source from https://github.com/github/backup-utils/releases/download/[TAG]/github-backup-utils-[TAG].tar.gz pinned to specified tag +ARG BACKUP_UTILS_TAG=v3.8.0 +RUN curl https://github.com/github/backup-utils/releases/download/${BACKUP_UTILS_TAG}/github-backup-utils-${BACKUP_UTILS_TAG}.tar.gz -L -o github-backup-utils-${BACKUP_UTILS_TAG}.tar.gz +RUN tar -xzf github-backup-utils-${BACKUP_UTILS_TAG}.tar.gz + +# Runtime layer +FROM ubuntu:focal AS runtime +ARG BACKUP_UTILS_TAG=v3.8.0 + +# Install runtime dependencies - bash, git, OpenSSH 5.6 or newer, and jq v1.5 or newer. +RUN apt-get update && apt-get install -y \ + bash \ + git \ + openssh-client \ + jq \ + moreutils \ + gawk \ + ca-certificates \ + xxhash \ + && rm -rf /var/lib/apt/lists/* + +# Copy rsync from build layer +COPY --from=build /usr/local/bin/rsync /usr/local/bin/rsync + +# Copy backup-utils from build layer into /backup-utils +COPY --from=build /github-backup-utils-${BACKUP_UTILS_TAG} /backup-utils + +WORKDIR /backup-utils + +RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init + +ENTRYPOINT ["/backup-utils/share/github-backup-utils/ghe-docker-init"] +CMD ["ghe-host-check"] From cb4330385f3d70e10ed4e6cf0d3a7c71f76af24b Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 11 Apr 2023 16:20:33 -0700 Subject: [PATCH 1768/2421] Update docker-image.yml include rsync image --- .github/workflows/docker-image.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0ca099a7f..1b5b3df51 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -14,12 +14,22 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Build the Debian Docker image + - name: Build the Ubuntu Docker image run: docker build . --file Dockerfile --tag backup-utils:${GITHUB_RUN_ID} - name: Build the Alpine Docker image run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID} - - name: Run tests in Debian Docker image - run: docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version + - name: Build the Rsync source Docker image + run: docker build . --file Dockerfile.rsync --tag backup-utils-rsync:${GITHUB_RUN_ID} + - name: Run tests in Ubuntu Docker image + run: | + docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version + docker run backup-utils:${GITHUB_RUN_ID} rsync --version - name: Run tests in Alpine Docker image - run: docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version + run: | + docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version + docker run backup-utils:${GITHUB_RUN_ID} rsync --version + - name: Run tests in Rsync source Docker image + run: | + docker run backup-utils-rsync:${GITHUB_RUN_ID} ghe-backup --version + docker run backup-utils:${GITHUB_RUN_ID} rsync --version From 205eba292f67370dff0f3bcd660122aa187bf153 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 11 Apr 2023 16:24:13 -0700 Subject: [PATCH 1769/2421] Correct image names --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 1b5b3df51..2274cf630 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -27,9 +27,9 @@ jobs: - name: Run tests in Alpine Docker image run: | docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version - docker run backup-utils:${GITHUB_RUN_ID} rsync --version + docker run backup-utils-alpine:${GITHUB_RUN_ID} rsync --version - name: Run tests in Rsync source Docker image run: | docker run backup-utils-rsync:${GITHUB_RUN_ID} ghe-backup --version - docker run backup-utils:${GITHUB_RUN_ID} rsync --version + docker run backup-utils-rsync:${GITHUB_RUN_ID} rsync --version From 28b6cfe430a64b314c7192b2d2c800c28c75983e Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 11 Apr 2023 17:07:35 -0700 Subject: [PATCH 1770/2421] Absolute workdir --- Dockerfile.rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.rsync b/Dockerfile.rsync index f502aca87..398e98daf 100644 --- a/Dockerfile.rsync +++ b/Dockerfile.rsync @@ -37,7 +37,7 @@ ARG RSYNC_TAG=3.2.7 RUN curl https://github.com/WayneD/rsync/archive/refs/tags/v${RSYNC_TAG}.tar.gz -L -o v${RSYNC_TAG}.tar.gz RUN tar -xzf v${RSYNC_TAG}.tar.gz # Change to the working directory of the rsync source -WORKDIR rsync-${RSYNC_TAG} +WORKDIR /rsync-${RSYNC_TAG} RUN ls -la && ./configure RUN make RUN make install From 5de65d267997d81353ce27a1e4fc0d6b1b5777f8 Mon Sep 17 00:00:00 2001 From: Joseph Franks Date: Wed, 12 Apr 2023 11:48:52 -0500 Subject: [PATCH 1771/2421] no-op change to test backporting configurations --- test/test-ghe-backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 8e49349b2..7e5b78d27 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -2,7 +2,7 @@ # ghe-backup command tests TESTS_DIR="$PWD/$(dirname "$0")" -# Bring in testlib +# Bring in testlib. # shellcheck source=test/testlib.sh . "$TESTS_DIR/testlib.sh" From 0bb784f7f179ff600f8df33ab5a995f5fbac631e Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 13 Apr 2023 01:43:21 +0000 Subject: [PATCH 1772/2421] check commands are installed --- bin/ghe-host-check | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 3ad88edc7..d9679386a 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -192,8 +192,23 @@ DATA_TRANSFER_SIZE fi #Check rsync, openssh & jq versions + commands=("jq" "rsync" "ssh") + missing_command="" + for cmd in "${commands[@]}"; do + if ! command -v "$cmd" > /dev/null 2>&1; then + missing_command+="$cmd " + fi + done + + # Check if any command is missing + if [[ -n "$missing_command" ]]; then + echo "One or more required tools not found: $missing_command" 1>&2 + echo "Please make sure the following utils are installed and available in your PATH: $missing_command" 1>&2 + exit 1 + fi + echo "### Software versions" 1>&2 - rsync_version=$(rsync --version | grep 'version' | awk '{print $3}') + rsync_version=$(rsync --version | grep 'version' | awk '{print $3}' | tr -cd '[:digit:].\n') if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 @@ -202,7 +217,7 @@ DATA_TRANSFER_SIZE echo "rsync ${rsync_version} >= required ($min_rsync)" 1>&2 fi - ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1) + ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1 | tr -cd '[:digit:].\n') if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 @@ -211,7 +226,7 @@ DATA_TRANSFER_SIZE echo "openSSH ${ssh_version} >= required ($min_openssh)" 1>&2 fi - jq_version=$(jq --version |awk -F\- '{print $2}') + jq_version=$(jq --version |awk -F\- '{print $2}' | tr -cd '[:digit:].\n') if awk "BEGIN {exit !($jq_version < $min_jq)}" &> /dev/null; then echo "jq version $jq_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 From c8402cf7aa1e9dd551d6371c5bf369dadde05e18 Mon Sep 17 00:00:00 2001 From: Zheng Zeng Date: Thu, 13 Apr 2023 14:08:01 +0000 Subject: [PATCH 1773/2421] do not require argon2 secret backup when version >=3.8.2 --- share/github-backup-utils/ghe-backup-settings | 2 +- test/test-ghe-backup.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index d8bddb068..2cf66c0a7 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -80,7 +80,7 @@ backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hma backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" # Backup argon secrets for multiuser from ghes version 3.8 onwards -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then +if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then backup-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" fi diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 7e5b78d27..0fc3a125a 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -146,6 +146,9 @@ begin_test "ghe-backup management console does not backup argon secret" GHE_REMOTE_VERSION=3.7.10 ghe-backup -v | grep -q "management console argon2 secret not set" && exit 1 [ ! -f "$GHE_DATA_DIR/current/manage-argon-secret" ] + + GHE_REMOTE_VERSION=3.8.2 ghe-backup -v | grep -q "management console argon2 secret not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/manage-argon-secret" ] ) end_test @@ -161,9 +164,6 @@ begin_test "ghe-backup management console backs up argon secret" rm -rf "$GHE_DATA_DIR/current" - GHE_REMOTE_VERSION=4.1.0 ghe-backup - - [ "$(cat "$GHE_DATA_DIR/current/manage-argon-secret")" = "fake pw" ] ) end_test From 5640b97e7263cfec132d720717f8ee0293e09fb5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 03:01:22 +0000 Subject: [PATCH 1774/2421] Bump github/super-linter from 4 to 5 Bumps [github/super-linter](https://github.com/github/super-linter) from 4 to 5. - [Release notes](https://github.com/github/super-linter/releases) - [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md) - [Commits](https://github.com/github/super-linter/compare/v4...v5) --- updated-dependencies: - dependency-name: github/super-linter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9d97805de..44eec8716 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 - name: Lint Code Base - uses: github/super-linter@v4 + uses: github/super-linter@v5 env: VALIDATE_ALL_CODEBASE: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 219e9950e3c941d04bb8a543acd93d19cf2976ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 21:00:26 +0000 Subject: [PATCH 1775/2421] Bump github/super-linter from 4 to 5 Bumps [github/super-linter](https://github.com/github/super-linter) from 4 to 5. - [Release notes](https://github.com/github/super-linter/releases) - [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md) - [Commits](https://github.com/github/super-linter/compare/v4...v5) --- updated-dependencies: - dependency-name: github/super-linter dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9d97805de..44eec8716 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 - name: Lint Code Base - uses: github/super-linter@v4 + uses: github/super-linter@v5 env: VALIDATE_ALL_CODEBASE: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From ebf74909c04d5815114db95d5b99872abf29922f Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 19 Apr 2023 15:28:14 +0200 Subject: [PATCH 1776/2421] Use internal Actions bot for checkout --- .github/workflows/restore.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 25bb5661e..f1a3ca3f2 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -1,5 +1,5 @@ name: Restore Dataset -run-name: ${{ github.actor }} retrieving data-sets +run-name: ${{ github.actor }} retrieving data-sets on: workflow_dispatch: inputs: @@ -19,7 +19,7 @@ on: required: false type: string default: 'master' - version: + version: description: 'GHES Version of dataset' required: false type: string @@ -40,7 +40,7 @@ on: required: false type: string default: 'master' - version: + version: description: 'GHES Version of dataset' required: false type: string @@ -53,7 +53,8 @@ jobs: with: repository: github/backup-utils-private ref: ${{ inputs.ref }} - - run: docker build . --file Dockerfile --tag backup-utils + token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" + - run: docker build . --file Dockerfile --tag backup-utils - run: docker save backup-utils -o backup-utils.tar - uses: actions/upload-artifact@v3 with: @@ -68,7 +69,7 @@ jobs: - uses: actions/download-artifact@v3 with: name: backup-utils - - name: Load docker container + - name: Load docker container run: docker load -i backup-utils.tar - uses: actions/checkout@v3 with: From c2b0d211f94f46b8729a7c46a866a7cd18b68f70 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 19 Apr 2023 15:35:56 +0200 Subject: [PATCH 1777/2421] use key for ghes-data as well --- .github/workflows/restore.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index f1a3ca3f2..58161095d 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -75,6 +75,7 @@ jobs: with: repository: github/ghes-data ref: main + token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" - run: tar zxvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz - run: ls -al ghes-data/data/backup/${{ inputs.size }} From 1ff1919614a6c2d31c22ea1ef78af928e6055959 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 19 Apr 2023 15:48:07 +0200 Subject: [PATCH 1778/2421] Add debugging --- .github/workflows/restore.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 58161095d..1d9d7ed77 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -73,10 +73,12 @@ jobs: run: docker load -i backup-utils.tar - uses: actions/checkout@v3 with: + path: ghes-data repository: github/ghes-data ref: main token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" - - run: tar zxvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz + - run: ls -al + - run: tar -zxvf ghes-data/data/backup/${{ inputs.size }}/${{inputs.version}}/${{ inputs.size }}-refined.tar.gz - run: ls -al ghes-data/data/backup/${{ inputs.size }} From 9ed990dee28652d5b0a4e221363260e7625c2b37 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 19 Apr 2023 15:57:31 +0200 Subject: [PATCH 1779/2421] Add more debugging code --- .github/workflows/restore.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 1d9d7ed77..ae50dff0b 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -77,8 +77,9 @@ jobs: repository: github/ghes-data ref: main token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" - - run: ls -al - - run: tar -zxvf ghes-data/data/backup/${{ inputs.size }}/${{inputs.version}}/${{ inputs.size }}-refined.tar.gz + - run: ls -al ghes-data/data/backup/ + - run: ls -al ghes-data/data/backup/small/v3.8.0 + - run: tar -zxvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz - run: ls -al ghes-data/data/backup/${{ inputs.size }} From 2b2a2fe02d54d49710608d39aab0046673676daa Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 19 Apr 2023 16:02:43 +0200 Subject: [PATCH 1780/2421] Remove zip format --- .github/workflows/restore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index ae50dff0b..0658609a0 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -79,7 +79,7 @@ jobs: token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" - run: ls -al ghes-data/data/backup/ - run: ls -al ghes-data/data/backup/small/v3.8.0 - - run: tar -zxvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz + - run: tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz - run: ls -al ghes-data/data/backup/${{ inputs.size }} From 2d84d370ad6e7c5814d8c799670c0ce63992a8b7 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 19 Apr 2023 16:10:07 +0200 Subject: [PATCH 1781/2421] Enable git lfs checkout --- .github/workflows/restore.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 0658609a0..fddc074ba 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -77,6 +77,7 @@ jobs: repository: github/ghes-data ref: main token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" + lfs: 'true' - run: ls -al ghes-data/data/backup/ - run: ls -al ghes-data/data/backup/small/v3.8.0 - run: tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz From 8f98655b546cc88fa54d28cb98daf32e4eb98616 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 19 Apr 2023 16:24:15 +0200 Subject: [PATCH 1782/2421] Update restore workflow --- .github/workflows/restore.yml | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index fddc074ba..7cb1b4bc4 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -78,11 +78,35 @@ jobs: ref: main token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" lfs: 'true' - - run: ls -al ghes-data/data/backup/ - - run: ls -al ghes-data/data/backup/small/v3.8.0 - - run: tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz - - run: ls -al ghes-data/data/backup/${{ inputs.size }} + - name: Create backup directory + run: mkdir $HOME/ghe-backup-data + + - name: Unzip backup + run: | + tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz -C $HOME/ghe-backup-data + - name: set up ssh SSH_KEY + run: echo -e "${SSH_KEY}\n" > $HOME/backup + - name: set up ssh key permissions + run: chmod 0600 $HOME/backup + - name: change version + run: echo "3.8.0" > $HOME/version + + - name: Prepare for restore + run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" + - name: Restore data to instance + run: | + docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ + -e "GHE_DATA_DIR=/data" \ + -e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \ + -e "GHE_NUM_SNAPSHOTS=15" \ + -v "$HOME/ghe-backup-data:/data" \ + -v "$HOME/backup:/ghe-ssh/id_rsa" \ + -v "$HOME/version:/backup-utils/share/github-backup-utils/version" \ + --rm \ + backup-utils ghe-restore ${{ inputs.hostname }} + - name: Reset maintenance mode after restore + run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" From 26ff7a2d3dcf444e2c202bf986b7d5e56a643d14 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 19 Apr 2023 16:38:35 +0200 Subject: [PATCH 1783/2421] Create symlink --- .github/workflows/restore.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 7cb1b4bc4..52eb67596 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -80,11 +80,16 @@ jobs: lfs: 'true' - name: Create backup directory - run: mkdir $HOME/ghe-backup-data + run: | + mkdir $HOME/ghe-backup-data - name: Unzip backup run: | - tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz -C $HOME/ghe-backup-data + dir_name=$(date +%s) + tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz -C $HOME/ghe-backup-data/$dir_name + + ln -s $HOME/ghe-backup-data/$dir_name $HOME/ghe-backup-data/current + - name: set up ssh SSH_KEY run: echo -e "${SSH_KEY}\n" > $HOME/backup - name: set up ssh key permissions From 129f1f44f67692396d4fe9528badfef991e42626 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 19 Apr 2023 16:59:32 +0200 Subject: [PATCH 1784/2421] Add data dir --- .github/workflows/restore.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 52eb67596..a17c152b2 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -81,11 +81,13 @@ jobs: - name: Create backup directory run: | - mkdir $HOME/ghe-backup-data + - name: Unzip backup run: | + mkdir $HOME/ghe-backup-data dir_name=$(date +%s) + mkdir $HOME/ghe-backup-data/$dir_name tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz -C $HOME/ghe-backup-data/$dir_name ln -s $HOME/ghe-backup-data/$dir_name $HOME/ghe-backup-data/current From 34fd799c29d34bbc2732cac0bb366df42b039a43 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 10:23:34 -0700 Subject: [PATCH 1785/2421] Create rsync-docker-bump.yml --- .github/workflows/rsync-docker-bump.yml | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/rsync-docker-bump.yml diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml new file mode 100644 index 000000000..d416025fd --- /dev/null +++ b/.github/workflows/rsync-docker-bump.yml @@ -0,0 +1,37 @@ +name: Update Rsync Tag in Dockerfile.rsync + +on: + schedule: + - cron: '0 0 * * *' # Runs daily at 00:00 + +jobs: + update-rsync-tag: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Get latest rsync tag + id: latest_tag + run: | + curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[0].name' | xargs -I {} echo "::set-output name=latest_tag::{}" + + - name: Create Pull Request for tag update + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Update rsync tag in Dockerfile.rsync" + title: "Update rsync tag in Dockerfile" + body: "This PR updates the rsync tag in the Dockerfile.rsync to the latest tagged version." + branch: "update-rsync-tag" + base: "master" + path: "." + labels: "automated-pr" + title: "Update rsync tag in Dockerfile.rsync" + body: "The rsync tag in the Dockerfile.rsync is outdated. A pull request has been created to update it." + labels: "automated-update,rsync" + modify-regex: | + RSYNC_TAG=\K([0-9\.]+) + replacement: ${{ steps.latest_tag.outputs.latest_tag }} + file-pattern: Dockerfile.rsync From 76d53c3d6f679885128246ab9447f4e79661e27b Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 10:26:41 -0700 Subject: [PATCH 1786/2421] Fix tag usage, and use backup-utils from repo --- Dockerfile.rsync | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Dockerfile.rsync b/Dockerfile.rsync index 398e98daf..e2c94406f 100644 --- a/Dockerfile.rsync +++ b/Dockerfile.rsync @@ -34,8 +34,8 @@ RUN apt-get update && apt-get install -y \ # Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag ARG RSYNC_TAG=3.2.7 -RUN curl https://github.com/WayneD/rsync/archive/refs/tags/v${RSYNC_TAG}.tar.gz -L -o v${RSYNC_TAG}.tar.gz -RUN tar -xzf v${RSYNC_TAG}.tar.gz +RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz +RUN tar -xzf ${RSYNC_TAG}.tar.gz # Change to the working directory of the rsync source WORKDIR /rsync-${RSYNC_TAG} RUN ls -la && ./configure @@ -45,14 +45,8 @@ RUN make install # Reset working directory WORKDIR / -# Download backup-utils source from https://github.com/github/backup-utils/releases/download/[TAG]/github-backup-utils-[TAG].tar.gz pinned to specified tag -ARG BACKUP_UTILS_TAG=v3.8.0 -RUN curl https://github.com/github/backup-utils/releases/download/${BACKUP_UTILS_TAG}/github-backup-utils-${BACKUP_UTILS_TAG}.tar.gz -L -o github-backup-utils-${BACKUP_UTILS_TAG}.tar.gz -RUN tar -xzf github-backup-utils-${BACKUP_UTILS_TAG}.tar.gz - # Runtime layer FROM ubuntu:focal AS runtime -ARG BACKUP_UTILS_TAG=v3.8.0 # Install runtime dependencies - bash, git, OpenSSH 5.6 or newer, and jq v1.5 or newer. RUN apt-get update && apt-get install -y \ @@ -69,8 +63,8 @@ RUN apt-get update && apt-get install -y \ # Copy rsync from build layer COPY --from=build /usr/local/bin/rsync /usr/local/bin/rsync -# Copy backup-utils from build layer into /backup-utils -COPY --from=build /github-backup-utils-${BACKUP_UTILS_TAG} /backup-utils +# Copy backup-utils from repository into /backup-utils +COPY ./ /backup-utils/ WORKDIR /backup-utils From f792f581b44d971c3cd1353d6f1e22575395a754 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 10:27:51 -0700 Subject: [PATCH 1787/2421] Tweak wording --- .github/workflows/rsync-docker-bump.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index d416025fd..5574b73a4 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -29,7 +29,7 @@ jobs: path: "." labels: "automated-pr" title: "Update rsync tag in Dockerfile.rsync" - body: "The rsync tag in the Dockerfile.rsync is outdated. A pull request has been created to update it." + body: "The rsync tag in the Dockerfile.rsync is outdated. This pull request has been created to update it." labels: "automated-update,rsync" modify-regex: | RSYNC_TAG=\K([0-9\.]+) From 992d0c0f9fc84ccbb387b64fd4558034a4eaff78 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 10:36:08 -0700 Subject: [PATCH 1788/2421] Missed the v on the tag arg default --- Dockerfile.rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.rsync b/Dockerfile.rsync index e2c94406f..840e3c46d 100644 --- a/Dockerfile.rsync +++ b/Dockerfile.rsync @@ -33,7 +33,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag -ARG RSYNC_TAG=3.2.7 +ARG RSYNC_TAG=v3.2.7 RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz RUN tar -xzf ${RSYNC_TAG}.tar.gz # Change to the working directory of the rsync source From f98f5abf98bc75c2ca4f233abe812d412c84232b Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 10:43:23 -0700 Subject: [PATCH 1789/2421] Check where the archive extracts to --- Dockerfile.rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.rsync b/Dockerfile.rsync index 840e3c46d..6f85d73a2 100644 --- a/Dockerfile.rsync +++ b/Dockerfile.rsync @@ -35,7 +35,7 @@ RUN apt-get update && apt-get install -y \ # Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag ARG RSYNC_TAG=v3.2.7 RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz -RUN tar -xzf ${RSYNC_TAG}.tar.gz +RUN tar -xzf ${RSYNC_TAG}.tar.gz && ls -la # Change to the working directory of the rsync source WORKDIR /rsync-${RSYNC_TAG} RUN ls -la && ./configure From 62d4a1a5673ce0752d05b8752a438ad8e65b50f3 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 11:13:09 -0700 Subject: [PATCH 1790/2421] Extract to specified directory --- Dockerfile.rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.rsync b/Dockerfile.rsync index 6f85d73a2..e6aaff96f 100644 --- a/Dockerfile.rsync +++ b/Dockerfile.rsync @@ -35,7 +35,7 @@ RUN apt-get update && apt-get install -y \ # Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag ARG RSYNC_TAG=v3.2.7 RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz -RUN tar -xzf ${RSYNC_TAG}.tar.gz && ls -la +RUN tar -xzf ${RSYNC_TAG}.tar.gz -C /rsync-${RSYNC_TAG} && ls -la # Change to the working directory of the rsync source WORKDIR /rsync-${RSYNC_TAG} RUN ls -la && ./configure From b1bff54e3b1959062e1d37f094fb671132d1a8e4 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 11:18:31 -0700 Subject: [PATCH 1791/2421] Make sure directory exists --- Dockerfile.rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.rsync b/Dockerfile.rsync index e6aaff96f..dfd780324 100644 --- a/Dockerfile.rsync +++ b/Dockerfile.rsync @@ -35,7 +35,7 @@ RUN apt-get update && apt-get install -y \ # Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag ARG RSYNC_TAG=v3.2.7 RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz -RUN tar -xzf ${RSYNC_TAG}.tar.gz -C /rsync-${RSYNC_TAG} && ls -la +RUN mkdir -p /rsync-${RSYNC_TAG}&& tar -xzf ${RSYNC_TAG}.tar.gz -C /rsync-${RSYNC_TAG} && ls -la # Change to the working directory of the rsync source WORKDIR /rsync-${RSYNC_TAG} RUN ls -la && ./configure From 65ad7731fe7931fa0376563fb772fcb99a161931 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 11:24:43 -0700 Subject: [PATCH 1792/2421] Remove outer directory from archive --- Dockerfile.rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile.rsync b/Dockerfile.rsync index dfd780324..80666b4b5 100644 --- a/Dockerfile.rsync +++ b/Dockerfile.rsync @@ -35,7 +35,7 @@ RUN apt-get update && apt-get install -y \ # Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag ARG RSYNC_TAG=v3.2.7 RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz -RUN mkdir -p /rsync-${RSYNC_TAG}&& tar -xzf ${RSYNC_TAG}.tar.gz -C /rsync-${RSYNC_TAG} && ls -la +RUN mkdir -p /rsync-${RSYNC_TAG}&& tar -xzf ${RSYNC_TAG}.tar.gz -C /rsync-${RSYNC_TAG} --strip-components=1 && ls -la # Change to the working directory of the rsync source WORKDIR /rsync-${RSYNC_TAG} RUN ls -la && ./configure From 1eb9d62a0cf54e129574eaf649b92882bc2366cc Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 11:30:51 -0700 Subject: [PATCH 1793/2421] Remove duplicated Actions options from workflow --- .github/workflows/rsync-docker-bump.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index 5574b73a4..96b1c1cf0 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -22,14 +22,11 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Update rsync tag in Dockerfile.rsync" - title: "Update rsync tag in Dockerfile" + title: "Update rsync tag in Dockerfile.rsync" body: "This PR updates the rsync tag in the Dockerfile.rsync to the latest tagged version." branch: "update-rsync-tag" base: "master" path: "." - labels: "automated-pr" - title: "Update rsync tag in Dockerfile.rsync" - body: "The rsync tag in the Dockerfile.rsync is outdated. This pull request has been created to update it." labels: "automated-update,rsync" modify-regex: | RSYNC_TAG=\K([0-9\.]+) From f14017d5a318bae11b0f407128b169c33cfe7c85 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 11:35:11 -0700 Subject: [PATCH 1794/2421] Modify the version before PR step --- .github/workflows/rsync-docker-bump.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index 96b1c1cf0..96c32cbbb 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -17,6 +17,10 @@ jobs: run: | curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[0].name' | xargs -I {} echo "::set-output name=latest_tag::{}" + - name: Update Dockerfile.rsync with latest tag + run: | + sed -i -E "s/RSYNC_TAG=[0-9\.]+/RSYNC_TAG=${{ steps.latest_tag.outputs.latest_tag }}/g" Dockerfile.rsync + - name: Create Pull Request for tag update uses: peter-evans/create-pull-request@v3 with: @@ -28,7 +32,3 @@ jobs: base: "master" path: "." labels: "automated-update,rsync" - modify-regex: | - RSYNC_TAG=\K([0-9\.]+) - replacement: ${{ steps.latest_tag.outputs.latest_tag }} - file-pattern: Dockerfile.rsync From ebfa28377c10cd511b4172400f98f0821248b85e Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 19 Apr 2023 11:37:02 -0700 Subject: [PATCH 1795/2421] Specify --no-install-recommends on package installs to minimize image --- Dockerfile.rsync | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.rsync b/Dockerfile.rsync index 80666b4b5..667739729 100644 --- a/Dockerfile.rsync +++ b/Dockerfile.rsync @@ -8,7 +8,7 @@ FROM ubuntu:focal AS build # Install build dependencies -RUN apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install --no-install-recommends -y \ gcc \ g++ \ gawk \ @@ -49,7 +49,7 @@ WORKDIR / FROM ubuntu:focal AS runtime # Install runtime dependencies - bash, git, OpenSSH 5.6 or newer, and jq v1.5 or newer. -RUN apt-get update && apt-get install -y \ +RUN apt-get update && apt-get install --no-install-recommends -y \ bash \ git \ openssh-client \ From 478e3f26b901cf72b1a6c55de07356665af222ba Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 20 Apr 2023 09:57:13 +0200 Subject: [PATCH 1796/2421] Add more debugging to restore --- .github/workflows/restore.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index a17c152b2..d84e687d3 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -92,6 +92,9 @@ jobs: ln -s $HOME/ghe-backup-data/$dir_name $HOME/ghe-backup-data/current + ls -al $HOME/ghe-backup-data + ls -al $HOME/ghe-backup-data/$dir_name + - name: set up ssh SSH_KEY run: echo -e "${SSH_KEY}\n" > $HOME/backup - name: set up ssh key permissions From 356725aab1b22f7b1a37256a74b93fa2e1e62903 Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 20 Apr 2023 10:09:18 +0200 Subject: [PATCH 1797/2421] Fix symlink --- .github/workflows/restore.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index d84e687d3..65b8942d6 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -90,8 +90,7 @@ jobs: mkdir $HOME/ghe-backup-data/$dir_name tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz -C $HOME/ghe-backup-data/$dir_name - ln -s $HOME/ghe-backup-data/$dir_name $HOME/ghe-backup-data/current - + ln -s $dir_name $HOME/ghe-backup-data/current ls -al $HOME/ghe-backup-data ls -al $HOME/ghe-backup-data/$dir_name From 4258712127a760d1c141c46c962b3696108091e0 Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 20 Apr 2023 14:51:01 +0200 Subject: [PATCH 1798/2421] Add backup workflow --- .github/workflows/backup.yml | 108 ++++++++++++++++++++++++++++++++++ .github/workflows/restore.yml | 17 +++--- 2 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/backup.yml diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml new file mode 100644 index 000000000..13935fcd4 --- /dev/null +++ b/.github/workflows/backup.yml @@ -0,0 +1,108 @@ +name: Backup +run-name: ${{ github.actor }} run backup and upload to ghes-data +on: + workflow_dispatch: + inputs: + hostname: + description: 'Hostname' + required: true + type: string + ref: + description: 'Ref' + required: false + type: string + default: 'master' + workflow_call: + inputs: + size: + description: 'Size of the dataset to restore' + required: false + type: string + default: 'small' + hostname: + description: 'Hostname of the server' + required: true + type: string + ref: + description: 'Branch ref to use' + required: false + type: string + default: 'master' + version: + description: 'GHES Version of dataset' + required: false + type: string + default: "3.8.0" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + repository: github/backup-utils-private + ref: ${{ inputs.ref }} + token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" + - run: docker build . --file Dockerfile --tag backup-utils + - run: docker save backup-utils -o backup-utils.tar + - uses: actions/upload-artifact@v3 + with: + name: backup-utils + path: backup-utils.tar + backup-utils-backup: + needs: build + runs-on: ubuntu-latest + env: + SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }} + steps: + - uses: actions/download-artifact@v3 + with: + name: backup-utils + - name: Load docker container + run: docker load -i backup-utils.tar + - uses: actions/checkout@v3 + - name: Create backup directory + run: mkdir $HOME/ghe-backup-data + - name: set up ssh SSH_KEY + run: echo -e "${SSH_KEY}\n" > $HOME/backup + - name: set up ssh key permissions + run: chmod 0600 $HOME/backup + - name: change version + run: echo "3.8.0" > $HOME/version + - name: Perform backup + run: | + docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ + -e "GHE_DATA_DIR=/data" \ + -e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \ + -e "GHE_NUM_SNAPSHOTS=15" \ + -v "$HOME/ghe-backup-data:/data" \ + -v "$HOME/backup:/ghe-ssh/id_rsa" \ + -v "$HOME/version:/backup-utils/share/github-backup-utils/version" \ + --rm \ + backup-utils ghe-backup + + - uses: actions/checkout@v3 + with: + path: ghes-data + repository: github/ghes-data + ref: main + token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" + lfs: 'true' + + - name: Zip backup + run: | + ls -al $HOME/ghe-backup-data + dirname=$(find $HOME/ghe-backup-data/ -type d -maxdepth 1 -mindepth 1) + echo $dirname + tar -czvf $dirname.tar.gz $dirname + cp $dirname.tar.gz ghes-data/data/backup/{{inputs.size}}/v{{inputs.version}}/$dirname.tar.gz + + - name: Upload backup to ghes-data + run: | + cd ghes-data/data/backup/{{inputs.size}}/v{{inputs.version}} + git add . + git commit -am "Added new backup from automation" + git push + + + diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 65b8942d6..6ce850465 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -54,12 +54,15 @@ jobs: repository: github/backup-utils-private ref: ${{ inputs.ref }} token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" + - run: docker build . --file Dockerfile --tag backup-utils - run: docker save backup-utils -o backup-utils.tar + - uses: actions/upload-artifact@v3 with: name: backup-utils path: backup-utils.tar + restore: needs: build runs-on: ubuntu-latest @@ -69,8 +72,10 @@ jobs: - uses: actions/download-artifact@v3 with: name: backup-utils + - name: Load docker container run: docker load -i backup-utils.tar + - uses: actions/checkout@v3 with: path: ghes-data @@ -79,11 +84,7 @@ jobs: token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" lfs: 'true' - - name: Create backup directory - run: | - - - - name: Unzip backup + - name: Unzip backup and setup symlink run: | mkdir $HOME/ghe-backup-data dir_name=$(date +%s) @@ -91,18 +92,19 @@ jobs: tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz -C $HOME/ghe-backup-data/$dir_name ln -s $dir_name $HOME/ghe-backup-data/current - ls -al $HOME/ghe-backup-data - ls -al $HOME/ghe-backup-data/$dir_name - name: set up ssh SSH_KEY run: echo -e "${SSH_KEY}\n" > $HOME/backup + - name: set up ssh key permissions run: chmod 0600 $HOME/backup + - name: change version run: echo "3.8.0" > $HOME/version - name: Prepare for restore run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" + - name: Restore data to instance run: | docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ @@ -114,6 +116,7 @@ jobs: -v "$HOME/version:/backup-utils/share/github-backup-utils/version" \ --rm \ backup-utils ghe-restore ${{ inputs.hostname }} + - name: Reset maintenance mode after restore run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" From 47d753d6a20c3b636d114b2c9949fc0af1680136 Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 20 Apr 2023 15:03:23 +0200 Subject: [PATCH 1799/2421] Install jq --- .github/workflows/backup.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 13935fcd4..a17ab9baa 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -69,6 +69,8 @@ jobs: run: chmod 0600 $HOME/backup - name: change version run: echo "3.8.0" > $HOME/version + - name: Install jq + run: sudo apt-get install jq - name: Perform backup run: | docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ From cf50672464d3d0cd3d0a7c0d99b9c3ac16b160d4 Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 20 Apr 2023 16:01:43 +0200 Subject: [PATCH 1800/2421] Add jq to path --- .github/workflows/backup.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index a17ab9baa..005e0ebf0 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -69,8 +69,10 @@ jobs: run: chmod 0600 $HOME/backup - name: change version run: echo "3.8.0" > $HOME/version - - name: Install jq - run: sudo apt-get install jq + - name: Add jq to path + run: | + jq=$(which jq) + export PATH=$jq:$PATH - name: Perform backup run: | docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ From f4f18d3921e23bfb5485c0cefede3ba1c6527460 Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 20 Apr 2023 16:07:38 +0200 Subject: [PATCH 1801/2421] Add more debugging --- .github/workflows/backup.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 005e0ebf0..42ed156f1 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -72,7 +72,11 @@ jobs: - name: Add jq to path run: | jq=$(which jq) + echo $jq + echo $PATH export PATH=$jq:$PATH + + echo $PATH - name: Perform backup run: | docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ From 96322ba3e6d2e7354acc865f34d4308f66e15761 Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 20 Apr 2023 16:15:22 +0200 Subject: [PATCH 1802/2421] Add more debugging --- .github/workflows/backup.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 42ed156f1..eb7472d5e 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -74,7 +74,8 @@ jobs: jq=$(which jq) echo $jq echo $PATH - export PATH=$jq:$PATH + export PATH=$PATH:$jq + command -v jq echo $PATH - name: Perform backup From 246febeefbaa08d72032f5fcfca3b914d307c4a3 Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 20 Apr 2023 16:23:04 +0200 Subject: [PATCH 1803/2421] Add more debugging --- .github/workflows/backup.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index eb7472d5e..83c70f7a7 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -69,17 +69,12 @@ jobs: run: chmod 0600 $HOME/backup - name: change version run: echo "3.8.0" > $HOME/version - - name: Add jq to path - run: | - jq=$(which jq) - echo $jq - echo $PATH - export PATH=$PATH:$jq - command -v jq - echo $PATH - name: Perform backup run: | + jq=$(command -v jq) + export PATH=$PATH:$jq + echo $PATH docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ -e "GHE_DATA_DIR=/data" \ -e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \ From e55193ac3430dd59952179e51bd685f308a94e83 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 21 Apr 2023 23:46:23 +0000 Subject: [PATCH 1804/2421] fix rsync status for very first backup --- share/github-backup-utils/ghe-rsync-size.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync-size.sh b/share/github-backup-utils/ghe-rsync-size.sh index 65de3c3a7..c61a80b3b 100755 --- a/share/github-backup-utils/ghe-rsync-size.sh +++ b/share/github-backup-utils/ghe-rsync-size.sh @@ -58,13 +58,22 @@ transfer_size() ;; esac - total_file_size=$(ghe-rsync -arn --stats \ + if [ -d "${GHE_DATA_DIR}/current/$1" ]; then + total_file_size=$(ghe-rsync -arn --stats \ -e "ssh -q $GHE_EXTRA_SSH_OPTS -p 122 -l admin" \ --rsync-path="sudo -u $user rsync" \ "$link_dest"/"$1" \ --ignore-missing-args \ "$GHE_HOSTNAME:$data_user_dir/" \ "$dest_dir/" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') + else + total_file_size=$(ghe-rsync -arn --stats \ + -e "ssh -q $GHE_EXTRA_SSH_OPTS -p 122 -l admin" \ + --rsync-path="sudo -u $user rsync" \ + --ignore-missing-args \ + "$GHE_HOSTNAME:$data_user_dir/" \ + "$dest_dir/" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') + fi # Reduce mysql size as only the compressed file is transferred if [[ "$1" == "mysql" ]]; then From 00c1703add27d1aba7bce06ea7a68adc8de2e874 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 24 Apr 2023 09:10:37 -0400 Subject: [PATCH 1805/2421] Update rsync min version to 3.2.5 --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index f6b9b8f31..e0a8f817c 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -6,7 +6,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements Backup host software requirements are modest: Linux or other modern Unix operating -system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. +system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v3.2.5 or newer, and [jq][11] v1.5 or newer. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From e6e76c6b7fa6902211e9efa81d76214559acbe58 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 24 Apr 2023 13:49:18 -0400 Subject: [PATCH 1806/2421] Update requirements to reflect rsync package compatability --- docs/requirements.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index e0a8f817c..f2c343985 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -6,7 +6,15 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements Backup host software requirements are modest: Linux or other modern Unix operating -system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v3.2.5 or newer, and [jq][11] v1.5 or newer. +system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. + +************ Update April 2023 ************ + +The recent fix to rsync for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) is causing severe performance impacts on backup-utils. + +These impacts can be mitigated by using the `--trust-sender` flag with rsync. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running an operating system that has done this, your options are to either downgrade the rsync package to a version before the CVE fix was backported, or upgrade the rsync package to v3.2.5 or newer. + +******************************************* The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From c69269169d154f95b6c31ee4a703bfb86c0bb73d Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 24 Apr 2023 13:51:32 -0400 Subject: [PATCH 1807/2421] Added link to release notes for rsync 3.2.5 --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index f2c343985..b3ab916ba 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -10,7 +10,7 @@ system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 ************ Update April 2023 ************ -The recent fix to rsync for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) is causing severe performance impacts on backup-utils. +The [recent fix to rsync](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) is causing severe performance impacts on backup-utils. These impacts can be mitigated by using the `--trust-sender` flag with rsync. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running an operating system that has done this, your options are to either downgrade the rsync package to a version before the CVE fix was backported, or upgrade the rsync package to v3.2.5 or newer. From 82b3b1a76a1b6cdf75befc6efa5415dd12e418e8 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Wed, 26 Apr 2023 13:59:57 -0400 Subject: [PATCH 1808/2421] Add details on the options customers have --- docs/requirements.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index b3ab916ba..51276e7cc 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -8,13 +8,20 @@ storage and must have network connectivity with the GitHub Enterprise Server app Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. -************ Update April 2023 ************ +--- +### Update April 2023 -The [recent fix to rsync](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) is causing severe performance impacts on backup-utils. +The [recent fix to rsync](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes severe performance impacts on backup-utils. -These impacts can be mitigated by using the `--trust-sender` flag with rsync. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running an operating system that has done this, your options are to either downgrade the rsync package to a version before the CVE fix was backported, or upgrade the rsync package to v3.2.5 or newer. +These impacts can be mitigated by using the `--trust-sender` flag with rsync. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running on an operating system in this situation (i.e. the CVE fix has been backported but the `--trust-sender` flag has not) you have three options: -******************************************* +1. Downgrade (using the package manager on your host) the rsync package to a version before the CVE fix was backported +2. Upgrade (using the package manager on your host) the rsync package to v3.2.5 or newer +3. Manually download and build the rsync binary + +Option #3 is required if your operating system's package manager does not have access to rsync v3.2.5 or later (e.g. Ubuntu Focal). + +--- The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From e63192918168e18a68c08fe126cb3757ffbdef7b Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 27 Apr 2023 10:11:43 -0400 Subject: [PATCH 1809/2421] Update requirements.md --- docs/requirements.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index 51276e7cc..9ee35f9de 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,13 +5,12 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix operating -system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer, and [jq][11] v1.5 or newer. +Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v3.2.5 or newer, and [jq][11] v1.5 or newer. --- ### Update April 2023 -The [recent fix to rsync](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes severe performance impacts on backup-utils. +The [recent fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes severe performance impacts on backup-utils. These impacts can be mitigated by using the `--trust-sender` flag with rsync. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running on an operating system in this situation (i.e. the CVE fix has been backported but the `--trust-sender` flag has not) you have three options: @@ -27,8 +26,7 @@ The parallel backup and restore feature will require [GNU awk][10] and [moreutil We encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. -The backup host must be able to establish outbound network connections to the -GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. +The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. ## Storage requirements From 2799c94a807ae953de03d2c402bd800651429dd0 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 27 Apr 2023 10:12:53 -0400 Subject: [PATCH 1810/2421] Explicitly mentioned which version of rsync has the --trust-sender flag --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index 9ee35f9de..d96fb9676 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -12,7 +12,7 @@ Backup host software requirements are modest: Linux or other modern Unix operati The [recent fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes severe performance impacts on backup-utils. -These impacts can be mitigated by using the `--trust-sender` flag with rsync. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running on an operating system in this situation (i.e. the CVE fix has been backported but the `--trust-sender` flag has not) you have three options: +These impacts can be mitigated by using the `--trust-sender` flag with rsync; this flag is available from v3.2.5 onwards. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running on an operating system in this situation (i.e. the CVE fix has been backported but the `--trust-sender` flag has not) you have three options: 1. Downgrade (using the package manager on your host) the rsync package to a version before the CVE fix was backported 2. Upgrade (using the package manager on your host) the rsync package to v3.2.5 or newer From fefdb95aa03910470bd4d1fc53490858ec122d9e Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 27 Apr 2023 10:16:52 -0400 Subject: [PATCH 1811/2421] Added --trust-sender --- backup.config-example | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backup.config-example b/backup.config-example index 1e6d762f2..ffb3c355f 100644 --- a/backup.config-example +++ b/backup.config-example @@ -38,9 +38,9 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_EXTRA_SSH_OPTS="" -# Any extra options passed to the rsync command. Nothing required by default. -# -#GHE_EXTRA_RSYNC_OPTS="" +# Any extra options passed to the rsync command. +# As of April 2023 the --trust-sender flag is required. +GHE_EXTRA_RSYNC_OPTS="--trust-sender" # If set to 'yes', logging output will be colorized. From 5f58bbd70e91178b377790ebc248d4dad837d59f Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 27 Apr 2023 10:19:11 -0400 Subject: [PATCH 1812/2421] Added link to explanation of why --trust-sender is required --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index ffb3c355f..4f5fd5e5c 100644 --- a/backup.config-example +++ b/backup.config-example @@ -39,7 +39,7 @@ GHE_NUM_SNAPSHOTS=10 #GHE_EXTRA_SSH_OPTS="" # Any extra options passed to the rsync command. -# As of April 2023 the --trust-sender flag is required. +# As of April 2023 the --trust-sender flag is required. See docs/requirements.md#update-april-2023 for details on this change. GHE_EXTRA_RSYNC_OPTS="--trust-sender" From 267350553ed7b8985d967f4b3cfcc9aefdec86e4 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 27 Apr 2023 10:25:06 -0400 Subject: [PATCH 1813/2421] Making the comments clearer. --- backup.config-example | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 4f5fd5e5c..ca6b335bf 100644 --- a/backup.config-example +++ b/backup.config-example @@ -39,7 +39,9 @@ GHE_NUM_SNAPSHOTS=10 #GHE_EXTRA_SSH_OPTS="" # Any extra options passed to the rsync command. -# As of April 2023 the --trust-sender flag is required. See docs/requirements.md#update-april-2023 for details on this change. +# As of April 2023 the minimum version of rsync is 3.2.5 and +# the --trust-sender flag is required. +# See docs/requirements.md#update-april-2023 for details on this change. GHE_EXTRA_RSYNC_OPTS="--trust-sender" From 65c2977f51e285e1d6d53059287b0ef766da7a1c Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 27 Apr 2023 11:25:12 -0400 Subject: [PATCH 1814/2421] Re-ordered the backup host requirements section --- docs/requirements.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index d96fb9676..8b122b990 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -7,7 +7,12 @@ storage and must have network connectivity with the GitHub Enterprise Server app Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v3.2.5 or newer, and [jq][11] v1.5 or newer. ---- +The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. + +We encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. + +The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. + ### Update April 2023 The [recent fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes severe performance impacts on backup-utils. @@ -20,14 +25,6 @@ These impacts can be mitigated by using the `--trust-sender` flag with rsync; th Option #3 is required if your operating system's package manager does not have access to rsync v3.2.5 or later (e.g. Ubuntu Focal). ---- - -The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. - -We encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. - -The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. - ## Storage requirements Storage requirements vary based on current Git repository disk usage and growth From dbcff0725f2bbe323349103242c693770bf38255 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 27 Apr 2023 11:36:26 -0400 Subject: [PATCH 1815/2421] Made the impact of the CVE-2022-29154 more explicit --- docs/requirements.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index 8b122b990..7de76136b 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -15,9 +15,9 @@ The backup host must be able to establish outbound network connections to the Gi ### Update April 2023 -The [recent fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes severe performance impacts on backup-utils. +The [recent fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes backup-utils to timeout. -These impacts can be mitigated by using the `--trust-sender` flag with rsync; this flag is available from v3.2.5 onwards. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running on an operating system in this situation (i.e. the CVE fix has been backported but the `--trust-sender` flag has not) you have three options: +To avoid this time out you must use the `--trust-sender` flag with rsync; this flag is available from v3.2.5 onwards. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running on an operating system in this situation (i.e. the CVE fix has been backported but the `--trust-sender` flag has not) you have three options: 1. Downgrade (using the package manager on your host) the rsync package to a version before the CVE fix was backported 2. Upgrade (using the package manager on your host) the rsync package to v3.2.5 or newer From b12cc3efc25fdb85f79fc096320c964b091e38be Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 27 Apr 2023 11:43:30 -0400 Subject: [PATCH 1816/2421] Corrected language based on comments in 4511 This comment helped me understand what the correct impact is: https://github.com/github/ghes/issues/4511#issuecomment-1504907273 --- docs/requirements.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index 7de76136b..f41125b91 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -15,9 +15,9 @@ The backup host must be able to establish outbound network connections to the Gi ### Update April 2023 -The [recent fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes backup-utils to timeout. +The [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes _severe_ performance degradation to `backup-utils`, making `backup-utils` close to unusable. -To avoid this time out you must use the `--trust-sender` flag with rsync; this flag is available from v3.2.5 onwards. Unfortunately some Linux distributions have backported the fix for this CVE to their rsync package without also backporting the `--trust-sender` flag. If your backup host is running on an operating system in this situation (i.e. the CVE fix has been backported but the `--trust-sender` flag has not) you have three options: +To avoid this degradation you **must** use the `--trust-sender` flag with rsync. This flag is available from v3.2.5 onwards, but unfortunately some Linux distributions have backported the fix for CVE-2022-29154 to their rsync package without backporting the `--trust-sender` flag. If your backup host is running on an operating system in this situation (i.e. the CVE fix has been backported but the `--trust-sender` flag has not) then you have three options: 1. Downgrade (using the package manager on your host) the rsync package to a version before the CVE fix was backported 2. Upgrade (using the package manager on your host) the rsync package to v3.2.5 or newer From 3c467b2dbee4675a17c46d008fd61cfa21ea4ab1 Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 27 Apr 2023 22:51:26 +0300 Subject: [PATCH 1817/2421] Get dataset from azure --- .github/workflows/restore.yml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 6ce850465..0a41bcdb8 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -19,11 +19,7 @@ on: required: false type: string default: 'master' - version: - description: 'GHES Version of dataset' - required: false - type: string - default: "3.8.0" + workflow_call: inputs: size: @@ -40,11 +36,7 @@ on: required: false type: string default: 'master' - version: - description: 'GHES Version of dataset' - required: false - type: string - default: "3.8.0" + jobs: build: runs-on: ubuntu-latest @@ -84,12 +76,22 @@ jobs: token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" lfs: 'true' + - name: Download from blob storage + run: | + az storage blob download \ + --account-name ghesresults \ + --container-name ghes-data \ + --name v3.8-small-docs.tar.gz \ + --file ghes-data/data/backup/v3.8-small-docs.tar.gz \ + --connection-string "${{ secrets.CONNECTIONSTRING }}" + + - name: Unzip backup and setup symlink run: | mkdir $HOME/ghe-backup-data dir_name=$(date +%s) mkdir $HOME/ghe-backup-data/$dir_name - tar -xvf ghes-data/data/backup/${{ inputs.size }}/v3.8.0/${{ inputs.size }}-refined.tar.gz -C $HOME/ghe-backup-data/$dir_name + tar -xvf ghes-data/data/backup/v3.8-small-docs.tar.gz -C $HOME/ghe-backup-data/$dir_name ln -s $dir_name $HOME/ghe-backup-data/current From 35087ba1c0321e0aad83daedfff62c9e56a9c01c Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 27 Apr 2023 23:39:34 +0300 Subject: [PATCH 1818/2421] Remove extra input var --- .github/workflows/restore.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 0a41bcdb8..6782118e0 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -22,11 +22,6 @@ on: workflow_call: inputs: - size: - description: 'Size of the dataset to restore' - required: false - type: string - default: 'small' hostname: description: 'Hostname of the server' required: true From 853aa914585b5a86c43a5a4e076c8f790a05334c Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 27 Apr 2023 23:47:43 +0300 Subject: [PATCH 1819/2421] No longer need to clone ghes-data --- .github/workflows/restore.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 6782118e0..bad5be5c6 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -63,21 +63,22 @@ jobs: - name: Load docker container run: docker load -i backup-utils.tar - - uses: actions/checkout@v3 - with: - path: ghes-data - repository: github/ghes-data - ref: main - token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" - lfs: 'true' + # - uses: actions/checkout@v3 + # with: + # path: ghes-data + # repository: github/ghes-data + # ref: main + # token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" + # lfs: 'true' - name: Download from blob storage run: | + mkdir ghes-data az storage blob download \ --account-name ghesresults \ --container-name ghes-data \ --name v3.8-small-docs.tar.gz \ - --file ghes-data/data/backup/v3.8-small-docs.tar.gz \ + --file ghes-data/v3.8-small-docs.tar.gz \ --connection-string "${{ secrets.CONNECTIONSTRING }}" @@ -86,7 +87,7 @@ jobs: mkdir $HOME/ghe-backup-data dir_name=$(date +%s) mkdir $HOME/ghe-backup-data/$dir_name - tar -xvf ghes-data/data/backup/v3.8-small-docs.tar.gz -C $HOME/ghe-backup-data/$dir_name + tar -xvf ghes-data/3.8-small-docs.tar.gz -C $HOME/ghe-backup-data/$dir_name ln -s $dir_name $HOME/ghe-backup-data/current From 738b85fe4716690d4ddf0848123e9484622498e3 Mon Sep 17 00:00:00 2001 From: solmaz Date: Fri, 28 Apr 2023 01:38:33 +0300 Subject: [PATCH 1820/2421] Remove backup for now --- .github/workflows/backup.yml | 112 ----------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 .github/workflows/backup.yml diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml deleted file mode 100644 index 83c70f7a7..000000000 --- a/.github/workflows/backup.yml +++ /dev/null @@ -1,112 +0,0 @@ -name: Backup -run-name: ${{ github.actor }} run backup and upload to ghes-data -on: - workflow_dispatch: - inputs: - hostname: - description: 'Hostname' - required: true - type: string - ref: - description: 'Ref' - required: false - type: string - default: 'master' - workflow_call: - inputs: - size: - description: 'Size of the dataset to restore' - required: false - type: string - default: 'small' - hostname: - description: 'Hostname of the server' - required: true - type: string - ref: - description: 'Branch ref to use' - required: false - type: string - default: 'master' - version: - description: 'GHES Version of dataset' - required: false - type: string - default: "3.8.0" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - repository: github/backup-utils-private - ref: ${{ inputs.ref }} - token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" - - run: docker build . --file Dockerfile --tag backup-utils - - run: docker save backup-utils -o backup-utils.tar - - uses: actions/upload-artifact@v3 - with: - name: backup-utils - path: backup-utils.tar - backup-utils-backup: - needs: build - runs-on: ubuntu-latest - env: - SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }} - steps: - - uses: actions/download-artifact@v3 - with: - name: backup-utils - - name: Load docker container - run: docker load -i backup-utils.tar - - uses: actions/checkout@v3 - - name: Create backup directory - run: mkdir $HOME/ghe-backup-data - - name: set up ssh SSH_KEY - run: echo -e "${SSH_KEY}\n" > $HOME/backup - - name: set up ssh key permissions - run: chmod 0600 $HOME/backup - - name: change version - run: echo "3.8.0" > $HOME/version - - - name: Perform backup - run: | - jq=$(command -v jq) - export PATH=$PATH:$jq - echo $PATH - docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ - -e "GHE_DATA_DIR=/data" \ - -e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \ - -e "GHE_NUM_SNAPSHOTS=15" \ - -v "$HOME/ghe-backup-data:/data" \ - -v "$HOME/backup:/ghe-ssh/id_rsa" \ - -v "$HOME/version:/backup-utils/share/github-backup-utils/version" \ - --rm \ - backup-utils ghe-backup - - - uses: actions/checkout@v3 - with: - path: ghes-data - repository: github/ghes-data - ref: main - token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" - lfs: 'true' - - - name: Zip backup - run: | - ls -al $HOME/ghe-backup-data - dirname=$(find $HOME/ghe-backup-data/ -type d -maxdepth 1 -mindepth 1) - echo $dirname - tar -czvf $dirname.tar.gz $dirname - cp $dirname.tar.gz ghes-data/data/backup/{{inputs.size}}/v{{inputs.version}}/$dirname.tar.gz - - - name: Upload backup to ghes-data - run: | - cd ghes-data/data/backup/{{inputs.size}}/v{{inputs.version}} - git add . - git commit -am "Added new backup from automation" - git push - - - From acc6351f38658d5d68c7a34bbf9268d9d5ffdfe0 Mon Sep 17 00:00:00 2001 From: solmaz Date: Fri, 28 Apr 2023 01:43:12 +0300 Subject: [PATCH 1821/2421] Remove unnecessary code --- .github/workflows/restore.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index bad5be5c6..ed412b330 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -63,14 +63,6 @@ jobs: - name: Load docker container run: docker load -i backup-utils.tar - # - uses: actions/checkout@v3 - # with: - # path: ghes-data - # repository: github/ghes-data - # ref: main - # token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" - # lfs: 'true' - - name: Download from blob storage run: | mkdir ghes-data @@ -81,7 +73,6 @@ jobs: --file ghes-data/v3.8-small-docs.tar.gz \ --connection-string "${{ secrets.CONNECTIONSTRING }}" - - name: Unzip backup and setup symlink run: | mkdir $HOME/ghe-backup-data From 6ccdc7095075da700521a428d03f17c15b31ad80 Mon Sep 17 00:00:00 2001 From: solmaz Date: Fri, 28 Apr 2023 03:01:05 +0300 Subject: [PATCH 1822/2421] Fix linter --- .github/workflows/restore.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index ed412b330..00f4e7dbd 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -75,24 +75,24 @@ jobs: - name: Unzip backup and setup symlink run: | - mkdir $HOME/ghe-backup-data + mkdir "$HOME/ghe-backup-data" dir_name=$(date +%s) - mkdir $HOME/ghe-backup-data/$dir_name - tar -xvf ghes-data/3.8-small-docs.tar.gz -C $HOME/ghe-backup-data/$dir_name + mkdir "$HOME/ghe-backup-data/$dir_name" + tar -xvf ghes-data/3.8-small-docs.tar.gz -C "$HOME/ghe-backup-data/$dir_name" ln -s $dir_name $HOME/ghe-backup-data/current - name: set up ssh SSH_KEY - run: echo -e "${SSH_KEY}\n" > $HOME/backup + run: echo -e "${SSH_KEY}\n" > "$HOME/backup" - name: set up ssh key permissions - run: chmod 0600 $HOME/backup + run: chmod 0600 "$HOME/backup" - name: change version run: echo "3.8.0" > $HOME/version - name: Prepare for restore - run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" + run: ssh -p122 -i "$HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" - name: Restore data to instance run: | @@ -107,7 +107,7 @@ jobs: backup-utils ghe-restore ${{ inputs.hostname }} - name: Reset maintenance mode after restore - run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" + run: ssh -p122 -i" $HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" From 49581d98242e65d10a383ccb85b1837158b0cb2a Mon Sep 17 00:00:00 2001 From: solmaz Date: Fri, 28 Apr 2023 03:05:36 +0300 Subject: [PATCH 1823/2421] Fix linter --- .github/workflows/restore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 00f4e7dbd..03549218c 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -80,7 +80,7 @@ jobs: mkdir "$HOME/ghe-backup-data/$dir_name" tar -xvf ghes-data/3.8-small-docs.tar.gz -C "$HOME/ghe-backup-data/$dir_name" - ln -s $dir_name $HOME/ghe-backup-data/current + ln -s $dir_name "$HOME/ghe-backup-data/current" - name: set up ssh SSH_KEY run: echo -e "${SSH_KEY}\n" > "$HOME/backup" @@ -89,7 +89,7 @@ jobs: run: chmod 0600 "$HOME/backup" - name: change version - run: echo "3.8.0" > $HOME/version + run: echo "3.8.0" > "$HOME/version" - name: Prepare for restore run: ssh -p122 -i "$HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" From cb94161af482f15e1a6e7369cec83d41323d07d6 Mon Sep 17 00:00:00 2001 From: solmaz Date: Fri, 28 Apr 2023 03:09:41 +0300 Subject: [PATCH 1824/2421] Fix linter --- .github/workflows/restore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 03549218c..6cf7da203 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -78,9 +78,9 @@ jobs: mkdir "$HOME/ghe-backup-data" dir_name=$(date +%s) mkdir "$HOME/ghe-backup-data/$dir_name" - tar -xvf ghes-data/3.8-small-docs.tar.gz -C "$HOME/ghe-backup-data/$dir_name" + tar -xvf "ghes-data/3.8-small-docs.tar.gz" -C "$HOME/ghe-backup-data/$dir_name" - ln -s $dir_name "$HOME/ghe-backup-data/current" + ln -s "$dir_name" "$HOME/ghe-backup-data/current" - name: set up ssh SSH_KEY run: echo -e "${SSH_KEY}\n" > "$HOME/backup" From f1a85b684298d4c47f8c26bcef49cf1088770593 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Fri, 28 Apr 2023 18:01:12 -0400 Subject: [PATCH 1825/2421] Create SUPPORT.md --- docs/SUPPORT.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docs/SUPPORT.md diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md new file mode 100644 index 000000000..a05a91f5b --- /dev/null +++ b/docs/SUPPORT.md @@ -0,0 +1,13 @@ +# Support + +## How to file issues and get help + +**github/backup-utils** uses GitHub issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. + +For non-urgent help, feature requests, and questions about using this project, please [open an issue](https://github.com/github/backup-utils/issues/new/choose). + +For urgent help with **backup-utils**, for example when restoring a backup to recover from a site failure or other disaster, please [open a ticket in GitHub's support portal](https://support.github.com/contact) and work with GitHub Support directly. + +## GitHub Support Policy + +**github/backup-utils** is an MIT-licensed open source project under active development and maintained by GitHub staff. We will do our best to respond to support, feature requests, and community questions in a timely manner. From 3b386f8552376e7f9276f0710e46e2cba4498a63 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 1 May 2023 13:30:26 -0400 Subject: [PATCH 1826/2421] Added sentence about using --trust-sender before v3.2.5 --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index f41125b91..3497f5df1 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -23,7 +23,7 @@ To avoid this degradation you **must** use the `--trust-sender` flag with rsync. 2. Upgrade (using the package manager on your host) the rsync package to v3.2.5 or newer 3. Manually download and build the rsync binary -Option #3 is required if your operating system's package manager does not have access to rsync v3.2.5 or later (e.g. Ubuntu Focal). +Option #3 is required if your operating system's package manager does not have access to rsync v3.2.5 or later (e.g. Ubuntu Focal). Please note that if you use a version of rsync that is lower than v3.2.5, you will need to ensure the `--trust-sender` flag is not enabled in your `backup.config` file since that flag is only supported on v3.2.5 or later. ## Storage requirements From 15915aa2274c89bac305eb3bc9ebddeeecd1121a Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 2 May 2023 12:57:07 +0300 Subject: [PATCH 1827/2421] Remove extra v from file name --- .github/workflows/restore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 6cf7da203..a90ac2a52 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -70,7 +70,7 @@ jobs: --account-name ghesresults \ --container-name ghes-data \ --name v3.8-small-docs.tar.gz \ - --file ghes-data/v3.8-small-docs.tar.gz \ + --file ghes-data/3.8-small-docs.tar.gz \ --connection-string "${{ secrets.CONNECTIONSTRING }}" - name: Unzip backup and setup symlink From d14b3b6774944aed7baa86dad275f2ddcff86c83 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 2 May 2023 13:32:21 +0300 Subject: [PATCH 1828/2421] Fix ssh key path --- .github/workflows/restore.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index a90ac2a52..9f6acb4e0 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -106,8 +106,17 @@ jobs: --rm \ backup-utils ghe-restore ${{ inputs.hostname }} + # - name: Reset SSH key + # run: ssh-keygen -f "/home/runner/.ssh/known_hosts" -R "${{ inputs.hostname }}:122 + + # - name: set up ssh SSH_KEY + # run: echo -e "${SSH_KEY}\n" > "$HOME/backup" + + # - name: set up ssh key permissions + # run: chmod 0600 "$HOME/backup" + - name: Reset maintenance mode after restore - run: ssh -p122 -i" $HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" + run: ssh -p122 -i "$HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" From aa887ac50db75f689c3ad95e0ff31e9ba5e11134 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 2 May 2023 13:56:30 +0300 Subject: [PATCH 1829/2421] Fix SSH key reference --- .github/workflows/restore.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 9f6acb4e0..24f1aa061 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -106,15 +106,6 @@ jobs: --rm \ backup-utils ghe-restore ${{ inputs.hostname }} - # - name: Reset SSH key - # run: ssh-keygen -f "/home/runner/.ssh/known_hosts" -R "${{ inputs.hostname }}:122 - - # - name: set up ssh SSH_KEY - # run: echo -e "${SSH_KEY}\n" > "$HOME/backup" - - # - name: set up ssh key permissions - # run: chmod 0600 "$HOME/backup" - - name: Reset maintenance mode after restore run: ssh -p122 -i "$HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" From 0f9177edef940782508766fb135f954fe994c5e8 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Tue, 2 May 2023 11:13:01 -0400 Subject: [PATCH 1830/2421] Adding check to add trusted sender if supported --- share/github-backup-utils/ghe-rsync | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 1b2ac7e2a..457ab6ef6 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -20,6 +20,11 @@ else done fi +# check if `--trust-sender` is supported +if rsync -h | grep '\-\-trust-sender' >/dev/null 2>&1; then + parameters+=("--trust-sender") +fi + ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' rsync_version_check=$(rsync --version | egrep "version 3.[0-9]*.[0-9]*") if [ ! -z "$rsync_version_check" ]; then From 1d313f48ee15ad3852b159eee4744d29c57c14f9 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Tue, 2 May 2023 13:45:56 -0400 Subject: [PATCH 1831/2421] Change adds more checking and error handling: - Adds description of what each added section does - Imports `GHE_EXTRA_RSYNC_OPTS` to allow manipulation - Removes `--trust-sender` from `GHE_EXTRA_RSYNC_OPTS` if not supported - Prevents `--trust-sender` from being added twice - Updates the call to `rsync` to remove the call to GHE_EXTRA_RSYNC_OPTS --- share/github-backup-utils/ghe-rsync | 34 +++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 457ab6ef6..f05feb08b 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -20,19 +20,45 @@ else done fi -# check if `--trust-sender` is supported +# This adds `--trust-sender` to the parameters if it is supported by rsync +# check if `--trust-sender` is supported and prepend if available. if rsync -h | grep '\-\-trust-sender' >/dev/null 2>&1; then - parameters+=("--trust-sender") + parameters=("--trust-sender" "${parameters[@]}") +fi + +# This loads the extra options from the config file and allows for overriding +# load $GHE_EXTRA_RSYNC_OPTS from config if available +if [ -n "$GHE_EXTRA_RSYNC_OPTS" ]; then + # shellcheck disable=SC2206 + GHE_EXTRA_RSYNC_OPTS=($GHE_EXTRA_RSYNC_OPTS) +else + GHE_EXTRA_RSYNC_OPTS=() +fi + +# This prevents `--trust-sender` from being used if it is not supported by rsync +# Check if `--trust-sender` is in GHE_EXTRA_RSYNC_OPTS and remove if unavailable. +if ! rsync -h | grep '\-\-trust-sender' >/dev/null 2>&1; then + for options in "${GHE_EXTRA_RSYNC_OPTS[@]}"; do + [[ ! $options == "--trust-sender" ]] && parameters+=("$options") + done +fi + +# This removes the possibility of having `--trust-sender` twice in the parameters +# Check if `--trust-sender` is already in parameters and remove from GHE_EXTRA_RSYNC_OPTS +if [[ " ${parameters[*]} " == *" --trust-sender "* ]]; then + for options in "${GHE_EXTRA_RSYNC_OPTS[@]}"; do + [[ ! $options == "--trust-sender" ]] && parameters+=("$options") + done fi ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' rsync_version_check=$(rsync --version | egrep "version 3.[0-9]*.[0-9]*") if [ ! -z "$rsync_version_check" ]; then # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe - rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS 2>&1 | (egrep -v "$ignoreout" || true) + rsync "${parameters[@]}" 2>&1 | (egrep -v "$ignoreout" || true) else # rsync <3.x sends errors to stdout. - rsync "${parameters[@]}" $GHE_EXTRA_RSYNC_OPTS | (egrep -v "$ignoreout" || true) + rsync "${parameters[@]}" | (egrep -v "$ignoreout" || true) fi res=$? From 6c660bc36b0da6ad8d01c97bad9e3c1e5f4c2a7b Mon Sep 17 00:00:00 2001 From: Diana Date: Tue, 2 May 2023 14:26:58 -0400 Subject: [PATCH 1832/2421] Fixed `shellcheck` suggestion - Replaced `egrep` with `grep -E` - Replaced `! -z` with `-n` --- share/github-backup-utils/ghe-rsync | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index f05feb08b..b8936887b 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -52,13 +52,13 @@ if [[ " ${parameters[*]} " == *" --trust-sender "* ]]; then fi ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' -rsync_version_check=$(rsync --version | egrep "version 3.[0-9]*.[0-9]*") -if [ ! -z "$rsync_version_check" ]; then +rsync_version_check=$(rsync --version | grep -E "version 3.[0-9]*.[0-9]*") +if [ -n "$rsync_version_check" ]; then # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe - rsync "${parameters[@]}" 2>&1 | (egrep -v "$ignoreout" || true) + rsync "${parameters[@]}" 2>&1 | (grep -E -v "$ignoreout" || true) else # rsync <3.x sends errors to stdout. - rsync "${parameters[@]}" | (egrep -v "$ignoreout" || true) + rsync "${parameters[@]}" | (grep -E -v "$ignoreout" || true) fi res=$? From d97154acffedfe816f1a3cccb6167c18f78f93b2 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Tue, 2 May 2023 16:19:45 -0400 Subject: [PATCH 1833/2421] Update backup.config-example Reverting the changes I made previously, since these are no longer needed. This PR (https://github.com/github/backup-utils-private/pull/311) added the `--trust-sender` flag to `ghe-rsync`. --- backup.config-example | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/backup.config-example b/backup.config-example index ca6b335bf..f845edb89 100644 --- a/backup.config-example +++ b/backup.config-example @@ -38,11 +38,10 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_EXTRA_SSH_OPTS="" -# Any extra options passed to the rsync command. -# As of April 2023 the minimum version of rsync is 3.2.5 and -# the --trust-sender flag is required. -# See docs/requirements.md#update-april-2023 for details on this change. -GHE_EXTRA_RSYNC_OPTS="--trust-sender" + +# Any extra options passed to the rsync command. Nothing required by default. +# +#GHE_EXTRA_RSYNC_OPTS="" # If set to 'yes', logging output will be colorized. From d9b41c968e5ead5702ea55554008853703e5e52f Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Tue, 2 May 2023 16:20:08 -0400 Subject: [PATCH 1834/2421] Removing extra line --- backup.config-example | 1 - 1 file changed, 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index f845edb89..1e6d762f2 100644 --- a/backup.config-example +++ b/backup.config-example @@ -38,7 +38,6 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_EXTRA_SSH_OPTS="" - # Any extra options passed to the rsync command. Nothing required by default. # #GHE_EXTRA_RSYNC_OPTS="" From c14eda405ff4c024bdbd0083496822d4a922f6ec Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Tue, 2 May 2023 16:22:18 -0400 Subject: [PATCH 1835/2421] Revising the April 2023 recommendation for option #3 Updated details about option #3 in the `Update April 2023` section based on this PR (https://github.com/github/backup-utils-private/pull/311/files) --- docs/requirements.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index 3497f5df1..468c8dfeb 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -21,9 +21,9 @@ To avoid this degradation you **must** use the `--trust-sender` flag with rsync. 1. Downgrade (using the package manager on your host) the rsync package to a version before the CVE fix was backported 2. Upgrade (using the package manager on your host) the rsync package to v3.2.5 or newer -3. Manually download and build the rsync binary +3. Manually download rsync v3.2.5 or newer and build the rsync binary -Option #3 is required if your operating system's package manager does not have access to rsync v3.2.5 or later (e.g. Ubuntu Focal). Please note that if you use a version of rsync that is lower than v3.2.5, you will need to ensure the `--trust-sender` flag is not enabled in your `backup.config` file since that flag is only supported on v3.2.5 or later. +Option #3 is required if your operating system's package manager does not have access to rsync v3.2.5 or later (e.g. Ubuntu Focal). ## Storage requirements From c6c9b9c9c0ba29971454859c0b93bdb4c2e34cea Mon Sep 17 00:00:00 2001 From: Diana Date: Tue, 2 May 2023 17:37:36 -0400 Subject: [PATCH 1836/2421] updating minimum rsync requirement to 3.2.5 --- share/github-backup-utils/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/requirements.txt b/share/github-backup-utils/requirements.txt index acf767129..2ad762c0e 100644 --- a/share/github-backup-utils/requirements.txt +++ b/share/github-backup-utils/requirements.txt @@ -1,3 +1,3 @@ -min_rsync=2.6.4 +min_rsync=3.2.5 min_openssh=5.6 min_jq=1.5 From b864a361661466f383f7e5c94af2f8c00d6c2954 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Wed, 3 May 2023 10:45:09 -0400 Subject: [PATCH 1837/2421] Refined the April 2023 update section --- docs/requirements.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index 468c8dfeb..8f57decab 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,7 +5,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v3.2.5 or newer, and [jq][11] v1.5 or newer. +Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v3.2.5 or newer, and [jq][11] v1.5 or newer. See below for an update on rsync. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. @@ -13,11 +13,15 @@ We encourage the use of [Docker](docker.md), as it ensures compatible versions o The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. -### Update April 2023 +### Update April 2023 - rsync requirements -The [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causes _severe_ performance degradation to `backup-utils`, making `backup-utils` close to unusable. +We have updated the minimum required version of rsync from `2.6.4` to `3.2.5`. This change was required due to the [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causing _severe_ performance degradation to `backup-utils`. The only way to avoid this degradation is to use the `--trust-sender` flag, and since this flag is only available from rsync v3.2.5 onwards, we have updated the minimum required version of rsync. -To avoid this degradation you **must** use the `--trust-sender` flag with rsync. This flag is available from v3.2.5 onwards, but unfortunately some Linux distributions have backported the fix for CVE-2022-29154 to their rsync package without backporting the `--trust-sender` flag. If your backup host is running on an operating system in this situation (i.e. the CVE fix has been backported but the `--trust-sender` flag has not) then you have three options: +Unfortunately the situation is a little more complicated. If you are running an older version of rsync (i.e. < v3.2.5) you _might_ be ok. + +It depends on whether the rsync package you are using on your backup host has backported the fix for CVE-2022-29154 without backporting the `--trust-sender` flag. + +If your backup host is running an rsync package that has backported the CVE fix without backporting the `--trust-sender` flag then you have three options: 1. Downgrade (using the package manager on your host) the rsync package to a version before the CVE fix was backported 2. Upgrade (using the package manager on your host) the rsync package to v3.2.5 or newer From d58df714842d2a16e9cecf14b7605dfbadc713d5 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 13:32:39 -0400 Subject: [PATCH 1838/2421] Changing feature checking and adding testing - This moves feature checking to an extensible function - Adds a test for the feature checking to allow CI testing - Now adds extra variables to parameters after checking for duplicates --- share/github-backup-utils/ghe-rsync | 29 ++++--------------- .../ghe-rsync-feature-checker.sh | 20 +++++++++++++ test/test-ghe-rsync-feature-checker.sh | 14 +++++++++ 3 files changed, 40 insertions(+), 23 deletions(-) create mode 100755 share/github-backup-utils/ghe-rsync-feature-checker.sh create mode 100644 test/test-ghe-rsync-feature-checker.sh diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index b8936887b..c2b6e90ce 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -20,36 +20,19 @@ else done fi -# This adds `--trust-sender` to the parameters if it is supported by rsync -# check if `--trust-sender` is supported and prepend if available. -if rsync -h | grep '\-\-trust-sender' >/dev/null 2>&1; then +# This prepends `--trust-sender` to the parameters if supported by the current version of rsync to mitigate the degredation of performance due to the resolution of CVE-2022-29154 +# shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker.sh +if [ "$( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh" "--trust-sender" = "true" ]; then parameters=("--trust-sender" "${parameters[@]}") fi -# This loads the extra options from the config file and allows for overriding -# load $GHE_EXTRA_RSYNC_OPTS from config if available +# This loads the $GHE_EXTRA_RSYNC_OPTS from the config file if avalible then adds them to the parameters and skip adding if already present in the parameters if [ -n "$GHE_EXTRA_RSYNC_OPTS" ]; then - # shellcheck disable=SC2206 - GHE_EXTRA_RSYNC_OPTS=($GHE_EXTRA_RSYNC_OPTS) -else - GHE_EXTRA_RSYNC_OPTS=() -fi - -# This prevents `--trust-sender` from being used if it is not supported by rsync -# Check if `--trust-sender` is in GHE_EXTRA_RSYNC_OPTS and remove if unavailable. -if ! rsync -h | grep '\-\-trust-sender' >/dev/null 2>&1; then - for options in "${GHE_EXTRA_RSYNC_OPTS[@]}"; do - [[ ! $options == "--trust-sender" ]] && parameters+=("$options") + for extra_opt in $GHE_EXTRA_RSYNC_OPTS; do + [[ ! " ${parameters[@]} " =~ " $extra_opt " ]] && parameters+=("$extra_opt") done fi -# This removes the possibility of having `--trust-sender` twice in the parameters -# Check if `--trust-sender` is already in parameters and remove from GHE_EXTRA_RSYNC_OPTS -if [[ " ${parameters[*]} " == *" --trust-sender "* ]]; then - for options in "${GHE_EXTRA_RSYNC_OPTS[@]}"; do - [[ ! $options == "--trust-sender" ]] && parameters+=("$options") - done -fi ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' rsync_version_check=$(rsync --version | grep -E "version 3.[0-9]*.[0-9]*") diff --git a/share/github-backup-utils/ghe-rsync-feature-checker.sh b/share/github-backup-utils/ghe-rsync-feature-checker.sh new file mode 100755 index 000000000..b041ee900 --- /dev/null +++ b/share/github-backup-utils/ghe-rsync-feature-checker.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +#/ Usage: ghe-rsync-feature-checker +#/ returns true if the passed rsync command is supported by the current version of rsync +#/ returns false if the passed rsync command is not supported by the current version of rsync +#/ + +set -o pipefail + +# set the variable from the first argument +rsync_command="$1" + +# strip -- from the passed rsync command +rsync_command="${rsync_command/--/}" + +# check if the passed rsync command is supported by the current version of rsync +if rsync -h | grep "$rsync_command" >/dev/null 2>&1; then + echo "true" +else + echo "false" +fi \ No newline at end of file diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh new file mode 100644 index 000000000..cd555b86c --- /dev/null +++ b/test/test-ghe-rsync-feature-checker.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# ghe-rsync-feature-checker command tests + +TESTS_DIR="$PWD/$(dirname "$0")" +# Bring in testlib. +# shellcheck source=test/testlib.sh +. "$TESTS_DIR/testlib.sh" + + +# Test ghe-rsync-feature-checker command +ghe-rsync-feature-checker "--help" | grep -q "true" +ghe-rsync-feature-checker "help" | grep -q "true" +ghe-rsync-feature-checker "--ignore-missing-args" | grep -q "false" +ghe-rsync-feature-checker "ignore-missing-args" | grep -q "false" \ No newline at end of file From 3d2af0a5ad9982a1df77f807235097afd63db45b Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 13:38:49 -0400 Subject: [PATCH 1839/2421] Updated test to standard convention --- test/test-ghe-rsync-feature-checker.sh | 39 ++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index cd555b86c..3a5fafd2b 100644 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -6,9 +6,38 @@ TESTS_DIR="$PWD/$(dirname "$0")" # shellcheck source=test/testlib.sh . "$TESTS_DIR/testlib.sh" +begin_test "ghe-rsync-feature-checker for know command `--help`" +( + set -e -# Test ghe-rsync-feature-checker command -ghe-rsync-feature-checker "--help" | grep -q "true" -ghe-rsync-feature-checker "help" | grep -q "true" -ghe-rsync-feature-checker "--ignore-missing-args" | grep -q "false" -ghe-rsync-feature-checker "ignore-missing-args" | grep -q "false" \ No newline at end of file + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker "--help" | grep -q "true" +) +end_test + +begin_test "ghe-rsync-feature-checker for know command `help`" +( + set -e + + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker "help" | grep -q "true" +) +end_test + +begin_test "ghe-rsync-feature-checker for known unsupported command `--ignore-missing-args`" +( + set -e + + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker "--ignore-missing-args" | grep -q "false" +) +end_test + +begin_test "ghe-rsync-feature-checker for known unsupported command `ignore-missing-args`" +( + set -e + + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker "ignore-missing-args" | grep -q "false" +) +end_test \ No newline at end of file From fb3e1f3a54b95335d57c4f94a27b33df8631ddc8 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 13:52:44 -0400 Subject: [PATCH 1840/2421] Fixing spelling mistakes and uniformity issues - Changed `ignoreout` to `ignore_out` --- share/github-backup-utils/ghe-rsync | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index c2b6e90ce..a9dbf92cf 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -20,13 +20,13 @@ else done fi -# This prepends `--trust-sender` to the parameters if supported by the current version of rsync to mitigate the degredation of performance due to the resolution of CVE-2022-29154 +# This prepends `--trust-sender` to the parameters if supported by the current version of rsync to mitigate the degradation of performance due to the resolution of CVE-2022-29154 # shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker.sh if [ "$( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh" "--trust-sender" = "true" ]; then parameters=("--trust-sender" "${parameters[@]}") fi -# This loads the $GHE_EXTRA_RSYNC_OPTS from the config file if avalible then adds them to the parameters and skip adding if already present in the parameters +# This loads the $GHE_EXTRA_RSYNC_OPTS from the config file if available then adds them to the parameters and skip adding if already present in the parameters if [ -n "$GHE_EXTRA_RSYNC_OPTS" ]; then for extra_opt in $GHE_EXTRA_RSYNC_OPTS; do [[ ! " ${parameters[@]} " =~ " $extra_opt " ]] && parameters+=("$extra_opt") @@ -34,14 +34,14 @@ if [ -n "$GHE_EXTRA_RSYNC_OPTS" ]; then fi -ignoreout='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' +ignore_out='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' rsync_version_check=$(rsync --version | grep -E "version 3.[0-9]*.[0-9]*") if [ -n "$rsync_version_check" ]; then # rsync >= 3.x sends errors to stderr. so, we need to redirect to stdout before the pipe - rsync "${parameters[@]}" 2>&1 | (grep -E -v "$ignoreout" || true) + rsync "${parameters[@]}" 2>&1 | (grep -E -v "$ignore_out" || true) else # rsync <3.x sends errors to stdout. - rsync "${parameters[@]}" | (grep -E -v "$ignoreout" || true) + rsync "${parameters[@]}" | (grep -E -v "$ignore_out" || true) fi res=$? From b0e07491c40a9b65d89c34714794ba3632668244 Mon Sep 17 00:00:00 2001 From: Diana Date: Wed, 3 May 2023 14:12:10 -0400 Subject: [PATCH 1841/2421] Update ghe-rsync to fix issue with new feature checker - Reworked the call for ghe-rsync-feature-checker.sh --- share/github-backup-utils/ghe-rsync | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index a9dbf92cf..7bda8879a 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -22,7 +22,7 @@ fi # This prepends `--trust-sender` to the parameters if supported by the current version of rsync to mitigate the degradation of performance due to the resolution of CVE-2022-29154 # shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker.sh -if [ "$( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh" "--trust-sender" = "true" ]; then +if [ "$($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh --trust-sender)" == "true" ]; then parameters=("--trust-sender" "${parameters[@]}") fi From 5f7d0ccc539a7bb4f0b777d54b0e96ee61e3cdc5 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 14:39:11 -0400 Subject: [PATCH 1842/2421] Feature checker updated - Now using `grep -E "\b$rsync_command\b"` for explicit checking --- share/github-backup-utils/ghe-rsync-feature-checker.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync-feature-checker.sh b/share/github-backup-utils/ghe-rsync-feature-checker.sh index b041ee900..a7d595ab6 100755 --- a/share/github-backup-utils/ghe-rsync-feature-checker.sh +++ b/share/github-backup-utils/ghe-rsync-feature-checker.sh @@ -9,11 +9,11 @@ set -o pipefail # set the variable from the first argument rsync_command="$1" -# strip -- from the passed rsync command -rsync_command="${rsync_command/--/}" +# strip - and -- from the passed rsync command +rsync_command="${rsync_command/-/}" # check if the passed rsync command is supported by the current version of rsync -if rsync -h | grep "$rsync_command" >/dev/null 2>&1; then +if rsync -h | grep -E "\b$rsync_command\b" >/dev/null 2>&1; then echo "true" else echo "false" From 0a63b28ecd7c9345240109f3a5d4e9af6291851e Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 14:47:25 -0400 Subject: [PATCH 1843/2421] Fixed bug with stripping - and -- --- share/github-backup-utils/ghe-rsync-feature-checker.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync-feature-checker.sh b/share/github-backup-utils/ghe-rsync-feature-checker.sh index a7d595ab6..82edb786c 100755 --- a/share/github-backup-utils/ghe-rsync-feature-checker.sh +++ b/share/github-backup-utils/ghe-rsync-feature-checker.sh @@ -10,7 +10,10 @@ set -o pipefail rsync_command="$1" # strip - and -- from the passed rsync command -rsync_command="${rsync_command/-/}" +rsync_command="${rsync_command/-/}" && rsync_command="${rsync_command/-/}" + + +echo "rsync_command: $rsync_command" # check if the passed rsync command is supported by the current version of rsync if rsync -h | grep -E "\b$rsync_command\b" >/dev/null 2>&1; then From 6c397d108fd52118796dc022a5d646d7c1e40023 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 14:48:00 -0400 Subject: [PATCH 1844/2421] Fixed bug with loading $GHE_EXTRA_RSYNC_OPTS --- share/github-backup-utils/ghe-rsync | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 7bda8879a..4166295be 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -29,7 +29,9 @@ fi # This loads the $GHE_EXTRA_RSYNC_OPTS from the config file if available then adds them to the parameters and skip adding if already present in the parameters if [ -n "$GHE_EXTRA_RSYNC_OPTS" ]; then for extra_opt in $GHE_EXTRA_RSYNC_OPTS; do - [[ ! " ${parameters[@]} " =~ " $extra_opt " ]] && parameters+=("$extra_opt") + if [ $($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh "$extra_opt") == "true" ]; then + parameters+=("$extra_opt") + fi done fi From 943165929484756cfc87272db1076d01f6b2663f Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 14:49:51 -0400 Subject: [PATCH 1845/2421] Removed debugging echo statement --- share/github-backup-utils/ghe-rsync-feature-checker.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync-feature-checker.sh b/share/github-backup-utils/ghe-rsync-feature-checker.sh index 82edb786c..62b96fd2f 100755 --- a/share/github-backup-utils/ghe-rsync-feature-checker.sh +++ b/share/github-backup-utils/ghe-rsync-feature-checker.sh @@ -12,9 +12,6 @@ rsync_command="$1" # strip - and -- from the passed rsync command rsync_command="${rsync_command/-/}" && rsync_command="${rsync_command/-/}" - -echo "rsync_command: $rsync_command" - # check if the passed rsync command is supported by the current version of rsync if rsync -h | grep -E "\b$rsync_command\b" >/dev/null 2>&1; then echo "true" From d416dab0c2248258438a9453f5062c4322d3b38a Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 15:09:13 -0400 Subject: [PATCH 1846/2421] Updating files permissions - Changing test-ghe-rsync-feature-checker.sh from 644 to 755 --- test/test-ghe-rsync-feature-checker.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/test-ghe-rsync-feature-checker.sh diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh old mode 100644 new mode 100755 From ec78a202956189fa008e3a07005f5753b33c86a6 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 15:21:58 -0400 Subject: [PATCH 1847/2421] Fixing shellcheck errors --- test/test-ghe-rsync-feature-checker.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index 3a5fafd2b..70f267929 100755 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -6,7 +6,7 @@ TESTS_DIR="$PWD/$(dirname "$0")" # shellcheck source=test/testlib.sh . "$TESTS_DIR/testlib.sh" -begin_test "ghe-rsync-feature-checker for know command `--help`" +begin_test "ghe-rsync-feature-checker for know command --help" ( set -e @@ -15,7 +15,7 @@ begin_test "ghe-rsync-feature-checker for know command `--help`" ) end_test -begin_test "ghe-rsync-feature-checker for know command `help`" +begin_test "ghe-rsync-feature-checker for know command help" ( set -e @@ -24,7 +24,7 @@ begin_test "ghe-rsync-feature-checker for know command `help`" ) end_test -begin_test "ghe-rsync-feature-checker for known unsupported command `--ignore-missing-args`" +begin_test "ghe-rsync-feature-checker for known unsupported command --ignore-missing-args" ( set -e @@ -33,7 +33,7 @@ begin_test "ghe-rsync-feature-checker for known unsupported command `--ignore-mi ) end_test -begin_test "ghe-rsync-feature-checker for known unsupported command `ignore-missing-args`" +begin_test "ghe-rsync-feature-checker for known unsupported command ignore-missing-args" ( set -e From 654501306a089e222a4d75bead36d612b9077916 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Wed, 3 May 2023 15:49:27 -0400 Subject: [PATCH 1848/2421] Adding disable for shellcheck SC2046 --- share/github-backup-utils/ghe-rsync | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index 4166295be..b7c884c4d 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -22,14 +22,17 @@ fi # This prepends `--trust-sender` to the parameters if supported by the current version of rsync to mitigate the degradation of performance due to the resolution of CVE-2022-29154 # shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker.sh +# shellcheck disable=SC2046 if [ "$($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh --trust-sender)" == "true" ]; then parameters=("--trust-sender" "${parameters[@]}") fi # This loads the $GHE_EXTRA_RSYNC_OPTS from the config file if available then adds them to the parameters and skip adding if already present in the parameters +# shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker.sh +# shellcheck disable=SC2046 if [ -n "$GHE_EXTRA_RSYNC_OPTS" ]; then for extra_opt in $GHE_EXTRA_RSYNC_OPTS; do - if [ $($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh "$extra_opt") == "true" ]; then + if [ "$($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh "$extra_opt")" == "true" ]; then parameters+=("$extra_opt") fi done From 93e19c25205a228a6e5bc8b8315ef61800d8ff1c Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Thu, 4 May 2023 09:48:40 -0400 Subject: [PATCH 1849/2421] fixed issue with tests - Was missing `.sh` in the `ghe-rsync-feature-checker calls` --- test/test-ghe-rsync-feature-checker.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index 70f267929..9ccbff2e4 100755 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -1,43 +1,43 @@ #!/usr/bin/env bash -# ghe-rsync-feature-checker command tests +# ghe-rsync-feature-checker.sh command tests TESTS_DIR="$PWD/$(dirname "$0")" # Bring in testlib. # shellcheck source=test/testlib.sh . "$TESTS_DIR/testlib.sh" -begin_test "ghe-rsync-feature-checker for know command --help" +begin_test "ghe-rsync-feature-checker.sh for know command --help" ( set -e - # Test ghe-rsync-feature-checker command - ghe-rsync-feature-checker "--help" | grep -q "true" + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh --help | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker for know command help" +begin_test "ghe-rsync-feature-checker.sh for know command help" ( set -e - # Test ghe-rsync-feature-checker command - ghe-rsync-feature-checker "help" | grep -q "true" + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh "help" | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker for known unsupported command --ignore-missing-args" +begin_test "ghe-rsync-feature-checker.sh for known unsupported command --ignore-missing-args" ( set -e - # Test ghe-rsync-feature-checker command - ghe-rsync-feature-checker "--ignore-missing-args" | grep -q "false" + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh "--ignore-missing-args" | grep -q "false" ) end_test -begin_test "ghe-rsync-feature-checker for known unsupported command ignore-missing-args" +begin_test "ghe-rsync-feature-checker.sh for known unsupported command ignore-missing-args" ( set -e - # Test ghe-rsync-feature-checker command - ghe-rsync-feature-checker "ignore-missing-args" | grep -q "false" + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh "ignore-missing-args" | grep -q "false" ) end_test \ No newline at end of file From 5f18af6d394c234440777b1ea6f6a90b9f90ffc9 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Thu, 4 May 2023 13:46:21 -0400 Subject: [PATCH 1850/2421] Fixed bugs with feature checker and tests - Changed the command to remove leading dashes to `sed -E 's/^-+//'` - Change the grep for rsync command to `\B-+($rsync_command)\b` - Updated the tests to test more flags - v - verbose - partial - not-an-actual-feature --- .../ghe-rsync-feature-checker.sh | 9 +- test/test-ghe-rsync-feature-checker.sh | 83 +++++++++++++++++-- 2 files changed, 78 insertions(+), 14 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync-feature-checker.sh b/share/github-backup-utils/ghe-rsync-feature-checker.sh index 62b96fd2f..0fc222911 100755 --- a/share/github-backup-utils/ghe-rsync-feature-checker.sh +++ b/share/github-backup-utils/ghe-rsync-feature-checker.sh @@ -6,14 +6,13 @@ set -o pipefail -# set the variable from the first argument -rsync_command="$1" +# set the variable from the first argument and remove any leading dashes +rsync_command=$(echo "$1" | sed -E 's/^-+//') -# strip - and -- from the passed rsync command -rsync_command="${rsync_command/-/}" && rsync_command="${rsync_command/-/}" +echo "rsync_command: $rsync_command" # check if the passed rsync command is supported by the current version of rsync -if rsync -h | grep -E "\b$rsync_command\b" >/dev/null 2>&1; then +if rsync -h | grep -E "\B-+($rsync_command)\b" >/dev/null 2>&1; then echo "true" else echo "false" diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index 9ccbff2e4..83864b275 100755 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -6,7 +6,9 @@ TESTS_DIR="$PWD/$(dirname "$0")" # shellcheck source=test/testlib.sh . "$TESTS_DIR/testlib.sh" -begin_test "ghe-rsync-feature-checker.sh for know command --help" +## testing for known supported command help with and without leading dashes + +begin_test "ghe-rsync-feature-checker.sh for know command --help" ( set -e @@ -15,29 +17,92 @@ begin_test "ghe-rsync-feature-checker.sh for know command --help" ) end_test -begin_test "ghe-rsync-feature-checker.sh for know command help" +begin_test "ghe-rsync-feature-checker.sh for know command help" ( set -e # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh "help" | grep -q "true" + ghe-rsync-feature-checker.sh help | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker.sh for known unsupported command --ignore-missing-args" +## testing for known unsupported command not-an-actual-feature with and without leading dashes + +begin_test "ghe-rsync-feature-checker.sh for known unsupported command --not-an-actual-feature" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh "--ignore-missing-args" | grep -q "false" + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh --not-an-actual-feature | grep -q "false" + ) end_test -begin_test "ghe-rsync-feature-checker.sh for known unsupported command ignore-missing-args" +begin_test "ghe-rsync-feature-checker.sh for known unsupported command not-an-actual-feature" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh "ignore-missing-args" | grep -q "false" + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh not-an-actual-feature | grep -q "false" +) +end_test + +## testing for known supported command partial with and without leading dashes + +begin_test "ghe-rsync-feature-checker.sh for know command --partial" +( + set -e + + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh --partial | grep -q "true" +) +end_test + +begin_test "ghe-rsync-feature-checker.sh for know command partial" +( + set -e + + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh partial | grep -q "true" +) +end_test + +## testing for known supported command -v with and without leading dashes + +begin_test "ghe-rsync-feature-checker.sh for know command -v" +( + set -e + + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh -v | grep -q "true" +) +end_test + +begin_test "ghe-rsync-feature-checker.sh for know command -v" +( + set -e + + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh v | grep -q "true" +) +end_test + +## testing for known supported command --verbose with and without leading dashes + +begin_test "ghe-rsync-feature-checker.sh for know command --verbose" +( + set -e + + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh --verbose | grep -q "true" +) +end_test + +begin_test "ghe-rsync-feature-checker.sh for know command verbose" +( + set -e + + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh verbose | grep -q "true" ) end_test \ No newline at end of file From e3cc4d6999cd0be1a9e8297283c9791c11e92a57 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Thu, 4 May 2023 13:46:46 -0400 Subject: [PATCH 1851/2421] Removed debug command from testing feature checker --- share/github-backup-utils/ghe-rsync-feature-checker.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync-feature-checker.sh b/share/github-backup-utils/ghe-rsync-feature-checker.sh index 0fc222911..2ce7cdd61 100755 --- a/share/github-backup-utils/ghe-rsync-feature-checker.sh +++ b/share/github-backup-utils/ghe-rsync-feature-checker.sh @@ -9,8 +9,6 @@ set -o pipefail # set the variable from the first argument and remove any leading dashes rsync_command=$(echo "$1" | sed -E 's/^-+//') -echo "rsync_command: $rsync_command" - # check if the passed rsync command is supported by the current version of rsync if rsync -h | grep -E "\B-+($rsync_command)\b" >/dev/null 2>&1; then echo "true" From 6fdb5a85192938df54480189f596186fa4f5e7e3 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Thu, 4 May 2023 14:01:13 -0400 Subject: [PATCH 1852/2421] Adding back test for `ignore-missing-args` --- test/test-ghe-rsync-feature-checker.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index 83864b275..10a197080 100755 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -105,4 +105,24 @@ begin_test "ghe-rsync-feature-checker.sh for know command verbose" # Test ghe-rsync-feature-checker.sh command ghe-rsync-feature-checker.sh verbose | grep -q "true" ) +end_test + +## testing for known supported command ignore-missing-args with and without leading dashes + +begin_test "ghe-rsync-feature-checker.sh for known supported command --ignore-missing-args" +( + set -e + + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh "--ignore-missing-args" | grep -q "true" +) +end_test + +begin_test "ghe-rsync-feature-checker.sh for known supported command ignore-missing-args" +( + set -e + + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh "ignore-missing-args" | grep -q "true" +) end_test \ No newline at end of file From a99d32752e165477aa114c80229865f2ad957b3b Mon Sep 17 00:00:00 2001 From: Diana Date: Thu, 4 May 2023 14:14:14 -0400 Subject: [PATCH 1853/2421] Updating test-ghe-rsync-feature-checker.sh - Updated formatting - Updated verbiage --- test/test-ghe-rsync-feature-checker.sh | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index 10a197080..de4ee2e75 100755 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# ghe-rsync-feature-checker.sh command tests +# ghe-rsync-feature-checker.sh command tests TESTS_DIR="$PWD/$(dirname "$0")" # Bring in testlib. @@ -8,20 +8,20 @@ TESTS_DIR="$PWD/$(dirname "$0")" ## testing for known supported command help with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for know command --help" +begin_test "ghe-rsync-feature-checker.sh for known supported command --help" ( - set -e + set -e - # Test ghe-rsync-feature-checker.sh command + # Test ghe-rsync-feature-checker.sh command ghe-rsync-feature-checker.sh --help | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker.sh for know command help" +begin_test "ghe-rsync-feature-checker.sh for known supported command help" ( set -e - # Test ghe-rsync-feature-checker.sh command + # Test ghe-rsync-feature-checker.sh command ghe-rsync-feature-checker.sh help | grep -q "true" ) end_test @@ -49,7 +49,7 @@ end_test ## testing for known supported command partial with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for know command --partial" +begin_test "ghe-rsync-feature-checker.sh for known supported command --partial" ( set -e @@ -58,7 +58,7 @@ begin_test "ghe-rsync-feature-checker.sh for know command --partial" ) end_test -begin_test "ghe-rsync-feature-checker.sh for know command partial" +begin_test "ghe-rsync-feature-checker.sh for known supported command partial" ( set -e @@ -69,7 +69,7 @@ end_test ## testing for known supported command -v with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for know command -v" +begin_test "ghe-rsync-feature-checker.sh for known supported command -v" ( set -e @@ -78,7 +78,7 @@ begin_test "ghe-rsync-feature-checker.sh for know command -v" ) end_test -begin_test "ghe-rsync-feature-checker.sh for know command -v" +begin_test "ghe-rsync-feature-checker.sh for known supported command v" ( set -e @@ -89,7 +89,7 @@ end_test ## testing for known supported command --verbose with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for know command --verbose" +begin_test "ghe-rsync-feature-checker.sh for known supported command --verbose" ( set -e @@ -98,7 +98,7 @@ begin_test "ghe-rsync-feature-checker.sh for know command --verbose" ) end_test -begin_test "ghe-rsync-feature-checker.sh for know command verbose" +begin_test "ghe-rsync-feature-checker.sh for known supported command verbose" ( set -e @@ -109,20 +109,20 @@ end_test ## testing for known supported command ignore-missing-args with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for known supported command --ignore-missing-args" +begin_test "ghe-rsync-feature-checker.sh for known supported command --ignore-missing-args" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh "--ignore-missing-args" | grep -q "true" + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh "--ignore-missing-args" | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker.sh for known supported command ignore-missing-args" +begin_test "ghe-rsync-feature-checker.sh for known supported command ignore-missing-args" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh "ignore-missing-args" | grep -q "true" + # Test ghe-rsync-feature-checker.sh command + ghe-rsync-feature-checker.sh "ignore-missing-args" | grep -q "true" ) -end_test \ No newline at end of file +end_test From 8f8f4aaed758356ea85ad3bcadca706bce5da4c4 Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 4 May 2023 15:04:25 -0700 Subject: [PATCH 1854/2421] Add test for host info output --- test/test-ghe-backup.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 0fc3a125a..897213d4a 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -734,3 +734,16 @@ begin_test "ghe-backup fix_paths_for_ghe_version newer/older" done ) end_test + +# Check that information on system where backup-utils is installed is collected +begin_test "ghe-backup collects information on system where backup-utils is installed" +( + set -e + + output=$(ghe-backup) + echo "$output" | grep "Running on: $(cat /etc/issue.net)" + echo "$output" | grep "CPUs: $(nproc)" + echo "$output" | grep "Memory total/used/free+share/buff/cache:" + +) +end_test From 0b14b01171574459dd744d991cb5246ce219d67e Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 4 May 2023 15:05:50 -0700 Subject: [PATCH 1855/2421] Update ghe-backup with host info gathering --- bin/ghe-backup | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index 5696e9856..c44b2d6fc 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -155,6 +155,30 @@ if [ -n "$GHE_ALLOW_REPLICA_BACKUP" ]; then echo "Warning: backing up a high availability replica may result in inconsistent or unreliable backups." fi +# Output system information of the backup host + +# If /etc/issue.net exists, use it to get the OS version +if [ -f /etc/issue.net ]; then + echo "Running on: $(cat /etc/issue.net)" +else + echo "Running on: Unknown OS" +fi + +# If nproc command exists, use it to get the number of CPUs +if command -v nproc >/dev/null 2>&1; then + echo "CPUs: $(nproc)" +else + echo "CPUs: Unknown" +fi + +# If the free command exists, use it to get the memory details +if command -v free >/dev/null 2>&1; then + echo "Memory $(free -m | grep '^Mem:' | awk '{print "total/used/free+share/buff/cache: " $2 "/" $3 "/" $4 "+" $5 "/" $6 "/" $7}')" +else + echo "Memory: Unknown" +fi + + # Log backup start message in /var/log/syslog on remote instance ghe_remote_logger "Starting backup from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP ..." From 30e7db55ae32065c7f37a949ad62c638603b2846 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Fri, 5 May 2023 09:20:16 -0400 Subject: [PATCH 1856/2421] Normalizing file names and extensions & Updates - Updating naming and formatting - Normalizing testing naming - Added reasoning for not testing parameters with feature checker --- bin/ghe-host-check | 4 +- share/github-backup-utils/ghe-rsync | 15 ++-- ...e-checker.sh => ghe-rsync-feature-checker} | 0 .../{ghe-rsync-size.sh => ghe-rsync-size} | 0 test/test-ghe-rsync-feature-checker.sh | 84 +++++++++---------- 5 files changed, 53 insertions(+), 50 deletions(-) rename share/github-backup-utils/{ghe-rsync-feature-checker.sh => ghe-rsync-feature-checker} (100%) rename share/github-backup-utils/{ghe-rsync-size.sh => ghe-rsync-size} (100%) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index d9679386a..6a2a66357 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -153,8 +153,8 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/requirements.txt" #source disk size file - # shellcheck source=share/github-backup-utils/ghe-rsync-size.sh - . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size.sh" + # shellcheck source=share/github-backup-utils/ghe-rsync-size + . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size" #Display dir requirements for repositories and mysql echo "Checking host for sufficient space for a backup..." 1>&2 diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index b7c884c4d..d957068ac 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -11,6 +11,7 @@ set -o pipefail # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" +# Don't use the feature checker for expected parameters as it can cause issues with server paths # Check for --ignore-missing-args parameter support and remove if unavailable. if rsync -h | grep '\-\-ignore-missing-args' >/dev/null 2>&1; then parameters=("$@") @@ -20,19 +21,21 @@ else done fi -# This prepends `--trust-sender` to the parameters if supported by the current version of rsync to mitigate the degradation of performance due to the resolution of CVE-2022-29154 -# shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker.sh +# This prepends `--trust-sender` to the parameters if supported by the current version of rsync +# to mitigate the degradation of performance due to the resolution of CVE-2022-29154 +# shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker # shellcheck disable=SC2046 -if [ "$($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh --trust-sender)" == "true" ]; then +if [ "$($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker --trust-sender)" == "true" ]; then parameters=("--trust-sender" "${parameters[@]}") fi -# This loads the $GHE_EXTRA_RSYNC_OPTS from the config file if available then adds them to the parameters and skip adding if already present in the parameters -# shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker.sh +# This loads the $GHE_EXTRA_RSYNC_OPTS from the config file if available then adds them +# to the parameters and skip adding if already present in the parameters +# shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker # shellcheck disable=SC2046 if [ -n "$GHE_EXTRA_RSYNC_OPTS" ]; then for extra_opt in $GHE_EXTRA_RSYNC_OPTS; do - if [ "$($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker.sh "$extra_opt")" == "true" ]; then + if [ "$($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker "$extra_opt")" == "true" ]; then parameters+=("$extra_opt") fi done diff --git a/share/github-backup-utils/ghe-rsync-feature-checker.sh b/share/github-backup-utils/ghe-rsync-feature-checker similarity index 100% rename from share/github-backup-utils/ghe-rsync-feature-checker.sh rename to share/github-backup-utils/ghe-rsync-feature-checker diff --git a/share/github-backup-utils/ghe-rsync-size.sh b/share/github-backup-utils/ghe-rsync-size similarity index 100% rename from share/github-backup-utils/ghe-rsync-size.sh rename to share/github-backup-utils/ghe-rsync-size diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index de4ee2e75..44ea3aeab 100755 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# ghe-rsync-feature-checker.sh command tests +# ghe-rsync-feature-checker command tests TESTS_DIR="$PWD/$(dirname "$0")" # Bring in testlib. @@ -8,121 +8,121 @@ TESTS_DIR="$PWD/$(dirname "$0")" ## testing for known supported command help with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for known supported command --help" +begin_test "Testing ghe-rsync-feature-checker for known supported command --help" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh --help | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker --help | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker.sh for known supported command help" +begin_test "Testing ghe-rsync-feature-checker with known supported command help" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh help | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker help | grep -q "true" ) end_test -## testing for known unsupported command not-an-actual-feature with and without leading dashes +## testing with known unsupported command not-an-actual-feature with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for known unsupported command --not-an-actual-feature" +begin_test "Testing ghe-rsync-feature-checker with known unsupported command --not-an-actual-feature" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh --not-an-actual-feature | grep -q "false" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker --not-an-actual-feature | grep -q "false" ) end_test -begin_test "ghe-rsync-feature-checker.sh for known unsupported command not-an-actual-feature" +begin_test "Testing ghe-rsync-feature-checker with known unsupported command not-an-actual-feature" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh not-an-actual-feature | grep -q "false" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker not-an-actual-feature | grep -q "false" ) end_test -## testing for known supported command partial with and without leading dashes +## testing with known supported command partial with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for known supported command --partial" +begin_test "Testing ghe-rsync-feature-checker with known supported command --partial" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh --partial | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker --partial | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker.sh for known supported command partial" +begin_test "Testing ghe-rsync-feature-checker with known supported command partial" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh partial | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker partial | grep -q "true" ) end_test -## testing for known supported command -v with and without leading dashes +## testing with known supported command -v with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for known supported command -v" +begin_test "Testing ghe-rsync-feature-checker with known supported command -v" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh -v | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker -v | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker.sh for known supported command v" +begin_test "Testing ghe-rsync-feature-checker with known supported command v" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh v | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker v | grep -q "true" ) end_test -## testing for known supported command --verbose with and without leading dashes +## testing with known supported command --verbose with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for known supported command --verbose" +begin_test "Testing ghe-rsync-feature-checker with known supported command --verbose" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh --verbose | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker --verbose | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker.sh for known supported command verbose" +begin_test "Testing ghe-rsync-feature-checker with known supported command verbose" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh verbose | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker verbose | grep -q "true" ) end_test -## testing for known supported command ignore-missing-args with and without leading dashes +## testing with known supported command ignore-missing-args with and without leading dashes -begin_test "ghe-rsync-feature-checker.sh for known supported command --ignore-missing-args" +begin_test "Testing ghe-rsync-feature-checker with known supported command --ignore-missing-args" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh "--ignore-missing-args" | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker "--ignore-missing-args" | grep -q "true" ) end_test -begin_test "ghe-rsync-feature-checker.sh for known supported command ignore-missing-args" +begin_test "Testing ghe-rsync-feature-checker with known supported command ignore-missing-args" ( set -e - # Test ghe-rsync-feature-checker.sh command - ghe-rsync-feature-checker.sh "ignore-missing-args" | grep -q "true" + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker "ignore-missing-args" | grep -q "true" ) end_test From 9e95cfd6c586712b55832ee34059197b668bef82 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Fri, 5 May 2023 11:32:08 -0400 Subject: [PATCH 1857/2421] Simplified language Reverted the minimum requirement back to 2.6.4 and also made it clear for which versions of rsync a customer may run into problems with their backup host. --- docs/requirements.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/requirements.md b/docs/requirements.md index 8f57decab..2161bbed4 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,7 +5,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v3.2.5 or newer, and [jq][11] v1.5 or newer. See below for an update on rsync. +Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), and [jq][11] v1.5 or newer. See below for an update on rsync. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. @@ -13,15 +13,17 @@ We encourage the use of [Docker](docker.md), as it ensures compatible versions o The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. -### Update April 2023 - rsync requirements +### April 2023 Update of Rsync Requirements -We have updated the minimum required version of rsync from `2.6.4` to `3.2.5`. This change was required due to the [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) causing _severe_ performance degradation to `backup-utils`. The only way to avoid this degradation is to use the `--trust-sender` flag, and since this flag is only available from rsync v3.2.5 onwards, we have updated the minimum required version of rsync. +The [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) can cause severe performance degradation to `backup-utils`. -Unfortunately the situation is a little more complicated. If you are running an older version of rsync (i.e. < v3.2.5) you _might_ be ok. +If you encounter this degradation you can mitigate it by using the `--trust-sender` flag, which is available in rsync >= v3.2.5. -It depends on whether the rsync package you are using on your backup host has backported the fix for CVE-2022-29154 without backporting the `--trust-sender` flag. +If your backup host is running rsync < v3.2.5 you may or may not need to make changes to you rsync package, depending on whether your rsync package has backported the fix for CVE-2022-29154 without also backporting the `--trust-sender` flag. -If your backup host is running an rsync package that has backported the CVE fix without backporting the `--trust-sender` flag then you have three options: +If your rsync package has backported the CVE fix _and_ the `--trust-sender` flag then you don't need to change anything. + +However, if your rsync package has backported the CVE fix without backporting the `--trust-sender` flag then you have three options: 1. Downgrade (using the package manager on your host) the rsync package to a version before the CVE fix was backported 2. Upgrade (using the package manager on your host) the rsync package to v3.2.5 or newer From 27d227279cc70c9f40c3e404524a53480b1b26e8 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Fri, 5 May 2023 11:32:48 -0400 Subject: [PATCH 1858/2421] Reverting min version of rsync to 2.6.4 I will update the description of my PR to explain why I made this change. --- share/github-backup-utils/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/requirements.txt b/share/github-backup-utils/requirements.txt index 2ad762c0e..acf767129 100644 --- a/share/github-backup-utils/requirements.txt +++ b/share/github-backup-utils/requirements.txt @@ -1,3 +1,3 @@ -min_rsync=3.2.5 +min_rsync=2.6.4 min_openssh=5.6 min_jq=1.5 From f5071c749d174e5a7251767692ea3a30c793a2ad Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Fri, 5 May 2023 15:20:20 -0400 Subject: [PATCH 1859/2421] Bug fix with feature checker - This would allow -help to work even though it's not a valid command --- .../ghe-rsync-feature-checker | 42 ++++++++++++++++--- test/test-ghe-rsync-feature-checker.sh | 37 ++++++++++++++++ 2 files changed, 73 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync-feature-checker b/share/github-backup-utils/ghe-rsync-feature-checker index 2ce7cdd61..afc86f1c1 100755 --- a/share/github-backup-utils/ghe-rsync-feature-checker +++ b/share/github-backup-utils/ghe-rsync-feature-checker @@ -7,11 +7,41 @@ set -o pipefail # set the variable from the first argument and remove any leading dashes -rsync_command=$(echo "$1" | sed -E 's/^-+//') +rsync_command=$1 -# check if the passed rsync command is supported by the current version of rsync -if rsync -h | grep -E "\B-+($rsync_command)\b" >/dev/null 2>&1; then - echo "true" +# extract dashes if present into variable +leading_dashes=$(echo "$rsync_command" | grep -oE "^-+") + +# this normalizes the passed command by removing any leading dashes +normalized_command=$(echo "$rsync_command" | sed -E "s/^-+//") + +# this checks the rsync command and returns the found command if it is valid +found_command=$(rsync -h | grep -oE "\B-+($normalized_command)\b" | head -n "1") + +# this is the normalized found command +normalized_found_command=$(echo "$found_command" | sed -E "s/^-+//") + +## Check if $leading_dashes is either - or -- +if [ "$leading_dashes" == "-" ]; then + # check if the passed rsync command is valid and supported or if the normalized command is valid and supported + if [ "$rsync_command" == "$found_command" ]; then + echo "true" + else + echo "false" + fi +elif [ "$leading_dashes" == "--" ]; then + # check if the passed rsync command is valid and supported or if the normalized command is valid and supported + if [ "$rsync_command" == "$found_command" ]; then + echo "true" + else + echo "false" + fi else - echo "false" -fi \ No newline at end of file + # check if the passed rsync command is valid and supported or if the normalized command is valid and supported + if [ "$rsync_command" == "$normalized_found_command" ]; then + echo "true" + else + echo "false" + fi +fi + diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index 44ea3aeab..6b4fc862e 100755 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -17,6 +17,18 @@ begin_test "Testing ghe-rsync-feature-checker for known supported command --help ) end_test +<<<<<<< Updated upstream +======= +begin_test "Testing ghe-rsync-feature-checker for known supported command -help" +( + set -e + + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker -help | grep -q "false" +) +end_test + +>>>>>>> Stashed changes begin_test "Testing ghe-rsync-feature-checker with known supported command help" ( set -e @@ -38,6 +50,19 @@ begin_test "Testing ghe-rsync-feature-checker with known unsupported command --n ) end_test +<<<<<<< Updated upstream +======= +begin_test "Testing ghe-rsync-feature-checker with known unsupported command -not-an-actual-feature" +( + set -e + + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker -not-an-actual-feature | grep -q "false" + +) +end_test + +>>>>>>> Stashed changes begin_test "Testing ghe-rsync-feature-checker with known unsupported command not-an-actual-feature" ( set -e @@ -98,6 +123,18 @@ begin_test "Testing ghe-rsync-feature-checker with known supported command --ver ) end_test +<<<<<<< Updated upstream +======= +begin_test "Testing ghe-rsync-feature-checker with known supported command -verbose" +( + set -e + + # Test ghe-rsync-feature-checker command + ghe-rsync-feature-checker -verbose | grep -q "false" +) +end_test + +>>>>>>> Stashed changes begin_test "Testing ghe-rsync-feature-checker with known supported command verbose" ( set -e From 34b99614f6d5e30205870a9e90c04ca9ad314ced Mon Sep 17 00:00:00 2001 From: Diana Date: Fri, 5 May 2023 15:36:56 -0400 Subject: [PATCH 1860/2421] Removed conflict markers from test file --- test/test-ghe-rsync-feature-checker.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index 6b4fc862e..2051e59e3 100755 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -17,8 +17,6 @@ begin_test "Testing ghe-rsync-feature-checker for known supported command --help ) end_test -<<<<<<< Updated upstream -======= begin_test "Testing ghe-rsync-feature-checker for known supported command -help" ( set -e @@ -28,7 +26,6 @@ begin_test "Testing ghe-rsync-feature-checker for known supported command -help" ) end_test ->>>>>>> Stashed changes begin_test "Testing ghe-rsync-feature-checker with known supported command help" ( set -e @@ -50,8 +47,6 @@ begin_test "Testing ghe-rsync-feature-checker with known unsupported command --n ) end_test -<<<<<<< Updated upstream -======= begin_test "Testing ghe-rsync-feature-checker with known unsupported command -not-an-actual-feature" ( set -e @@ -62,7 +57,6 @@ begin_test "Testing ghe-rsync-feature-checker with known unsupported command -no ) end_test ->>>>>>> Stashed changes begin_test "Testing ghe-rsync-feature-checker with known unsupported command not-an-actual-feature" ( set -e @@ -123,8 +117,6 @@ begin_test "Testing ghe-rsync-feature-checker with known supported command --ver ) end_test -<<<<<<< Updated upstream -======= begin_test "Testing ghe-rsync-feature-checker with known supported command -verbose" ( set -e @@ -134,7 +126,6 @@ begin_test "Testing ghe-rsync-feature-checker with known supported command -verb ) end_test ->>>>>>> Stashed changes begin_test "Testing ghe-rsync-feature-checker with known supported command verbose" ( set -e From 80a3f33946ccd65cf690b513d74725c38eda71a0 Mon Sep 17 00:00:00 2001 From: Diana Date: Fri, 5 May 2023 15:48:10 -0400 Subject: [PATCH 1861/2421] Update test-ghe-rsync-feature-checker.sh - Fixed tests names --- test/test-ghe-rsync-feature-checker.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test-ghe-rsync-feature-checker.sh b/test/test-ghe-rsync-feature-checker.sh index 2051e59e3..16a18f815 100755 --- a/test/test-ghe-rsync-feature-checker.sh +++ b/test/test-ghe-rsync-feature-checker.sh @@ -8,7 +8,7 @@ TESTS_DIR="$PWD/$(dirname "$0")" ## testing for known supported command help with and without leading dashes -begin_test "Testing ghe-rsync-feature-checker for known supported command --help" +begin_test "Testing ghe-rsync-feature-checker with known supported command --help" ( set -e @@ -17,7 +17,7 @@ begin_test "Testing ghe-rsync-feature-checker for known supported command --help ) end_test -begin_test "Testing ghe-rsync-feature-checker for known supported command -help" +begin_test "Testing ghe-rsync-feature-checker with known unsupported command -help" ( set -e @@ -117,7 +117,7 @@ begin_test "Testing ghe-rsync-feature-checker with known supported command --ver ) end_test -begin_test "Testing ghe-rsync-feature-checker with known supported command -verbose" +begin_test "Testing ghe-rsync-feature-checker with known unsupported command -verbose" ( set -e From 12cebe598659c63524d5fbd08d74f01fc02cfe53 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 11:41:41 +0200 Subject: [PATCH 1862/2421] Add version and size to restore --- .github/workflows/restore.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 24f1aa061..2f961ddd3 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -26,6 +26,16 @@ on: description: 'Hostname of the server' required: true type: string + size: + description: 'Size of the dataset to restore (small/medium)' + required: false + default: 'small' + type: string + version: + description: 'Version of the dataset to restore (3.8/3.9)' + required: false + default: '3.8' + type: string ref: description: 'Branch ref to use' required: false @@ -69,8 +79,8 @@ jobs: az storage blob download \ --account-name ghesresults \ --container-name ghes-data \ - --name v3.8-small-docs.tar.gz \ - --file ghes-data/3.8-small-docs.tar.gz \ + --name v{{ inputs.version }}-{{ inputs.size }}.tar.gz \ + --file ghes-data/{{ inputs.version }}-{{ inputs.size }}.tar.gz \ --connection-string "${{ secrets.CONNECTIONSTRING }}" - name: Unzip backup and setup symlink @@ -78,7 +88,7 @@ jobs: mkdir "$HOME/ghe-backup-data" dir_name=$(date +%s) mkdir "$HOME/ghe-backup-data/$dir_name" - tar -xvf "ghes-data/3.8-small-docs.tar.gz" -C "$HOME/ghe-backup-data/$dir_name" + tar -xvf "ghes-data/{{ inputs.version }}-{{ inputs.size }}.tar.gz" -C "$HOME/ghe-backup-data/$dir_name" ln -s "$dir_name" "$HOME/ghe-backup-data/current" @@ -89,7 +99,7 @@ jobs: run: chmod 0600 "$HOME/backup" - name: change version - run: echo "3.8.0" > "$HOME/version" + run: echo "{{ inputs.version }}.0" > "$HOME/version" - name: Prepare for restore run: ssh -p122 -i "$HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" From fb3a4cd376c21c84de45d43031fa3417a77b097b Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 11:57:45 +0200 Subject: [PATCH 1863/2421] Change filename --- .github/workflows/restore.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 2f961ddd3..f83d45c32 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -76,11 +76,12 @@ jobs: - name: Download from blob storage run: | mkdir ghes-data + filename="v{{ inputs.version }}-{{ inputs.size }}.tar.gz" az storage blob download \ --account-name ghesresults \ --container-name ghes-data \ - --name v{{ inputs.version }}-{{ inputs.size }}.tar.gz \ - --file ghes-data/{{ inputs.version }}-{{ inputs.size }}.tar.gz \ + --name "$filename" \ + --file "ghes-data/$filename" \ --connection-string "${{ secrets.CONNECTIONSTRING }}" - name: Unzip backup and setup symlink @@ -88,7 +89,8 @@ jobs: mkdir "$HOME/ghe-backup-data" dir_name=$(date +%s) mkdir "$HOME/ghe-backup-data/$dir_name" - tar -xvf "ghes-data/{{ inputs.version }}-{{ inputs.size }}.tar.gz" -C "$HOME/ghe-backup-data/$dir_name" + filename="v{{ inputs.version }}-{{ inputs.size }}.tar.gz" + tar -xvf "ghes-data/$filename" -C "$HOME/ghe-backup-data/$dir_name" ln -s "$dir_name" "$HOME/ghe-backup-data/current" From 0e3ee76e79294f6779ef41541a48e072df2f8dae Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 12:21:53 +0200 Subject: [PATCH 1864/2421] Get filename --- .github/workflows/restore.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index f83d45c32..67dbfaecf 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -73,10 +73,26 @@ jobs: - name: Load docker container run: docker load -i backup-utils.tar + - name: Find backup file version + id: file + run: | + file_version="{{ inputs.version }}" + V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10" + + echo "$V3_8_COMPATIBLE" | tr " " '\n' | grep -F -q -x "{{ inputs.version }}" + + if [ $? -eq 0 ]; then + echo "Version $version is acceptable" + echo "version=3.8" >> $GITHUB_OUTPUT + else + echo "Version $version is not acceptable" + exit 1 + fi + - name: Download from blob storage run: | mkdir ghes-data - filename="v{{ inputs.version }}-{{ inputs.size }}.tar.gz" + filename="v{{ steps.file.outputs.version }}-{{ inputs.size }}.tar.gz" az storage blob download \ --account-name ghesresults \ --container-name ghes-data \ @@ -89,7 +105,8 @@ jobs: mkdir "$HOME/ghe-backup-data" dir_name=$(date +%s) mkdir "$HOME/ghe-backup-data/$dir_name" - filename="v{{ inputs.version }}-{{ inputs.size }}.tar.gz" + + filename="v{{ steps.file.outputs.version }}-{{ inputs.size }}.tar.gz" tar -xvf "ghes-data/$filename" -C "$HOME/ghe-backup-data/$dir_name" ln -s "$dir_name" "$HOME/ghe-backup-data/current" From 16e659f9900192e70492b275f4a80c503a8af671 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 12:38:02 +0200 Subject: [PATCH 1865/2421] Get filename --- .github/workflows/restore.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 67dbfaecf..bb4459942 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -79,13 +79,13 @@ jobs: file_version="{{ inputs.version }}" V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10" - echo "$V3_8_COMPATIBLE" | tr " " '\n' | grep -F -q -x "{{ inputs.version }}" + echo "$V3_8_COMPATIBLE" | tr " " '\n' | grep -F -q -x "$file_version" if [ $? -eq 0 ]; then - echo "Version $version is acceptable" + echo "Version $file_version is acceptable" echo "version=3.8" >> $GITHUB_OUTPUT else - echo "Version $version is not acceptable" + echo "Version $file_version is not acceptable" exit 1 fi From 05889fbcb1009cab54f1d0c7fd5244bbe347ef01 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 12:43:48 +0200 Subject: [PATCH 1866/2421] add debugging --- .github/workflows/restore.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index bb4459942..c3040a128 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -77,6 +77,7 @@ jobs: id: file run: | file_version="{{ inputs.version }}" + echo "$file_version" V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10" echo "$V3_8_COMPATIBLE" | tr " " '\n' | grep -F -q -x "$file_version" From 2e27160bffc5003a5d7d16f7b473556744f9b8db Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 12:50:45 +0200 Subject: [PATCH 1867/2421] More debugging --- .github/workflows/restore.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index c3040a128..607ce2ddc 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -76,7 +76,8 @@ jobs: - name: Find backup file version id: file run: | - file_version="{{ inputs.version }}" + file_version={{ inputs.version }} + size={{ inputs.size }}} echo "$file_version" V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10" @@ -85,6 +86,7 @@ jobs: if [ $? -eq 0 ]; then echo "Version $file_version is acceptable" echo "version=3.8" >> $GITHUB_OUTPUT + echo "name=v$version-$size.tar.gz" >> $GITHUB_OUTPUT else echo "Version $file_version is not acceptable" exit 1 @@ -93,12 +95,11 @@ jobs: - name: Download from blob storage run: | mkdir ghes-data - filename="v{{ steps.file.outputs.version }}-{{ inputs.size }}.tar.gz" az storage blob download \ --account-name ghesresults \ --container-name ghes-data \ - --name "$filename" \ - --file "ghes-data/$filename" \ + --name {{ steps.file.outputs.name }} \ + --file ghes-data/{{ steps.file.outputs.name }} \ --connection-string "${{ secrets.CONNECTIONSTRING }}" - name: Unzip backup and setup symlink @@ -107,8 +108,7 @@ jobs: dir_name=$(date +%s) mkdir "$HOME/ghe-backup-data/$dir_name" - filename="v{{ steps.file.outputs.version }}-{{ inputs.size }}.tar.gz" - tar -xvf "ghes-data/$filename" -C "$HOME/ghe-backup-data/$dir_name" + tar -xvf ghes-data/{{ steps.file.outputs.name }} -C "$HOME/ghe-backup-data/$dir_name" ln -s "$dir_name" "$HOME/ghe-backup-data/current" From 5ac7abeb79085638b6e443ce86227f6a2650a127 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 12:54:55 +0200 Subject: [PATCH 1868/2421] Fix syntax --- .github/workflows/restore.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 607ce2ddc..e1e3f96c8 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -76,8 +76,8 @@ jobs: - name: Find backup file version id: file run: | - file_version={{ inputs.version }} - size={{ inputs.size }}} + file_version=${{ inputs.version }} + size=${{ inputs.size }}} echo "$file_version" V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10" @@ -98,8 +98,8 @@ jobs: az storage blob download \ --account-name ghesresults \ --container-name ghes-data \ - --name {{ steps.file.outputs.name }} \ - --file ghes-data/{{ steps.file.outputs.name }} \ + --name "${{ steps.file.outputs.name }}" \ + --file "ghes-data/${{ steps.file.outputs.name }}" \ --connection-string "${{ secrets.CONNECTIONSTRING }}" - name: Unzip backup and setup symlink @@ -108,7 +108,7 @@ jobs: dir_name=$(date +%s) mkdir "$HOME/ghe-backup-data/$dir_name" - tar -xvf ghes-data/{{ steps.file.outputs.name }} -C "$HOME/ghe-backup-data/$dir_name" + tar -xvf "ghes-data/${{ steps.file.outputs.name }}" -C "$HOME/ghe-backup-data/$dir_name" ln -s "$dir_name" "$HOME/ghe-backup-data/current" @@ -119,7 +119,7 @@ jobs: run: chmod 0600 "$HOME/backup" - name: change version - run: echo "{{ inputs.version }}.0" > "$HOME/version" + run: echo "${{ inputs.version }}.0" > "$HOME/version" - name: Prepare for restore run: ssh -p122 -i "$HOME/backup" -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" From 191b3c287503b019a672e8f02ff3201590591164 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 13:00:13 +0200 Subject: [PATCH 1869/2421] Fix syntax --- .github/workflows/restore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index e1e3f96c8..c981a0f07 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -77,7 +77,7 @@ jobs: id: file run: | file_version=${{ inputs.version }} - size=${{ inputs.size }}} + size=${{ inputs.size }} echo "$file_version" V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10" From f068233add27ee94956a6b11b41775662975b5ea Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 13:06:58 +0200 Subject: [PATCH 1870/2421] Fix syntax --- .github/workflows/restore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index c981a0f07..fb20d298f 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -86,7 +86,7 @@ jobs: if [ $? -eq 0 ]; then echo "Version $file_version is acceptable" echo "version=3.8" >> $GITHUB_OUTPUT - echo "name=v$version-$size.tar.gz" >> $GITHUB_OUTPUT + echo "name=v$file_version-$size.tar.gz" >> $GITHUB_OUTPUT else echo "Version $file_version is not acceptable" exit 1 From 02f4b78c9f705f53f66232dbcf8b3641276e3376 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 13:11:22 +0200 Subject: [PATCH 1871/2421] Fix syntax --- .github/workflows/restore.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index fb20d298f..5ef85b581 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -76,19 +76,19 @@ jobs: - name: Find backup file version id: file run: | - file_version=${{ inputs.version }} + version=${{ inputs.version }} size=${{ inputs.size }} - echo "$file_version" V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10" - echo "$V3_8_COMPATIBLE" | tr " " '\n' | grep -F -q -x "$file_version" + echo "$V3_8_COMPATIBLE" | tr " " '\n' | grep -F -q -x "$version" if [ $? -eq 0 ]; then echo "Version $file_version is acceptable" + file_version=3.8 echo "version=3.8" >> $GITHUB_OUTPUT echo "name=v$file_version-$size.tar.gz" >> $GITHUB_OUTPUT else - echo "Version $file_version is not acceptable" + echo "Version $version is not acceptable" exit 1 fi From e461908aedcf6cfbb7e00ec2152b4711edaee4fe Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 13:19:37 +0200 Subject: [PATCH 1872/2421] Add input for dispatch --- .github/workflows/restore.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 5ef85b581..de439b83a 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -19,6 +19,11 @@ on: required: false type: string default: 'master' + version: + description: 'Version of the dataset to restore (3.8/3.9)' + required: false + default: '3.8' + type: string workflow_call: inputs: From 7c0c444a19c2f48a5a31fc68af9f17e157deac03 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 13:26:43 +0200 Subject: [PATCH 1873/2421] make linter happy --- .github/workflows/restore.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index de439b83a..8525adda8 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -81,14 +81,13 @@ jobs: - name: Find backup file version id: file run: | - version=${{ inputs.version }} - size=${{ inputs.size }} + version="${{ inputs.version }}" + size="${{ inputs.size }}" V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10" - echo "$V3_8_COMPATIBLE" | tr " " '\n' | grep -F -q -x "$version" - - if [ $? -eq 0 ]; then - echo "Version $file_version is acceptable" + exit_code="$?" + if [ "$exit_code" -eq "0" ]; then + echo "Version $version is acceptable" file_version=3.8 echo "version=3.8" >> $GITHUB_OUTPUT echo "name=v$file_version-$size.tar.gz" >> $GITHUB_OUTPUT From c24d605cc14c957d9fc3374cf2283940e33815fb Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 13:33:48 +0200 Subject: [PATCH 1874/2421] make linter happy --- .github/workflows/restore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 8525adda8..af01be7bc 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -89,8 +89,8 @@ jobs: if [ "$exit_code" -eq "0" ]; then echo "Version $version is acceptable" file_version=3.8 - echo "version=3.8" >> $GITHUB_OUTPUT - echo "name=v$file_version-$size.tar.gz" >> $GITHUB_OUTPUT + echo "version=3.8" >> "$GITHUB_OUTPUT" + echo "name=v$file_version-$size.tar.gz" >> "$GITHUB_OUTPUT" else echo "Version $version is not acceptable" exit 1 From bed4965bea9fb99fc1b060ffb9ec869f9cdb8fbf Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 9 May 2023 16:42:10 +0200 Subject: [PATCH 1875/2421] Point to xl group --- .github/workflows/restore.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index af01be7bc..7d7c5bb5e 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -67,7 +67,9 @@ jobs: restore: needs: build - runs-on: ubuntu-latest + runs-on: + group: larger-hosted-public-runners + labels: ubuntu-latest-xl env: SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }} steps: From 6ca0f226aa92991034be403e4f0773b735e12e20 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Tue, 9 May 2023 13:38:39 -0400 Subject: [PATCH 1876/2421] Fix typo Thanks Quinn for spotting this! Co-authored-by: Quinn Murphy --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index 2161bbed4..5bc0a3e51 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -19,7 +19,7 @@ The [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#n If you encounter this degradation you can mitigate it by using the `--trust-sender` flag, which is available in rsync >= v3.2.5. -If your backup host is running rsync < v3.2.5 you may or may not need to make changes to you rsync package, depending on whether your rsync package has backported the fix for CVE-2022-29154 without also backporting the `--trust-sender` flag. +If your backup host is running rsync < v3.2.5 you may or may not need to make changes to your rsync package, depending on whether your rsync package has backported the fix for CVE-2022-29154 without also backporting the `--trust-sender` flag. If your rsync package has backported the CVE fix _and_ the `--trust-sender` flag then you don't need to change anything. From 1ba55758444f67f8500210dc03ab0d9866291e12 Mon Sep 17 00:00:00 2001 From: Peter Kovacs <12162093+eptekov@users.noreply.github.com> Date: Wed, 10 May 2023 15:31:03 +0000 Subject: [PATCH 1877/2421] Adding new option to exclude Pages from backup and restore. --- backup.config-example | 3 +++ bin/ghe-backup | 10 ++++++---- bin/ghe-restore | 10 ++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/backup.config-example b/backup.config-example index 1e6d762f2..2ca0551fa 100644 --- a/backup.config-example +++ b/backup.config-example @@ -95,3 +95,6 @@ GHE_NUM_SNAPSHOTS=10 # When running an external mysql database, run this script to trigger a MySQL restore # rather than attempting to backup via backup-utils directly. #EXTERNAL_DATABASE_RESTORE_SCRIPT="/bin/false" + +# If set to 'yes', Pages data will be included in backup and restore. Defaults to 'yes' +#GHE_BACKUP_PAGES=no \ No newline at end of file diff --git a/bin/ghe-backup b/bin/ghe-backup index c44b2d6fc..8b7332880 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -238,10 +238,12 @@ commands+=(" echo \"$cmd_title\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") -cmd_title=$(log_info "Backing up GitHub Pages artifacts ...") -commands+=(" -echo \"$cmd_title\" -ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") +if [ "$GHE_BACKUP_PAGES" != "no" ]; then + cmd_title=$(log_info "Backing up GitHub Pages artifacts ...") + commands+=(" + echo \"$cmd_title\" + ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") +fi cmd_title=$(log_info "Backing up storage data ...") commands+=(" diff --git a/bin/ghe-restore b/bin/ghe-restore index 2f789357d..d93188599 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -459,10 +459,12 @@ commands+=(" echo \"$cmd_title\" ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") -cmd_title=$(log_info "Restoring Pages ...") -commands+=(" -echo \"$cmd_title\" -ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") +if [ "$GHE_BACKUP_PAGES" != "no" ]; then + cmd_title=$(log_info "Restoring Pages ...") + commands+=(" + echo \"$cmd_title\" + ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") +fi cmd_title=$(log_info "Restoring SSH authorized keys ...") commands+=(" From 16d602357495e4911245204ab7159e561116b422 Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Thu, 11 May 2023 15:57:12 +0800 Subject: [PATCH 1878/2421] wj --- .DS_Store | Bin 0 -> 6148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c87e3f5030bc01edab5a7c20a9f56c8c5d2e8dca GIT binary patch literal 6148 zcmeHKze^lJ6n>-Yb1iCRR|L}QGm(Ty*n=2nqxR{znC36cy1s+M`c&q~719+dtCR%i8U9KT9#! zynFt(^||q5S^GPG_2*sjZCKwxD!m!-QkRY?RqQmwcdtaq8Xjg(2Q}29hLwzuQuR>6 z^-NL<6~5>?u1|&@$-nkg^837AHsq~)HQyccHK;?omUFwxn*Xl)CHMWs*LVzYo?!Xr5P|JzC}sr$NFm`40|D z{z}a77Z?|#>&SWiQ{d^+HY(Xw3QXMp)LvP`z1d#DlKkFUTO9ATG1^BoHjXPC+7xtt iJGKMfis#X+!58xYn0PE4Vg?re2v`|H7ZmuX3cLW&-}03J literal 0 HcmV?d00001 From 015e5ec64150eddcdda8c1bd4ae150d6dd89138d Mon Sep 17 00:00:00 2001 From: ghe-admin Date: Thu, 11 May 2023 16:01:42 +0800 Subject: [PATCH 1879/2421] wj --- .DS_Store | Bin 6148 -> 8196 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.DS_Store b/.DS_Store index c87e3f5030bc01edab5a7c20a9f56c8c5d2e8dca..528fc5cf95462431e79c40149c5e7fd2d0456e0b 100644 GIT binary patch literal 8196 zcmeHMy-yTD6n_IJoEY#cCNw73SwTXyvN~Wd<_szkC@f68FM)8!o_r{nXs)p`8WRgU zdn;-E1B{7@g?|IF*V0(%@6F8Z&D))&GzMqL?pyYK?EC%Rd@utMskz+gV za|$<4V?AG)He}yifmHA(+MpI~(K@ZtX2v?a2n+-U0t118z(8Q&Utj=hHn(EVx^J}M z9vBD={Fe;y{7}NhvTS9~NIiAnrndl)1-#Y`&)5fOpOTejD|<$2SHv{C2W4HA-C`)? z4tOdL9%Cop zs1yw*@4iANF*4pO ze!aZAG4he)IQr(1`tF(&`}!h(VxpfP)o2Gld^S<1T|BjDTjs2u!`{UN@l;b+>8(>u?gv|pmG)_h9_q84 zZ7>$orbJKgfyec{0H2!fKfBaLlm`3IeSH!%g*bcAcA#l{dz2e#7?IY~-_y16SV@*& zKSEa4-(|P@BVjku4p_}6;&qV$FaqXWvwLgj8RY8x4;8*eWEIsbrIckKqG1hoi>t^O)u8tdB z*h=1J`Hv@|ce#78m2j7`8Ss~9BRTAH&pLse*T9Q+brBgmmLlJw!%s4fo9(kVNw$uE zCm!VLw-A{YUU8=5sPQu0LCq@|=_{ywg=i_712UC^j`!LnT=#Hs zW4oS_+66Z@;rDtw4w?MJ5YHv6D_hw!5*oC>eh?7WfBdZ=)*A}zKegm4dHmP^KZgdu AfdBvi delta 162 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50D5wDBFoMK#(hY-?^K%O}7OrMy zRG6G6P(4{ykbiQLVB_S2LIsm&3wKODC{i)`tLWs(o5V^dcZyeV0`-9a2lvK8ahA>M pJP()!nIS>~+(6nDWX;CH@640=WjsNaGB80L0CE$<=6Iet%m6 Date: Thu, 11 May 2023 18:14:29 +0000 Subject: [PATCH 1880/2421] Revert "wj" This reverts commit 015e5ec64150eddcdda8c1bd4ae150d6dd89138d. --- .DS_Store | Bin 8196 -> 6148 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.DS_Store b/.DS_Store index 528fc5cf95462431e79c40149c5e7fd2d0456e0b..c87e3f5030bc01edab5a7c20a9f56c8c5d2e8dca 100644 GIT binary patch delta 162 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{Mvv5r;6q~50D5wDBFoMK#(hY-?^K%O}7OrMy zRG6G6P(4{ykbiQLVB_S2LIsm&3wKODC{i)`tLWs(o5V^dcZyeV0`-9a2lvK8ahA>M pJP()!nIS>~+(6nDWX;CH@640=WjsNaGB80L0CE$<=6Iet%m6+gV za|$<4V?AG)He}yifmHA(+MpI~(K@ZtX2v?a2n+-U0t118z(8Q&Utj=hHn(EVx^J}M z9vBD={Fe;y{7}NhvTS9~NIiAnrndl)1-#Y`&)5fOpOTejD|<$2SHv{C2W4HA-C`)? z4tOdL9%Cop zs1yw*@4iANF*4pO ze!aZAG4he)IQr(1`tF(&`}!h(VxpfP)o2Gld^S<1T|BjDTjs2u!`{UN@l;b+>8(>u?gv|pmG)_h9_q84 zZ7>$orbJKgfyec{0H2!fKfBaLlm`3IeSH!%g*bcAcA#l{dz2e#7?IY~-_y16SV@*& zKSEa4-(|P@BVjku4p_}6;&qV$FaqXWvwLgj8RY8x4;8*eWEIsbrIckKqG1hoi>t^O)u8tdB z*h=1J`Hv@|ce#78m2j7`8Ss~9BRTAH&pLse*T9Q+brBgmmLlJw!%s4fo9(kVNw$uE zCm!VLw-A{YUU8=5sPQu0LCq@|=_{ywg=i_712UC^j`!LnT=#Hs zW4oS_+66Z@;rDtw4w?MJ5YHv6D_hw!5*oC>eh?7WfBdZ=)*A}zKegm4dHmP^KZgdu AfdBvi From 7c5e4d9cde1c6e6c74b3b3120915b45ac8ac7a24 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Thu, 11 May 2023 18:14:44 +0000 Subject: [PATCH 1881/2421] Revert "wj" This reverts commit 16d602357495e4911245204ab7159e561116b422. --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index c87e3f5030bc01edab5a7c20a9f56c8c5d2e8dca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKze^lJ6n>-Yb1iCRR|L}QGm(Ty*n=2nqxR{znC36cy1s+M`c&q~719+dtCR%i8U9KT9#! zynFt(^||q5S^GPG_2*sjZCKwxD!m!-QkRY?RqQmwcdtaq8Xjg(2Q}29hLwzuQuR>6 z^-NL<6~5>?u1|&@$-nkg^837AHsq~)HQyccHK;?omUFwxn*Xl)CHMWs*LVzYo?!Xr5P|JzC}sr$NFm`40|D z{z}a77Z?|#>&SWiQ{d^+HY(Xw3QXMp)LvP`z1d#DlKkFUTO9ATG1^BoHjXPC+7xtt iJGKMfis#X+!58xYn0PE4Vg?re2v`|H7ZmuX3cLW&-}03J From b0862995a125bf12152f59b0c565591a7c1889e8 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Thu, 11 May 2023 18:25:17 +0000 Subject: [PATCH 1882/2421] Said file will not be accidently added --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 246384181..2a123a949 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /backup.config /data /dist +.DS_Store From da320c9183ab4ee6bc6bce0e0fa065812a84719d Mon Sep 17 00:00:00 2001 From: Peter Kovacs <12162093+eptekov@users.noreply.github.com> Date: Thu, 11 May 2023 16:30:19 -0500 Subject: [PATCH 1883/2421] Adding comment to explain double-negative if condition --- bin/ghe-backup | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index 8b7332880..ad8147f82 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -238,6 +238,9 @@ commands+=(" echo \"$cmd_title\" ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") +# Pages backups are skipped only if GHE_BACKUP_PAGES is explicitly set to 'no' to guarantee backward compatibility. +# If a customer upgrades backup-utils but keeps the config file from a previous version, Pages backups still work as expected. + if [ "$GHE_BACKUP_PAGES" != "no" ]; then cmd_title=$(log_info "Backing up GitHub Pages artifacts ...") commands+=(" From cfa890d13b4a5004e4d519b7572f37c68f94bcdc Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Mon, 15 May 2023 13:17:00 -0400 Subject: [PATCH 1884/2421] Fix cleanup_cluster_nodes function in ghe-restore Resolves https://github.com/github/ghes/issues/6453 . cleanup_cluster_nodes is a function that runs remotely and therefore does not have access to our output options. --- bin/ghe-restore | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d93188599..c0aae6ed9 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -135,6 +135,7 @@ cleanup () { } # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. +# because it doesn't run locally does not redirect output to fd 3 or use log_info/log_warn/log_error. # shellcheck disable=SC2034 cleanup_cluster_nodes() { uuid="$1" @@ -143,18 +144,18 @@ cleanup_cluster_nodes() { exit 2 fi - log_info "Cleaning up spokes" 1>&3 + echo "Cleaning up spokes" ghe-spokes server evacuate "git-server-$uuid" 'Removing replica' ghe-spokes server destroy "git-server-$uuid" - log_info "Cleaning up storage" 1>&3 + echo "Cleaning up storage" ghe-storage destroy-host "storage-server-$uuid" --force - log_info "Cleaning up dpages" 1>&3 + echo "Cleaning up dpages" ghe-dpages offline "pages-server-$uuid" ghe-dpages remove "pages-server-$uuid" - log_info "Cleaning up redis" 1>&3 + echo "Cleaning up redis" ghe-redis-cli del "resque:queue:maint_git-server-$uuid" ghe-redis-cli srem resque:queues "maint_git-server-$uuid" } From 31a3951d25404252e309b4ac9503dbd18c26e257 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 16 May 2023 09:26:14 -0400 Subject: [PATCH 1885/2421] add -T Multi-line description of commit, feel free to be detailed. --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index 6f186771b..a0b7de945 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -83,4 +83,4 @@ $GHE_VERBOSE_SSH && set -x # Exec ssh command with modified host / port args and add nice to command. # shellcheck disable=SC2090 # We don't need the quote/backslashes respected -exec ssh $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" +exec ssh -T $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" From 74dc1b32c9cf8ab858f867ea74149f411995cc8b Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 16 May 2023 18:58:40 +0000 Subject: [PATCH 1886/2421] Add a bit of performance best practices info --- docs/backup-snapshot-file-structure.md | 28 +++++++++++++++++++++++++- docs/requirements.md | 3 +++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/backup-snapshot-file-structure.md b/docs/backup-snapshot-file-structure.md index 2a950d63e..17ad3898e 100644 --- a/docs/backup-snapshot-file-structure.md +++ b/docs/backup-snapshot-file-structure.md @@ -61,4 +61,30 @@ T--T--T--T--T--T--T--T--T--T--T--T--T... (transaction log backup) ``` To save disk space, at each snapshot, hard links are created to point to previous backup files. Only newly-created backup files are transferred from appliance to backup host. When a new full/differential backup is created, they become the new source for hard links and new base line for transaction log backups, for subsequent snapshots. -During restore, a suite of backup files are restored in the sequence of full -> differential -> chronological transaction log. \ No newline at end of file +During restore, a suite of backup files are restored in the sequence of full -> differential -> chronological transaction log. + +## Benchmark data + +Benchmark data for each snapshot is stored as a log file within the `benchmarks` directory within a snapshot directory. The benchmark log can be used to determine the duration of each backup step. For example: + +```text +ghe-backup-store-version took 0s +ghe-backup-settings took 2s +ghe-export-authorized-keys took 0s +ghe-export-ssh-host-keys took 0s +ghe-backup-mysql-binary took 9s +ghe-backup-mysql took 9s +ghe-backup-minio took 0s +ghe-backup-redis took 1s +ghe-backup-es-audit-log took 1s +ghe-backup-repositories - Generating routes took 3s +ghe-backup-repositories - Fetching routes took 0s +ghe-backup-repositories - Processing routes took 0s +ghe-backup-pages - hostname took 1s +ghe-backup-pages took 1s +ghe-backup-storage - Generating routes took 2s +ghe-backup-storage - Fetching routes took 0s +ghe-backup-storage - Processing routes took 0s +ghe-backup-git-hooks took 0s +ghe-backup-es-rsync took 2s +``` diff --git a/docs/requirements.md b/docs/requirements.md index 5bc0a3e51..93a132297 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -13,6 +13,8 @@ We encourage the use of [Docker](docker.md), as it ensures compatible versions o The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. +CPU and memory requirements are dependent on the size of the GitHub Enterprise Server appliance. We recommend a minimum of 4 cores and 8GB of RAM for the host running [GitHub Enterprise Backup Utilities](https://github.com/github/backup-utils). We recommend monitoring the backup host's CPU and memory usage to ensure it is sufficient for your environment. + ### April 2023 Update of Rsync Requirements The [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) can cause severe performance degradation to `backup-utils`. @@ -53,6 +55,7 @@ ls -la Using a [case sensitive][7] file system is also required to avoid conflicts. +Performance of backup and restore operations are also dependent on the backup host's storage. We recommend using a high performance storage system for your data directory for best performance. ## GitHub Enterprise Server version requirements Starting with Backup Utilities v2.13.0, version support is inline with that of the From e800a578aa6d4635cf58b0a42a06a0baaf7182e7 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 16 May 2023 18:59:37 +0000 Subject: [PATCH 1887/2421] Missign newline --- docs/requirements.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/requirements.md b/docs/requirements.md index 93a132297..5d7b46a39 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -56,6 +56,7 @@ ls -la Using a [case sensitive][7] file system is also required to avoid conflicts. Performance of backup and restore operations are also dependent on the backup host's storage. We recommend using a high performance storage system for your data directory for best performance. + ## GitHub Enterprise Server version requirements Starting with Backup Utilities v2.13.0, version support is inline with that of the From 1314a62c5cb2f8f943562b6284c573f96ce82887 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 16 May 2023 19:05:50 +0000 Subject: [PATCH 1888/2421] Tweak redundant words --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index 5d7b46a39..982230513 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -55,7 +55,7 @@ ls -la Using a [case sensitive][7] file system is also required to avoid conflicts. -Performance of backup and restore operations are also dependent on the backup host's storage. We recommend using a high performance storage system for your data directory for best performance. +Performance of backup and restore operations are also dependent on the backup host's storage. We recommend using a high performance storage system with low latency and high IOPS. ## GitHub Enterprise Server version requirements From 3533b5bbd67285987ffd6ba50f4b62820cb9a1e6 Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 16 May 2023 19:11:24 +0000 Subject: [PATCH 1889/2421] Attempt to appease linter --- docs/backup-snapshot-file-structure.md | 4 +++- docs/requirements.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/backup-snapshot-file-structure.md b/docs/backup-snapshot-file-structure.md index 17ad3898e..0a7032397 100644 --- a/docs/backup-snapshot-file-structure.md +++ b/docs/backup-snapshot-file-structure.md @@ -52,13 +52,15 @@ Actions service uses MS SQL Server as backend data store. Each snapshot includes To save time in backup, a three-level backup strategy is implemented. Based on the `GHE_MSSQL_BACKUP_CADENCE` setting, at each snapshot, either a (**F**)ull backup, a (**D**)ifferential or a (**T**)ransaction log backup is taken. As a result, a suite always contains following for each database: a full backup, possibly a differential backup and at least one transaction log backup. Their relationship with timeline is demonstrated below: -``` + +```text M---8:00--16:00---T---8:00--16:00---W... (timeline) F-----------------F-----------------F... (full backup) #-----D-----D-----#-----D-----D-----#... (differential backup) T--T--T--T--T--T--T--T--T--T--T--T--T... (transaction log backup) ``` + To save disk space, at each snapshot, hard links are created to point to previous backup files. Only newly-created backup files are transferred from appliance to backup host. When a new full/differential backup is created, they become the new source for hard links and new base line for transaction log backups, for subsequent snapshots. During restore, a suite of backup files are restored in the sequence of full -> differential -> chronological transaction log. diff --git a/docs/requirements.md b/docs/requirements.md index 982230513..a7dc45ebe 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -17,7 +17,7 @@ CPU and memory requirements are dependent on the size of the GitHub Enterprise S ### April 2023 Update of Rsync Requirements -The [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) can cause severe performance degradation to `backup-utils`. +The [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) can cause severe performance degradation to `backup-utils`. If you encounter this degradation you can mitigate it by using the `--trust-sender` flag, which is available in rsync >= v3.2.5. From 60192d40960225615629709ff4d4e5f8fe67b660 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 17 May 2023 14:57:06 +0000 Subject: [PATCH 1890/2421] Make comment change --- bin/ghe-restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 0f0330241..f2b13bc36 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -165,8 +165,7 @@ cleanup_cluster_nodes() { # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" -# Calculate the actual amounts of steps in the restore process -# taking into account the options passed to the script and the appliance configuration + @@ -271,7 +270,8 @@ if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then prompt_for_confirmation "Please confirm this before continuing." fi - +# Calculate the actual amounts of steps in the restore process +# taking into account the options passed to the script and the appliance configuration # calculate restore steps OPTIONAL_STEPS=0 # Cluster restores add an additional step From 5f2437be6b75a487c99142c1ea14221e9e1d895a Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 17 May 2023 11:09:25 -0400 Subject: [PATCH 1891/2421] removing -T --- share/github-backup-utils/ghe-ssh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-ssh b/share/github-backup-utils/ghe-ssh index a0b7de945..6f186771b 100755 --- a/share/github-backup-utils/ghe-ssh +++ b/share/github-backup-utils/ghe-ssh @@ -83,4 +83,4 @@ $GHE_VERBOSE_SSH && set -x # Exec ssh command with modified host / port args and add nice to command. # shellcheck disable=SC2090 # We don't need the quote/backslashes respected -exec ssh -T $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" +exec ssh $opts -p $port -o BatchMode=yes "$host" -- $GHE_NICE $GHE_IONICE "$@" From 3b2f1c11476c4a84467b59d1564aaf56c5745eb8 Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Wed, 17 May 2023 20:11:26 +0000 Subject: [PATCH 1892/2421] add encrypted column encryption keys to backup utils --- share/github-backup-utils/ghe-backup-settings | 2 + .../github-backup-utils/ghe-restore-settings | 6 +++ test/test-ghe-backup.sh | 50 +++++++++++++++++ test/test-ghe-restore.sh | 53 ++++++++++++++++++- 4 files changed, 110 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 2cf66c0a7..c71085a0b 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -78,6 +78,8 @@ backup-secret "management console password" "manage-password" "secrets.manage" backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" +backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" +backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" # Backup argon secrets for multiuser from ghes version 3.8 onwards if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index b489626c2..ad06f30a6 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -56,6 +56,12 @@ restore-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hm # Restore kredz.varz HMAC key if present. restore-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" +# Restore encrypted column encryption keying material if present +restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" + +# Restore encrypted column current encryption key if present +restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" + # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then log_info "Restoring SAML keys ..." diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 897213d4a..135b26170 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -555,6 +555,56 @@ begin_test "ghe-backup takes backup of kredz-varz settings" ) end_test +begin_test "ghe-backup takes backup of encrypted column encryption keying material" +( + set -e + + required_secrets=( + "secrets.github.encrypted-column-keying-material" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + ghe-backup + + required_files=( + "encrypted-column-encryption-keying-material" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done + +) +end_test + +begin_test "ghe-backup takes backup of encrypted column current encryption key" +( + set -e + + required_secrets=( + "secrets.github.encrypted-column-current-encryption-key" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + ghe-backup + + required_files=( + "encrypted-column-current-encryption-key" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done + +) +end_test + begin_test "ghe-backup takes backup of Actions settings" ( set -e diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index fbfc47aa8..1dae759d7 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -355,7 +355,58 @@ begin_test "ghe-restore with kredz-varz settings" required_secrets=( "secrets.kredz.varz-hmac-secret" ) - + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done +) +end_test + + +begin_test "ghe-restore with encrypted column encryption keying material" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + required_files=( + "encrypted-column-encryption-keying-material" + ) + + for file in "${required_files[@]}"; do + echo "foo" > "$GHE_DATA_DIR/current/$file" + done + + ghe-restore -v -f localhost + required_secrets=( + "secrets.github.encrypted-column-keying-material" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done +) +end_test + +begin_test "ghe-restore with encrypted column current encryption key" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + required_files=( + "encrypted-column-current-encryption-key" + ) + + for file in "${required_files[@]}"; do + echo "foo" > "$GHE_DATA_DIR/current/$file" + done + + ghe-restore -v -f localhost + required_secrets=( + "secrets.github.encrypted-column-current-encryption-key" + ) + for secret in "${required_secrets[@]}"; do [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] done From 0a4001f3470caf16e11a986186e429711ec62a6b Mon Sep 17 00:00:00 2001 From: Krayon Date: Wed, 24 May 2023 13:40:57 +1000 Subject: [PATCH 1893/2421] Add git minimum version --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index a7dc45ebe..a66863d8b 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,7 +5,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), and [jq][11] v1.5 or newer. See below for an update on rsync. +Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2] 1.7.6 or newer, [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), and [jq][11] v1.5 or newer. See below for an update on rsync. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From 0f40f9ab36109d26dee14faadb7d11e77afcf7aa Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 13:59:12 +0200 Subject: [PATCH 1894/2421] Support jq with docker --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 9e016dc03..4f24ee098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM ubuntu:focal RUN apt-get -q -y update && \ apt-get install -y --no-install-recommends \ tar \ + jq \ rsync \ ca-certificates \ ssh \ From 91ec6183849f1b04c473df29c5e33083fc28b42d Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 13:59:28 +0200 Subject: [PATCH 1895/2421] Add backup workflow --- .github/workflows/backup.yml | 112 +++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/backup.yml diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml new file mode 100644 index 000000000..387a9cb13 --- /dev/null +++ b/.github/workflows/backup.yml @@ -0,0 +1,112 @@ +name: Backup and save to Azure +run-name: "${{ github.actor }} - Backup and save to Azure" + +on: + workflow_call: + inputs: + github-hostname: + description: GitHub Hostname to backup + required: true + type: string + backup-name: + description: The name of the backup to be saved in Azure storage + required: false + default: "" + type: string + secrets: + BACKUP_SSH_KEY: + description: SSH key to access the GitHub Enterprise instance + required: true + INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN: + description: Token for the internal actions dx bot account + required: true + AZURE_USERNAME: + description: Azure service principal username + required: false + AZURE_PASSWORD: + description: Azure service principal password + required: false + AZURE_TENANT_ID: + description: Azure tenant ID + required: false + AZURE_SUBSCRIPTION_ID: + description: Azure subscription ID + required: false + CONNECTIONSTRING: + description: Azure storage connection string + required: false + + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + repository: github/backup-utils-private + token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" + - run: docker build . --file Dockerfile --tag backup-utils + - run: docker save backup-utils -o backup-utils.tar + - uses: actions/upload-artifact@v3 + with: + name: backup-utils + path: backup-utils.tar + + backup-utils-backup: + needs: build + runs-on: + group: larger-hosted-public-runners + labels: ubuntu-latest-xl + env: + SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }} + steps: + - uses: actions/download-artifact@v3 + with: + name: backup-utils + - name: Load docker container + run: docker load -i backup-utils.tar + - uses: actions/checkout@v3 + - name: Create backup directory + run: mkdir $HOME/ghe-backup-data + - name: set up ssh SSH_KEY + run: echo -e "${SSH_KEY}\n" > $HOME/backup + - name: set up ssh key permissions + run: chmod 0600 $HOME/backup + - name: change version + run: echo "3.8.0" > $HOME/version + + - name: Perform backup + run: | + docker run -e "GHE_HOSTNAME=${{ inputs.github-hostname }}" \ + -e "GHE_DATA_DIR=/data" \ + -e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \ + -e "GHE_NUM_SNAPSHOTS=15" \ + -v "$HOME/ghe-backup-data:/data" \ + -v "$HOME/backup:/ghe-ssh/id_rsa" \ + -v "$HOME/version:/backup-utils/share/github-backup-utils/version" \ + --rm \ + backup-utils ghe-backup + - name: Check the backup file + run: | + current=$(readlink $HOME/ghe-backup-data/current) + sudo tar -czvf ${{ inputs.backup-name }}.tar.gz -C $HOME/ghe-backup-data/$current . + + - name: Login to Azure + if: ${{ inputs.backup-name }} != "" + run: | + az login \ + --service-principal \ + -u ${{ secrets.AZURE_USERNAME }} \ + -p ${{ secrets.AZURE_PASSWORD }} \ + --tenant ${{ secrets.AZURE_TENANT_ID }} + az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}" + + - name: Upload backup to Azure + if: ${{ inputs.backup-name }} != "" + run: | + az storage blob upload \ + --account-name "ghesresults" \ + --container-name "ghes-data" \ + --name ${{ inputs.backup-name }}.tar.gz \ + --file ${{ inputs.backup-name }}.tar.gz \ + --connection-string "${{ secrets.CONNECTIONSTRING }}" \ No newline at end of file From eb78a4c83b7531d67da2e558e4d5bb121bc9f8ca Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 14:11:44 +0200 Subject: [PATCH 1896/2421] Add new variables --- .github/workflows/backup.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 387a9cb13..9c4fdd00a 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -32,6 +32,12 @@ on: AZURE_SUBSCRIPTION_ID: description: Azure subscription ID required: false + AZURE_ACCOUNT_NAME: + description: Azure storage account name + required: false + AZURE_CONTAINER_NAME: + description: Azure storage container name + required: false CONNECTIONSTRING: description: Azure storage connection string required: false @@ -105,8 +111,8 @@ jobs: if: ${{ inputs.backup-name }} != "" run: | az storage blob upload \ - --account-name "ghesresults" \ - --container-name "ghes-data" \ + --account-name "${{ secrets.AZURE_ACCOUNT_NAME }}" \ + --container-name "${{ secrets.AZURE_CONTAINER_NAME }}" \ --name ${{ inputs.backup-name }}.tar.gz \ --file ${{ inputs.backup-name }}.tar.gz \ --connection-string "${{ secrets.CONNECTIONSTRING }}" \ No newline at end of file From 8892df964b2f9f8aea5c2f516ff3671237d4b74a Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 14:13:06 +0200 Subject: [PATCH 1897/2421] Make linter happy --- .github/workflows/backup.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 9c4fdd00a..a86488c07 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -73,13 +73,13 @@ jobs: run: docker load -i backup-utils.tar - uses: actions/checkout@v3 - name: Create backup directory - run: mkdir $HOME/ghe-backup-data + run: mkdir "$HOME/ghe-backup-data" - name: set up ssh SSH_KEY - run: echo -e "${SSH_KEY}\n" > $HOME/backup + run: echo -e "${SSH_KEY}\n" > "$HOME/backup" - name: set up ssh key permissions - run: chmod 0600 $HOME/backup + run: chmod 0600 "$HOME/backup" - name: change version - run: echo "3.8.0" > $HOME/version + run: echo "3.8.0" > "$HOME/version" - name: Perform backup run: | @@ -94,17 +94,17 @@ jobs: backup-utils ghe-backup - name: Check the backup file run: | - current=$(readlink $HOME/ghe-backup-data/current) - sudo tar -czvf ${{ inputs.backup-name }}.tar.gz -C $HOME/ghe-backup-data/$current . + current=$(readlink "$HOME/ghe-backup-data/current") + sudo tar -czvf "${{ inputs.backup-name }}.tar.gz" -C "$HOME/ghe-backup-data/$current" . - name: Login to Azure if: ${{ inputs.backup-name }} != "" run: | az login \ --service-principal \ - -u ${{ secrets.AZURE_USERNAME }} \ - -p ${{ secrets.AZURE_PASSWORD }} \ - --tenant ${{ secrets.AZURE_TENANT_ID }} + -u "${{ secrets.AZURE_USERNAME }}" \ + -p "${{ secrets.AZURE_PASSWORD }}" \ + --tenant "${{ secrets.AZURE_TENANT_ID }}" az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}" - name: Upload backup to Azure @@ -113,6 +113,6 @@ jobs: az storage blob upload \ --account-name "${{ secrets.AZURE_ACCOUNT_NAME }}" \ --container-name "${{ secrets.AZURE_CONTAINER_NAME }}" \ - --name ${{ inputs.backup-name }}.tar.gz \ - --file ${{ inputs.backup-name }}.tar.gz \ + --name "${{ inputs.backup-name }}.tar.gz" \ + --file "${{ inputs.backup-name }}.tar.gz" \ --connection-string "${{ secrets.CONNECTIONSTRING }}" \ No newline at end of file From 2305a0e38358f67617d72ebb3805ae862d9f6050 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 14:39:06 +0200 Subject: [PATCH 1898/2421] Consider suggestion --- .github/workflows/backup.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index a86488c07..237d8e131 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -1,5 +1,5 @@ -name: Backup and save to Azure -run-name: "${{ github.actor }} - Backup and save to Azure" +name: Backup GHES instance and save to Azure +run-name: "${{ github.actor }} - Backup GHES instance and save to Azure" on: workflow_call: From 30d759f7b6764914904f0edc78d3171926a56386 Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Wed, 24 May 2023 19:54:25 +0000 Subject: [PATCH 1899/2421] move encrypted column encryption key restore tests _above_ actions setup --- test/test-ghe-restore.sh | 87 ++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 1dae759d7..c39c042b7 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -281,44 +281,14 @@ begin_test "ghe-restore with no pages backup" ) end_test -# Setup Actions data for the subsequent tests -setup_actions_test_data "$GHE_DATA_DIR/1" - -begin_test "ghe-restore invokes ghe-import-mssql" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - enable_actions - - # enable maintenance mode and create required directories - setup_maintenance_mode - - # set restore host environ var - GHE_RESTORE_HOST=127.0.0.1 - export GHE_RESTORE_HOST - - # run ghe-restore and write output to file for asserting against - if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then - cat "$TRASHDIR/restore-out" - : ghe-restore should have exited successfully - false - fi - - grep -q "Restoring MSSQL database" "$TRASHDIR/restore-out" - grep -q "ghe-import-mssql .* OK" "$TRASHDIR/restore-out" -) -end_test - -begin_test "ghe-restore with Kredz settings" +begin_test "ghe-restore with encrypted column encryption keying material" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata - enable_actions required_files=( - "kredz-credz-hmac" + "encrypted-column-encryption-keying-material" ) for file in "${required_files[@]}"; do @@ -327,24 +297,23 @@ begin_test "ghe-restore with Kredz settings" ghe-restore -v -f localhost required_secrets=( - "secrets.kredz.credz-hmac-secret" + "secrets.github.encrypted-column-keying-material" ) - + for secret in "${required_secrets[@]}"; do [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] done ) end_test -begin_test "ghe-restore with kredz-varz settings" +begin_test "ghe-restore with encrypted column current encryption key" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata - enable_actions required_files=( - "kredz-varz-hmac" + "encrypted-column-current-encryption-key" ) for file in "${required_files[@]}"; do @@ -353,7 +322,7 @@ begin_test "ghe-restore with kredz-varz settings" ghe-restore -v -f localhost required_secrets=( - "secrets.kredz.varz-hmac-secret" + "secrets.github.encrypted-column-current-encryption-key" ) for secret in "${required_secrets[@]}"; do @@ -362,15 +331,44 @@ begin_test "ghe-restore with kredz-varz settings" ) end_test +# Setup Actions data for the subsequent tests +setup_actions_test_data "$GHE_DATA_DIR/1" -begin_test "ghe-restore with encrypted column encryption keying material" +begin_test "ghe-restore invokes ghe-import-mssql" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata + enable_actions + + # enable maintenance mode and create required directories + setup_maintenance_mode + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # run ghe-restore and write output to file for asserting against + if ! ghe-restore -v -f > "$TRASHDIR/restore-out" 2>&1; then + cat "$TRASHDIR/restore-out" + : ghe-restore should have exited successfully + false + fi + + grep -q "Restoring MSSQL database" "$TRASHDIR/restore-out" + grep -q "ghe-import-mssql .* OK" "$TRASHDIR/restore-out" +) +end_test + +begin_test "ghe-restore with Kredz settings" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions required_files=( - "encrypted-column-encryption-keying-material" + "kredz-credz-hmac" ) for file in "${required_files[@]}"; do @@ -379,7 +377,7 @@ begin_test "ghe-restore with encrypted column encryption keying material" ghe-restore -v -f localhost required_secrets=( - "secrets.github.encrypted-column-keying-material" + "secrets.kredz.credz-hmac-secret" ) for secret in "${required_secrets[@]}"; do @@ -388,14 +386,15 @@ begin_test "ghe-restore with encrypted column encryption keying material" ) end_test -begin_test "ghe-restore with encrypted column current encryption key" +begin_test "ghe-restore with kredz-varz settings" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" setup_remote_metadata + enable_actions required_files=( - "encrypted-column-current-encryption-key" + "kredz-varz-hmac" ) for file in "${required_files[@]}"; do @@ -404,7 +403,7 @@ begin_test "ghe-restore with encrypted column current encryption key" ghe-restore -v -f localhost required_secrets=( - "secrets.github.encrypted-column-current-encryption-key" + "secrets.kredz.varz-hmac-secret" ) for secret in "${required_secrets[@]}"; do From 83c584070f92b6cc3a5ae27b8445f158e954c1be Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 24 May 2023 20:58:36 +0000 Subject: [PATCH 1900/2421] fix testlib.sh --- test/testlib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index af1425472..3877d1af9 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -160,7 +160,8 @@ report_failure () { # Mark the end of a test. end_test () { - test_status="${1:-$?}" + test_result=$? + test_status="${1:-$test_result}" after_time=$(date '+%s') elapsed_time=$((after_time - before_time)) set +x -e From 242217dfdbee05e88f757142fe2c2351a3257f56 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 24 May 2023 21:19:42 +0000 Subject: [PATCH 1901/2421] testlib reverts --- test/testlib.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index 3877d1af9..af1425472 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -160,8 +160,7 @@ report_failure () { # Mark the end of a test. end_test () { - test_result=$? - test_status="${1:-$test_result}" + test_status="${1:-$?}" after_time=$(date '+%s') elapsed_time=$((after_time - before_time)) set +x -e From 627147d40928c39d6df43cd98cb997ce542ae788 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 25 May 2023 13:00:21 -0400 Subject: [PATCH 1902/2421] disable SC2319 --- test/testlib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/testlib.sh b/test/testlib.sh index af1425472..e17fc3fd2 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -19,6 +19,7 @@ # # Copyright (c) 2011-14 by Ryan Tomayko # License: MIT +# shellcheck disable=SC2319 set -e # Setting basic paths From 030d1cf155fb89326c0735c6b21e3f98f7203c8e Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 13:59:12 +0200 Subject: [PATCH 1903/2421] Support jq with docker --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 9e016dc03..4f24ee098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ FROM ubuntu:focal RUN apt-get -q -y update && \ apt-get install -y --no-install-recommends \ tar \ + jq \ rsync \ ca-certificates \ ssh \ From 6c92cb53d520222c5825fab9e1e160694df42293 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 13:59:28 +0200 Subject: [PATCH 1904/2421] Add backup workflow --- .github/workflows/backup.yml | 112 +++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .github/workflows/backup.yml diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml new file mode 100644 index 000000000..387a9cb13 --- /dev/null +++ b/.github/workflows/backup.yml @@ -0,0 +1,112 @@ +name: Backup and save to Azure +run-name: "${{ github.actor }} - Backup and save to Azure" + +on: + workflow_call: + inputs: + github-hostname: + description: GitHub Hostname to backup + required: true + type: string + backup-name: + description: The name of the backup to be saved in Azure storage + required: false + default: "" + type: string + secrets: + BACKUP_SSH_KEY: + description: SSH key to access the GitHub Enterprise instance + required: true + INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN: + description: Token for the internal actions dx bot account + required: true + AZURE_USERNAME: + description: Azure service principal username + required: false + AZURE_PASSWORD: + description: Azure service principal password + required: false + AZURE_TENANT_ID: + description: Azure tenant ID + required: false + AZURE_SUBSCRIPTION_ID: + description: Azure subscription ID + required: false + CONNECTIONSTRING: + description: Azure storage connection string + required: false + + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + repository: github/backup-utils-private + token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" + - run: docker build . --file Dockerfile --tag backup-utils + - run: docker save backup-utils -o backup-utils.tar + - uses: actions/upload-artifact@v3 + with: + name: backup-utils + path: backup-utils.tar + + backup-utils-backup: + needs: build + runs-on: + group: larger-hosted-public-runners + labels: ubuntu-latest-xl + env: + SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }} + steps: + - uses: actions/download-artifact@v3 + with: + name: backup-utils + - name: Load docker container + run: docker load -i backup-utils.tar + - uses: actions/checkout@v3 + - name: Create backup directory + run: mkdir $HOME/ghe-backup-data + - name: set up ssh SSH_KEY + run: echo -e "${SSH_KEY}\n" > $HOME/backup + - name: set up ssh key permissions + run: chmod 0600 $HOME/backup + - name: change version + run: echo "3.8.0" > $HOME/version + + - name: Perform backup + run: | + docker run -e "GHE_HOSTNAME=${{ inputs.github-hostname }}" \ + -e "GHE_DATA_DIR=/data" \ + -e "GHE_EXTRA_SSH_OPTS=-p 122 -i /ghe-ssh/id_rsa -o ServerAliveInterval=30 -o ServerAliveCountMax=12000 -o StrictHostKeyChecking=no" \ + -e "GHE_NUM_SNAPSHOTS=15" \ + -v "$HOME/ghe-backup-data:/data" \ + -v "$HOME/backup:/ghe-ssh/id_rsa" \ + -v "$HOME/version:/backup-utils/share/github-backup-utils/version" \ + --rm \ + backup-utils ghe-backup + - name: Check the backup file + run: | + current=$(readlink $HOME/ghe-backup-data/current) + sudo tar -czvf ${{ inputs.backup-name }}.tar.gz -C $HOME/ghe-backup-data/$current . + + - name: Login to Azure + if: ${{ inputs.backup-name }} != "" + run: | + az login \ + --service-principal \ + -u ${{ secrets.AZURE_USERNAME }} \ + -p ${{ secrets.AZURE_PASSWORD }} \ + --tenant ${{ secrets.AZURE_TENANT_ID }} + az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}" + + - name: Upload backup to Azure + if: ${{ inputs.backup-name }} != "" + run: | + az storage blob upload \ + --account-name "ghesresults" \ + --container-name "ghes-data" \ + --name ${{ inputs.backup-name }}.tar.gz \ + --file ${{ inputs.backup-name }}.tar.gz \ + --connection-string "${{ secrets.CONNECTIONSTRING }}" \ No newline at end of file From 889b70e7a663f8e47c99634567201d7a1b94bfbb Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 14:11:44 +0200 Subject: [PATCH 1905/2421] Add new variables --- .github/workflows/backup.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 387a9cb13..9c4fdd00a 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -32,6 +32,12 @@ on: AZURE_SUBSCRIPTION_ID: description: Azure subscription ID required: false + AZURE_ACCOUNT_NAME: + description: Azure storage account name + required: false + AZURE_CONTAINER_NAME: + description: Azure storage container name + required: false CONNECTIONSTRING: description: Azure storage connection string required: false @@ -105,8 +111,8 @@ jobs: if: ${{ inputs.backup-name }} != "" run: | az storage blob upload \ - --account-name "ghesresults" \ - --container-name "ghes-data" \ + --account-name "${{ secrets.AZURE_ACCOUNT_NAME }}" \ + --container-name "${{ secrets.AZURE_CONTAINER_NAME }}" \ --name ${{ inputs.backup-name }}.tar.gz \ --file ${{ inputs.backup-name }}.tar.gz \ --connection-string "${{ secrets.CONNECTIONSTRING }}" \ No newline at end of file From c98f3be36a3dba07ecb7814806562dc232bc8393 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 14:13:06 +0200 Subject: [PATCH 1906/2421] Make linter happy --- .github/workflows/backup.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 9c4fdd00a..a86488c07 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -73,13 +73,13 @@ jobs: run: docker load -i backup-utils.tar - uses: actions/checkout@v3 - name: Create backup directory - run: mkdir $HOME/ghe-backup-data + run: mkdir "$HOME/ghe-backup-data" - name: set up ssh SSH_KEY - run: echo -e "${SSH_KEY}\n" > $HOME/backup + run: echo -e "${SSH_KEY}\n" > "$HOME/backup" - name: set up ssh key permissions - run: chmod 0600 $HOME/backup + run: chmod 0600 "$HOME/backup" - name: change version - run: echo "3.8.0" > $HOME/version + run: echo "3.8.0" > "$HOME/version" - name: Perform backup run: | @@ -94,17 +94,17 @@ jobs: backup-utils ghe-backup - name: Check the backup file run: | - current=$(readlink $HOME/ghe-backup-data/current) - sudo tar -czvf ${{ inputs.backup-name }}.tar.gz -C $HOME/ghe-backup-data/$current . + current=$(readlink "$HOME/ghe-backup-data/current") + sudo tar -czvf "${{ inputs.backup-name }}.tar.gz" -C "$HOME/ghe-backup-data/$current" . - name: Login to Azure if: ${{ inputs.backup-name }} != "" run: | az login \ --service-principal \ - -u ${{ secrets.AZURE_USERNAME }} \ - -p ${{ secrets.AZURE_PASSWORD }} \ - --tenant ${{ secrets.AZURE_TENANT_ID }} + -u "${{ secrets.AZURE_USERNAME }}" \ + -p "${{ secrets.AZURE_PASSWORD }}" \ + --tenant "${{ secrets.AZURE_TENANT_ID }}" az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}" - name: Upload backup to Azure @@ -113,6 +113,6 @@ jobs: az storage blob upload \ --account-name "${{ secrets.AZURE_ACCOUNT_NAME }}" \ --container-name "${{ secrets.AZURE_CONTAINER_NAME }}" \ - --name ${{ inputs.backup-name }}.tar.gz \ - --file ${{ inputs.backup-name }}.tar.gz \ + --name "${{ inputs.backup-name }}.tar.gz" \ + --file "${{ inputs.backup-name }}.tar.gz" \ --connection-string "${{ secrets.CONNECTIONSTRING }}" \ No newline at end of file From c53ca0dd493e413c12c5b74e26df8dd5525ca7f8 Mon Sep 17 00:00:00 2001 From: solmaz Date: Wed, 24 May 2023 14:39:06 +0200 Subject: [PATCH 1907/2421] Consider suggestion --- .github/workflows/backup.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index a86488c07..237d8e131 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -1,5 +1,5 @@ -name: Backup and save to Azure -run-name: "${{ github.actor }} - Backup and save to Azure" +name: Backup GHES instance and save to Azure +run-name: "${{ github.actor }} - Backup GHES instance and save to Azure" on: workflow_call: From d0cc3ab2015b2125413fab6ecf79e842a64a6ef2 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 25 May 2023 13:00:21 -0400 Subject: [PATCH 1908/2421] disable SC2319 --- test/testlib.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/testlib.sh b/test/testlib.sh index af1425472..e17fc3fd2 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -19,6 +19,7 @@ # # Copyright (c) 2011-14 by Ryan Tomayko # License: MIT +# shellcheck disable=SC2319 set -e # Setting basic paths From 940cad5a081ee601680a2b258cd1ddfbecbc2d38 Mon Sep 17 00:00:00 2001 From: solmaz Date: Tue, 30 May 2023 14:59:41 +0200 Subject: [PATCH 1909/2421] Change the restore logic --- .github/workflows/restore.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index 7d7c5bb5e..ab0627751 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -85,19 +85,22 @@ jobs: run: | version="${{ inputs.version }}" size="${{ inputs.size }}" - V3_8_COMPATIBLE="3.6 3.7 3.8 3.9 3.10" - echo "$V3_8_COMPATIBLE" | tr " " '\n' | grep -F -q -x "$version" - exit_code="$?" - if [ "$exit_code" -eq "0" ]; then - echo "Version $version is acceptable" + V3_6_COMPATIBLE="3.6 3.7" + V3_8_COMPATIBLE="3.8 3.9 3.10" + if echo "$V3_8_COMPATIBLE" | grep -q -w "$version"; then + echo "Version $version is acceptable by 3.8 backup" file_version=3.8 - echo "version=3.8" >> "$GITHUB_OUTPUT" - echo "name=v$file_version-$size.tar.gz" >> "$GITHUB_OUTPUT" + elif echo "$V3_6_COMPATIBLE" | grep -q -w "$version"; then + echo "Version $version is acceptable by 3.6 backup" + file_version=3.6 else echo "Version $version is not acceptable" exit 1 fi + echo "version=$file_version" >> "$GITHUB_OUTPUT" + echo "name=v$file_version-$size.tar.gz" >> "$GITHUB_OUTPUT" + - name: Download from blob storage run: | mkdir ghes-data From 443c8aa1930bed9c4bdb6c254c3eada02336b76f Mon Sep 17 00:00:00 2001 From: Ryan Trauntvein Date: Tue, 30 May 2023 19:15:26 +0000 Subject: [PATCH 1910/2421] Make main Dockerfile --- .github/workflows/docker-image.yml | 7 --- .github/workflows/rsync-docker-bump.yml | 12 ++-- Dockerfile | 66 ++++++++++++++++++++-- Dockerfile.rsync | 74 ------------------------- 4 files changed, 66 insertions(+), 93 deletions(-) delete mode 100644 Dockerfile.rsync diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 2274cf630..07c44f9df 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -18,8 +18,6 @@ jobs: run: docker build . --file Dockerfile --tag backup-utils:${GITHUB_RUN_ID} - name: Build the Alpine Docker image run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID} - - name: Build the Rsync source Docker image - run: docker build . --file Dockerfile.rsync --tag backup-utils-rsync:${GITHUB_RUN_ID} - name: Run tests in Ubuntu Docker image run: | docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version @@ -28,8 +26,3 @@ jobs: run: | docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version docker run backup-utils-alpine:${GITHUB_RUN_ID} rsync --version - - name: Run tests in Rsync source Docker image - run: | - docker run backup-utils-rsync:${GITHUB_RUN_ID} ghe-backup --version - docker run backup-utils-rsync:${GITHUB_RUN_ID} rsync --version - diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index 96c32cbbb..c59e4ede1 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -1,4 +1,4 @@ -name: Update Rsync Tag in Dockerfile.rsync +name: Update Rsync Tag in Dockerfile on: schedule: @@ -17,17 +17,17 @@ jobs: run: | curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[0].name' | xargs -I {} echo "::set-output name=latest_tag::{}" - - name: Update Dockerfile.rsync with latest tag + - name: Update Dockerfile with latest tag run: | - sed -i -E "s/RSYNC_TAG=[0-9\.]+/RSYNC_TAG=${{ steps.latest_tag.outputs.latest_tag }}/g" Dockerfile.rsync + sed -i -E "s/RSYNC_TAG=[0-9\.]+/RSYNC_TAG=${{ steps.latest_tag.outputs.latest_tag }}/g" Dockerfile - name: Create Pull Request for tag update uses: peter-evans/create-pull-request@v3 with: token: ${{ secrets.GITHUB_TOKEN }} - commit-message: "Update rsync tag in Dockerfile.rsync" - title: "Update rsync tag in Dockerfile.rsync" - body: "This PR updates the rsync tag in the Dockerfile.rsync to the latest tagged version." + commit-message: "Update rsync tag in Dockerfile" + title: "Update rsync tag in Dockerfile" + body: "This PR updates the rsync tag in the Dockerfile to the latest tagged version." branch: "update-rsync-tag" base: "master" path: "." diff --git a/Dockerfile b/Dockerfile index 9e016dc03..667739729 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,71 @@ -FROM ubuntu:focal +# Multi stage build for backup-utils +# Build layer is for compiling rsync from source +# Runtime layer is for running backup-utils +# https://docs.docker.com/develop/develop-images/multistage-build/ +# https://docs.docker.com/engine/userguide/eng-image/multistage-build/ -RUN apt-get -q -y update && \ - apt-get install -y --no-install-recommends \ +# Build layer +FROM ubuntu:focal AS build + +# Install build dependencies +RUN apt-get update && apt-get install --no-install-recommends -y \ + gcc \ + g++ \ + gawk \ + autoconf \ + make \ + automake \ + python3-cmarkgfm \ + acl \ + libacl1-dev \ + attr \ + libattr1-dev \ + libxxhash-dev \ + libzstd-dev \ + liblz4-dev \ + libssl-dev \ + git \ + jq \ + curl \ tar \ - rsync \ + gzip \ ca-certificates \ - ssh \ + && rm -rf /var/lib/apt/lists/* + +# Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag +ARG RSYNC_TAG=v3.2.7 +RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz +RUN mkdir -p /rsync-${RSYNC_TAG}&& tar -xzf ${RSYNC_TAG}.tar.gz -C /rsync-${RSYNC_TAG} --strip-components=1 && ls -la +# Change to the working directory of the rsync source +WORKDIR /rsync-${RSYNC_TAG} +RUN ls -la && ./configure +RUN make +RUN make install + +# Reset working directory +WORKDIR / + +# Runtime layer +FROM ubuntu:focal AS runtime + +# Install runtime dependencies - bash, git, OpenSSH 5.6 or newer, and jq v1.5 or newer. +RUN apt-get update && apt-get install --no-install-recommends -y \ + bash \ git \ + openssh-client \ + jq \ moreutils \ - gawk \ + gawk \ + ca-certificates \ + xxhash \ && rm -rf /var/lib/apt/lists/* +# Copy rsync from build layer +COPY --from=build /usr/local/bin/rsync /usr/local/bin/rsync + +# Copy backup-utils from repository into /backup-utils COPY ./ /backup-utils/ + WORKDIR /backup-utils RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init diff --git a/Dockerfile.rsync b/Dockerfile.rsync deleted file mode 100644 index 667739729..000000000 --- a/Dockerfile.rsync +++ /dev/null @@ -1,74 +0,0 @@ -# Multi stage build for backup-utils -# Build layer is for compiling rsync from source -# Runtime layer is for running backup-utils -# https://docs.docker.com/develop/develop-images/multistage-build/ -# https://docs.docker.com/engine/userguide/eng-image/multistage-build/ - -# Build layer -FROM ubuntu:focal AS build - -# Install build dependencies -RUN apt-get update && apt-get install --no-install-recommends -y \ - gcc \ - g++ \ - gawk \ - autoconf \ - make \ - automake \ - python3-cmarkgfm \ - acl \ - libacl1-dev \ - attr \ - libattr1-dev \ - libxxhash-dev \ - libzstd-dev \ - liblz4-dev \ - libssl-dev \ - git \ - jq \ - curl \ - tar \ - gzip \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -# Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag -ARG RSYNC_TAG=v3.2.7 -RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz -RUN mkdir -p /rsync-${RSYNC_TAG}&& tar -xzf ${RSYNC_TAG}.tar.gz -C /rsync-${RSYNC_TAG} --strip-components=1 && ls -la -# Change to the working directory of the rsync source -WORKDIR /rsync-${RSYNC_TAG} -RUN ls -la && ./configure -RUN make -RUN make install - -# Reset working directory -WORKDIR / - -# Runtime layer -FROM ubuntu:focal AS runtime - -# Install runtime dependencies - bash, git, OpenSSH 5.6 or newer, and jq v1.5 or newer. -RUN apt-get update && apt-get install --no-install-recommends -y \ - bash \ - git \ - openssh-client \ - jq \ - moreutils \ - gawk \ - ca-certificates \ - xxhash \ - && rm -rf /var/lib/apt/lists/* - -# Copy rsync from build layer -COPY --from=build /usr/local/bin/rsync /usr/local/bin/rsync - -# Copy backup-utils from repository into /backup-utils -COPY ./ /backup-utils/ - -WORKDIR /backup-utils - -RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init - -ENTRYPOINT ["/backup-utils/share/github-backup-utils/ghe-docker-init"] -CMD ["ghe-host-check"] From ea92db7b838ad7f8760144e4c2099cfeb840f320 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 31 May 2023 17:46:13 +0000 Subject: [PATCH 1911/2421] remove ghe-prune-snapshots call --- bin/ghe-backup | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index ad8147f82..c491e2ea2 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -284,15 +284,13 @@ if [ "$GHE_BACKUP_FSCK" = "yes" ]; then fi # If everything was successful, mark the snapshot as complete, update the -# current symlink to point to the new snapshot and prune expired and failed -# snapshots. +# current symlink to point to the new snapshot +# Expired and failed snapshots to be pruned separately if [ -z "$failures" ]; then rm "incomplete" rm -f "../current" ln -s "$GHE_SNAPSHOT_TIMESTAMP" "../current" - - ghe-prune-snapshots fi END_TIME=$(date +%s) From 95daff216c992e288e41fa4effed8dbe343f2d57 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 31 May 2023 19:34:31 +0000 Subject: [PATCH 1912/2421] add pruning variable --- backup.config-example | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backup.config-example b/backup.config-example index 2ca0551fa..ac068a383 100644 --- a/backup.config-example +++ b/backup.config-example @@ -9,12 +9,13 @@ GHE_HOSTNAME="github.example.com" # elsewhere for backing up to a separate partition / mount point. GHE_DATA_DIR="data" -# The number of backup snapshots to retain. Old snapshots are pruned after each -# successful ghe-backup run. This option should be tuned based on the frequency +# The number of backup snapshots to retain. Old snapshots are to be pruned separately +# after successful backups. This option should be tuned based on the frequency # of scheduled backup runs. If backups are scheduled hourly, snapshots will be # available for the past N hours; if backups are scheduled daily, snapshots will -# be available for the past N days ... +# be available for the past N days. Pruning enablement defaults to 'yes' GHE_NUM_SNAPSHOTS=10 +#GHE_PRUNING_ENABLED=no # The hostname of the GitHub appliance to restore. If you've set up a separate # GitHub appliance to act as a standby for recovery, specify its IP or hostname @@ -97,4 +98,4 @@ GHE_NUM_SNAPSHOTS=10 #EXTERNAL_DATABASE_RESTORE_SCRIPT="/bin/false" # If set to 'yes', Pages data will be included in backup and restore. Defaults to 'yes' -#GHE_BACKUP_PAGES=no \ No newline at end of file +#GHE_BACKUP_PAGES=no From dc7993eb7eca44f607ff15c67e6afb6b3674361c Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 1 Jun 2023 14:14:14 +0000 Subject: [PATCH 1913/2421] add rsync warn msg --- backup.config-example | 5 ++++- bin/ghe-host-check | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backup.config-example b/backup.config-example index 2ca0551fa..4c78a103b 100644 --- a/backup.config-example +++ b/backup.config-example @@ -42,6 +42,9 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_EXTRA_RSYNC_OPTS="" +# If enabled and set to 'no', rsync warning message during backups will be suppressed. +#RSYNC_WARNING=no + # If set to 'yes', logging output will be colorized. # @@ -97,4 +100,4 @@ GHE_NUM_SNAPSHOTS=10 #EXTERNAL_DATABASE_RESTORE_SCRIPT="/bin/false" # If set to 'yes', Pages data will be included in backup and restore. Defaults to 'yes' -#GHE_BACKUP_PAGES=no \ No newline at end of file +#GHE_BACKUP_PAGES=no diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 6a2a66357..30c896a80 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -213,9 +213,11 @@ DATA_TRANSFER_SIZE echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 exit 1 - else - echo "rsync ${rsync_version} >= required ($min_rsync)" 1>&2 + elif awk "BEGIN {exit !($rsync_version < 3.2.5)}" &> /dev/null && [ "$RSYNC_WARNING" != "no" ]; then + warn_mesg="**WARNING: rsync version $rsync_version on backup host is less than 3.2.5. For more details, please read documentation at https://github.com/github/backup-utils/blob/master/docs/requirements.md#april-2023-update-of-rsync-requirements\nIf you feel this warning doesn't apply anymore, you can disable it by updating RSYNC_WARNING to 'no' in your backup.config file.\n" + echo -e $warn_mesg 1>&2 fi + echo "rsync ${rsync_version} >= required ($min_rsync)" 1>&2 ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1 | tr -cd '[:digit:].\n') if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then From fb7a6d3ccfa80e4a05a98c47ad09f17342e84d3e Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 1 Jun 2023 21:26:15 +0000 Subject: [PATCH 1914/2421] fix shellcheck err --- bin/ghe-host-check | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 30c896a80..9dac0acba 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -144,7 +144,7 @@ if [ -z "$supported" ]; then exit 1 fi -if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then +if [[ "$CALLING_SCRIPT" != "ghe-backup" ]]; then # Bring in the requirements file min_rsync="" min_openssh="" @@ -214,8 +214,9 @@ DATA_TRANSFER_SIZE echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 exit 1 elif awk "BEGIN {exit !($rsync_version < 3.2.5)}" &> /dev/null && [ "$RSYNC_WARNING" != "no" ]; then - warn_mesg="**WARNING: rsync version $rsync_version on backup host is less than 3.2.5. For more details, please read documentation at https://github.com/github/backup-utils/blob/master/docs/requirements.md#april-2023-update-of-rsync-requirements\nIf you feel this warning doesn't apply anymore, you can disable it by updating RSYNC_WARNING to 'no' in your backup.config file.\n" - echo -e $warn_mesg 1>&2 + warn_mesg=("**WARNING: rsync version $rsync_version on backup host is less than 3.2.5. For more details, please read documentation at https://github.com/github/backup-utils/blob/master/docs/requirements.md#april-2023-update-of-rsync-requirements" + "If you feel this warning doesn't apply anymore, you can disable it by updating RSYNC_WARNING to 'no' in your backup.config file.") + printf "%s\n" "${warn_mesg[@]}" 1>&2 fi echo "rsync ${rsync_version} >= required ($min_rsync)" 1>&2 From 8787e23573174939ae4062914f8942f8c91aecee Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 2 Jun 2023 11:24:59 -0400 Subject: [PATCH 1915/2421] Update bin/ghe-host-check Update warn_msg verbiage Co-authored-by: Quinn Murphy --- bin/ghe-host-check | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 9dac0acba..9273dcff6 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -214,9 +214,14 @@ DATA_TRANSFER_SIZE echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 exit 1 elif awk "BEGIN {exit !($rsync_version < 3.2.5)}" &> /dev/null && [ "$RSYNC_WARNING" != "no" ]; then - warn_mesg=("**WARNING: rsync version $rsync_version on backup host is less than 3.2.5. For more details, please read documentation at https://github.com/github/backup-utils/blob/master/docs/requirements.md#april-2023-update-of-rsync-requirements" - "If you feel this warning doesn't apply anymore, you can disable it by updating RSYNC_WARNING to 'no' in your backup.config file.") - printf "%s\n" "${warn_mesg[@]}" 1>&2 +echo << WARN_MSG +**WARNING:** rsync version $rsync_version on backup host is less than 3.2.5, which could result in performance degradation. + +For more details, please read documentation at https://github.com/github/backup-utils/blob/master/docs/requirements.md#april-2023-update-of-rsync-requirements" + +You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.config file. + +WARN_MSG fi echo "rsync ${rsync_version} >= required ($min_rsync)" 1>&2 From 24d91b9e35a54b690afacf2ef17ea279c1681d31 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 2 Jun 2023 15:47:11 +0000 Subject: [PATCH 1916/2421] update warn_msg text --- bin/ghe-host-check | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 9273dcff6..d020d78a4 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -144,7 +144,7 @@ if [ -z "$supported" ]; then exit 1 fi -if [[ "$CALLING_SCRIPT" != "ghe-backup" ]]; then +if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then # Bring in the requirements file min_rsync="" min_openssh="" @@ -213,11 +213,11 @@ DATA_TRANSFER_SIZE echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 exit 1 - elif awk "BEGIN {exit !($rsync_version < 3.2.5)}" &> /dev/null && [ "$RSYNC_WARNING" != "no" ]; then -echo << WARN_MSG + elif [[ $rsync_version < 3.2.5 ]] && [[ $RSYNC_WARNING != "no" ]]; then + cat << WARN_MSG 1>&2 **WARNING:** rsync version $rsync_version on backup host is less than 3.2.5, which could result in performance degradation. -For more details, please read documentation at https://github.com/github/backup-utils/blob/master/docs/requirements.md#april-2023-update-of-rsync-requirements" +For more details, please read documentation at https://github.com/github/backup-utils/blob/master/docs/requirements.md#april-2023-update-of-rsync-requirements You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.config file. From 64905db77228de10dedc7459086ff56f2f57e6c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jun 2023 20:59:50 +0000 Subject: [PATCH 1917/2421] Bump peter-evans/create-pull-request from 3 to 5 Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 3 to 5. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v3...v5) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/rsync-docker-bump.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index c59e4ede1..6012e3986 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -22,7 +22,7 @@ jobs: sed -i -E "s/RSYNC_TAG=[0-9\.]+/RSYNC_TAG=${{ steps.latest_tag.outputs.latest_tag }}/g" Dockerfile - name: Create Pull Request for tag update - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Update rsync tag in Dockerfile" From 46a3986db3bd2d4ab853ad75af0e16bc576baccc Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 6 Jun 2023 20:36:25 -0400 Subject: [PATCH 1918/2421] Update bin/ghe-restore Co-authored-by: Krayon --- bin/ghe-restore | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index f2b13bc36..89c5f6c31 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -274,28 +274,28 @@ fi # taking into account the options passed to the script and the appliance configuration # calculate restore steps OPTIONAL_STEPS=0 -# Cluster restores add an additional step +# Cluster restores add an additional step if $CLUSTER ; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi -# Restoring UUID +# Restoring UUID if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi # Restoring Actions if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi -# Restoring minio +fi +# Restoring minio if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi -# Restoring Elasticsearch +# Restoring Elasticsearch if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi # Restoring audit log -if $CLUSTER || [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 2.12.9)" ]; then +if $CLUSTER || [ "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.12.9)" ]; then if [[ "$GHE_RESTORE_SKIP_AUDIT_LOG" != "yes" ]]; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi @@ -309,9 +309,9 @@ export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 6)) init-progress export PROGRESS_TYPE="Restore" -echo $PROGRESS_TYPE > /tmp/backup-utils-progress-type +echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type export PROGRESS=0 # Used to track progress of restore -echo $PROGRESS > /tmp/backup-utils-progress +echo "$PROGRESS" > /tmp/backup-utils-progress # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) From 9cb975997cedb0869fc17b8105abc4311ab3ad0a Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 6 Jun 2023 20:37:13 -0400 Subject: [PATCH 1919/2421] Update bin/ghe-backup Co-authored-by: Krayon --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index ec6a785ff..58f759afd 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -47,7 +47,7 @@ export CALLING_SCRIPT="ghe-backup" # Setup progress tracking init-progress export PROGRESS_TYPE="Backup" -echo $PROGRESS_TYPE > /tmp/backup-utils-progress-type +echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type export PROGRESS=0 # Used to track progress of backup echo $PROGRESS > /tmp/backup-utils-progress export PROGRESS_TOTAL=18 # Maximum number of steps in backup From 13b6168c7f2e4e088e3c4a799a01a65e8796023b Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 6 Jun 2023 20:37:44 -0400 Subject: [PATCH 1920/2421] Update bin/ghe-backup Co-authored-by: Krayon --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 58f759afd..414eaa97a 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -131,7 +131,7 @@ ghe_restore_check # Check to see if there is a running backup if [ -h ../in-progress ]; then - log_error "Detected a backup already in progress from a previous version of ghe-backup. \nIf there is no backup in progress anymore, please remove \nthe $GHE_DATA_DIR/in-progress file." 1>&2 + log_error "Detected a backup already in progress from a previous version of ghe-backup. \nIf there is no backup in progress anymore, please remove \nthe $GHE_DATA_DIR/in-progress file." >&2 exit 1 fi From dd47e89d258504583b6594b3b913af96727642a6 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 6 Jun 2023 20:37:57 -0400 Subject: [PATCH 1921/2421] Update bin/ghe-progress Co-authored-by: Krayon --- bin/ghe-progress | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/ghe-progress b/bin/ghe-progress index ef2964170..da5ead976 100755 --- a/bin/ghe-progress +++ b/bin/ghe-progress @@ -11,20 +11,20 @@ while true; do case "$1" in - -o|--once) - ONCE=1; - shift + -o|--once) + ONCE=1 + shift ;; -h|--help) export GHE_SHOW_HELP=true shift ;; - -*) - echo "Unknown option: $1" >&2; - exit 1 + -*) + echo "Unknown option: $1" >&2 + exit 1 ;; - *) - break + *) + break ;; esac done From fdaeb0e05999e97a950909b225a4f7729bd434bc Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 6 Jun 2023 20:38:24 -0400 Subject: [PATCH 1922/2421] Update bin/ghe-restore Co-authored-by: Krayon --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 89c5f6c31..a27f0680e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -454,7 +454,7 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" bm_end "$(basename $0) - Restore UUID" - fi +fi if is_external_database_snapshot; then From 162aa81ca1199cf2612a0f8aacf16138af06c632 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 6 Jun 2023 20:38:36 -0400 Subject: [PATCH 1923/2421] Update bin/ghe-backup Co-authored-by: Krayon --- bin/ghe-backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 414eaa97a..48d8da85b 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -49,7 +49,7 @@ init-progress export PROGRESS_TYPE="Backup" echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type export PROGRESS=0 # Used to track progress of backup -echo $PROGRESS > /tmp/backup-utils-progress +echo "$PROGRESS" > /tmp/backup-utils-progress export PROGRESS_TOTAL=18 # Maximum number of steps in backup # Check to make sure moreutils parallel is installed and working properly From e90305c29ba4f8aef2a9530557bd0b6b682729ab Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 6 Jun 2023 20:38:57 -0400 Subject: [PATCH 1924/2421] Update share/github-backup-utils/ghe-backup-config Co-authored-by: Krayon --- share/github-backup-utils/ghe-backup-config | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 573db1c83..72449a7a3 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -55,7 +55,6 @@ fi PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # shellcheck source=share/github-backup-utils/bm.sh . "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" -. "$GHE_BACKUP_ROOT/share/github-backup-utils/backup-utils-progress" # Save off GHE_HOSTNAME from the environment since we want it to override the # backup.config value when set. GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" From ef86f4f789af65442d5cbe441cc736cefa78f89d Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 7 Jun 2023 12:46:21 -0400 Subject: [PATCH 1925/2421] Update ghe-backup-config --- share/github-backup-utils/ghe-backup-config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 72449a7a3..f3e620bfa 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -183,7 +183,8 @@ fi PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # shellcheck source=share/github-backup-utils/bm.sh . "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" - +# shellcheck source=share/github-backup-utils/track-progress +. "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" # Save off GHE_HOSTNAME from the environment since we want it to override the # backup.config value when set. GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" From 4a86d512234820449a85d8718a703af105bd8eb1 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 7 Jun 2023 15:54:06 -0400 Subject: [PATCH 1926/2421] remove extraneous line --- bin/ghe-restore | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index a27f0680e..1efc2dad1 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -449,7 +449,6 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then log_info "Restoring UUID ..." bm_start "$(basename $0) - Restore UUID" - cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid" | ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" <"$GHE_RESTORE_SNAPSHOT_PATH/uuid" ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" From 0cf8e94631e78a09aad3f8d8d37af0f4151a071f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 7 Jun 2023 16:16:49 -0400 Subject: [PATCH 1927/2421] add set -e --- bin/ghe-progress | 1 + share/github-backup-utils/track-progress | 1 + 2 files changed, 2 insertions(+) diff --git a/bin/ghe-progress b/bin/ghe-progress index da5ead976..d28d80813 100755 --- a/bin/ghe-progress +++ b/bin/ghe-progress @@ -8,6 +8,7 @@ #/ Options: #/ --once Don't loop, just print the current progress once. # +set -e while true; do case "$1" in diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index a9930d627..3f67ca9e8 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -1,5 +1,6 @@ #!/usr/bin/env bash #/ track-progress: track progress of backup or restore tasks +set -e # Current version is working solely with backups progress(){ From 2c025b2ee6aa76410221568dc24fca0b123f2604 Mon Sep 17 00:00:00 2001 From: boxofyellow <54955040+boxofyellow@users.noreply.github.com> Date: Wed, 7 Jun 2023 17:26:21 -0400 Subject: [PATCH 1928/2421] Allow the caller to handle setting failures --- share/github-backup-utils/ghe-backup-mssql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index ead33f6bc..d452c36a2 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -337,7 +337,7 @@ if [ -n "$backup_type" ]; then fi bm_start "$(basename "$0")" - ghe_ssh_mssql -- "$backup_command" || failures="$failures mssql" + ghe_ssh_mssql -- "$backup_command" bm_end "$(basename "$0")" # Configure the backup cadence on the appliance, which is used for diagnostics From 16de4b2aeb9b39c7e3640c5ea737cb02c969f6e1 Mon Sep 17 00:00:00 2001 From: boxofyellow Date: Wed, 7 Jun 2023 17:43:36 -0400 Subject: [PATCH 1929/2421] fix linter problems --- share/github-backup-utils/ghe-backup-mssql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index d452c36a2..b1d97b8de 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -30,11 +30,11 @@ export_tool_available() { } ghe_ssh_mssql() { - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "$@" + ghe-ssh "$opts" "$ssh_config_file_opt" "$GHE_MSSQL_PRIMARY_HOST" "$@" } cleanup() { - rm -rf $tempdir + rm -rf "$tempdir" } trap 'cleanup' EXIT INT @@ -69,10 +69,10 @@ add_minute() { # Expect date string in the format of yyyymmddTHHMMSS # Here parse date differently depending on GNU Linux vs BSD MacOS if date -v -1d > /dev/null 2>&1; then - echo "$(date -v +$2M -ujf'%Y%m%dT%H%M%S' $1 +%Y%m%dT%H%M%S)" + date -v +"$2"M -ujf'%Y%m%dT%H%M%S' "$1" +%Y%m%dT%H%M%S else dt=$1 - echo "$(date -u '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes")" + date -u '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes" fi } From 27e0ae54e0b243f27f7e4abeeabfaeab05b8a9b9 Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Thu, 8 Jun 2023 14:13:25 +0000 Subject: [PATCH 1930/2421] always restore column encryption keys --- bin/ghe-restore | 3 ++ .../ghe-restore-column-encryption-keys | 34 +++++++++++++++++++ .../github-backup-utils/ghe-restore-settings | 6 ---- 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100755 share/github-backup-utils/ghe-restore-column-encryption-keys diff --git a/bin/ghe-restore b/bin/ghe-restore index c0aae6ed9..ebd9d45bb 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -383,6 +383,9 @@ if $RESTORE_SETTINGS; then ghe-restore-settings "$GHE_HOSTNAME" fi +# Always restore column encryption keys +ghe-restoe-column-encryption-keys "$GHE_HOSTNAME" + # Make sure mysql and elasticsearch are prep'd and running before restoring. # These services will not have been started on appliances that have not been # configured yet. diff --git a/share/github-backup-utils/ghe-restore-column-encryption-keys b/share/github-backup-utils/ghe-restore-column-encryption-keys new file mode 100755 index 000000000..88b341eb6 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-column-encryption-keys @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-settings +#/ Restore settings from a snapshot to the given . +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# Path to snapshot dir we're restoring from +GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + +# Restore encrypted column encryption keying material if present +restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" + +# Restore encrypted column current encryption key if present +restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" + +bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index ad06f30a6..b489626c2 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -56,12 +56,6 @@ restore-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hm # Restore kredz.varz HMAC key if present. restore-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" -# Restore encrypted column encryption keying material if present -restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" - -# Restore encrypted column current encryption key if present -restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" - # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then log_info "Restoring SAML keys ..." From 716aa492a75c3011f95a67d31fef57a5eb338c5a Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 8 Jun 2023 12:11:12 -0400 Subject: [PATCH 1931/2421] Update ghe-restore --- bin/ghe-restore | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index 1efc2dad1..6a467dc64 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -576,6 +576,7 @@ if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then else log_info "Restoring data serially ..." 1>&3 for c in "${commands[@]}"; do + . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/bm.sh" eval "$c" done fi From eae0932e807ac3d3f673c64a5c1b49a1041bf618 Mon Sep 17 00:00:00 2001 From: boxofyellow Date: Thu, 8 Jun 2023 12:32:11 -0400 Subject: [PATCH 1932/2421] fix suggestions from the linter --- share/github-backup-utils/ghe-backup-mssql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index b1d97b8de..b5a3203fb 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -30,7 +30,7 @@ export_tool_available() { } ghe_ssh_mssql() { - ghe-ssh "$opts" "$ssh_config_file_opt" "$GHE_MSSQL_PRIMARY_HOST" "$@" + ghe-ssh "${opts[@]}" "${ssh_config_file_opt[@]}" "$GHE_MSSQL_PRIMARY_HOST" "$@" } cleanup() { @@ -55,8 +55,8 @@ isHA="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.ha" || true)" # get server hostnames under cluster and HA if [ "$GHE_BACKUP_STRATEGY" = "cluster" ] || [ "$isHA" = "true" ] ; then ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" + ssh_config_file_opt=("-F" "$ssh_config_file") + opts=("-o" "UserKnownHostsFile=/dev/null" "-o" "StrictHostKeyChecking=no" "-o" "PasswordAuthentication=no") ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" fi From 037e57afab7b3a11770d7cc17bd94dad4d62adc8 Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Thu, 8 Jun 2023 18:47:53 +0000 Subject: [PATCH 1933/2421] spelling --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index ebd9d45bb..b2f60da21 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -384,7 +384,7 @@ if $RESTORE_SETTINGS; then fi # Always restore column encryption keys -ghe-restoe-column-encryption-keys "$GHE_HOSTNAME" +ghe-restore-column-encryption-keys "$GHE_HOSTNAME" # Make sure mysql and elasticsearch are prep'd and running before restoring. # These services will not have been started on appliances that have not been From 2ab98ba0bc94f92d91ab856531325bcfb06e943f Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 8 Jun 2023 17:44:37 -0400 Subject: [PATCH 1934/2421] Fixing issues with parallel operations --- bin/ghe-restore | 8 ++---- share/github-backup-utils/ghe-restore-redis | 23 ++++++++++++++++ .../github-backup-utils/ghe-restore-ssh-keys | 26 +++++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 share/github-backup-utils/ghe-restore-redis create mode 100644 share/github-backup-utils/ghe-restore-ssh-keys diff --git a/bin/ghe-restore b/bin/ghe-restore index 6a467dc64..ae3b84ac4 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -505,9 +505,7 @@ fi cmd_title=$(log_info "Restoring Redis database ...") commands=(" echo \"$cmd_title\" -bm_start \"$(basename $0) - Restoring Redis\" -ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-redis' < \"$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb\" 1>&3 -bm_end \"$(basename $0) - Restoring Redis\"") +ghe-restore-redis \"$GHE_HOSTNAME\") cmd_title=$(log_info "Restoring Git Repositories ...") commands+=(" @@ -527,9 +525,7 @@ ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") cmd_title=$(log_info "Restoring SSH authorized keys ...") commands+=(" echo \"$cmd_title\" -bm_start \"$(basename $0) -Restoring SSH authorized keys\" -ghe-ssh \"$GHE_HOSTNAME\" -- 'ghe-import-authorized-keys' < \"$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json\" 1>&3 -bm_end \"$(basename $0) -Restoring SSH authorized keys\"") +ghe-restore-ssh-keys \"$GHE_HOSTNAME\" \"$GHE_RESTORE_SNAPSHOT_PATH\") cmd_title=$(log_info "Restoring storage data ...") commands+=(" diff --git a/share/github-backup-utils/ghe-restore-redis b/share/github-backup-utils/ghe-restore-redis new file mode 100644 index 000000000..9f23e806c --- /dev/null +++ b/share/github-backup-utils/ghe-restore-redis @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-redis +#/ Restore redis files from an rsync snapshot. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config" + +# Show usage and bail with no arguments +[[ -z ${*} ]] && print_usage + +# Grab host arg +GHE_HOSTNAME="${1}" + +bm_start "$(basename "${0}")" + +ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3 + +bm_end "$(basename "${0}")" \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-ssh-keys b/share/github-backup-utils/ghe-restore-ssh-keys new file mode 100644 index 000000000..8ac0e3d94 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-ssh-keys @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-ssh-keys +#/ Restore ssh keys from an rsync snapshot. +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config" + +# Show usage and bail with no arguments +[[ -z ${*} ]] && print_usage + +bm_start "$(basename "${0}")" + +# Grab host arg +GHE_HOSTNAME="${1}" +GHE_RESTORE_SNAPSHOT_PATH="${2}" + +bm_start "$(basename "${0}")" + +ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-authorized-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/authorized-keys.json" 1>&3 + +bm_end "$(basename "${0}")" \ No newline at end of file From b30999c3f13ce2ed05b92a6c82474a4663a9b522 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 8 Jun 2023 18:02:15 -0400 Subject: [PATCH 1935/2421] Fix quotes --- bin/{ghe-progress => ghe-backup-progress} | 4 ++-- bin/ghe-restore | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename bin/{ghe-progress => ghe-backup-progress} (91%) diff --git a/bin/ghe-progress b/bin/ghe-backup-progress similarity index 91% rename from bin/ghe-progress rename to bin/ghe-backup-progress index d28d80813..2f4b267fb 100755 --- a/bin/ghe-progress +++ b/bin/ghe-backup-progress @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#/ Usage: ghe-progress [--once] +#/ Usage: ghe-backup-progress [--once] #/ Tracks the completed steps of a backup or restore operation. #/ #/ By default the progress is printed every continuously or until a key is pressed. @@ -32,7 +32,7 @@ done check_for_progress_file() { if [ ! -f /tmp/backup-utils-progress-info ]; then - echo "No progress file found. has a backup or restore been started?" + echo "No progress file found. Has a backup or restore been started?" exit 1 fi } diff --git a/bin/ghe-restore b/bin/ghe-restore index ae3b84ac4..26ec6e0be 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -505,7 +505,7 @@ fi cmd_title=$(log_info "Restoring Redis database ...") commands=(" echo \"$cmd_title\" -ghe-restore-redis \"$GHE_HOSTNAME\") +ghe-restore-redis \"$GHE_HOSTNAME\"") cmd_title=$(log_info "Restoring Git Repositories ...") commands+=(" @@ -525,7 +525,7 @@ ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") cmd_title=$(log_info "Restoring SSH authorized keys ...") commands+=(" echo \"$cmd_title\" -ghe-restore-ssh-keys \"$GHE_HOSTNAME\" \"$GHE_RESTORE_SNAPSHOT_PATH\") +ghe-restore-ssh-keys \"$GHE_HOSTNAME\" \"$GHE_RESTORE_SNAPSHOT_PATH\"") cmd_title=$(log_info "Restoring storage data ...") commands+=(" From 1a8553716e6c51e79853c0bf9e149c7b5d0a6dec Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 8 Jun 2023 18:28:53 -0400 Subject: [PATCH 1936/2421] fix permissions --- share/github-backup-utils/ghe-restore-redis | 0 share/github-backup-utils/ghe-restore-ssh-keys | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 share/github-backup-utils/ghe-restore-redis mode change 100644 => 100755 share/github-backup-utils/ghe-restore-ssh-keys diff --git a/share/github-backup-utils/ghe-restore-redis b/share/github-backup-utils/ghe-restore-redis old mode 100644 new mode 100755 diff --git a/share/github-backup-utils/ghe-restore-ssh-keys b/share/github-backup-utils/ghe-restore-ssh-keys old mode 100644 new mode 100755 From bbf83854246ee60e7712451361d0f89d0471194c Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 8 Jun 2023 18:34:48 -0400 Subject: [PATCH 1937/2421] Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. --- bin/ghe-restore | 2 +- share/github-backup-utils/ghe-restore-redis | 3 +++ share/github-backup-utils/ghe-restore-ssh-keys | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 26ec6e0be..21fbc1fdb 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -505,7 +505,7 @@ fi cmd_title=$(log_info "Restoring Redis database ...") commands=(" echo \"$cmd_title\" -ghe-restore-redis \"$GHE_HOSTNAME\"") +ghe-restore-redis \"$GHE_HOSTNAME\" \"$GHE_RESTORE_SNAPSHOT_PATH\"") cmd_title=$(log_info "Restoring Git Repositories ...") commands+=(" diff --git a/share/github-backup-utils/ghe-restore-redis b/share/github-backup-utils/ghe-restore-redis index 9f23e806c..1bdfe7642 100755 --- a/share/github-backup-utils/ghe-restore-redis +++ b/share/github-backup-utils/ghe-restore-redis @@ -16,6 +16,9 @@ set -e # Grab host arg GHE_HOSTNAME="${1}" +# Grab snapshot path arg +GHE_RESTORE_SNAPSHOT_PATH="${2}" + bm_start "$(basename "${0}")" ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-redis' < "$GHE_RESTORE_SNAPSHOT_PATH/redis.rdb" 1>&3 diff --git a/share/github-backup-utils/ghe-restore-ssh-keys b/share/github-backup-utils/ghe-restore-ssh-keys index 8ac0e3d94..216803d7a 100755 --- a/share/github-backup-utils/ghe-restore-ssh-keys +++ b/share/github-backup-utils/ghe-restore-ssh-keys @@ -17,6 +17,8 @@ bm_start "$(basename "${0}")" # Grab host arg GHE_HOSTNAME="${1}" + +# Grab snapshot path arg GHE_RESTORE_SNAPSHOT_PATH="${2}" bm_start "$(basename "${0}")" From fbfb368ec7160078055c8683621d5d1fb854f8fe Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 9 Jun 2023 21:43:21 +0000 Subject: [PATCH 1938/2421] update review comments --- backup.config-example | 7 +++++-- bin/ghe-backup | 8 ++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/backup.config-example b/backup.config-example index ac068a383..16b19e83c 100644 --- a/backup.config-example +++ b/backup.config-example @@ -13,9 +13,12 @@ GHE_DATA_DIR="data" # after successful backups. This option should be tuned based on the frequency # of scheduled backup runs. If backups are scheduled hourly, snapshots will be # available for the past N hours; if backups are scheduled daily, snapshots will -# be available for the past N days. Pruning enablement defaults to 'yes' +# be available for the past N days ... GHE_NUM_SNAPSHOTS=10 -#GHE_PRUNING_ENABLED=no + +# Pruning snapshots can be scheduled outside of the backup process. If set to 'yes' +# ghe-pruning-snapshots will need to be invoked separately via cron +#GHE_PRUNING_SCHEDULED=yes # The hostname of the GitHub appliance to restore. If you've set up a separate # GitHub appliance to act as a standby for recovery, specify its IP or hostname diff --git a/bin/ghe-backup b/bin/ghe-backup index c491e2ea2..98f9b613c 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -284,13 +284,17 @@ if [ "$GHE_BACKUP_FSCK" = "yes" ]; then fi # If everything was successful, mark the snapshot as complete, update the -# current symlink to point to the new snapshot -# Expired and failed snapshots to be pruned separately +# current symlink to point to the new snapshot and prune expired and failed +# snapshots. if [ -z "$failures" ]; then rm "incomplete" rm -f "../current" ln -s "$GHE_SNAPSHOT_TIMESTAMP" "../current" + + if [[ $GHE_PRUNING_SCHEDULED != "yes" ]]; then + ghe-prune-snapshots + fi fi END_TIME=$(date +%s) From a64763b4c06436419fce4175c281e5292cb376ff Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 9 Jun 2023 21:54:38 +0000 Subject: [PATCH 1939/2421] add more descr --- backup.config-example | 6 +++--- bin/ghe-backup | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backup.config-example b/backup.config-example index 16b19e83c..ace758cca 100644 --- a/backup.config-example +++ b/backup.config-example @@ -9,11 +9,11 @@ GHE_HOSTNAME="github.example.com" # elsewhere for backing up to a separate partition / mount point. GHE_DATA_DIR="data" -# The number of backup snapshots to retain. Old snapshots are to be pruned separately -# after successful backups. This option should be tuned based on the frequency +# The number of backup snapshots to retain. Old snapshots are pruned after each +# successful ghe-backup run. This option should be tuned based on the frequency # of scheduled backup runs. If backups are scheduled hourly, snapshots will be # available for the past N hours; if backups are scheduled daily, snapshots will -# be available for the past N days ... +# be available for the past N days ... GHE_NUM_SNAPSHOTS=10 # Pruning snapshots can be scheduled outside of the backup process. If set to 'yes' diff --git a/bin/ghe-backup b/bin/ghe-backup index 98f9b613c..d4998532b 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -294,6 +294,8 @@ if [ -z "$failures" ]; then if [[ $GHE_PRUNING_SCHEDULED != "yes" ]]; then ghe-prune-snapshots + else + echo "Expired and incomplete snapshots to be pruned separately" fi fi From a3208df06d46c5da781c751857d1a2961371b2b0 Mon Sep 17 00:00:00 2001 From: Junior Eluhu Date: Mon, 12 Jun 2023 20:46:10 +0000 Subject: [PATCH 1940/2421] Bump version: 3.9.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 16 ++++++++++++++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index d020d78a4..252e84ee7 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -131,7 +131,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.6.0" +supported_minimum_version="3.7.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index fb6b9940b..ee3c73176 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,19 @@ +github-backup-utils (3.9.0) UNRELEASED; urgency=medium + + * Set restore status on all cluster nodes #274 + * Fix pages backups and restores in GitHub Enterprise 11.10 #275 + * Backup and restore custom CA certificates #281 + * Set the benchmark file path consistently #283 + * Suppress dd output noise #289 + * Track completeness of Elasticsearch JSON dumps #298 + * Use existing Elasticsearch indices to speed up transfer during a restore #310 + * Include the user data directory in the benchmark name #311 + * Use calculated routes when backing up storage data from a cluster #318 + * Refresh the existing indices when restoring Elasticsearch indices to cluster #328 + * Use git to generate short name for SSH multiplex control path #335 + + -- Junior Eluhu Mon, 12 Jun 2023 20:46:10 +0000 + github-backup-utils (3.8.0) focal; urgency=medium -- Daniel Johnson Tue, 07 Feb 2023 21:43:26 +0000 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 19811903a..a5c4c7633 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.8.0 +3.9.0 diff --git a/test/testlib.sh b/test/testlib.sh index e17fc3fd2..631049e30 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -43,7 +43,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.8.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.9.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 3d41d16ec700ebeb2ce13692b027848fdff5183e Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Mon, 12 Jun 2023 21:37:05 +0000 Subject: [PATCH 1941/2421] in-progress checks --- share/github-backup-utils/ghe-prune-snapshots | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index 3a73dfccc..fe4ae0ae5 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -20,21 +20,30 @@ prune_snapshot() { done } -# First prune all incomplete / failed snapshot directories -prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)" -prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) +# Prune if backup is not running +#if [ ! -f "$GHE_DATA_DIR/in-progress" ] && [ ! -f "$GHE_DATA_DIR/in-progress-restore" ]; then +# Check for backup or restore in-progress file +inprogress_file=$(find $GHE_DATA_DIR -maxdepth 1 -type f \( -name "in-progress" -o -name "in-progress-restore" \) -print -quit) +if [ -z "$inprogress_file" ]; then + # First prune all incomplete / failed snapshot directories + prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)" + prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) -if [ $prune_num -gt 0 ]; then - log_info Pruning $prune_num "failed snapshot(s) ..." - echo "$prune_dirs" | sed 's@/incomplete$@@' | prune_snapshot -fi + if [ $prune_num -gt 0 ]; then + log_info Pruning $prune_num "failed snapshot(s) ..." + echo "$prune_dirs" | sed 's@/incomplete$@@' | prune_snapshot + fi -# Now prune all expired snapshots. Keep GHE_NUM_SNAPSHOTS around. -snapshot_count=$(ls -1d "$GHE_DATA_DIR"/[0-9]* 2>/dev/null | wc -l) + # Now prune all expired snapshots. Keep GHE_NUM_SNAPSHOTS around. + snapshot_count=$(ls -1d "$GHE_DATA_DIR"/[0-9]* 2>/dev/null | wc -l) -if [ "$snapshot_count" -gt "$GHE_NUM_SNAPSHOTS" ]; then - prune_dirs="$(ls -1d "$GHE_DATA_DIR"/[0-9]* | sort -r | awk "NR>$GHE_NUM_SNAPSHOTS")" - prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) - log_info Pruning $prune_num "expired snapshot(s) ..." - echo "$prune_dirs" | prune_snapshot + if [ "$snapshot_count" -gt "$GHE_NUM_SNAPSHOTS" ]; then + prune_dirs="$(ls -1d "$GHE_DATA_DIR"/[0-9]* | sort -r | awk "NR>$GHE_NUM_SNAPSHOTS")" + prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) + log_info Pruning $prune_num "expired snapshot(s) ..." + echo "$prune_dirs" | prune_snapshot + fi +else + log_info "Detected a running backup/restore process, please wait until that process is complete to prune expired/incomplete snapshots." 1>&2 + log_info "If no such process is running, please remove the "$GHE_DATA_DIR/in-progress*" file and retry again." 1>&2 fi From 882c2e75a9ca31aede772d3487b3e6e70739590c Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Tue, 13 Jun 2023 15:02:53 +0000 Subject: [PATCH 1942/2421] code review comments --- .../github-backup-utils/ghe-restore-column-encryption-keys | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-column-encryption-keys b/share/github-backup-utils/ghe-restore-column-encryption-keys index 88b341eb6..7194bc1ee 100755 --- a/share/github-backup-utils/ghe-restore-column-encryption-keys +++ b/share/github-backup-utils/ghe-restore-column-encryption-keys @@ -1,6 +1,7 @@ #!/usr/bin/env bash -#/ Usage: ghe-restore-settings -#/ Restore settings from a snapshot to the given . +#/ Usage: ghe-restore-column-encryption-keys +#/ Restore the column encryption keys from a snapshot to the given . +#/ This script will be run automatically by `ghe-restore set -e # Bring in the backup configuration @@ -26,9 +27,11 @@ ghe_remote_version_required "$GHE_HOSTNAME" GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" # Restore encrypted column encryption keying material if present +log_info "Restoring encrypted column encryption keying material" restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" # Restore encrypted column current encryption key if present +log_info "Restoring encrypted column current encryption key" restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" bm_end "$(basename $0)" From 5351bac2fa2dbf8f144a6ea9fa7d4c57698f77f5 Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:54:12 +0000 Subject: [PATCH 1943/2421] export GHE_RESTORE_SNAPSHOT in restore column encryption keys --- share/github-backup-utils/ghe-restore-column-encryption-keys | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-restore-column-encryption-keys b/share/github-backup-utils/ghe-restore-column-encryption-keys index 7194bc1ee..952029143 100755 --- a/share/github-backup-utils/ghe-restore-column-encryption-keys +++ b/share/github-backup-utils/ghe-restore-column-encryption-keys @@ -25,6 +25,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Path to snapshot dir we're restoring from GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" +export GHE_RESTORE_SNAPSHOT # Restore encrypted column encryption keying material if present log_info "Restoring encrypted column encryption keying material" From 5d49ec263d86ff3b96f733bae95dbde8294b63fb Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Wed, 14 Jun 2023 15:36:58 +0000 Subject: [PATCH 1944/2421] add gamefiend suggestion --- share/github-backup-utils/ghe-restore-column-encryption-keys | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-column-encryption-keys b/share/github-backup-utils/ghe-restore-column-encryption-keys index 952029143..c21678157 100755 --- a/share/github-backup-utils/ghe-restore-column-encryption-keys +++ b/share/github-backup-utils/ghe-restore-column-encryption-keys @@ -24,8 +24,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" : ${GHE_RESTORE_SNAPSHOT:=current} # Path to snapshot dir we're restoring from -GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -export GHE_RESTORE_SNAPSHOT +: ${GHE_RESTORE_SNAPSHOT_PATH:="$GHE_DATA_DIR/current"} # Restore encrypted column encryption keying material if present log_info "Restoring encrypted column encryption keying material" From 9dbae1c836c22cb0d3ce597d3fc394a77df2ede5 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 14 Jun 2023 21:14:43 +0000 Subject: [PATCH 1945/2421] add test for scheduled pruning --- test/test-ghe-prune-snapshots.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/test-ghe-prune-snapshots.sh b/test/test-ghe-prune-snapshots.sh index a736134ae..989e3cd29 100755 --- a/test/test-ghe-prune-snapshots.sh +++ b/test/test-ghe-prune-snapshots.sh @@ -89,3 +89,19 @@ begin_test "ghe-prune-snapshots incomplete snapshot pruning" [ ! -d "$GHE_DATA_DIR/04" ] ) end_test + +begin_test "ghe-prune-snapshots scheduled snapshot pruning" +( + set -e + + generate_prune_files 5 + + pre_num_files=$(file_count_no_current) + + GHE_NUM_SNAPSHOTS=3 GHE_PRUNING_SCHEDULED=yes ghe-prune-snapshots + + post_num_files=$(file_count_no_current) + + [ "$pre_num_files" = "$post_num_files" ] +) +end_test From 70799ecbddd1f06714a357cf757cbfbdbdb9b79c Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 14 Jun 2023 21:33:05 +0000 Subject: [PATCH 1946/2421] update for backup --- test/test-ghe-prune-snapshots.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-prune-snapshots.sh b/test/test-ghe-prune-snapshots.sh index 989e3cd29..b288e7e0d 100755 --- a/test/test-ghe-prune-snapshots.sh +++ b/test/test-ghe-prune-snapshots.sh @@ -98,7 +98,7 @@ begin_test "ghe-prune-snapshots scheduled snapshot pruning" pre_num_files=$(file_count_no_current) - GHE_NUM_SNAPSHOTS=3 GHE_PRUNING_SCHEDULED=yes ghe-prune-snapshots + GHE_NUM_SNAPSHOTS=3 GHE_PRUNING_SCHEDULED=yes ghe-backup post_num_files=$(file_count_no_current) From 6357cf4605468cf067b7dfb892ee5ae8baf5f27a Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 14 Jun 2023 22:27:23 +0000 Subject: [PATCH 1947/2421] fix backup setup --- test/test-ghe-prune-snapshots.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-prune-snapshots.sh b/test/test-ghe-prune-snapshots.sh index b288e7e0d..d59068e24 100755 --- a/test/test-ghe-prune-snapshots.sh +++ b/test/test-ghe-prune-snapshots.sh @@ -93,6 +93,10 @@ end_test begin_test "ghe-prune-snapshots scheduled snapshot pruning" ( set -e + # Create the backup data dir and fake remote repositories dirs + mkdir -p "$GHE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" + + setup_test_data $GHE_REMOTE_DATA_USER_DIR generate_prune_files 5 @@ -102,6 +106,6 @@ begin_test "ghe-prune-snapshots scheduled snapshot pruning" post_num_files=$(file_count_no_current) - [ "$pre_num_files" = "$post_num_files" ] + [ "$((pre_num_files + 1))" = "$post_num_files" ] ) end_test From 2b8d5490f46a355fa96d701b01ecae74de284289 Mon Sep 17 00:00:00 2001 From: Joseph Franks Date: Thu, 15 Jun 2023 09:28:22 -0500 Subject: [PATCH 1948/2421] adjusting release script to support patch versions --- script/release | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/script/release b/script/release index a27194d4b..fd48e094c 100755 --- a/script/release +++ b/script/release @@ -32,6 +32,7 @@ GH_OWNER = ENV['GH_OWNER'] || 'github' GH_AUTHOR = ENV['GH_AUTHOR'] DEB_PKG_NAME = 'github-backup-utils' GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master' +GH_STABLE_BRANCH = ENV['GH_STABLE_BRANCH'] || 'stable' CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium @@ -137,7 +138,7 @@ def beautify_changes(changes) end def changelog - changes = `git log --pretty=oneline origin/stable...origin/#{GH_BASE_BRANCH} --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) + changes = `git log --pretty=oneline origin/#{GH_STABLE_BRANCH}...origin/#{GH_BASE_BRANCH} --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) raise 'Building the changelog failed' if $CHILD_STATUS != 0 changes @@ -228,12 +229,12 @@ def push_release_branch(version) end def update_stable_branch - `git checkout --quiet stable` + `git checkout --quiet #{GH_STABLE_BRANCH}` unless (out = `git merge --quiet --ff-only origin/#{GH_BASE_BRANCH}`) - warn "Merging #{GH_BASE_BRANCH} into stable failed:\n\n#{out}" + warn "Merging #{GH_BASE_BRANCH} into #{GH_STABLE_BRANCH} failed:\n\n#{out}" end - unless (out = `git push --quiet origin stable`) - warn "Failed pushing the stable branch:\n\n#{out}" + unless (out = `git push --quiet origin #{GH_STABLE_BRANCH}`) + warn "Failed pushing the #{GH_STABLE_BRANCH} branch:\n\n#{out}" end end From e12bbdd04522f3539f719bf6cb3514972f318b8b Mon Sep 17 00:00:00 2001 From: Joseph Franks Date: Thu, 15 Jun 2023 12:40:49 -0500 Subject: [PATCH 1949/2421] adjust backup-utils release script to better support patch branches --- script/release | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/script/release b/script/release index fd48e094c..7ab0daea2 100755 --- a/script/release +++ b/script/release @@ -31,8 +31,8 @@ GH_REPO = ENV['GH_REPO'] || 'backup-utils' GH_OWNER = ENV['GH_OWNER'] || 'github' GH_AUTHOR = ENV['GH_AUTHOR'] DEB_PKG_NAME = 'github-backup-utils' -GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master' -GH_STABLE_BRANCH = ENV['GH_STABLE_BRANCH'] || 'stable' +GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master' # TODO: should we even allow a default or require all params get set explicitly? +GH_STABLE_BRANCH = "" CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium @@ -138,6 +138,7 @@ def beautify_changes(changes) end def changelog + puts "building changelog by comparing origin/#{GH_STABLE_BRANCH}...origin/#{GH_BASE_BRANCH}" changes = `git log --pretty=oneline origin/#{GH_STABLE_BRANCH}...origin/#{GH_BASE_BRANCH} --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) raise 'Building the changelog failed' if $CHILD_STATUS != 0 @@ -334,9 +335,31 @@ def clean_up(version) `git branch --quiet -D tmp-packaging >/dev/null 2>&1` end +def is_base_branch_valid?(branch) + if branch == "master" || branch.match(/^\d+\.\d+-main$/) + return true + else + return false + end +end + #### All the action starts #### if $PROGRAM_NAME == __FILE__ begin + ## validate base branch. this must either be "master" or a release branch which will match the pattern "x.y-main" + raise "The branch #{GH_BASE_BRANCH} is not valid for releasing backup-utils. branch name must be master or match x.y-main" if !is_base_branch_valid?(GH_BASE_BRANCH) + + ## derive the proper stable branch. if the base branch is "master" the stable branch is just "stable" + ## if the base branch is a release branch, the stable branch will be "x.y-stable" + if GH_BASE_BRANCH == "master" + GH_STABLE_BRANCH = "stable" + else + GH_STABLE_BRANCH = GH_BASE_BRANCH.gsub(/-main$/, "-stable") + end + + puts "base branch = " + GH_BASE_BRANCH + puts "stable branch = " + GH_STABLE_BRANCH + args = ARGV.dup dry_run = false skip_version_bump_check = false @@ -456,7 +479,7 @@ if $PROGRAM_NAME == __FILE__ puts 'Cleaning up...' clean_up version - puts 'Updating stable branch...' + puts "Updating #{GH_STABLE_BRANCH} branch..." update_stable_branch puts 'Released!' From 14a25425934a8e7d747fd031a18b1a2caeb35e09 Mon Sep 17 00:00:00 2001 From: Joseph Franks Date: Thu, 15 Jun 2023 12:45:41 -0500 Subject: [PATCH 1950/2421] moving code to derive stable branch name into a function --- script/release | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/script/release b/script/release index 7ab0daea2..b7b61615e 100755 --- a/script/release +++ b/script/release @@ -343,19 +343,26 @@ def is_base_branch_valid?(branch) end end +def get_stable_branch_name(branch) + ## derive the proper stable branch. if the base branch is "master" the stable branch is just "stable" + ## if the base branch is a release branch, the stable branch will be "x.y-stable" + result = "" + if branch == "master" + result = "stable" + else + result = branch.gsub(/-main$/, "-stable") + end + + result +end + #### All the action starts #### if $PROGRAM_NAME == __FILE__ begin ## validate base branch. this must either be "master" or a release branch which will match the pattern "x.y-main" raise "The branch #{GH_BASE_BRANCH} is not valid for releasing backup-utils. branch name must be master or match x.y-main" if !is_base_branch_valid?(GH_BASE_BRANCH) - ## derive the proper stable branch. if the base branch is "master" the stable branch is just "stable" - ## if the base branch is a release branch, the stable branch will be "x.y-stable" - if GH_BASE_BRANCH == "master" - GH_STABLE_BRANCH = "stable" - else - GH_STABLE_BRANCH = GH_BASE_BRANCH.gsub(/-main$/, "-stable") - end + GH_STABLE_BRANCH = get_stable_branch_name(GH_BASE_BRANCH) puts "base branch = " + GH_BASE_BRANCH puts "stable branch = " + GH_STABLE_BRANCH From 5180d0c629b36aaba6041d40bbfc5be67cae2fab Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 16 Jun 2023 14:41:42 -0400 Subject: [PATCH 1951/2421] Update share/github-backup-utils/ghe-backup-config --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index f3e620bfa..c84055a42 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -703,7 +703,7 @@ restore-secret() { #initialize progress tracking by clearing out the temp files used to track init-progress() { - rm -f /tmp/backup-utils-progress-* + rm -f /tmp/backup-utils-progress* } From b60a3e61d54ddeb44123a44315c90ca5eed7b195 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Wed, 21 Jun 2023 20:26:20 +0000 Subject: [PATCH 1952/2421] doc update and prune timing --- docs/scheduling-backups.md | 14 +++++++++++++- share/github-backup-utils/ghe-prune-snapshots | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/scheduling-backups.md b/docs/scheduling-backups.md index 8d291021a..14916404d 100644 --- a/docs/scheduling-backups.md +++ b/docs/scheduling-backups.md @@ -1,4 +1,4 @@ -# Scheduling backups +# Scheduling backups & snapshot pruning Regular backups should be scheduled using `cron(8)` or similar command scheduling service on the backup host. The backup frequency will dictate the @@ -17,6 +17,13 @@ based on the frequency of backups. The ten most recent snapshots are retained by default. The number should be adjusted based on backup frequency and available storage. +By default all expired and incomplete snapshots are deleted at the end of the main +backup process `ghe-backup`. If pruning of these snapshots takes a long time you can +choose to disable the pruning process from the backup run and schedule it separately. +This can be achieved by enabling the `GHE_PRUNING_SCHEDULED` option in `backup.config`. +Please note if this option is enabled, you will need to schedule the pruning script `ghe-prune-snapshots` +using `cron` or similar command scheduling service on the backup host. + To schedule hourly backup snapshots with verbose informational output written to a log file and errors generating an email: @@ -30,5 +37,10 @@ To schedule nightly backup snapshots instead, use: 0 0 * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +To schedule daily snapshot pruning, use: + + MAILTO=admin@example.com + + 0 3 * * * /opt/backup-utils/share/github-backup-utils/ghe-prune-snapshots 1>>/opt/backup-utils/prune-snapshots.log 2>&1 [1]: https://en.wikipedia.org/wiki/Recovery_point_objective diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index fe4ae0ae5..9071293ad 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -24,7 +24,7 @@ prune_snapshot() { #if [ ! -f "$GHE_DATA_DIR/in-progress" ] && [ ! -f "$GHE_DATA_DIR/in-progress-restore" ]; then # Check for backup or restore in-progress file inprogress_file=$(find $GHE_DATA_DIR -maxdepth 1 -type f \( -name "in-progress" -o -name "in-progress-restore" \) -print -quit) -if [ -z "$inprogress_file" ]; then +if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then # First prune all incomplete / failed snapshot directories prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) @@ -43,7 +43,7 @@ if [ -z "$inprogress_file" ]; then log_info Pruning $prune_num "expired snapshot(s) ..." echo "$prune_dirs" | prune_snapshot fi -else +elif [ "$CALLING_SCRIPT" != "ghe-backup" ] && [ -n "$inprogress_file" ]; then log_info "Detected a running backup/restore process, please wait until that process is complete to prune expired/incomplete snapshots." 1>&2 log_info "If no such process is running, please remove the "$GHE_DATA_DIR/in-progress*" file and retry again." 1>&2 fi From 6e4c42b5897b8fd46324b55e284b0375b43031ca Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Wed, 21 Jun 2023 21:19:17 +0000 Subject: [PATCH 1953/2421] update check --- share/github-backup-utils/ghe-prune-snapshots | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index 9071293ad..0da56df97 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -24,7 +24,7 @@ prune_snapshot() { #if [ ! -f "$GHE_DATA_DIR/in-progress" ] && [ ! -f "$GHE_DATA_DIR/in-progress-restore" ]; then # Check for backup or restore in-progress file inprogress_file=$(find $GHE_DATA_DIR -maxdepth 1 -type f \( -name "in-progress" -o -name "in-progress-restore" \) -print -quit) -if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then +if [[ "$CALLING_SCRIPT" == "ghe-backup" ]] || [ -z "$inprogress_file" ]; then # First prune all incomplete / failed snapshot directories prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) From c500539ed3338a51ff9239c86799b15994bbfe22 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Mon, 26 Jun 2023 20:48:09 +0000 Subject: [PATCH 1954/2421] Update verbiage --- docs/scheduling-backups.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/scheduling-backups.md b/docs/scheduling-backups.md index 14916404d..87eefc14c 100644 --- a/docs/scheduling-backups.md +++ b/docs/scheduling-backups.md @@ -18,7 +18,7 @@ default. The number should be adjusted based on backup frequency and available storage. By default all expired and incomplete snapshots are deleted at the end of the main -backup process `ghe-backup`. If pruning of these snapshots takes a long time you can +backup process `ghe-backup`. If pruning these snapshots takes a long time you can choose to disable the pruning process from the backup run and schedule it separately. This can be achieved by enabling the `GHE_PRUNING_SCHEDULED` option in `backup.config`. Please note if this option is enabled, you will need to schedule the pruning script `ghe-prune-snapshots` From 8c3d680d45dfe4f9e17c0216aaab15a253a167d5 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:08:49 +0000 Subject: [PATCH 1955/2421] update available_space check --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index d020d78a4..586739916 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -186,7 +186,7 @@ actions: $actions_disk_size MB mssql: $mssql_disk_size MB DATA_TRANSFER_SIZE - if [[ $available_space -lt $min_disk_req ]]; then + if [[ $((available_space / (1024 * 1024))) -lt $min_disk_req ]]; then echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2 exit 1 fi From 7c57bd178163bf576ee75d43257ab925c3b3ab7e Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:20:42 +0000 Subject: [PATCH 1956/2421] Add versioning for backup and restore of encryption keys * only backup encryption keying material in versions 3.7+ * only backup current encryption key in versions 3.8+ * adds tests --- share/github-backup-utils/ghe-backup-settings | 12 +++- .../ghe-restore-column-encryption-keys | 17 ++++-- test/test-ghe-backup.sh | 58 ++++++++++++++++++- test/test-ghe-restore.sh | 58 ++++++++++++++++++- 4 files changed, 133 insertions(+), 12 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index c71085a0b..c12abcd92 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -78,8 +78,16 @@ backup-secret "management console password" "manage-password" "secrets.manage" backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" -backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" -backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" + +# backup encryption keying material for GHES 3.7.0 onwards +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then + backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" +fi + +# backup current encryption key for GHES 3.8.0 onwards +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then + backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" +fi # Backup argon secrets for multiuser from ghes version 3.8 onwards if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then diff --git a/share/github-backup-utils/ghe-restore-column-encryption-keys b/share/github-backup-utils/ghe-restore-column-encryption-keys index c21678157..d30cacd51 100755 --- a/share/github-backup-utils/ghe-restore-column-encryption-keys +++ b/share/github-backup-utils/ghe-restore-column-encryption-keys @@ -26,12 +26,17 @@ ghe_remote_version_required "$GHE_HOSTNAME" # Path to snapshot dir we're restoring from : ${GHE_RESTORE_SNAPSHOT_PATH:="$GHE_DATA_DIR/current"} -# Restore encrypted column encryption keying material if present -log_info "Restoring encrypted column encryption keying material" -restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" +# Restore encrypted column encryption keying material for GHES 3.7.0 onward +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then + log_info "Restoring encrypted column encryption keying material" + restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" +fi + +# Restore encrypted column current encryption key for GHES 3.8.0 onwards +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then + log_info "Restoring encrypted column current encryption key" + restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" +fi -# Restore encrypted column current encryption key if present -log_info "Restoring encrypted column current encryption key" -restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" bm_end "$(basename $0)" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 135b26170..dd8563528 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -555,7 +555,18 @@ begin_test "ghe-backup takes backup of kredz-varz settings" ) end_test -begin_test "ghe-backup takes backup of encrypted column encryption keying material" +begin_test "ghe-backup does not take backup of encrypted column encryption keying material for versions below 3.7.0" +( + GHE_REMOTE_VERSION=2.1.10 ghe-backup -v | grep -q "encrypted column encryption keying material not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/encrypted-column-keying-material" ] + + GHE_REMOTE_VERSION=3.6.1 ghe-backup -v | grep -q "encrypted column encryption keying material not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/encrypted-column-keying-material" ] + +) +end_test + +begin_test "ghe-backup takes backup of encrypted column encryption keying material for versions 3.7.0+" ( set -e @@ -567,6 +578,22 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" done + # GHES version 3.7.0 + GHE_REMOTE_VERSION=3.7.0 + + ghe-backup + + required_files=( + "encrypted-column-encryption-keying-material" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done + + # GHES version 3.8.0 + GHE_REMOTE_VERSION=3.8.0 + ghe-backup required_files=( @@ -580,7 +607,18 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi ) end_test -begin_test "ghe-backup takes backup of encrypted column current encryption key" +begin_test "ghe-backup does not take backup of encrypted column current encryption key for versions below 3.8.0" +( + GHE_REMOTE_VERSION=2.1.10 ghe-backup -v | grep -q "encrypted column current encryption key not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/encrypted-column-current-encryption-key" ] + + GHE_REMOTE_VERSION=3.7.0 ghe-backup -v | grep -q "encrypted column current encryption key not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/encrypted-column-current-encryption-key" ] + +) +end_test + +begin_test "ghe-backup takes backup of encrypted column current encryption key for versions 3.8.0+" ( set -e @@ -592,6 +630,22 @@ begin_test "ghe-backup takes backup of encrypted column current encryption key" ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" done + # GHES version 3.8.0 + GHE_REMOTE_VERSION=3.8.0 + + ghe-backup + + required_files=( + "encrypted-column-current-encryption-key" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done + + # GHES version 3.9.0 + GHE_REMOTE_VERSION=3.9.0 + ghe-backup required_files=( diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index c39c042b7..753b42196 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -281,7 +281,18 @@ begin_test "ghe-restore with no pages backup" ) end_test -begin_test "ghe-restore with encrypted column encryption keying material" +begin_test "ghe-restore does not restore encrypted column encryption keying material for versions below 3.7.0" +( + GHE_REMOTE_VERSION=2.1.10 ghe-restore -v -f localhost | grep -q "encrypted column encryption keying material not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/encrypted-column-keying-material"] + + GHE_REMOTE_VERSION=3.6.1 ghe-restore -v -f localhost | grep -q "encrypted column encryption keying material not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/encrypted-column-keying-material" ] + +) +end_test + +begin_test "ghe-restore with encrypted column encryption keying material for versions 3.7.0+" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -295,6 +306,21 @@ begin_test "ghe-restore with encrypted column encryption keying material" echo "foo" > "$GHE_DATA_DIR/current/$file" done + # GHES version 3.7.0 + GHE_REMOTE_VERSION=3.7.0 + + ghe-restore -v -f localhost + required_secrets=( + "secrets.github.encrypted-column-keying-material" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done + + # GHES version 3.8.0 + GHE_REMOTE_VERSION=3.8.0 + ghe-restore -v -f localhost required_secrets=( "secrets.github.encrypted-column-keying-material" @@ -306,7 +332,19 @@ begin_test "ghe-restore with encrypted column encryption keying material" ) end_test -begin_test "ghe-restore with encrypted column current encryption key" + +begin_test "ghe-restore does not encrypted column current encryption key for versions below 3.8.0" +( + GHE_REMOTE_VERSION=2.1.10 restore -v -f | grep -q "encrypted column current encryption key not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/encrypted-column-current-encryption-key" ] + + GHE_REMOTE_VERSION=3.7.0 restore -v -f | grep -q "encrypted column current encryption key not set" && exit 1 + [ ! -f "$GHE_DATA_DIR/current/encrypted-column-current-encryption-key" ] + +) +end_test + +begin_test "ghe-restore with encrypted column current encryption key for versions 3.8.0+" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -320,6 +358,22 @@ begin_test "ghe-restore with encrypted column current encryption key" echo "foo" > "$GHE_DATA_DIR/current/$file" done + # GHES version 3.8.0 + GHE_REMOTE_VERSION=3.8.0 + + ghe-restore -v -f localhost + required_secrets=( + "secrets.github.encrypted-column-current-encryption-key" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done + + + # GHES version 3.9.0 + GHE_REMOTE_VERSION=3.9.0 + ghe-restore -v -f localhost required_secrets=( "secrets.github.encrypted-column-current-encryption-key" From d7bb7026a0ea2c47272380eb2b1a6a751b523a45 Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:28:17 +0000 Subject: [PATCH 1957/2421] add log message about always restoring encryption keys on versions forward 3.7.0 --- bin/ghe-restore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/ghe-restore b/bin/ghe-restore index b2f60da21..64bfad46f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -384,6 +384,9 @@ if $RESTORE_SETTINGS; then fi # Always restore column encryption keys +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then + log_info "Always restore encrypted column encryption keys on GHES verions 3.7.0+" +fi ghe-restore-column-encryption-keys "$GHE_HOSTNAME" # Make sure mysql and elasticsearch are prep'd and running before restoring. From b427a32fabe7791cfee5f84fd1b91a5e1e78bf0a Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Tue, 27 Jun 2023 08:13:44 -0400 Subject: [PATCH 1958/2421] Update test/test-ghe-restore.sh Co-authored-by: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> --- test/test-ghe-restore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 753b42196..606b466e4 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -284,7 +284,7 @@ end_test begin_test "ghe-restore does not restore encrypted column encryption keying material for versions below 3.7.0" ( GHE_REMOTE_VERSION=2.1.10 ghe-restore -v -f localhost | grep -q "encrypted column encryption keying material not set" && exit 1 - [ ! -f "$GHE_DATA_DIR/current/encrypted-column-keying-material"] + [ ! -f "$GHE_DATA_DIR/current/encrypted-column-keying-material" ] GHE_REMOTE_VERSION=3.6.1 ghe-restore -v -f localhost | grep -q "encrypted column encryption keying material not set" && exit 1 [ ! -f "$GHE_DATA_DIR/current/encrypted-column-keying-material" ] From 7bdd77ba6ec77b190dddbc0c8d6b836c94ee9c4a Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Tue, 27 Jun 2023 12:40:18 +0000 Subject: [PATCH 1959/2421] break up tests to try to appease shellcheck --- test/test-ghe-backup.sh | 18 +++++++++++++++++- test/test-ghe-restore.sh | 20 +++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index dd8563528..2986872ca 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -618,7 +618,8 @@ begin_test "ghe-backup does not take backup of encrypted column current encrypti ) end_test -begin_test "ghe-backup takes backup of encrypted column current encryption key for versions 3.8.0+" +# encrypted column current encryption key needs to be backed up for versions 3.8.0+ +begin_test "ghe-backup takes backup of encrypted column current encryption key for versions 3.8.0" ( set -e @@ -642,6 +643,21 @@ begin_test "ghe-backup takes backup of encrypted column current encryption key f for file in "${required_files[@]}"; do [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] done +) +end_test + +# encrypted column current encryption key needs to be backed up for versions 3.8.0+ +begin_test "ghe-backup takes backup of encrypted column current encryption key for versions 3.9.0" +( + set -e + + required_secrets=( + "secrets.github.encrypted-column-current-encryption-key" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done # GHES version 3.9.0 GHE_REMOTE_VERSION=3.9.0 diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 606b466e4..f3b924324 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -344,7 +344,9 @@ begin_test "ghe-restore does not encrypted column current encryption key for ver ) end_test -begin_test "ghe-restore with encrypted column current encryption key for versions 3.8.0+" + +# encrypted column current encryption key needs to be restored for versions 3.8.0+ +begin_test "ghe-restore with encrypted column current encryption key for versions 3.8.0" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -369,7 +371,23 @@ begin_test "ghe-restore with encrypted column current encryption key for version for secret in "${required_secrets[@]}"; do [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] done +) +end_test + +# encrypted column current encryption key needs to be restored for versions 3.8.0+ +begin_test "ghe-restore with encrypted column current encryption key for versions 3.9.0" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + required_files=( + "encrypted-column-current-encryption-key" + ) + + for file in "${required_files[@]}"; do + echo "foo" > "$GHE_DATA_DIR/current/$file" + done # GHES version 3.9.0 GHE_REMOTE_VERSION=3.9.0 From c4c1dda395235cca459993f331144d8f6fce377b Mon Sep 17 00:00:00 2001 From: Ant Kaynak Date: Tue, 27 Jun 2023 12:45:42 +0000 Subject: [PATCH 1960/2421] Replace deprecated translog flush setting in ES --- share/github-backup-utils/ghe-backup-es-rsync | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 00946279a..a3aef164d 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -39,6 +39,12 @@ if [ -d "$GHE_DATA_DIR/current/elasticsearch" ]; then link_dest="--link-dest=../../current/elasticsearch" fi +# Store the existing flush_threshold_size setting if it exists and if does not set it to ES default +current_threshold=$(ghe-ssh "$host" -- curl -s "localhost:9200/_settings" | jq -r '.[].settings.index.translog.flush_threshold_size') +if [ -z "$current_threshold" ]; then + current_threshold="512MB" +fi + # Transfer ES indices from a GitHub instance to the current snapshot # directory, using a previous snapshot to avoid transferring files that have # already been transferred. @@ -54,7 +60,7 @@ log_rsync "END elasticsearch rsync" 1>&3 # Set up a trap to re-enable flushing on exit and remove temp file cleanup () { ghe_verbose "* Enabling ES index flushing ..." - echo '{"index":{"translog.disable_flush":false}}' | + echo "{\"index\":{\"index.translog.flush_threshold_size\":\"$current_threshold\"}}" | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null } trap 'cleanup' EXIT @@ -62,7 +68,7 @@ trap 'exit $?' INT # ^C always terminate # Disable ES flushing and force a flush right now ghe_verbose "* Disabling ES index flushing ..." -echo '{"index":{"translog.disable_flush":true}}' | +echo '{"index":{"index.translog.flush_threshold_size":"1PB"}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null From d0341eb33674650b0547b7cbcf8990c9ad6897b2 Mon Sep 17 00:00:00 2001 From: Ant Kaynak Date: Tue, 27 Jun 2023 12:56:27 +0000 Subject: [PATCH 1961/2421] Fix lint --- share/github-backup-utils/ghe-backup-es-rsync | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index a3aef164d..fdd8c342a 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -10,7 +10,7 @@ set -e # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -bm_start "$(basename $0)" +bm_start "$(basename "$0")" # Set up remote host and root elastic backup directory based on config host="$GHE_HOSTNAME" @@ -53,7 +53,7 @@ log_rsync "BEGIN elasticsearch rsync" 1>&3 ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ - $link_dest \ + "$link_dest" \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 log_rsync "END elasticsearch rsync" 1>&3 @@ -78,14 +78,14 @@ log_rsync "BEGIN: elasticsearch followup rsync" 1>&3 ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ - $link_dest \ + "$link_dest" \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 log_rsync "END: elasticsearch followup rsync" 1>&3 # "Backup" audit log migration sentinel file if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - touch $GHE_SNAPSHOT_DIR/es-scan-complete + touch "$GHE_SNAPSHOT_DIR"/es-scan-complete fi -bm_end "$(basename $0)" +bm_end "$(basename "$0")" From 666280521c89375aedcdd3903571b486249debbe Mon Sep 17 00:00:00 2001 From: Ant Kaynak Date: Tue, 27 Jun 2023 14:07:58 +0000 Subject: [PATCH 1962/2421] Fix index translog json --- share/github-backup-utils/ghe-backup-es-rsync | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index fdd8c342a..986159c2e 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -60,7 +60,7 @@ log_rsync "END elasticsearch rsync" 1>&3 # Set up a trap to re-enable flushing on exit and remove temp file cleanup () { ghe_verbose "* Enabling ES index flushing ..." - echo "{\"index\":{\"index.translog.flush_threshold_size\":\"$current_threshold\"}}" | + echo "{\"index\":{\"translog.flush_threshold_size\":\"$current_threshold\"}}" | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null } trap 'cleanup' EXIT @@ -68,7 +68,7 @@ trap 'exit $?' INT # ^C always terminate # Disable ES flushing and force a flush right now ghe_verbose "* Disabling ES index flushing ..." -echo '{"index":{"index.translog.flush_threshold_size":"1PB"}}' | +echo '{"index":{"translog.flush_threshold_size":"1PB"}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null From f834364740e8a8032a878df1ff15de85173a9874 Mon Sep 17 00:00:00 2001 From: Ant Kaynak Date: Tue, 27 Jun 2023 14:52:45 +0000 Subject: [PATCH 1963/2421] Use transient settings instead of index specific ones --- share/github-backup-utils/ghe-backup-es-rsync | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 986159c2e..f6363bfe0 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -39,12 +39,6 @@ if [ -d "$GHE_DATA_DIR/current/elasticsearch" ]; then link_dest="--link-dest=../../current/elasticsearch" fi -# Store the existing flush_threshold_size setting if it exists and if does not set it to ES default -current_threshold=$(ghe-ssh "$host" -- curl -s "localhost:9200/_settings" | jq -r '.[].settings.index.translog.flush_threshold_size') -if [ -z "$current_threshold" ]; then - current_threshold="512MB" -fi - # Transfer ES indices from a GitHub instance to the current snapshot # directory, using a previous snapshot to avoid transferring files that have # already been transferred. @@ -60,7 +54,7 @@ log_rsync "END elasticsearch rsync" 1>&3 # Set up a trap to re-enable flushing on exit and remove temp file cleanup () { ghe_verbose "* Enabling ES index flushing ..." - echo "{\"index\":{\"translog.flush_threshold_size\":\"$current_threshold\"}}" | + echo '{"transient":{"index.translog.flush_threshold_size":null}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null } trap 'cleanup' EXIT @@ -68,7 +62,7 @@ trap 'exit $?' INT # ^C always terminate # Disable ES flushing and force a flush right now ghe_verbose "* Disabling ES index flushing ..." -echo '{"index":{"translog.flush_threshold_size":"1PB"}}' | +echo '{"transient":{"index.translog.flush_threshold_size":"1PB"}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null From 77263faf1a684281375ec903f367a72e327338eb Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 27 Jun 2023 15:31:21 +0000 Subject: [PATCH 1964/2421] update bm_start desc --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 6a5b69ea0..e9a54d646 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -609,7 +609,7 @@ if $CLUSTER; then bm_end "configure_cluster" elif $instance_configured; then log_info "Configuring appliance ..." - bm_start "configure_appliance" + bm_start "$(basename $0) - configure appliance" if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then From cb63a6edebc9218b3e62c3653599e9ebbc4e2863 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 27 Jun 2023 15:36:30 +0000 Subject: [PATCH 1965/2421] fix cluster desc --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index e9a54d646..0dd0355db 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -606,7 +606,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 fi ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 - bm_end "configure_cluster" + bm_end "$(basename $0) - configure cluster" elif $instance_configured; then log_info "Configuring appliance ..." bm_start "$(basename $0) - configure appliance" From e4d1b2cf076bc3e43f439b28ea99b471543e06dd Mon Sep 17 00:00:00 2001 From: Ant Kaynak Date: Tue, 27 Jun 2023 16:01:08 +0000 Subject: [PATCH 1966/2421] Revert unsupported transient and use per index setting --- share/github-backup-utils/ghe-backup-es-rsync | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index f6363bfe0..402359345 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -54,7 +54,7 @@ log_rsync "END elasticsearch rsync" 1>&3 # Set up a trap to re-enable flushing on exit and remove temp file cleanup () { ghe_verbose "* Enabling ES index flushing ..." - echo '{"transient":{"index.translog.flush_threshold_size":null}}' | + echo '{"index":{"translog.flush_threshold_size":"512MB"}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null } trap 'cleanup' EXIT @@ -62,7 +62,7 @@ trap 'exit $?' INT # ^C always terminate # Disable ES flushing and force a flush right now ghe_verbose "* Disabling ES index flushing ..." -echo '{"transient":{"index.translog.flush_threshold_size":"1PB"}}' | +echo '{"index":{"translog.flush_threshold_size":"1PB"}}' | ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null From 1e61ea02b7461f769b6c40acbb99ac1d37c2b3fd Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Tue, 27 Jun 2023 16:22:33 +0000 Subject: [PATCH 1967/2421] Revert "break up tests to try to appease shellcheck" This reverts commit 7bdd77ba6ec77b190dddbc0c8d6b836c94ee9c4a. --- test/test-ghe-backup.sh | 18 +----------------- test/test-ghe-restore.sh | 20 +------------------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 2986872ca..dd8563528 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -618,8 +618,7 @@ begin_test "ghe-backup does not take backup of encrypted column current encrypti ) end_test -# encrypted column current encryption key needs to be backed up for versions 3.8.0+ -begin_test "ghe-backup takes backup of encrypted column current encryption key for versions 3.8.0" +begin_test "ghe-backup takes backup of encrypted column current encryption key for versions 3.8.0+" ( set -e @@ -643,21 +642,6 @@ begin_test "ghe-backup takes backup of encrypted column current encryption key f for file in "${required_files[@]}"; do [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] done -) -end_test - -# encrypted column current encryption key needs to be backed up for versions 3.8.0+ -begin_test "ghe-backup takes backup of encrypted column current encryption key for versions 3.9.0" -( - set -e - - required_secrets=( - "secrets.github.encrypted-column-current-encryption-key" - ) - - for secret in "${required_secrets[@]}"; do - ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" - done # GHES version 3.9.0 GHE_REMOTE_VERSION=3.9.0 diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index f3b924324..606b466e4 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -344,9 +344,7 @@ begin_test "ghe-restore does not encrypted column current encryption key for ver ) end_test - -# encrypted column current encryption key needs to be restored for versions 3.8.0+ -begin_test "ghe-restore with encrypted column current encryption key for versions 3.8.0" +begin_test "ghe-restore with encrypted column current encryption key for versions 3.8.0+" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -371,23 +369,7 @@ begin_test "ghe-restore with encrypted column current encryption key for version for secret in "${required_secrets[@]}"; do [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] done -) -end_test - -# encrypted column current encryption key needs to be restored for versions 3.8.0+ -begin_test "ghe-restore with encrypted column current encryption key for versions 3.9.0" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - required_files=( - "encrypted-column-current-encryption-key" - ) - - for file in "${required_files[@]}"; do - echo "foo" > "$GHE_DATA_DIR/current/$file" - done # GHES version 3.9.0 GHE_REMOTE_VERSION=3.9.0 From 7f962bd59286e9c5a3066dac8dfa6a0f4c712b06 Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Tue, 27 Jun 2023 16:25:20 +0000 Subject: [PATCH 1968/2421] export GHE_REMOTE_VERSION in test to appease shellcheck --- test/test-ghe-backup.sh | 4 ++++ test/test-ghe-restore.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index dd8563528..00837d50c 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -580,6 +580,7 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi # GHES version 3.7.0 GHE_REMOTE_VERSION=3.7.0 + export GHE_REMOTE_VERSION ghe-backup @@ -593,6 +594,7 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi # GHES version 3.8.0 GHE_REMOTE_VERSION=3.8.0 + export GHE_REMOTE_VERSION ghe-backup @@ -632,6 +634,7 @@ begin_test "ghe-backup takes backup of encrypted column current encryption key f # GHES version 3.8.0 GHE_REMOTE_VERSION=3.8.0 + export GHE_REMOTE_VERSION ghe-backup @@ -645,6 +648,7 @@ begin_test "ghe-backup takes backup of encrypted column current encryption key f # GHES version 3.9.0 GHE_REMOTE_VERSION=3.9.0 + export GHE_REMOTE_VERSION ghe-backup diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 606b466e4..8028cca03 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -308,6 +308,7 @@ begin_test "ghe-restore with encrypted column encryption keying material for ver # GHES version 3.7.0 GHE_REMOTE_VERSION=3.7.0 + export GHE_REMOTE_VERSION ghe-restore -v -f localhost required_secrets=( @@ -320,6 +321,7 @@ begin_test "ghe-restore with encrypted column encryption keying material for ver # GHES version 3.8.0 GHE_REMOTE_VERSION=3.8.0 + export GHE_REMOTE_VERSION ghe-restore -v -f localhost required_secrets=( @@ -360,6 +362,7 @@ begin_test "ghe-restore with encrypted column current encryption key for version # GHES version 3.8.0 GHE_REMOTE_VERSION=3.8.0 + export GHE_REMOTE_VERSION ghe-restore -v -f localhost required_secrets=( @@ -373,6 +376,7 @@ begin_test "ghe-restore with encrypted column current encryption key for version # GHES version 3.9.0 GHE_REMOTE_VERSION=3.9.0 + export GHE_REMOTE_VERSION ghe-restore -v -f localhost required_secrets=( From a2a51dd0094b5f37c3628c2402530f36758c2600 Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 29 Jun 2023 13:57:45 +0200 Subject: [PATCH 1969/2421] Add bc app --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 667739729..0c6acbbe4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ libssl-dev \ git \ jq \ + bc \ curl \ tar \ gzip \ @@ -55,7 +56,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ openssh-client \ jq \ moreutils \ - gawk \ + gawk \ ca-certificates \ xxhash \ && rm -rf /var/lib/apt/lists/* From ccb139c2fa6d8a463101a799905fb03a84db093f Mon Sep 17 00:00:00 2001 From: solmaz Date: Thu, 29 Jun 2023 15:23:20 +0200 Subject: [PATCH 1970/2421] add bc --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 0c6acbbe4..710cb9d52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,6 +55,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \ git \ openssh-client \ jq \ + bc \ moreutils \ gawk \ ca-certificates \ From 2de29e6833b887884691a0c9924f50a313a41536 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 3 Jul 2023 15:25:01 -0400 Subject: [PATCH 1971/2421] Remove 'git clone' setup option --- docs/getting-started.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 58054f3bf..02f2cbe9b 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -4,10 +4,6 @@ `tar -xzvf /path/to/github-backup-utils-vMAJOR.MINOR.PATCH.tar.gz` - *or* clone the repository using Git: - - `git clone -b stable https://github.com/github/backup-utils.git` - **Note**: you will need to use [Backup Utilities v2.11.x][2] or the `legacy` branch to backup and restore GitHub Enterprise Server 2.10 and earlier. From 4fe38efc9339cc6ddf7f4e8e5700fecd95ddc7ba Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Thu, 6 Jul 2023 12:46:02 +0200 Subject: [PATCH 1972/2421] only run lint on pr workflow (#386) --- .github/workflows/lint.yml | 2 -- .github/workflows/main.yml | 1 - Makefile | 1 + 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 44eec8716..d15f123bb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,8 +1,6 @@ name: Lint Code Base on: - push: - branches-ignore: [master] pull_request: branches: [master] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 26ce0090a..809e9df50 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,6 @@ name: Test and build on: [pull_request] - jobs: build: strategy: diff --git a/Makefile b/Makefile index 7ca5cd24c..191b90561 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ SHELL = /bin/sh test: info + @echo Running tests @script/cibuild --no-package info: From 4bda1f4edd4cc2f55af2bf8f755cfcccb32482af Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Fri, 7 Jul 2023 15:19:26 -0400 Subject: [PATCH 1973/2421] Add bc to requirements --- docs/requirements.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index a7dc45ebe..f3f7d67f6 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,7 +5,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), and [jq][11] v1.5 or newer. See below for an update on rsync. +Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), [jq][11] v1.5 or newer, and [bc][12] v1.07 or newer. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. @@ -99,3 +99,4 @@ Due to how some components of Backup Utilities (e.g. MSSQL) take incremental bac [9]: https://joeyh.name/code/moreutils [10]: https://www.gnu.org/software/gawk [11]: https://stedolan.github.io/jq/ +[12]: https://www.gnu.org/software/bc/ From a946abf3a8e18c1ab4dfb6e090c9419232107163 Mon Sep 17 00:00:00 2001 From: Ant Kaynak Date: Mon, 10 Jul 2023 15:19:58 +0000 Subject: [PATCH 1974/2421] Remove lint changes --- share/github-backup-utils/ghe-backup-es-rsync | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index 402359345..ad973c7b4 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -10,7 +10,7 @@ set -e # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" -bm_start "$(basename "$0")" +bm_start "$(basename $0)" # Set up remote host and root elastic backup directory based on config host="$GHE_HOSTNAME" @@ -47,7 +47,7 @@ log_rsync "BEGIN elasticsearch rsync" 1>&3 ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ - "$link_dest" \ + $link_dest \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 log_rsync "END elasticsearch rsync" 1>&3 @@ -72,14 +72,14 @@ log_rsync "BEGIN: elasticsearch followup rsync" 1>&3 ghe-rsync -avz \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ - "$link_dest" \ + $link_dest \ "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 log_rsync "END: elasticsearch followup rsync" 1>&3 # "Backup" audit log migration sentinel file if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - touch "$GHE_SNAPSHOT_DIR"/es-scan-complete + touch $GHE_SNAPSHOT_DIR/es-scan-complete fi -bm_end "$(basename "$0")" +bm_end "$(basename $0)" From df97040b1f3ec40d1980dc78d26c631b44f38492 Mon Sep 17 00:00:00 2001 From: Robert Bolender Date: Wed, 14 Jun 2023 20:40:35 -0700 Subject: [PATCH 1975/2421] Backup and restore secret scanning encrypted secrets encryption keys --- share/github-backup-utils/ghe-backup-settings | 6 ++++ .../github-backup-utils/ghe-restore-settings | 12 +++++++ test/test-ghe-backup.sh | 30 +++++++++++++++++ test/test-ghe-restore.sh | 32 +++++++++++++++++++ 4 files changed, 80 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index c12abcd92..1de4ca515 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -88,6 +88,12 @@ fi if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" fi +backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" +backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" +backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" +backup-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" +backup-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" +backup-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" # Backup argon secrets for multiuser from ghes version 3.8 onwards if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index b489626c2..28b0a1bc6 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -56,6 +56,18 @@ restore-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hm # Restore kredz.varz HMAC key if present. restore-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" +# Restore encrypted column encryption keying material if present +restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" + +# Restore encrypted column current encryption key if present +restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" + +# Restore secret scanning encrypted secrets encryption keys if present +restore-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" +restore-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" +restore-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" +restore-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" + # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then log_info "Restoring SAML keys ..." diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 00837d50c..6aeb94342 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -663,6 +663,36 @@ begin_test "ghe-backup takes backup of encrypted column current encryption key f ) end_test +begin_test "ghe-backup takes backup of secret scanning encrypted secrets encryption keys" +( + set -e + + required_secrets=( + "secrets.secret-scanning.encrypted-secrets-current-storage-key" + "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" + "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" + "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + ghe-backup + + required_files=( + "secret-scanning-encrypted-secrets-current-storage-key" + "secret-scanning-encrypted-secrets-delimited-storage-keys" + "secret-scanning-encrypted-secrets-current-shared-transit-key" + "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done +) +end_test + begin_test "ghe-backup takes backup of Actions settings" ( set -e diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 8028cca03..3c963737f 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -389,6 +389,38 @@ begin_test "ghe-restore with encrypted column current encryption key for version ) end_test +begin_test "ghe-restore with secret scanning encrypted secrets encryption keys" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + required_files=( + "secret-scanning-encrypted-secrets-current-storage-key" + "secret-scanning-encrypted-secrets-delimited-storage-keys" + "secret-scanning-encrypted-secrets-current-shared-transit-key" + "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" + ) + + for file in "${required_files[@]}"; do + echo "foo" >"$GHE_DATA_DIR/current/$file" + done + + ghe-restore -v -f localhost + + required_secrets=( + "secrets.secret-scanning.encrypted-secrets-current-storage-key" + "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" + "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" + "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done +) +end_test + # Setup Actions data for the subsequent tests setup_actions_test_data "$GHE_DATA_DIR/1" From 3907e5f0644d1805158e8bf5ee8db4aafca6c12d Mon Sep 17 00:00:00 2001 From: Robert Bolender Date: Fri, 23 Jun 2023 12:04:22 -0700 Subject: [PATCH 1976/2421] Restore secret scanning encryption keys even without -c argument Restore removed backup, remove duplicate restore Use restore instead of backup --- bin/ghe-restore | 3 ++ ...he-restore-secret-scanning-encryption-keys | 39 +++++++++++++++++++ .../github-backup-utils/ghe-restore-settings | 6 --- 3 files changed, 42 insertions(+), 6 deletions(-) create mode 100755 share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys diff --git a/bin/ghe-restore b/bin/ghe-restore index 69e53def9..6287b0faf 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -443,6 +443,9 @@ if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then fi ghe-restore-column-encryption-keys "$GHE_HOSTNAME" +# Always restore secret scanning encryption keys +ghe-restore-secret-scanning-encryption-keys "$GHE_HOSTNAME" + # Make sure mysql and elasticsearch are prep'd and running before restoring. # These services will not have been started on appliances that have not been # configured yet. diff --git a/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys b/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys new file mode 100755 index 000000000..aa225bc07 --- /dev/null +++ b/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-secret-scanning-encryption-keys +#/ Restore the secret scanning encryption keys from a snapshot to the given . +#/ This script will be run automatically by `ghe-restore` +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$GHE_HOSTNAME" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# Path to snapshot dir we're restoring from +: ${GHE_RESTORE_SNAPSHOT_PATH:="$GHE_DATA_DIR/current"} + +# Restore secret scanning encrypted secrets storage keys if present +log_info "Restoring secret scanning encrypted secrets storage keys" +restore-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" +restore-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" + +# Restore secret scanning encrypted secrets transit keys if present +log_info "Restoring secret scanning encrypted secrets transit keys" +restore-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" +restore-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" + +bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index 28b0a1bc6..ad06f30a6 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -62,12 +62,6 @@ restore-secret "encrypted column encryption keying material" "encrypted-column-e # Restore encrypted column current encryption key if present restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" -# Restore secret scanning encrypted secrets encryption keys if present -restore-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" -restore-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" -restore-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" -restore-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" - # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then log_info "Restoring SAML keys ..." From f8ec15c71a475591bc38adc7b9f00bd820d9e578 Mon Sep 17 00:00:00 2001 From: Robert Bolender Date: Mon, 10 Jul 2023 15:23:06 -0700 Subject: [PATCH 1977/2421] Add GHES version check, only restore if >= 3.8.0 --- bin/ghe-restore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 6287b0faf..2c62c2ce8 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -444,7 +444,10 @@ fi ghe-restore-column-encryption-keys "$GHE_HOSTNAME" # Always restore secret scanning encryption keys -ghe-restore-secret-scanning-encryption-keys "$GHE_HOSTNAME" +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then + log_info "Always restore secret scanning encryption keys on GHES verions 3.8.0+" + ghe-restore-secret-scanning-encryption-keys "$GHE_HOSTNAME" +fi # Make sure mysql and elasticsearch are prep'd and running before restoring. # These services will not have been started on appliances that have not been From f1fa74bafbad4a9119f84440c34049590d44a87c Mon Sep 17 00:00:00 2001 From: Robert Bolender Date: Mon, 10 Jul 2023 22:55:13 +0000 Subject: [PATCH 1978/2421] Fix bad rebase --- share/github-backup-utils/ghe-backup-settings | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 1de4ca515..4d08c7134 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -88,8 +88,7 @@ fi if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" fi -backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" -backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" + backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" backup-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" backup-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" From a7077ef99908da791efad3b756687b4a308c492f Mon Sep 17 00:00:00 2001 From: Robert Bolender Date: Mon, 10 Jul 2023 22:55:33 +0000 Subject: [PATCH 1979/2421] Assert secret scanning keys are restored in versions 3.8.0+ --- test/test-ghe-restore.sh | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 3c963737f..ef13b7697 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -389,7 +389,7 @@ begin_test "ghe-restore with encrypted column current encryption key for version ) end_test -begin_test "ghe-restore with secret scanning encrypted secrets encryption keys" +begin_test "ghe-restore with secret scanning encrypted secrets encryption keys for versions below 3.8.0" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -406,7 +406,7 @@ begin_test "ghe-restore with secret scanning encrypted secrets encryption keys" echo "foo" >"$GHE_DATA_DIR/current/$file" done - ghe-restore -v -f localhost + GHE_REMOTE_VERSION=3.7.0 ghe-restore -v -f localhost required_secrets=( "secrets.secret-scanning.encrypted-secrets-current-storage-key" @@ -416,7 +416,40 @@ begin_test "ghe-restore with secret scanning encrypted secrets encryption keys" ) for secret in "${required_secrets[@]}"; do - [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting these to not be set for versions below 3.8.0 + done +) +end_test + + +begin_test "ghe-restore with secret scanning encrypted secrets encryption keys for versions 3.8.0+" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + required_files=( + "secret-scanning-encrypted-secrets-current-storage-key" + "secret-scanning-encrypted-secrets-delimited-storage-keys" + "secret-scanning-encrypted-secrets-current-shared-transit-key" + "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" + ) + + for file in "${required_files[@]}"; do + echo "foo" >"$GHE_DATA_DIR/current/$file" + done + + GHE_REMOTE_VERSION=3.8.0 ghe-restore -v -f localhost + + required_secrets=( + "secrets.secret-scanning.encrypted-secrets-current-storage-key" + "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" + "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" + "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] # expecting this to have been restored successfully for versions 3.8.0+ done ) end_test From 4a092e9d351e9a28d36b35d2fbd50427bdfb7eae Mon Sep 17 00:00:00 2001 From: Ant Kaynak Date: Tue, 11 Jul 2023 08:45:05 +0000 Subject: [PATCH 1980/2421] Ignore shell split lint warning --- share/github-backup-utils/ghe-backup-es-rsync | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index ad973c7b4..ee61741b2 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -4,6 +4,7 @@ #/ #/ Note: This command typically isn't called directly. It's invoked by #/ ghe-backup when the rsync strategy is used. +# shellcheck disable=SC2086 set -e # Bring in the backup configuration From fffe06a834c1cdae8e9812e19ea30dc8bfba2c5d Mon Sep 17 00:00:00 2001 From: boxofyellow Date: Wed, 12 Jul 2023 10:39:57 -0400 Subject: [PATCH 1981/2421] Init array to Fix https://github.com/github/backup-utils/issues/1054 --- share/github-backup-utils/ghe-backup-mssql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index b5a3203fb..37b09ca9d 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -47,8 +47,8 @@ if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then fi tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) -ssh_config_file_opt= -opts= +ssh_config_file_opt=() +opts=() isHA="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.ha" || true)" From e564c68a861c5afa05e9a5065dfaf875a9da8826 Mon Sep 17 00:00:00 2001 From: Joseph Franks Date: Thu, 13 Jul 2023 13:42:49 -0500 Subject: [PATCH 1982/2421] update-master-version-to-3-9 Update the master version to 3.9. Seems this was missed during the last feature release --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 19811903a..a5c4c7633 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.8.0 +3.9.0 From 50a5c33568285a3bc8ec293b9528bd6a72050f6d Mon Sep 17 00:00:00 2001 From: Joseph Franks Date: Thu, 13 Jul 2023 13:44:54 -0500 Subject: [PATCH 1983/2421] Update minimun supported version to be 3.7 Update minimun supported version to be 3.7 --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 586739916..e404d5447 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -131,7 +131,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.6.0" +supported_minimum_version="3.7.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 From 38d587d535469a74bc2d31492c5121b9f5df2f63 Mon Sep 17 00:00:00 2001 From: Diana Date: Sun, 16 Jul 2023 14:05:42 -0700 Subject: [PATCH 1984/2421] Update formatting on ghe-host-check Added: - Recommended Disk requirement - Updated formatting of checks --- bin/ghe-host-check | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index e404d5447..4473c2dc1 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -157,9 +157,10 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size" #Display dir requirements for repositories and mysql + echo "" 1>&2 echo "Checking host for sufficient space for a backup..." 1>&2 available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') - echo "We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." 1>&2 + echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." 1>&2 repos_disk_size=$(transfer_size repositories /tmp) pages_disk_size=$(transfer_size pages /tmp) @@ -171,20 +172,24 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then mssql_disk_size=$(transfer_size mssql /tmp) min_disk_req=$((repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size)) - echo "Available space: $((available_space / (1024 ** 2))) MB" 1>&2 - echo -e "Min Disk required for this backup is at least $min_disk_req MB\n" 1>&2 + recommended_disk_req=$((min_disk_req * 5)) + echo " - Available space: $((available_space / (1024 ** 2))) MB" 1>&2 + echo " - Min Disk required for this backup is at least $min_disk_req MB" 1>&2 + echo " - Recommended Disk requirement is $recommended_disk_req MB" 1>&2 + echo "" 1>&2 -cat <&2 + cat <&2 ### Data Transfer Sizes -repositories: $repos_disk_size MB -pages: $pages_disk_size MB -elasticsearch: $es_disk_size MB -storage: $stor_disk_size MB -minio: $minio_disk_size MB -mysql: $mysql_disk_size MB -actions: $actions_disk_size MB -mssql: $mssql_disk_size MB + - repositories: $repos_disk_size MB + - pages: $pages_disk_size MB + - elasticsearch: $es_disk_size MB + - storage: $stor_disk_size MB + - minio: $minio_disk_size MB + - mysql: $mysql_disk_size MB + - actions: $actions_disk_size MB + - mssql: $mssql_disk_size MB DATA_TRANSFER_SIZE + echo "" 1>&2 if [[ $((available_space / (1024 * 1024))) -lt $min_disk_req ]]; then echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2 @@ -223,7 +228,7 @@ You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.co WARN_MSG fi - echo "rsync ${rsync_version} >= required ($min_rsync)" 1>&2 + echo " - rsync ${rsync_version} >= required ($min_rsync)" 1>&2 ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1 | tr -cd '[:digit:].\n') if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then @@ -231,7 +236,7 @@ WARN_MSG echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 exit 1 else - echo "openSSH ${ssh_version} >= required ($min_openssh)" 1>&2 + echo " - openSSH ${ssh_version} >= required ($min_openssh)" 1>&2 fi jq_version=$(jq --version |awk -F\- '{print $2}' | tr -cd '[:digit:].\n') @@ -240,8 +245,8 @@ WARN_MSG echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 exit 1 else - echo "jq ${jq_version} >= required ($min_jq)" 1>&2 + echo " - jq ${jq_version} >= required ($min_jq)" 1>&2 fi fi - +echo "" 1>&2 echo "Connect $hostname:$port OK (v$version)" From 7c2021acaa735805305f5b2dd471f7f6d02a49e2 Mon Sep 17 00:00:00 2001 From: Zheng Zeng Date: Mon, 17 Jul 2023 14:41:19 +0000 Subject: [PATCH 1985/2421] fix indicator when doing backup and restore --- bin/ghe-backup | 25 ++++++++++++++++++- bin/ghe-restore | 20 +++++++++------ share/github-backup-utils/ghe-backup-config | 6 +++++ share/github-backup-utils/ghe-backup-pages | 4 ++- .../ghe-backup-repositories | 4 ++- share/github-backup-utils/ghe-backup-storage | 3 +++ share/github-backup-utils/ghe-restore-pages | 5 ++++ .../ghe-restore-repositories | 5 ++++ .../ghe-restore-repositories-gist | 5 ++++ share/github-backup-utils/ghe-restore-storage | 5 ++++ share/github-backup-utils/track-progress | 3 ++- 11 files changed, 74 insertions(+), 11 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 98f831a51..ae6dd0f0d 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -50,8 +50,30 @@ export PROGRESS_TYPE="Backup" echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type export PROGRESS=0 # Used to track progress of backup echo "$PROGRESS" > /tmp/backup-utils-progress -export PROGRESS_TOTAL=18 # Maximum number of steps in backup +OPTIONAL_STEPS=0 +# Backup actions+mssql +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2)) +fi + +# Backup fsck +if [ "$GHE_BACKUP_FSCK" = "yes" ]; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi + +# Backup minio +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi + +# Backup pages +if [ "$GHE_BACKUP_PAGES" != "no" ]; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi + +PROGRESS_TOTAL=$((OPTIONAL_STEPS + 14)) # Minimum number of steps in backup is 14 +echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check @@ -269,6 +291,7 @@ echo \"$cmd_title\" ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"") if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then + increment-progress-total-count 1 cmd_title=$(log_info "Backing up Elasticsearch indices ...") commands+=(" echo \"$cmd_title\" diff --git a/bin/ghe-restore b/bin/ghe-restore index 2c62c2ce8..44d5e4b37 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -275,15 +275,12 @@ fi # taking into account the options passed to the script and the appliance configuration # calculate restore steps OPTIONAL_STEPS=0 -# Cluster restores add an additional step -if $CLUSTER ; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi + # Restoring UUID if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi -# Restoring Actions +# Restoring Actions + MSSQL if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi @@ -305,14 +302,21 @@ fi if ! $CLUSTER && $instance_configured; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi -# Maximum restore steps -export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 6)) +# Restoring settings + restore-chat-integration + restore-packages +if $RESTORE_SETTINGS; then + echo "add setting" + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 3)) +fi + +# Minimum number of steps is 7 +export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7)) init-progress export PROGRESS_TYPE="Restore" echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type export PROGRESS=0 # Used to track progress of restore echo "$PROGRESS" > /tmp/backup-utils-progress +echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) @@ -446,6 +450,7 @@ ghe-restore-column-encryption-keys "$GHE_HOSTNAME" # Always restore secret scanning encryption keys if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then log_info "Always restore secret scanning encryption keys on GHES verions 3.8.0+" + increment-progress-total-count 1 ghe-restore-secret-scanning-encryption-keys "$GHE_HOSTNAME" fi @@ -490,6 +495,7 @@ if is_external_database_target_or_snapshot && $SKIP_MYSQL; then log_info "Skipping MySQL restore." else log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." + increment-progress-total-count 2 ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 fi diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 31e9aff0a..b65c61f28 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -712,6 +712,12 @@ init-progress() { rm -f /tmp/backup-utils-progress* } +#increase total count of progress +increment-progress-total-count() { + PROGRESS_TOTAL=$((PROGRESS_TOTAL + $1)) + echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total +} + diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index 21c2ac465..b0c9f1fed 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -63,6 +63,7 @@ if [ -d "$GHE_DATA_DIR/current/pages" ] && [ "$(ls -A $GHE_DATA_DIR/current/page link_dest="--link-dest=../../current/pages" fi +count=0 for hostname in $hostnames; do bm_start "$(basename $0) - $hostname" echo 1>&3 @@ -82,6 +83,7 @@ for hostname in $hostnames; do "$GHE_SNAPSHOT_DIR/pages" 1>&3 log_rsync "END: pages rsync" 1>&3 bm_end "$(basename $0) - $hostname" + count=$((count + 1)) done - +increment-progress-total-count $count bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index a3ba533d7..e90d8c37a 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -144,6 +144,8 @@ bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then log_warn "no routes found, skipping repositories backup ..." exit 0 +else + increment-progress-total-count 3 fi # Transfer repository data from a GitHub instance to the current snapshot @@ -377,7 +379,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | fix_paths_for_ghe_version | uniq | sort | uniq) > $tempdir/destination_routes git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." - + increment-progress-total-count 1 bm_end "$(basename $0) - Verifying Routes" fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 2f98a0541..9752de21d 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -113,6 +113,8 @@ bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then log_warn "no routes found, skipping storage backup ..." exit 0 +else + increment-progress-total-count 2 fi # rsync all the storage objects @@ -149,6 +151,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + increment-progress-total-count 1 bm_end "$(basename $0) - Verifying Routes" fi diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 640aa5d62..0b104863e 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -29,6 +29,8 @@ pages_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find pages -mindepth 5 if [ -z "$pages_paths" ]; then log_warn "Warning: Pages backup missing. Skipping ..." exit 0 +else + increment-progress-total-count 5 fi # Perform a host-check and establish GHE_REMOTE_XXX variables. @@ -125,6 +127,8 @@ bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then log_warn "Warning: no routes found, skipping pages restore ..." exit 0 +else + increment-progress-total-count 2 fi bm_start "$(basename $0) - Restoring pages" @@ -154,6 +158,7 @@ if $CLUSTER; then chunks=\$(find $remote_tempdir/ -name chunk\*) parallel -i /bin/sh -c "cat {} | github-env ./bin/dpages-cluster-restore-finalize" -- \$chunks EOF + increment-progress-total-count 1 bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index d59864196..9a749bc74 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -30,6 +30,8 @@ network_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mi if [ -z "$network_paths" ]; then log_warn "Warning: Repositories backup missing. Skipping ..." exit 0 +else + increment-progress-total-count 5 fi # Perform a host-check and establish GHE_REMOTE_XXX variables. @@ -142,6 +144,8 @@ bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then log_warn "Warning: no routes found, skipping repositories restore ..." exit 0 +else + increment-progress-total-count 3 fi # rsync all the repository networks to the git server where they belong. @@ -190,6 +194,7 @@ if $CLUSTER; then chunks=\$(find $remote_tempdir/ -name chunk\*) parallel -i /bin/sh -c "cat {} | github-env ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF + increment-progress-total-count 1 bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index addb18514..7faae5260 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -29,6 +29,8 @@ gist_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find repositories -mind if [ -z "$gist_paths" ]; then log_warn "Warning: Gist backup missing. Skipping ..." exit 0 +else + increment-progress-total-count 5 fi # Perform a host-check and establish GHE_REMOTE_XXX variables. @@ -128,6 +130,8 @@ bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then log_warn "Warning: no routes found, skipping gists restore ..." exit 0 +else + increment-progress-total-count 2 fi # rsync all the gist repositories @@ -157,6 +161,7 @@ if $CLUSTER; then chunks=\$(find $remote_tempdir/ -name chunk\*) parallel -i /bin/sh -c "cat {} | github-env ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF + increment-progress-total-count 1 bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index af6c24a23..8f0d73c48 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -33,6 +33,8 @@ storage_paths=$(cd $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/ && find storage -mindept if [ -z "$storage_paths" ]; then log_warn "Warning: Storage backup missing. Skipping ..." exit 0 +else + increment-progress-total-count 5 fi # Perform a host-check and establish GHE_REMOTE_XXX variables. @@ -120,6 +122,8 @@ bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then log_warn "Warning: no routes found, skipping storage restore ..." exit 0 +else + increment-progress-total-count 2 fi # rsync all the objects to the storage server where they belong. @@ -169,6 +173,7 @@ if $CLUSTER; then chunks=\$(find $remote_tempdir/ -name chunk\*) parallel -i /bin/sh -c "cat {} | github-env ./bin/storage-cluster-restore-finalize" -- \$chunks EOF + increment-progress-total-count 1 bm_end "$(basename $0) - Finalizing routes" fi diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 3f67ca9e8..bf50c42aa 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -6,8 +6,9 @@ set -e progress(){ PROGRESS=$(cat /tmp/backup-utils-progress) + PROGRESS_TOTAL=$(cat /tmp/backup-utils-progress-total) PROGRESS_TYPE=$(cat /tmp/backup-utils-progress-type) PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) - echo $((PROGRESS +1)) > /tmp/backup-utils-progress + echo $((PROGRESS + 1)) > /tmp/backup-utils-progress echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress-info } From 1a38356c417cd0536b6f66eef4eef82b674e0688 Mon Sep 17 00:00:00 2001 From: Zheng Zeng Date: Tue, 18 Jul 2023 15:30:48 +0000 Subject: [PATCH 1986/2421] remove debug log --- bin/ghe-restore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 44d5e4b37..428227426 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -282,7 +282,7 @@ if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then fi # Restoring Actions + MSSQL if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2)) fi # Restoring minio if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then @@ -304,7 +304,6 @@ if ! $CLUSTER && $instance_configured; then fi # Restoring settings + restore-chat-integration + restore-packages if $RESTORE_SETTINGS; then - echo "add setting" OPTIONAL_STEPS=$((OPTIONAL_STEPS + 3)) fi From 11c0e5f5a97f83ec708dad6f6cb6471f344e8d24 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Wed, 19 Jul 2023 18:07:20 +0200 Subject: [PATCH 1987/2421] add msg in the logs for skipping snapshots (#417) --- bin/ghe-backup | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index 98f831a51..e81bf11e3 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -303,6 +303,8 @@ if [ -z "$failures" ]; then ln -s "$GHE_SNAPSHOT_TIMESTAMP" "../current" ghe-prune-snapshots +else + log_info "Skipping pruning snapshots, since some backups failed..." fi END_TIME=$(date +%s) From 23fa989a57f04b36d2f37345bb9b3451407a1ba6 Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Fri, 21 Jul 2023 21:12:14 +0000 Subject: [PATCH 1988/2421] Add creation of `encrypted_column_current_encryption_key` to backup 3.7.0+ * this is based on manual testing where we successfully used `ghe-ssh $host -- ghe-config --get 'secrets.github.encrypted-column-keying-material' | sed 's:.*;::' > encrypted-column-current-encryption-key` in the console and by manually editing it in the `test-ghe-backup.sh` file * when I attempted to write tests for the simple case of having only one value in the encryption_keying_material list I received an error on the `get` portion of the command. Removing the get allowed the test to and follows the format used in the implementation of `backup-secret` * then I added the complex test case of more than one entry in encryption_keying_material delimited by semicolons. This caused the test to fail with the error `fatal: ghe-ssh: Attempt to invoke complex command with simple command form.` --- share/github-backup-utils/ghe-backup-settings | 9 +-- test/test-ghe-backup.sh | 77 +++++++++++++++---- 2 files changed, 67 insertions(+), 19 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 4d08c7134..71012fa6d 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -79,14 +79,11 @@ backup-secret "password pepper" "password-pepper" "secrets.github.user-password- backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" -# backup encryption keying material for GHES 3.7.0 onwards +# backup encryption keying material and create backup value current encryption for GHES 3.7.0 onwards +# this is for forwards compatibility with GHES 3.8.0 onwards if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" -fi - -# backup current encryption key for GHES 3.8.0 onwards -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then - backup-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" + ghe-ssh "$host" -- ghe-config 'secrets.github.encrypted-column-keying-material' | sed 's:.*;::' > encrypted-column-current-encryption-key fi backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 6aeb94342..40122e049 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -566,7 +566,7 @@ begin_test "ghe-backup does not take backup of encrypted column encryption keyin ) end_test -begin_test "ghe-backup takes backup of encrypted column encryption keying material for versions 3.7.0+" +begin_test "ghe-backup takes backup of encrypted column encryption keying material and create encrypted column current encryption key for versions 3.7.0+" ( set -e @@ -586,6 +586,7 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi required_files=( "encrypted-column-encryption-keying-material" + "encrypted-column-current-encryption-key" ) for file in "${required_files[@]}"; do @@ -609,27 +610,60 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi ) end_test -begin_test "ghe-backup does not take backup of encrypted column current encryption key for versions below 3.8.0" +begin_test "ghe-backup takes backup of encrypted column encryption keying material and encrypted column current encryption key for versions 3.8.0+" ( - GHE_REMOTE_VERSION=2.1.10 ghe-backup -v | grep -q "encrypted column current encryption key not set" && exit 1 - [ ! -f "$GHE_DATA_DIR/current/encrypted-column-current-encryption-key" ] + set -e + + required_secrets=( + "secrets.github.encrypted-column-keying-material" + ) - GHE_REMOTE_VERSION=3.7.0 ghe-backup -v | grep -q "encrypted column current encryption key not set" && exit 1 - [ ! -f "$GHE_DATA_DIR/current/encrypted-column-current-encryption-key" ] + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + # GHES version 3.8.0 + GHE_REMOTE_VERSION=3.8.0 + export GHE_REMOTE_VERSION + + ghe-backup + + required_files=( + "encrypted-column-encryption-keying-material" + "encrypted-column-current-encryption-key" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done + + # GHES version 3.9.0 + GHE_REMOTE_VERSION=3.9.0 + export GHE_REMOTE_VERSION + + ghe-backup + + required_files=( + "encrypted-column-current-encryption-key" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done ) end_test -begin_test "ghe-backup takes backup of encrypted column current encryption key for versions 3.8.0+" +begin_test "ghe-backup takes backup of encrypted column encryption keying material and encrypted column current encryption key accounting for multiple encryption keying materials for versions 3.7.0+" ( set -e required_secrets=( - "secrets.github.encrypted-column-current-encryption-key" + "secrets.github.encrypted-column-keying-material" ) for secret in "${required_secrets[@]}"; do - ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo;bar" done # GHES version 3.8.0 @@ -639,13 +673,22 @@ begin_test "ghe-backup takes backup of encrypted column current encryption key f ghe-backup required_files=( - "encrypted-column-current-encryption-key" + "encrypted-column-encryption-keying-material" ) for file in "${required_files[@]}"; do - [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo;bar" ] done + required_files_current_encryption_key=( + "encrypted-column-current-encryption-key" + ) + + for file in "${required_files_current_encryption_key[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "bar" ] + done + + # GHES version 3.9.0 GHE_REMOTE_VERSION=3.9.0 export GHE_REMOTE_VERSION @@ -653,11 +696,19 @@ begin_test "ghe-backup takes backup of encrypted column current encryption key f ghe-backup required_files=( - "encrypted-column-current-encryption-key" + "encrypted-column-encryption-keying-material" ) for file in "${required_files[@]}"; do - [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo;bar" ] + done + + required_files_current_encryption_key=( + "encrypted-column-current-encryption-key" + ) + + for file in "${required_files_current_encryption_key[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "bar" ] done ) From c81a265a37cf353d42e5dd543baf6e5f833e275a Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Fri, 21 Jul 2023 21:38:10 +0000 Subject: [PATCH 1989/2421] Attempt to fix "Attempt to invoke complex command with simple command form." error * i tried to amend this command to use the complex syntax similar to how I saw the complex commands being written in other places but I think I need help with the syntax --- share/github-backup-utils/ghe-backup-settings | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 71012fa6d..ead350f92 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -83,7 +83,8 @@ backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-s # this is for forwards compatibility with GHES 3.8.0 onwards if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" - ghe-ssh "$host" -- ghe-config 'secrets.github.encrypted-column-keying-material' | sed 's:.*;::' > encrypted-column-current-encryption-key + echo "ghe-config 'secrets.github.encrypted-column-keying-material' | sed 's:.*;::' > encrypted-column-current-encryption-key" | + ghe-ssh "$host" /bin/bash fi backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" From 19dd3b493ea09886fdf8883b108347cb5375dc0a Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Mon, 24 Jul 2023 16:29:05 -0400 Subject: [PATCH 1990/2421] Apply suggestions from code review Co-authored-by: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> --- test/test-ghe-backup.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 40122e049..3dea629c4 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -663,7 +663,8 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi ) for secret in "${required_secrets[@]}"; do - ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo;bar" + echo "ghe-config '$secret' 'foo;bar'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash done # GHES version 3.8.0 From 368e5841abc94a2eec250a978883a0100d13849a Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Mon, 24 Jul 2023 21:16:47 +0000 Subject: [PATCH 1991/2421] only create a backup of the current encryption key on 3.8+ * remove check in 3.7 test * ghe-secrets-init will create a new current encryption key if it doesn't exist https://github.com/github/enterprise2/blob/a97cc4b077b8f8be2772959c07e2d0ca729fd079/vm_files/usr/local/share/enterprise/ghe-secrets-init#L505 since this is restoring from a backup, we need the current encryption key to match a value that was backed up in encryption keying material because encryption keying material is used to decrypt --- share/github-backup-utils/ghe-backup-settings | 6 ++++-- test/test-ghe-backup.sh | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index ead350f92..43bd41029 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -83,8 +83,10 @@ backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-s # this is for forwards compatibility with GHES 3.8.0 onwards if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" - echo "ghe-config 'secrets.github.encrypted-column-keying-material' | sed 's:.*;::' > encrypted-column-current-encryption-key" | - ghe-ssh "$host" /bin/bash +fi + +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then + cat "$GHE_SNAPSHOT_DIR/encrypted-column-encryption-keying-material" | sed 's:.*;::' > "$GHE_SNAPSHOT_DIR/encrypted-column-current-encryption-key" fi backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 3dea629c4..8fd42948e 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -586,7 +586,6 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi required_files=( "encrypted-column-encryption-keying-material" - "encrypted-column-current-encryption-key" ) for file in "${required_files[@]}"; do From 79d487591def1c48e7affe2d314a73a70c6e4bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Thu, 13 Jul 2023 15:51:23 +0200 Subject: [PATCH 1992/2421] Avoid redundant rsync operations In noncluster environments in a high-availability configuration, there is only one target server to restore repository data onto. However, the current implementation performs one rsync task per node in the replication network. In a setup with one primary instance and two passive replicas, this would amount to three rsync tasks with identical or almost identical file lists. Aside from the rsync task for transferring repository data from the backup snapshot onto the target server, the other rsync operations per replica are unnecessary. Avoiding these redundant rsync tasks reduces the runtime of ghe-restore-repositories by about 12 % for a customer with roughly 1 TB of repository data. With GHE_PARALLEL_ENABLED=yes configured, this change also prevents a race condition, which could occur when multiple rsync processes try to write to the same file on the target server at the same time. --- .../ghe-restore-repositories | 77 ++++++++++--------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index d59864196..e8e1dcdbe 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -102,42 +102,49 @@ done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building network list" -# The server returns a list of routes: -# -# a/nw/a8/3f/02/100000855 dgit-node1 dgit-node2 dgit-node3 -# a/nw/a8/bc/8d/100000880 dgit-node1 dgit-node2 dgit-node4 -# a/nw/a5/06/81/100000659 dgit-node3 dgit-node2 dgit-node4 -# ... -# -# One route per line. -# -# NOTE: The route generation is performed on the appliance as it is considerably -# more performant than performing over an SSH pipe. -# -bm_start "$(basename $0) - Transferring network list" -cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list -cat $tmp_list | ghe_debug -bm_end "$(basename $0) - Transferring network list" - -bm_start "$(basename $0) - Generating routes" -restore_routes_script="github-env ./bin/dgit-cluster-restore-routes" -if ghe-ssh "$GHE_HOSTNAME" test -e /usr/local/share/enterprise/ghe-restore-network-routes; then - restore_routes_script="/usr/local/share/enterprise/ghe-restore-network-routes" +if $CLUSTER; then + # The server returns a list of routes: + # + # a/nw/a8/3f/02/100000855 dgit-node1 dgit-node2 dgit-node3 + # a/nw/a8/bc/8d/100000880 dgit-node1 dgit-node2 dgit-node4 + # a/nw/a5/06/81/100000659 dgit-node3 dgit-node2 dgit-node4 + # ... + # + # One route per line. + # + # NOTE: The route generation is performed on the appliance as it is considerably + # more performant than performing over an SSH pipe. + # + bm_start "$(basename $0) - Transferring network list" + cat $tmp_list | ghe-ssh "$GHE_HOSTNAME" -- sponge $remote_tmp_list + cat $tmp_list | ghe_debug + bm_end "$(basename $0) - Transferring network list" + + bm_start "$(basename $0) - Generating routes" + restore_routes_script="github-env ./bin/dgit-cluster-restore-routes" + if ghe-ssh "$GHE_HOSTNAME" test -e /usr/local/share/enterprise/ghe-restore-network-routes; then + restore_routes_script="/usr/local/share/enterprise/ghe-restore-network-routes" + fi + echo "cat $remote_tmp_list | $restore_routes_script | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash + ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug + bm_end "$(basename $0) - Generating routes" + + bm_start "$(basename $0) - Fetching routes" + ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list + cat $routes_list | ghe_debug + bm_end "$(basename $0) - Fetching routes" + + bm_start "$(basename $0) - Processing routes" + + cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' + cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore + ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" + bm_end "$(basename $0) - Processing routes" +else + # In noncluster setups, the primary instance owns all repository networks, so all network paths + # are to be synchronized to the primary instance. + cp "$tmp_list" "$tempdir/git-server-primary.rsync" fi -echo "cat $remote_tmp_list | $restore_routes_script | grep 'git-server-' > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug -bm_end "$(basename $0) - Generating routes" - -bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list -cat $routes_list | ghe_debug -bm_end "$(basename $0) - Fetching routes" - -bm_start "$(basename $0) - Processing routes" -cat $routes_list | awk -v tempdir="$tempdir" '{ for(i=2;i<=NF;i++){ print $1 > (tempdir"/"$i".rsync") }}' -cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore -ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" -bm_end "$(basename $0) - Processing routes" if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then log_warn "Warning: no routes found, skipping repositories restore ..." From 632da3cb50f7a3e0bda2f5b248dc70e52d4c00ef Mon Sep 17 00:00:00 2001 From: Zheng Zeng Date: Tue, 25 Jul 2023 15:55:56 +0000 Subject: [PATCH 1993/2421] make increment inline --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b65c61f28..65e863b56 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -714,7 +714,7 @@ init-progress() { #increase total count of progress increment-progress-total-count() { - PROGRESS_TOTAL=$((PROGRESS_TOTAL + $1)) + ((PROGRESS_TOTAL += $1)) echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total } From 0671226fcd779b044736eb2a8ef425e3138a559d Mon Sep 17 00:00:00 2001 From: Diana Date: Wed, 26 Jul 2023 03:01:28 -0700 Subject: [PATCH 1994/2421] Update rsync version warning to remove cat --- bin/ghe-host-check | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 4473c2dc1..211ea8c78 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -219,14 +219,10 @@ DATA_TRANSFER_SIZE echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 exit 1 elif [[ $rsync_version < 3.2.5 ]] && [[ $RSYNC_WARNING != "no" ]]; then - cat << WARN_MSG 1>&2 -**WARNING:** rsync version $rsync_version on backup host is less than 3.2.5, which could result in performance degradation. - -For more details, please read documentation at https://github.com/github/backup-utils/blob/master/docs/requirements.md#april-2023-update-of-rsync-requirements - -You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.config file. - -WARN_MSG + printf "\n **WARNING:** rsync version %s on backup host is less than 3.2.5, which could result in performance degradation. + For more details, please read documentation at https://gh.io/april-2023-update-of-rsync-requirements + You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.config file.\n\n" \ + "$rsync_version" 1>&2 fi echo " - rsync ${rsync_version} >= required ($min_rsync)" 1>&2 From 24ec2c670a141afbb9224f062c3111b9d7f79cc3 Mon Sep 17 00:00:00 2001 From: Zheng Zeng Date: Wed, 26 Jul 2023 15:23:49 +0000 Subject: [PATCH 1995/2421] fix test --- bin/ghe-backup | 4 +++- bin/ghe-restore | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index ae6dd0f0d..4bd8d5bb3 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -46,6 +46,8 @@ export CALLING_SCRIPT="ghe-backup" # Setup progress tracking init-progress +export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14 +echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total export PROGRESS_TYPE="Backup" echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type export PROGRESS=0 # Used to track progress of backup @@ -72,7 +74,7 @@ if [ "$GHE_BACKUP_PAGES" != "no" ]; then OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) fi -PROGRESS_TOTAL=$((OPTIONAL_STEPS + 14)) # Minimum number of steps in backup is 14 +PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14 echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check diff --git a/bin/ghe-restore b/bin/ghe-restore index 428227426..6d646ad54 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -311,11 +311,11 @@ fi export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7)) init-progress +echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total export PROGRESS_TYPE="Restore" echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type export PROGRESS=0 # Used to track progress of restore echo "$PROGRESS" > /tmp/backup-utils-progress -echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) From c670c4eae21dd0161a83ba3cf49a7ca28611b3fd Mon Sep 17 00:00:00 2001 From: Kylie Stradley <4666485+KyFaSt@users.noreply.github.com> Date: Wed, 26 Jul 2023 16:18:33 +0000 Subject: [PATCH 1996/2421] create the encrypted column current encryption key backup on 3.7.0+ * the previous implementation effectively only created the current encryption key backup on versions 3.8.0+ which does not help in the situation when a customer is upgrading from 3.7 to 3.8 or 3.9 --- share/github-backup-utils/ghe-backup-settings | 3 - test/test-ghe-backup.sh | 66 +++++++------------ 2 files changed, 25 insertions(+), 44 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 43bd41029..3a05feba7 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -83,9 +83,6 @@ backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-s # this is for forwards compatibility with GHES 3.8.0 onwards if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" -fi - -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then cat "$GHE_SNAPSHOT_DIR/encrypted-column-encryption-keying-material" | sed 's:.*;::' > "$GHE_SNAPSHOT_DIR/encrypted-column-current-encryption-key" fi diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 8fd42948e..f1b730d4e 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -555,17 +555,6 @@ begin_test "ghe-backup takes backup of kredz-varz settings" ) end_test -begin_test "ghe-backup does not take backup of encrypted column encryption keying material for versions below 3.7.0" -( - GHE_REMOTE_VERSION=2.1.10 ghe-backup -v | grep -q "encrypted column encryption keying material not set" && exit 1 - [ ! -f "$GHE_DATA_DIR/current/encrypted-column-keying-material" ] - - GHE_REMOTE_VERSION=3.6.1 ghe-backup -v | grep -q "encrypted column encryption keying material not set" && exit 1 - [ ! -f "$GHE_DATA_DIR/current/encrypted-column-keying-material" ] - -) -end_test - begin_test "ghe-backup takes backup of encrypted column encryption keying material and create encrypted column current encryption key for versions 3.7.0+" ( set -e @@ -586,6 +575,7 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi required_files=( "encrypted-column-encryption-keying-material" + "encrypted-column-current-encryption-key" ) for file in "${required_files[@]}"; do @@ -598,35 +588,6 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi ghe-backup - required_files=( - "encrypted-column-encryption-keying-material" - ) - - for file in "${required_files[@]}"; do - [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] - done - -) -end_test - -begin_test "ghe-backup takes backup of encrypted column encryption keying material and encrypted column current encryption key for versions 3.8.0+" -( - set -e - - required_secrets=( - "secrets.github.encrypted-column-keying-material" - ) - - for secret in "${required_secrets[@]}"; do - ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" - done - - # GHES version 3.8.0 - GHE_REMOTE_VERSION=3.8.0 - export GHE_REMOTE_VERSION - - ghe-backup - required_files=( "encrypted-column-encryption-keying-material" "encrypted-column-current-encryption-key" @@ -666,7 +627,30 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi ghe-ssh "$GHE_HOSTNAME" -- /bin/bash done - # GHES version 3.8.0 + # GHES version 3.7.0 + GHE_REMOTE_VERSION=3.7.0 + export GHE_REMOTE_VERSION + + ghe-backup + + required_files=( + "encrypted-column-encryption-keying-material" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo;bar" ] + done + + required_files_current_encryption_key=( + "encrypted-column-current-encryption-key" + ) + + for file in "${required_files_current_encryption_key[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "bar" ] + done + + + # GHES version 3.8.0 GHE_REMOTE_VERSION=3.8.0 export GHE_REMOTE_VERSION From 91b21fe085105f34ea4b03690fb3ec7fa2dcf7a3 Mon Sep 17 00:00:00 2001 From: David Daly Date: Thu, 27 Jul 2023 16:22:52 +0000 Subject: [PATCH 1997/2421] backup container prefix for actions --- share/github-backup-utils/ghe-backup-config | 14 +++++++------- share/github-backup-utils/ghe-backup-settings | 1 + share/github-backup-utils/ghe-restore-actions | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 31e9aff0a..00bcf716e 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -372,13 +372,13 @@ export GHE_DATA_DIR : "${GHE_RELEASE_FILE:="/etc/github/enterprise-release"}" # Check that utils are not being run directly on GHE appliance. -if [ -f "$GHE_RELEASE_FILE" ]; then - echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 - echo " The backup utilities should be run on a host dedicated to" 1>&2 - echo " long-term permanent storage and must have network connectivity" 1>&2 - echo " with the GitHub Enterprise appliance." 1>&2 - exit 1 -fi +# if [ -f "$GHE_RELEASE_FILE" ]; then +# echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 +# echo " The backup utilities should be run on a host dedicated to" 1>&2 +# echo " long-term permanent storage and must have network connectivity" 1>&2 +# echo " with the GitHub Enterprise appliance." 1>&2 +# exit 1 +# fi GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 43bd41029..ad1c4e49c 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -122,6 +122,7 @@ if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then backup-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" --best-effort backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" + backup-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" backup-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" backup-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 93596033a..af33c60d4 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -68,6 +68,7 @@ restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secr restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" +restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" restore-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" restore-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" From 591416ccd98ddd9065362ac74efaa488aba18b06 Mon Sep 17 00:00:00 2001 From: David Daly Date: Thu, 27 Jul 2023 18:47:17 +0000 Subject: [PATCH 1998/2421] fix track-progress --- share/github-backup-utils/track-progress | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 3f67ca9e8..1381cbbef 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -7,7 +7,7 @@ progress(){ PROGRESS=$(cat /tmp/backup-utils-progress) PROGRESS_TYPE=$(cat /tmp/backup-utils-progress-type) - PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) + PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100") echo $((PROGRESS +1)) > /tmp/backup-utils-progress echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress-info } From d83e0085ff44d355167ec066b418a45244941cec Mon Sep 17 00:00:00 2001 From: David Daly Date: Fri, 28 Jul 2023 18:31:21 +0000 Subject: [PATCH 1999/2421] update to only restore prefix when using -c --- share/github-backup-utils/ghe-backup-config | 14 +++++++------- share/github-backup-utils/ghe-restore-actions | 8 +++++++- share/github-backup-utils/track-progress | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 00bcf716e..31e9aff0a 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -372,13 +372,13 @@ export GHE_DATA_DIR : "${GHE_RELEASE_FILE:="/etc/github/enterprise-release"}" # Check that utils are not being run directly on GHE appliance. -# if [ -f "$GHE_RELEASE_FILE" ]; then -# echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 -# echo " The backup utilities should be run on a host dedicated to" 1>&2 -# echo " long-term permanent storage and must have network connectivity" 1>&2 -# echo " with the GitHub Enterprise appliance." 1>&2 -# exit 1 -# fi +if [ -f "$GHE_RELEASE_FILE" ]; then + echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 + echo " The backup utilities should be run on a host dedicated to" 1>&2 + echo " long-term permanent storage and must have network connectivity" 1>&2 + echo " with the GitHub Enterprise appliance." 1>&2 + exit 1 +fi GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index af33c60d4..3db864c6f 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -68,7 +68,6 @@ restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secr restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" -restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" restore-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" restore-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" @@ -86,6 +85,13 @@ restore-secret "Actions Launch service private key" "actions-launch-app-app-priv restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" "secrets.launch.token-oauth-key" restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert" +# Restore storage container prefix, but only if the `-c` option is used with ghe-restore +# `-c` should be used if restoring to an unconfigured appliance or when sif restoring to an unconfigured appliance or when +# specified manually. +# This is to avoid a staging instance using the same bucket prefix settings as production in the case of a staging instance restored from production +if $RESTORE_SETTINGS; then + restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" +fi # Setup the database logins. ghe_verbose "* Restoring database logins and users to $host ..." diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 1381cbbef..3f67ca9e8 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -7,7 +7,7 @@ progress(){ PROGRESS=$(cat /tmp/backup-utils-progress) PROGRESS_TYPE=$(cat /tmp/backup-utils-progress-type) - PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100") + PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) echo $((PROGRESS +1)) > /tmp/backup-utils-progress echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress-info } From 5529410f9517ba44ae52e2e96c8683057a74150b Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 1 Aug 2023 18:37:03 -0400 Subject: [PATCH 2000/2421] Incremental MySQL Backups and Restores (#366) Implementing incremental mysql backups for 3.10 Co-authored-by: Dax Amin Co-authored-by: Manuel Bergler Co-authored-by: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> --- .gitignore | 2 + bin/ghe-backup | 31 +- bin/ghe-restore | 23 +- share/github-backup-utils/ghe-backup-config | 7 +- share/github-backup-utils/ghe-backup-mysql | 8 + .../ghe-backup-mysql-binary | 46 +- .../ghe-incremental-backup-restore | 397 ++++++++++++++++++ share/github-backup-utils/ghe-prune-snapshots | 86 +++- .../ghe-restore-mysql-binary | 61 ++- share/github-backup-utils/version | 2 +- test/test-ghe-backup.sh | 61 +++ test/testlib.sh | 12 + 12 files changed, 705 insertions(+), 31 deletions(-) create mode 100644 share/github-backup-utils/ghe-incremental-backup-restore diff --git a/.gitignore b/.gitignore index 246384181..e6a5a2890 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /backup.config /data /dist +dash +parallel diff --git a/bin/ghe-backup b/bin/ghe-backup index 62359899b..d818c6be4 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -27,6 +27,10 @@ while true; do export GHE_VERBOSE=true shift ;; + -i|--incremental) + export GHE_INCREMENTAL=true + shift + ;; -*) echo "Error: invalid argument: '$1'" 1>&2 exit 1 @@ -173,17 +177,34 @@ if [ -f ../in-progress ]; then fi fi +# Perform a host connection check and establish the remote appliance version. +# The version is available in the GHE_REMOTE_VERSION variable and also written +# to a version file in the snapshot directory itself. +ghe_remote_version_required +echo "$GHE_REMOTE_VERSION" > version + +# check that incremental settings are valid if set +is_inc=$(is_incremental_backup_feature_on) + +if [ "$is_inc" = true ]; then +if [ "$GHE_VERSION_MAJOR" -lt 3 ] && [ "$GHE_VERSION_MINOR" -lt 10 ]; then + log_error "Cannot only perform incremental backups on enterprise version 3.10 or higher" + exit 1 +fi + incremental_backup_check + # If everything is ok, check if we have hit GHE_MAX_INCREMENTAL_BACKUPS, performing pruning actions if necessary + check_for_incremental_max_backups + # initialize incremental backup if it hasn't been done yet + incremental_backup_init +fi + echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress echo "$GHE_SNAPSHOT_TIMESTAMP $$" > "${GHE_DATA_DIR}/in-progress-backup" START_TIME=$(date +%s) log_info "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" -# Perform a host connection check and establish the remote appliance version. -# The version is available in the GHE_REMOTE_VERSION variable and also written -# to a version file in the snapshot directory itself. -ghe_remote_version_required -echo "$GHE_REMOTE_VERSION" > version + if [ -n "$GHE_ALLOW_REPLICA_BACKUP" ]; then echo "Warning: backing up a high availability replica may result in inconsistent or unreliable backups." diff --git a/bin/ghe-restore b/bin/ghe-restore index 6d646ad54..67061265b 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -71,6 +71,10 @@ while true; do export GHE_VERBOSE=true shift ;; + -i|--incremental) + export GHE_INCREMENTAL=true + shift + ;; -*) echo "Error: invalid argument: '$1'" 1>&2 exit 1 @@ -321,6 +325,21 @@ echo "$PROGRESS" > /tmp/backup-utils-progress START_TIME=$(date +%s) log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" +if [ "$GHE_INCREMENTAL" ]; then + log_info "Incremental restore from snapshot $GHE_RESTORE_SNAPSHOT" + # If we see 'inc_previous' prepended to the snapshot name, then + # we set $INC_FULL_BACKUP and $INC_SNAPSHOT_DATA to $INC_PREVIOUS_FULL_BACKUP and + # $INC_PREVIOUS_SNAPSHOT_DATA respectively. Otherwise, leave them at default setting + # so that incremental restore is from current cycle + if [[ "$GHE_RESTORE_SNAPSHOT" =~ ^inc_previous ]]; then + INC_FULL_BACKUP=$INC_PREVIOUS_FULL_BACKUP + INC_SNAPSHOT_DATA=$INC_PREVIOUS_SNAPSHOT_DATA + log_info "Incremental restore from previous cycle snapshot. Using $INC_FULL_BACKUP" + log_info "Incremental restore from previous cycle snapshot. Using $INC_SNAPSHOT_DATA" + fi + log_info "Validating snapshot $GHE_RESTORE_SNAPSHOT" + validate_inc_snapshot_data "$GHE_RESTORE_SNAPSHOT" +fi ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." # Create an in-progress-restore file to prevent simultaneous backup or restore runs echo "${START_TIME} $$" > "${GHE_DATA_DIR}/in-progress-restore" @@ -498,6 +517,8 @@ else ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 fi + + if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then log_info "Stopping Actions before restoring databases ..." # We mark Actions as stopped even if the `ghe-actions-stop` @@ -601,7 +622,7 @@ fi log_info "Restarting memcached ..." 1>&3 bm_start "$(basename $0) - Restarting memcached" echo "sudo restart -q memcached 2>/dev/null || true" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh +ghe-ssh "$GHE_HOSTNAME" -- /bin/sh bm_end "$(basename $0) - Restarting memcached" # Prevent GitHub Connect jobs running before we've had a chance to reset diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 65e863b56..02a8df435 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -183,6 +183,8 @@ fi PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # shellcheck source=share/github-backup-utils/bm.sh . "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" +# shellcheck source=share/github-backup-utils/ghe-incremental-backup-restore +. "$GHE_BACKUP_ROOT/share/github-backup-utils/ghe-incremental-backup-restore" # shellcheck source=share/github-backup-utils/track-progress . "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" # Save off GHE_HOSTNAME from the environment since we want it to override the @@ -712,12 +714,9 @@ init-progress() { rm -f /tmp/backup-utils-progress* } + #increase total count of progress increment-progress-total-count() { ((PROGRESS_TOTAL += $1)) echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total } - - - - diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql index 0ae9172ce..733051bc4 100755 --- a/share/github-backup-utils/ghe-backup-mysql +++ b/share/github-backup-utils/ghe-backup-mysql @@ -33,6 +33,14 @@ else if is_binary_backup_feature_on; then ghe-backup-mysql-binary else + # if incremental backups are turned on, we can't do them with + # logical backups, so we need to tell the user and exit + is_inc=$(is_incremental_backup_feature_on) + if [ $is_inc = true ]; then + log_warn "Incremental backups are configured on the target environment." + log_warn "Incremental backup is not supported with a logical MySQL backup. Please disable incremental backups with 'ghe-config mysql.backup.incremental false'" + exit 1 + fi ghe-backup-mysql-logical fi fi diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary index 70091cbba..106757c71 100755 --- a/share/github-backup-utils/ghe-backup-mysql-binary +++ b/share/github-backup-utils/ghe-backup-mysql-binary @@ -16,9 +16,45 @@ bm_start "$(basename $0)" ghe_remote_version_required "$GHE_HOSTNAME" log_verbose "Backing up MySQL database using binary backup strategy ..." - -echo "set -o pipefail; ghe-export-mysql" | -ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" -echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" - +is_inc=$(is_incremental_backup_feature_on) +if [ $is_inc = true ]; then + log_verbose "Incremental backups are configured on the target environment." + log_info "Performing incremental backup of MySQL database ..." 1>&3 + INC_TYPE=$(full_or_incremental_backup) + INC_LSN="" + if [ "$INC_TYPE" == "full" ]; then + log_info "Incremental backup type: $INC_TYPE" 1>&3 + INC_LSN=0 # 0 means full backup + else + validate_inc_snapshot_data + log_info "Incremental backup type: $INC_TYPE" 1>&3 + INC_LSN=$(retrieve_last_lsn) + fi + echo "set -o pipefail; env INC_BACKUP=$INC_LSN ghe-export-mysql" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" + echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" + # Ensure that we capture the xtrabackup_checkpoints file from the remote host + log_info "Checking if incremental backup is part of a cluster" + GET_LSN=$(get_cluster_lsn "$GHE_HOSTNAME") + ghe-ssh "$GHE_HOSTNAME" "$GET_LSN" > "$GHE_SNAPSHOT_DIR/xtrabackup_checkpoints" + if [ "$INC_TYPE" == "full" ]; then + log_info "Adding $GHE_SNAPSHOT_DIR to the list of full backups" 1>&3 + update_inc_full_backup "$GHE_SNAPSHOT_DIR" + else + log_info "Adding $GHE_SNAPSHOT_DIR to the list of incremental backups" 1>&3 + update_inc_snapshot_data "$GHE_SNAPSHOT_DIR" + fi + bm_end "$(basename $0)" + exit 0 +fi +# if incremental backup isn't enabled, or we are performing a full backup as part of the process, +# fall through and do a full backup + echo "set -o pipefail; ghe-export-mysql" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" + echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" + is_inc=$(is_incremental_backup_feature_on) + if [ $is_inc = true ]; then + update_inc_full_backup "$GHE_SNAPSHOT_DIR" + fi bm_end "$(basename $0)" + diff --git a/share/github-backup-utils/ghe-incremental-backup-restore b/share/github-backup-utils/ghe-incremental-backup-restore new file mode 100644 index 000000000..fd1309fe6 --- /dev/null +++ b/share/github-backup-utils/ghe-incremental-backup-restore @@ -0,0 +1,397 @@ +#!/bin/bash +# ghe-incremental-backup-restore +# contains functions used for incremental backups and restores. +# Not called directly, but rather sourced from other scripts. +# Incremental backups are only supported on backup-utils 3.10 and greater. + +# INC_FULL_BACKUP is a file that tracks the last full backup that we have done for the current incremental backup cycle. +export INC_FULL_BACKUP="inc_full_backup" +# INC_PREVIOUS_FULL_BACKUP is a file that tracks the last full backup that we have done for the previous incremental backup cycle. +# Kept around for a cycle to ensure that we have a rolling window of incremental backups. +export INC_PREVIOUS_FULL_BACKUP="inc_previous_full_backup" +# PRUNE_FULL_BACKUP is a file that tracks the full backups that need to be pruned. +export PRUNE_FULL_BACKUP="prune_inc_previous_full_backup" +# INC_SNAPSHOT_DATA is a file that tracks the incremental backups that we have done for the current incremental backup cycle. +export INC_SNAPSHOT_DATA="inc_snapshot_data" +# INC_PREVIOUS_SNAPSHOT_DATA is a file that tracks the incremental backups that we have done for the previous incremental backup cycle. +export INC_PREVIOUS_SNAPSHOT_DATA="inc_previous_snapshot_data" +# PRUNE_SNAPSHOT_DATA is a file that tracks the incremental backups that need to be pruned. +export PRUNE_SNAPSHOT_DATA="prune_inc_previous_snapshot_data" + +# Check if incremental backups are enabled. +is_incremental_backup_feature_on() { + if [ "$GHE_INCREMENTAL" ]; then + echo "true" + else + echo "false" + fi +} + +# Do sanity checks on incremental backups. +incremental_backup_check() { + if $GHE_INCREMENTAL; then + if [ -z "$GHE_INCREMENTAL_MAX_BACKUPS" ]; then + log_error "incremental backups require GHE_INCREMENTAL_MAX_BACKUPS to be set" 1>&2 + exit 1 + fi + if [ "$GHE_INCREMENTAL_MAX_BACKUPS" -lt 1 ]; then + log_error "GHE_INCREMENTAL_MAX_BACKUPS must be greater than 0" 1>&3 + exit 1 + fi + fi +} + +# initialize incremental backup. We create a file 'inc_snapshot_data' +# in $GHE_DATA_DIR to track the incremental backups that we have done. +# We also create a file called 'inc_full_backup' that tracks the last +# full backup that we have done that the incremental backups are based on. +# If the file does not exist, we create it and leave it blank. +incremental_backup_init() { + if $GHE_INCREMENTAL; then + if [ ! -f "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA" ]; then + touch "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA" + fi + if [ ! -f "$GHE_DATA_DIR/$INC_FULL_BACKUP" ]; then + touch "$GHE_DATA_DIR/$INC_FULL_BACKUP" + fi + fi +} + +# if incremental backups are enabled, we check if we have up to max incremental backups +# if we do, if there are no folders with 'inc_previous', we move the current list of +# incremental backups to 'inc_previous_snapshot_data' and 'inc_previous_full_backup' +# using set_previous_incremental_backup. If there are folders with 'inc_previous', we +# prune them using set_prune_incremental_backup. +check_for_incremental_max_backups(){ + if $GHE_INCREMENTAL; then + # decrement the number of snapshots by 1 to account for the full backup + if [ "$(cat "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA" | wc -l)" -ge "$((GHE_INCREMENTAL_MAX_BACKUPS-1))" ]; then + if [ -z "$(ls -d "$GHE_DATA_DIR"/inc_previous* 2>/dev/null)" ]; then + set_to_inc_previous + else + set_to_prune + set_to_inc_previous + fi + fi + fi +} +# retrieve the lsn of the snapshot directory passed in as an argument +# from xtrabackup_checkpoint which would be in $GHE_DATA_DIR/ +retrieve_lsn(){ + local lsn + if $GHE_INCREMENTAL; then + if [ -z "$1" ]; then + log_error "retrieve_lsn requires a snapshot directory to be passed in" 1>&3 + exit 1 + fi + if [ ! -d "$1" ]; then + log_error "retrieve_lsn requires a valid snapshot directory to be passed in" 1>&3 + exit 1 + fi + if [ ! -f "$1/xtrabackup_checkpoints" ]; then + log_error "retrieve_lsn requires a valid xtrabackup_checkpoints file in $1" 1>&3 + exit 1 + fi + lsn=$(grep 'to_lsn' < "$1/xtrabackup_checkpoints" | cut -d' ' -f3) + echo "$lsn" + fi +} +# retrieve the lsn of the last snapshot directory in the file 'inc_snapshot_data' +# use that directory to call the retrieve_lsn function to get the lsn +# if inc_snapshot_data is empty, use the full backup directory to get the lsn + +retrieve_last_lsn(){ + local lsn backup_data last_snapshot_dir + if $GHE_INCREMENTAL; then + if [ ! -f "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA" ]; then + log_error "retrieve_last_lsn requires a valid inc_snapshot_data file in $GHE_DATA_DIR" 1>&3 + exit 1 + fi + if [ -z "$(cat "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA")" ]; then + backup_data=$(cat "$GHE_DATA_DIR/$INC_FULL_BACKUP") + lsn=$(retrieve_lsn "$backup_data") + log_info "No incremental backups have been done yet. Using full backup directory $backup_data to get previous lsn ($lsn)" 1>&3 + else + last_snapshot_dir=$(tail -n 1 "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA") + log_info "Using incremental directory $last_snapshot_dir to get previous lsn" 1>&3 + lsn=$(retrieve_lsn "$last_snapshot_dir") + fi + echo "$lsn" + fi +} + +# determine if we need to do a full backup or an incremental backup +# based on the number of snapshots we have and the number of incremental +# backups we have done. If we have done GHE_INCREMENTAL_MAX_BACKUPS +# incremental backups, we do a full backup. Otherwise, we do an incremental +# backup. We also do a full backup if we have not done any backups yet. +# We determine that by checking the value of the file 'inc_full_backup' +# in $GHE_DATA_DIR. If the file is blank, we need to do a full backup. +# If the file exists and points to a directory, then we are doing an incremental. +full_or_incremental_backup(){ + if $GHE_INCREMENTAL; then + if [ ! -f "$GHE_DATA_DIR/$INC_FULL_BACKUP" ]; then + echo "full" + elif [ -z "$(cat "$GHE_DATA_DIR/$INC_FULL_BACKUP")" ]; then + echo "full" + elif [ "$(cat "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA" | wc -l)" == "$GHE_INCREMENTAL_MAX_BACKUPS" ]; then + echo "full" + else + echo "incremental" + fi + fi +} + +# add snapshot directory to the list of incremental backups we have done +# in the file 'inc_snapshot_data' in $GHE_DATA_DIR. +update_inc_snapshot_data(){ + if $GHE_INCREMENTAL; then + if [ -z "$1" ]; then + log_error "update_snapshot_data requires a snapshot directory to be passed in" 1>&3 + exit 1 + fi + INC_DATA_DIR="$GHE_DATA_DIR/$(basename $1)" + if [ ! -d "$INC_DATA_DIR" ]; then + log_error "update_snapshot_data requires a valid snapshot directory to be passed in" 1>&3 + exit 1 + fi + echo "$1" >> "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA" + fi +} + +# update the file 'inc_full_backup' in $GHE_DATA_DIR to point to the passed in +# snapshot directory. This is the snapshot directory that the incremental backups +# will be based on. +update_inc_full_backup(){ + if $GHE_INCREMENTAL; then + if [ -z "$1" ]; then + log_error "update_inc_full_backup requires a snapshot directory to be passed in" 1>&3 + exit 1 + fi + DIR="$GHE_DATA_DIR/$(basename "$1")" + if [ ! -d "$DIR" ]; then + log_error "update_inc_full_backup requires a valid snapshot directory to be passed in" 1>&3 + exit 1 + fi + echo "$1" > "$GHE_DATA_DIR/$INC_FULL_BACKUP" + fi +} + +# validate that inc_snapshot_data file. For each snapshot directory in the file, +# the directory should exist and its lsn retrieved from xtrabackups_checkpoint +# should be lower than the next snapshot directory in the file. If the lsn is +# not lower, then we have a problem and we warn the user and tell them to perform +# a full backup. +validate_inc_snapshot_data(){ + if $GHE_INCREMENTAL; then + local snapshot_data full_data lines snapshot_data_array snapshot_data_array_length i + + snapshot_data=$(cat "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA") + if [ -z "$snapshot_data" ]; then + log_info "no incremental snapshots yet, will make first incremental from full backup" 1>&3 + full_data=$(cat "$GHE_DATA_DIR/$INC_FULL_BACKUP") + log_info "validating full backup $full_data" 1>&3 + snapshot_data="$full_data" + fi + readarray -t snapshot_data_array <<< "$snapshot_data" + snapshot_data_array_length=${#snapshot_data_array[@]} + log_info "$snapshot_data_array_length snapshot directories found in inc_snapshot_data" + i=0 + # I would normally use a for loop here, but I need to utilize before + # and after values of the array index to compare the lsn values + while [ $i -lt "$snapshot_data_array_length" ]; do + # if this is the first snapshot directory, we don't need to compare + # it to the previous snapshot directory + if [ "$snapshot_data_array_length" -gt 0 ]; then + local snapshot_dir + + + snapshot_dir=${snapshot_data_array[$i]} + if [ ! -d "$snapshot_dir" ]; then + log_error "snapshot directory $snapshot_dir does not exist" 1>&3 + exit 1 + fi + local lsn next_lsn + log_info "retrieving lsn for snapshot directory $snapshot_dir" 1>&3 + lsn=$(retrieve_lsn "$snapshot_dir") + if [ $i -lt $((snapshot_data_array_length-1)) ]; then + local next_snapshot_dir + next_snapshot_dir=${snapshot_data_array[$((i+1))]} + next_lsn=$(retrieve_lsn "$next_snapshot_dir") + if [ "$lsn" -ge "$next_lsn" ]; then + log_error "snapshot directory $snapshot_dir has an lsn of $lsn which is greater than or equal to the next snapshot directory $next_snapshot_dir with an lsn of $next_lsn" 1>&2 + log_error "incremental backups are invalid. Please perform a full backup" 1>&3 + exit 1 + fi + log_info "$snapshot_dir lsn = $lsn, $next_snapshot_dir lsn = $next_lsn" 1>&3 + fi + i=$((i+1)) + else + log_info "retrieving lsn for snapshot directory $snapshot_data" 1>&3 + lsn=$(retrieve_lsn "$snapshot_data") + log_info "$snapshot_data is the only incremental snapshot, lsn=$lsn" 1>&3 + fi + done + fi +} + +# returns whether the supplied directory is in inc_full_backup or not. +# if the directory is in inc_full_backup, then we return true, otherwise +# we return false. +is_full_backup(){ + if [ -z "$1" ]; then + log_error "is_full_backup requires a snapshot directory to be passed in, received $1" 1>&3 + exit 1 + fi + BACKUP_DIR="$GHE_DATA_DIR/$(basename "$1")" + if [ ! -d "$BACKUP_DIR" ]; then + log_error "is_full_backup requires a valid snapshot directory to be passed in, received $1" 1>&3 + exit 1 + fi + if [ "$1" = "$(cat "$GHE_DATA_DIR/$INC_FULL_BACKUP")" ]; then + echo "true" + else + echo "false" + fi +} + +# returns the full backup directory from the inc_full_backup file +# should ever only be one line in the file +get_full_backup(){ + if $GHE_INCREMENTAL; then + backup_dir=$(cat "$GHE_DATA_DIR/$INC_FULL_BACKUP") + basename "$backup_dir" + fi +} + +# retrieve the incremental backups in the list up to and including the passed in +# snapshot directory. If the snapshot directory is not in the list, then we +# return a blank string. +get_incremental_backups(){ + if $GHE_INCREMENTAL; then + if [ -z "$1" ]; then + log_error "get_incremental_backups requires a snapshot directory to be passed in" 1>&3 + exit 1 + fi + if [ ! -d "$1" ]; then + log_error "get_incremental_backups requires a valid snapshot directory to be passed in" 1>&3 + exit 1 + fi + local incremental_backups + incremental_backups="" + snapshot_data=$(cat "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA") + while IFS= read -r line; do + if [[ "$line" == "$1" ]]; then + incremental_backups="$incremental_backups $(basename "$line")" + break + fi + incremental_backups="$incremental_backups $(basename "$line")" + done <<< "$snapshot_data" + echo "$incremental_backups" + fi +} + +get_cluster_lsn(){ + local GHE_HOSTNAME + GHE_HOSTNAME=$1 + + ghe-ssh "$GHE_HOSTNAME" "[ -f /etc/github/cluster ] && [ -z \"$LOCAL_MYSQL\" ]" + + if [ $? -eq 0 ]; then + local_host=$(ghe-ssh "$GHE_HOSTNAME" "cat /etc/github/cluster") + mysql_master=$(ghe-ssh "$GHE_HOSTNAME" "ghe-config cluster.mysql-master") + + if [ "$local_host" != "$mysql_master" ]; then + echo "ssh -p 122 admin@$mysql_master -- sudo cat /tmp/lsndir/xtrabackup_checkpoints" + else + echo "sudo cat /tmp/lsndir/xtrabackup_checkpoints" + fi + else + echo "sudo cat /tmp/lsndir/xtrabackup_checkpoints" + fi +} + +# Change our ssh command based on if we are in a cluster or not +# cluster_restore_ssh_cmd(){ +# local GHE_HOSTNAME +# GHE_HOSTNAME=$1 + +# ghe-ssh "$GHE_HOSTNAME" "[ -f /etc/github/cluster ] && [ -z \"$LOCAL_MYSQL\" ]" + +# if [ $? -eq 0 ]; then +# local_host=$(ghe-ssh "$GHE_HOSTNAME" "cat /etc/github/cluster") +# mysql_master=$(ghe-ssh "$GHE_HOSTNAME" "ghe-config cluster.mysql-master") + +# if [ "$local_host" != "$mysql_master" ]; then +# echo "ssh -p 122 admin@$mysql_master" +# else +# echo "" +# fi +# } + +# used to set the previous incremental backups. +# takes every directory in $GHE_DATA_DIR/$INC_FULL_BACKUP and +# $GHE_DATA_DIR/$INC_SNAPSHOT_DATA and renames them by prepending +# inc_previous to the beginning. We also change inc_full_backup and +# inc_snapshot_data to inc_previous_full_backup and inc_previous_snapshot_data +set_to_inc_previous(){ + log_info "setting previous incremental backups" 1>&3 + full_backup=$(cat "$GHE_DATA_DIR/$INC_FULL_BACKUP") + snapshot_data=$(cat "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA") + if [ -n "$full_backup" ]; then + inc_previous_full_backup_dir="inc_previous_$(basename "$full_backup")" + log_info "moving $full_backup to $GHE_DATA_DIR/$inc_previous_full_backup_dir" 1>&3 + mv "$full_backup" "$GHE_DATA_DIR/$inc_previous_full_backup_dir" + echo "$GHE_DATA_DIR/$inc_previous_full_backup_dir" > "$GHE_DATA_DIR/$INC_PREVIOUS_FULL_BACKUP" + log_info "removing $GHE_DATA_DIR/$INC_FULL_BACKUP" 1>&3 + rm -f "$GHE_DATA_DIR/$INC_FULL_BACKUP" + fi + if [ -n "$snapshot_data" ]; then + while IFS= read -r line; do + local inc_previous_snapshot_dir + inc_previous_snapshot_dir="inc_previous_$(basename "$line")" + log_info "moving $GHE_DATA_DIR/$line to $GHE_DATA_DIR/$inc_previous_snapshot_dir" 1>&3 + mv "$line" "$GHE_DATA_DIR/$inc_previous_snapshot_dir" + echo "$GHE_DATA_DIR/$inc_previous_snapshot_dir" >> "$GHE_DATA_DIR/$INC_PREVIOUS_SNAPSHOT_DATA" + done <<< "$snapshot_data" + log_info "removing $GHE_DATA_DIR/$INC_SNAPSHOT_DATA" 1>&3 + rm -f "$GHE_DATA_DIR/$INC_SNAPSHOT_DATA" + fi + +} + +# set directories prepended with "inc_previous" to be prepended with prune +# this enables the directories to be pruned by ghe-snapshot. +# Will prepend prune to each inc_previous folder in $GHE_DATA_DIR +# and will remove $GHE_DATA_DIR/inc_previous_full_backup and +# will remove $GHE_DATA_DIR/inc_previous_snapshot_data +set_to_prune(){ + log_info "setting previous incremental backups to be pruned" 1>&3 + previous_full_backup=$(cat "$GHE_DATA_DIR/$INC_PREVIOUS_FULL_BACKUP") + previous_snapshot_data=$(cat "$GHE_DATA_DIR/$INC_PREVIOUS_SNAPSHOT_DATA") + if [ -n "$previous_full_backup" ]; then + prune_full_backup_dir="prune_$(basename "$previous_full_backup")" + log_info "moving $GHE_DATA_DIR/$previous_full_backup to $GHE_DATA_DIR/$prune_full_backup_dir" 1>&3 + mv "$previous_full_backup" "$GHE_DATA_DIR/$prune_full_backup_dir" + mv "$GHE_DATA_DIR/$INC_PREVIOUS_FULL_BACKUP" "$GHE_DATA_DIR/$PRUNE_FULL_BACKUP" + log_info "removing $GHE_DATA_DIR/inc_previous_full_backup" 1>&3 + echo "$GHE_DATA_DIR/$prune_full_backup_dir" >> "$GHE_DATA_DIR/$PRUNE_FULL_BACKUP" + fi + if [ -n "$previous_snapshot_data" ]; then + while IFS= read -r line; do + local prune_snapshot_dir + prune_snapshot_dir="prune_$(basename "$line")" + log_info "moving $GHE_DATA_DIR/$line to $GHE_DATA_DIR/prune_$line" 1>&3 + mv "$line" "$GHE_DATA_DIR/$prune_snapshot_dir" + echo "$GHE_DATA_DIR/$prune_snapshot_dir" >> "$GHE_DATA_DIR/$PRUNE_SNAPSHOT_DATA" + done <<< "$previous_snapshot_data" + log_info "removing $GHE_DATA_DIR/$INC_PREVIOUS_SNAPSHOT_DATA" 1>&3 + rm -f "$GHE_DATA_DIR/$INC_PREVIOUS_SNAPSHOT_DATA" + fi + +} + +test_restore_output(){ + log_info "$INC_FULL_BACKUP" + log_info "$INC_SNAPSHOT_DATA" +} diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index 0da56df97..b71c39f0b 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -13,10 +13,51 @@ set -e prune_snapshot() { local prune_dir while read prune_dir; do - [ -n "$prune_dir" ] || return - touch "$prune_dir/incomplete" + [ -n "$prune_dir" ] || return + # ignore any directory that is included in inc_full_backup or inc_snapshot_data + # the files should be filtered out earlier, but this is a safeguard to make sure. + # inc_previous_* and prune_inc_previous are ignored by default + if grep -q "$prune_dir" "$GHE_DATA_DIR/inc_full_backup" || grep "$prune_dir" "$GHE_DATA_DIR/inc_snapshot_data"; then + continue + fi + # skip if the directory is not a directory or blank + if [ ! -d "$prune_dir" ] || [ -z "$prune_dir" ]; then + log_info "Skipping blank or non-directory: $prune_dir" 1>&3 + continue + fi + +# Track these steps as they can be difficult to track down if they fail. + + log_info "Pruning directory $prune_dir" 1>&3 + touch "$prune_dir/incomplete" + if [ $? -ne 0 ]; then + log_info "Failed to create $prune_dir/incomplete" 1>&3 + fi + find "$prune_dir" -mindepth 1 -maxdepth 1 -not -path "$prune_dir/incomplete" -print0 | xargs -0 rm -rf + if [ $? -ne 0 ] ; then + log_info "Failed to prune $prune_dir" 1>&3 + fi + rm -rf "$prune_dir" + if [ $? -ne 0 ]; then + log_info "Failed to remove $prune_dir" 1>&3 + fi + done +} + +# Utilize similar logic for incremental backups, except we will only prune directories that start with "prune_". Any directory +# prepended with this will be pruned. Otherwise, we use similar logic to the prune_snapshot function. +prune_incremental_snapshot() { + local incremental_prune_dir + + while read incremental_prune_dir; do + if [ -d "$incremental_prune_dir" ]; then + touch "$incremental_prune_dir/incomplete" + find "$incremental_prune_dir" -mindepth 1 -maxdepth 1 -not -path "$incremental_prune_dir/incomplete" -print0 | xargs -0 rm -rf + fi + + rm -rf "$incremental_prune_dir" done } @@ -28,6 +69,7 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]] || [ -z "$inprogress_file" ]; then # First prune all incomplete / failed snapshot directories prune_dirs="$(ls -1 "$GHE_DATA_DIR"/[0-9]*/incomplete 2>/dev/null || true)" prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) + incremental_prune_dirs="$(ls -1 "$GHE_DATA_DIR"/prune* 2>/dev/null || true)" if [ $prune_num -gt 0 ]; then log_info Pruning $prune_num "failed snapshot(s) ..." @@ -37,12 +79,40 @@ if [[ "$CALLING_SCRIPT" == "ghe-backup" ]] || [ -z "$inprogress_file" ]; then # Now prune all expired snapshots. Keep GHE_NUM_SNAPSHOTS around. snapshot_count=$(ls -1d "$GHE_DATA_DIR"/[0-9]* 2>/dev/null | wc -l) - if [ "$snapshot_count" -gt "$GHE_NUM_SNAPSHOTS" ]; then - prune_dirs="$(ls -1d "$GHE_DATA_DIR"/[0-9]* | sort -r | awk "NR>$GHE_NUM_SNAPSHOTS")" - prune_num=$(echo "$prune_dirs" | grep -v '^$' | wc -l) - log_info Pruning $prune_num "expired snapshot(s) ..." - echo "$prune_dirs" | prune_snapshot - fi +if [ "$snapshot_count" -gt "$GHE_NUM_SNAPSHOTS" ]; then + # Get the list of directories that need pruning + dirs_to_prune="" + if [ -f "$GHE_DATA_DIR/inc_full_backup" ]; then +# Read the list of directories from inc_full_backup file into the exclude_list +exclude_list=$(cat "$GHE_DATA_DIR"/inc_full_backup | tr '\n' ' ') + +# Add inc_snapshot_data directory to the exclude_list +exclude_list+=" $(cat "$GHE_DATA_DIR"/inc_snapshot_data)" + log_info "Excluding directories from pruning: $exclude_list" 1>&3 + scan_dirs="$(ls -1d "$GHE_DATA_DIR"/[0-9]*)" + log_info "Scanning directories: $scan_dirs" 1>&3 + dirs_to_prune=$(echo "$scan_dirs" | grep -v -F "$exclude_list" | sort -r | awk "NR > $GHE_NUM_SNAPSHOTS") + else + dirs_to_prune="$(ls -1d "$GHE_DATA_DIR"/[0-9]* | sort -r | awk "NR>$GHE_NUM_SNAPSHOTS")" + fi + + # Count the number of directories to be pruned + prune_num=$(echo "$dirs_to_prune" | grep -c '^') + + log_info "Pruning $prune_num expired snapshot(s) ..." + log_info "Pruning directories: $dirs_to_prune" 1>&3 + echo "$dirs_to_prune" | prune_snapshot +fi + +# Prune incremental snapshots afterward +incremental_snapshot_count=$(ls -1d "$GHE_DATA_DIR"/prune* 2>/dev/null | wc -l) +if [ $incremental_snapshot_count -gt 0 ]; then + incremental_prune_dirs="$(ls -1d "$GHE_DATA_DIR"/prune*)" + log_info "Pruning $incremental_snapshot_count stale incremental backups..." + echo "$incremental_prune_dirs" | prune_incremental_snapshot +fi + + elif [ "$CALLING_SCRIPT" != "ghe-backup" ] && [ -n "$inprogress_file" ]; then log_info "Detected a running backup/restore process, please wait until that process is complete to prune expired/incomplete snapshots." 1>&2 log_info "If no such process is running, please remove the "$GHE_DATA_DIR/in-progress*" file and retry again." 1>&2 diff --git a/share/github-backup-utils/ghe-restore-mysql-binary b/share/github-backup-utils/ghe-restore-mysql-binary index 2a4374c88..b35fd7392 100755 --- a/share/github-backup-utils/ghe-restore-mysql-binary +++ b/share/github-backup-utils/ghe-restore-mysql-binary @@ -17,6 +17,13 @@ bm_start "$(basename $0)" # Grab host arg GHE_HOSTNAME="$1" +if [ "$GHE_INCREMENTAL" ]; then +echo "Incremental backup is configured." +else +echo "I don't see that incremental backup is configured. $GHE_INCREMENTAL" +fi + +#exit 0 # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. ghe_remote_version_required "$GHE_HOSTNAME" @@ -57,17 +64,57 @@ else fi cleanup() { - ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz" + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf $GHE_REMOTE_DATA_USER_DIR/tmp/*" + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo rm -rf /tmp/incremental-backup-files.txt" } trap 'cleanup' INT TERM EXIT - +log_info "Creating temporary directory on remote host at $GHE_REMOTE_DATA_USER_DIR/tmp ..." 1>&3 ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp'" 1>&3 -# Transfer MySQL data from the snapshot to the GitHub instance. -cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" +# If incremental restore is enabled, we need to upload the incremental backup file to the remote host +# We get a list of all the incremental backup files up to the snapshot we want to restore +# If the snapshot happens to be a full backup, we don't need to upload any incremental backup files +# Otherwise we follow this procedure: +# - for each incremental backup, create a directory in the format: +# $GHE_REMOTE_DATA_USER_DIR/tmp/incremental-restore-snapshot-dir/mysql.sql.gz +# - upload the incremental backup file to the directory +is_full=$(is_full_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT") +is_inc=$(is_incremental_backup_feature_on) -log_info "Restore MySQL database ..." -# Import the database -echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 +if [ "$is_inc" = true ] && [ "$is_full" = false ]; then + log_info "Uploading incremental backup directories to the remote host ..." 1>&3 + full_backup_dir=$(get_full_backup) + log_info "Full backup directory: $full_backup_dir" 1>&3 + #recreate the incremental-backup-files.txt file + if [ -f "/tmp/incremental-backup-files.txt" ]; then + rm "/tmp/incremental-backup-files.txt" + fi + touch "/tmp/incremental-backup-files.txt" + for incremental_backup in $(get_incremental_backups "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"); do + echo "$incremental_backup" >> "/tmp/incremental-backup-files.txt" + log_info "Incremental files to upload: $incremental_backup" 1>&3 + log_info "Creating directory $GHE_REMOTE_DATA_USER_DIR/tmp/$incremental_backup on remote host..." 1>&3 + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- " sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/tmp/$incremental_backup'" + log_info "Uploading incremental backup file $GHE_DATA_DIR/$incremental_backup to the remote host ..." 1>&3 + cat "$GHE_DATA_DIR/$incremental_backup/mysql.sql.gz" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- " sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/$incremental_backup/mysql.sql.gz >/dev/null 2>&1" + done + + # Transfer the full backup to the remote host + log_info "Uploading full backup file $GHE_DATA_DIR/$full_backup_dir/mysql.sql.gz to the remote host ..." 1>&3 + cat $GHE_DATA_DIR/$full_backup_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" + # Pass the list of incremental backup files + ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- " sudo dd of=/tmp/incremental-backup-files.txt >/dev/null 2>&1" < "/tmp/incremental-backup-files.txt" + # Restore the full backup and the incremental backup files + log_info "Restoring full backup from $GHE_REMOTE_DATA_USER_DIR/tmp/full/mysql.sql.gz ..." 1>&3 + echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 + + +else + log_info "Uploading $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mysql.sql.gz MySQL data to the remote host $GHE_RESTORE_HOST in $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz ..." 1>&3 + cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" + log_info "Restore MySQL database ..." + # Import the database + echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 +fi bm_end "$(basename $0)" diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index a5c4c7633..30291cba2 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.9.0 +3.10.0 diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index f1b730d4e..46df090f8 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -50,6 +50,67 @@ begin_test "ghe-backup subsequent snapshot" ) end_test +begin_test "ghe-backup incremental" +( + set -e + sleep 1 + + setup_incremental_backup_config + + # check that no current symlink exists yet + [ -d "$GHE_DATA_DIR/current" ] + + # run it + # this time expect full backup + ghe-backup -i + + # check metadata files are created + [ -e "$GHE_DATA_DIR/inc_full_backup" ] + [ -e "$GHE_DATA_DIR/inc_snapshot_data" ] + + # check the metadata + expected_full_backup=$(wc -l < "$GHE_DATA_DIR/inc_full_backup") + expected_incremental_backup=$(wc -l < "$GHE_DATA_DIR/inc_snapshot_data") + # should have 1 full backup and 0 incremental backup + [ $expected_full_backup -eq 1 ] + [ $expected_incremental_backup -eq 0 ] + + # re-run + # this time expect incremental backup + ghe-backup -i + + expected_full_backup=$(wc -l < "$GHE_DATA_DIR/inc_full_backup") + expected_incremental_backup=$(wc -l < "$GHE_DATA_DIR/inc_snapshot_data") + # should have 1 full backup and 1 incremental backup + [ $expected_full_backup -eq 1 ] + [ $expected_incremental_backup -eq 1 ] + + # re-run + # this time expect yet another incremental backup + ghe-backup -i + + expected_full_backup=$(wc -l < "$GHE_DATA_DIR/inc_full_backup") + expected_incremental_backup=$(wc -l < "$GHE_DATA_DIR/inc_snapshot_data") + # should have 1 full backup and 2 incremental backup + [ $expected_full_backup -eq 1 ] + [ $expected_incremental_backup -eq 2 ] +) +end_test + +begin_test "ghe-backup incremental without config" +( + set -e + sleep 1 + + # set incorrect config for incremental backup + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config mysql.backup.binary false' + export GHE_INCREMENTAL_MAX_BACKUPS=1 + + # check ghe-backup fails + ! ghe-backup -i +) +end_test + begin_test "ghe-backup logs the benchmark" ( set -e diff --git a/test/testlib.sh b/test/testlib.sh index e17fc3fd2..5dd5ac451 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -327,6 +327,14 @@ setup_test_data () { setup_minio_test_data "$GHE_DATA_DIR" } +setup_incremental_backup_config() { + ghe-ssh "$GHE_HOSTNAME" -- 'mkdir -p /tmp/lsndir' + ghe-ssh "$GHE_HOSTNAME" -- 'echo "fake xtrabackup checkpoint" > /tmp/lsndir/xtrabackup_checkpoints' + + enable_binary_backup + export GHE_INCREMENTAL_MAX_BACKUPS=10 +} + setup_actions_test_data() { local loc=$1 @@ -583,6 +591,10 @@ is_minio_enabled() { ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled' } +enable_binary_backup() { + ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config mysql.backup.binary true' +} + setup_moreutils_parallel() { # CI servers may have moreutils parallel and GNU parallel installed. # We need moreutils parallel From d9b90b4e5da311ef0940805d55fc9050ae7a93d0 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 2 Aug 2023 14:01:12 -0400 Subject: [PATCH 2001/2421] Cat inc full backups fix (#461) * Initial commit of incremental backups Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Add more backup functions Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * add restore implementation * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Subject line (try to keep under 50 characters) Multi-line description of commit, feel free to be detailed. * Add basic test * bug fix when checking incremental backup on * functional test * tests for incremental backup * revert version * typo * add end_test * Makes command work in cluster or HA * updating version * Update bin/ghe-restore Co-authored-by: Manuel Bergler * Put test of version in correct place * implement moving to inc_previous and prune_ * adding incremental max detection * Adding tweaks to restore * remove redis code * tweak pruning * typo fix * Amend pruning test * tweak pruning snapshots * finalizing tweaks to snapshot pruning * troubleshooting * tweaking ghe-prune-snapshots * last tweaks * Resolve #7039 --------- Co-authored-by: Dax Amin Co-authored-by: Manuel Bergler --- .../ghe-incremental-backup-restore | 17 ----------------- .../ghe-restore-mysql-binary | 9 +++++++-- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/share/github-backup-utils/ghe-incremental-backup-restore b/share/github-backup-utils/ghe-incremental-backup-restore index fd1309fe6..860f35775 100644 --- a/share/github-backup-utils/ghe-incremental-backup-restore +++ b/share/github-backup-utils/ghe-incremental-backup-restore @@ -311,23 +311,6 @@ get_cluster_lsn(){ fi } -# Change our ssh command based on if we are in a cluster or not -# cluster_restore_ssh_cmd(){ -# local GHE_HOSTNAME -# GHE_HOSTNAME=$1 - -# ghe-ssh "$GHE_HOSTNAME" "[ -f /etc/github/cluster ] && [ -z \"$LOCAL_MYSQL\" ]" - -# if [ $? -eq 0 ]; then -# local_host=$(ghe-ssh "$GHE_HOSTNAME" "cat /etc/github/cluster") -# mysql_master=$(ghe-ssh "$GHE_HOSTNAME" "ghe-config cluster.mysql-master") - -# if [ "$local_host" != "$mysql_master" ]; then -# echo "ssh -p 122 admin@$mysql_master" -# else -# echo "" -# fi -# } # used to set the previous incremental backups. # takes every directory in $GHE_DATA_DIR/$INC_FULL_BACKUP and diff --git a/share/github-backup-utils/ghe-restore-mysql-binary b/share/github-backup-utils/ghe-restore-mysql-binary index b35fd7392..afff663eb 100755 --- a/share/github-backup-utils/ghe-restore-mysql-binary +++ b/share/github-backup-utils/ghe-restore-mysql-binary @@ -78,9 +78,13 @@ ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo mkdir -p '$GHE_REMOTE_ # - for each incremental backup, create a directory in the format: # $GHE_REMOTE_DATA_USER_DIR/tmp/incremental-restore-snapshot-dir/mysql.sql.gz # - upload the incremental backup file to the directory -is_full=$(is_full_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT") -is_inc=$(is_incremental_backup_feature_on) +is_full=true +is_inc=false +if [ "$GHE_INCREMENTAL" ]; then + is_full=$(is_full_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT") + is_inc=$(is_incremental_backup_feature_on) +fi if [ "$is_inc" = true ] && [ "$is_full" = false ]; then log_info "Uploading incremental backup directories to the remote host ..." 1>&3 full_backup_dir=$(get_full_backup) @@ -109,6 +113,7 @@ if [ "$is_inc" = true ] && [ "$is_full" = false ]; then echo "cat $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz | $IMPORT_MYSQL" | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- /bin/bash 1>&3 + else log_info "Uploading $GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mysql.sql.gz MySQL data to the remote host $GHE_RESTORE_HOST in $GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz ..." 1>&3 cat $snapshot_dir/mysql.sql.gz | ghe-ssh $ssh_config_file_opt "$GHE_RESTORE_HOST" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/tmp/mysql.sql.gz >/dev/null 2>&1" From 950846f460ad7b05f5d44fd47babff9b36866d41 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Wed, 2 Aug 2023 14:26:29 -0400 Subject: [PATCH 2002/2421] Add details about snapshot pruning --- docs/scheduling-backups.md | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/docs/scheduling-backups.md b/docs/scheduling-backups.md index 87eefc14c..2b581f968 100644 --- a/docs/scheduling-backups.md +++ b/docs/scheduling-backups.md @@ -4,7 +4,6 @@ Regular backups should be scheduled using `cron(8)` or similar command scheduling service on the backup host. The backup frequency will dictate the worst case [recovery point objective (RPO)][1] in your backup plan. We recommend hourly backups at the least. - ## Example scheduling usage The following examples assume the Backup Utilities are installed under @@ -17,30 +16,36 @@ based on the frequency of backups. The ten most recent snapshots are retained by default. The number should be adjusted based on backup frequency and available storage. -By default all expired and incomplete snapshots are deleted at the end of the main -backup process `ghe-backup`. If pruning these snapshots takes a long time you can -choose to disable the pruning process from the backup run and schedule it separately. -This can be achieved by enabling the `GHE_PRUNING_SCHEDULED` option in `backup.config`. -Please note if this option is enabled, you will need to schedule the pruning script `ghe-prune-snapshots` -using `cron` or similar command scheduling service on the backup host. - To schedule hourly backup snapshots with verbose informational output written to a log file and errors generating an email: +``` +MAILTO=admin@example.com - MAILTO=admin@example.com - - 0 * * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +0 * * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +``` To schedule nightly backup snapshots instead, use: - MAILTO=admin@example.com +``` +MAILTO=admin@example.com - 0 0 * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +0 0 * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 +``` + +### Example snapshot pruning + +By default all expired and incomplete snapshots are deleted at the end of the main +backup process `ghe-backup`. If pruning these snapshots takes a long time you can +choose to disable the pruning process from the backup run and schedule it separately. +This can be achieved by enabling the `GHE_PRUNING_SCHEDULED` option in `backup.config`. +Please note that this option is only avilable for `backup-utils` >= v3.10.0, if this option is enabled you will need to schedule the pruning script `ghe-prune-snapshots` using `cron` or a similar command scheduling service on the backup host. To schedule daily snapshot pruning, use: - MAILTO=admin@example.com +``` +MAILTO=admin@example.com - 0 3 * * * /opt/backup-utils/share/github-backup-utils/ghe-prune-snapshots 1>>/opt/backup-utils/prune-snapshots.log 2>&1 +0 3 * * * /opt/backup-utils/share/github-backup-utils/ghe-prune-snapshots 1>>/opt/backup-utils/prune-snapshots.log 2>&1 +``` [1]: https://en.wikipedia.org/wiki/Recovery_point_objective From 12c2505b1299d576fea0312daee612ea473e8f4e Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 2 Aug 2023 18:50:20 +0000 Subject: [PATCH 2003/2421] Remove duplicate code --- share/github-backup-utils/ghe-backup-config | 25 --------------------- 1 file changed, 25 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 02a8df435..b61f5a8c0 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -191,31 +191,6 @@ PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # backup.config value when set. GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" -# Source in the backup config file from the copy specified in the environment -# first and then fall back to the backup-utils root, home directory and system. -config_found=false -for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ - "$HOME/.github-backup-utils/backup.config" "/etc/github-backup-utils/backup.config"; do - if [ -f "$f" ]; then - GHE_BACKUP_CONFIG="$f" - # shellcheck disable=SC1090 # This is a user-supplied value that can't be predicted - . "$GHE_BACKUP_CONFIG" - config_found=true - break - fi -done - -# If we don't have a readlink command, error out -! type readlink 1>/dev/null 2>&1 && { - echo "Error: readlink not found. Please install readlink and ensure it is in your PATH." 1>&2 - exit 1 -} - -GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore") -GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup") - -export GHE_RESTORE_IN_PROGRESS -export GHE_BACKUP_IN_PROGRESS ghe_restore_check() { if [ -h "$GHE_RESTORE_IN_PROGRESS" ]; then From 4210881c233efaf4dc9cdd71e6649e5eb8413647 Mon Sep 17 00:00:00 2001 From: David Daly Date: Wed, 2 Aug 2023 21:12:52 +0000 Subject: [PATCH 2004/2421] allow backups on gheboot for testing --- share/github-backup-utils/ghe-backup-config | 14 +++++++------- share/github-backup-utils/ghe-restore-actions | 10 ++++++++++ share/github-backup-utils/track-progress | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 31e9aff0a..00bcf716e 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -372,13 +372,13 @@ export GHE_DATA_DIR : "${GHE_RELEASE_FILE:="/etc/github/enterprise-release"}" # Check that utils are not being run directly on GHE appliance. -if [ -f "$GHE_RELEASE_FILE" ]; then - echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 - echo " The backup utilities should be run on a host dedicated to" 1>&2 - echo " long-term permanent storage and must have network connectivity" 1>&2 - echo " with the GitHub Enterprise appliance." 1>&2 - exit 1 -fi +# if [ -f "$GHE_RELEASE_FILE" ]; then +# echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 +# echo " The backup utilities should be run on a host dedicated to" 1>&2 +# echo " long-term permanent storage and must have network connectivity" 1>&2 +# echo " with the GitHub Enterprise appliance." 1>&2 +# exit 1 +# fi GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 3db864c6f..a24997453 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -92,6 +92,16 @@ restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert if $RESTORE_SETTINGS; then restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" fi +# Restore storage container prefix, but only if the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings +# This value will only be present in backups from versions >= 3.10 so needs to be wrapped in version checks. +# if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then +# snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) +# # shellcheck disable=SC2046 # Word splitting is required to populate the variables +# read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) +# if [ "$(version $snapshot_version_major.$snapshot_version_minor.0)" -a $RESTORE_SETTINGS ]; then +# restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" +# fi +# fi # Setup the database logins. ghe_verbose "* Restoring database logins and users to $host ..." diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 3f67ca9e8..1381cbbef 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -7,7 +7,7 @@ progress(){ PROGRESS=$(cat /tmp/backup-utils-progress) PROGRESS_TYPE=$(cat /tmp/backup-utils-progress-type) - PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) + PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100") echo $((PROGRESS +1)) > /tmp/backup-utils-progress echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress-info } From 54b7224298a660dbec688f5af7c15d7edac7d222 Mon Sep 17 00:00:00 2001 From: David Daly Date: Wed, 2 Aug 2023 21:49:04 +0000 Subject: [PATCH 2005/2421] add check for greater than 3.9 --- share/github-backup-utils/ghe-restore-actions | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index a24997453..4eb846f7d 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -85,23 +85,16 @@ restore-secret "Actions Launch service private key" "actions-launch-app-app-priv restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" "secrets.launch.token-oauth-key" restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert" -# Restore storage container prefix, but only if the `-c` option is used with ghe-restore -# `-c` should be used if restoring to an unconfigured appliance or when sif restoring to an unconfigured appliance or when -# specified manually. -# This is to avoid a staging instance using the same bucket prefix settings as production in the case of a staging instance restored from production -if $RESTORE_SETTINGS; then - restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" -fi # Restore storage container prefix, but only if the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings # This value will only be present in backups from versions >= 3.10 so needs to be wrapped in version checks. -# if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then -# snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) -# # shellcheck disable=SC2046 # Word splitting is required to populate the variables -# read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) -# if [ "$(version $snapshot_version_major.$snapshot_version_minor.0)" -a $RESTORE_SETTINGS ]; then -# restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" -# fi -# fi +if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then + snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) + # shellcheck disable=SC2046 # Word splitting is required to populate the variables + read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) + if [ "$snapshot_version_major" -eq "3" -a "$snapshot_version_minor" -ge "9" -a $RESTORE_SETTINGS ]; then + restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" + fi +fi # Setup the database logins. ghe_verbose "* Restoring database logins and users to $host ..." From dc95625544e4956c5898c1b8fde38a96e17b7e87 Mon Sep 17 00:00:00 2001 From: David Daly Date: Wed, 2 Aug 2023 22:16:57 +0000 Subject: [PATCH 2006/2421] update to check for 3.10 --- share/github-backup-utils/ghe-backup-config | 14 +++++++------- share/github-backup-utils/ghe-restore-actions | 2 +- share/github-backup-utils/track-progress | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 1203e346c..02a8df435 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -374,13 +374,13 @@ export GHE_DATA_DIR : "${GHE_RELEASE_FILE:="/etc/github/enterprise-release"}" # Check that utils are not being run directly on GHE appliance. -# if [ -f "$GHE_RELEASE_FILE" ]; then -# echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 -# echo " The backup utilities should be run on a host dedicated to" 1>&2 -# echo " long-term permanent storage and must have network connectivity" 1>&2 -# echo " with the GitHub Enterprise appliance." 1>&2 -# exit 1 -# fi +if [ -f "$GHE_RELEASE_FILE" ]; then + echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 + echo " The backup utilities should be run on a host dedicated to" 1>&2 + echo " long-term permanent storage and must have network connectivity" 1>&2 + echo " with the GitHub Enterprise appliance." 1>&2 + exit 1 +fi GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 4eb846f7d..d5b493e3c 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -91,7 +91,7 @@ if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) # shellcheck disable=SC2046 # Word splitting is required to populate the variables read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) - if [ "$snapshot_version_major" -eq "3" -a "$snapshot_version_minor" -ge "9" -a $RESTORE_SETTINGS ]; then + if [ "$snapshot_version_major" -eq "3" -a "$snapshot_version_minor" -ge "10" -a $RESTORE_SETTINGS ]; then restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" fi fi diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index 00a9d2c65..bf50c42aa 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -11,4 +11,4 @@ progress(){ PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) echo $((PROGRESS + 1)) > /tmp/backup-utils-progress echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress-info -} \ No newline at end of file +} From e05b21ff9fd315f2cc2bf3babcc220b934b255b5 Mon Sep 17 00:00:00 2001 From: David Daly Date: Wed, 2 Aug 2023 22:31:46 +0000 Subject: [PATCH 2007/2421] fix linting --- share/github-backup-utils/ghe-restore-actions | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index d5b493e3c..78f75ab31 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -88,10 +88,10 @@ restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert # Restore storage container prefix, but only if the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings # This value will only be present in backups from versions >= 3.10 so needs to be wrapped in version checks. if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then - snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) + snapshot_version=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/version") # shellcheck disable=SC2046 # Word splitting is required to populate the variables - read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) - if [ "$snapshot_version_major" -eq "3" -a "$snapshot_version_minor" -ge "10" -a $RESTORE_SETTINGS ]; then + read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version "$snapshot_version") + if [[ "$snapshot_version_major" -eq "3" && "$snapshot_version_minor" -ge "10" && $RESTORE_SETTINGS ]]; then restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" fi fi From 116350d6880f04fc5d345ab60a4869e3e3b1c523 Mon Sep 17 00:00:00 2001 From: David Daly Date: Wed, 2 Aug 2023 23:26:26 +0000 Subject: [PATCH 2008/2421] cleanup version check --- share/github-backup-utils/ghe-restore-actions | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 78f75ab31..8a67da02f 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -87,13 +87,11 @@ restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert # Restore storage container prefix, but only if the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings # This value will only be present in backups from versions >= 3.10 so needs to be wrapped in version checks. -if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then - snapshot_version=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/version") - # shellcheck disable=SC2046 # Word splitting is required to populate the variables - read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version "$snapshot_version") - if [[ "$snapshot_version_major" -eq "3" && "$snapshot_version_minor" -ge "10" && $RESTORE_SETTINGS ]]; then - restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" - fi +snapshot_version=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/version") +# shellcheck disable=SC2046 # Word splitting is required to populate the variables +read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version "$snapshot_version") +if [[ $RESTORE_SETTINGS && "$snapshot_version_major" -eq "3" && "$snapshot_version_minor" -ge "10"]]; then + restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" fi # Setup the database logins. From f210a47080b02473268dd340ed8de80cf182adb6 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 2 Aug 2023 23:29:25 +0000 Subject: [PATCH 2009/2421] check for file presence --- share/github-backup-utils/ghe-prune-snapshots | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-prune-snapshots b/share/github-backup-utils/ghe-prune-snapshots index b71c39f0b..84c64545f 100755 --- a/share/github-backup-utils/ghe-prune-snapshots +++ b/share/github-backup-utils/ghe-prune-snapshots @@ -17,9 +17,20 @@ prune_snapshot() { # ignore any directory that is included in inc_full_backup or inc_snapshot_data # the files should be filtered out earlier, but this is a safeguard to make sure. # inc_previous_* and prune_inc_previous are ignored by default - if grep -q "$prune_dir" "$GHE_DATA_DIR/inc_full_backup" || grep "$prune_dir" "$GHE_DATA_DIR/inc_snapshot_data"; then - continue + if [ -f "$GHE_DATA_DIR/inc_full_backup" ]; then + if grep -q "$prune_dir" "$GHE_DATA_DIR"/inc_full_backup; then + log_info "Skipping incremental backup directory: $prune_dir" 1>&3 + continue + fi + fi + + if [ -f "$GHE_DATA_DIR/inc_snapshot_data" ]; then + if grep -q "$prune_dir" "$GHE_DATA_DIR"/inc_snapshot_data; then + log_info "Skipping incremental backup directory: $prune_dir" 1>&3 + continue + fi fi + # skip if the directory is not a directory or blank if [ ! -d "$prune_dir" ] || [ -z "$prune_dir" ]; then log_info "Skipping blank or non-directory: $prune_dir" 1>&3 From 40dbc40df5b0d159ac8b977fa3260c1812603454 Mon Sep 17 00:00:00 2001 From: David Daly Date: Thu, 3 Aug 2023 00:39:05 +0000 Subject: [PATCH 2010/2421] fix test --- share/github-backup-utils/ghe-restore-actions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 8a67da02f..cdc5480b5 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -90,7 +90,7 @@ restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert snapshot_version=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/version") # shellcheck disable=SC2046 # Word splitting is required to populate the variables read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version "$snapshot_version") -if [[ $RESTORE_SETTINGS && "$snapshot_version_major" -eq "3" && "$snapshot_version_minor" -ge "10"]]; then +if [[ $RESTORE_SETTINGS && "$snapshot_version_major" -eq "3" && "$snapshot_version_minor" -ge "10" ]]; then restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" fi From acca07136c1ac90aefce6615ccafd81567ca0065 Mon Sep 17 00:00:00 2001 From: David Daly Date: Thu, 3 Aug 2023 00:54:14 +0000 Subject: [PATCH 2011/2421] fix restore settings check --- share/github-backup-utils/ghe-restore-actions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index cdc5480b5..d30d54488 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -90,7 +90,7 @@ restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert snapshot_version=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/version") # shellcheck disable=SC2046 # Word splitting is required to populate the variables read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version "$snapshot_version") -if [[ $RESTORE_SETTINGS && "$snapshot_version_major" -eq "3" && "$snapshot_version_minor" -ge "10" ]]; then +if [[ $RESTORE_SETTINGS == "true" && "$snapshot_version_major" -eq "3" && "$snapshot_version_minor" -ge "10" ]]; then restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" fi From c64f6fc6d0f25ed5ba60c4465826ff54cd519f7c Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 3 Aug 2023 19:20:58 +0000 Subject: [PATCH 2012/2421] add option for skipping checks --- backup.config-example | 4 ++++ bin/ghe-backup | 12 +++++++++--- bin/ghe-host-check | 8 +++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/backup.config-example b/backup.config-example index f20ec4e51..3119e2585 100644 --- a/backup.config-example +++ b/backup.config-example @@ -20,6 +20,10 @@ GHE_NUM_SNAPSHOTS=10 # ghe-pruning-snapshots will need to be invoked separately via cron #GHE_PRUNING_SCHEDULED=yes +# If set to true or when backup is run with `-s` or `--skip-checks` ghe-host-check +# disk space validation is disabled. +# GHE_SKIP_CHECKS=false + # The hostname of the GitHub appliance to restore. If you've set up a separate # GitHub appliance to act as a standby for recovery, specify its IP or hostname # here. The host to restore to may also be specified directly when running diff --git a/bin/ghe-backup b/bin/ghe-backup index d818c6be4..fbf7a395f 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -5,9 +5,11 @@ #/ the MySQL database, instance settings, GitHub Pages data, etc. #/ #/ OPTIONS: -#/ -v | --verbose Enable verbose output. -#/ -h | --help Show this message. -#/ --version Display version information. +#/ -v | --verbose Enable verbose output. +#/ -h | --help Show this message. +#/ --version Display version information. +#/ -i | --incremental Incremental backup +#/ -s | --skip-checks Skip storage/sw version checks #/ set -e @@ -31,6 +33,10 @@ while true; do export GHE_INCREMENTAL=true shift ;; + -s|--skip-checks) + export GHE_SKIP_CHECKS=true + shift + ;; -*) echo "Error: invalid argument: '$1'" 1>&2 exit 1 diff --git a/bin/ghe-host-check b/bin/ghe-host-check index e404d5447..a93c67cf8 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -144,7 +144,12 @@ if [ -z "$supported" ]; then exit 1 fi -if [[ "$CALLING_SCRIPT" == "ghe-backup" ]]; then +if [[ "$CALLING_SCRIPT" == "ghe-backup" && "$GHE_SKIP_CHECKS" != "true" ]]; then + cat << SKIP_MSG 1>&2 +**You can disable the following storage & version checks by updating GHE_SKIP_CHECKS to 'true' in your backup.config file. + +SKIP_MSG + # Bring in the requirements file min_rsync="" min_openssh="" @@ -184,6 +189,7 @@ minio: $minio_disk_size MB mysql: $mysql_disk_size MB actions: $actions_disk_size MB mssql: $mssql_disk_size MB + DATA_TRANSFER_SIZE if [[ $((available_space / (1024 * 1024))) -lt $min_disk_req ]]; then From a0a1a9fbec22aa02e25084c49dcebbad60420278 Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Fri, 4 Aug 2023 15:30:59 +0900 Subject: [PATCH 2013/2421] update mssl scripts to exit 1 on failure --- share/github-backup-utils/ghe-backup-mssql | 2 +- share/github-backup-utils/ghe-restore-mssql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 37b09ca9d..b22a4c2eb 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -62,7 +62,7 @@ fi if ! export_tool_available ; then log_error "ghe-export-mssql is not available" 1>&2 - exit + exit 1 fi add_minute() { diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index 3b62ce2c8..e7d48c61f 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -57,7 +57,7 @@ fi if ! import_tool_available; then ghe_verbose "ghe-import-mssql is not available" - exit + exit 1 fi # Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. From d4c7dd95570df6a9b712e9b995b4ebdd7e9fd573 Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Mon, 7 Aug 2023 15:40:27 +0900 Subject: [PATCH 2014/2421] make super-linter happy --- .shellcheckrc | 1 + share/github-backup-utils/ghe-restore-mssql | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 .shellcheckrc diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 000000000..1135b65a4 --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1 @@ +disable=SC2002 #useless cat \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index e7d48c61f..e6fbb58e8 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -22,11 +22,11 @@ import_tool_available() { } ghe_ssh_mssql() { - ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "$@" + ghe-ssh "$opts" "$ssh_config_file_opt" "$GHE_MSSQL_PRIMARY_HOST" "$@" } cleanup() { - rm -rf $tempdir + rm -rf "$tempdir" } trap 'cleanup' EXIT INT @@ -65,7 +65,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" # The snapshot to restore should be set by the ghe-restore command but this lets # us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} +: "${GHE_RESTORE_SNAPSHOT:=current}" # The directory holding the snapshot to restore snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" @@ -79,13 +79,13 @@ do filename="${b##*/}" ghe_verbose "Transferring $filename to appliance host" - cat $snapshot_dir_mssql/$filename | ghe_ssh_mssql "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" + cat "$snapshot_dir_mssql/$filename" | ghe_ssh_mssql "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" done # Change owner to mssql:mssql to ready for restore ghe_ssh_mssql "sudo chown -R mssql:mssql $appliance_dir" # Invoke restore command -bm_start "$(basename $0)" +bm_start "$(basename "$0")" ghe_ssh_mssql -- "ghe-import-mssql" < "/dev/null" 1>&3 -bm_end "$(basename $0)" +bm_end "$(basename "$0")" From 3d81cf2c58a0d43ffe22df67b5db40489867fd5d Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 11:36:39 -0400 Subject: [PATCH 2015/2421] Update backup.config-example Co-authored-by: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 3119e2585..04d1b951b 100644 --- a/backup.config-example +++ b/backup.config-example @@ -21,7 +21,7 @@ GHE_NUM_SNAPSHOTS=10 #GHE_PRUNING_SCHEDULED=yes # If set to true or when backup is run with `-s` or `--skip-checks` ghe-host-check -# disk space validation is disabled. +# disk space validation and s/w version checks on the backup-host will be disabled. # GHE_SKIP_CHECKS=false # The hostname of the GitHub appliance to restore. If you've set up a separate From 8186e717cf5dd33e997b16ec789c923125c4e77a Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 11:37:52 -0400 Subject: [PATCH 2016/2421] Update README.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 153549d14..e84d313df 100644 --- a/docs/README.md +++ b/docs/README.md @@ -6,7 +6,7 @@ - **[GitHub Enterprise Server version requirements](requirements.md#github-enterprise-version-requirements)** - **[Getting started](getting-started.md)** - **[Using the backup and restore commands](usage.md)** -- **[Scheduling backups](scheduling-backups.md)** +- **[Scheduling backups & snapshot pruning](scheduling-backups.md)** - **[Backup snapshot file structure](backup-snapshot-file-structure.md)** - **[How does Backup Utilities differ from a High Availability replica?](faq.md)** - **[Docker](docker.md)** From 43020aebb6bb58613a4bdf5ad311aaf5fdb0df3b Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 11:45:46 -0400 Subject: [PATCH 2017/2421] Added details on how to skip disk and software preflight checks --- docs/usage.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index b4db45e73..a3d5ca5a8 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -73,13 +73,18 @@ appliance at IP "5.5.5.5": Restore of 5.5.5.5:122 from snapshot 20180326T020444 finished. To complete the restore process, please visit https://5.5.5.5/setup/settings to review and save the appliance configuration. -A different backup snapshot may be selected by passing the `-s` argument and the -datestamp-named directory from the backup location. +A different backup snapshot may be selected by passing the `-s` argument to `ghe-restore` and specifcying the +datestamp-named directory from the backup location as the value. The `ghe-backup` and `ghe-restore` commands also have a verbose output mode (`-v`) that lists files as they're being transferred. It's often useful to enable when output is logged to a file. +Every time you execute `ghe-backup` we verify the storage and software setup of the host +you [installed][1] Backup Utilities on, to make sure our [requirements][2] for the host are +met. You can disable this check using the `--skip-checks` argument or by +adding `GHE_SKIP_CHECKS=true` to your configuration file. + ### Restoring settings, TLS certificate, and license When restoring to a new GitHub Enterprise Server instance, settings, certificate, and @@ -107,3 +112,4 @@ GitHub Actions enabled, the following steps are required: Please refer to [GHES Documentation](https://docs.github.com/en/enterprise-server/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled) for more details. [1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md +[2]: requirements.md From c960d8cff9e9e46f79f2cc7f0361c93cb84430e6 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Mon, 7 Aug 2023 11:55:17 -0400 Subject: [PATCH 2018/2421] Don't run incremental backups or restores with versions < 3.10 (#471) --- bin/ghe-backup | 9 +++++++-- bin/ghe-restore | 8 ++++++++ test/test-ghe-backup.sh | 21 +++++++++++++++++---- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index d818c6be4..226c64be1 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -187,10 +187,15 @@ echo "$GHE_REMOTE_VERSION" > version is_inc=$(is_incremental_backup_feature_on) if [ "$is_inc" = true ]; then -if [ "$GHE_VERSION_MAJOR" -lt 3 ] && [ "$GHE_VERSION_MINOR" -lt 10 ]; then - log_error "Cannot only perform incremental backups on enterprise version 3.10 or higher" +if [ "$GHE_VERSION_MAJOR" -lt 3 ]; then + log_error "Can only perform incremental backups on enterprise version 3.10 or higher" exit 1 fi +if [ "$GHE_VERSION_MINOR" -lt 10 ]; then + log_error "Can only perform incremental backups on enterprise version 3.10 or higher" + exit 1 +fi + incremental_backup_check # If everything is ok, check if we have hit GHE_MAX_INCREMENTAL_BACKUPS, performing pruning actions if necessary check_for_incremental_max_backups diff --git a/bin/ghe-restore b/bin/ghe-restore index 67061265b..92ae72443 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -326,6 +326,14 @@ START_TIME=$(date +%s) log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" if [ "$GHE_INCREMENTAL" ]; then + if [ "$GHE_VERSION_MAJOR" -lt 3 ]; then + log_error "Can only perform incremental restores on enterprise version 3.10 or higher" + exit 1 +fi +if [ "$GHE_VERSION_MINOR" -lt 10 ]; then + log_error "Can only perform incremental restores on enterprise version 3.10 or higher" + exit 1 +fi log_info "Incremental restore from snapshot $GHE_RESTORE_SNAPSHOT" # If we see 'inc_previous' prepended to the snapshot name, then # we set $INC_FULL_BACKUP and $INC_SNAPSHOT_DATA to $INC_PREVIOUS_FULL_BACKUP and diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 46df090f8..745538264 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -62,7 +62,7 @@ begin_test "ghe-backup incremental" # run it # this time expect full backup - ghe-backup -i + GHE_TEST_REMOTE_VERSION=3.10.0 ghe-backup -i # check metadata files are created [ -e "$GHE_DATA_DIR/inc_full_backup" ] @@ -77,7 +77,7 @@ begin_test "ghe-backup incremental" # re-run # this time expect incremental backup - ghe-backup -i + GHE_TEST_REMOTE_VERSION=3.10.0 ghe-backup -i expected_full_backup=$(wc -l < "$GHE_DATA_DIR/inc_full_backup") expected_incremental_backup=$(wc -l < "$GHE_DATA_DIR/inc_snapshot_data") @@ -87,7 +87,7 @@ begin_test "ghe-backup incremental" # re-run # this time expect yet another incremental backup - ghe-backup -i + GHE_TEST_REMOTE_VERSION=3.10.0 ghe-backup -i expected_full_backup=$(wc -l < "$GHE_DATA_DIR/inc_full_backup") expected_incremental_backup=$(wc -l < "$GHE_DATA_DIR/inc_snapshot_data") @@ -107,10 +107,23 @@ begin_test "ghe-backup incremental without config" export GHE_INCREMENTAL_MAX_BACKUPS=1 # check ghe-backup fails - ! ghe-backup -i + ! GHE_TEST_REMOTE_VERSION=3.10.0 ghe-backup -i ) end_test +begin_test "ghe-backup performs proper version check" +( + set -e + sleep 1 + + setup_incremental_backup_config + + #check ghe-backup fails + ! GHE_TEST_REMOTE_VERSION=3.9.0 ghe-backup -i + ! GHE_TEST_REMOTE_VERSION=3.8.0 ghe-backup -i + ! GHE_TEST_REMOTE_VERSION=2.2.0 ghe_backup -i +) + begin_test "ghe-backup logs the benchmark" ( set -e From 4c2ecb0716533a774b1f0d3035cd717e968a3bd7 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 12:13:03 -0400 Subject: [PATCH 2019/2421] Update docs/usage.md Co-authored-by: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index a3d5ca5a8..c603c5e36 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -73,7 +73,7 @@ appliance at IP "5.5.5.5": Restore of 5.5.5.5:122 from snapshot 20180326T020444 finished. To complete the restore process, please visit https://5.5.5.5/setup/settings to review and save the appliance configuration. -A different backup snapshot may be selected by passing the `-s` argument to `ghe-restore` and specifcying the +A different backup snapshot may be selected by passing the `-s` argument to `ghe-restore` and specifying the datestamp-named directory from the backup location as the value. The `ghe-backup` and `ghe-restore` commands also have a verbose output mode From 411772cc0ca1d941aa629996f06b2ffbb39cb092 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Mon, 7 Aug 2023 16:33:46 +0000 Subject: [PATCH 2020/2421] remove flag --- backup.config-example | 4 ++-- bin/ghe-backup | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backup.config-example b/backup.config-example index 04d1b951b..8a8e2fd13 100644 --- a/backup.config-example +++ b/backup.config-example @@ -20,9 +20,9 @@ GHE_NUM_SNAPSHOTS=10 # ghe-pruning-snapshots will need to be invoked separately via cron #GHE_PRUNING_SCHEDULED=yes -# If set to true or when backup is run with `-s` or `--skip-checks` ghe-host-check +# If set to true or when backup is run with `--skip-checks` ghe-host-check # disk space validation and s/w version checks on the backup-host will be disabled. -# GHE_SKIP_CHECKS=false +#GHE_SKIP_CHECKS=false # The hostname of the GitHub appliance to restore. If you've set up a separate # GitHub appliance to act as a standby for recovery, specify its IP or hostname diff --git a/bin/ghe-backup b/bin/ghe-backup index fbf7a395f..3c7399ca7 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -9,7 +9,7 @@ #/ -h | --help Show this message. #/ --version Display version information. #/ -i | --incremental Incremental backup -#/ -s | --skip-checks Skip storage/sw version checks +#/ --skip-checks Skip storage/sw version checks #/ set -e @@ -33,7 +33,7 @@ while true; do export GHE_INCREMENTAL=true shift ;; - -s|--skip-checks) + --skip-checks) export GHE_SKIP_CHECKS=true shift ;; From 062b5656c6582c5139666cb94ec9d2da52566625 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Mon, 7 Aug 2023 17:29:26 +0000 Subject: [PATCH 2021/2421] additional clarity --- bin/ghe-host-check | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index a93c67cf8..6c22d2d15 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -146,7 +146,8 @@ fi if [[ "$CALLING_SCRIPT" == "ghe-backup" && "$GHE_SKIP_CHECKS" != "true" ]]; then cat << SKIP_MSG 1>&2 -**You can disable the following storage & version checks by updating GHE_SKIP_CHECKS to 'true' in your backup.config file. +**You can disable the following storage & version checks by running ghe-backup with option "--skip-checks" +OR updating GHE_SKIP_CHECKS to 'true' in your backup.config file. SKIP_MSG From 90fdc58a5139b1ce428a202a3bbce06e73686097 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Mon, 7 Aug 2023 14:08:09 -0400 Subject: [PATCH 2022/2421] Update backup.config-example Co-authored-by: David Jarzebowski --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 8a8e2fd13..1038e5f5b 100644 --- a/backup.config-example +++ b/backup.config-example @@ -21,7 +21,7 @@ GHE_NUM_SNAPSHOTS=10 #GHE_PRUNING_SCHEDULED=yes # If set to true or when backup is run with `--skip-checks` ghe-host-check -# disk space validation and s/w version checks on the backup-host will be disabled. +# disk space validation and software version checks on the backup-host will be disabled. #GHE_SKIP_CHECKS=false # The hostname of the GitHub appliance to restore. If you've set up a separate From 4d3209d04aac5dead9979c1e3faf41c2d23aae7c Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Mon, 7 Aug 2023 14:47:19 -0400 Subject: [PATCH 2023/2421] Update backup.config-example Co-authored-by: David Jarzebowski --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 1038e5f5b..e679d74eb 100644 --- a/backup.config-example +++ b/backup.config-example @@ -20,7 +20,7 @@ GHE_NUM_SNAPSHOTS=10 # ghe-pruning-snapshots will need to be invoked separately via cron #GHE_PRUNING_SCHEDULED=yes -# If set to true or when backup is run with `--skip-checks` ghe-host-check +# If GHE_SKIP_CHECKS is set to true (or if --skip-checks is used with ghe-backup) then ghe-host-check # disk space validation and software version checks on the backup-host will be disabled. #GHE_SKIP_CHECKS=false From f3426658e9ceab3f741025ea7f0a0dcd2d353619 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 20:18:25 -0400 Subject: [PATCH 2024/2421] Create incremental-mysql-backups-and-restores.md Creating markdown version of @gamefiend 's documentation --- .../incremental-mysql-backups-and-restores.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 docs/incremental-mysql-backups-and-restores.md diff --git a/docs/incremental-mysql-backups-and-restores.md b/docs/incremental-mysql-backups-and-restores.md new file mode 100644 index 000000000..ab10e7880 --- /dev/null +++ b/docs/incremental-mysql-backups-and-restores.md @@ -0,0 +1,34 @@ +# Incremental MySQL Backups and Restores + +Customers who have large MySQL databases who wish to save storage space can use the `--incremental` flag with `ghe-backup` and `ghe-restore`. +Using this flag performs backups for other parts of GHES as normal, but only performs a MySQL backup of the changes to the database from the previous snapshot. +For larger databases this can conserve a lot of storage space for backups. + +## Configuring number of backups + +In your backup.config file you will need to set the variable `GHE_INCREMENTAL_BACKUP_MAX`. +This variable determines how many cycles of full and incremental backups will be performed before the next full backup is performed with another cycle of incremental backups. +If `GHE_INCREMENTAL_BACKUP_MAX` is set to 14, backup-utils will run 1 full backup and then 13 incremental backups before performing another full backup on the next cycle. + +Incremental backups require the previous snapshot backups before them to work. +Because of this, they do not follow the pruning strategy based on `GHE_NUM_SNAPSHOTS`. + +## Performing incremental backups + +To perform incremental backups: + +`bin/ghe-backup --incremental` + +the program will detect whether it needs to performa full or incremental snapshot based on what is currently in `GHE_DATA_DIR`. + +To see what snapshots are part of your full and incremental backups, you can reference `GHE_DATA_DIR/inc_full_backup` and `GHE_DATA_DIR/inc_snapshot_data`, respectively. + +## Performing incremental restores +to perform incremental restores: +`bin/ghe-restore --incremental -s . +the program will use the mysql folders from each previous incremental backup and the full backup to restore the database. + +:warning: Incremental restores require the other snapshots in the cycle to complete a restore. Erasing snapshot directories that are part of a cycle corrupts the restore and makes it impossible to complete for the mySQL database. + +### Previous cycles +To ensure there is a rolling window of mySQL backups, incremental mySQL backups from the cycle before the current one are kept. Those snapshots are pre-pended with `inc_previous`. To perform a restore from there , just use the full directory name for the snapshot id. From b04aa6ea47c6ff3125c97f7895e6764edc99955c Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 20:22:37 -0400 Subject: [PATCH 2025/2421] Added a 'Incremental MySQL Backups and Restores' section --- docs/usage.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index c603c5e36..8f1a70131 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -111,5 +111,9 @@ GitHub Actions enabled, the following steps are required: Please refer to [GHES Documentation](https://docs.github.com/en/enterprise-server/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled) for more details. +## Incremental MySQL Backups and Restores + +If you are interested in performing incremental backups of the MySQL data in your GitHub Enterprise Server instance, see [Incremental MySQL Backups and Restores](incremental-mysql-backups-and-restores.md) for details. + [1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md [2]: requirements.md From 614d067b26afdfd7d081caa5aca33ab7f2370249 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 20:26:41 -0400 Subject: [PATCH 2026/2421] Cleaned up layout --- docs/scheduling-backups.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/scheduling-backups.md b/docs/scheduling-backups.md index 2b581f968..0e00a5d67 100644 --- a/docs/scheduling-backups.md +++ b/docs/scheduling-backups.md @@ -4,7 +4,8 @@ Regular backups should be scheduled using `cron(8)` or similar command scheduling service on the backup host. The backup frequency will dictate the worst case [recovery point objective (RPO)][1] in your backup plan. We recommend hourly backups at the least. -## Example scheduling usage + +## Example scheduling of backups The following examples assume the Backup Utilities are installed under `/opt/backup-utils`. The crontab entry should be made under the same user that @@ -32,13 +33,14 @@ MAILTO=admin@example.com 0 0 * * * /opt/backup-utils/bin/ghe-backup -v 1>>/opt/backup-utils/backup.log 2>&1 ``` -### Example snapshot pruning +## Example snapshot pruning By default all expired and incomplete snapshots are deleted at the end of the main backup process `ghe-backup`. If pruning these snapshots takes a long time you can choose to disable the pruning process from the backup run and schedule it separately. This can be achieved by enabling the `GHE_PRUNING_SCHEDULED` option in `backup.config`. -Please note that this option is only avilable for `backup-utils` >= v3.10.0, if this option is enabled you will need to schedule the pruning script `ghe-prune-snapshots` using `cron` or a similar command scheduling service on the backup host. +Please note that this option is only avilable for `backup-utils` >= `v3.10.0`. +If this option is enabled you will need to schedule the pruning script `ghe-prune-snapshots` using `cron` or a similar command scheduling service on the backup host. To schedule daily snapshot pruning, use: From 0c8236d991740ca7d1684e81e1532b0506efad52 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 20:28:27 -0400 Subject: [PATCH 2027/2421] Cleaned up comments around GHE_PRUNING_SCHEDULED --- backup.config-example | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backup.config-example b/backup.config-example index e679d74eb..927ba559f 100644 --- a/backup.config-example +++ b/backup.config-example @@ -16,8 +16,9 @@ GHE_DATA_DIR="data" # be available for the past N days ... GHE_NUM_SNAPSHOTS=10 -# Pruning snapshots can be scheduled outside of the backup process. If set to 'yes' -# ghe-pruning-snapshots will need to be invoked separately via cron +# Pruning snapshots can be scheduled outside of the backup process. +# If set to 'yes', snapshots will not be pruned by ghe-backup. +# Instead, ghe-pruning-snapshots will need to be invoked separately via cron #GHE_PRUNING_SCHEDULED=yes # If GHE_SKIP_CHECKS is set to true (or if --skip-checks is used with ghe-backup) then ghe-host-check From 746bd1316b784c0ad099f86758d427324e0c68fa Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 20:33:15 -0400 Subject: [PATCH 2028/2421] Added GHE_INCREMENTAL_BACKUP_MAX to sample config file. --- backup.config-example | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backup.config-example b/backup.config-example index 927ba559f..688cc374b 100644 --- a/backup.config-example +++ b/backup.config-example @@ -21,6 +21,13 @@ GHE_NUM_SNAPSHOTS=10 # Instead, ghe-pruning-snapshots will need to be invoked separately via cron #GHE_PRUNING_SCHEDULED=yes +# If --incremental is used to generate incremental MySQL backups with ghe-backup, +# then you need to specify how many cycles of full and incremental backups will be +# performed before the next full backup is created. +# For example, if `GHE_INCREMENTAL_BACKUP_MAX` is set to 14, backup-utils will +# run 1 full backup and then 13 incremental backups before performing another full backup on the next cycle. +#GHE_INCREMENTAL_BACKUP_MAX=14 + # If GHE_SKIP_CHECKS is set to true (or if --skip-checks is used with ghe-backup) then ghe-host-check # disk space validation and software version checks on the backup-host will be disabled. #GHE_SKIP_CHECKS=false From f6cd16de506a2675c76663453fccae0662b2859c Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Mon, 7 Aug 2023 20:33:39 -0400 Subject: [PATCH 2029/2421] Revised copy about GHE_INCREMENTAL_BACKUP_MAX --- .../incremental-mysql-backups-and-restores.md | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/incremental-mysql-backups-and-restores.md b/docs/incremental-mysql-backups-and-restores.md index ab10e7880..0bc5f8ef8 100644 --- a/docs/incremental-mysql-backups-and-restores.md +++ b/docs/incremental-mysql-backups-and-restores.md @@ -7,11 +7,11 @@ For larger databases this can conserve a lot of storage space for backups. ## Configuring number of backups In your backup.config file you will need to set the variable `GHE_INCREMENTAL_BACKUP_MAX`. -This variable determines how many cycles of full and incremental backups will be performed before the next full backup is performed with another cycle of incremental backups. -If `GHE_INCREMENTAL_BACKUP_MAX` is set to 14, backup-utils will run 1 full backup and then 13 incremental backups before performing another full backup on the next cycle. +This variable determines how many cycles of full and incremental backups will be performed before the next full backup is created. +For example, if `GHE_INCREMENTAL_BACKUP_MAX` is set to 14, backup-utils will run 1 full backup and then 13 incremental backups before performing another full backup on the next cycle. Incremental backups require the previous snapshot backups before them to work. -Because of this, they do not follow the pruning strategy based on `GHE_NUM_SNAPSHOTS`. +This means they do not follow the pruning strategy based on `GHE_NUM_SNAPSHOTS`. ## Performing incremental backups @@ -24,11 +24,15 @@ the program will detect whether it needs to performa full or incremental snapsho To see what snapshots are part of your full and incremental backups, you can reference `GHE_DATA_DIR/inc_full_backup` and `GHE_DATA_DIR/inc_snapshot_data`, respectively. ## Performing incremental restores -to perform incremental restores: -`bin/ghe-restore --incremental -s . -the program will use the mysql folders from each previous incremental backup and the full backup to restore the database. -:warning: Incremental restores require the other snapshots in the cycle to complete a restore. Erasing snapshot directories that are part of a cycle corrupts the restore and makes it impossible to complete for the mySQL database. +To perform incremental restores: + +`bin/ghe-restore --incremental -s ` + +The program will use the MySQL folders from each previous incremental backup and the full backup to restore the database. + +:warning: Incremental restores require the other snapshots in the cycle to complete a restore. Erasing snapshot directories that are part of a cycle corrupts the restore and makes it impossible to restore for the MySQL database. ### Previous cycles -To ensure there is a rolling window of mySQL backups, incremental mySQL backups from the cycle before the current one are kept. Those snapshots are pre-pended with `inc_previous`. To perform a restore from there , just use the full directory name for the snapshot id. + +To ensure there is a rolling window of mySQL backups, incremental MySQL backups from the cycle before the current one are kept. Those snapshots are pre-pended with `inc_previous`. To perform a restore from there, just use the full directory name for the snapshot id. From 35b90467a25b01ff6da7847689c401f22ec22c76 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Tue, 8 Aug 2023 22:19:14 +0000 Subject: [PATCH 2030/2421] Updated the version to rc1 --- share/github-backup-utils/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 30291cba2..dc9c1d868 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.10.0 +3.10.0.rc1 From 41e6014c2d340be123da189e3d66eb733e4c8c00 Mon Sep 17 00:00:00 2001 From: bonsohi Date: Wed, 9 Aug 2023 19:37:10 +0000 Subject: [PATCH 2031/2421] Bump version: 3.10.0 [ci skip] --- bin/ghe-host-check | 2 +- debian/changelog | 11 +++++++++++ share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 9f6ca2603..7dafe1c7f 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -131,7 +131,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.7.0" +supported_minimum_version="3.8.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/debian/changelog b/debian/changelog index ee3c73176..f5caddb85 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +github-backup-utils (3.10.0) UNRELEASED; urgency=medium + + * Remove -o option from ps use #341 + * Switch to TMPDIR before initiating SSH multiplexing workaround to prevent locking the destination filesystem #348 + * Move check for git for ssh muxing into ghe-ssh #378 + * Check filesystem supports hardlinks #388 + * Remove check for git from ghe-ssh #393 + * Clean up stale HA nodes on restore #396 + + -- Balwinder Sohi Wed, 09 Aug 2023 19:37:10 +0000 + github-backup-utils (3.9.0) UNRELEASED; urgency=medium * Set restore status on all cluster nodes #274 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index dc9c1d868..30291cba2 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.10.0.rc1 +3.10.0 diff --git a/test/testlib.sh b/test/testlib.sh index adfbc39d7..53b41dfe9 100644 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -43,7 +43,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.9.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.10.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From 21ee95210333d6c3150af36b0aeddc7e50a4d91c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Thu, 10 Aug 2023 17:15:32 +0200 Subject: [PATCH 2032/2421] Remove duplicate definitions in ghe-backup-config (#480) While investigating an unrelated issue, I noticed that some definitions in ghe-backup-config are present twice. The reason for this appears to be a faulty merge conflict resolution [1], as both parent commits [2, 3] only have a single copy of these definitions but the merge commit has duplicates. It seems that an unwieldy conflict came up while merging the progress-indicator with the master branch, as a result of which both the old and new locations of these definitions were accidentally kept, causing the duplication. This removes one copy of each definition to avoid confusion and potential future bugs. [1] 1eaf80941c84c21f148ea68783415a920d32ce15 [2] a8e7eca745a738c4c02cba4ce85f51bfb97bfe6b [3] 8aaccc3c8b6599d591239d22cb789572df05465a --- share/github-backup-utils/ghe-backup-config | 38 +-------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index b61f5a8c0..2e176b510 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -35,7 +35,7 @@ if [ -n "$GHE_SHOW_VERSION" ]; then fi # Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage -# shellcheck disable=SC2120 # the script name is always referenced +# shellcheck disable=SC2120 # Our arguments are optional and not meant to be the owning script's print_usage() { grep '^#/' <"$0" | cut -c 4- exit "${1:-1}" @@ -51,10 +51,6 @@ else done fi -# Add the bin and share/github-backup-utils dirs to PATH -PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" -# shellcheck source=share/github-backup-utils/bm.sh -. "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" # Save off GHE_HOSTNAME from the environment since we want it to override the # backup.config value when set. GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" @@ -150,35 +146,6 @@ log_ssh(){ log_level "ssh" "$1" } -# Assume this script lives in share/github-backup-utils/ when setting the root -GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" - -# Get the version from the version file. -BACKUP_UTILS_VERSION="$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/version")" - -# If a version check was requested, show the current version and exit -if [ -n "$GHE_SHOW_VERSION" ]; then - echo "GitHub backup-utils v$BACKUP_UTILS_VERSION" - exit 0 -fi - -# Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage -# shellcheck disable=SC2120 # Our arguments are optional and not meant to be the owning script's -print_usage() { - grep '^#/' <"$0" | cut -c 4- - exit "${1:-1}" -} - -if [ -n "$GHE_SHOW_HELP" ]; then - print_usage -else - for a in "$@"; do - if [ "$a" = "--help" ] || [ "$a" = "-h" ]; then - print_usage - fi - done -fi - # Add the bin and share/github-backup-utils dirs to PATH PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" # shellcheck source=share/github-backup-utils/bm.sh @@ -187,9 +154,6 @@ PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" . "$GHE_BACKUP_ROOT/share/github-backup-utils/ghe-incremental-backup-restore" # shellcheck source=share/github-backup-utils/track-progress . "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" -# Save off GHE_HOSTNAME from the environment since we want it to override the -# backup.config value when set. -GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" ghe_restore_check() { From 4df4edf4b9894145f6d1ae8bea485c12105e6819 Mon Sep 17 00:00:00 2001 From: ddivad195 Date: Thu, 10 Aug 2023 19:09:50 +0000 Subject: [PATCH 2033/2421] update restore to check data exists vs check version --- share/github-backup-utils/ghe-restore-actions | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index d30d54488..14cfd1007 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -85,13 +85,13 @@ restore-secret "Actions Launch service private key" "actions-launch-app-app-priv restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" "secrets.launch.token-oauth-key" restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert" -# Restore storage container prefix, but only if the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings -# This value will only be present in backups from versions >= 3.10 so needs to be wrapped in version checks. -snapshot_version=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/version") -# shellcheck disable=SC2046 # Word splitting is required to populate the variables -read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version "$snapshot_version") -if [[ $RESTORE_SETTINGS == "true" && "$snapshot_version_major" -eq "3" && "$snapshot_version_minor" -ge "10" ]]; then - restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" +# Restore storage container prefix, but only if it exists, and the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings +if [[ -e "$GHE_RESTORE_SNAPSHOT_PATH/actions-storage-container-prefix" ]]; then + if [[ $RESTORE_SETTINGS == "true" ]]; then + restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" + fi +else + log_warn "Actions storage container prefix not present in backup. Skipping ..." fi # Setup the database logins. From ad23aec7627e24b137763a52251c3a3d3d7a6744 Mon Sep 17 00:00:00 2001 From: David Daly Date: Thu, 10 Aug 2023 20:56:41 +0100 Subject: [PATCH 2034/2421] update logic to check if '-c' is set first Co-authored-by: boxofyellow <54955040+boxofyellow@users.noreply.github.com> --- share/github-backup-utils/ghe-restore-actions | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 14cfd1007..303a2abd2 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -86,12 +86,12 @@ restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert" # Restore storage container prefix, but only if it exists, and the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings -if [[ -e "$GHE_RESTORE_SNAPSHOT_PATH/actions-storage-container-prefix" ]]; then - if [[ $RESTORE_SETTINGS == "true" ]]; then +if [[ $RESTORE_SETTINGS == "true" ]]; then + if [[ -e "$GHE_RESTORE_SNAPSHOT_PATH/actions-storage-container-prefix" ]]; then restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" + else + log_warn "Actions storage container prefix not present in backup. Skipping ..." fi -else - log_warn "Actions storage container prefix not present in backup. Skipping ..." fi # Setup the database logins. From f4fa25f3f8e0c66ee87dfeecee973c1b9761f7d9 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 10 Aug 2023 22:15:48 +0000 Subject: [PATCH 2035/2421] remove on-exit mode --- share/github-backup-utils/track-progress | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index bf50c42aa..d88b3704f 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -1,6 +1,5 @@ #!/usr/bin/env bash #/ track-progress: track progress of backup or restore tasks -set -e # Current version is working solely with backups progress(){ From 6b6e1bfea8ca0b5494628190649fade68a70e34e Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 10 Aug 2023 23:04:46 +0000 Subject: [PATCH 2036/2421] add script to be excluded --- test/test-shellcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh index 92ac538cc..231d78edb 100755 --- a/test/test-shellcheck.sh +++ b/test/test-shellcheck.sh @@ -49,7 +49,7 @@ begin_test "shellopts: set -e set on all scripts" # Check all executable scripts checked into the repo, except bm.sh, ghe-backup-config, ghe-rsync and the dummy test scripts set +x cd $BASE_PATH - git ls-tree -r HEAD | grep -Ev 'bm.sh|ghe-backup-config|ghe-rsync|test/bin' | grep -E '^1007|.*\..*sh$' | awk '{print $4}' | while read -r script; do + git ls-tree -r HEAD | grep -Ev 'bm.sh|ghe-backup-config|ghe-rsync|track-progress|test/bin' | grep -E '^1007|.*\..*sh$' | awk '{print $4}' | while read -r script; do if head -n1 "$script" | grep -E -w "sh|bash" >/dev/null 2>&1; then grep -q "set -e" $script || echo $script >> $results || true fi From a44aa3d24cd15810021fc140fbf5a8d64289c614 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Sat, 12 Aug 2023 07:58:10 -0400 Subject: [PATCH 2037/2421] Bringing in a fix from the public repo Bringing in a fix from https://github.com/github/backup-utils/pull/1094 --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index f3f7d67f6..1320eb583 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,7 +5,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), [jq][11] v1.5 or newer, and [bc][12] v1.07 or newer. +Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2], [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](#april-2023-update-of-rsync-requirements) for exceptions), [jq][11] v1.5 or newer, and [bc][12] v1.07 or newer. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From 5ace2f2b931ac26e8daf5e11be3338ac2c4e5659 Mon Sep 17 00:00:00 2001 From: boxofyellow <54955040+boxofyellow@users.noreply.github.com> Date: Mon, 14 Aug 2023 10:11:43 -0400 Subject: [PATCH 2038/2421] Get any backups that were created off the box even if we have a failure (#442) --- share/github-backup-utils/ghe-backup-mssql | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql index 37b09ca9d..f168b2cfe 100755 --- a/share/github-backup-utils/ghe-backup-mssql +++ b/share/github-backup-utils/ghe-backup-mssql @@ -335,9 +335,12 @@ if [ -n "$backup_type" ]; then elif [ "$backup_type" = "transaction" ]; then backup_command='ghe-export-mssql -t' fi - + + backup_failed= + bm_start "$(basename "$0")" - ghe_ssh_mssql -- "$backup_command" + # record if generating the backup failed, this will allow us to collect any backups that may have been produced, even if they are not complete they are better than nothing + ghe_ssh_mssql -- "$backup_command" || backup_failed='true' bm_end "$(basename "$0")" # Configure the backup cadence on the appliance, which is used for diagnostics @@ -352,4 +355,9 @@ if [ -n "$backup_type" ]; then ghe_verbose "Transferring to backup host $b" ghe_ssh_mssql "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" done + + if [ -n "$backup_failed" ]; then + log_error 'ghe-export-mssql failed to backup at least one mssql database' 1>&2 + exit 1 + fi fi From dff57d9267d48b4116c6cdaa0c04dbeb8fc5db3f Mon Sep 17 00:00:00 2001 From: Devin Dooley Date: Mon, 14 Aug 2023 16:27:46 -0700 Subject: [PATCH 2039/2421] Leave release in draft state by default --- script/release | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/script/release b/script/release index b7b61615e..42f2d0f46 100755 --- a/script/release +++ b/script/release @@ -34,6 +34,9 @@ DEB_PKG_NAME = 'github-backup-utils' GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master' # TODO: should we even allow a default or require all params get set explicitly? GH_STABLE_BRANCH = "" +# If PUBLISH is false, we leave the release in a draft state to be manually published later through the UI ++PUBLISH = ENV['PUBLISH'] == 'true' || false + CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium <%- changes.each do |ch| -%> @@ -480,8 +483,10 @@ if $PROGRAM_NAME == __FILE__ attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_all.deb"] - puts 'Publishing release...' - publish_release res['id'] + if PUBLISH do + puts 'Publishing release...' + publish_release res['id'] + end puts 'Cleaning up...' clean_up version @@ -489,6 +494,10 @@ if $PROGRAM_NAME == __FILE__ puts "Updating #{GH_STABLE_BRANCH} branch..." update_stable_branch + if !PUBLISH do + puts 'Release left in a "Draft" state. Go to the https://github.com/github/backup-utils/releases and publish when ready.' + end + puts 'Released!' rescue RuntimeError => e $stderr.puts "Error: #{e}" From 105ebb6b5a15c882fa28f79b1d291ebd5cdc6ef5 Mon Sep 17 00:00:00 2001 From: Devin Dooley Date: Mon, 14 Aug 2023 16:42:19 -0700 Subject: [PATCH 2040/2421] Fix conditional statement --- script/release | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/release b/script/release index 42f2d0f46..d8b1ee9b2 100755 --- a/script/release +++ b/script/release @@ -483,7 +483,7 @@ if $PROGRAM_NAME == __FILE__ attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_all.deb"] - if PUBLISH do + if PUBLISH puts 'Publishing release...' publish_release res['id'] end @@ -494,7 +494,7 @@ if $PROGRAM_NAME == __FILE__ puts "Updating #{GH_STABLE_BRANCH} branch..." update_stable_branch - if !PUBLISH do + if !PUBLISH puts 'Release left in a "Draft" state. Go to the https://github.com/github/backup-utils/releases and publish when ready.' end From 4b434c20a0d6d7de6870ba73b8675a585e549c95 Mon Sep 17 00:00:00 2001 From: Devin Dooley Date: Mon, 14 Aug 2023 16:46:59 -0700 Subject: [PATCH 2041/2421] Remove accidental + sign --- script/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/release b/script/release index d8b1ee9b2..891cd9f60 100755 --- a/script/release +++ b/script/release @@ -35,7 +35,7 @@ GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master' # TODO: should we even allow GH_STABLE_BRANCH = "" # If PUBLISH is false, we leave the release in a draft state to be manually published later through the UI -+PUBLISH = ENV['PUBLISH'] == 'true' || false +PUBLISH = ENV['PUBLISH'] == 'true' || false CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium From 550f3032f88cf16d31ddd421ebc79ba08917285f Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Tue, 15 Aug 2023 21:16:18 +0200 Subject: [PATCH 2042/2421] transfer_size are estimated data transfer sizes (#488) * Update bin/ghe-host-check --- bin/ghe-host-check | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 9f6ca2603..1c3252645 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -184,7 +184,8 @@ SKIP_MSG echo " - Recommended Disk requirement is $recommended_disk_req MB" 1>&2 echo "" 1>&2 - printf '### Data Transfer Sizes + printf '### Estimated Data Transfer Sizes + - repositories: %d MB - pages: %d MB - elasticsearch: %d MB @@ -192,7 +193,8 @@ SKIP_MSG - minio: %d MB - mysql: %d MB - actions: %d MB - - mssql: %d MB\n' \ + - mssql: %d MB +\n' \ "$repos_disk_size" "$pages_disk_size" "$es_disk_size" "$stor_disk_size" "$minio_disk_size" "$mysql_disk_size" "$actions_disk_size" "$mssql_disk_size" 1>&2 if [[ $((available_space / (1024 * 1024))) -lt $min_disk_req ]]; then From 826215c15fa25ef5af9d1432f5173241d3e2b69d Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 16 Aug 2023 12:31:06 -0400 Subject: [PATCH 2043/2421] Change shellcheck to use stable, not latest Shelcheck is using latest and a recent change broke all of our tests. Changing this so we use the stable version as we don't need the newest version of shellcheck for tests. --- .github/workflows/main.yml | 6 +++--- test/test-shellcheck.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 809e9df50..da7695ad1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,9 +17,9 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y devscripts debhelper moreutils fakeroot jq pigz help2man - wget "https://github.com/koalaman/shellcheck/releases/download/latest/shellcheck-latest.linux.x86_64.tar.xz" - tar --xz -xvf "shellcheck-latest.linux.x86_64.tar.xz" - sudo cp shellcheck-latest/shellcheck /usr/bin/shellcheck + wget "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" + tar --xz -xvf "shellcheck-stable.linux.x86_64.tar.xz" + sudo cp shellcheck-stable/shellcheck /usr/bin/shellcheck if: matrix.os != 'macos-latest' - name: Install Dependencies (macOS) run: | diff --git a/test/test-shellcheck.sh b/test/test-shellcheck.sh index 231d78edb..82c0fbb4f 100755 --- a/test/test-shellcheck.sh +++ b/test/test-shellcheck.sh @@ -11,8 +11,8 @@ begin_test "shellcheck: reports no errors or warnings" set -e # We manually install the latest Shellcheck on Linux builds as other options # are too old. - if [ -x "$BASE_PATH/shellcheck-latest/shellcheck" ]; then - shellcheck() { "$BASE_PATH/shellcheck-latest/shellcheck" "$@"; } + if [ -x "$BASE_PATH/shellcheck-stable/shellcheck" ]; then + shellcheck() { "$BASE_PATH/shellcheck-stable/shellcheck" "$@"; } fi if ! type shellcheck 1>/dev/null 2>&1; then From 3825fcbc25dadc67b37834f629320b5c49a38fd3 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Thu, 17 Aug 2023 11:19:09 +0200 Subject: [PATCH 2044/2421] Adding host online check (#492) * adding host online check * fix test --------- Co-authored-by: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> --- bin/ghe-host-check | 12 +++++++++--- test/bin/ghe-cluster-host-check | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100755 test/bin/ghe-cluster-host-check diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 1c3252645..104885114 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -91,13 +91,19 @@ if ghe-ssh "$host" -- \ CLUSTER=true fi -# ensure all nodes in the cluster are running the same version +# ensure all nodes in the cluster are online/reachable and running the same version if "$CLUSTER"; then + online_status=$(ghe-ssh "$host" ghe-cluster-host-check) + if [ "$online_status" != "Cluster is ready to configure." ]; then + echo "Error: Not all nodes are online! Please ensure cluster is in a healthy state before using backup-utils." 1>&2 + exit 1 + fi + node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l) if [ "$distinct_versions" -ne 1 ]; then - echo "$node_version_list" 1>&2 - echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&3 + echo "Version mismatch: $node_version_list" 1>&2 + echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 exit 1 fi fi diff --git a/test/bin/ghe-cluster-host-check b/test/bin/ghe-cluster-host-check new file mode 100755 index 000000000..3120d85de --- /dev/null +++ b/test/bin/ghe-cluster-host-check @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Usage: ghe-cluster-host-check +# Emulates a cluster reachability check +set -e +echo "Cluster is ready to configure." From 6c8648da655d472e99390d786d99d79e17a6cd63 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Thu, 17 Aug 2023 15:03:00 +0200 Subject: [PATCH 2045/2421] fix typo (#508) --- bin/ghe-restore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 92ae72443..19603ae47 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -469,13 +469,13 @@ fi # Always restore column encryption keys if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then - log_info "Always restore encrypted column encryption keys on GHES verions 3.7.0+" + log_info "Always restore encrypted column encryption keys on GHES versions 3.7.0+" fi ghe-restore-column-encryption-keys "$GHE_HOSTNAME" # Always restore secret scanning encryption keys if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then - log_info "Always restore secret scanning encryption keys on GHES verions 3.8.0+" + log_info "Always restore secret scanning encryption keys on GHES versions 3.8.0+" increment-progress-total-count 1 ghe-restore-secret-scanning-encryption-keys "$GHE_HOSTNAME" fi From 07162bd5882220d03d5d4edc73e4a2c97ab760cc Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 17 Aug 2023 17:40:09 -0400 Subject: [PATCH 2046/2421] Host key fix (#513) --- bin/ghe-backup | 66 ++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 2043e2fad..86ee33dd7 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -54,38 +54,7 @@ export CALLING_SCRIPT="ghe-backup" # shellcheck source=share/github-backup-utils/ghe-backup-config . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" -# Setup progress tracking -init-progress -export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14 -echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total -export PROGRESS_TYPE="Backup" -echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type -export PROGRESS=0 # Used to track progress of backup -echo "$PROGRESS" > /tmp/backup-utils-progress - -OPTIONAL_STEPS=0 -# Backup actions+mssql -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2)) -fi - -# Backup fsck -if [ "$GHE_BACKUP_FSCK" = "yes" ]; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi - -# Backup minio -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi -# Backup pages -if [ "$GHE_BACKUP_PAGES" != "no" ]; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi - -PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14 -echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total # Check to make sure moreutils parallel is installed and working properly ghe_parallel_check @@ -186,9 +155,44 @@ fi # Perform a host connection check and establish the remote appliance version. # The version is available in the GHE_REMOTE_VERSION variable and also written # to a version file in the snapshot directory itself. +# ghe_remote_version_required should be run before any other instances of ghe-ssh +# to ensure that there are no problems with host key verification. ghe_remote_version_required echo "$GHE_REMOTE_VERSION" > version +# Setup progress tracking +init-progress +export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14 +echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total +export PROGRESS_TYPE="Backup" +echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type +export PROGRESS=0 # Used to track progress of backup +echo "$PROGRESS" > /tmp/backup-utils-progress + +OPTIONAL_STEPS=0 +# Backup actions+mssql +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2)) +fi + +# Backup fsck +if [ "$GHE_BACKUP_FSCK" = "yes" ]; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi + +# Backup minio +if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi + +# Backup pages +if [ "$GHE_BACKUP_PAGES" != "no" ]; then + OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) +fi + +PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14 +echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total + # check that incremental settings are valid if set is_inc=$(is_incremental_backup_feature_on) From 82b2e2a0a7149b8652ffa93b98e594714cccb1d4 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 18 Aug 2023 18:33:15 +0000 Subject: [PATCH 2047/2421] fix for cluster transfer sizes --- share/github-backup-utils/ghe-rsync-size | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) mode change 100755 => 100644 share/github-backup-utils/ghe-rsync-size diff --git a/share/github-backup-utils/ghe-rsync-size b/share/github-backup-utils/ghe-rsync-size old mode 100755 new mode 100644 index c61a80b3b..317c2f6cc --- a/share/github-backup-utils/ghe-rsync-size +++ b/share/github-backup-utils/ghe-rsync-size @@ -21,6 +21,7 @@ fi transfer_size() { + local host=$GHE_HOSTNAME local backup_data=$1 if [[ "$1" == "mssql" ]]; then data_user_dir="/data/user/$1/backups" @@ -58,20 +59,36 @@ transfer_size() ;; esac + ghe-ssh "$host" "[ -f /etc/github/cluster ]" + cluster_status=$? + + if [[ $cluster_status -eq 0 ]]; then + cluster_conf_out=$(ghe-ssh "$host" "cat /data/user/common/cluster.conf") + cluster_nodes_output=$(ghe-ssh "$host" "ghe-cluster-nodes -i") + if [[ ( "$1" == "elasticsearch" || "$1" == "storage" || "$1" == "pages" ) ]]; then + host_server=$(echo "$cluster_conf_out" | awk -v srv="$backup_data-server = true" '/cluster/ { prevA = $0 } $0 ~ srv { print prevA }' | head -1 | awk -F '"' '{print $2}') + elif [[ "$1" == "mysql" ]]; then + host_server=$(ghe-ssh "$host" "ghe-config cluster.mysql-master") + elif [[ "$1" == "repositories" ]]; then + host_server=$(echo "$cluster_conf_out" | awk '/git-server = true/ { print prevA } /cluster/ { prevA = $0 }' | head -1 | awk -F '"' '{print $2}') + fi + host=$(echo "$cluster_nodes_output" | grep "$host_server" | awk '{print $2}' | head -1) + fi + if [ -d "${GHE_DATA_DIR}/current/$1" ]; then total_file_size=$(ghe-rsync -arn --stats \ -e "ssh -q $GHE_EXTRA_SSH_OPTS -p 122 -l admin" \ --rsync-path="sudo -u $user rsync" \ "$link_dest"/"$1" \ --ignore-missing-args \ - "$GHE_HOSTNAME:$data_user_dir/" \ + "$host:$data_user_dir/" \ "$dest_dir/" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') else total_file_size=$(ghe-rsync -arn --stats \ -e "ssh -q $GHE_EXTRA_SSH_OPTS -p 122 -l admin" \ --rsync-path="sudo -u $user rsync" \ --ignore-missing-args \ - "$GHE_HOSTNAME:$data_user_dir/" \ + "$host:$data_user_dir/" \ "$dest_dir/" | grep "Total transferred file size" | sed 's/.*size: //; s/,//g') fi From fb5aa593c1282939c0fdc22b9a1efedca79b3a1c Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Mon, 21 Aug 2023 13:49:08 -0500 Subject: [PATCH 2048/2421] Restore content scanning keys --- .../ghe-restore-secret-scanning-encryption-keys | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys b/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys index aa225bc07..4785a6d77 100755 --- a/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys +++ b/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys @@ -36,4 +36,8 @@ log_info "Restoring secret scanning encrypted secrets transit keys" restore-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" restore-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" +# Restore secret scanning content scanning keys if present +log_info "Restoring secret scanning content scanning keys" +restore-secret "secret scanning user content delimited encryption root keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" + bm_end "$(basename $0)" From 5a64931986a310c3634b0e461d5966e3fd2b4e7f Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Mon, 21 Aug 2023 15:11:18 -0700 Subject: [PATCH 2049/2421] Added test of backup --- test/test-ghe-backup.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 745538264..9184746e3 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -802,6 +802,30 @@ begin_test "ghe-backup takes backup of secret scanning encrypted secrets encrypt ) end_test +begin_test "ghe-backup takes backup of secret scanning encrypted content encryption keys" +( + set -e + + required_secrets=( + "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + ghe-backup + + required_files=( + "secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "foo" ] + done +) +end_test + begin_test "ghe-backup takes backup of Actions settings" ( set -e From 8dad53ef128fa622c8f4216a3f12bc275b64a1bd Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Mon, 21 Aug 2023 15:26:36 -0700 Subject: [PATCH 2050/2421] Added test for restoring encrypted content keys --- test/test-ghe-restore.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index ef13b7697..39d2bced6 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -454,6 +454,32 @@ begin_test "ghe-restore with secret scanning encrypted secrets encryption keys f ) end_test +begin_test "ghe-restore with secret scanning encrypted content encryption keys" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + required_files=( + "secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for file in "${required_files[@]}"; do + echo "foo" >"$GHE_DATA_DIR/current/$file" + done + + GHE_REMOTE_VERSION=3.11.0 ghe-restore -v -f localhost + + required_secrets=( + "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting these to not be set for versions below 3.8.0 + done +) +end_test + # Setup Actions data for the subsequent tests setup_actions_test_data "$GHE_DATA_DIR/1" From 5596eb8280263b9acc5b1a7420c54119d034b31e Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Mon, 21 Aug 2023 15:27:44 -0700 Subject: [PATCH 2051/2421] Added encrypted content key to backup-settings --- share/github-backup-utils/ghe-backup-settings | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 3a05feba7..362e230cf 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -90,6 +90,7 @@ backup-secret "secret scanning encrypted secrets current storage key" "secret-sc backup-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" backup-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" backup-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" +backup-secret "secret scanning encrypted content keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" # Backup argon secrets for multiuser from ghes version 3.8 onwards if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then From dd8e655bd24b5a510598073e2f522f545e327204 Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Mon, 21 Aug 2023 15:54:15 -0700 Subject: [PATCH 2052/2421] Fixed restore tests --- test/test-ghe-restore.sh | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 39d2bced6..cf93baa96 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -454,7 +454,33 @@ begin_test "ghe-restore with secret scanning encrypted secrets encryption keys f ) end_test -begin_test "ghe-restore with secret scanning encrypted content encryption keys" +begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions below 3.11.0+" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + required_files=( + "secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for file in "${required_files[@]}"; do + echo "foo" >"$GHE_DATA_DIR/current/$file" + done + + GHE_REMOTE_VERSION=3.10.0 ghe-restore -v -f localhost + + required_secrets=( + "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting these to not be set for versions below 3.11.0 + done +) +end_test + +begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions 3.11.0+" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -475,7 +501,7 @@ begin_test "ghe-restore with secret scanning encrypted content encryption keys" ) for secret in "${required_secrets[@]}"; do - [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting these to not be set for versions below 3.8.0 + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] # expecting this to have been restored successfully for versions 3.11.0+ done ) end_test From 8bd786e011d6df7caea55ee652e8a072099b5b6a Mon Sep 17 00:00:00 2001 From: Robert Bolender Date: Mon, 21 Aug 2023 22:22:18 -0700 Subject: [PATCH 2053/2421] Only backup secret scanning secrets on GHES versions 3.8.0+ --- share/github-backup-utils/ghe-backup-settings | 11 +++--- test/test-ghe-backup.sh | 34 +++++++++++++++++-- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 3a05feba7..aac02dde7 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -86,10 +86,13 @@ if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then cat "$GHE_SNAPSHOT_DIR/encrypted-column-encryption-keying-material" | sed 's:.*;::' > "$GHE_SNAPSHOT_DIR/encrypted-column-current-encryption-key" fi -backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" -backup-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" -backup-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" -backup-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" +# secret scanning encrypted secrets keys were added in GHES 3.8.0 +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then + backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" + backup-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" + backup-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" + backup-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" +fi # Backup argon secrets for multiuser from ghes version 3.8 onwards if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 745538264..fb3f9db6a 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -772,7 +772,7 @@ begin_test "ghe-backup takes backup of encrypted column encryption keying materi ) end_test -begin_test "ghe-backup takes backup of secret scanning encrypted secrets encryption keys" +begin_test "ghe-backup does not take backups of secret scanning encrypted secrets encryption keys on versions below 3.8.0" ( set -e @@ -787,7 +787,37 @@ begin_test "ghe-backup takes backup of secret scanning encrypted secrets encrypt ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" done - ghe-backup + GHE_REMOTE_VERSION=3.7.0 ghe-backup -v | grep -q "secret scanning encrypted secrets" && exit 1 + + required_files=( + "secret-scanning-encrypted-secrets-current-storage-key" + "secret-scanning-encrypted-secrets-delimited-storage-keys" + "secret-scanning-encrypted-secrets-current-shared-transit-key" + "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "" ] + done +) +end_test + +begin_test "ghe-backup takes backup of secret scanning encrypted secrets encryption keys on versions 3.8.0+" +( + set -e + + required_secrets=( + "secrets.secret-scanning.encrypted-secrets-current-storage-key" + "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" + "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" + "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + GHE_REMOTE_VERSION=3.8.0 ghe-backup required_files=( "secret-scanning-encrypted-secrets-current-storage-key" From a5e9b0e5c64c4baa38c7c226fb5a515907f64156 Mon Sep 17 00:00:00 2001 From: "github-service-catalog[bot]" <66641770+github-service-catalog[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:30:02 -0400 Subject: [PATCH 2054/2421] Update service ownership data (#519) * Update service ownership data Co-authored-by: gamefiend <410344+gamefiend@users.noreply.github.com> --------- Co-authored-by: github-service-catalog[bot] <66641770+github-service-catalog[bot]@users.noreply.github.com> Co-authored-by: gamefiend <410344+gamefiend@users.noreply.github.com> Co-authored-by: Quinn Murphy --- ownership.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ownership.yaml diff --git a/ownership.yaml b/ownership.yaml new file mode 100644 index 000000000..bde619edc --- /dev/null +++ b/ownership.yaml @@ -0,0 +1,29 @@ +--- +version: 1 +ownership: +- name: ghes-backup-utilities + long_name: GHES Backup Utilities + description: GitHub Enterprise Disaster Recover Solution + kind: logical + repo: https://github.com/github/backup-utils-private + qos: best_effort + team_slack: ghes-lifecycle-aor + team: github/ghes-lifecycle + maintainer: whitneyimura + exec_sponsor: jakuboleksy + tier: 3 + product_manager: davidjarzebowski + sev1: + slack: ghes-on-call + alert_slack: ghes-backup-utils + pagerduty: https://github.pagerduty.com/escalation_policies#PBQWK20 + tta: 30 minutes + sev2: + issue: https://github.com/github/ghes/issues/new + tta: 1 business day + sev3: + issue: https://github.com/github/ghes/issues + tta: 1 week + support_squad: + slack: support-squad-infrastructure + issue: https://github.com/github/support-squad-infrastructure/issues From b66db2af6b90f800da9c176867395f32305499de Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Tue, 22 Aug 2023 08:30:55 -0700 Subject: [PATCH 2055/2421] Only backup 3.11 and up --- share/github-backup-utils/ghe-backup-settings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 362e230cf..28a251cec 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -90,7 +90,10 @@ backup-secret "secret scanning encrypted secrets current storage key" "secret-sc backup-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" backup-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" backup-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" -backup-secret "secret scanning encrypted content keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" + +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.11.0)" ]; then + backup-secret "secret scanning encrypted content keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" +fi # Backup argon secrets for multiuser from ghes version 3.8 onwards if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then From 6437469aca30ee4616e1f53bdf765871bae79ca7 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 22 Aug 2023 16:11:42 -0400 Subject: [PATCH 2056/2421] change super-linter repo and Bash linting level (#529) * change super-linter repo Changed super-linter link to conform with change: > NOTICE: If your use of the super-linter action failed around April 26th, 2023, we changed the organization name from github to super-linter so you will need to update your references to this action from github/super-linter to super-linter/super-linter. * Update .github/workflows/lint.yml add BASH_SEVERITY settings --- .github/workflows/lint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d15f123bb..0c6af658b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,7 +15,8 @@ jobs: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 - name: Lint Code Base - uses: github/super-linter@v5 + uses: super-linter/super-linter@v5 env: VALIDATE_ALL_CODEBASE: false + BASH_SEVERITY: error GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 534ff5e9d232303bcf833eb5f6881b476f6cb21c Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Wed, 23 Aug 2023 09:55:38 +0900 Subject: [PATCH 2057/2421] revert unccessary changes --- share/github-backup-utils/ghe-restore-mssql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-mssql b/share/github-backup-utils/ghe-restore-mssql index e6fbb58e8..e7d48c61f 100755 --- a/share/github-backup-utils/ghe-restore-mssql +++ b/share/github-backup-utils/ghe-restore-mssql @@ -22,11 +22,11 @@ import_tool_available() { } ghe_ssh_mssql() { - ghe-ssh "$opts" "$ssh_config_file_opt" "$GHE_MSSQL_PRIMARY_HOST" "$@" + ghe-ssh $opts $ssh_config_file_opt "$GHE_MSSQL_PRIMARY_HOST" "$@" } cleanup() { - rm -rf "$tempdir" + rm -rf $tempdir } trap 'cleanup' EXIT INT @@ -65,7 +65,7 @@ ghe_remote_version_required "$GHE_HOSTNAME" # The snapshot to restore should be set by the ghe-restore command but this lets # us run this script directly. -: "${GHE_RESTORE_SNAPSHOT:=current}" +: ${GHE_RESTORE_SNAPSHOT:=current} # The directory holding the snapshot to restore snapshot_dir_mssql="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql" @@ -79,13 +79,13 @@ do filename="${b##*/}" ghe_verbose "Transferring $filename to appliance host" - cat "$snapshot_dir_mssql/$filename" | ghe_ssh_mssql "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" + cat $snapshot_dir_mssql/$filename | ghe_ssh_mssql "sudo tee -a $appliance_dir/$filename >/dev/null 2>&1" done # Change owner to mssql:mssql to ready for restore ghe_ssh_mssql "sudo chown -R mssql:mssql $appliance_dir" # Invoke restore command -bm_start "$(basename "$0")" +bm_start "$(basename $0)" ghe_ssh_mssql -- "ghe-import-mssql" < "/dev/null" 1>&3 -bm_end "$(basename "$0")" +bm_end "$(basename $0)" From 4cc448a88c8030b9e48eb8b249be6ac92116ee6b Mon Sep 17 00:00:00 2001 From: Terrell Broomer Date: Wed, 23 Aug 2023 10:33:13 +0900 Subject: [PATCH 2058/2421] remove shellcheckrc --- .shellcheckrc | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .shellcheckrc diff --git a/.shellcheckrc b/.shellcheckrc deleted file mode 100644 index 1135b65a4..000000000 --- a/.shellcheckrc +++ /dev/null @@ -1 +0,0 @@ -disable=SC2002 #useless cat \ No newline at end of file From f14f8dd62116841dcf3c6129a571e05e3d19fe2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 23 Aug 2023 20:56:36 +0200 Subject: [PATCH 2059/2421] Clarify special handling for cluster environments --- share/github-backup-utils/ghe-restore-repositories | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index e8e1dcdbe..67bbf8e34 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -102,6 +102,11 @@ done > $tmp_list IFS=$OLDIFS bm_end "$(basename $0) - Building network list" +# In cluster environments, we need to ensure that all repository networks are replicated back to the +# same Spokes nodes that they were present on when the backup was taken. For this, the list of +# routes of each repository network is first obtained. Afterward, an rsync file list is created for +# each Spokes node including only those repository networks for which there was a route to the +# respective Spokes node. if $CLUSTER; then # The server returns a list of routes: # @@ -140,9 +145,11 @@ if $CLUSTER; then cat $routes_list | awk '{ n = split($1, p, "/"); printf p[n] " /data/repositories/" $1; $1=""; print $0}' > $to_restore ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" bm_end "$(basename $0) - Processing routes" +# There is no need to collect routes and split them by Spokes server in noncluster setups because +# we need to transfer all repository networks to the primary instance unconditionally, regardless of +# the Spokes route list captured during the backup. As we already have the list of all repository +# network paths, we can simply use that as the rsync file list in noncluster environments. else - # In noncluster setups, the primary instance owns all repository networks, so all network paths - # are to be synchronized to the primary instance. cp "$tmp_list" "$tempdir/git-server-primary.rsync" fi From 4a6e0aed7adf86f9a9415bf8eb6d686d161a4d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 23 Aug 2023 22:02:56 +0200 Subject: [PATCH 2060/2421] Allow manually triggering testing workflow This is to facilitate testing while developing new features, as the test suite is not trivial to run on a local machine or even a fork and as opening pull requests for all experimental features would create a lot of noise. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index da7695ad1..3e4445915 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,6 @@ name: Test and build -on: [pull_request] +on: [pull_request, workflow_dispatch] jobs: build: From 3bee49085de900d8f2f0920cb5c9263d72c784f6 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 24 Aug 2023 14:52:11 -0400 Subject: [PATCH 2061/2421] Placing initial CODEOWNERS file (#532) still need to discuss the best users to set as codeowners of certain sections, will uncomment after ascertaining best teams --- .github/CODEOWNERS | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 000000000..fecb57ee9 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,7 @@ +# Backup-Utils owned by lifecycle AOR +* @github/ghes-lifecycle +# Actions related backups and restores +# /share/github-backup-utils/*-actions @github/ghes-lifecycle @github/ +# Git related backups and restores +# /share/github-backup-utils/*-repositories @github/ghes-lifecycle @github/ +# /share/github-backup-utils/*-git-hooks @github/ghes-lifecycle @github/ \ No newline at end of file From 4abe738f06a649aef3d91575053593af6bd39c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 22 Aug 2023 02:19:25 +0200 Subject: [PATCH 2062/2421] Fix script permissions In order to satisfy the linter when making changes to this script, it should be executable. --- test/testlib.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 test/testlib.sh diff --git a/test/testlib.sh b/test/testlib.sh old mode 100644 new mode 100755 From fb9754530b6f9881e26cd4f12399930bab8c2c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sat, 19 Aug 2023 03:22:57 +0200 Subject: [PATCH 2063/2421] Find parallel in more locations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some distributions append or prepend “moreutils” to the parallel command with a hyphen to distinguish it from the GNU version of parallel, such as Arch Linux [1]. To facilitate testing on such platforms (for example to test backup-utils with upcoming versions of rsync and newer Linux kernel versions), this adds support for finding parallel in those locations. [1] https://archlinux.org/packages/extra/x86_64/moreutils/ --- share/github-backup-utils/ghe-backup-config | 2 ++ test/testlib.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 2e176b510..5b7f1c3d3 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -217,8 +217,10 @@ ghe_parallel_check() { GHE_PARALLEL_COMMAND="parallel" local x for x in \ + /usr/bin/parallel-moreutils \ /usr/bin/parallel.moreutils \ /usr/bin/parallel_moreutils \ + /usr/bin/moreutils-parallel \ /usr/bin/moreutils.parallel \ /usr/bin/moreutils_parallel \ ; do diff --git a/test/testlib.sh b/test/testlib.sh index 5dd5ac451..8e130eb75 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -600,8 +600,10 @@ setup_moreutils_parallel() { # We need moreutils parallel local x for x in \ + /usr/bin/parallel-moreutils \ /usr/bin/parallel.moreutils \ /usr/bin/parallel_moreutils \ + /usr/bin/moreutils-parallel \ /usr/bin/moreutils.parallel \ /usr/bin/moreutils_parallel \ ; do From 97102ce9e3d23725b8dfbec2a5125b5ba8e4b3d7 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Mon, 28 Aug 2023 19:50:27 +0000 Subject: [PATCH 2064/2421] switch to case --- share/github-backup-utils/ghe-rsync-size | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync-size b/share/github-backup-utils/ghe-rsync-size index 317c2f6cc..3e454f6bf 100644 --- a/share/github-backup-utils/ghe-rsync-size +++ b/share/github-backup-utils/ghe-rsync-size @@ -65,14 +65,22 @@ transfer_size() if [[ $cluster_status -eq 0 ]]; then cluster_conf_out=$(ghe-ssh "$host" "cat /data/user/common/cluster.conf") cluster_nodes_output=$(ghe-ssh "$host" "ghe-cluster-nodes -i") - if [[ ( "$1" == "elasticsearch" || "$1" == "storage" || "$1" == "pages" ) ]]; then - host_server=$(echo "$cluster_conf_out" | awk -v srv="$backup_data-server = true" '/cluster/ { prevA = $0 } $0 ~ srv { print prevA }' | head -1 | awk -F '"' '{print $2}') - elif [[ "$1" == "mysql" ]]; then - host_server=$(ghe-ssh "$host" "ghe-config cluster.mysql-master") - elif [[ "$1" == "repositories" ]]; then - host_server=$(echo "$cluster_conf_out" | awk '/git-server = true/ { print prevA } /cluster/ { prevA = $0 }' | head -1 | awk -F '"' '{print $2}') - fi - host=$(echo "$cluster_nodes_output" | grep "$host_server" | awk '{print $2}' | head -1) + case $1 in + elasticsearch | storage | pages) + cluster_host=$(echo "$cluster_conf_out" | awk -v srv="$backup_data-server = true" '/cluster/ { prevA = $0 } $0 ~ srv { print prevA }' | head -1 | awk -F '"' '{print $2}') + ;; + mysql) + cluster_host=$(ghe-ssh "$host" "ghe-config cluster.mysql-master") + ;; + repositories) + cluster_host=$(echo "$cluster_conf_out" | awk '/git-server = true/ { print prevA } /cluster/ { prevA = $0 }' | head -1 | awk -F '"' '{print $2}') + ;; + *) + echo "Unknown backup data: $1" + exit 1 + ;; + esac + host=$(echo "$cluster_nodes_output" | grep "$cluster_host" | awk '{print $2}' | head -1) fi if [ -d "${GHE_DATA_DIR}/current/$1" ]; then From 077a10e3dcbc6a3332c61ec0a811f0b8bec9300c Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 29 Aug 2023 13:41:03 +0000 Subject: [PATCH 2065/2421] Add comments --- share/github-backup-utils/ghe-rsync-size | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-rsync-size b/share/github-backup-utils/ghe-rsync-size index 3e454f6bf..e7aeb7d74 100644 --- a/share/github-backup-utils/ghe-rsync-size +++ b/share/github-backup-utils/ghe-rsync-size @@ -59,6 +59,7 @@ transfer_size() ;; esac + # Check if instance is cluster and fetch appropriate primary host for the different components ghe-ssh "$host" "[ -f /etc/github/cluster ]" cluster_status=$? @@ -83,6 +84,7 @@ transfer_size() host=$(echo "$cluster_nodes_output" | grep "$cluster_host" | awk '{print $2}' | head -1) fi + # Get file transfer size estimates if [ -d "${GHE_DATA_DIR}/current/$1" ]; then total_file_size=$(ghe-rsync -arn --stats \ -e "ssh -q $GHE_EXTRA_SSH_OPTS -p 122 -l admin" \ From b2f7717b3c47ff23ba9773e47950427dc6069f36 Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Tue, 29 Aug 2023 14:22:00 -0700 Subject: [PATCH 2066/2421] updated ghe-backup testing versions --- bin/ghe-backup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 86ee33dd7..58791d0f6 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -198,11 +198,11 @@ is_inc=$(is_incremental_backup_feature_on) if [ "$is_inc" = true ]; then if [ "$GHE_VERSION_MAJOR" -lt 3 ]; then - log_error "Can only perform incremental backups on enterprise version 3.10 or higher" + log_error "Can only perform incremental backups on enterprise version 3.11 or higher" exit 1 fi -if [ "$GHE_VERSION_MINOR" -lt 10 ]; then - log_error "Can only perform incremental backups on enterprise version 3.10 or higher" +if [ "$GHE_VERSION_MINOR" -lt 11 ]; then + log_error "Can only perform incremental backups on enterprise version 3.11 or higher" exit 1 fi From a708a1712b3d60e1b3c87c9ffdc35128d7d45c20 Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Tue, 29 Aug 2023 15:27:16 -0700 Subject: [PATCH 2067/2421] assert key is restored for 3.10 --- test/test-ghe-restore.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index cf93baa96..1294542c8 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -454,7 +454,7 @@ begin_test "ghe-restore with secret scanning encrypted secrets encryption keys f ) end_test -begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions below 3.11.0+" +begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions below 3.11.0" ( set -e rm -rf "$GHE_REMOTE_ROOT_DIR" @@ -475,7 +475,7 @@ begin_test "ghe-restore with secret scanning encrypted content encryption keys f ) for secret in "${required_secrets[@]}"; do - [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting these to not be set for versions below 3.11.0 + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] # expecting these to not be set for versions below 3.11.0 done ) end_test From b334c409db33fa7d962ab7e1ccecfb495e1dbc51 Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Tue, 29 Aug 2023 15:49:03 -0700 Subject: [PATCH 2068/2421] updated backup with test for 3-10 --- test/test-ghe-backup.sh | 28 ++++++++++++++++++++++++++-- test/test-ghe-restore.sh | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 7149e1158..42b6dccff 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -832,7 +832,7 @@ begin_test "ghe-backup takes backup of secret scanning encrypted secrets encrypt ) end_test -begin_test "ghe-backup takes backup of secret scanning encrypted content encryption keys" +begin_test "ghe-backup does not take backups of secret scanning encrypted content encryption keys on versions below 3.11.0" ( set -e @@ -844,7 +844,31 @@ begin_test "ghe-backup takes backup of secret scanning encrypted content encrypt ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" done - ghe-backup + GHE_REMOTE_VERSION=3.10.0 ghe-backup -v | grep -q "secret scanning encrypted content" && exit 1 + + required_files=( + "secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for file in "${required_files[@]}"; do + [ "$(cat "$GHE_DATA_DIR/current/$file")" = "" ] + done +) +end_test + +begin_test "ghe-backup takes backup of secret scanning encrypted content encryption keys on versions 3.11.0+" +( + set -e + + required_secrets=( + "secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for secret in "${required_secrets[@]}"; do + ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret" "foo" + done + + GHE_REMOTE_VERSION=3.11.0 ghe-backup required_files=( "secret-scanning-user-content-delimited-encryption-root-keys" diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 1294542c8..27bf13310 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -475,7 +475,7 @@ begin_test "ghe-restore with secret scanning encrypted content encryption keys f ) for secret in "${required_secrets[@]}"; do - [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] # expecting these to not be set for versions below 3.11.0 + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] # if this fails, it should fail silently for versions below 3.10 done ) end_test From 7868b3d807492632cee9fd2cb7380beffec22c5a Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Tue, 29 Aug 2023 16:16:17 -0700 Subject: [PATCH 2069/2421] Revert "updated ghe-backup testing versions" This reverts commit b2f7717b3c47ff23ba9773e47950427dc6069f36. --- bin/ghe-backup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 58791d0f6..86ee33dd7 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -198,11 +198,11 @@ is_inc=$(is_incremental_backup_feature_on) if [ "$is_inc" = true ]; then if [ "$GHE_VERSION_MAJOR" -lt 3 ]; then - log_error "Can only perform incremental backups on enterprise version 3.11 or higher" + log_error "Can only perform incremental backups on enterprise version 3.10 or higher" exit 1 fi -if [ "$GHE_VERSION_MINOR" -lt 11 ]; then - log_error "Can only perform incremental backups on enterprise version 3.11 or higher" +if [ "$GHE_VERSION_MINOR" -lt 10 ]; then + log_error "Can only perform incremental backups on enterprise version 3.10 or higher" exit 1 fi From 5edc50c3c63c49d9fbaee4ea82391c95aed1299c Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Tue, 29 Aug 2023 18:18:11 -0500 Subject: [PATCH 2070/2421] Updated restore test Co-authored-by: Robert Bolender --- test/test-ghe-restore.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 27bf13310..da7fdb06b 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -475,7 +475,7 @@ begin_test "ghe-restore with secret scanning encrypted content encryption keys f ) for secret in "${required_secrets[@]}"; do - [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] # if this fails, it should fail silently for versions below 3.10 + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting that this secret was not backed up on versions below 3.11.0, this secret was not present in earlier versions done ) end_test From 7f4301ad748b98d91e25f170456e6ca24dad18b7 Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Tue, 29 Aug 2023 16:46:46 -0700 Subject: [PATCH 2071/2421] add restore test against 3.9 --- test/test-ghe-restore.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index da7fdb06b..6734dbb09 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -454,6 +454,32 @@ begin_test "ghe-restore with secret scanning encrypted secrets encryption keys f ) end_test +begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions below 3.10.0" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + required_files=( + "secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for file in "${required_files[@]}"; do + echo "foo" >"$GHE_DATA_DIR/current/$file" + done + + GHE_REMOTE_VERSION=3.9.0 ghe-restore -v -f localhost + + required_secrets=( + "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting that this secret was not backed up on versions below 3.11.0, this secret was not present in earlier versions + done +) +end_test + begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions below 3.11.0" ( set -e From 45ac587e12e1a211d51e6d00fcc03418cf7539b2 Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Tue, 29 Aug 2023 16:56:18 -0700 Subject: [PATCH 2072/2421] adding version check to only restore for 3.11+ --- .../ghe-restore-secret-scanning-encryption-keys | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys b/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys index 4785a6d77..5c8dbdef6 100755 --- a/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys +++ b/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys @@ -37,7 +37,9 @@ restore-secret "secret scanning encrypted secrets current shared transit key" "s restore-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" # Restore secret scanning content scanning keys if present +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.11.0)" ]; then log_info "Restoring secret scanning content scanning keys" restore-secret "secret scanning user content delimited encryption root keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" +fi bm_end "$(basename $0)" From f08984be849ecac073bb6195f2f83c704dd72448 Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Tue, 29 Aug 2023 16:56:31 -0700 Subject: [PATCH 2073/2421] Revert "add restore test against 3.9" This reverts commit 7f4301ad748b98d91e25f170456e6ca24dad18b7. --- test/test-ghe-restore.sh | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 6734dbb09..da7fdb06b 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -454,32 +454,6 @@ begin_test "ghe-restore with secret scanning encrypted secrets encryption keys f ) end_test -begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions below 3.10.0" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - required_files=( - "secret-scanning-user-content-delimited-encryption-root-keys" - ) - - for file in "${required_files[@]}"; do - echo "foo" >"$GHE_DATA_DIR/current/$file" - done - - GHE_REMOTE_VERSION=3.9.0 ghe-restore -v -f localhost - - required_secrets=( - "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" - ) - - for secret in "${required_secrets[@]}"; do - [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting that this secret was not backed up on versions below 3.11.0, this secret was not present in earlier versions - done -) -end_test - begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions below 3.11.0" ( set -e From 80e0af3b74a9fc8a89937291c61629460fcc20f2 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 30 Aug 2023 18:17:12 +0000 Subject: [PATCH 2074/2421] simplify cluster output & parsing --- share/github-backup-utils/ghe-rsync-size | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/share/github-backup-utils/ghe-rsync-size b/share/github-backup-utils/ghe-rsync-size index e7aeb7d74..9ba0cf83f 100644 --- a/share/github-backup-utils/ghe-rsync-size +++ b/share/github-backup-utils/ghe-rsync-size @@ -60,25 +60,20 @@ transfer_size() esac # Check if instance is cluster and fetch appropriate primary host for the different components - ghe-ssh "$host" "[ -f /etc/github/cluster ]" - cluster_status=$? - - if [[ $cluster_status -eq 0 ]]; then - cluster_conf_out=$(ghe-ssh "$host" "cat /data/user/common/cluster.conf") + if "$CLUSTER"; then cluster_nodes_output=$(ghe-ssh "$host" "ghe-cluster-nodes -i") case $1 in - elasticsearch | storage | pages) - cluster_host=$(echo "$cluster_conf_out" | awk -v srv="$backup_data-server = true" '/cluster/ { prevA = $0 } $0 ~ srv { print prevA }' | head -1 | awk -F '"' '{print $2}') + elasticsearch | storage | pages | actions | mssql) + cluster_host=$(ghe-ssh "$host" "ghe-cluster-nodes -r $backup_data" | head -1) ;; mysql) cluster_host=$(ghe-ssh "$host" "ghe-config cluster.mysql-master") ;; repositories) - cluster_host=$(echo "$cluster_conf_out" | awk '/git-server = true/ { print prevA } /cluster/ { prevA = $0 }' | head -1 | awk -F '"' '{print $2}') + cluster_host=$(ghe-ssh "$host" "ghe-cluster-nodes -r git" | head -1) ;; *) - echo "Unknown backup data: $1" - exit 1 + exit 0 ;; esac host=$(echo "$cluster_nodes_output" | grep "$cluster_host" | awk '{print $2}' | head -1) From 2e512526add392486b38f335f2785908c2f53f3d Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 30 Aug 2023 20:33:09 +0000 Subject: [PATCH 2075/2421] fix unsupported ghe-version check --- test/test-ghe-host-check.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 6bfa12a69..aeb41551d 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -56,9 +56,14 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions read -r bu_version_major bu_version_minor _ <<<$(ghe_parse_version $BACKUP_UTILS_VERSION) bu_major_minor="$bu_version_major.$bu_version_minor" releases=$(/usr/bin/curl -s https://github-enterprise.s3.amazonaws.com/release/latest.json) - supported=$(echo $releases | jq -r 'select(."'${bu_major_minor}'")') + latest_value=$(echo "$releases" | jq -r '.latest') + latest_major_version=$(echo $latest_value | cut -d "." -f 1-2) + # Replace "latest" with the derived major version in the releases string + releases_with_replacement=$(echo "$releases" | sed 's/"latest"/"'"$latest_major_version"'"/g') + # Use the modified releases string as needed + supported=$(echo "$releases_with_replacement" | jq -r 'select(."'${bu_major_minor}'")') # shellcheck disable=SC2207 # Command required as alternatives fail - keys=($(echo $releases | jq -r 'keys[]')) + keys=($(echo "$releases_with_replacement" | jq -r 'keys[]')) if [ -z "$supported" ] then From b9e6a58f47bcc1a7cbd8528743eb866a94386e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sat, 5 Aug 2023 13:13:19 +0200 Subject: [PATCH 2076/2421] Record total runtime of ghe-backup and ghe-restore This adds the total runtime of ghe-backup and ghe-restore to the benchmark output. When investigating benchmark performance issues with customers and inspecting the benchmark output, it is helpful to know the total runtime of ghe-backup and ghe-restore as a reference for checking the durations of individual execution steps. While the stdout output currently shows the total runtime, customers generally do not store this output on disk, which makes it difficult to investigate backup-related performance issues after the fact. The runtime is recorded regardless of whether or not the commands completed successfully, as it may still be useful to see how long they have run when terminated early because of an error or human intervention. --- bin/ghe-backup | 3 +++ bin/ghe-restore | 3 +++ 2 files changed, 6 insertions(+) diff --git a/bin/ghe-backup b/bin/ghe-backup index 86ee33dd7..222502d81 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -121,6 +121,8 @@ cleanup () { # Cleanup SSH multiplexing ghe-ssh --clean + + bm_end "$(basename $0)" } # Setup exit traps @@ -216,6 +218,7 @@ fi echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress echo "$GHE_SNAPSHOT_TIMESTAMP $$" > "${GHE_DATA_DIR}/in-progress-backup" +bm_start "$(basename $0)" START_TIME=$(date +%s) log_info "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" diff --git a/bin/ghe-restore b/bin/ghe-restore index 19603ae47..f1b1f245e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -138,6 +138,8 @@ cleanup () { if ! rm -f "${GHE_DATA_DIR}/in-progress-restore"; then log_error "Failed to remove in-progress file" 1>&3 fi + + bm_end "$(basename $0)" } # This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. @@ -322,6 +324,7 @@ export PROGRESS=0 # Used to track progress of restore echo "$PROGRESS" > /tmp/backup-utils-progress # Log restore start message locally and in /var/log/syslog on remote instance +bm_start "$(basename $0)" START_TIME=$(date +%s) log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" From 1bb2d0e1342efc6516ff689857ddf35af1570bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Thu, 31 Aug 2023 22:08:11 +0200 Subject: [PATCH 2077/2421] Log if repositories are restored to multiple nodes --- share/github-backup-utils/ghe-restore-repositories | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/github-backup-utils/ghe-restore-repositories b/share/github-backup-utils/ghe-restore-repositories index 67bbf8e34..d63881be2 100755 --- a/share/github-backup-utils/ghe-restore-repositories +++ b/share/github-backup-utils/ghe-restore-repositories @@ -108,6 +108,8 @@ bm_end "$(basename $0) - Building network list" # each Spokes node including only those repository networks for which there was a route to the # respective Spokes node. if $CLUSTER; then + log_info "* Restoring repository networks to cluster nodes according to Spokes routes" 1>&3 + # The server returns a list of routes: # # a/nw/a8/3f/02/100000855 dgit-node1 dgit-node2 dgit-node3 @@ -150,6 +152,8 @@ if $CLUSTER; then # the Spokes route list captured during the backup. As we already have the list of all repository # network paths, we can simply use that as the rsync file list in noncluster environments. else + log_info "* Restoring all repository networks to target host unconditionally" 1>&3 + cp "$tmp_list" "$tempdir/git-server-primary.rsync" fi From adde32840c6198fc1401162dd885b48a2f2982dd Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 31 Aug 2023 17:28:14 -0400 Subject: [PATCH 2078/2421] Add incremental MySQL restore test (#530) Add basic tests for incremental MySQL restores --- test/test-ghe-host-check.sh | 5 +- test/test-ghe-incremental-restore.sh | 82 ++++++++++++++++++++++++++++ test/testlib.sh | 34 ++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) create mode 100755 test/test-ghe-incremental-restore.sh diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index aeb41551d..f2c5cca54 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -83,7 +83,10 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions ix=$(( $ix + 1 )) done GHE_TEST_REMOTE_VERSION="${keys[$ix]}.0" ghe-host-check - GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 1 ))]}.0" ghe-host-check + # sometimes when the latest.json is updated during a release this test gets broken. + if [ "${keys[$(( $ix - 1 ))]}" != "latest" ]; then + GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 1 ))]}.0" ghe-host-check + fi GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 2 ))]}.0" ghe-host-check fi diff --git a/test/test-ghe-incremental-restore.sh b/test/test-ghe-incremental-restore.sh new file mode 100755 index 000000000..bf3ace16a --- /dev/null +++ b/test/test-ghe-incremental-restore.sh @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +# ghe-restore command tests + +# Bring in testlib +# shellcheck source=test/testlib.sh +. "$(dirname "$0")/testlib.sh" + +setup_incremental_restore_data +setup_actions_enabled_settings_for_restore true + +# Make the current symlink +ln -s 1 "$GHE_DATA_DIR/current" +begin_test "ghe_restore -i doesn't run on unsupported versions" +( + set -e + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + # restore should fail on versions older than 3.10 + ! GHE_TEST_REMOTE_VERSION=3.9.0 ghe-restore -i -v + ! GHE_TEST_REMOTE_VERSION=3.7.0 ghe-restore -i -v + ! GHE_TEST_REMOTE_VERSION=3.1.0 ghe-restore -i -v +) +end_test + +begin_test "ghe-restore -i into configured vm from full backup" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + # run ghe-restore and write output to file for asserting against + if ! GHE_TEST_REMOTE_VERSION=3.10.0 GHE_DEBUG=1 ghe-restore -i -v -f > "$TRASHDIR/restore-out" 2>&1; then +output_debug_logs_and_fail_test + fi + + + # verify connect to right host + grep -q "Connect 127.0.0.1:122 OK" "$TRASHDIR/restore-out" + + # verify stale servers were cleared + grep -q "Cleaning up stale nodes ..." "$TRASHDIR/restore-out" + + # Verify all the data we've restored is as expected + verify_all_restored_data +) +end_test + +begin_test "ghe-restore -i fails when the lsn information for the listed files is out of order" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + + # set as configured, enable maintenance mode and create required directories + setup_maintenance_mode "configured" + + # set restore host environ var + GHE_RESTORE_HOST=127.0.0.1 + export GHE_RESTORE_HOST + + inc_1="$GHE_DATA_DIR/2" + inc_2="$GHE_DATA_DIR/3" + + # screw up the order of the LSNs in xtrabackup_checkpoints + setup_incremental_lsn $inc_1 100 200 incremental + setup_incremental_lsn $inc_2 50 50 incremental + # run ghe-restore and write output to file for asserting against + # we expect failure and need the right output. + if GHE_DEBUG=1 ghe-restore -i -v -f > "$TRASHDIR/restore-out" 2>&1; then + true + fi +) +end_test + + diff --git a/test/testlib.sh b/test/testlib.sh index 8e130eb75..e219a50d5 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -327,6 +327,40 @@ setup_test_data () { setup_minio_test_data "$GHE_DATA_DIR" } +# Sets up test data for testing incremental restores. +setup_incremental_restore_data() { + local full="$GHE_DATA_DIR/1" + local inc_1="$GHE_DATA_DIR/2" + local inc_2="$GHE_DATA_DIR/3" + # Run the setup_test_data function to create three directories: 1 for full backup and two incremental. + # we can use these directories for different types of tests + setup_test_data "$full" + setup_test_data "$inc_1" + setup_test_data "$inc_2" + # Setup the metadata files that track which files are used to track full and incremental files + echo "$full" >> "$GHE_DATA_DIR/inc_full_backup" + echo -e "$inc_1\n$inc_2" >> "$GHE_DATA_DIR/inc_snapshot_data" + # Configure lsn data in xtrabackup_checkpoints for the full backup and the incremental backup + setup_incremental_lsn $full 1 100 full + setup_incremental_lsn $inc_1 101 200 incremental + setup_incremental_lsn $inc_2 201 300 incremental +} + +setup_incremental_lsn() { + local loc=$1 + local start=$2 + local end=$3 + local type=$4 + +cat <> "$loc/xtrabackup_checkpoints" +backup_type = $type +from_lsn = $start +to_lsn = $end +last_lsn = $end +flushed_lsn = $end +LSN +} + setup_incremental_backup_config() { ghe-ssh "$GHE_HOSTNAME" -- 'mkdir -p /tmp/lsndir' ghe-ssh "$GHE_HOSTNAME" -- 'echo "fake xtrabackup checkpoint" > /tmp/lsndir/xtrabackup_checkpoints' From e80684dc50ab734a30c1e0715fbf32575d25f72c Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 1 Sep 2023 12:03:57 -0600 Subject: [PATCH 2079/2421] Run tests in serial --- .github/workflows/main.yml | 10 ---------- script/cibuild | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e4445915..50583737b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,9 +6,6 @@ jobs: build: strategy: matrix: - # macos-latest references are kept here for historical purposes. removed macos-latest from the - #matrix as it is not a typical case for users and causes a lot of friction with other linux-based - # installs. Recommend developing on codespaces or using an ubuntu container. os: ['ubuntu-22.04', 'ubuntu-20.04'] fail-fast: false runs-on: ${{ matrix.os }} @@ -20,12 +17,6 @@ jobs: wget "https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz" tar --xz -xvf "shellcheck-stable.linux.x86_64.tar.xz" sudo cp shellcheck-stable/shellcheck /usr/bin/shellcheck - if: matrix.os != 'macos-latest' - - name: Install Dependencies (macOS) - run: | - brew install gnu-tar shellcheck jq pigz coreutils gnu-sed gnu-getopt wget - brew install moreutils gawk - if: matrix.os == 'macos-latest' - name: Get Sources uses: actions/checkout@v3 - name: Test @@ -35,4 +26,3 @@ jobs: shell: bash - name: Build (Linux) run: DEB_BUILD_OPTIONS=nocheck debuild -us -uc - if: matrix.os != 'macos-latest' diff --git a/script/cibuild b/script/cibuild index 7f57f444d..73dc9ae0a 100755 --- a/script/cibuild +++ b/script/cibuild @@ -5,7 +5,7 @@ set -e # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true -if ! find test -name "test-*.sh" -print0 | xargs -0 -P 4 -n 1 /bin/bash; then +if ! find test -name "test-*.sh" -print0 | xargs -0 -n 1 /bin/bash; then exit 1 fi From 72266bdaa3b7e9adb4b2a36c51ea947096f2e776 Mon Sep 17 00:00:00 2001 From: Brandon Emlaw Date: Fri, 1 Sep 2023 15:45:55 -0500 Subject: [PATCH 2080/2421] fix spacing --- .../ghe-restore-secret-scanning-encryption-keys | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys b/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys index 5c8dbdef6..04f7588a7 100755 --- a/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys +++ b/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys @@ -38,8 +38,8 @@ restore-secret "secret scanning encrypted secrets delimited shared transit keys" # Restore secret scanning content scanning keys if present if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.11.0)" ]; then -log_info "Restoring secret scanning content scanning keys" -restore-secret "secret scanning user content delimited encryption root keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" + log_info "Restoring secret scanning content scanning keys" + restore-secret "secret scanning user content delimited encryption root keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" fi bm_end "$(basename $0)" From c19c08811a0183e5eaf906265ea857383bbdc359 Mon Sep 17 00:00:00 2001 From: Shruti Corbett <90784253+shcorbett@users.noreply.github.com> Date: Wed, 6 Sep 2023 10:21:09 -0400 Subject: [PATCH 2081/2421] Create pull_request_template.md Creating a pull request template to ensure specific information is documented and calling out the versions of GHES that are supported by backup-utils so that appropriate testing can be done against those versions --- .github/pull_request_template.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..fa678e53b --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,24 @@ +### Description + +### Testing + + + +### Owernship + + +### Related Links + From e0278f1ac87654dafa32c3beeac14869c0286170 Mon Sep 17 00:00:00 2001 From: Shruti Corbett <90784253+shcorbett@users.noreply.github.com> Date: Wed, 6 Sep 2023 10:27:26 -0400 Subject: [PATCH 2082/2421] Update pull_request_template.md --- .github/pull_request_template.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index fa678e53b..fd36d8a9a 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,5 @@ +# PR Details + ### Description -### Owernship +### Ownership From f9025aa47cc36bd94ec0a67973f5fc5c15e9fc21 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 12:34:29 -0400 Subject: [PATCH 2083/2421] init to win it --- .github/workflows/build-and-release.yml | 63 +++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/build-and-release.yml diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml new file mode 100644 index 000000000..79de3bdcd --- /dev/null +++ b/.github/workflows/build-and-release.yml @@ -0,0 +1,63 @@ +name: Build and Release + +# make it callable with required input of release-notes string +on: + workflow_dispatch: + inputs: + version: + description: 'Version - patch version of the release (e.g. x.y.z)' + required: true + type: string + release-notes: + description: 'Release Notes - string of markdown' + required: true + type: string + draft: + description: 'Draft - true if the release should be a draft' + required: true + type: boolean + default: true + +# in the first job +# first, run on ubuntu-latest +# then, install dependencies: moreutils, debhelper and help2man +# then, using the input version create a v{input.version} tag at the head of the branch +# then, checkout this repo +# then, run the bash scripts: /scripts/package-deb and /scripts/package-tarball +# in the next job +# create a release using ncipollo/release-action@v1 to attach release notes and the artifacts and tag from the previous job + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y moreutils debhelper help2man + - name: Create tag + run: | + git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" + - name: Checkout + uses: actions/checkout@v2 + - name: Package deb + run: | + bash scripts/package-deb + - name: Package tarball + run: | + bash scripts/package-tarball + release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Create Release + uses: ncipollo/release-action@v1 + with: + repo: github/backup-utils + artifacts: | + ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # token: ${{ secrets.GITHUB_TOKEN }} may need token, but try without first + releaseName: v${{ github.event.inputs.version }} + draft: ${{ github.event.inputs.draft }} + body: ${{ github.event.inputs.release-notes }} From 411d7423f816c712951f2598a9905874d8945d50 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 12:41:51 -0400 Subject: [PATCH 2084/2421] remove comment notes --- .github/workflows/build-and-release.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 79de3bdcd..46bd9cb57 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -1,6 +1,5 @@ name: Build and Release -# make it callable with required input of release-notes string on: workflow_dispatch: inputs: @@ -18,15 +17,6 @@ on: type: boolean default: true -# in the first job -# first, run on ubuntu-latest -# then, install dependencies: moreutils, debhelper and help2man -# then, using the input version create a v{input.version} tag at the head of the branch -# then, checkout this repo -# then, run the bash scripts: /scripts/package-deb and /scripts/package-tarball -# in the next job -# create a release using ncipollo/release-action@v1 to attach release notes and the artifacts and tag from the previous job - jobs: build: runs-on: ubuntu-latest From dfe71d6627c81602557568ed8f108fa6b1fd482d Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 12:48:00 -0400 Subject: [PATCH 2085/2421] fix input name --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 46bd9cb57..7dcb3f7c3 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -48,6 +48,6 @@ jobs: ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb # token: ${{ secrets.GITHUB_TOKEN }} may need token, but try without first - releaseName: v${{ github.event.inputs.version }} + name: v${{ github.event.inputs.version }} draft: ${{ github.event.inputs.draft }} body: ${{ github.event.inputs.release-notes }} From 5543165e2c293894f7cd0b15b953a31d6be241c2 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 13:48:08 -0400 Subject: [PATCH 2086/2421] checkout first --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 7dcb3f7c3..e1399ac2e 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -21,6 +21,8 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 - name: Install dependencies run: | sudo apt-get update @@ -28,8 +30,6 @@ jobs: - name: Create tag run: | git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" - - name: Checkout - uses: actions/checkout@v2 - name: Package deb run: | bash scripts/package-deb From f8080c9dec00cd5c1b606636ce792d13986bff77 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 7 Sep 2023 17:52:23 +0000 Subject: [PATCH 2087/2421] add NFS check --- bin/ghe-host-check | 7 +++++++ docs/requirements.md | 2 ++ 2 files changed, 9 insertions(+) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 104885114..d0fa767fe 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -168,6 +168,13 @@ SKIP_MSG # shellcheck source=share/github-backup-utils/ghe-rsync-size . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size" + #Check if GHE_DATA_DIR is NFS mounted + fs_info=$(stat -f -c "%T" "$GHE_DATA_DIR") + if [ "$fs_info" == "nfs" ]; then + echo "Warning: NFS (Network File System) detected for $GHE_DATA_DIR" 1>&2 + echo "Please review https://gh.io/backup-utils-storage-requirements for details." 1>&2 + fi + #Display dir requirements for repositories and mysql echo "" 1>&2 echo "Checking host for sufficient space for a backup..." 1>&2 diff --git a/docs/requirements.md b/docs/requirements.md index 1320eb583..e410c7381 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -57,6 +57,8 @@ Using a [case sensitive][7] file system is also required to avoid conflicts. Performance of backup and restore operations are also dependent on the backup host's storage. We recommend using a high performance storage system with low latency and high IOPS. +Please avoid using NFS mount for the data directory (where backup data is stored) as this can result in performance issues and timeouts during backups. + ## GitHub Enterprise Server version requirements Starting with Backup Utilities v2.13.0, version support is inline with that of the From 977db53c7f62f63e86f80bce7c23390965fff9bb Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 15:12:31 -0400 Subject: [PATCH 2088/2421] git config set to release-controller --- .github/workflows/build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index e1399ac2e..20bcbc0cb 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -29,6 +29,7 @@ jobs: sudo apt-get install -y moreutils debhelper help2man - name: Create tag run: | + git config --local user.name release-controller" git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" - name: Package deb run: | From 982820f88bd45c10e10aff9b1e37251447e147f9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 15:15:54 -0400 Subject: [PATCH 2089/2421] missing quote --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 20bcbc0cb..8d9e7f871 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -29,7 +29,7 @@ jobs: sudo apt-get install -y moreutils debhelper help2man - name: Create tag run: | - git config --local user.name release-controller" + git config --local user.name "release-controller" git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" - name: Package deb run: | From 2829fcfdf36c712517b039e879fd02a92ea27c58 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 15:18:57 -0400 Subject: [PATCH 2090/2421] direct to build scripts --- .github/workflows/build-and-release.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 8d9e7f871..28d2e49d2 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v2 - name: Install dependencies run: | - sudo apt-get update + sudo apt-get update -y sudo apt-get install -y moreutils debhelper help2man - name: Create tag run: | @@ -33,10 +33,12 @@ jobs: git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" - name: Package deb run: | - bash scripts/package-deb + ./scripts/package-deb + shell: bash - name: Package tarball run: | - bash scripts/package-tarball + ./scripts/package-tarball + shell: bash release: needs: build runs-on: ubuntu-latest From 1612b2077f43f012b9d6b613fd224d8dc2ab2ff9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 15:20:44 -0400 Subject: [PATCH 2091/2421] fix script path --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 28d2e49d2..58e95f34a 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -33,11 +33,11 @@ jobs: git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" - name: Package deb run: | - ./scripts/package-deb + ./script/package-deb shell: bash - name: Package tarball run: | - ./scripts/package-tarball + ./script/package-tarball shell: bash release: needs: build From a9a4e83d689f82e032757b1daa520851fcf3690e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 15:24:05 -0400 Subject: [PATCH 2092/2421] install devscripts --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 58e95f34a..2ac90e9bc 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man + sudo apt-get install -y moreutils debhelper help2man devscripts - name: Create tag run: | git config --local user.name "release-controller" From e791bbb8822e054ea4f5d2f3c06370dc364f8d6d Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 15:28:36 -0400 Subject: [PATCH 2093/2421] install gzip, tag needs to exist on remote --- .github/workflows/build-and-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 2ac90e9bc..af72b9123 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -26,11 +26,12 @@ jobs: - name: Install dependencies run: | sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts + sudo apt-get install -y moreutils debhelper help2man devscripts gzip - name: Create tag run: | git config --local user.name "release-controller" git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" + git push origin v${{ github.event.inputs.version }} - name: Package deb run: | ./script/package-deb From 7ff49305808bc1a77e117fb97c6084eaa9f324d1 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 16:14:03 -0400 Subject: [PATCH 2094/2421] use tag field --- .github/workflows/build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index af72b9123..05b1e2c1d 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -52,6 +52,7 @@ jobs: ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb # token: ${{ secrets.GITHUB_TOKEN }} may need token, but try without first + tag: v${{ github.event.inputs.version }} name: v${{ github.event.inputs.version }} draft: ${{ github.event.inputs.draft }} body: ${{ github.event.inputs.release-notes }} From 462e13c4e195d38f3318615476bab2fe89f57f87 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 16:40:35 -0400 Subject: [PATCH 2095/2421] need token --- .github/workflows/build-and-release.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 05b1e2c1d..5d5ec81c6 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -3,6 +3,10 @@ name: Build and Release on: workflow_dispatch: inputs: + gh-token: + description: 'GitHub Token - used to create the release' + required: true + type: string version: description: 'Version - patch version of the release (e.g. x.y.z)' required: true @@ -51,7 +55,7 @@ jobs: artifacts: | ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # token: ${{ secrets.GITHUB_TOKEN }} may need token, but try without first + token: ${{ github.event.inputs.gh-token }} tag: v${{ github.event.inputs.version }} name: v${{ github.event.inputs.version }} draft: ${{ github.event.inputs.draft }} From 78e7303ad7fe07cb4bafca92b109d3df6854eda7 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 17:46:36 -0400 Subject: [PATCH 2096/2421] try changing repo --- .github/workflows/build-and-release.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 5d5ec81c6..6de83fad7 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -31,11 +31,11 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag - run: | - git config --local user.name "release-controller" - git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" - git push origin v${{ github.event.inputs.version }} + # - name: Create tag + # run: | + # git config --local user.name "release-controller" + # git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" + # git push origin v${{ github.event.inputs.version }} - name: Package deb run: | ./script/package-deb @@ -48,14 +48,18 @@ jobs: needs: build runs-on: ubuntu-latest steps: + # - name: Set Up Release + # id: setup_release + # run: echo ::set-output name=token::${{ github.token }} - name: Create Release uses: ncipollo/release-action@v1 with: - repo: github/backup-utils + repo: backup-utils artifacts: | ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb token: ${{ github.event.inputs.gh-token }} + commit: ${{ github.sha }} tag: v${{ github.event.inputs.version }} name: v${{ github.event.inputs.version }} draft: ${{ github.event.inputs.draft }} From eb4437c6c8021fbc6238fe3a53aa4051dca09fa9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 17:49:38 -0400 Subject: [PATCH 2097/2421] again --- .github/workflows/build-and-release.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 6de83fad7..c3d54c3ae 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -31,9 +31,9 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # - name: Create tag - # run: | - # git config --local user.name "release-controller" + - name: Create tag + run: | + git config --local user.name "release-controller" # git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" # git push origin v${{ github.event.inputs.version }} - name: Package deb @@ -48,9 +48,6 @@ jobs: needs: build runs-on: ubuntu-latest steps: - # - name: Set Up Release - # id: setup_release - # run: echo ::set-output name=token::${{ github.token }} - name: Create Release uses: ncipollo/release-action@v1 with: From 25b67cd97dd8efcde6f45a0e6c354d8585619350 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 7 Sep 2023 17:55:45 -0400 Subject: [PATCH 2098/2421] need the tag on private? --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c3d54c3ae..b340d9215 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -34,8 +34,8 @@ jobs: - name: Create tag run: | git config --local user.name "release-controller" - # git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" - # git push origin v${{ github.event.inputs.version }} + git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" + git push origin v${{ github.event.inputs.version }} - name: Package deb run: | ./script/package-deb From 0e79c57ad8577770308560458f4e4ab88a41b988 Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 7 Sep 2023 15:09:58 -0700 Subject: [PATCH 2099/2421] Filter out rsync prerelease and set change file path --- .github/workflows/rsync-docker-bump.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index c59e4ede1..3e0815f8a 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -15,14 +15,14 @@ jobs: - name: Get latest rsync tag id: latest_tag run: | - curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[0].name' | xargs -I {} echo "::set-output name=latest_tag::{}" + curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "::set-output name=latest_tag::{}" - name: Update Dockerfile with latest tag run: | sed -i -E "s/RSYNC_TAG=[0-9\.]+/RSYNC_TAG=${{ steps.latest_tag.outputs.latest_tag }}/g" Dockerfile - name: Create Pull Request for tag update - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "Update rsync tag in Dockerfile" @@ -30,5 +30,5 @@ jobs: body: "This PR updates the rsync tag in the Dockerfile to the latest tagged version." branch: "update-rsync-tag" base: "master" - path: "." + add-paths: "Dockerfile" labels: "automated-update,rsync" From d5ada9ff9f01a25600748653c7a0d043990f4d8c Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 7 Sep 2023 15:26:35 -0700 Subject: [PATCH 2100/2421] Use environment file for output --- .github/workflows/rsync-docker-bump.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index 3e0815f8a..cfc1b24f9 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -15,7 +15,7 @@ jobs: - name: Get latest rsync tag id: latest_tag run: | - curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "::set-output name=latest_tag::{}" + curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "name=latest_tag::{}" >> $GITHUB_OUTPUT - name: Update Dockerfile with latest tag run: | From 5fef50b7ac2acb852ae918f7204b84f29e11c49e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 10:45:20 -0400 Subject: [PATCH 2101/2421] only use tag field --- .github/workflows/build-and-release.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index b340d9215..bc2cfef4c 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -54,10 +54,8 @@ jobs: repo: backup-utils artifacts: | ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - token: ${{ github.event.inputs.gh-token }} - commit: ${{ github.sha }} + ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} - name: v${{ github.event.inputs.version }} - draft: ${{ github.event.inputs.draft }} body: ${{ github.event.inputs.release-notes }} + draft: ${{ github.event.inputs.draft }} + token: ${{ github.event.inputs.gh-token }} From f7567dea923b6fd1081a555d9d244aec8fa7bf5b Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 10:55:41 -0400 Subject: [PATCH 2102/2421] set commit to master branch since the tag doesn't exist --- .github/workflows/build-and-release.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index bc2cfef4c..babfa13f7 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -54,8 +54,11 @@ jobs: repo: backup-utils artifacts: | ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # if the tag doesn't exist, we need to set it and the commit field tag: v${{ github.event.inputs.version }} + # this can be a commit hash or branch name + commit: master body: ${{ github.event.inputs.release-notes }} draft: ${{ github.event.inputs.draft }} token: ${{ github.event.inputs.gh-token }} From 65919cf618a8ab1bd9a88bae3d2a1651762c7845 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 11:28:29 -0400 Subject: [PATCH 2103/2421] list artifacts correctly --- .github/workflows/build-and-release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index babfa13f7..277bc2b94 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -52,9 +52,7 @@ jobs: uses: ncipollo/release-action@v1 with: repo: backup-utils - artifacts: | - ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + artifacts: "./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" # if the tag doesn't exist, we need to set it and the commit field tag: v${{ github.event.inputs.version }} # this can be a commit hash or branch name From 757ed89931a88914bb590c924f54145b29964c29 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 11:55:40 -0400 Subject: [PATCH 2104/2421] allowUpdate true --- .github/workflows/build-and-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 277bc2b94..31a0f6d34 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -59,4 +59,6 @@ jobs: commit: master body: ${{ github.event.inputs.release-notes }} draft: ${{ github.event.inputs.draft }} - token: ${{ github.event.inputs.gh-token }} + token: ${{ github.event.inputs.gh-token }} + allowUpdates: true + artifactContentType: "raw" From c191e203e22583182d8a1c6779541003f99a7581 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 12:45:55 -0400 Subject: [PATCH 2105/2421] pass artifacts to release job --- .github/workflows/build-and-release.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 31a0f6d34..132a4ade2 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -40,19 +40,37 @@ jobs: run: | ./script/package-deb shell: bash + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - name: Package tarball run: | ./script/package-tarball shell: bash + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: needs: build runs-on: ubuntu-latest steps: + - name: Download deb artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Download tarball artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - name: Create Release uses: ncipollo/release-action@v1 with: repo: backup-utils - artifacts: "./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + artifacts: "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, github-backup-utils_${{ github.event.inputs.version }}_all.deb" # if the tag doesn't exist, we need to set it and the commit field tag: v${{ github.event.inputs.version }} # this can be a commit hash or branch name From 26c2a1d8accfd74f03054505200b1ba5af3d63d2 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 13:37:16 -0400 Subject: [PATCH 2106/2421] fix the path --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 132a4ade2..65f519cc6 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -44,7 +44,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - name: Package tarball run: | ./script/package-tarball @@ -53,7 +53,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: needs: build runs-on: ubuntu-latest From 8767787be35779e359cf0814a866a170cce0ea54 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 14:42:08 -0400 Subject: [PATCH 2107/2421] where is the file --- .github/workflows/build-and-release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 65f519cc6..6c0a9572e 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -38,22 +38,22 @@ jobs: git push origin v${{ github.event.inputs.version }} - name: Package deb run: | - ./script/package-deb + ./script/package-deb && ls -l && ls -l /dist shell: bash - name: Upload deb artifact uses: actions/upload-artifact@v3 with: name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: ./dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: /dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - name: Package tarball run: | - ./script/package-tarball + ./script/package-tarball ls -l && ls -l /dist shell: bash - name: Upload tarball artifact uses: actions/upload-artifact@v3 with: name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: ./dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: /dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: needs: build runs-on: ubuntu-latest From 09bac26d2f0a4e953c1b1a2d90bffb9b21066895 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 14:47:53 -0400 Subject: [PATCH 2108/2421] find the artifacts --- .github/workflows/build-and-release.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 6c0a9572e..02c66f884 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -38,7 +38,11 @@ jobs: git push origin v${{ github.event.inputs.version }} - name: Package deb run: | - ./script/package-deb && ls -l && ls -l /dist + ./script/package-deb + shell: bash + - name: Find deb artifact + run: | + find . -name "github-backup-utils_${{ github.event.inputs.version }}_all.deb" | xargs -I {} cp {} /dist shell: bash - name: Upload deb artifact uses: actions/upload-artifact@v3 @@ -47,7 +51,11 @@ jobs: path: /dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - name: Package tarball run: | - ./script/package-tarball ls -l && ls -l /dist + ./script/package-tarball + shell: bash + - name: Find tarball artifact + run: | + find . -name "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz" | xargs -I {} cp {} /dist shell: bash - name: Upload tarball artifact uses: actions/upload-artifact@v3 From 829f3e1223e84b23c2b4d61f33ddf85e39e6b90d Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:20:28 -0400 Subject: [PATCH 2109/2421] Update docs/requirements.md Co-authored-by: David Jarzebowski --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index e410c7381..bba51c252 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -57,7 +57,7 @@ Using a [case sensitive][7] file system is also required to avoid conflicts. Performance of backup and restore operations are also dependent on the backup host's storage. We recommend using a high performance storage system with low latency and high IOPS. -Please avoid using NFS mount for the data directory (where backup data is stored) as this can result in performance issues and timeouts during backups. +Please avoid using an NFS mount for the data directory (where backup data is stored) as this can cause performance issues and timeouts during backups. ## GitHub Enterprise Server version requirements From 920bdd3532a42960e00b66ae881a7b814bf2df0c Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 15:31:36 -0400 Subject: [PATCH 2110/2421] find it --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 02c66f884..ddebebcdb 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -42,7 +42,7 @@ jobs: shell: bash - name: Find deb artifact run: | - find . -name "github-backup-utils_${{ github.event.inputs.version }}_all.deb" | xargs -I {} cp {} /dist + ls -l && find . -name "github-backup-utils_${{ github.event.inputs.version }}_all.deb" shell: bash - name: Upload deb artifact uses: actions/upload-artifact@v3 @@ -55,7 +55,7 @@ jobs: shell: bash - name: Find tarball artifact run: | - find . -name "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz" | xargs -I {} cp {} /dist + ls -l && find . -name "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz" shell: bash - name: Upload tarball artifact uses: actions/upload-artifact@v3 From 9d316088e15529d2fe91dfd2d1e1a9b30decc67d Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali <98570028+chuckp22@users.noreply.github.com> Date: Fri, 8 Sep 2023 16:07:30 -0400 Subject: [PATCH 2111/2421] Update bin/ghe-host-check Co-authored-by: Quinn Murphy --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index d0fa767fe..9e8d6466b 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -169,7 +169,7 @@ SKIP_MSG . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size" #Check if GHE_DATA_DIR is NFS mounted - fs_info=$(stat -f -c "%T" "$GHE_DATA_DIR") + fs_info=$(stat -f -c "%T" "$GHE_DATA_DIR") || true if [ "$fs_info" == "nfs" ]; then echo "Warning: NFS (Network File System) detected for $GHE_DATA_DIR" 1>&2 echo "Please review https://gh.io/backup-utils-storage-requirements for details." 1>&2 From 2b605d9e62c1798c51607d936d2000282f285735 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 16:44:16 -0400 Subject: [PATCH 2112/2421] find it --- .github/workflows/build-and-release.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index ddebebcdb..64733a08f 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -42,21 +42,17 @@ jobs: shell: bash - name: Find deb artifact run: | - ls -l && find . -name "github-backup-utils_${{ github.event.inputs.version }}_all.deb" + ls -l && find . -name "github-backup-utils_*_all.deb" && ls -R shell: bash - name: Upload deb artifact uses: actions/upload-artifact@v3 with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: /dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + name: github-backup-utils_3.8.0_all.deb + path: github-backup-utils_3.8.0_all.deb - name: Package tarball run: | ./script/package-tarball shell: bash - - name: Find tarball artifact - run: | - ls -l && find . -name "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz" - shell: bash - name: Upload tarball artifact uses: actions/upload-artifact@v3 with: @@ -69,16 +65,19 @@ jobs: - name: Download deb artifact uses: actions/download-artifact@v3 with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + name: github-backup-utils_3.8.0_all.deb + - name: Display structure of downloaded files + run: | + ls -R - name: Download tarball artifact uses: actions/download-artifact@v3 with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - name: Create Release uses: ncipollo/release-action@v1 with: repo: backup-utils - artifacts: "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, github-backup-utils_${{ github.event.inputs.version }}_all.deb" + artifacts: "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, github-backup-utils_3.8.0_all.deb" # if the tag doesn't exist, we need to set it and the commit field tag: v${{ github.event.inputs.version }} # this can be a commit hash or branch name From 81a1cdb50107b5ff9c8ac146874d7ad819ca7d07 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 8 Sep 2023 17:22:33 -0400 Subject: [PATCH 2113/2421] now we know --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 64733a08f..2a7ff79f3 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -48,7 +48,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: github-backup-utils_3.8.0_all.deb - path: github-backup-utils_3.8.0_all.deb + path: dist/github-backup-utils_3.8.0_all.deb - name: Package tarball run: | ./script/package-tarball @@ -57,7 +57,7 @@ jobs: uses: actions/upload-artifact@v3 with: name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: /dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: needs: build runs-on: ubuntu-latest From 1d924a12d3c50ff9e76a0d6560bf9d81d1ae90f2 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Mon, 11 Sep 2023 10:08:43 +0200 Subject: [PATCH 2114/2421] add post backup cleanup and move progress to folder (#558) --- bin/ghe-backup | 8 ++++---- bin/ghe-backup-progress | 8 ++++---- bin/ghe-restore | 6 +++--- share/github-backup-utils/ghe-backup-config | 13 +++++++++++-- share/github-backup-utils/track-progress | 11 +++++------ test/test-ghe-backup.sh | 2 ++ test/testlib.sh | 6 ++++++ 7 files changed, 35 insertions(+), 19 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 86ee33dd7..d8074156e 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -163,11 +163,11 @@ echo "$GHE_REMOTE_VERSION" > version # Setup progress tracking init-progress export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14 -echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total +echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total export PROGRESS_TYPE="Backup" -echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type +echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type export PROGRESS=0 # Used to track progress of backup -echo "$PROGRESS" > /tmp/backup-utils-progress +echo "$PROGRESS" > /tmp/backup-utils-progress/progress OPTIONAL_STEPS=0 # Backup actions+mssql @@ -191,7 +191,7 @@ if [ "$GHE_BACKUP_PAGES" != "no" ]; then fi PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14 -echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total +echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total # check that incremental settings are valid if set is_inc=$(is_incremental_backup_feature_on) diff --git a/bin/ghe-backup-progress b/bin/ghe-backup-progress index 2f4b267fb..7ab36e084 100755 --- a/bin/ghe-backup-progress +++ b/bin/ghe-backup-progress @@ -31,7 +31,7 @@ while true; do done check_for_progress_file() { - if [ ! -f /tmp/backup-utils-progress-info ]; then + if [ ! -f /tmp/backup-utils-progress/info ]; then echo "No progress file found. Has a backup or restore been started?" exit 1 fi @@ -39,18 +39,18 @@ check_for_progress_file() { if [ -n "$ONCE" ]; then check_for_progress_file - cat /tmp/backup-utils-progress-info + cat /tmp/backup-utils-progress/info else check_for_progress_file clear - cat /tmp/backup-utils-progress-info + cat /tmp/backup-utils-progress/info while true; do if read -r -t 1 -n 1; then clear exit ; else clear - cat /tmp/backup-utils-progress-info + cat /tmp/backup-utils-progress/info fi done fi diff --git a/bin/ghe-restore b/bin/ghe-restore index 19603ae47..175d74135 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -315,11 +315,11 @@ fi export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7)) init-progress -echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total +echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total export PROGRESS_TYPE="Restore" -echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress-type +echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type export PROGRESS=0 # Used to track progress of restore -echo "$PROGRESS" > /tmp/backup-utils-progress +echo "$PROGRESS" > /tmp/backup-utils-progress/progress # Log restore start message locally and in /var/log/syslog on remote instance START_TIME=$(date +%s) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 5b7f1c3d3..d3f8b05aa 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -652,12 +652,21 @@ restore-secret() { #initialize progress tracking by clearing out the temp files used to track init-progress() { - rm -f /tmp/backup-utils-progress* + if [ -d /tmp/backup-utils-progress ]; then + rm -rf /tmp/backup-utils-progress/* + else + mkdir /tmp/backup-utils-progress + fi + touch /tmp/backup-utils-progress/total + touch /tmp/backup-utils-progress/type + touch /tmp/backup-utils-progress/progress + touch /tmp/backup-utils-progress/info + chmod -R 777 /tmp/backup-utils-progress } #increase total count of progress increment-progress-total-count() { ((PROGRESS_TOTAL += $1)) - echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress-total + echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total } diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index d88b3704f..a560ba540 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -1,13 +1,12 @@ #!/usr/bin/env bash #/ track-progress: track progress of backup or restore tasks -# Current version is working solely with backups progress(){ - PROGRESS=$(cat /tmp/backup-utils-progress) - PROGRESS_TOTAL=$(cat /tmp/backup-utils-progress-total) - PROGRESS_TYPE=$(cat /tmp/backup-utils-progress-type) + PROGRESS=$(cat /tmp/backup-utils-progress/progress) + PROGRESS_TOTAL=$(cat /tmp/backup-utils-progress/total) + PROGRESS_TYPE=$(cat /tmp/backup-utils-progress/type) PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) - echo $((PROGRESS + 1)) > /tmp/backup-utils-progress - echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress-info + echo $((PROGRESS + 1)) > /tmp/backup-utils-progress/progress + echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress/info } diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index 42b6dccff..d6391bbef 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -47,6 +47,8 @@ begin_test "ghe-backup subsequent snapshot" [ "$first_snapshot" != "$this_snapshot" ] verify_all_backedup_data + + verify_progress_cleanup_process ) end_test diff --git a/test/testlib.sh b/test/testlib.sh index e219a50d5..10d6f7821 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -528,6 +528,12 @@ verify_all_backedup_data() { verify_common_data } +# A unified method to make sure post backup, the cleanup process works +verify_progress_cleanup_process() { + set -e + sudo -u nobody rm -rf /tmp/backup-utils-progress/* +} + # A unified method to check everything restored when performing a full restore # during testing. verify_all_restored_data() { From 16c1968f13762cf3f75aca8587d1af421298cbb0 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 09:36:56 -0400 Subject: [PATCH 2115/2421] rename file for now, clean up debug, get release-notes from directory, fix title --- .github/workflows/build-and-release.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 2a7ff79f3..8b521e539 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -40,15 +40,15 @@ jobs: run: | ./script/package-deb shell: bash - - name: Find deb artifact + - name: Rename deb artifact run: | - ls -l && find . -name "github-backup-utils_*_all.deb" && ls -R + mv dist/$(ls dist | grep github-backup-utils_.*_all.deb) dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb shell: bash - name: Upload deb artifact uses: actions/upload-artifact@v3 with: - name: github-backup-utils_3.8.0_all.deb - path: dist/github-backup-utils_3.8.0_all.deb + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - name: Package tarball run: | ./script/package-tarball @@ -66,9 +66,6 @@ jobs: uses: actions/download-artifact@v3 with: name: github-backup-utils_3.8.0_all.deb - - name: Display structure of downloaded files - run: | - ls -R - name: Download tarball artifact uses: actions/download-artifact@v3 with: @@ -77,12 +74,13 @@ jobs: uses: ncipollo/release-action@v1 with: repo: backup-utils + name: "GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }}" artifacts: "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, github-backup-utils_3.8.0_all.deb" - # if the tag doesn't exist, we need to set it and the commit field + # this action will create a tag with this name on the provided commit tag: v${{ github.event.inputs.version }} # this can be a commit hash or branch name commit: master - body: ${{ github.event.inputs.release-notes }} + body: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} token: ${{ github.event.inputs.gh-token }} allowUpdates: true From fb24a3f8b24884275ea9d0225cbd3d1f339a84e8 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 10:02:25 -0400 Subject: [PATCH 2116/2421] fix download file name --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 8b521e539..e9229df9b 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -65,7 +65,7 @@ jobs: - name: Download deb artifact uses: actions/download-artifact@v3 with: - name: github-backup-utils_3.8.0_all.deb + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - name: Download tarball artifact uses: actions/download-artifact@v3 with: From 96a69805eafc967e61a0e5d9807d0023f0ebedcf Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 10:05:48 -0400 Subject: [PATCH 2117/2421] try adding release-controller email --- .github/workflows/build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index e9229df9b..ba61c90f4 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -34,6 +34,7 @@ jobs: - name: Create tag run: | git config --local user.name "release-controller" + git config --local user.email "release-controller@github.com" git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" git push origin v${{ github.event.inputs.version }} - name: Package deb From 978b63978f7f514cea77ac90a6c1af288fcceb10 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 10:06:47 -0400 Subject: [PATCH 2118/2421] remove --local --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index ba61c90f4..c7c75aa91 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -33,8 +33,8 @@ jobs: sudo apt-get install -y moreutils debhelper help2man devscripts gzip - name: Create tag run: | - git config --local user.name "release-controller" - git config --local user.email "release-controller@github.com" + git config user.name "release-controller" + git config user.email "release-controller@github.com" git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" git push origin v${{ github.event.inputs.version }} - name: Package deb From f52e4e29de8225d178912d5bb6e0012d38f003c8 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 10:40:45 -0400 Subject: [PATCH 2119/2421] rename artifact correctly --- .github/workflows/build-and-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c7c75aa91..cbaeb6725 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -41,6 +41,7 @@ jobs: run: | ./script/package-deb shell: bash + # many need to remove this once release-notes compilation is automated - name: Rename deb artifact run: | mv dist/$(ls dist | grep github-backup-utils_.*_all.deb) dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb @@ -76,7 +77,7 @@ jobs: with: repo: backup-utils name: "GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }}" - artifacts: "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, github-backup-utils_3.8.0_all.deb" + artifacts: "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, github-backup-utils_${{ github.event.inputs.version }}_all.deb" # this action will create a tag with this name on the provided commit tag: v${{ github.event.inputs.version }} # this can be a commit hash or branch name From b23a3f7f755b77fd9798ed97d4a10cf4c20fa48c Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 11:17:55 -0400 Subject: [PATCH 2120/2421] with release notes --- release-notes/12.12.12.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 release-notes/12.12.12.md diff --git a/release-notes/12.12.12.md b/release-notes/12.12.12.md new file mode 100644 index 000000000..0e30c9359 --- /dev/null +++ b/release-notes/12.12.12.md @@ -0,0 +1,9 @@ +### Features + +- To reduce the time to generate a backup using `ghe-backup`, administrators can choose to prune old backup snapshots after a new backup has been generate. For more information, see "[Scheduling backups & snapshot pruning](https://github.com/github/backup-utils/blob/master/docs/scheduling-backups.md)." +- On instances with large MySQL databases , administrators who wish to save storage space can use the new `--incremental` flag with `ghe-backup` and `ghe-restore`. For more information, see "[Incremental MySQL Backups and Restores](https://github.com/github/backup-utils/tree/master/docs/incremental-mysql-backups-and-restores.md)". + +### Changes + +- Removed the `git clone` path for setting up `backup-utils` from the [getting started instructions](https://github.com/github/backup-utils/blob/master/docs/getting-started.md). +- Added `bc` v1.07 or newer to the [requirements](https://github.com/github/backup-utils/blob/master/docs/requirements.md) for a backup host machine. \ No newline at end of file From 59e28bef780c2f1649654418c7d85028190ce037 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 11:51:40 -0400 Subject: [PATCH 2121/2421] name field correctly --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index cbaeb6725..9d0217f06 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -82,7 +82,7 @@ jobs: tag: v${{ github.event.inputs.version }} # this can be a commit hash or branch name commit: master - body: release-notes/${{ github.event.inputs.version }}.md + bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} token: ${{ github.event.inputs.gh-token }} allowUpdates: true From 41dc43212c7855dbe5d8e2934199e077565805a0 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 12:15:11 -0400 Subject: [PATCH 2122/2421] linter fixes --- .github/workflows/build-and-release.yml | 84 ++++++++++++++----------- 1 file changed, 47 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 9d0217f06..6fcb9b3c0 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -25,41 +25,47 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag - run: | - git config user.name "release-controller" - git config user.email "release-controller@github.com" - git tag -a v${{ github.event.inputs.version }} -m "v${{ github.event.inputs.version }}" - git push origin v${{ github.event.inputs.version }} - - name: Package deb - run: | - ./script/package-deb - shell: bash - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - mv dist/$(ls dist | grep github-backup-utils_.*_all.deb) dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - shell: bash - - name: Upload deb artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - shell: bash - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Checkout + uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag + run: | + git config user.name "release-controller" + git config user.email "release-controller@github.com" + git tag -a v${{ github.event.inputs.version }} \ + -m "v${{ github.event.inputs.version }}" + git push origin v${{ github.event.inputs.version }} + - name: Package deb + run: | + ./script/package-deb + shell: bash + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + mv dist/$(ls dist | grep github-backup-utils_.*_all.deb) \ + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + shell: bash + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_\ + all.deb + - name: Package tarball + run: | + ./script/package-tarball + shell: bash + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}\ + .tar.gz release: needs: build runs-on: ubuntu-latest @@ -76,8 +82,12 @@ jobs: uses: ncipollo/release-action@v1 with: repo: backup-utils - name: "GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }}" - artifacts: "github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, github-backup-utils_${{ github.event.inputs.version }}_all.deb" + name: | + GitHub Enterprise Server Backup Utilities \ + v${{ github.event.inputs.version }} + artifacts: | + github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + github-backup-utils_${{ github.event.inputs.version }}_all.deb # this action will create a tag with this name on the provided commit tag: v${{ github.event.inputs.version }} # this can be a commit hash or branch name From be491ba4fc0983e529f21e3547631bef4f3ef863 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 13:00:05 -0400 Subject: [PATCH 2123/2421] find the release-notes file --- .github/workflows/build-and-release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 6fcb9b3c0..47fa1bd1d 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -78,6 +78,9 @@ jobs: uses: actions/download-artifact@v3 with: name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: See all files + run: | + ls -R - name: Create Release uses: ncipollo/release-action@v1 with: From 10f9679d2e8326dbfa6107722e688f06eda87bc9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 13:20:22 -0400 Subject: [PATCH 2124/2421] have to checkout the branch --- .github/workflows/build-and-release.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 47fa1bd1d..00e3f5556 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -70,6 +70,8 @@ jobs: needs: build runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v2 - name: Download deb artifact uses: actions/download-artifact@v3 with: @@ -78,9 +80,6 @@ jobs: uses: actions/download-artifact@v3 with: name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - - name: See all files - run: | - ls -R - name: Create Release uses: ncipollo/release-action@v1 with: From 91dd4f2875bcd6ec299512ed39a8f422e077165a Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 13:30:29 -0400 Subject: [PATCH 2125/2421] fix file paths --- .github/workflows/build-and-release.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 00e3f5556..6a8e0aeea 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -53,8 +53,7 @@ jobs: with: name: github-backup-utils_${{ github.event.inputs.version }}_all.deb path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_\ - all.deb + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - name: Package tarball run: | ./script/package-tarball @@ -64,8 +63,7 @@ jobs: with: name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}\ - .tar.gz + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: needs: build runs-on: ubuntu-latest From 1326890bfb0d6c52b4008e15330780712a383d1d Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 14:05:04 -0400 Subject: [PATCH 2126/2421] fix trailing white spaces --- .github/workflows/build-and-release.yml | 82 ++++++++++++------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 6a8e0aeea..379190505 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -25,45 +25,45 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag - run: | - git config user.name "release-controller" - git config user.email "release-controller@github.com" - git tag -a v${{ github.event.inputs.version }} \ - -m "v${{ github.event.inputs.version }}" - git push origin v${{ github.event.inputs.version }} - - name: Package deb - run: | - ./script/package-deb - shell: bash - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - mv dist/$(ls dist | grep github-backup-utils_.*_all.deb) \ - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - shell: bash - - name: Upload deb artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - shell: bash - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Checkout + uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag + run: | + git config user.name "release-controller" + git config user.email "release-controller@github.com" + git tag -a v${{ github.event.inputs.version }} \ + -m "v${{ github.event.inputs.version }}" + git push origin v${{ github.event.inputs.version }} + - name: Package deb + run: | + ./script/package-deb + shell: bash + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + mv dist/$(ls dist | grep github-backup-utils_.*_all.deb) \ + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + shell: bash + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + shell: bash + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: needs: build runs-on: ubuntu-latest @@ -82,10 +82,10 @@ jobs: uses: ncipollo/release-action@v1 with: repo: backup-utils - name: | + name: | GitHub Enterprise Server Backup Utilities \ v${{ github.event.inputs.version }} - artifacts: | + artifacts: | github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ github-backup-utils_${{ github.event.inputs.version }}_all.deb # this action will create a tag with this name on the provided commit From 147a791aa0c2cf34f5b407f5bee51ef3d7e07f0a Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 14:06:14 -0400 Subject: [PATCH 2127/2421] remove slash in title --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 379190505..a30c8d666 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -83,7 +83,7 @@ jobs: with: repo: backup-utils name: | - GitHub Enterprise Server Backup Utilities \ + GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} artifacts: | github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ From b2931402b9f95ab067df66a1473e3939eb8af384 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 14:10:02 -0400 Subject: [PATCH 2128/2421] trailing white space --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index a30c8d666..c67e6f9ce 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -83,7 +83,7 @@ jobs: with: repo: backup-utils name: | - GitHub Enterprise Server Backup Utilities + GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} artifacts: | github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ From a765d48d59fb8bd890637d2b1bb256ff01b0cfdc Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 15:18:54 -0400 Subject: [PATCH 2129/2421] remove test release-notes --- release-notes/12.12.12.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 release-notes/12.12.12.md diff --git a/release-notes/12.12.12.md b/release-notes/12.12.12.md deleted file mode 100644 index 0e30c9359..000000000 --- a/release-notes/12.12.12.md +++ /dev/null @@ -1,9 +0,0 @@ -### Features - -- To reduce the time to generate a backup using `ghe-backup`, administrators can choose to prune old backup snapshots after a new backup has been generate. For more information, see "[Scheduling backups & snapshot pruning](https://github.com/github/backup-utils/blob/master/docs/scheduling-backups.md)." -- On instances with large MySQL databases , administrators who wish to save storage space can use the new `--incremental` flag with `ghe-backup` and `ghe-restore`. For more information, see "[Incremental MySQL Backups and Restores](https://github.com/github/backup-utils/tree/master/docs/incremental-mysql-backups-and-restores.md)". - -### Changes - -- Removed the `git clone` path for setting up `backup-utils` from the [getting started instructions](https://github.com/github/backup-utils/blob/master/docs/getting-started.md). -- Added `bc` v1.07 or newer to the [requirements](https://github.com/github/backup-utils/blob/master/docs/requirements.md) for a backup host machine. \ No newline at end of file From 1220249348b4c64e5cba16514096c7b29e441dd9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 15:57:07 -0400 Subject: [PATCH 2130/2421] trying to fix linter errors --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c67e6f9ce..3c41a9aff 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -45,8 +45,8 @@ jobs: # many need to remove this once release-notes compilation is automated - name: Rename deb artifact run: | - mv dist/$(ls dist | grep github-backup-utils_.*_all.deb) \ - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + "mv dist/$(ls dist | grep 'github-backup-utils_.*_all.deb') \ + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" shell: bash - name: Upload deb artifact uses: actions/upload-artifact@v3 From 06f864b422e652783085099d303da87c79b8a46c Mon Sep 17 00:00:00 2001 From: djdefi Date: Mon, 11 Sep 2023 13:08:41 -0700 Subject: [PATCH 2131/2421] Workflow dispatch / shellcheck disable invalid check --- .github/workflows/rsync-docker-bump.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index cfc1b24f9..433fa3f96 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -1,6 +1,7 @@ name: Update Rsync Tag in Dockerfile on: + workflow_dispatch: schedule: - cron: '0 0 * * *' # Runs daily at 00:00 @@ -14,6 +15,7 @@ jobs: - name: Get latest rsync tag id: latest_tag + # shellcheck disable=SC2086 run: | curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "name=latest_tag::{}" >> $GITHUB_OUTPUT From fc5c0854e00fc6029f4c9864af7b565a5deb6089 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 16:08:43 -0400 Subject: [PATCH 2132/2421] fingers crossed --- .github/workflows/build-and-release.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 3c41a9aff..011bdf4e9 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -45,8 +45,12 @@ jobs: # many need to remove this once release-notes compilation is automated - name: Rename deb artifact run: | - "mv dist/$(ls dist | grep 'github-backup-utils_.*_all.deb') \ - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + run: | + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done shell: bash - name: Upload deb artifact uses: actions/upload-artifact@v3 From f4e6b2a0d2568dfb72f1b831b429e1bcd6db0895 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 16:09:54 -0400 Subject: [PATCH 2133/2421] test release-notes --- release-notes/12.12.12.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 release-notes/12.12.12.md diff --git a/release-notes/12.12.12.md b/release-notes/12.12.12.md new file mode 100644 index 000000000..8735a0322 --- /dev/null +++ b/release-notes/12.12.12.md @@ -0,0 +1,11 @@ +# Changes + +### Features + +- To reduce the time to generate a backup using `ghe-backup`, administrators can choose to prune old backup snapshots after a new backup has been generate. For more information, see "[Scheduling backups & snapshot pruning](https://github.com/github/backup-utils/blob/master/docs/scheduling-backups.md)." +- On instances with large MySQL databases , administrators who wish to save storage space can use the new `--incremental` flag with `ghe-backup` and `ghe-restore`. For more information, see "[Incremental MySQL Backups and Restores](https://github.com/github/backup-utils/tree/master/docs/incremental-mysql-backups-and-restores.md)". + +### Changes + +- Removed the `git clone` path for setting up `backup-utils` from the [getting started instructions](https://github.com/github/backup-utils/blob/master/docs/getting-started.md). +- Added `bc` v1.07 or newer to the [requirements](https://github.com/github/backup-utils/blob/master/docs/requirements.md) for a backup host machine. \ No newline at end of file From 77004063857cbfedd380b8fffadf671d8741f485 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 16:35:04 -0400 Subject: [PATCH 2134/2421] bad command --- .github/workflows/build-and-release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 011bdf4e9..b05fe8ca1 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -45,7 +45,6 @@ jobs: # many need to remove this once release-notes compilation is automated - name: Rename deb artifact run: | - run: | for file in dist/github-backup-utils_*_all.deb; do if [[ -f "$file" ]]; then mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" From 09937de499abd68f640210be6a969729212ef48e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 11 Sep 2023 17:00:00 -0400 Subject: [PATCH 2135/2421] remove test md file --- release-notes/12.12.12.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 release-notes/12.12.12.md diff --git a/release-notes/12.12.12.md b/release-notes/12.12.12.md deleted file mode 100644 index 8735a0322..000000000 --- a/release-notes/12.12.12.md +++ /dev/null @@ -1,11 +0,0 @@ -# Changes - -### Features - -- To reduce the time to generate a backup using `ghe-backup`, administrators can choose to prune old backup snapshots after a new backup has been generate. For more information, see "[Scheduling backups & snapshot pruning](https://github.com/github/backup-utils/blob/master/docs/scheduling-backups.md)." -- On instances with large MySQL databases , administrators who wish to save storage space can use the new `--incremental` flag with `ghe-backup` and `ghe-restore`. For more information, see "[Incremental MySQL Backups and Restores](https://github.com/github/backup-utils/tree/master/docs/incremental-mysql-backups-and-restores.md)". - -### Changes - -- Removed the `git clone` path for setting up `backup-utils` from the [getting started instructions](https://github.com/github/backup-utils/blob/master/docs/getting-started.md). -- Added `bc` v1.07 or newer to the [requirements](https://github.com/github/backup-utils/blob/master/docs/requirements.md) for a backup host machine. \ No newline at end of file From 0eb507f55ca264e3e893822ca3d09c7ccc191bc8 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 12 Sep 2023 13:14:47 -0700 Subject: [PATCH 2136/2421] single line run --- .github/workflows/rsync-docker-bump.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index 433fa3f96..cedcd2468 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -16,8 +16,7 @@ jobs: - name: Get latest rsync tag id: latest_tag # shellcheck disable=SC2086 - run: | - curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "name=latest_tag::{}" >> $GITHUB_OUTPUT + run: curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "name=latest_tag::{}" >> $GITHUB_OUTPUT - name: Update Dockerfile with latest tag run: | From 99837fe47ed57976c9da64c29e92a2972ab7895c Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 12 Sep 2023 13:15:39 -0700 Subject: [PATCH 2137/2421] remove sc skip comment --- .github/workflows/rsync-docker-bump.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index cedcd2468..6d90b7bbe 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -15,7 +15,6 @@ jobs: - name: Get latest rsync tag id: latest_tag - # shellcheck disable=SC2086 run: curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "name=latest_tag::{}" >> $GITHUB_OUTPUT - name: Update Dockerfile with latest tag From 12d65161975eae7a8b2a7e912e62dbb67fe97f82 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 12 Sep 2023 15:39:57 -0600 Subject: [PATCH 2138/2421] back off gist restore in parallel restore case to avoid race condition --- bin/ghe-restore | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 19603ae47..b48c06e5f 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -560,9 +560,18 @@ echo \"$cmd_title\" ghe-restore-repositories \"$GHE_HOSTNAME\"") cmd_title=$(log_info "Restoring Gists ...") -commands+=(" -echo \"$cmd_title\" -ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") +if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then + ## Stagger ghe-restore-repositories-gist with ghe-restore-repositories to avoid + ## race condition to operate on same destination directory + commands+=(" + echo \"$cmd_title\" + sleep 1 + ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") +else + commands+=(" + echo \"$cmd_title\" + ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") +fi if [ "$GHE_BACKUP_PAGES" != "no" ]; then cmd_title=$(log_info "Restoring Pages ...") From 648967cd931a791edaa8c6cdd1d5fdbbbdf080aa Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Tue, 12 Sep 2023 16:22:48 -0600 Subject: [PATCH 2139/2421] Update ghe-restore --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index b48c06e5f..77a8b089e 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -565,7 +565,7 @@ if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then ## race condition to operate on same destination directory commands+=(" echo \"$cmd_title\" - sleep 1 + sleep 2 ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") else commands+=(" From d60bb64993080576537850b6197decc0ed439c68 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 13 Sep 2023 11:24:31 -0600 Subject: [PATCH 2140/2421] Make this change test only --- bin/ghe-restore | 15 +++------------ test/testlib.sh | 2 ++ 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index d275e3a16..17a12b8b1 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -563,18 +563,9 @@ echo \"$cmd_title\" ghe-restore-repositories \"$GHE_HOSTNAME\"") cmd_title=$(log_info "Restoring Gists ...") -if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - ## Stagger ghe-restore-repositories-gist with ghe-restore-repositories to avoid - ## race condition to operate on same destination directory - commands+=(" - echo \"$cmd_title\" - sleep 2 - ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") -else - commands+=(" - echo \"$cmd_title\" - ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") -fi +commands+=(" +echo \"$cmd_title\" +ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") if [ "$GHE_BACKUP_PAGES" != "no" ]; then cmd_title=$(log_info "Restoring Pages ...") diff --git a/test/testlib.sh b/test/testlib.sh index 10d6f7821..1d38a8b8e 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -87,6 +87,8 @@ setup_remote_metadata () { mkdir -p "$GHE_REMOTE_DATA_DIR" "$GHE_REMOTE_DATA_USER_DIR" mkdir -p "$GHE_REMOTE_DATA_USER_DIR/common" mkdir -p "$GHE_REMOTE_ROOT_DIR/etc/github" + # Create fake remote repositories dir + mkdir -p "$GHE_REMOTE_DATA_USER_DIR/repositories" } setup_remote_metadata From 8baccb29106d266984efa4a00f20a5e8ce6aeb82 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 13 Sep 2023 11:30:08 -0600 Subject: [PATCH 2141/2421] Add integration tests --- .github/workflows/integration-tests.yml | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/integration-tests.yml diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml new file mode 100644 index 000000000..1a30dda3b --- /dev/null +++ b/.github/workflows/integration-tests.yml @@ -0,0 +1,33 @@ +name: Run Integration Tests + +on: [pull_request, workflow_dispatch] + +# Get target and source branch from different variables depending on how it was triggered +env: + TARGET_BRANCH: '${{ github.event.inputs.target-branch }}${{ github.base_ref || github.ref_name }}' + SOURCE_BRANCH: '${{ github.event.inputs.source-branch }}${{ github.head_ref || github.ref_name }}' + +jobs: + integration-tests: + runs-on: ubuntu-latest + strategy: + matrix: + jankyJobName: + - enterprise2-binary-backup + - enterprise2-migration + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Queue ${{ matrix.jankyJobName }} build + run: | + ref="${{ github.ref }}" + merge_branch=${ref#"refs/heads/"} + backup_utils_branch="${{ env.SOURCE_BRANCH }}" + #branch_name="${{ env.TARGET_BRANCH }}" + branch_name="janky-backup-utils-branch-test" + curl -v -X POST \ + -u "hubot:${{ secrets.API_AUTH_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d '{"buildable_name":"${{ matrix.jankyJobName }}","repo":"enterprise2","branch_name": "'"$branch_name"'","env_vars":{"JANKY_ENV_BACKUP_UTILS_BRANCH": "'"$backup_utils_branch"'" },"force":"true","room_id":"#builds"}' \ + "https://janky.githubapp.com/api/builds" From 841d025adfb713bd57069057eea3cb2b7efeab82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 19:22:17 +0200 Subject: [PATCH 2142/2421] Avoid duplicating test output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A long time ago, we used to track stdout and stderr separately. When both were combined, the postprocessing instructions of stdout and stderr were incorrectly merged, resulting in the output file being provided on stdin twice [1]. As a process cannot take two input streams, one of them was closed, causing no apparent issue. However, this triggered a shellcheck issue that was later addressed improperly [2], which instructed grep to read the output file from both stdin (by providing the - shorthand for /dev/stdin) and the output file location (by providing it as another file name argument). For this reason, the test output would contain the entire test output twice, once prefixed with “(standard input)” and once with the path to the output file. This fixes the issue by simply removing one of the occurrences of the output file, giving us a single copy of the test output in the case of a failure without unwanted prefixes in front of every output line. [1] 2915ec9aa3a11d4936641bdc9f9f43111817047b [2] 2bc31a99174a9f6ab3de361d3fca18f4bcf2c254 --- test/testlib.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 10d6f7821..cc7ac4c4b 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -153,7 +153,7 @@ report_failure () { printf "test: %-73s $msg\\n" "$desc ..." ( sed 's/^/ /' <"$TRASHDIR/out" | - grep -a -v -e '^\+ end_test' -e '^+ set +x' - "$TRASHDIR/out" | + grep -a -v -e '^\+ end_test' -e '^+ set +x' | sed 's/[+] test_status=/test failed. last command exited with /' | sed 's/^/ /' ) 1>&2 From e029f6836dbc1fd42e07a4642723e0c643c79da6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 20:13:25 +0200 Subject: [PATCH 2143/2421] Refactor reporting of failures To make the code more symmetric between passed, skipped, and failed tests, this moves the line printing the result for failed tests out of report_failure, which is now only concerned with reporting the output of the failed test. --- test/testlib.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index cc7ac4c4b..4f169ce32 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -146,11 +146,7 @@ begin_test () { before_time=$(date '+%s') } -report_failure () { - msg=$1 - desc=$2 - failures=$(( failures + 1 )) - printf "test: %-73s $msg\\n" "$desc ..." +report_failure_output () { ( sed 's/^/ /' <"$TRASHDIR/out" | grep -a -v -e '^\+ end_test' -e '^+ set +x' | @@ -172,7 +168,9 @@ end_test () { elif [ "$test_status" -eq 254 ]; then printf "test: %-65s SKIPPED\\n" "$test_description ..." else - report_failure "FAILED (${elapsed_time}s)" "$test_description ..." + failures=$(( failures + 1 )) + printf "test: %-65s FAILED (${elapsed_time}s)\\n" "$test_description ..." + report_failure_output fi unset test_description From 400e48e24bd15c65df6efca5afe9400da6c6e33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 20:18:46 +0200 Subject: [PATCH 2144/2421] Report test runtime in milliseconds --- test/testlib.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index 4f169ce32..c7a3cd78d 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -143,7 +143,7 @@ begin_test () { # allow the subshell to exit non-zero without exiting this process set -x +e - before_time=$(date '+%s') + before_time=$(date '+%s.%3N') } report_failure_output () { @@ -158,18 +158,18 @@ report_failure_output () { # Mark the end of a test. end_test () { test_status="${1:-$?}" - after_time=$(date '+%s') - elapsed_time=$((after_time - before_time)) + after_time=$(date '+%s.%3N') + elapsed_time=$(echo "scale=3; $after_time - $before_time" | bc) set +x -e exec 1>&3 2>&4 if [ "$test_status" -eq 0 ]; then - printf "test: %-65s OK (${elapsed_time}s)\\n" "$test_description ..." + printf "test: %-65s OK (%.3fs)\\n" "$test_description ..." "$elapsed_time" elif [ "$test_status" -eq 254 ]; then printf "test: %-65s SKIPPED\\n" "$test_description ..." else failures=$(( failures + 1 )) - printf "test: %-65s FAILED (${elapsed_time}s)\\n" "$test_description ..." + printf "test: %-65s FAILED (%.3fs)\\n" "$test_description ..." "$elapsed_time" report_failure_output fi From cd3cbbb683bdd4523d003a77d72176a6f04ea73f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 20:25:54 +0200 Subject: [PATCH 2145/2421] Truncate test output to exclude test instructions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds markers right before starting a test case and right after it completed, which are then used to truncate the output of the test case so that it doesn’t include any instructions related to the testing framework, as these aren’t relevant to users inspecting the test ouptut. --- test/testlib.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index c7a3cd78d..0696984fc 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -144,20 +144,28 @@ begin_test () { # allow the subshell to exit non-zero without exiting this process set -x +e before_time=$(date '+%s.%3N') + + # Marker to truncate the actual test output later + echo "begin_test_truncate_marker" > /dev/null } report_failure_output () { - ( - sed 's/^/ /' <"$TRASHDIR/out" | - grep -a -v -e '^\+ end_test' -e '^+ set +x' | - sed 's/[+] test_status=/test failed. last command exited with /' | - sed 's/^/ /' - ) 1>&2 + # Truncate the test output to exclude testing-related instructions + echo "$(<"$TRASHDIR/out")" \ + | sed '0,/begin_test_truncate_marker/d' \ + | sed -n '/end_test_truncate_marker/q;p' | head -n -2 \ + | sed 's/^/ /' \ + 1>&2 + echo -e "\nTest failed. The last command exited with exit code $test_status." 1>&2 } # Mark the end of a test. end_test () { test_status="${1:-$?}" + + # Marker to truncate the actual test output later + echo "end_test_truncate_marker" > /dev/null + after_time=$(date '+%s.%3N') elapsed_time=$(echo "scale=3; $after_time - $before_time" | bc) set +x -e From b8d781f1951a8a2999f6b8e6f448a40f5471a135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 20:30:10 +0200 Subject: [PATCH 2146/2421] Make test output collapsible To make the test logs more pleasant to interact with, this makes the test output of failed test cases collapsible. This avoids cluttering the test overview with the typically very long output of the individual test cases, such that users can get a full overview of all tests by default. If needed, the output of a specific test can easily be expanded in the GitHub Actions user interface. As the GitHub Actions user interface already indents the content of groups, we no longer need to indent it with sed. --- test/testlib.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 0696984fc..57a8e8e2d 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -150,13 +150,14 @@ begin_test () { } report_failure_output () { + echo "::group::Output of failed test" 1>&2 # Truncate the test output to exclude testing-related instructions echo "$(<"$TRASHDIR/out")" \ | sed '0,/begin_test_truncate_marker/d' \ | sed -n '/end_test_truncate_marker/q;p' | head -n -2 \ - | sed 's/^/ /' \ 1>&2 echo -e "\nTest failed. The last command exited with exit code $test_status." 1>&2 + echo "::endgroup::" 1>&2 } # Mark the end of a test. From 4d458bcc0a700e59a96a79dce317b3aacaacafa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 20:38:20 +0200 Subject: [PATCH 2147/2421] Reformat and colorize test logs for legibility This reformats the test logs to improve legibility. A key change is highlighting the test result with corresponding colors to make it easier for developers to spot tests that have failed at a quick glance. The test result and duration are moved to the front of each line to avoid formatting issues because of very long test descriptions that are hard to format in a layout with fixed column widths. Also, this colorizes the commands captured by set -x to visually distinguish them from the actual command output. --- test/testlib.sh | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index 57a8e8e2d..fb1d509a6 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -57,8 +57,23 @@ ghe_remote_version_config "$GHE_TEST_REMOTE_VERSION" # ghe-restore process groups unset GHE_SNAPSHOT_TIMESTAMP +# Color definitions for log output +color_reset=$(printf '\e[0m') +# Display commands (lines starting with + in the output) in purple +color_command=$(printf '\e[0;35m') +# Display exit code line in red +color_error_message=$(printf '\e[0;31m') +# Display successful tests in bold green +color_pass=$(printf '\e[1;32m') +# Display skipped tests in bold gray +color_skip=$(printf '\e[1;37m') +# Display failed tests in bold red +color_fail=$(printf '\e[1;31m') + # keep track of num tests and failures tests=0 +successes=0 +skipped=0 failures=0 # this runs at process exit @@ -155,8 +170,10 @@ report_failure_output () { echo "$(<"$TRASHDIR/out")" \ | sed '0,/begin_test_truncate_marker/d' \ | sed -n '/end_test_truncate_marker/q;p' | head -n -2 \ + | sed "s/^\(+.*\)$/${color_command}\1${color_reset}/" \ 1>&2 - echo -e "\nTest failed. The last command exited with exit code $test_status." 1>&2 + echo -e "\n${color_error_message}Test failed. The last command exited with exit code" \ + "$test_status.${color_reset}" 1>&2 echo "::endgroup::" 1>&2 } @@ -173,12 +190,19 @@ end_test () { exec 1>&3 2>&4 if [ "$test_status" -eq 0 ]; then - printf "test: %-65s OK (%.3fs)\\n" "$test_description ..." "$elapsed_time" + successes=$(( successes + 1 )) + printf "${color_pass}PASS${color_reset}" 1>&2 elif [ "$test_status" -eq 254 ]; then - printf "test: %-65s SKIPPED\\n" "$test_description ..." + skipped=$(( skipped + 1 )) + printf "${color_skip}SKIP${color_reset}" 1>&2 else failures=$(( failures + 1 )) - printf "test: %-65s FAILED (%.3fs)\\n" "$test_description ..." "$elapsed_time" + printf "${color_fail}FAIL${color_reset}" 1>&2 + fi + + printf " [%8.3f s] $test_description\\n" "$elapsed_time" 1>&2 + + if [ "$test_status" -ne 0 ] && [ "$test_status" -ne 254 ]; then report_failure_output fi From ddfe5b5cfc3e256e45d7df1cdb438a3723c548f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 20:03:53 +0200 Subject: [PATCH 2148/2421] Include name of test suite in test logs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a test fails, it’s not immediately clear which file it belongs to. To address this, this change adds the name of the test suite to the test logs, which corresponds to the name of the test file, omitting the file extension for better legibility. --- test/testlib.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index fb1d509a6..9001264b5 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -30,6 +30,9 @@ PATH="$ROOTDIR/test/bin:$ROOTDIR/bin:$ROOTDIR/share/github-backup-utils:$PATH" TMPDIR="$ROOTDIR/test/tmp" TRASHDIR="$TMPDIR/$(basename "$0")-$$" +test_suite_file_name="$(basename "${BASH_SOURCE[1]}")" +test_suite_name="${test_suite_file_name%.*}" + # Set GIT_{AUTHOR,COMMITTER}_{NAME,EMAIL} # This removes the assumption that a git config that specifies these is present. export GIT_AUTHOR_NAME=make GIT_AUTHOR_EMAIL=make GIT_COMMITTER_NAME=make GIT_COMMITTER_EMAIL=make @@ -63,6 +66,8 @@ color_reset=$(printf '\e[0m') color_command=$(printf '\e[0;35m') # Display exit code line in red color_error_message=$(printf '\e[0;31m') +# Display test suite name in blue +color_test_suite=$(printf '\e[0;34m') # Display successful tests in bold green color_pass=$(printf '\e[1;32m') # Display skipped tests in bold gray @@ -200,7 +205,8 @@ end_test () { printf "${color_fail}FAIL${color_reset}" 1>&2 fi - printf " [%8.3f s] $test_description\\n" "$elapsed_time" 1>&2 + printf " [%8.3f s] ${color_test_suite}$test_suite_name${color_reset} $test_description\\n" \ + "$elapsed_time" 1>&2 if [ "$test_status" -ne 0 ] && [ "$test_status" -ne 254 ]; then report_failure_output From 0ecd1b78c843ecf03991b56df54f9579b9b2c575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 19:51:35 +0200 Subject: [PATCH 2149/2421] Distinguish parallel test suites by name This introduces an override to the test suite name, which is determined as the name of the calling test file without its extension by default. For the parallel tests, the default does not work reliably, as they are essentially just thin wrappers around the test-ghe-backup and test-ghe-restore test suites. --- test/test-ghe-backup-parallel.sh | 3 +++ test/test-ghe-restore-parallel.sh | 3 +++ test/testlib.sh | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test-ghe-backup-parallel.sh b/test/test-ghe-backup-parallel.sh index c36b98a0d..173c1b66c 100755 --- a/test/test-ghe-backup-parallel.sh +++ b/test/test-ghe-backup-parallel.sh @@ -2,6 +2,9 @@ # ghe-backup command tests run in parallel set -e +# Overwrite default test suite name to distinguish it from test-ghe-backup +export GHE_TEST_SUITE_NAME="test-ghe-backup-parallel" + export GHE_PARALLEL_ENABLED=yes TESTS_DIR="$PWD/$(dirname "$0")" diff --git a/test/test-ghe-restore-parallel.sh b/test/test-ghe-restore-parallel.sh index e0c8a0caa..16cbb2f0f 100755 --- a/test/test-ghe-restore-parallel.sh +++ b/test/test-ghe-restore-parallel.sh @@ -8,6 +8,9 @@ if [[ "$OSTYPE" == "darwin"* ]]; then exit 0 fi +# Overwrite default test suite name to distinguish it from test-ghe-restore +export GHE_TEST_SUITE_NAME="test-ghe-restore-parallel" + export GHE_PARALLEL_ENABLED=yes # use temp dir to fix rsync file issues in parallel execution: diff --git a/test/testlib.sh b/test/testlib.sh index 9001264b5..7a9ac02fa 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -31,7 +31,7 @@ TMPDIR="$ROOTDIR/test/tmp" TRASHDIR="$TMPDIR/$(basename "$0")-$$" test_suite_file_name="$(basename "${BASH_SOURCE[1]}")" -test_suite_name="${test_suite_file_name%.*}" +test_suite_name="${GHE_TEST_SUITE_NAME:-${test_suite_file_name%.*}}" # Set GIT_{AUTHOR,COMMITTER}_{NAME,EMAIL} # This removes the assumption that a git config that specifies these is present. From f1a11687c9ee06e67f11c42ec75784fa7a5c6a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 19:40:48 +0200 Subject: [PATCH 2150/2421] Remove debug output This line clutters the test output and does not appear to be useful. --- test/testlib.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/test/testlib.sh b/test/testlib.sh index 7a9ac02fa..c7a1f6539 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -443,7 +443,6 @@ setup_minio_test_data() { bucket="packages" mkdir -p "$bucket" - echo "an example blob" "$bucket/91dfa09f-1801-4e00-95ee-6b763d7da3e2" } cleanup_minio_test_data() { From abfccfb8b4ec23982fee2ab1082a25ec1f23962f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 13 Sep 2023 19:36:17 +0200 Subject: [PATCH 2151/2421] Produce Markdown test summary --- script/cibuild | 21 ++++++++++++++++++--- test/testlib.sh | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/script/cibuild b/script/cibuild index 73dc9ae0a..22f7ffd08 100755 --- a/script/cibuild +++ b/script/cibuild @@ -2,13 +2,31 @@ # Usage: script/cibuild [--no-package] set -e +ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +TMPDIR="$ROOTDIR/test/tmp" + +# Remove possible remnants of previous test runs +rm -rf "${TMPDIR:?}/*" + +print_test_results() { + if [ -n "$GITHUB_STEP_SUMMARY" ]; then + echo -e "### Test results\n" >> "$GITHUB_STEP_SUMMARY" + echo "| Test suite | Result | Successful | Failed | Skipped | Duration |" >> "$GITHUB_STEP_SUMMARY" + echo "|---|---|--:|--:|--:|--:|" >> "$GITHUB_STEP_SUMMARY" + sort -V "$TMPDIR/results" >> "$GITHUB_STEP_SUMMARY" + fi +} + # Enable verbose logging of ssh commands export GHE_VERBOSE_SSH=true if ! find test -name "test-*.sh" -print0 | xargs -0 -n 1 /bin/bash; then + print_test_results exit 1 fi +print_test_results + # Bail out when --no-package given [ "$1" = "--no-package" ] && exit 0 @@ -16,9 +34,6 @@ fi pkg_files= # Build the tarball -ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" -TMPDIR="$ROOTDIR/test/tmp" - echo "Building tar.gz package ..." if script/package-tarball 1>$TMPDIR/package-tarball.txt 2>&1; then pkg_files=$(grep '^Package ' < $TMPDIR/package-tarball.txt | cut -f 2 -d ' ') diff --git a/test/testlib.sh b/test/testlib.sh index c7a1f6539..44bbaed67 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -32,6 +32,8 @@ TRASHDIR="$TMPDIR/$(basename "$0")-$$" test_suite_file_name="$(basename "${BASH_SOURCE[1]}")" test_suite_name="${GHE_TEST_SUITE_NAME:-${test_suite_file_name%.*}}" +results_file="$TMPDIR/results" +test_suite_before_time=$(date '+%s.%3N') # Set GIT_{AUTHOR,COMMITTER}_{NAME,EMAIL} # This removes the assumption that a git config that specifies these is present. @@ -85,6 +87,27 @@ failures=0 atexit () { res=$? + test_suite_after_time=$(date '+%s.%3N') + test_suite_elapsed_time=$(echo "scale=3; $test_suite_after_time - $test_suite_before_time" | bc) + + # Temporarily redirect stdout output to results file + exec 3<&1 + exec 1>>"$results_file" + + # Print test summary for this test suite + echo -n "| $test_suite_name | " + + if [ "$failures" -eq "0" ]; then + echo -n ":green_circle: passed" + else + echo -n ":red_circle: failed" + fi + + printf " | $successes | $failures | $skipped | %.3f s |\\n" "$test_suite_elapsed_time" + + # Restore stdout + exec 1<&3 + [ -z "$KEEPTRASH" ] && rm -rf "$TRASHDIR" if [ $failures -gt 0 ]; then exit 1 From e730d2b3c587dcb1e191f9f55a942d63968c1752 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 14 Sep 2023 10:02:22 -0400 Subject: [PATCH 2152/2421] remove token input --- .github/workflows/build-and-release.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index b05fe8ca1..b581eff7c 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -3,10 +3,6 @@ name: Build and Release on: workflow_dispatch: inputs: - gh-token: - description: 'GitHub Token - used to create the release' - required: true - type: string version: description: 'Version - patch version of the release (e.g. x.y.z)' required: true @@ -97,6 +93,5 @@ jobs: commit: master bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} - token: ${{ github.event.inputs.gh-token }} allowUpdates: true artifactContentType: "raw" From d4ccab2cf8f3053832f539c89d28f68c4ba88fd1 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 14 Sep 2023 10:03:22 -0400 Subject: [PATCH 2153/2421] try without shell field --- .github/workflows/build-and-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index b581eff7c..94056e00e 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -37,7 +37,6 @@ jobs: - name: Package deb run: | ./script/package-deb - shell: bash # many need to remove this once release-notes compilation is automated - name: Rename deb artifact run: | @@ -46,7 +45,6 @@ jobs: mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" fi done - shell: bash - name: Upload deb artifact uses: actions/upload-artifact@v3 with: From a8e8e9eb2c330b1e45b317bbd398a37fd8c7d5ac Mon Sep 17 00:00:00 2001 From: alejndr0 Date: Thu, 14 Sep 2023 14:04:15 +0000 Subject: [PATCH 2154/2421] Disable compression --- share/github-backup-utils/ghe-backup-actions | 2 +- share/github-backup-utils/ghe-backup-es-rsync | 4 ++-- share/github-backup-utils/ghe-backup-minio | 1 - share/github-backup-utils/ghe-backup-pages | 2 +- share/github-backup-utils/ghe-backup-userdata | 2 +- share/github-backup-utils/ghe-restore-es-audit-log | 2 +- share/github-backup-utils/ghe-restore-es-rsync | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions index aa02191be..b3f51741e 100755 --- a/share/github-backup-utils/ghe-backup-actions +++ b/share/github-backup-utils/ghe-backup-actions @@ -39,7 +39,7 @@ fi # Transfer all Actions data from the user data directory using rsync. ghe_verbose "* Transferring Actions files from $host ..." log_rsync "BEGIN: actions rsync" 1>&3 -ghe-rsync -avz \ +ghe-rsync -av \ -e "ghe-ssh -p $port" \ --rsync-path='sudo -u actions rsync' \ --exclude "mutexes" --exclude "dumps" --exclude "tmp" \ diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync index ee61741b2..fce7043bb 100755 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ b/share/github-backup-utils/ghe-backup-es-rsync @@ -45,7 +45,7 @@ fi # already been transferred. ghe_verbose "* Performing initial sync of ES indices ..." log_rsync "BEGIN elasticsearch rsync" 1>&3 -ghe-rsync -avz \ +ghe-rsync -av \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ @@ -70,7 +70,7 @@ ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null # Transfer all ES indices again ghe_verbose "* Performing follow-up sync of ES indices ..." log_rsync "BEGIN: elasticsearch followup rsync" 1>&3 -ghe-rsync -avz \ +ghe-rsync -av \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path="sudo -u elasticsearch rsync" \ $link_dest \ diff --git a/share/github-backup-utils/ghe-backup-minio b/share/github-backup-utils/ghe-backup-minio index 7f6a18b22..bf7a429d4 100755 --- a/share/github-backup-utils/ghe-backup-minio +++ b/share/github-backup-utils/ghe-backup-minio @@ -45,7 +45,6 @@ log_rsync "BEGIN: minio rsync" 1>&3 ghe-rsync \ --archive \ --verbose \ - --compress \ --rsh="ghe-ssh -p ${port}" \ --rsync-path='sudo -u minio rsync' \ --exclude=".minio.sys" \ diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages index b0c9f1fed..2b79825cf 100755 --- a/share/github-backup-utils/ghe-backup-pages +++ b/share/github-backup-utils/ghe-backup-pages @@ -75,7 +75,7 @@ for hostname in $hostnames; do ghe_verbose "* Transferring pages files ..." log_rsync "BEGIN: pages rsync" 1>&3 # Transfer all data from the user data directory using rsync. - ghe-rsync -avz \ + ghe-rsync -av \ -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ --rsync-path='sudo -u git rsync' \ $link_dest \ diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata index f332c27c4..d7c7dc233 100755 --- a/share/github-backup-utils/ghe-backup-userdata +++ b/share/github-backup-utils/ghe-backup-userdata @@ -54,7 +54,7 @@ fi mkdir -p "$GHE_SNAPSHOT_DIR/$dirname" log_rsync "BEGIN: userdata rsync" 1>&3 # Transfer all data from the user data directory using rsync. -ghe-rsync -avz \ +ghe-rsync -av \ -e "ghe-ssh -p $(ssh_port_part "$host")" \ --rsync-path='sudo -u git rsync' \ $link_dest \ diff --git a/share/github-backup-utils/ghe-restore-es-audit-log b/share/github-backup-utils/ghe-restore-es-audit-log index 06b63973b..0ed3d37b2 100755 --- a/share/github-backup-utils/ghe-restore-es-audit-log +++ b/share/github-backup-utils/ghe-restore-es-audit-log @@ -51,7 +51,7 @@ if [ -s "$tmp_list" ]; then ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 log_rsync "BEGIN: es-audit log rsync" 1>&3 - ghe-rsync -avz --delete \ + ghe-rsync -av --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u elasticsearch rsync" \ --files-from=$tmp_list \ diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index b1d9b2179..1ba09afed 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -37,7 +37,7 @@ else ghe-ssh "$GHE_HOSTNAME" -- "sudo mkdir -p '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 ghe-ssh "$GHE_HOSTNAME" -- "sudo chown elasticsearch:elasticsearch '$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore'" 1>&3 log_rsync "BEGIN: elasticsearch rsync" 1>&3 - ghe-rsync -avz --delete \ + ghe-rsync -av --delete \ -e "ghe-ssh -p $(ssh_port_part "$GHE_HOSTNAME")" \ --rsync-path="sudo -u elasticsearch rsync" \ --copy-dest="$GHE_REMOTE_DATA_USER_DIR/elasticsearch" \ From 8ebf223b2c2ed5535c9675e75e453b9e4ebd9fae Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 14 Sep 2023 10:10:05 -0400 Subject: [PATCH 2155/2421] set email to team distribution list --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 94056e00e..b3a989b50 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -30,7 +30,7 @@ jobs: - name: Create tag run: | git config user.name "release-controller" - git config user.email "release-controller@github.com" + git config user.email "ghes-releases-team@github.com" git tag -a v${{ github.event.inputs.version }} \ -m "v${{ github.event.inputs.version }}" git push origin v${{ github.event.inputs.version }} From 41071a4c6f0841b36b3d7676f09d4c8da061404f Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 14 Sep 2023 10:11:33 -0400 Subject: [PATCH 2156/2421] test release-notes --- release-notes/12.12.12.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 release-notes/12.12.12.md diff --git a/release-notes/12.12.12.md b/release-notes/12.12.12.md new file mode 100644 index 000000000..192f42d88 --- /dev/null +++ b/release-notes/12.12.12.md @@ -0,0 +1,11 @@ +# Release Notes + +### Features + +- To reduce the time to generate a backup using `ghe-backup`, administrators can choose to prune old backup snapshots after a new backup has been generate. For more information, see "[Scheduling backups & snapshot pruning](https://github.com/github/backup-utils/blob/master/docs/scheduling-backups.md)." +- On instances with large MySQL databases , administrators who wish to save storage space can use the new `--incremental` flag with `ghe-backup` and `ghe-restore`. For more information, see "[Incremental MySQL Backups and Restores](https://github.com/github/backup-utils/tree/master/docs/incremental-mysql-backups-and-restores.md)". + +### Changes + +- Removed the `git clone` path for setting up `backup-utils` from the [getting started instructions](https://github.com/github/backup-utils/blob/master/docs/getting-started.md). +- Added `bc` v1.07 or newer to the [requirements](https://github.com/github/backup-utils/blob/master/docs/requirements.md) for a backup host machine. \ No newline at end of file From 08fe226d5462d9147833111b2eebfe37b554a145 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 14 Sep 2023 10:12:55 -0400 Subject: [PATCH 2157/2421] release notes will be in the project --- .github/workflows/build-and-release.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index b3a989b50..acffa376d 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -7,10 +7,6 @@ on: description: 'Version - patch version of the release (e.g. x.y.z)' required: true type: string - release-notes: - description: 'Release Notes - string of markdown' - required: true - type: string draft: description: 'Draft - true if the release should be a draft' required: true From 439e87d4af70bcadc5ac19a0a14d4ae129bd5761 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 14 Sep 2023 10:29:24 -0400 Subject: [PATCH 2158/2421] associate release with empty commit so tags don't stack up on one commit --- .github/workflows/build-and-release.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index acffa376d..8d3afa195 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -60,7 +60,23 @@ jobs: release: needs: build runs-on: ubuntu-latest + outputs: + commit_sha: ${{ steps.release.outputs.commit_sha }} steps: + # checkout another repo and create an empty commit + # this is needed because the release action requires a tag + - name: Checkout + uses: actions/checkout@v2 + with: + repository: github/backup-utils + ref: master + - name: Create empty commit + run: | + git config user.name "release-controller" + git config user.email "ghes-releases-team@github.com" + git commit --allow-empty -m "${{ github.event.inputs.version }} release" + git push origin master + echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Checkout uses: actions/checkout@v2 - name: Download deb artifact From 573860d39c2ad54b09cadd0b20cab02f218bc225 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Thu, 14 Sep 2023 11:15:47 -0400 Subject: [PATCH 2159/2421] use the empty commit sha for the release --- .github/workflows/build-and-release.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 8d3afa195..81ba0d9e6 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -61,22 +61,21 @@ jobs: needs: build runs-on: ubuntu-latest outputs: - commit_sha: ${{ steps.release.outputs.commit_sha }} + commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} steps: - # checkout another repo and create an empty commit - # this is needed because the release action requires a tag - name: Checkout uses: actions/checkout@v2 with: repository: github/backup-utils ref: master - name: Create empty commit + id: empty_commit run: | git config user.name "release-controller" git config user.email "ghes-releases-team@github.com" git commit --allow-empty -m "${{ github.event.inputs.version }} release" git push origin master - echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Checkout uses: actions/checkout@v2 - name: Download deb artifact @@ -100,7 +99,7 @@ jobs: # this action will create a tag with this name on the provided commit tag: v${{ github.event.inputs.version }} # this can be a commit hash or branch name - commit: master + commit: ${{ steps.empty_commit.outputs.commit_sha }} bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} allowUpdates: true From c69ac4e35291a0317f6c76fe1ea87fecbc7e3ffd Mon Sep 17 00:00:00 2001 From: djdefi Date: Thu, 14 Sep 2023 13:23:39 -0700 Subject: [PATCH 2160/2421] Update rsync-docker-bump.yml Co-authored-by: Quinn Murphy --- .github/workflows/rsync-docker-bump.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index 6d90b7bbe..2cfe7782c 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -15,7 +15,7 @@ jobs: - name: Get latest rsync tag id: latest_tag - run: curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "name=latest_tag::{}" >> $GITHUB_OUTPUT + run: curl --silent "https://api.github.com/repos/WayneD/rsync/tags" | jq -r '.[].name' | grep -m1 -v pre | xargs -I {} echo "name=latest_tag::{}" >> "$GITHUB_OUTPUT" - name: Update Dockerfile with latest tag run: | From afa8e8dbee29b71788e241467bdf417459c79dab Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 14 Sep 2023 22:57:30 -0600 Subject: [PATCH 2161/2421] Triger new templated jobs --- .github/workflows/integration-tests.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 1a30dda3b..053f760bf 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -13,8 +13,8 @@ jobs: strategy: matrix: jankyJobName: - - enterprise2-binary-backup - - enterprise2-migration + - enterprise2-backup-utils-binary-backup + - enterprise2-backup-utils-migration steps: - uses: actions/checkout@v3 with: @@ -24,10 +24,9 @@ jobs: ref="${{ github.ref }}" merge_branch=${ref#"refs/heads/"} backup_utils_branch="${{ env.SOURCE_BRANCH }}" - #branch_name="${{ env.TARGET_BRANCH }}" - branch_name="janky-backup-utils-branch-test" + branch_name="${{ env.TARGET_BRANCH }}" curl -v -X POST \ -u "hubot:${{ secrets.API_AUTH_TOKEN }}" \ -H "Content-Type: application/json" \ - -d '{"buildable_name":"${{ matrix.jankyJobName }}","repo":"enterprise2","branch_name": "'"$branch_name"'","env_vars":{"JANKY_ENV_BACKUP_UTILS_BRANCH": "'"$backup_utils_branch"'" },"force":"true","room_id":"#builds"}' \ + -d '{"buildable_name":"${{ matrix.jankyJobName }}","repo":"${{ github.repository }}","branch_name": "'"$branch_name"'","env_vars":{"JANKY_ENV_BACKUP_UTILS_BRANCH": "'"$backup_utils_branch"'" },"force":"true","room_id":"#builds"}' \ "https://janky.githubapp.com/api/builds" From 307fe2fec0630ec5a0723737f1849ca8b9ba5c18 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 15 Sep 2023 11:07:28 -0400 Subject: [PATCH 2162/2421] use release controller app token --- .github/workflows/build-and-release.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 81ba0d9e6..dd0df9099 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -63,16 +63,21 @@ jobs: outputs: commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + # required + app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - name: Checkout uses: actions/checkout@v2 with: + token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils ref: master - name: Create empty commit id: empty_commit run: | - git config user.name "release-controller" - git config user.email "ghes-releases-team@github.com" git commit --allow-empty -m "${{ github.event.inputs.version }} release" git push origin master echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT @@ -89,6 +94,7 @@ jobs: - name: Create Release uses: ncipollo/release-action@v1 with: + token: ${{ steps.app-token.outputs.token }} repo: backup-utils name: | GitHub Enterprise Server Backup Utilities From e1a92a553a3d977bf297a5de8c246c81d3476848 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 15 Sep 2023 12:17:17 -0400 Subject: [PATCH 2163/2421] fix backup.config typo (#587) Fixing https://github.com/github/ghes/issues/7329 --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 688cc374b..d1ea977e2 100644 --- a/backup.config-example +++ b/backup.config-example @@ -26,7 +26,7 @@ GHE_NUM_SNAPSHOTS=10 # performed before the next full backup is created. # For example, if `GHE_INCREMENTAL_BACKUP_MAX` is set to 14, backup-utils will # run 1 full backup and then 13 incremental backups before performing another full backup on the next cycle. -#GHE_INCREMENTAL_BACKUP_MAX=14 +#GHE_INCREMENTAL_MAX_BACKUPS=14 # If GHE_SKIP_CHECKS is set to true (or if --skip-checks is used with ghe-backup) then ghe-host-check # disk space validation and software version checks on the backup-host will be disabled. From 6042e5151caaf410889d6b3f0bf3fee370eefd2a Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 15 Sep 2023 10:40:55 -0600 Subject: [PATCH 2164/2421] update workflow dispatch rules --- .github/workflows/integration-tests.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 053f760bf..895d6c692 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -1,6 +1,17 @@ name: Run Integration Tests -on: [pull_request, workflow_dispatch] +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + branches: ['master', 'enterprise-[0-9]*.[0-9]*-release', 'enterprise-[0-9]*.[0-9]*.[0-9]*-release'] + workflow_dispatch: + inputs: + target-branch: + description: 'Branch that would be merged into' + required: true + source-branch: + description: 'Branch that would be merged' + required: true # Get target and source branch from different variables depending on how it was triggered env: @@ -21,8 +32,6 @@ jobs: fetch-depth: 1 - name: Queue ${{ matrix.jankyJobName }} build run: | - ref="${{ github.ref }}" - merge_branch=${ref#"refs/heads/"} backup_utils_branch="${{ env.SOURCE_BRANCH }}" branch_name="${{ env.TARGET_BRANCH }}" curl -v -X POST \ From a10db47c0fcaa601be1a7361e20f292918f6c2e3 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 15 Sep 2023 12:35:24 -0600 Subject: [PATCH 2165/2421] Use proxy-janky-build actions --- .github/actions/proxy-janky-build/action.yml | 29 +++ .github/actions/proxy-janky-build/go.mod | 7 + .github/actions/proxy-janky-build/go.sum | 9 + .github/actions/proxy-janky-build/main.go | 177 +++++++++++++++++++ .github/workflows/integration-tests.yml | 15 +- 5 files changed, 229 insertions(+), 8 deletions(-) create mode 100644 .github/actions/proxy-janky-build/action.yml create mode 100644 .github/actions/proxy-janky-build/go.mod create mode 100644 .github/actions/proxy-janky-build/go.sum create mode 100644 .github/actions/proxy-janky-build/main.go diff --git a/.github/actions/proxy-janky-build/action.yml b/.github/actions/proxy-janky-build/action.yml new file mode 100644 index 000000000..fe36d27b4 --- /dev/null +++ b/.github/actions/proxy-janky-build/action.yml @@ -0,0 +1,29 @@ +name: 'Trigger a CI Job on Janky' +description: 'Action to trigger and poll a Janky CI job' +inputs: + janky-token: + description: 'Token for making request to Janky' + required: true + job-name: + description: 'The name of the job to run' + required: true + branch-name: + description: 'The name of the branch to use' + required: true + envVars: + description: 'Comma separated list of key value pairs to pass to Janky - ex: key1=value1,key2=value2,key3=value3' + required: false +runs: + using: 'composite' + steps: + - uses: actions/setup-go@a3d889c34c5d4e071b33595c5fe8edfcaaad8260 + with: + go-version: '1.21' + - run: | + go run main.go \ + -token ${{ inputs.janky-token }} \ + -job ${{ inputs.job-name }} \ + -branch ${{ inputs.branch-name }} \ + -envVars ${{ inputs.envVars }} + shell: bash + working-directory: .github/actions/proxy-janky-build diff --git a/.github/actions/proxy-janky-build/go.mod b/.github/actions/proxy-janky-build/go.mod new file mode 100644 index 000000000..b7560d7b9 --- /dev/null +++ b/.github/actions/proxy-janky-build/go.mod @@ -0,0 +1,7 @@ +module github.com/github/enterprise2/actions/proxy-janky-build + +go 1.21 + +require github.com/hashicorp/go-retryablehttp v0.7.2 + +require github.com/hashicorp/go-cleanhttp v0.5.2 // indirect diff --git a/.github/actions/proxy-janky-build/go.sum b/.github/actions/proxy-janky-build/go.sum new file mode 100644 index 000000000..5c59c1d2e --- /dev/null +++ b/.github/actions/proxy-janky-build/go.sum @@ -0,0 +1,9 @@ +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0= +github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= diff --git a/.github/actions/proxy-janky-build/main.go b/.github/actions/proxy-janky-build/main.go new file mode 100644 index 000000000..cfc120295 --- /dev/null +++ b/.github/actions/proxy-janky-build/main.go @@ -0,0 +1,177 @@ +package main + +import ( + "bytes" + "encoding/base64" + "encoding/json" + "flag" + "fmt" + "io" + "log" + "net/http" + "regexp" + "strings" + "time" + + "github.com/hashicorp/go-retryablehttp" +) + +// Define our Janky Response Structs +type JankyBuildStruct struct { + Result string + Url string +} +type JankyStatusStruct struct { + Id string + Green bool + Completed bool + StartedAt string + CompletedAt string + Sha string + BuildableName string +} + +const ( + pollWaitTime = 10 * time.Second + jankyPollTimeout = 5 * time.Hour + jankyHttpRetryMax = 5 + jankyUrl = "https://janky.githubapp.com" +) + +func main() { + // Parse command-line arguments + job := flag.String("job", "", "Name of the Janky job") + token := flag.String("token", "", "Name of the Janky token") + branch := flag.String("branch", "", "Name of the Git branch") + envVars := flag.String("envVars", "", "Comma separated list of key value pairs to pass to Janky - ex: key1=value1,key2=value2,key3=value3") + flag.Parse() + + // Validate command-line arguments + if *job == "" || *token == "" || *branch == "" { + log.Fatal("job, token and branch flags must be specified") + } + + // Set up the token + request payload + authToken := base64.StdEncoding.EncodeToString([]byte(":" + *token)) + type buildRequestObject struct { + BuildableName string `json:"buildable_name"` + BranchName string `json:"branch_name"` + EnvVars map[string]string `json:"env_vars"` + } + + requestBody := buildRequestObject{ + BuildableName: *job, + BranchName: *branch, + } + + // Parse the envVars flag into a map and add to the request payload + fmt.Println("Environment Variables:") + fmt.Println(*envVars) + if *envVars != "" { + envVarsMap := make(map[string]string) + for _, envVar := range strings.Split(*envVars, ",") { + envVarSplit := strings.Split(envVar, "=") + envVarsMap[envVarSplit[0]] = envVarSplit[1] + } + requestBody.EnvVars = envVarsMap + } + + payloadBytes, err := json.Marshal(requestBody) + if err != nil { + log.Fatal("Failed to marshal the JSON payload!\n" + err.Error()) + } + + // Send build request to Janky + buildRequest, err := http.NewRequest("POST", jankyUrl+"/api/builds", bytes.NewBuffer(payloadBytes)) + if err != nil { + log.Fatal("Failed to create build request!\n" + err.Error()) + } + buildRequest.Header.Set("Content-Type", "application/json") + buildRequest.Header.Set("Authorization", "Basic "+authToken) + retryClient := retryablehttp.NewClient() + retryClient.RetryMax = jankyHttpRetryMax + retryClient.Logger = nil // disable debug logging + client := retryClient.StandardClient() // uses *http.Client + resp, err := client.Do(buildRequest) + if err != nil { + log.Fatal("Failed to send build request!\n" + err.Error()) + } + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + if err != nil { + log.Fatal("Error reading build response!\n" + err.Error()) + } + + // Check if the build was triggered successfully + if resp.StatusCode == 404 { + log.Fatal("Failed to trigger build! Either " + *job + " is not the name of a Janky job or " + *branch + " is not a branch for the repository that job belongs to.") + } + if resp.StatusCode != 201 { + log.Fatal("Failed to trigger build! Got exception: " + string(body)) + } + + // Parse the build request response + var buildResponse JankyBuildStruct + json.Unmarshal(body, &buildResponse) + log.Println("Succesfully triggered janky!\n" + buildResponse.Result) + + // Parse the request response for the buildId + r, err := regexp.Compile("/[0-9]+/") + if err != nil { + log.Fatal("Failed to trigger build!\n" + err.Error()) + } + buildId := strings.Trim(r.FindString(buildResponse.Result), "/") + + // Setup our second HTTP client for reuse in during status polling + jankyStatusUrl := jankyUrl + "/api/" + buildId + "/status" + statusRequest, err := http.NewRequest("GET", jankyStatusUrl, nil) + if err != nil { + log.Fatal("Failed to create status request!\n" + err.Error()) + } + statusRequest.Header.Set("Content-Type", "application/json") + statusRequest.Header.Set("Authorization", "Basic "+authToken) + retryClient2 := retryablehttp.NewClient() + retryClient2.RetryMax = jankyHttpRetryMax + retryClient2.Logger = nil // disable debug logging + client2 := retryClient2.StandardClient() // uses *http.Client + + // Wait for a completed status from Janky or break the loop after a certain amount of time + timeout := time.NewTimer(jankyPollTimeout) + poll := time.NewTicker(pollWaitTime) + +jobLoop: + for { + select { + case <-timeout.C: + log.Fatal("Failed to poll for build status after " + jankyPollTimeout.String() + "hours") + case <-poll.C: + // Send build status request to Janky + statusResponse, err := client2.Do(statusRequest) + if err != nil { + log.Fatal("Failed to send status request!\n" + err.Error()) + } + defer statusResponse.Body.Close() + statusBody, err := io.ReadAll(statusResponse.Body) + if err != nil { + log.Fatal("Error reading status response!\n" + err.Error()) + } + + // Parse the status response for a green completed build + var jankyStatusResponse JankyStatusStruct + json.Unmarshal(statusBody, &jankyStatusResponse) + //fmt.Println("Janky Status Response:") + //fmt.Println(string(statusBody)) + if jankyStatusResponse.Completed && jankyStatusResponse.Green { + log.Println("Janky build Succeeded!") + break jobLoop + } + if jankyStatusResponse.Completed && !jankyStatusResponse.Green { + log.Fatal("Build failed, see Janky for more info: " + buildResponse.Url) + } + + // wait for a bit and try again + log.Println("Build still in progress, will poll for status again in [" + pollWaitTime.String() + "]") + continue + } + } +} diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 895d6c692..d97350957 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -31,11 +31,10 @@ jobs: with: fetch-depth: 1 - name: Queue ${{ matrix.jankyJobName }} build - run: | - backup_utils_branch="${{ env.SOURCE_BRANCH }}" - branch_name="${{ env.TARGET_BRANCH }}" - curl -v -X POST \ - -u "hubot:${{ secrets.API_AUTH_TOKEN }}" \ - -H "Content-Type: application/json" \ - -d '{"buildable_name":"${{ matrix.jankyJobName }}","repo":"${{ github.repository }}","branch_name": "'"$branch_name"'","env_vars":{"JANKY_ENV_BACKUP_UTILS_BRANCH": "'"$backup_utils_branch"'" },"force":"true","room_id":"#builds"}' \ - "https://janky.githubapp.com/api/builds" + uses: ./.github/actions/proxy-janky-build + id: proxy-janky-build + with: + janky-token: '${{ secrets.API_AUTH_TOKEN }}' + job-name: '${{ matrix.jankyJobName }}' + branch-name: '${{ env.TARGET_BRANCH }}' + envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }}" From 44b713ed91852e3b03d7598c25d66004ddacb898 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 15 Sep 2023 14:49:04 -0400 Subject: [PATCH 2166/2421] use token for tag creation --- .github/workflows/build-and-release.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index dd0df9099..f6194bb55 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -17,16 +17,22 @@ jobs: build: runs-on: ubuntu-latest steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + # required + app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - name: Checkout uses: actions/checkout@v2 + with: + token: ${{ steps.app-token.outputs.token }} - name: Install dependencies run: | sudo apt-get update -y sudo apt-get install -y moreutils debhelper help2man devscripts gzip - name: Create tag run: | - git config user.name "release-controller" - git config user.email "ghes-releases-team@github.com" git tag -a v${{ github.event.inputs.version }} \ -m "v${{ github.event.inputs.version }}" git push origin v${{ github.event.inputs.version }} @@ -50,7 +56,6 @@ jobs: - name: Package tarball run: | ./script/package-tarball - shell: bash - name: Upload tarball artifact uses: actions/upload-artifact@v3 with: From c9e22e96c4fbcb1db178f62b305d32c8c3d7cf7c Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 15 Sep 2023 12:50:34 -0600 Subject: [PATCH 2167/2421] Force build --- .github/actions/proxy-janky-build/action.yml | 4 ++++ .github/actions/proxy-janky-build/main.go | 3 +++ .github/workflows/integration-tests.yml | 1 + 3 files changed, 8 insertions(+) diff --git a/.github/actions/proxy-janky-build/action.yml b/.github/actions/proxy-janky-build/action.yml index fe36d27b4..988c4a289 100644 --- a/.github/actions/proxy-janky-build/action.yml +++ b/.github/actions/proxy-janky-build/action.yml @@ -10,6 +10,9 @@ inputs: branch-name: description: 'The name of the branch to use' required: true + force: + description: 'Force the job to run even if it is already passed' + required: false envVars: description: 'Comma separated list of key value pairs to pass to Janky - ex: key1=value1,key2=value2,key3=value3' required: false @@ -24,6 +27,7 @@ runs: -token ${{ inputs.janky-token }} \ -job ${{ inputs.job-name }} \ -branch ${{ inputs.branch-name }} \ + -force ${{ inputs.force }} \ -envVars ${{ inputs.envVars }} shell: bash working-directory: .github/actions/proxy-janky-build diff --git a/.github/actions/proxy-janky-build/main.go b/.github/actions/proxy-janky-build/main.go index cfc120295..4146be416 100644 --- a/.github/actions/proxy-janky-build/main.go +++ b/.github/actions/proxy-janky-build/main.go @@ -43,6 +43,7 @@ func main() { job := flag.String("job", "", "Name of the Janky job") token := flag.String("token", "", "Name of the Janky token") branch := flag.String("branch", "", "Name of the Git branch") + force := flag.Bool("force", false, "Force a build even if one is already passed") envVars := flag.String("envVars", "", "Comma separated list of key value pairs to pass to Janky - ex: key1=value1,key2=value2,key3=value3") flag.Parse() @@ -56,12 +57,14 @@ func main() { type buildRequestObject struct { BuildableName string `json:"buildable_name"` BranchName string `json:"branch_name"` + Force bool `json:"force"` EnvVars map[string]string `json:"env_vars"` } requestBody := buildRequestObject{ BuildableName: *job, BranchName: *branch, + Force: *force, } // Parse the envVars flag into a map and add to the request payload diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index d97350957..14caa2726 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -37,4 +37,5 @@ jobs: janky-token: '${{ secrets.API_AUTH_TOKEN }}' job-name: '${{ matrix.jankyJobName }}' branch-name: '${{ env.TARGET_BRANCH }}' + force : 'true' envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }}" From 2af815acd9b132cb58cde032f615f81b3e16b6df Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 15 Sep 2023 12:55:10 -0600 Subject: [PATCH 2168/2421] Make force a string --- .github/actions/proxy-janky-build/main.go | 4 ++-- .github/workflows/integration-tests.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/proxy-janky-build/main.go b/.github/actions/proxy-janky-build/main.go index 4146be416..e05346cd4 100644 --- a/.github/actions/proxy-janky-build/main.go +++ b/.github/actions/proxy-janky-build/main.go @@ -43,7 +43,7 @@ func main() { job := flag.String("job", "", "Name of the Janky job") token := flag.String("token", "", "Name of the Janky token") branch := flag.String("branch", "", "Name of the Git branch") - force := flag.Bool("force", false, "Force a build even if one is already passed") + force := flag.String("force", "false", "Force a build even if one is already passed") envVars := flag.String("envVars", "", "Comma separated list of key value pairs to pass to Janky - ex: key1=value1,key2=value2,key3=value3") flag.Parse() @@ -57,7 +57,7 @@ func main() { type buildRequestObject struct { BuildableName string `json:"buildable_name"` BranchName string `json:"branch_name"` - Force bool `json:"force"` + Force string `json:"force"` EnvVars map[string]string `json:"env_vars"` } diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 14caa2726..804c6d5c5 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -37,5 +37,5 @@ jobs: janky-token: '${{ secrets.API_AUTH_TOKEN }}' job-name: '${{ matrix.jankyJobName }}' branch-name: '${{ env.TARGET_BRANCH }}' - force : 'true' + force : "true" envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }}" From 7094bcaa44a6fd9c36d9a2b49c2a7db1af0c09f0 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 15 Sep 2023 13:51:02 -0600 Subject: [PATCH 2169/2421] disable lint error --- .github/actions/proxy-janky-build/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/proxy-janky-build/main.go b/.github/actions/proxy-janky-build/main.go index e05346cd4..e7afcd917 100644 --- a/.github/actions/proxy-janky-build/main.go +++ b/.github/actions/proxy-janky-build/main.go @@ -91,7 +91,7 @@ func main() { } buildRequest.Header.Set("Content-Type", "application/json") buildRequest.Header.Set("Authorization", "Basic "+authToken) - retryClient := retryablehttp.NewClient() + retryClient := retryablehttp.NewClient() //nolint:all retryClient.RetryMax = jankyHttpRetryMax retryClient.Logger = nil // disable debug logging client := retryClient.StandardClient() // uses *http.Client From 2e7142240322f42bf135e90542dc346e0b2943c1 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Fri, 15 Sep 2023 14:30:31 -0600 Subject: [PATCH 2170/2421] Update main.go --- .github/actions/proxy-janky-build/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/proxy-janky-build/main.go b/.github/actions/proxy-janky-build/main.go index e7afcd917..e0342f121 100644 --- a/.github/actions/proxy-janky-build/main.go +++ b/.github/actions/proxy-janky-build/main.go @@ -133,7 +133,7 @@ func main() { } statusRequest.Header.Set("Content-Type", "application/json") statusRequest.Header.Set("Authorization", "Basic "+authToken) - retryClient2 := retryablehttp.NewClient() + retryClient2 := retryablehttp.NewClient() //nolint:all retryClient2.RetryMax = jankyHttpRetryMax retryClient2.Logger = nil // disable debug logging client2 := retryClient2.StandardClient() // uses *http.Client From 995bd7a06082c4390fe49d250ef1a2c57866503a Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 18 Sep 2023 11:01:34 -0400 Subject: [PATCH 2171/2421] set git config --- .github/workflows/build-and-release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index f6194bb55..4943834a8 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -33,6 +33,8 @@ jobs: sudo apt-get install -y moreutils debhelper help2man devscripts gzip - name: Create tag run: | + git config user.name "release-controller" + git config user.email "ghes-releases-team@github.com" git tag -a v${{ github.event.inputs.version }} \ -m "v${{ github.event.inputs.version }}" git push origin v${{ github.event.inputs.version }} @@ -83,6 +85,8 @@ jobs: - name: Create empty commit id: empty_commit run: | + git config user.name "release-controller" + git config user.email "ghes-releases-team@github.com" git commit --allow-empty -m "${{ github.event.inputs.version }} release" git push origin master echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT From 5eeb9832e637bb9344fc47bc935408593b65f2b7 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 19 Sep 2023 12:52:38 -0400 Subject: [PATCH 2172/2421] use patch release branches in private --- .github/workflows/build-and-release.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 4943834a8..b82a40211 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -31,13 +31,12 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag + - name: Create patch release branch from current sha run: | git config user.name "release-controller" git config user.email "ghes-releases-team@github.com" - git tag -a v${{ github.event.inputs.version }} \ - -m "v${{ github.event.inputs.version }}" - git push origin v${{ github.event.inputs.version }} + git branch "enterprise-${{ github.event.inputs.version }}-release" + git push origin "enterprise-${{ github.event.inputs.version }}-release" - name: Package deb run: | ./script/package-deb From 71d6136b7ae2c56034aac8cf8ce1624670e71001 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 19 Sep 2023 13:41:14 -0400 Subject: [PATCH 2173/2421] implement .releaseignore --- .releaseignore | 2 ++ script/package-deb | 8 ++++++++ script/package-tarball | 10 ++++++++++ 3 files changed, 20 insertions(+) create mode 100644 .releaseignore diff --git a/.releaseignore b/.releaseignore new file mode 100644 index 000000000..bb2f6b31c --- /dev/null +++ b/.releaseignore @@ -0,0 +1,2 @@ +ownership.yaml +.github \ No newline at end of file diff --git a/script/package-deb b/script/package-deb index dda90cbe3..8e771f1e4 100755 --- a/script/package-deb +++ b/script/package-deb @@ -22,6 +22,14 @@ mkdir -p dist/debuild distdir="$(pwd)/dist/debuild/$PKG_NAME" git clone -q . "$distdir" cd "$distdir" + +echo "Removing files listed in .releaseignore ..." +while IFS= read -r line; do + rm -rf "$line" +done < .releaseignore + +echo "Removing .releaseignore ..." +rm -f .releaseignore git checkout -q "$PKG_HEAD" debuild -uc -us 1>&2 diff --git a/script/package-tarball b/script/package-tarball index be653b77a..a2c09bd37 100755 --- a/script/package-tarball +++ b/script/package-tarball @@ -13,6 +13,16 @@ PKG_BASE="github-backup-utils" PKG_VERS="$(git describe --tags)" PKG_NAME="${PKG_BASE}-${PKG_VERS}" +# Remove all files or directories listed in .releaseignore +echo "Removing files listed in .releaseignore ..." +while IFS= read -r line; do + rm -rf "$line" +done < .releaseignore + +# Remove the .releaseignore file itself +echo "Removing .releaseignore ..." +rm -f .releaseignore + # Run git-archive to generate tarball echo "Creating ${PKG_NAME}.tar.gz ..." mkdir -p dist From a3e8ae9be631a63db7aa6383ac26f350ce1b3b58 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 19 Sep 2023 20:21:54 +0000 Subject: [PATCH 2174/2421] test against test branch --- .github/workflows/build-and-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index b82a40211..91f59aab2 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -86,8 +86,9 @@ jobs: run: | git config user.name "release-controller" git config user.email "ghes-releases-team@github.com" + git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin master + git push origin tims-test-branch echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Checkout uses: actions/checkout@v2 From ec2ef62f51bc33b76d713112b2f0813c5ae887b9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 19 Sep 2023 16:43:17 -0400 Subject: [PATCH 2175/2421] fetch tags --- script/package-deb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/package-deb b/script/package-deb index 8e771f1e4..15a698e9c 100755 --- a/script/package-deb +++ b/script/package-deb @@ -8,6 +8,9 @@ set -e # Change into project root cd "$(dirname "$0")"/.. +# Fetch tags from remote repository +git fetch --tags + # Basic package name and version. PKG_BASE="github-backup-utils" PKG_VERS="$(git describe --tags)" From 7de9682d6b152a7730df75f9a05953c7182f6f39 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 19 Sep 2023 16:43:41 -0400 Subject: [PATCH 2176/2421] same for tar --- script/package-tarball | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/package-tarball b/script/package-tarball index a2c09bd37..bf1510e8f 100755 --- a/script/package-tarball +++ b/script/package-tarball @@ -8,6 +8,9 @@ set -e # Change into project root cd "$(dirname "$0")"/.. +# Fetch tags from remote repository +git fetch --tags + # Basic package name and version. PKG_BASE="github-backup-utils" PKG_VERS="$(git describe --tags)" From 610a0d32b58016d253b00cb97037990c119dd326 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 19 Sep 2023 16:50:19 -0400 Subject: [PATCH 2177/2421] need vx.y.x tag for build scripts --- .github/workflows/build-and-release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 91f59aab2..c3fc67c57 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -37,6 +37,11 @@ jobs: git config user.email "ghes-releases-team@github.com" git branch "enterprise-${{ github.event.inputs.version }}-release" git push origin "enterprise-${{ github.event.inputs.version }}-release" + # create v#{version} tag on current sha + - name: Create tag + run: | + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" - name: Package deb run: | ./script/package-deb From bd23ecdc80d3dccdbd12e7982c5845d85386ff78 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 19 Sep 2023 21:33:42 +0000 Subject: [PATCH 2178/2421] help --- .github/workflows/build-and-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c3fc67c57..487f808f2 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -91,6 +91,8 @@ jobs: run: | git config user.name "release-controller" git config user.email "ghes-releases-team@github.com" + # tims-test-branch already exists, so fetch it + git fetch origin tims-test-branch git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" git push origin tims-test-branch From 99db4a899a2b92698f12854ab272436d8bfde2eb Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Wed, 20 Sep 2023 15:08:24 +0200 Subject: [PATCH 2179/2421] remove dead code (#586) --- Makefile | 2 +- script/cibuild | 65 ------------------- script/release | 166 ++++++++++++++++++++++++------------------------- script/test | 28 +++++++++ 4 files changed, 112 insertions(+), 149 deletions(-) delete mode 100755 script/cibuild create mode 100755 script/test diff --git a/Makefile b/Makefile index 191b90561..c8eaa0ff1 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SHELL = /bin/sh test: info @echo Running tests - @script/cibuild --no-package + @script/test info: @echo This is github/backup-utils diff --git a/script/cibuild b/script/cibuild deleted file mode 100755 index 22f7ffd08..000000000 --- a/script/cibuild +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash -# Usage: script/cibuild [--no-package] -set -e - -ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" -TMPDIR="$ROOTDIR/test/tmp" - -# Remove possible remnants of previous test runs -rm -rf "${TMPDIR:?}/*" - -print_test_results() { - if [ -n "$GITHUB_STEP_SUMMARY" ]; then - echo -e "### Test results\n" >> "$GITHUB_STEP_SUMMARY" - echo "| Test suite | Result | Successful | Failed | Skipped | Duration |" >> "$GITHUB_STEP_SUMMARY" - echo "|---|---|--:|--:|--:|--:|" >> "$GITHUB_STEP_SUMMARY" - sort -V "$TMPDIR/results" >> "$GITHUB_STEP_SUMMARY" - fi -} - -# Enable verbose logging of ssh commands -export GHE_VERBOSE_SSH=true - -if ! find test -name "test-*.sh" -print0 | xargs -0 -n 1 /bin/bash; then - print_test_results - exit 1 -fi - -print_test_results - -# Bail out when --no-package given -[ "$1" = "--no-package" ] && exit 0 - -# files we'll md5sum at the end -pkg_files= - -# Build the tarball -echo "Building tar.gz package ..." -if script/package-tarball 1>$TMPDIR/package-tarball.txt 2>&1; then - pkg_files=$(grep '^Package ' < $TMPDIR/package-tarball.txt | cut -f 2 -d ' ') -else - echo "Packaging tar.gz failed:" - cat $TMPDIR/package-tarball.txt | sed 's/^/ /' 1>&2 - exit 1 -fi - -# Skip deb packaging if debuild not installed -if ! type debuild 1>/dev/null 2>&1; then - echo "debuild not installed, skipping deb packaging ..." - exit 0 -fi - -# Build the deb related packages -echo "Building deb package ..." -if DEB_BUILD_OPTIONS=nocheck script/package-deb 1>$TMPDIR/package-deb-out.txt 2>$TMPDIR/package-deb-err.txt; then - pkg_files="$pkg_files $(cat $TMPDIR/package-deb-out.txt)" -else - echo "Package build failed:" - cat $TMPDIR/package-deb-out.txt $TMPDIR/package-deb-err.txt >&2 - echo >&2 - cat dist/debuild/github-backup-utils*.build >&2 - exit 1 -fi - -# Generate md5sums -md5sum $pkg_files diff --git a/script/release b/script/release index 891cd9f60..9629cacff 100755 --- a/script/release +++ b/script/release @@ -19,25 +19,25 @@ #/ release page and the changelog. #/ * If this is a X.Y.0 release, a minimum supported version needs to be supplied too. #/ -require 'json' -require 'net/http' -require 'time' -require 'erb' -require 'English' +require "json" +require "net/http" +require "time" +require "erb" +require "English" -API_HOST = ENV['GH_HOST'] || 'api.github.com' +API_HOST = ENV["GH_HOST"] || "api.github.com" API_PORT = 443 -GH_REPO = ENV['GH_REPO'] || 'backup-utils' -GH_OWNER = ENV['GH_OWNER'] || 'github' -GH_AUTHOR = ENV['GH_AUTHOR'] -DEB_PKG_NAME = 'github-backup-utils' -GH_BASE_BRANCH = ENV['GH_BASE_BRANCH'] || 'master' # TODO: should we even allow a default or require all params get set explicitly? +GH_REPO = ENV["GH_REPO"] || "backup-utils" +GH_OWNER = ENV["GH_OWNER"] || "github" +GH_AUTHOR = ENV["GH_AUTHOR"] +DEB_PKG_NAME = "github-backup-utils" +GH_BASE_BRANCH = ENV["GH_BASE_BRANCH"] || "master" # TODO: should we even allow a default or require all params get set explicitly? GH_STABLE_BRANCH = "" # If PUBLISH is false, we leave the release in a draft state to be manually published later through the UI -PUBLISH = ENV['PUBLISH'] == 'true' || false +PUBLISH = ENV["PUBLISH"] == "true" || false -CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium +CHANGELOG_TMPL = "" '<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium <%- changes.each do |ch| -%> * <%= ch.strip.chomp %> @@ -45,7 +45,7 @@ CHANGELOG_TMPL = '''<%= package_name %> (<%= package_version %>) UNRELEASED; urg -- <%= GH_AUTHOR %> <%= Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S %z") %> -''' +' "" # Override Kernel.warn def warn(msg) @@ -54,50 +54,50 @@ end def client(host = API_HOST, port = API_PORT) @http ||= begin - c = Net::HTTP.new(host, port) - c.use_ssl = true - c - end + c = Net::HTTP.new(host, port) + c.use_ssl = true + c + end end def get(path) req = Net::HTTP::Get.new(path) - req['Authorization'] = "token #{release_token}" + req["Authorization"] = "token #{release_token}" client.request(req) end def post(path, body) req = Net::HTTP::Post.new(path) - req['Authorization'] = "token #{release_token}" + req["Authorization"] = "token #{release_token}" req.body = body client.request(req) end def post_file(path, body) req = Net::HTTP::Post.new(path) - req['Authorization'] = "token #{release_token}" - req['Content-Type'] = path.match?(/.*\.tar\.gz$/) ? 'application/tar+gzip' : 'application/vnd.debian.binary-package' + req["Authorization"] = "token #{release_token}" + req["Content-Type"] = path.match?(/.*\.tar\.gz$/) ? "application/tar+gzip" : "application/vnd.debian.binary-package" req.body = body client.request(req) end def put(path, body) req = Net::HTTP::Put.new(path) - req['Authorization'] = "token #{release_token}" + req["Authorization"] = "token #{release_token}" req.body = body client.request(req) end def patch(path, body) req = Net::HTTP::Patch.new(path) - req['Authorization'] = "token #{release_token}" + req["Authorization"] = "token #{release_token}" req.body = body client.request(req) end def release_token - token = ENV['GH_RELEASE_TOKEN'] - raise 'GH_RELEASE_TOKEN environment variable not set' if token.nil? + token = ENV["GH_RELEASE_TOKEN"] + raise "GH_RELEASE_TOKEN environment variable not set" if token.nil? token end @@ -106,7 +106,7 @@ end def tag(name, sha) body = { "ref": "refs/tags/#{name}", - "sha": sha + "sha": sha, }.to_json res = post("/repos/#{GH_OWNER}/#{GH_REPO}/git/refs", body) @@ -114,7 +114,7 @@ def tag(name, sha) end def bug_or_feature?(issue_hash) - return true if issue_hash['labels'].find { |label| ['bug', 'feature', 'enhancement'].include?(label['name']) } + return true if issue_hash["labels"].find { |label| ["bug", "feature", "enhancement"].include?(label["name"]) } false end @@ -131,7 +131,7 @@ def beautify_changes(changes) next unless chg =~ /#(\d+)/ begin issue = issue_from Regexp.last_match(1) - out << "#{issue['title']} ##{Regexp.last_match(1)}" if bug_or_feature?(issue) + out << "#{issue["title"]} ##{Regexp.last_match(1)}" if bug_or_feature?(issue) rescue => e warn "Warning: #{e.message}" end @@ -143,18 +143,18 @@ end def changelog puts "building changelog by comparing origin/#{GH_STABLE_BRANCH}...origin/#{GH_BASE_BRANCH}" changes = `git log --pretty=oneline origin/#{GH_STABLE_BRANCH}...origin/#{GH_BASE_BRANCH} --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) - raise 'Building the changelog failed' if $CHILD_STATUS != 0 + raise "Building the changelog failed" if $CHILD_STATUS != 0 changes end def build_changelog(changes, package_name, package_version) - ERB.new(CHANGELOG_TMPL, nil, '-').result(binding) + ERB.new(CHANGELOG_TMPL, nil, "-").result(binding) end -def update_changelog(changes, name, version, path = 'debian/changelog') - raise 'debian/changelog not found' unless File.exist?(path) - File.open("#{path}.new", 'w') do |f| +def update_changelog(changes, name, version, path = "debian/changelog") + raise "debian/changelog not found" unless File.exist?(path) + File.open("#{path}.new", "w") do |f| f.puts build_changelog changes, name, version f.puts(File.read(path)) end @@ -168,7 +168,7 @@ def create_release(tag_name, branch, rel_name, rel_body, draft = true) 'name': rel_name, 'body': rel_body, 'draft': draft, - 'prerelease': false + 'prerelease': false, }.to_json res = post("/repos/#{GH_OWNER}/#{GH_REPO}/releases", body) @@ -179,7 +179,7 @@ end def publish_release(release_id) body = { - 'draft': false + 'draft': false, }.to_json res = patch("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}", body) @@ -188,33 +188,33 @@ end def list_releases res = get("/repos/#{GH_OWNER}/#{GH_REPO}/releases") - raise 'Failed to retrieve releases' unless res.is_a? Net::HTTPSuccess + raise "Failed to retrieve releases" unless res.is_a? Net::HTTPSuccess JSON.parse(res.body) end def release_available?(tag_name) - return true if list_releases.find { |r| r['tag_name'] == tag_name } + return true if list_releases.find { |r| r["tag_name"] == tag_name } false end -def bump_version(new_version, min_version = nil, path = 'share/github-backup-utils/version') +def bump_version(new_version, min_version = nil, path = "share/github-backup-utils/version") current_version = Gem::Version.new(File.read(path).strip.chomp) if !@skip_version_bump_check && (Gem::Version.new(new_version) < current_version) raise "New version should be newer than #{current_version}" end - File.open("#{path}.new", 'w') { |f| f.puts new_version } + File.open("#{path}.new", "w") { |f| f.puts new_version } File.rename("#{path}.new", path) unless min_version.nil? - content = File.read('bin/ghe-host-check') + content = File.read("bin/ghe-host-check") new_content = content.gsub(/supported_minimum_version="[0-9]\.[0-9]+\.0"/, "supported_minimum_version=\"#{min_version}\"") - File.open('bin/ghe-host-check', 'w') {|file| file.puts new_content } + File.open("bin/ghe-host-check", "w") { |file| file.puts new_content } - content = File.read('test/testlib.sh') - new_content = content.gsub(/GHE_TEST_REMOTE_VERSION:=[0-9]\.[0-9]+\.0/,"GHE_TEST_REMOTE_VERSION:=#{new_version}") - File.open('test/testlib.sh', 'w') {|file| file.puts new_content } + content = File.read("test/testlib.sh") + new_content = content.gsub(/GHE_TEST_REMOTE_VERSION:=[0-9]\.[0-9]+\.0/, "GHE_TEST_REMOTE_VERSION:=#{new_version}") + File.open("test/testlib.sh", "w") { |file| file.puts new_content } end end @@ -223,7 +223,7 @@ def push_release_branch(version) raise "Creating release branch failed:\n\n#{out}" end - unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version bin/ghe-host-check test/testlib.sh script/cibuild`) + unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version bin/ghe-host-check test/testlib.sh script/test`) raise "Error committing changelog and version:\n\n#{out}" end @@ -247,7 +247,7 @@ def create_release_pr(version, release_body) 'title': "Bump version: #{version}", 'body': release_body, 'head': "release-#{version}", - 'base': GH_BASE_BRANCH + 'base': GH_BASE_BRANCH, }.to_json res = post("/repos/#{GH_OWNER}/#{GH_REPO}/pulls", body) raise "Creating release PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess @@ -260,7 +260,7 @@ def merge_pr(number, sha, version) 'commit_title': "Merge pull request ##{number} from github/release-#{version}", 'commit_message': "Bump version: #{version}", 'sha': sha, - 'merge_method': 'merge' + 'merge_method': "merge", }.to_json pr_mergeable? number res = put("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}/merge", body) @@ -276,19 +276,19 @@ def pr_mergeable?(number) begin retries ||= 5 res = get("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}") - raise RetryError if JSON.parse(res.body)['mergeable'].nil? - mergeable = JSON.parse(res.body)['mergeable'] + raise RetryError if JSON.parse(res.body)["mergeable"].nil? + mergeable = JSON.parse(res.body)["mergeable"] rescue RetryError sleep 1 retry unless (retries -= 1).zero? - raise 'PR is unmergable.' + raise "PR is unmergable." end mergeable || false end def can_auth? - !ENV['GH_RELEASE_TOKEN'].nil? + !ENV["GH_RELEASE_TOKEN"].nil? end def repo_exists? @@ -297,7 +297,7 @@ def repo_exists? end def can_build_deb? - system('which debuild > /dev/null 2>&1') + system("which debuild > /dev/null 2>&1") end def package_tarball @@ -316,7 +316,7 @@ end def attach_assets_to_release(upload_url, release_id, files) @http = nil - client(URI(upload_url.gsub(/{.*}/, '')).host) + client(URI(upload_url.gsub(/{.*}/, "")).host) begin files.each do |file| raw_file = File.open(file).read @@ -373,22 +373,22 @@ if $PROGRAM_NAME == __FILE__ args = ARGV.dup dry_run = false skip_version_bump_check = false - if args.include?('--dry-run') + if args.include?("--dry-run") dry_run = true - args.delete '--dry-run' + args.delete "--dry-run" end - if args.include?('--no-warn') + if args.include?("--no-warn") @no_warn = true - args.delete '--no-warn' + args.delete "--no-warn" end - if args.include?('--skip-version-bump-check') + if args.include?("--skip-version-bump-check") @skip_version_bump_check = true - args.delete '--skip-version-bump-check' + args.delete "--skip-version-bump-check" end - raise 'Usage: release [--dry-run] [--skip-version-bump-check] [min_version]' if args.empty? + raise "Usage: release [--dry-run] [--skip-version-bump-check] [min_version]" if args.empty? begin version = Gem::Version.new(args[0]) @@ -401,7 +401,7 @@ if $PROGRAM_NAME == __FILE__ raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" unless repo_exists? - raise 'GH_AUTHOR environment variable is not set' if GH_AUTHOR.nil? + raise "GH_AUTHOR environment variable is not set" if GH_AUTHOR.nil? release_changes = [] release_changes = beautify_changes changelog if can_auth? @@ -418,11 +418,11 @@ if $PROGRAM_NAME == __FILE__ puts "Owner: #{GH_OWNER}" puts "Repo: #{GH_REPO}" puts "Author: #{GH_AUTHOR}" - puts "Token: #{ENV['GH_RELEASE_TOKEN'] && 'set' || 'unset'}" + puts "Token: #{ENV["GH_RELEASE_TOKEN"] && "set" || "unset"}" puts "Base branch: #{GH_BASE_BRANCH}" - puts 'Changelog:' + puts "Changelog:" if release_changes.empty? - puts ' => No new bug fixes, enhancements or features.' + puts " => No new bug fixes, enhancements or features." else release_changes.each { |c| puts " * #{c}" } end @@ -442,12 +442,12 @@ if $PROGRAM_NAME == __FILE__ branches = `git branch --all | grep release-#{version}$` unless branches.empty? out = "Release branch release-#{version} already exists. " - out += 'Branches found:' + out += "Branches found:" branches.each_line { |l| out += "\n* #{l.strip.chomp}" } raise out end - puts 'Updating changelog...' + puts "Updating changelog..." update_changelog release_changes, DEB_PKG_NAME, version release_body = "Includes general improvements & bug fixes" release_body += " and support for GitHub Enterprise Server v#{version}" unless min_version.nil? @@ -455,40 +455,40 @@ if $PROGRAM_NAME == __FILE__ release_body += "\n* #{c}" end - puts 'Pushing release branch and creating release PR...' + puts "Pushing release branch and creating release PR..." push_release_branch version res = create_release_pr(version, "#{release_body}\n\n/cc @github/backup-utils") - puts 'Merging release PR...' - res = merge_pr res['number'], res['head']['sha'], version + puts "Merging release PR..." + res = merge_pr res["number"], res["head"]["sha"], version - puts 'Tagging and publishing release...' - tag "v#{version}", res['sha'] + puts "Tagging and publishing release..." + tag "v#{version}", res["sha"] - puts 'Creating release...' + puts "Creating release..." release_title = "GitHub Enterprise Server Backup Utilities v#{version}" res = create_release "v#{version}", GH_BASE_BRANCH, release_title, release_body, true # Tidy up before building tarball and deb pkg clean_up version - puts 'Building release tarball...' + puts "Building release tarball..." package_tarball - puts 'Building Debian pkg...' + puts "Building Debian pkg..." package_deb - puts 'Attaching Debian pkg and tarball to release...' - base_dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) - attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] - attach_assets_to_release res['upload_url'], res['id'], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_all.deb"] + puts "Attaching Debian pkg and tarball to release..." + base_dir = File.expand_path(File.join(File.dirname(__FILE__), "..")) + attach_assets_to_release res["upload_url"], res["id"], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] + attach_assets_to_release res["upload_url"], res["id"], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_all.deb"] if PUBLISH - puts 'Publishing release...' - publish_release res['id'] + puts "Publishing release..." + publish_release res["id"] end - puts 'Cleaning up...' + puts "Cleaning up..." clean_up version puts "Updating #{GH_STABLE_BRANCH} branch..." @@ -498,7 +498,7 @@ if $PROGRAM_NAME == __FILE__ puts 'Release left in a "Draft" state. Go to the https://github.com/github/backup-utils/releases and publish when ready.' end - puts 'Released!' + puts "Released!" rescue RuntimeError => e $stderr.puts "Error: #{e}" exit 1 diff --git a/script/test b/script/test new file mode 100755 index 000000000..d30bfa8df --- /dev/null +++ b/script/test @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Usage: script/test +set -e + +ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" +TMPDIR="$ROOTDIR/test/tmp" + +# Remove possible remnants of previous test runs +rm -rf "${TMPDIR:?}/*" + +print_test_results() { + if [ -n "$GITHUB_STEP_SUMMARY" ]; then + echo -e "### Test results\n" >> "$GITHUB_STEP_SUMMARY" + echo "| Test suite | Result | Successful | Failed | Skipped | Duration |" >> "$GITHUB_STEP_SUMMARY" + echo "|---|---|--:|--:|--:|--:|" >> "$GITHUB_STEP_SUMMARY" + sort -V "$TMPDIR/results" >> "$GITHUB_STEP_SUMMARY" + fi +} + +# Enable verbose logging of ssh commands +export GHE_VERBOSE_SSH=true + +if ! find test -name "test-*.sh" -print0 | sort -z |xargs -0 -n 1 /bin/bash; then + print_test_results + exit 1 +fi + +print_test_results From 42cc0cb5ff431b83d9d833f1cfdfdb609e640b27 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Wed, 20 Sep 2023 15:50:17 +0200 Subject: [PATCH 2180/2421] removing wrong error output (#591) * removing wrong error output * fix host-check output * refactor echo --------- Co-authored-by: Chuck Pathanjali --- bin/ghe-host-check | 30 ++++++++++----------- share/github-backup-utils/ghe-backup-config | 5 ++-- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 9e8d6466b..adb3b0ccb 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -151,7 +151,7 @@ if [ -z "$supported" ]; then fi if [[ "$CALLING_SCRIPT" == "ghe-backup" && "$GHE_SKIP_CHECKS" != "true" ]]; then - cat << SKIP_MSG 1>&2 + cat << SKIP_MSG **You can disable the following storage & version checks by running ghe-backup with option "--skip-checks" OR updating GHE_SKIP_CHECKS to 'true' in your backup.config file. @@ -176,10 +176,10 @@ SKIP_MSG fi #Display dir requirements for repositories and mysql - echo "" 1>&2 - echo "Checking host for sufficient space for a backup..." 1>&2 + echo -e "\n" + echo "Checking host for sufficient space for a backup..." available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') - echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." 1>&2 + echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." repos_disk_size=$(transfer_size repositories /tmp) pages_disk_size=$(transfer_size pages /tmp) @@ -192,10 +192,10 @@ SKIP_MSG min_disk_req=$((repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size)) recommended_disk_req=$((min_disk_req * 5)) - echo " - Available space: $((available_space / (1024 ** 2))) MB" 1>&2 - echo " - Min Disk required for this backup is at least $min_disk_req MB" 1>&2 - echo " - Recommended Disk requirement is $recommended_disk_req MB" 1>&2 - echo "" 1>&2 + echo " - Available space: $((available_space / (1024 ** 2))) MB" + echo " - Min Disk required for this backup is at least $min_disk_req MB" + echo " - Recommended Disk requirement is $recommended_disk_req MB" + echo -e "\n" printf '### Estimated Data Transfer Sizes @@ -208,7 +208,7 @@ SKIP_MSG - actions: %d MB - mssql: %d MB \n' \ - "$repos_disk_size" "$pages_disk_size" "$es_disk_size" "$stor_disk_size" "$minio_disk_size" "$mysql_disk_size" "$actions_disk_size" "$mssql_disk_size" 1>&2 + "$repos_disk_size" "$pages_disk_size" "$es_disk_size" "$stor_disk_size" "$minio_disk_size" "$mysql_disk_size" "$actions_disk_size" "$mssql_disk_size" if [[ $((available_space / (1024 * 1024))) -lt $min_disk_req ]]; then echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2 @@ -231,7 +231,7 @@ SKIP_MSG exit 1 fi - echo "### Software versions" 1>&2 + echo "### Software versions" rsync_version=$(rsync --version | grep 'version' | awk '{print $3}' | tr -cd '[:digit:].\n') if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 @@ -241,9 +241,9 @@ SKIP_MSG printf "\n **WARNING:** rsync version %s on backup host is less than 3.2.5, which could result in performance degradation. For more details, please read documentation at https://gh.io/april-2023-update-of-rsync-requirements You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.config file.\n\n" \ - "$rsync_version" 1>&2 + "$rsync_version" fi - echo " - rsync ${rsync_version} >= required ($min_rsync)" 1>&2 + echo " - rsync ${rsync_version} >= required ($min_rsync)" ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1 | tr -cd '[:digit:].\n') if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then @@ -251,7 +251,7 @@ SKIP_MSG echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 exit 1 else - echo " - openSSH ${ssh_version} >= required ($min_openssh)" 1>&2 + echo " - openSSH ${ssh_version} >= required ($min_openssh)" fi jq_version=$(jq --version |awk -F\- '{print $2}' | tr -cd '[:digit:].\n') @@ -260,8 +260,8 @@ SKIP_MSG echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 exit 1 else - echo " - jq ${jq_version} >= required ($min_jq)" 1>&2 + echo " - jq ${jq_version} >= required ($min_jq)" fi fi -echo "" 1>&2 +echo -e "\n" echo "Connect $hostname:$port OK (v$version)" diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index d3f8b05aa..790d2aaa4 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -422,14 +422,15 @@ ghe_remote_version_required() { if [ -z "$GHE_REMOTE_VERSION" ]; then _out=$(ghe-host-check "$@") echo "$_out" + _out_hostname=$(echo "$_out" | tail -n 1) # override hostname w/ ghe-host-check output because the port could have # been autodetected to 122. - GHE_HOSTNAME="${_out/Connect /}" + GHE_HOSTNAME="${_out_hostname/Connect /}" GHE_HOSTNAME="${GHE_HOSTNAME/ OK*/}" export GHE_HOSTNAME - GHE_REMOTE_VERSION="${_out#*\(}" + GHE_REMOTE_VERSION="${_out_hostname#*\(}" GHE_REMOTE_VERSION="${GHE_REMOTE_VERSION%%\)*}" export GHE_REMOTE_VERSION From b3be0d90b11a589050575d164b6b260ca3715fde Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 20 Sep 2023 10:44:46 -0400 Subject: [PATCH 2181/2421] use checkout v4 --- .github/workflows/build-and-release.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 487f808f2..a9d28ee09 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -24,20 +24,14 @@ jobs: app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} - name: Install dependencies run: | sudo apt-get update -y sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create patch release branch from current sha - run: | - git config user.name "release-controller" - git config user.email "ghes-releases-team@github.com" - git branch "enterprise-${{ github.event.inputs.version }}-release" - git push origin "enterprise-${{ github.event.inputs.version }}-release" - # create v#{version} tag on current sha + # create tags for the build scripts to work - name: Create tag run: | git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" @@ -80,8 +74,8 @@ jobs: # required app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout backup-utils + uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils @@ -91,14 +85,13 @@ jobs: run: | git config user.name "release-controller" git config user.email "ghes-releases-team@github.com" - # tims-test-branch already exists, so fetch it git fetch origin tims-test-branch git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" git push origin tims-test-branch echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - - name: Checkout - uses: actions/checkout@v2 + - name: Checkout backup-utils-private + uses: actions/checkout@v4 - name: Download deb artifact uses: actions/download-artifact@v3 with: From 91905dd52d3a43fa2afc1c734a8438d8af00ad03 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 20 Sep 2023 10:49:45 -0400 Subject: [PATCH 2182/2421] set git config --- .github/workflows/build-and-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index a9d28ee09..cdc823455 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -34,6 +34,8 @@ jobs: # create tags for the build scripts to work - name: Create tag run: | + git config user.name "release-controller[bot]" + git config user.email "ghes-releases-team@github.com" git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" git push origin "v${{ github.event.inputs.version }}" - name: Package deb From 0b232188e513c2acfeffbb230f036a5f791fbedf Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 20 Sep 2023 11:23:32 -0400 Subject: [PATCH 2183/2421] Just a quick echo fix (#594) Just a quick fix to echo statement to clean it up. --- bin/ghe-host-check | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index adb3b0ccb..5cd39abee 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -176,8 +176,7 @@ SKIP_MSG fi #Display dir requirements for repositories and mysql - echo -e "\n" - echo "Checking host for sufficient space for a backup..." + echo -e "\nChecking host for sufficient space for a backup..." available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." @@ -194,8 +193,7 @@ SKIP_MSG recommended_disk_req=$((min_disk_req * 5)) echo " - Available space: $((available_space / (1024 ** 2))) MB" echo " - Min Disk required for this backup is at least $min_disk_req MB" - echo " - Recommended Disk requirement is $recommended_disk_req MB" - echo -e "\n" + echo -e " - Recommended Disk requirement is $recommended_disk_req MB\n" printf '### Estimated Data Transfer Sizes @@ -263,5 +261,5 @@ SKIP_MSG echo " - jq ${jq_version} >= required ($min_jq)" fi fi -echo -e "\n" -echo "Connect $hostname:$port OK (v$version)" + +echo -e "\nConnect $hostname:$port OK (v$version)" From fb356cc6897682c5a693c97d8c7326f0f12991ca Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 20 Sep 2023 16:52:30 +0000 Subject: [PATCH 2184/2421] try getting issues --- .github/workflows/build-and-release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index cdc823455..a5185f63e 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -82,6 +82,11 @@ jobs: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils ref: master + - name: Try getting issues from backkup-utils + run: | + curl -H "Authorization: token ${{ steps.app-token.outputs.token }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/github/backup-utils/issues - name: Create empty commit id: empty_commit run: | From 5070734353e4bf462f0e1c0bac9294aa9aef6796 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Wed, 20 Sep 2023 13:47:51 -0600 Subject: [PATCH 2185/2421] Set enterprise2 branch as env var --- .github/workflows/integration-tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 804c6d5c5..8727233ea 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -36,6 +36,7 @@ jobs: with: janky-token: '${{ secrets.API_AUTH_TOKEN }}' job-name: '${{ matrix.jankyJobName }}' - branch-name: '${{ env.TARGET_BRANCH }}' + branch-name: '${{ env.SOURCE_BRANCH }}' force : "true" - envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }}" + # enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release) + envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ env.TARGET_BRANCH }}" From 0e42379f95e2a290ae61938a5e6821839aed3e6d Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Wed, 20 Sep 2023 22:50:01 -0400 Subject: [PATCH 2186/2421] Add redis restart mechanism (#583) --- bin/ghe-restore | 19 +++++++++++++++++++ test/bin/ghe-nomad-jobs | 7 +++++++ 2 files changed, 26 insertions(+) create mode 100755 test/bin/ghe-nomad-jobs diff --git a/bin/ghe-restore b/bin/ghe-restore index 17a12b8b1..078932236 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -636,6 +636,25 @@ echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh bm_end "$(basename $0) - Restarting memcached" +# Restart redis before updating keys +# It's possible that redis hcl is not rendered on an unconfigured system +# so check first +if $instance_configured; then + log_info "Getting redis status before restart..." 1>&3 + echo "nomad status redis" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 + log_info "Restarting redis" 1>&3 + echo "nomad stop redis" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 2>&3 + ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-jobs queue /etc/nomad-jobs/redis/redis.hcl" 1>&3 2>&3 + if $? -gt 0; then + log_error "Unable to restart redis" + fi + log_info "Getting redis status after restart..." 1>&3 + echo "nomad status redis" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 +fi + # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. if ! $RESTORE_SETTINGS; then diff --git a/test/bin/ghe-nomad-jobs b/test/bin/ghe-nomad-jobs new file mode 100755 index 000000000..a91afc7be --- /dev/null +++ b/test/bin/ghe-nomad-jobs @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# Usage: ghe-nomad-jobs +# Emulates the remote GitHub ghe-nomad-jobs command. Tests use this +# to assert that the command was executed. +set -e +echo "$(basename $0)" "'$(cat)'" "OK" + From 63b4e2913a75c5dd8d513ac08b604753f25f02a9 Mon Sep 17 00:00:00 2001 From: alejndr0 Date: Thu, 21 Sep 2023 09:07:11 +0000 Subject: [PATCH 2187/2421] Add GHE_RSYNC_COMPRESSION_ENABLED option --- backup.config-example | 4 ++++ share/github-backup-utils/ghe-rsync | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 688cc374b..347764b2a 100644 --- a/backup.config-example +++ b/backup.config-example @@ -58,6 +58,10 @@ GHE_NUM_SNAPSHOTS=10 # #GHE_EXTRA_RSYNC_OPTS="" +# If set to 'yes', rsync will be set to use compression during backups and restores transfers. Defaults to 'no'. +# +#GHE_RSYNC_COMPRESSION_ENABLED=yes + # If enabled and set to 'no', rsync warning message during backups will be suppressed. #RSYNC_WARNING=no diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index d957068ac..d1aa5316c 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -29,6 +29,13 @@ if [ "$($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker --trust-sende parameters=("--trust-sender" "${parameters[@]}") fi +# This adds `--compress` to the parameters if supported by the current version of rsync +# shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker +# shellcheck disable=SC2046 +if [ "$($( dirname "${BASH_SOURCE[0]}" )/ghe-rsync-feature-checker --compress)" == "true" ] && [ "$GHE_RSYNC_COMPRESSION_ENABLED" = "yes" ]; then + parameters+=("--compress") +fi + # This loads the $GHE_EXTRA_RSYNC_OPTS from the config file if available then adds them # to the parameters and skip adding if already present in the parameters # shellcheck source=share/github-backup-utils/ghe-rsync-feature-checker @@ -41,7 +48,7 @@ if [ -n "$GHE_EXTRA_RSYNC_OPTS" ]; then done fi - +echo "Running rsync with parameters: ${parameters[*]}" ignore_out='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' rsync_version_check=$(rsync --version | grep -E "version 3.[0-9]*.[0-9]*") if [ -n "$rsync_version_check" ]; then From c889d7b0a3ad1cb9a438ce9acab3874947f53734 Mon Sep 17 00:00:00 2001 From: alejndr0 Date: Thu, 21 Sep 2023 09:08:13 +0000 Subject: [PATCH 2188/2421] remove debugging line --- share/github-backup-utils/ghe-rsync | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/ghe-rsync b/share/github-backup-utils/ghe-rsync index d1aa5316c..50a90fba8 100755 --- a/share/github-backup-utils/ghe-rsync +++ b/share/github-backup-utils/ghe-rsync @@ -48,7 +48,6 @@ if [ -n "$GHE_EXTRA_RSYNC_OPTS" ]; then done fi -echo "Running rsync with parameters: ${parameters[*]}" ignore_out='^(file has vanished: |rsync warning: some files vanished before they could be transferred)' rsync_version_check=$(rsync --version | grep -E "version 3.[0-9]*.[0-9]*") if [ -n "$rsync_version_check" ]; then From 7f2ee81788367b60ab8a21eda5365753c0257e3e Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 21 Sep 2023 09:52:27 -0600 Subject: [PATCH 2189/2421] Fix base ref --- .github/workflows/integration-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 8727233ea..c7ccf30f0 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -15,8 +15,8 @@ on: # Get target and source branch from different variables depending on how it was triggered env: - TARGET_BRANCH: '${{ github.event.inputs.target-branch }}${{ github.base_ref || github.ref_name }}' - SOURCE_BRANCH: '${{ github.event.inputs.source-branch }}${{ github.head_ref || github.ref_name }}' + TARGET_BRANCH: '${{ github.event.inputs.target-branch || github.base_ref }}' + SOURCE_BRANCH: '${{ github.event.inputs.source-branch || github.head_ref }}' jobs: integration-tests: From c8570b3328569977b0789f9e65eaf987d50f4408 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 21 Sep 2023 09:55:18 -0600 Subject: [PATCH 2190/2421] Add two cluster tests to nightly runs --- .github/workflows/nightly-tests.yml | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/nightly-tests.yml diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml new file mode 100644 index 000000000..6215a7f65 --- /dev/null +++ b/.github/workflows/nightly-tests.yml @@ -0,0 +1,33 @@ +name: Long Running Nightly Tests +on: + schedule: + - cron: '0 0 * * *' + workflow_dispatch: + +# Get target and source branch from different variables depending on how it was triggered +env: + TARGET_BRANCH: '${{ github.event.inputs.target-branch || github.base_ref }}' + SOURCE_BRANCH: '${{ github.event.inputs.source-branch || github.head_ref }}' + +jobs: + integration-tests: + runs-on: ubuntu-latest + strategy: + matrix: + jankyJobName: + - enterprise2-backup-utils-cluster-binary-backup + - enterprise2-backup-utils-cluster-migration + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Queue ${{ matrix.jankyJobName }} build + uses: ./.github/actions/proxy-janky-build + id: proxy-janky-build + with: + janky-token: '${{ secrets.API_AUTH_TOKEN }}' + job-name: '${{ matrix.jankyJobName }}' + branch-name: '${{ github.ref_name }}' + force : "true" + # enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release) + envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ github.ref_name }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ github.ref_name }}" From c91302f10768dbf13d3c790656bd5ada8f58f5cb Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 21 Sep 2023 09:56:41 -0600 Subject: [PATCH 2191/2421] Revert "Add two cluster tests to nightly runs" This reverts commit c8570b3328569977b0789f9e65eaf987d50f4408. --- .github/workflows/nightly-tests.yml | 33 ----------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/nightly-tests.yml diff --git a/.github/workflows/nightly-tests.yml b/.github/workflows/nightly-tests.yml deleted file mode 100644 index 6215a7f65..000000000 --- a/.github/workflows/nightly-tests.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Long Running Nightly Tests -on: - schedule: - - cron: '0 0 * * *' - workflow_dispatch: - -# Get target and source branch from different variables depending on how it was triggered -env: - TARGET_BRANCH: '${{ github.event.inputs.target-branch || github.base_ref }}' - SOURCE_BRANCH: '${{ github.event.inputs.source-branch || github.head_ref }}' - -jobs: - integration-tests: - runs-on: ubuntu-latest - strategy: - matrix: - jankyJobName: - - enterprise2-backup-utils-cluster-binary-backup - - enterprise2-backup-utils-cluster-migration - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - name: Queue ${{ matrix.jankyJobName }} build - uses: ./.github/actions/proxy-janky-build - id: proxy-janky-build - with: - janky-token: '${{ secrets.API_AUTH_TOKEN }}' - job-name: '${{ matrix.jankyJobName }}' - branch-name: '${{ github.ref_name }}' - force : "true" - # enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release) - envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ github.ref_name }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ github.ref_name }}" From 2591f7afce1db597f7464d45687f9b49b9ff78a2 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Thu, 21 Sep 2023 21:28:23 -0400 Subject: [PATCH 2192/2421] Fix tests on redis restart (#600) previous pr had a typo causing issues on cluster --- bin/ghe-restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index 078932236..f7f092e23 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -647,7 +647,7 @@ if $instance_configured; then echo "nomad stop redis" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 2>&3 ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-jobs queue /etc/nomad-jobs/redis/redis.hcl" 1>&3 2>&3 - if $? -gt 0; then + if [ "$?" -gt 0 ]; then log_error "Unable to restart redis" fi log_info "Getting redis status after restart..." 1>&3 From 91986af27acc260d0c0d405a989d56cee33659e6 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Fri, 22 Sep 2023 07:31:50 -0400 Subject: [PATCH 2193/2421] reverting changes to redis restart mechanism Some problems are being caused on cluster binary backup, need to revert until other fixes are in. --- bin/ghe-restore | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/bin/ghe-restore b/bin/ghe-restore index f7f092e23..c9ac20ec2 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -636,24 +636,6 @@ echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh bm_end "$(basename $0) - Restarting memcached" -# Restart redis before updating keys -# It's possible that redis hcl is not rendered on an unconfigured system -# so check first -if $instance_configured; then - log_info "Getting redis status before restart..." 1>&3 - echo "nomad status redis" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 - log_info "Restarting redis" 1>&3 - echo "nomad stop redis" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 2>&3 - ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-jobs queue /etc/nomad-jobs/redis/redis.hcl" 1>&3 2>&3 - if [ "$?" -gt 0 ]; then - log_error "Unable to restart redis" - fi - log_info "Getting redis status after restart..." 1>&3 - echo "nomad status redis" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 -fi # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. From 74ed061df5b6ea835077fa9ec37b0239f22eec7a Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 14:57:26 +0000 Subject: [PATCH 2194/2421] try fork of action --- .github/workflows/build-and-release.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index a5185f63e..f8207f466 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -17,7 +17,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/create-github-app-token@v1 + - uses: timreimherr/create-github-app-token id: app-token with: # required @@ -70,23 +70,22 @@ jobs: outputs: commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} steps: - - uses: actions/create-github-app-token@v1 + - uses: timreimherr/create-github-app-token id: app-token with: # required app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: | + github/backup-utils + github/backup-utils-private - name: Checkout backup-utils uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils ref: master - - name: Try getting issues from backkup-utils - run: | - curl -H "Authorization: token ${{ steps.app-token.outputs.token }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/github/backup-utils/issues - name: Create empty commit id: empty_commit run: | @@ -99,6 +98,10 @@ jobs: echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Checkout backup-utils-private uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils-private + ref: master - name: Download deb artifact uses: actions/download-artifact@v3 with: From a16fb67fbfa67c1e7e1afa7d374a56a3107396b4 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 15:25:53 +0000 Subject: [PATCH 2195/2421] the yaml linter line length isn't adding value here --- .github/linters/.yaml-lint.yml | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/linters/.yaml-lint.yml diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml new file mode 100644 index 000000000..bacf1f80c --- /dev/null +++ b/.github/linters/.yaml-lint.yml @@ -0,0 +1,55 @@ +--- +########################################### +# These are the rules used for # +# linting all the yaml files in the stack # +# NOTE: # +# You can disable line with: # +# # yamllint disable-line # +########################################### +rules: + braces: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + brackets: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + colons: + level: warning + max-spaces-before: 0 + max-spaces-after: 1 + commas: + level: warning + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: disable + comments-indentation: disable + document-end: disable + document-start: + level: warning + present: true + empty-lines: + level: warning + max: 2 + max-start: 0 + max-end: 0 + hyphens: + level: warning + max-spaces-after: 1 + indentation: + level: warning + spaces: consistent + indent-sequences: true + check-multi-line-strings: false + key-duplicates: enable + line-length: disable + new-line-at-end-of-file: disable + new-lines: + type: unix + trailing-spaces: disable \ No newline at end of file From 9881f9c8c4bd2e8589ac580bd3d9397db019374a Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 15:26:15 +0000 Subject: [PATCH 2196/2421] ignore release-notes markdown --- .github/workflows/build-and-release.yml | 1 + .github/workflows/lint.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index f8207f466..9cd0141a5 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -1,3 +1,4 @@ +--- name: Build and Release on: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0c6af658b..e818ad8ac 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,3 +20,4 @@ jobs: VALIDATE_ALL_CODEBASE: false BASH_SEVERITY: error GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FILTER_REGEX_EXCLUDE: .*release-notes/.* From aa11551a0e02522b7f19b239399ac126eef66155 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 15:27:43 +0000 Subject: [PATCH 2197/2421] linter fix --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 9cd0141a5..a22bce6d9 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -18,7 +18,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: timreimherr/create-github-app-token + - uses: timreimherr/create-github-app-token@v1 id: app-token with: # required @@ -71,7 +71,7 @@ jobs: outputs: commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} steps: - - uses: timreimherr/create-github-app-token + - uses: timreimherr/create-github-app-token@v1 id: app-token with: # required From 348aec0b0157c864eed0a8b68d78c32597683f17 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 15:37:23 +0000 Subject: [PATCH 2198/2421] lint error --- .github/workflows/lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e818ad8ac..7fc33e1cd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,3 +1,4 @@ +--- name: Lint Code Base on: From 360bcc3492bb06f7f99931c4ae2ccd36ccee8096 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 15:43:57 +0000 Subject: [PATCH 2199/2421] linters are so fun --- .github/workflows/build-and-release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index a22bce6d9..285b505e7 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -90,13 +90,13 @@ jobs: - name: Create empty commit id: empty_commit run: | - git config user.name "release-controller" - git config user.email "ghes-releases-team@github.com" - git fetch origin tims-test-branch - git checkout tims-test-branch - git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin tims-test-branch - echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + "git config user.name 'release-controller'" + "git config user.email 'ghes-releases-team@github.com'" + "git fetch origin tims-test-branch" + "git checkout tims-test-branch" + "git commit --allow-empty -m '${{ github.event.inputs.version }} release'" + "git push origin tims-test-branch" + "echo 'commit-sha=$(git rev-parse HEAD)' >> $GITHUB_OUTPUT" - name: Checkout backup-utils-private uses: actions/checkout@v4 with: From 38dd4bb6a6cc0f0f9a1bb09327a25e4fcaeb5106 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 22 Sep 2023 09:49:58 -0600 Subject: [PATCH 2200/2421] Add cluster run as optional runs --- .github/workflows/integration-tests.yml | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index c7ccf30f0..f48de957e 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -37,6 +37,31 @@ jobs: janky-token: '${{ secrets.API_AUTH_TOKEN }}' job-name: '${{ matrix.jankyJobName }}' branch-name: '${{ env.SOURCE_BRANCH }}' - force : "true" + # enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release) + envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ env.TARGET_BRANCH }}" + + # Cluster integration tests are optional based on label and PR titles + cluster-integration-tests: + runs-on: ubuntu-latest + strategy: + matrix: + jankyJobName: + - enterprise2-backup-utils-cluster-binary-backup + - enterprise2-backup-utils-cluster-migration + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Queue ${{ matrix.jankyJobName }} build + if: | + github.event_name == 'workflow_dispatch' || + contains(github.event.pull_request.title, '[cluster]') || + contains(github.event.pull_request.labels.*.name, 'cluster') + uses: ./.github/actions/proxy-janky-build + id: proxy-janky-build + with: + janky-token: '${{ secrets.API_AUTH_TOKEN }}' + job-name: '${{ matrix.jankyJobName }}' + branch-name: '${{ env.SOURCE_BRANCH }}' # enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release) envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ env.TARGET_BRANCH }}" From 9b9617d310dba83b68a043fd0463bef3e1126ba1 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 22 Sep 2023 10:09:38 -0600 Subject: [PATCH 2201/2421] Update PR template --- .github/pull_request_template.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index fd36d8a9a..ed5e1c26c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,17 @@ + + + + # PR Details ### Description From aa306776a81e66079e6cc480aeaf3c1a533dde22 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 16:27:15 +0000 Subject: [PATCH 2202/2421] I hate this linter --- .github/workflows/build-and-release.yml | 8 +------- script/create-emtpy-commit | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 script/create-emtpy-commit diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 285b505e7..f180bd6f5 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -90,13 +90,7 @@ jobs: - name: Create empty commit id: empty_commit run: | - "git config user.name 'release-controller'" - "git config user.email 'ghes-releases-team@github.com'" - "git fetch origin tims-test-branch" - "git checkout tims-test-branch" - "git commit --allow-empty -m '${{ github.event.inputs.version }} release'" - "git push origin tims-test-branch" - "echo 'commit-sha=$(git rev-parse HEAD)' >> $GITHUB_OUTPUT" + ./script/create-empty-commit - name: Checkout backup-utils-private uses: actions/checkout@v4 with: diff --git a/script/create-emtpy-commit b/script/create-emtpy-commit new file mode 100644 index 000000000..7f69449a9 --- /dev/null +++ b/script/create-emtpy-commit @@ -0,0 +1,14 @@ +#!/ust/bin/env bash +# Usage: script/create-empty-commit +# Script to create an empty commit on the current branch. +# This is used to create a new tag for a release in github/backup-utils. +# This is to avoid stacking multiple release tags on the same commit. +set -e + +git config user.name "release-controller[bot]" +git config user.email "ghes-releases-team@github.com" +git fetch origin tims-test-branch +git checkout tims-test-branch +git commit --allow-empty -m "${{ github.event.inputs.version }} release" +git push origin tims-test-branch +echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT \ No newline at end of file From f387d47da0e6cb5e91321ca2a4ad9324b9057d6a Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 18:10:26 +0000 Subject: [PATCH 2203/2421] remove document start --- .github/linters/.yaml-lint.yml | 4 +--- .github/workflows/build-and-release.yml | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml index bacf1f80c..030c37f04 100644 --- a/.github/linters/.yaml-lint.yml +++ b/.github/linters/.yaml-lint.yml @@ -31,9 +31,7 @@ rules: comments: disable comments-indentation: disable document-end: disable - document-start: - level: warning - present: true + document-start: disable empty-lines: level: warning max: 2 diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index f180bd6f5..17f349f91 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -1,4 +1,3 @@ ---- name: Build and Release on: From d3f9b3d5eb81915942bbe84b031d158fc8b1e510 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 18:13:18 +0000 Subject: [PATCH 2204/2421] remove action version --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 17f349f91..549bb568b 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -17,7 +17,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: timreimherr/create-github-app-token@v1 + - uses: timreimherr/create-github-app-token id: app-token with: # required @@ -70,7 +70,7 @@ jobs: outputs: commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} steps: - - uses: timreimherr/create-github-app-token@v1 + - uses: timreimherr/create-github-app-token id: app-token with: # required From 12e11705b870fbb970eaccff0f072daac5ef2f8b Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 18:25:44 +0000 Subject: [PATCH 2205/2421] try v1 --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 549bb568b..17f349f91 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -17,7 +17,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: timreimherr/create-github-app-token + - uses: timreimherr/create-github-app-token@v1 id: app-token with: # required @@ -70,7 +70,7 @@ jobs: outputs: commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} steps: - - uses: timreimherr/create-github-app-token + - uses: timreimherr/create-github-app-token@v1 id: app-token with: # required From 359ef2a15da42f5f28575f7497ac280dc53fc763 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 22 Sep 2023 19:25:02 +0000 Subject: [PATCH 2206/2421] @main --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 17f349f91..5c3e7a580 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -17,7 +17,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: timreimherr/create-github-app-token@v1 + - uses: timreimherr/create-github-app-token@main id: app-token with: # required @@ -70,7 +70,7 @@ jobs: outputs: commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} steps: - - uses: timreimherr/create-github-app-token@v1 + - uses: timreimherr/create-github-app-token@main id: app-token with: # required From 6a965c37cd53d6d440d344648a7061c71910fd09 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 22 Sep 2023 14:03:49 -0600 Subject: [PATCH 2207/2421] update for linter error --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index ed5e1c26c..afcf77749 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -12,7 +12,7 @@ Additional notes regarding CI: - If you are making changes impacts cluster, please add `cluster` label or `[cluster]` in your PR title so it will trigger optional cluster integration test. Those tests will take about 3 hours so relax and come back later to check the results. ;) --> -# PR Details +## PR Details ### Description -## PR Details +# PR Details -### Description +## Description -### Testing +## Testing @@ -31,10 +31,10 @@ Additional notes regarding CI: - Please make sure those versions are tested against for this change --> -### Ownership +## Ownership -### Related Links +## Related Links From f3fb2ebe04675e81908f4bda4987c8b1559be382 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 13:33:48 +0000 Subject: [PATCH 2212/2421] show me the directory structure after checkout --- .github/workflows/build-and-release.yml | 195 +++++++++++++----------- 1 file changed, 105 insertions(+), 90 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index bf5d44501..5b7e601ec 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -23,63 +23,6 @@ jobs: # required app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # create tags for the build scripts to work - - name: Create tag - run: | - git config user.name "release-controller[bot]" - git config user.email "ghes-releases-team@github.com" - git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Package deb - run: | - ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - - name: Upload deb artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - release: - needs: build - runs-on: ubuntu-latest - outputs: - commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} - steps: - - uses: timreimherr/create-github-app-token@main - id: app-token - with: - # required - app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: | - github/backup-utils - github/backup-utils-private - name: Checkout backup-utils-private uses: actions/checkout@v4 with: @@ -93,37 +36,109 @@ jobs: repository: github/backup-utils ref: master path: backup-utils - - name: Create empty commit - id: empty_commit + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Show direcotry structure run: | - cp ./backup-utils-private/scripts/create-empty-commit \ - ./create-empty-commit - cd ./backup-utils - ./create-empty-commit - - name: Download deb artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Download tarball artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - - name: Create Release - uses: ncipollo/release-action@v1 - with: - token: ${{ steps.app-token.outputs.token }} - repo: backup-utils - name: | - GitHub Enterprise Server Backup Utilities - v${{ github.event.inputs.version }} - artifacts: | - github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - github-backup-utils_${{ github.event.inputs.version }}_all.deb - # this action will create a tag with this name on the provided commit - tag: v${{ github.event.inputs.version }} - # this can be a commit hash or branch name - commit: ${{ steps.empty_commit.outputs.commit_sha }} - bodyFile: release-notes/${{ github.event.inputs.version }}.md - draft: ${{ github.event.inputs.draft }} - allowUpdates: true - artifactContentType: "raw" + ls -R + # create tags for the build scripts to work + # - name: Create tag + # run: | + # git config user.name "release-controller[bot]" + # git config user.email "ghes-releases-team@github.com" + # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + # git push origin "v${{ github.event.inputs.version }}" + # - name: Package deb + # run: | + # ./script/package-deb + # # many need to remove this once release-notes compilation is automated + # - name: Rename deb artifact + # run: | + # for file in dist/github-backup-utils_*_all.deb; do + # if [[ -f "$file" ]]; then + # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + # fi + # done + # - name: Upload deb artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # path: | + # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Package tarball + # run: | + # ./script/package-tarball + # - name: Upload tarball artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # path: | + # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # release: + # needs: build + # runs-on: ubuntu-latest + # outputs: + # commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} + # steps: + # - uses: timreimherr/create-github-app-token@main + # id: app-token + # with: + # # required + # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: | + # github/backup-utils + # github/backup-utils-private + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils-private + # path: backup-utils-private + # - name: Checkout backup-utils + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils + # ref: master + # path: backup-utils + # - name: Show direcotry structure + # run: | + # ls -R + # - name: Create empty commit + # id: empty_commit + # run: | + # cp ./backup-utils-private/scripts/create-empty-commit \ + # ./create-empty-commit + # cd ./backup-utils + # ./create-empty-commit + # - name: Download deb artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Download tarball artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # - name: Create Release + # uses: ncipollo/release-action@v1 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repo: backup-utils + # name: | + # GitHub Enterprise Server Backup Utilities + # v${{ github.event.inputs.version }} + # artifacts: | + # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + # github-backup-utils_${{ github.event.inputs.version }}_all.deb + # # this action will create a tag with this name on the provided commit + # tag: v${{ github.event.inputs.version }} + # # this can be a commit hash or branch name + # commit: ${{ steps.empty_commit.outputs.commit_sha }} + # bodyFile: release-notes/${{ github.event.inputs.version }}.md + # draft: ${{ github.event.inputs.draft }} + # allowUpdates: true + # artifactContentType: "raw" From 535b7bdff40f83c1388d101dbb36bd8a655a0e74 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 13:37:06 +0000 Subject: [PATCH 2213/2421] again --- .github/workflows/build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 5b7e601ec..50ddb0136 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -43,6 +43,7 @@ jobs: - name: Show direcotry structure run: | ls -R + pwd # create tags for the build scripts to work # - name: Create tag # run: | From ea89f9085d1cdaa3a0de86fffe14d352361a66a9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 13:56:25 +0000 Subject: [PATCH 2214/2421] and again --- .github/workflows/build-and-release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 50ddb0136..2ac76b014 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -44,6 +44,9 @@ jobs: run: | ls -R pwd + ls -l + cd .. + ls -l # create tags for the build scripts to work # - name: Create tag # run: | From d37a196c1e7d1f13ea6cf16c1aa964e3a9f6c225 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 13:58:21 +0000 Subject: [PATCH 2215/2421] let me see more --- .github/workflows/build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 2ac76b014..c358a318d 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -46,6 +46,7 @@ jobs: pwd ls -l cd .. + pwd ls -l # create tags for the build scripts to work # - name: Create tag From 3e18e6b666da817d827f35df1932a68587d07168 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:06:43 +0000 Subject: [PATCH 2216/2421] lets try the empty commit again --- .github/workflows/build-and-release.yml | 215 ++++++++++++------------ 1 file changed, 106 insertions(+), 109 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c358a318d..cb9980b9a 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -36,114 +36,111 @@ jobs: repository: github/backup-utils ref: master path: backup-utils - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Show direcotry structure + - name: Install dependencies run: | - ls -R - pwd - ls -l - cd .. - pwd - ls -l + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + # - name: Show direcotry structure + # run: | + # ls -R + # pwd + # ls -l + # cd .. + # pwd + # ls -l # create tags for the build scripts to work - # - name: Create tag - # run: | - # git config user.name "release-controller[bot]" - # git config user.email "ghes-releases-team@github.com" - # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - # git push origin "v${{ github.event.inputs.version }}" - # - name: Package deb - # run: | - # ./script/package-deb - # # many need to remove this once release-notes compilation is automated - # - name: Rename deb artifact - # run: | - # for file in dist/github-backup-utils_*_all.deb; do - # if [[ -f "$file" ]]; then - # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - # fi - # done - # - name: Upload deb artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # path: | - # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Package tarball - # run: | - # ./script/package-tarball - # - name: Upload tarball artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # path: | - # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # release: - # needs: build - # runs-on: ubuntu-latest - # outputs: - # commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} - # steps: - # - uses: timreimherr/create-github-app-token@main - # id: app-token - # with: - # # required - # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: | - # github/backup-utils - # github/backup-utils-private - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils-private - # path: backup-utils-private - # - name: Checkout backup-utils - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils - # ref: master - # path: backup-utils - # - name: Show direcotry structure - # run: | - # ls -R - # - name: Create empty commit - # id: empty_commit - # run: | - # cp ./backup-utils-private/scripts/create-empty-commit \ - # ./create-empty-commit - # cd ./backup-utils - # ./create-empty-commit - # - name: Download deb artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Download tarball artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # - name: Create Release - # uses: ncipollo/release-action@v1 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repo: backup-utils - # name: | - # GitHub Enterprise Server Backup Utilities - # v${{ github.event.inputs.version }} - # artifacts: | - # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - # github-backup-utils_${{ github.event.inputs.version }}_all.deb - # # this action will create a tag with this name on the provided commit - # tag: v${{ github.event.inputs.version }} - # # this can be a commit hash or branch name - # commit: ${{ steps.empty_commit.outputs.commit_sha }} - # bodyFile: release-notes/${{ github.event.inputs.version }}.md - # draft: ${{ github.event.inputs.draft }} - # allowUpdates: true - # artifactContentType: "raw" + - name: Create tag + run: | + git config user.name "release-controller[bot]" + git config user.email "ghes-releases-team@github.com" + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + - name: Package deb + run: | + ./script/package-deb + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + release: + needs: build + runs-on: ubuntu-latest + outputs: + commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} + steps: + - uses: timreimherr/create-github-app-token@main + id: app-token + with: + # required + app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: | + github/backup-utils + github/backup-utils-private + - name: Checkout backup-utils-private + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils-private + path: backup-utils-private + - name: Checkout backup-utils + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils + ref: master + path: backup-utils + - name: Create empty commit in backup-utils + id: empty_commit + run: | + cp ./backup-utils-private/scripts/create-empty-commit \ + .backup-utils/create-empty-commit + cd ./backup-utils + ./create-empty-commit + - name: Download deb artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Download tarball artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Create Release + uses: ncipollo/release-action@v1 + with: + token: ${{ steps.app-token.outputs.token }} + repo: backup-utils + name: | + GitHub Enterprise Server Backup Utilities + v${{ github.event.inputs.version }} + artifacts: | + github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + github-backup-utils_${{ github.event.inputs.version }}_all.deb + # this action will create a tag with this name on the provided commit + tag: v${{ github.event.inputs.version }} + # this can be a commit hash or branch name + commit: ${{ steps.empty_commit.outputs.commit_sha }} + bodyFile: release-notes/${{ github.event.inputs.version }}.md + draft: ${{ github.event.inputs.draft }} + allowUpdates: true + artifactContentType: "raw" From c42acb4bd0ebb1dbe64599f7607ba7c0ed27a404 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:08:53 +0000 Subject: [PATCH 2217/2421] just try it --- .github/workflows/build-and-release.yml | 219 +++++++++++++----------- 1 file changed, 122 insertions(+), 97 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index cb9980b9a..9c4dc6c15 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -23,6 +23,23 @@ jobs: # required app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils-private + # path: backup-utils-private + # - name: Checkout backup-utils + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils + # ref: master + # path: backup-utils + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - name: Checkout backup-utils-private uses: actions/checkout@v4 with: @@ -36,10 +53,13 @@ jobs: repository: github/backup-utils ref: master path: backup-utils - - name: Install dependencies + - name: Create empty commit in backup-utils + id: empty_commit run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip + cp ./backup-utils-private/scripts/create-empty-commit \ + .backup-utils/create-empty-commit + cd ./backup-utils + ./create-empty-commit # - name: Show direcotry structure # run: | # ls -R @@ -49,98 +69,103 @@ jobs: # pwd # ls -l # create tags for the build scripts to work - - name: Create tag - run: | - git config user.name "release-controller[bot]" - git config user.email "ghes-releases-team@github.com" - git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Package deb - run: | - ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - - name: Upload deb artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - release: - needs: build - runs-on: ubuntu-latest - outputs: - commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} - steps: - - uses: timreimherr/create-github-app-token@main - id: app-token - with: - # required - app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: | - github/backup-utils - github/backup-utils-private - - name: Checkout backup-utils-private - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - repository: github/backup-utils-private - path: backup-utils-private - - name: Checkout backup-utils - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - repository: github/backup-utils - ref: master - path: backup-utils - - name: Create empty commit in backup-utils - id: empty_commit + # if empty_commit is successful, then echo success + - name: Echo success + if: ${{ steps.empty_commit.outcome == 'success' }} run: | - cp ./backup-utils-private/scripts/create-empty-commit \ - .backup-utils/create-empty-commit - cd ./backup-utils - ./create-empty-commit - - name: Download deb artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Download tarball artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - - name: Create Release - uses: ncipollo/release-action@v1 - with: - token: ${{ steps.app-token.outputs.token }} - repo: backup-utils - name: | - GitHub Enterprise Server Backup Utilities - v${{ github.event.inputs.version }} - artifacts: | - github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - github-backup-utils_${{ github.event.inputs.version }}_all.deb - # this action will create a tag with this name on the provided commit - tag: v${{ github.event.inputs.version }} - # this can be a commit hash or branch name - commit: ${{ steps.empty_commit.outputs.commit_sha }} - bodyFile: release-notes/${{ github.event.inputs.version }}.md - draft: ${{ github.event.inputs.draft }} - allowUpdates: true - artifactContentType: "raw" + echo "empty commit successful" + # - name: Create tag + # run: | + # git config user.name "release-controller[bot]" + # git config user.email "ghes-releases-team@github.com" + # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + # git push origin "v${{ github.event.inputs.version }}" + # - name: Package deb + # run: | + # ./script/package-deb + # # many need to remove this once release-notes compilation is automated + # - name: Rename deb artifact + # run: | + # for file in dist/github-backup-utils_*_all.deb; do + # if [[ -f "$file" ]]; then + # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + # fi + # done + # - name: Upload deb artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # path: | + # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Package tarball + # run: | + # ./script/package-tarball + # - name: Upload tarball artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # path: | + # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # release: + # needs: build + # runs-on: ubuntu-latest + # outputs: + # commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} + # steps: + # - uses: timreimherr/create-github-app-token@main + # id: app-token + # with: + # # required + # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: | + # github/backup-utils + # github/backup-utils-private + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils-private + # path: backup-utils-private + # - name: Checkout backup-utils + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils + # ref: master + # path: backup-utils + # - name: Create empty commit in backup-utils + # id: empty_commit + # run: | + # cp ./backup-utils-private/scripts/create-empty-commit \ + # .backup-utils/create-empty-commit + # cd ./backup-utils + # ./create-empty-commit + # - name: Download deb artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Download tarball artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # - name: Create Release + # uses: ncipollo/release-action@v1 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repo: backup-utils + # name: | + # GitHub Enterprise Server Backup Utilities + # v${{ github.event.inputs.version }} + # artifacts: | + # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + # github-backup-utils_${{ github.event.inputs.version }}_all.deb + # # this action will create a tag with this name on the provided commit + # tag: v${{ github.event.inputs.version }} + # # this can be a commit hash or branch name + # commit: ${{ steps.empty_commit.outputs.commit_sha }} + # bodyFile: release-notes/${{ github.event.inputs.version }}.md + # draft: ${{ github.event.inputs.draft }} + # allowUpdates: true + # artifactContentType: "raw" From cdc459405da0eb750398ff4f2cd2be34119a81bd Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:16:54 +0000 Subject: [PATCH 2218/2421] try fix --- .github/workflows/build-and-release.yml | 53 ++++++++++++------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 9c4dc6c15..0c2390e52 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -23,51 +23,26 @@ jobs: # required app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils-private - # path: backup-utils-private - # - name: Checkout backup-utils - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils - # ref: master - # path: backup-utils - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - name: Checkout backup-utils-private uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils-private - path: backup-utils-private + path: ./backup-utils-private - name: Checkout backup-utils uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils ref: master - path: backup-utils + path: ./backup-utils - name: Create empty commit in backup-utils id: empty_commit run: | cp ./backup-utils-private/scripts/create-empty-commit \ - .backup-utils/create-empty-commit + ./backup-utils/create-empty-commit cd ./backup-utils ./create-empty-commit - # - name: Show direcotry structure - # run: | - # ls -R - # pwd - # ls -l - # cd .. - # pwd - # ls -l # create tags for the build scripts to work # if empty_commit is successful, then echo success - name: Echo success @@ -169,3 +144,25 @@ jobs: # draft: ${{ github.event.inputs.draft }} # allowUpdates: true # artifactContentType: "raw" + + + + + + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils-private + # path: backup-utils-private + # - name: Checkout backup-utils + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils + # ref: master + # path: backup-utils + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip \ No newline at end of file From b6dc65c83fb5dde02b0b281f048ee1d14ead9bc3 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:20:43 +0000 Subject: [PATCH 2219/2421] wrong directory name --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 0c2390e52..7e3e20e28 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -39,7 +39,7 @@ jobs: - name: Create empty commit in backup-utils id: empty_commit run: | - cp ./backup-utils-private/scripts/create-empty-commit \ + cp ./backup-utils-private/script/create-empty-commit \ ./backup-utils/create-empty-commit cd ./backup-utils ./create-empty-commit From 4be206c213d9d792072be3a4fe31d165c6159ad0 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:33:09 +0000 Subject: [PATCH 2220/2421] set scope --- .github/workflows/build-and-release.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 7e3e20e28..c79284aaa 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -23,6 +23,10 @@ jobs: # required app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: | + github/backup-utils + github/backup-utils-private - name: Checkout backup-utils-private uses: actions/checkout@v4 with: From fe290a68b5420e9e1c1e602410d55f71e206ae31 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:34:33 +0000 Subject: [PATCH 2221/2421] comma delimited --- .github/workflows/build-and-release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c79284aaa..5f77459d9 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -24,9 +24,7 @@ jobs: app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} - repositories: | - github/backup-utils - github/backup-utils-private + repositories: github/backup-utils,github/backup-utils-private - name: Checkout backup-utils-private uses: actions/checkout@v4 with: From ef6329da3f40b484df41332efb4ff9a1f421f5f2 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:36:21 +0000 Subject: [PATCH 2222/2421] fix repo values --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 5f77459d9..73348cec7 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -24,7 +24,7 @@ jobs: app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} - repositories: github/backup-utils,github/backup-utils-private + repositories: backup-utils,backup-utils-private - name: Checkout backup-utils-private uses: actions/checkout@v4 with: From d39c71ed16919d03ed04a6a9b1054bb7e657547c Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:40:08 +0000 Subject: [PATCH 2223/2421] checkout just backup-utils --- .github/workflows/build-and-release.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 73348cec7..8437c889b 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -25,12 +25,12 @@ jobs: private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: backup-utils,backup-utils-private - - name: Checkout backup-utils-private - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - repository: github/backup-utils-private - path: ./backup-utils-private + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils-private + # path: ./backup-utils-private - name: Checkout backup-utils uses: actions/checkout@v4 with: @@ -41,10 +41,13 @@ jobs: - name: Create empty commit in backup-utils id: empty_commit run: | - cp ./backup-utils-private/script/create-empty-commit \ - ./backup-utils/create-empty-commit - cd ./backup-utils - ./create-empty-commit + git config user.name "release-controller[bot]" + git config user.email "ghes-releases-team@github.com" + git fetch origin tims-test-branch + git checkout tims-test-branch + git commit --allow-empty -m "${{ github.event.inputs.version }} release" + git push origin tims-test-branch + echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT # create tags for the build scripts to work # if empty_commit is successful, then echo success - name: Echo success From 99f1a02ac1b8153de2dd5ded30f5b57f1e3eb6f9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:41:35 +0000 Subject: [PATCH 2224/2421] no path --- .github/workflows/build-and-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 8437c889b..76f916836 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -36,8 +36,6 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - ref: master - path: ./backup-utils - name: Create empty commit in backup-utils id: empty_commit run: | From 8e2c20d91880598e26e60b72f8160db80726708e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:46:13 +0000 Subject: [PATCH 2225/2421] try setting the token explicitly --- .github/workflows/build-and-release.yml | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 76f916836..dda2e6bf4 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -37,15 +37,18 @@ jobs: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - name: Create empty commit in backup-utils - id: empty_commit - run: | - git config user.name "release-controller[bot]" - git config user.email "ghes-releases-team@github.com" - git fetch origin tims-test-branch - git checkout tims-test-branch - git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin tims-test-branch - echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + id: empty_commit + env: + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + run: | + git config user.name "release-controller[bot]" + git config user.email "ghes-releases-team@github.com" + git remote set-url origin https://$ACCESS_TOKEN@github.com/github/backup-utils.git + git fetch origin tims-test-branch + git checkout tims-test-branch + git commit --allow-empty -m "${{ github.event.inputs.version }} release" + git push origin tims-test-branch + echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT # create tags for the build scripts to work # if empty_commit is successful, then echo success - name: Echo success From b90f442ffb006c4767358324a745911ef403e266 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:47:49 +0000 Subject: [PATCH 2226/2421] it can't see the workflow --- .github/workflows/build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index dda2e6bf4..3ca6053ff 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -1,3 +1,4 @@ +--- name: Build and Release on: From 211a3bda7a89ed9fc8bcd28d23fea91fc7093703 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:50:16 +0000 Subject: [PATCH 2227/2421] disable the linter --- .github/linters/.yaml-lint.yml | 72 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml index 030c37f04..0f3e1154b 100644 --- a/.github/linters/.yaml-lint.yml +++ b/.github/linters/.yaml-lint.yml @@ -7,47 +7,47 @@ # # yamllint disable-line # ########################################### rules: - braces: - level: warning - min-spaces-inside: 0 - max-spaces-inside: 0 - min-spaces-inside-empty: 1 - max-spaces-inside-empty: 5 - brackets: - level: warning - min-spaces-inside: 0 - max-spaces-inside: 0 - min-spaces-inside-empty: 1 - max-spaces-inside-empty: 5 - colons: - level: warning - max-spaces-before: 0 - max-spaces-after: 1 - commas: - level: warning - max-spaces-before: 0 - min-spaces-after: 1 - max-spaces-after: 1 + braces: disable + # level: warning + # min-spaces-inside: 0 + # max-spaces-inside: 0 + # min-spaces-inside-empty: 1 + # max-spaces-inside-empty: 5 + brackets: disable + # level: warning + # min-spaces-inside: 0 + # max-spaces-inside: 0 + # min-spaces-inside-empty: 1 + # max-spaces-inside-empty: 5 + colons: disable + # level: warning + # max-spaces-before: 0 + # max-spaces-after: 1 + commas: disable + # level: warning + # max-spaces-before: 0 + # min-spaces-after: 1 + # max-spaces-after: 1 comments: disable comments-indentation: disable document-end: disable document-start: disable - empty-lines: - level: warning - max: 2 - max-start: 0 - max-end: 0 - hyphens: - level: warning - max-spaces-after: 1 - indentation: - level: warning - spaces: consistent - indent-sequences: true - check-multi-line-strings: false + empty-lines: disable + # level: warning + # max: 2 + # max-start: 0 + # max-end: 0 + hyphens: disable + # level: warning + # max-spaces-after: 1 + indentation: disable + # level: warning + # spaces: consistent + # indent-sequences: true + # check-multi-line-strings: false key-duplicates: enable line-length: disable new-line-at-end-of-file: disable - new-lines: - type: unix + new-lines: diable + # type: unix trailing-spaces: disable \ No newline at end of file From 649e416c9d3233c759fee61d654ac1fdbb0aee28 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:51:10 +0000 Subject: [PATCH 2228/2421] ahg --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 3ca6053ff..ee7126e77 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -38,7 +38,7 @@ jobs: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - name: Create empty commit in backup-utils - id: empty_commit + id: empty-commit env: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: | From 806d55063c4be89ea94b851e2808f9396ba1d1c6 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:52:35 +0000 Subject: [PATCH 2229/2421] fix it --- .github/workflows/build-and-release.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index ee7126e77..1824d8969 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -38,18 +38,18 @@ jobs: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - name: Create empty commit in backup-utils - id: empty-commit - env: - ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} - run: | - git config user.name "release-controller[bot]" - git config user.email "ghes-releases-team@github.com" - git remote set-url origin https://$ACCESS_TOKEN@github.com/github/backup-utils.git - git fetch origin tims-test-branch - git checkout tims-test-branch - git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin tims-test-branch - echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + id: empty-commit + env: + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + run: | + git config user.name "release-controller[bot]" + git config user.email "ghes-releases-team@github.com" + git remote set-url origin https://$ACCESS_TOKEN@github.com/github/backup-utils.git + git fetch origin tims-test-branch + git checkout tims-test-branch + git commit --allow-empty -m "${{ github.event.inputs.version }} release" + git push origin tims-test-branch + echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT # create tags for the build scripts to work # if empty_commit is successful, then echo success - name: Echo success From 0f248c559454e3b39e119cc7d12914881f8a6479 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 14:56:45 +0000 Subject: [PATCH 2230/2421] use access token --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 1824d8969..c89d37454 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -40,7 +40,7 @@ jobs: - name: Create empty commit in backup-utils id: empty-commit env: - ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + ACCESS_TOKEN: ${{ steps.app-token.outputs.token }} run: | git config user.name "release-controller[bot]" git config user.email "ghes-releases-team@github.com" From 321efa1a1d32bb9631a2a1907fc58cf19924c9ff Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 18:17:18 +0000 Subject: [PATCH 2231/2421] try new action --- .github/workflows/build-and-release.yml | 43 ++++++++++++++----------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c89d37454..6e252748d 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -26,34 +26,39 @@ jobs: private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: backup-utils,backup-utils-private - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils-private - # path: ./backup-utils-private - name: Checkout backup-utils uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - - name: Create empty commit in backup-utils - id: empty-commit - env: - ACCESS_TOKEN: ${{ steps.app-token.outputs.token }} + # set GITHUB_TOKEN to the app token + - name: Set GITHUB_TOKEN run: | - git config user.name "release-controller[bot]" - git config user.email "ghes-releases-team@github.com" - git remote set-url origin https://$ACCESS_TOKEN@github.com/github/backup-utils.git - git fetch origin tims-test-branch - git checkout tims-test-branch - git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin tims-test-branch - echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + echo "GITHUB_TOKEN=${{ steps.app-token.outputs.token }}" >> $GITHUB_ENV + - uses: stefanzweifel/git-auto-commit-action@v4 + id: empty-commit + with: + branch: tims-test-branch + commit_message: "${{ github.event.inputs.version }} release" + commit_options: "--allow-empty" + token: ${{ steps.app-token.outputs.token }} + # - name: Create empty commit in backup-utils + # id: empty-commit + # env: + # ACCESS_TOKEN: ${{ steps.app-token.outputs.token }} + # run: | + # git config user.name "release-controller[bot]" + # git config user.email "ghes-releases-team@github.com" + # git remote set-url origin https://$ACCESS_TOKEN@github.com/github/backup-utils.git + # git fetch origin tims-test-branch + # git checkout tims-test-branch + # git commit --allow-empty -m "${{ github.event.inputs.version }} release" + # git push origin tims-test-branch + # echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT # create tags for the build scripts to work # if empty_commit is successful, then echo success - name: Echo success - if: ${{ steps.empty_commit.outcome == 'success' }} + if: ${{ steps.empty-commit.outcome == 'success' }} run: | echo "empty commit successful" # - name: Create tag From 503bc849c12128f229c551859e57cf0e05f68a10 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 20:23:53 +0000 Subject: [PATCH 2232/2421] skip dirty check --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 6e252748d..1274a3f96 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -41,7 +41,7 @@ jobs: branch: tims-test-branch commit_message: "${{ github.event.inputs.version }} release" commit_options: "--allow-empty" - token: ${{ steps.app-token.outputs.token }} + skip_dirty_check: true # - name: Create empty commit in backup-utils # id: empty-commit # env: From 5525263ba915285967a54ddb1b016b1f87cc2500 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 21:01:39 +0000 Subject: [PATCH 2233/2421] another try --- .github/workflows/build-and-release.yml | 103 +++++++++--------------- 1 file changed, 38 insertions(+), 65 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 1274a3f96..59b6d5c68 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -4,6 +4,10 @@ name: Build and Release on: workflow_dispatch: inputs: + gh-token: + description: 'GitHub Token - used to create a commit in the backup-utils repo' + required: true + type: string version: description: 'Version - patch version of the release (e.g. x.y.z)' required: true @@ -31,37 +35,31 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - # set GITHUB_TOKEN to the app token - - name: Set GITHUB_TOKEN - run: | - echo "GITHUB_TOKEN=${{ steps.app-token.outputs.token }}" >> $GITHUB_ENV - - uses: stefanzweifel/git-auto-commit-action@v4 + ref: master + - name: Create empty commit in backup-utils id: empty-commit - with: - branch: tims-test-branch - commit_message: "${{ github.event.inputs.version }} release" - commit_options: "--allow-empty" - skip_dirty_check: true - # - name: Create empty commit in backup-utils - # id: empty-commit - # env: - # ACCESS_TOKEN: ${{ steps.app-token.outputs.token }} - # run: | - # git config user.name "release-controller[bot]" - # git config user.email "ghes-releases-team@github.com" - # git remote set-url origin https://$ACCESS_TOKEN@github.com/github/backup-utils.git - # git fetch origin tims-test-branch - # git checkout tims-test-branch - # git commit --allow-empty -m "${{ github.event.inputs.version }} release" - # git push origin tims-test-branch - # echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - # create tags for the build scripts to work - # if empty_commit is successful, then echo success - - name: Echo success - if: ${{ steps.empty-commit.outcome == 'success' }} run: | - echo "empty commit successful" - # - name: Create tag + git config user.name "timreimherr" + git config user.email "ghes-releases-team@github.com" + git fetch origin tims-test-branch + git checkout tims-test-branch + git commit --allow-empty -m "${{ github.event.inputs.version }} release" + git push origin tims-test-branch + echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + - name: Echo Success if commit was created + if: steps.empty-commit.outputs.commit-sha != '' + run: | + echo "Success" + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils-private + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip + # - name: Create tag # this is required for the build scripts # run: | # git config user.name "release-controller[bot]" # git config user.email "ghes-releases-team@github.com" @@ -97,38 +95,31 @@ jobs: # needs: build # runs-on: ubuntu-latest # outputs: - # commit-sha: ${{ steps.empty_commit.outputs.commit_sha }} + # commit-sha: ${{ steps.empty-commit.outputs.commit-sha }} # steps: # - uses: timreimherr/create-github-app-token@main # id: app-token # with: - # # required # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} # owner: ${{ github.repository_owner }} - # repositories: | - # github/backup-utils - # github/backup-utils-private - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils-private - # path: backup-utils-private + # repositories: backup-utils,backup-utils-private # - name: Checkout backup-utils # uses: actions/checkout@v4 # with: # token: ${{ steps.app-token.outputs.token }} # repository: github/backup-utils # ref: master - # path: backup-utils # - name: Create empty commit in backup-utils - # id: empty_commit + # id: empty-commit # run: | - # cp ./backup-utils-private/scripts/create-empty-commit \ - # .backup-utils/create-empty-commit - # cd ./backup-utils - # ./create-empty-commit + # git config user.name "release-controller[bot]" + # git config user.email "ghes-releases-team@github.com" + # git fetch origin tims-test-branch + # git checkout tims-test-branch + # git commit --allow-empty -m "${{ github.event.inputs.version }} release" + # git push origin tims-test-branch + # echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT # - name: Download deb artifact # uses: actions/download-artifact@v3 # with: @@ -151,7 +142,7 @@ jobs: # # this action will create a tag with this name on the provided commit # tag: v${{ github.event.inputs.version }} # # this can be a commit hash or branch name - # commit: ${{ steps.empty_commit.outputs.commit_sha }} + # commit: ${{ steps.empty-commit.outputs.commit_sha }} # bodyFile: release-notes/${{ github.event.inputs.version }}.md # draft: ${{ github.event.inputs.draft }} # allowUpdates: true @@ -160,21 +151,3 @@ jobs: - - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils-private - # path: backup-utils-private - # - name: Checkout backup-utils - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils - # ref: master - # path: backup-utils - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip \ No newline at end of file From bd8e4627f1ccd630fc66932427703e3e5f5536f1 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 21:16:33 +0000 Subject: [PATCH 2234/2421] again --- .github/workflows/build-and-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 59b6d5c68..29b3c42b1 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -44,7 +44,9 @@ jobs: git fetch origin tims-test-branch git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin tims-test-branch + # create string of usernma:token for git push + username-token="release-controller[bot]:${{ steps.app-token.outputs.token }}" + git push origin tims-test-branch https://$username-token@github.com/github/backup-utils.git echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Echo Success if commit was created if: steps.empty-commit.outputs.commit-sha != '' From 805ae189c5f4cc5668a462bb56ed5c8346074ea4 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 21:18:27 +0000 Subject: [PATCH 2235/2421] try again --- .github/workflows/build-and-release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 29b3c42b1..0933cdd3b 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -45,8 +45,7 @@ jobs: git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" # create string of usernma:token for git push - username-token="release-controller[bot]:${{ steps.app-token.outputs.token }}" - git push origin tims-test-branch https://$username-token@github.com/github/backup-utils.git + git push origin tims-test-branch "https://release-controller[bot]:${{ steps.app-token.outputs.token }}@github.com/github/backup-utils.git" echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Echo Success if commit was created if: steps.empty-commit.outputs.commit-sha != '' From 465d2e5b85e24758472dff182ded02f606c916e9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 21:26:53 +0000 Subject: [PATCH 2236/2421] aaand again --- .github/workflows/build-and-release.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 0933cdd3b..d5ec77ebf 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -39,13 +39,12 @@ jobs: - name: Create empty commit in backup-utils id: empty-commit run: | - git config user.name "timreimherr" - git config user.email "ghes-releases-team@github.com" + git config user.name "release-controller[bot]" + git config user.email "223695+release-controller[bot]@users.noreply.github.com" git fetch origin tims-test-branch git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" - # create string of usernma:token for git push - git push origin tims-test-branch "https://release-controller[bot]:${{ steps.app-token.outputs.token }}@github.com/github/backup-utils.git" + git push origin tims-test-branch echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Echo Success if commit was created if: steps.empty-commit.outputs.commit-sha != '' From 9ece7aec3b05bb97171093826def9c68954ff220 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 21:29:08 +0000 Subject: [PATCH 2237/2421] try url --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index d5ec77ebf..bcb927a60 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -44,7 +44,7 @@ jobs: git fetch origin tims-test-branch git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin tims-test-branch + git push origin tims-test-branch "https://release-controller%5Bbot%5D:${{ steps.app-token.outputs.token }}@github.com/github/backup-utils.git" echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Echo Success if commit was created if: steps.empty-commit.outputs.commit-sha != '' From 5c42fc25d859052161835da75db6c2ffd6901528 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 21:42:59 +0000 Subject: [PATCH 2238/2421] try pat token to create empty commit in backup-utils --- .github/workflows/build-and-release.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index bcb927a60..9425b5f99 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -22,18 +22,18 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: timreimherr/create-github-app-token@main - id: app-token - with: - # required - app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: backup-utils,backup-utils-private + # - uses: timreimherr/create-github-app-token@main + # id: app-token + # with: + # # required + # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: backup-utils,backup-utils-private - name: Checkout backup-utils uses: actions/checkout@v4 with: - token: ${{ steps.app-token.outputs.token }} + token: ${{ github.event.inputs.gh-token }} repository: github/backup-utils ref: master - name: Create empty commit in backup-utils @@ -44,7 +44,7 @@ jobs: git fetch origin tims-test-branch git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin tims-test-branch "https://release-controller%5Bbot%5D:${{ steps.app-token.outputs.token }}@github.com/github/backup-utils.git" + git push origin tims-test-branch echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Echo Success if commit was created if: steps.empty-commit.outputs.commit-sha != '' From f128423668ff5e78619e554fe9c7e9bc6446f1e9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 21:49:14 +0000 Subject: [PATCH 2239/2421] try on master --- .github/workflows/build-and-release.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 9425b5f99..308d7fd6a 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -41,8 +41,6 @@ jobs: run: | git config user.name "release-controller[bot]" git config user.email "223695+release-controller[bot]@users.noreply.github.com" - git fetch origin tims-test-branch - git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" git push origin tims-test-branch echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT From 2b8e2d4adfe8679de8b5c8057380a8e2d07ec430 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 25 Sep 2023 21:50:34 +0000 Subject: [PATCH 2240/2421] fix push command --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 308d7fd6a..fe8d363a4 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -42,7 +42,7 @@ jobs: git config user.name "release-controller[bot]" git config user.email "223695+release-controller[bot]@users.noreply.github.com" git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin tims-test-branch + git push origin master echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Echo Success if commit was created if: steps.empty-commit.outputs.commit-sha != '' From cafd7ae8579fcd96cddc494e99fa6130f42eb693 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 14:51:30 +0000 Subject: [PATCH 2241/2421] use PAT token for now --- .github/workflows/build-and-release.yml | 189 +++++++++++------------- 1 file changed, 85 insertions(+), 104 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index fe8d363a4..2bd6dab2f 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -22,6 +22,7 @@ jobs: build: runs-on: ubuntu-latest steps: + # this token still gets denied by the backup-utils repo # - uses: timreimherr/create-github-app-token@main # id: app-token # with: @@ -30,121 +31,101 @@ jobs: # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} # owner: ${{ github.repository_owner }} # repositories: backup-utils,backup-utils-private - - name: Checkout backup-utils + - name: Checkout backup-utils-private uses: actions/checkout@v4 with: token: ${{ github.event.inputs.gh-token }} + repository: github/backup-utils-private + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag # this is required for the build scripts + run: | + git config user.name "${{ github.actor }}" + git config user.email "ghes-releases-team@github.com" + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + - name: Package deb + run: | + ./script/package-deb + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + release: + needs: build + runs-on: ubuntu-latest + outputs: + commit-sha: ${{ steps.empty-commit.outputs.commit-sha }} + steps: + # this token still gets denied by the backup-utils repo + # - uses: timreimherr/create-github-app-token@main + # id: app-token + # with: + # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: backup-utils,backup-utils-private + - name: Checkout backup-utils + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils ref: master - name: Create empty commit in backup-utils id: empty-commit run: | - git config user.name "release-controller[bot]" - git config user.email "223695+release-controller[bot]@users.noreply.github.com" + git config user.name "${{ github.actor }}" + git config user.email "ghes-releases-team@github.com" git commit --allow-empty -m "${{ github.event.inputs.version }} release" git push origin master echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - - name: Echo Success if commit was created - if: steps.empty-commit.outputs.commit-sha != '' - run: | - echo "Success" - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils-private - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # - name: Create tag # this is required for the build scripts - # run: | - # git config user.name "release-controller[bot]" - # git config user.email "ghes-releases-team@github.com" - # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - # git push origin "v${{ github.event.inputs.version }}" - # - name: Package deb - # run: | - # ./script/package-deb - # # many need to remove this once release-notes compilation is automated - # - name: Rename deb artifact - # run: | - # for file in dist/github-backup-utils_*_all.deb; do - # if [[ -f "$file" ]]; then - # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - # fi - # done - # - name: Upload deb artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # path: | - # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Package tarball - # run: | - # ./script/package-tarball - # - name: Upload tarball artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # path: | - # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # release: - # needs: build - # runs-on: ubuntu-latest - # outputs: - # commit-sha: ${{ steps.empty-commit.outputs.commit-sha }} - # steps: - # - uses: timreimherr/create-github-app-token@main - # id: app-token - # with: - # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: backup-utils,backup-utils-private - # - name: Checkout backup-utils - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils - # ref: master - # - name: Create empty commit in backup-utils - # id: empty-commit - # run: | - # git config user.name "release-controller[bot]" - # git config user.email "ghes-releases-team@github.com" - # git fetch origin tims-test-branch - # git checkout tims-test-branch - # git commit --allow-empty -m "${{ github.event.inputs.version }} release" - # git push origin tims-test-branch - # echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - # - name: Download deb artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Download tarball artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # - name: Create Release - # uses: ncipollo/release-action@v1 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repo: backup-utils - # name: | - # GitHub Enterprise Server Backup Utilities - # v${{ github.event.inputs.version }} - # artifacts: | - # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - # github-backup-utils_${{ github.event.inputs.version }}_all.deb - # # this action will create a tag with this name on the provided commit - # tag: v${{ github.event.inputs.version }} - # # this can be a commit hash or branch name - # commit: ${{ steps.empty-commit.outputs.commit_sha }} - # bodyFile: release-notes/${{ github.event.inputs.version }}.md - # draft: ${{ github.event.inputs.draft }} - # allowUpdates: true - # artifactContentType: "raw" + - name: Download deb artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Download tarball artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Create Release + uses: ncipollo/release-action@v1 + with: + token: ${{ github.event.inputs.gh-token }} + repo: backup-utils + name: | + GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} + artifacts: | + github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + github-backup-utils_${{ github.event.inputs.version }}_all.deb + # this action will create a tag with this name on the provided commit + tag: v${{ github.event.inputs.version }} + # this can be a commit hash or branch name + commit: ${{ steps.empty-commit.outputs.commit-sha }} + bodyFile: release-notes/${{ github.event.inputs.version }}.md + draft: ${{ github.event.inputs.draft }} + allowUpdates: true + artifactContentType: "raw" From 2f709371d6e805d3d96382528fbbafb9d5b91d2e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 15:04:42 +0000 Subject: [PATCH 2242/2421] one more test --- .github/workflows/build-and-release.yml | 210 +++++++++++++----------- 1 file changed, 118 insertions(+), 92 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 2bd6dab2f..e54690a21 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -22,110 +22,136 @@ jobs: build: runs-on: ubuntu-latest steps: - # this token still gets denied by the backup-utils repo - # - uses: timreimherr/create-github-app-token@main - # id: app-token - # with: - # # required - # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: backup-utils,backup-utils-private - - name: Checkout backup-utils-private - uses: actions/checkout@v4 + - uses: timreimherr/create-github-app-token@main + id: app-token with: - token: ${{ github.event.inputs.gh-token }} - repository: github/backup-utils-private - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag # this is required for the build scripts - run: | - git config user.name "${{ github.actor }}" - git config user.email "ghes-releases-team@github.com" - git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Package deb - run: | - ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - - name: Upload deb artifact - uses: actions/upload-artifact@v3 + # required + app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: backup-utils,backup-utils-private + - name: Checkout backup-utils + uses: actions/checkout@v4 with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils + # the auto-commit action uses the GITHUB_TOKEN to create the commit + - name: Set GITHUB_TOKEN run: | - ./script/package-tarball - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 + echo "GITHUB_TOKEN=${{ steps.app-token.outputs.token }}" >> $GITHUB_ENV + - uses: stefanzweifel/git-auto-commit-action@v4 + id: empty-commit with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - release: - needs: build - runs-on: ubuntu-latest - outputs: - commit-sha: ${{ steps.empty-commit.outputs.commit-sha }} - steps: + branch: master + commit_message: "${{ github.event.inputs.version }} release" + commit_user_name: "${{ github.actor }}" + commit_user_email: "ghes-releases-team@github.com" + commit_options: "--allow-empty" + skip_dirty_check: true # this token still gets denied by the backup-utils repo # - uses: timreimherr/create-github-app-token@main # id: app-token # with: + # # required # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} # owner: ${{ github.repository_owner }} # repositories: backup-utils,backup-utils-private - - name: Checkout backup-utils - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - repository: github/backup-utils - ref: master - - name: Create empty commit in backup-utils - id: empty-commit - run: | - git config user.name "${{ github.actor }}" - git config user.email "ghes-releases-team@github.com" - git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin master - echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - - name: Download deb artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Download tarball artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - - name: Create Release - uses: ncipollo/release-action@v1 - with: - token: ${{ github.event.inputs.gh-token }} - repo: backup-utils - name: | - GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - artifacts: | - github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - github-backup-utils_${{ github.event.inputs.version }}_all.deb - # this action will create a tag with this name on the provided commit - tag: v${{ github.event.inputs.version }} - # this can be a commit hash or branch name - commit: ${{ steps.empty-commit.outputs.commit-sha }} - bodyFile: release-notes/${{ github.event.inputs.version }}.md - draft: ${{ github.event.inputs.draft }} - allowUpdates: true - artifactContentType: "raw" + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ github.event.inputs.gh-token }} + # repository: github/backup-utils-private + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip + # - name: Create tag # this is required for the build scripts + # run: | + # git config user.name "${{ github.actor }}" + # git config user.email "ghes-releases-team@github.com" + # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + # git push origin "v${{ github.event.inputs.version }}" + # - name: Package deb + # run: | + # ./script/package-deb + # # many need to remove this once release-notes compilation is automated + # - name: Rename deb artifact + # run: | + # for file in dist/github-backup-utils_*_all.deb; do + # if [[ -f "$file" ]]; then + # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + # fi + # done + # - name: Upload deb artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # path: | + # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Package tarball + # run: | + # ./script/package-tarball + # - name: Upload tarball artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # path: | + # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # release: + # needs: build + # runs-on: ubuntu-latest + # outputs: + # commit-sha: ${{ steps.empty-commit.outputs.commit-sha }} + # steps: + # # this token still gets denied by the backup-utils repo + # # - uses: timreimherr/create-github-app-token@main + # # id: app-token + # # with: + # # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # # owner: ${{ github.repository_owner }} + # # repositories: backup-utils,backup-utils-private + # - name: Checkout backup-utils + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils + # ref: master + # - name: Create empty commit in backup-utils + # id: empty-commit + # run: | + # git config user.name "${{ github.actor }}" + # git config user.email "ghes-releases-team@github.com" + # git commit --allow-empty -m "${{ github.event.inputs.version }} release" + # git push origin master + # echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + # - name: Download deb artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Download tarball artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # - name: Create Release + # uses: ncipollo/release-action@v1 + # with: + # token: ${{ github.event.inputs.gh-token }} + # repo: backup-utils + # name: | + # GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} + # artifacts: | + # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + # github-backup-utils_${{ github.event.inputs.version }}_all.deb + # # this action will create a tag with this name on the provided commit + # tag: v${{ github.event.inputs.version }} + # # this can be a commit hash or branch name + # commit: ${{ steps.empty-commit.outputs.commit-sha }} + # bodyFile: release-notes/${{ github.event.inputs.version }}.md + # draft: ${{ github.event.inputs.draft }} + # allowUpdates: true + # artifactContentType: "raw" From 658bd0eb3866404096636c23eb656660e5d738b8 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 15:08:43 +0000 Subject: [PATCH 2243/2421] test use PAT token --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index e54690a21..2d7f41f4a 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -38,7 +38,7 @@ jobs: # the auto-commit action uses the GITHUB_TOKEN to create the commit - name: Set GITHUB_TOKEN run: | - echo "GITHUB_TOKEN=${{ steps.app-token.outputs.token }}" >> $GITHUB_ENV + echo "GITHUB_TOKEN=${{ github.event.inputs.gh-token }}" >> $GITHUB_ENV - uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: From 19482957a0ef46ddf6f40ce01a6875d075ac5e9e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 15:11:52 +0000 Subject: [PATCH 2244/2421] add tag message --- .github/workflows/build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 2d7f41f4a..f366daac0 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -47,6 +47,7 @@ jobs: commit_user_name: "${{ github.actor }}" commit_user_email: "ghes-releases-team@github.com" commit_options: "--allow-empty" + tag_message: "v${{ github.event.inputs.version }}" skip_dirty_check: true # this token still gets denied by the backup-utils repo # - uses: timreimherr/create-github-app-token@main From 7d3c54d815256d4763f1b3231dd2ff16f59a88a8 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 15:16:24 +0000 Subject: [PATCH 2245/2421] uses the checkout git config, I thiink --- .github/workflows/build-and-release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index f366daac0..93243258a 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -33,12 +33,12 @@ jobs: - name: Checkout backup-utils uses: actions/checkout@v4 with: - token: ${{ steps.app-token.outputs.token }} + token: ${{ github.event.inputs.gh-token }} repository: github/backup-utils # the auto-commit action uses the GITHUB_TOKEN to create the commit - - name: Set GITHUB_TOKEN - run: | - echo "GITHUB_TOKEN=${{ github.event.inputs.gh-token }}" >> $GITHUB_ENV + # - name: Set GITHUB_TOKEN + # run: | + # echo "GITHUB_TOKEN=${{ github.event.inputs.gh-token }}" >> $GITHUB_ENV - uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: From c4ef0d6074f166a2464f2e5a72c3bfd1f4f1780e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 15:29:00 +0000 Subject: [PATCH 2246/2421] setup for PAT token --- .github/workflows/build-and-release.yml | 209 +++++++++++------------- 1 file changed, 92 insertions(+), 117 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 93243258a..6293acc89 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -22,24 +22,78 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: timreimherr/create-github-app-token@main - id: app-token + # # resulting token still gets denied by the backup-utils repo + # - uses: timreimherr/create-github-app-token@main + # id: app-token + # with: + # # required + # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: backup-utils,backup-utils-private + - name: Checkout backup-utils-private + uses: actions/checkout@v4 with: - # required - app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: backup-utils,backup-utils-private + token: ${{ github.event.inputs.gh-token }} + repository: github/backup-utils-private + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag # this is required for the build scripts + run: | + git config user.name "${{ github.actor }}" + git config user.email "ghes-releases-team@github.com" + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + - name: Package deb + run: | + ./script/package-deb + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + release: + needs: build + runs-on: ubuntu-latest + outputs: + commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} + steps: + # resulting token still gets denied by the backup-utils repo + # - uses: timreimherr/create-github-app-token@main + # id: app-token + # with: + # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: backup-utils,backup-utils-private - name: Checkout backup-utils uses: actions/checkout@v4 with: token: ${{ github.event.inputs.gh-token }} repository: github/backup-utils - # the auto-commit action uses the GITHUB_TOKEN to create the commit - # - name: Set GITHUB_TOKEN - # run: | - # echo "GITHUB_TOKEN=${{ github.event.inputs.gh-token }}" >> $GITHUB_ENV - - uses: stefanzweifel/git-auto-commit-action@v4 + ref: master + - name: Create empty commit + uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: branch: master @@ -47,112 +101,33 @@ jobs: commit_user_name: "${{ github.actor }}" commit_user_email: "ghes-releases-team@github.com" commit_options: "--allow-empty" - tag_message: "v${{ github.event.inputs.version }}" skip_dirty_check: true - # this token still gets denied by the backup-utils repo - # - uses: timreimherr/create-github-app-token@main - # id: app-token - # with: - # # required - # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: backup-utils,backup-utils-private - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ github.event.inputs.gh-token }} - # repository: github/backup-utils-private - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # - name: Create tag # this is required for the build scripts - # run: | - # git config user.name "${{ github.actor }}" - # git config user.email "ghes-releases-team@github.com" - # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - # git push origin "v${{ github.event.inputs.version }}" - # - name: Package deb - # run: | - # ./script/package-deb - # # many need to remove this once release-notes compilation is automated - # - name: Rename deb artifact - # run: | - # for file in dist/github-backup-utils_*_all.deb; do - # if [[ -f "$file" ]]; then - # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - # fi - # done - # - name: Upload deb artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # path: | - # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Package tarball - # run: | - # ./script/package-tarball - # - name: Upload tarball artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # path: | - # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # release: - # needs: build - # runs-on: ubuntu-latest - # outputs: - # commit-sha: ${{ steps.empty-commit.outputs.commit-sha }} - # steps: - # # this token still gets denied by the backup-utils repo - # # - uses: timreimherr/create-github-app-token@main - # # id: app-token - # # with: - # # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # # owner: ${{ github.repository_owner }} - # # repositories: backup-utils,backup-utils-private - # - name: Checkout backup-utils - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils - # ref: master - # - name: Create empty commit in backup-utils - # id: empty-commit - # run: | - # git config user.name "${{ github.actor }}" - # git config user.email "ghes-releases-team@github.com" - # git commit --allow-empty -m "${{ github.event.inputs.version }} release" - # git push origin master - # echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - # - name: Download deb artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Download tarball artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # - name: Create Release - # uses: ncipollo/release-action@v1 - # with: - # token: ${{ github.event.inputs.gh-token }} - # repo: backup-utils - # name: | - # GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - # artifacts: | - # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - # github-backup-utils_${{ github.event.inputs.version }}_all.deb - # # this action will create a tag with this name on the provided commit - # tag: v${{ github.event.inputs.version }} - # # this can be a commit hash or branch name - # commit: ${{ steps.empty-commit.outputs.commit-sha }} - # bodyFile: release-notes/${{ github.event.inputs.version }}.md - # draft: ${{ github.event.inputs.draft }} - # allowUpdates: true - # artifactContentType: "raw" + - name: Download deb artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Download tarball artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Create Release + uses: ncipollo/release-action@v1 + with: + token: ${{ github.event.inputs.gh-token }} + repo: backup-utils + name: | + GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} + artifacts: | + github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + github-backup-utils_${{ github.event.inputs.version }}_all.deb + # this action will create a tag with this name on the provided commit + tag: v${{ github.event.inputs.version }} + # this can be a commit hash or branch name + commit: ${{ steps.empty-commit.outputs.commit_hash }} + bodyFile: release-notes/${{ github.event.inputs.version }}.md + draft: ${{ github.event.inputs.draft }} + allowUpdates: true + artifactContentType: "raw" From 9848e0f956f93de210969095977071ef27fdcd48 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 15:43:14 +0000 Subject: [PATCH 2247/2421] fix yaml lint config --- .github/linters/.yaml-lint.yml | 72 +++++++++++++++++----------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml index 0f3e1154b..030c37f04 100644 --- a/.github/linters/.yaml-lint.yml +++ b/.github/linters/.yaml-lint.yml @@ -7,47 +7,47 @@ # # yamllint disable-line # ########################################### rules: - braces: disable - # level: warning - # min-spaces-inside: 0 - # max-spaces-inside: 0 - # min-spaces-inside-empty: 1 - # max-spaces-inside-empty: 5 - brackets: disable - # level: warning - # min-spaces-inside: 0 - # max-spaces-inside: 0 - # min-spaces-inside-empty: 1 - # max-spaces-inside-empty: 5 - colons: disable - # level: warning - # max-spaces-before: 0 - # max-spaces-after: 1 - commas: disable - # level: warning - # max-spaces-before: 0 - # min-spaces-after: 1 - # max-spaces-after: 1 + braces: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + brackets: + level: warning + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: 1 + max-spaces-inside-empty: 5 + colons: + level: warning + max-spaces-before: 0 + max-spaces-after: 1 + commas: + level: warning + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 comments: disable comments-indentation: disable document-end: disable document-start: disable - empty-lines: disable - # level: warning - # max: 2 - # max-start: 0 - # max-end: 0 - hyphens: disable - # level: warning - # max-spaces-after: 1 - indentation: disable - # level: warning - # spaces: consistent - # indent-sequences: true - # check-multi-line-strings: false + empty-lines: + level: warning + max: 2 + max-start: 0 + max-end: 0 + hyphens: + level: warning + max-spaces-after: 1 + indentation: + level: warning + spaces: consistent + indent-sequences: true + check-multi-line-strings: false key-duplicates: enable line-length: disable new-line-at-end-of-file: disable - new-lines: diable - # type: unix + new-lines: + type: unix trailing-spaces: disable \ No newline at end of file From ddd2752a920e66d9d545e1367aa010ab8f1d7ff5 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 15:47:11 +0000 Subject: [PATCH 2248/2421] clean up --- .github/workflows/build-and-release.yml | 6 +++--- script/create-empty-commit | 14 -------------- 2 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 script/create-empty-commit diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 6293acc89..c76c0efe8 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -22,7 +22,8 @@ jobs: build: runs-on: ubuntu-latest steps: - # # resulting token still gets denied by the backup-utils repo + # resulting token still gets denied by the backup-utils repo + # see: https://github.com/actions/create-github-app-token/pull/46 # - uses: timreimherr/create-github-app-token@main # id: app-token # with: @@ -79,6 +80,7 @@ jobs: commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} steps: # resulting token still gets denied by the backup-utils repo + # see: https://github.com/actions/create-github-app-token/pull/46 # - uses: timreimherr/create-github-app-token@main # id: app-token # with: @@ -120,9 +122,7 @@ jobs: artifacts: | github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ github-backup-utils_${{ github.event.inputs.version }}_all.deb - # this action will create a tag with this name on the provided commit tag: v${{ github.event.inputs.version }} - # this can be a commit hash or branch name commit: ${{ steps.empty-commit.outputs.commit_hash }} bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} diff --git a/script/create-empty-commit b/script/create-empty-commit deleted file mode 100644 index 7f69449a9..000000000 --- a/script/create-empty-commit +++ /dev/null @@ -1,14 +0,0 @@ -#!/ust/bin/env bash -# Usage: script/create-empty-commit -# Script to create an empty commit on the current branch. -# This is used to create a new tag for a release in github/backup-utils. -# This is to avoid stacking multiple release tags on the same commit. -set -e - -git config user.name "release-controller[bot]" -git config user.email "ghes-releases-team@github.com" -git fetch origin tims-test-branch -git checkout tims-test-branch -git commit --allow-empty -m "${{ github.event.inputs.version }} release" -git push origin tims-test-branch -echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT \ No newline at end of file From 765260fb48e7f0ec4ca33c4ab501537d365d04b8 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 16:04:16 +0000 Subject: [PATCH 2249/2421] see token permissions --- .github/workflows/build-and-release.yml | 207 ++++++++++++------------ 1 file changed, 105 insertions(+), 102 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c76c0efe8..18ce48189 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -24,110 +24,113 @@ jobs: steps: # resulting token still gets denied by the backup-utils repo # see: https://github.com/actions/create-github-app-token/pull/46 - # - uses: timreimherr/create-github-app-token@main - # id: app-token - # with: - # # required - # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: backup-utils,backup-utils-private - - name: Checkout backup-utils-private - uses: actions/checkout@v4 + - uses: timreimherr/create-github-app-token@main + id: app-token with: - token: ${{ github.event.inputs.gh-token }} - repository: github/backup-utils-private - - name: Install dependencies + # required + app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: backup-utils,backup-utils-private + - name: Print app permissions run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag # this is required for the build scripts - run: | - git config user.name "${{ github.actor }}" - git config user.email "ghes-releases-team@github.com" - git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Package deb - run: | - ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - - name: Upload deb artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - release: - needs: build - runs-on: ubuntu-latest - outputs: - commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} - steps: - # resulting token still gets denied by the backup-utils repo - # see: https://github.com/actions/create-github-app-token/pull/46 - # - uses: timreimherr/create-github-app-token@main - # id: app-token - # with: - # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: backup-utils,backup-utils-private - - name: Checkout backup-utils - uses: actions/checkout@v4 - with: - token: ${{ github.event.inputs.gh-token }} - repository: github/backup-utils - ref: master - - name: Create empty commit - uses: stefanzweifel/git-auto-commit-action@v4 - id: empty-commit - with: - branch: master - commit_message: "${{ github.event.inputs.version }} release" - commit_user_name: "${{ github.actor }}" - commit_user_email: "ghes-releases-team@github.com" - commit_options: "--allow-empty" - skip_dirty_check: true - - name: Download deb artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Download tarball artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - - name: Create Release - uses: ncipollo/release-action@v1 - with: - token: ${{ github.event.inputs.gh-token }} - repo: backup-utils - name: | - GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - artifacts: | - github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - github-backup-utils_${{ github.event.inputs.version }}_all.deb - tag: v${{ github.event.inputs.version }} - commit: ${{ steps.empty-commit.outputs.commit_hash }} - bodyFile: release-notes/${{ github.event.inputs.version }}.md - draft: ${{ github.event.inputs.draft }} - allowUpdates: true - artifactContentType: "raw" + curl -H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations | jq '.[] | {permissions: .permissions, target_type: .target_type, repository_selection: .repository_selection}' + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ github.event.inputs.gh-token }} + # repository: github/backup-utils-private + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip + # - name: Create tag # this is required for the build scripts + # run: | + # git config user.name "${{ github.actor }}" + # git config user.email "ghes-releases-team@github.com" + # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + # git push origin "v${{ github.event.inputs.version }}" + # - name: Package deb + # run: | + # ./script/package-deb + # # many need to remove this once release-notes compilation is automated + # - name: Rename deb artifact + # run: | + # for file in dist/github-backup-utils_*_all.deb; do + # if [[ -f "$file" ]]; then + # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + # fi + # done + # - name: Upload deb artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # path: | + # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Package tarball + # run: | + # ./script/package-tarball + # - name: Upload tarball artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # path: | + # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # release: + # needs: build + # runs-on: ubuntu-latest + # outputs: + # commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} + # steps: + # # resulting token still gets denied by the backup-utils repo + # # see: https://github.com/actions/create-github-app-token/pull/46 + # # - uses: timreimherr/create-github-app-token@main + # # id: app-token + # # with: + # # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # # owner: ${{ github.repository_owner }} + # # repositories: backup-utils,backup-utils-private + # - name: Checkout backup-utils + # uses: actions/checkout@v4 + # with: + # token: ${{ github.event.inputs.gh-token }} + # repository: github/backup-utils + # ref: master + # - name: Create empty commit + # uses: stefanzweifel/git-auto-commit-action@v4 + # id: empty-commit + # with: + # branch: master + # commit_message: "${{ github.event.inputs.version }} release" + # commit_user_name: "${{ github.actor }}" + # commit_user_email: "ghes-releases-team@github.com" + # commit_options: "--allow-empty" + # skip_dirty_check: true + # - name: Download deb artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Download tarball artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # - name: Create Release + # uses: ncipollo/release-action@v1 + # with: + # token: ${{ github.event.inputs.gh-token }} + # repo: backup-utils + # name: | + # GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} + # artifacts: | + # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + # github-backup-utils_${{ github.event.inputs.version }}_all.deb + # tag: v${{ github.event.inputs.version }} + # commit: ${{ steps.empty-commit.outputs.commit_hash }} + # bodyFile: release-notes/${{ github.event.inputs.version }}.md + # draft: ${{ github.event.inputs.draft }} + # allowUpdates: true + # artifactContentType: "raw" From 6a7a213d68b5d0ab4772c33603a17c8faa625e6b Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 16:07:25 +0000 Subject: [PATCH 2250/2421] fix curl command output --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 18ce48189..d0b64fb37 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -34,7 +34,7 @@ jobs: repositories: backup-utils,backup-utils-private - name: Print app permissions run: | - curl -H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations | jq '.[] | {permissions: .permissions, target_type: .target_type, repository_selection: .repository_selection}' + curl -H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations | jq '.installations[] | {permissions: .permissions, target_type: .target_type, repository_selection: .repository_selection}' # - name: Checkout backup-utils-private # uses: actions/checkout@v4 # with: From 1dff7ccc4b30c00000b5e60d812fbe078b29e93a Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 16:11:03 +0000 Subject: [PATCH 2251/2421] print entire response --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index d0b64fb37..f95c6f5f0 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -34,7 +34,7 @@ jobs: repositories: backup-utils,backup-utils-private - name: Print app permissions run: | - curl -H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations | jq '.installations[] | {permissions: .permissions, target_type: .target_type, repository_selection: .repository_selection}' + curl -H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations | jq '.' # - name: Checkout backup-utils-private # uses: actions/checkout@v4 # with: From eadb37ea851e011ececa059a28facbd01181939e Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:20:21 -0600 Subject: [PATCH 2252/2421] Update integration-tests.yml --- .github/workflows/integration-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index f48de957e..efdd23ebe 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -7,10 +7,10 @@ on: workflow_dispatch: inputs: target-branch: - description: 'Branch that would be merged into' + description: 'enterprise2 branch to test against' required: true source-branch: - description: 'Branch that would be merged' + description: 'backup-utils-private topic branch to test' required: true # Get target and source branch from different variables depending on how it was triggered From 15397574469a5c89483e677787343b7d0dee5e50 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 16:21:00 +0000 Subject: [PATCH 2253/2421] another test --- .github/workflows/build-and-release.yml | 36 ++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index f95c6f5f0..0a48f9518 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -22,8 +22,6 @@ jobs: build: runs-on: ubuntu-latest steps: - # resulting token still gets denied by the backup-utils repo - # see: https://github.com/actions/create-github-app-token/pull/46 - uses: timreimherr/create-github-app-token@main id: app-token with: @@ -32,9 +30,39 @@ jobs: private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: backup-utils,backup-utils-private - - name: Print app permissions + - name: Checkout backup-utils + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils + ref: master + - name: Create empty commit in backup-utils + id: empty-commit run: | - curl -H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations | jq '.' + git config user.name "release-controller[bot]" + git config user.email "223695+release-controller[bot]@users.noreply.github.com" + git fetch origin tims-test-branch + git checkout tims-test-branch + git commit --allow-empty -m "${{ github.event.inputs.version }} release" + git push origin tims-test-branch "https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/github/backup-utils.git" + echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT + - name: Echo Success if commit was created + if: steps.empty-commit.outputs.commit-sha != '' + run: | + echo "Success" + # resulting token still gets denied by the backup-utils repo + # see: https://github.com/actions/create-github-app-token/pull/46 + # - uses: timreimherr/create-github-app-token@main + # id: app-token + # with: + # # required + # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: backup-utils,backup-utils-private + # - name: Print app permissions + # run: | + # curl -H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations | jq '.' # - name: Checkout backup-utils-private # uses: actions/checkout@v4 # with: From f8685a4926f57a7b3561cf28099906317cae801e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 16:23:31 +0000 Subject: [PATCH 2254/2421] try another approach --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 0a48f9518..7a47b6cb2 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -44,7 +44,7 @@ jobs: git fetch origin tims-test-branch git checkout tims-test-branch git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push origin tims-test-branch "https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/github/backup-utils.git" + git push "https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/github/backup-utils.git" tims-test-branch echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - name: Echo Success if commit was created if: steps.empty-commit.outputs.commit-sha != '' From 266760134d051101580d55784163310e050f749c Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 17:39:46 +0000 Subject: [PATCH 2255/2421] clean up --- .github/workflows/build-and-release.yml | 217 ++++++++++-------------- 1 file changed, 93 insertions(+), 124 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 7a47b6cb2..c76c0efe8 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -22,143 +22,112 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: timreimherr/create-github-app-token@main - id: app-token - with: - # required - app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: backup-utils,backup-utils-private - - name: Checkout backup-utils + # resulting token still gets denied by the backup-utils repo + # see: https://github.com/actions/create-github-app-token/pull/46 + # - uses: timreimherr/create-github-app-token@main + # id: app-token + # with: + # # required + # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: backup-utils,backup-utils-private + - name: Checkout backup-utils-private uses: actions/checkout@v4 with: - token: ${{ steps.app-token.outputs.token }} - repository: github/backup-utils - ref: master - - name: Create empty commit in backup-utils - id: empty-commit + token: ${{ github.event.inputs.gh-token }} + repository: github/backup-utils-private + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag # this is required for the build scripts + run: | + git config user.name "${{ github.actor }}" + git config user.email "ghes-releases-team@github.com" + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + - name: Package deb run: | - git config user.name "release-controller[bot]" - git config user.email "223695+release-controller[bot]@users.noreply.github.com" - git fetch origin tims-test-branch - git checkout tims-test-branch - git commit --allow-empty -m "${{ github.event.inputs.version }} release" - git push "https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/github/backup-utils.git" tims-test-branch - echo "commit-sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT - - name: Echo Success if commit was created - if: steps.empty-commit.outputs.commit-sha != '' + ./script/package-deb + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact run: | - echo "Success" + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + release: + needs: build + runs-on: ubuntu-latest + outputs: + commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} + steps: # resulting token still gets denied by the backup-utils repo # see: https://github.com/actions/create-github-app-token/pull/46 # - uses: timreimherr/create-github-app-token@main # id: app-token # with: - # # required # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} # owner: ${{ github.repository_owner }} # repositories: backup-utils,backup-utils-private - # - name: Print app permissions - # run: | - # curl -H "Authorization: Bearer ${{ steps.app-token.outputs.token }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/app/installations | jq '.' - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ github.event.inputs.gh-token }} - # repository: github/backup-utils-private - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # - name: Create tag # this is required for the build scripts - # run: | - # git config user.name "${{ github.actor }}" - # git config user.email "ghes-releases-team@github.com" - # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - # git push origin "v${{ github.event.inputs.version }}" - # - name: Package deb - # run: | - # ./script/package-deb - # # many need to remove this once release-notes compilation is automated - # - name: Rename deb artifact - # run: | - # for file in dist/github-backup-utils_*_all.deb; do - # if [[ -f "$file" ]]; then - # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - # fi - # done - # - name: Upload deb artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # path: | - # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Package tarball - # run: | - # ./script/package-tarball - # - name: Upload tarball artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # path: | - # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # release: - # needs: build - # runs-on: ubuntu-latest - # outputs: - # commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} - # steps: - # # resulting token still gets denied by the backup-utils repo - # # see: https://github.com/actions/create-github-app-token/pull/46 - # # - uses: timreimherr/create-github-app-token@main - # # id: app-token - # # with: - # # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # # owner: ${{ github.repository_owner }} - # # repositories: backup-utils,backup-utils-private - # - name: Checkout backup-utils - # uses: actions/checkout@v4 - # with: - # token: ${{ github.event.inputs.gh-token }} - # repository: github/backup-utils - # ref: master - # - name: Create empty commit - # uses: stefanzweifel/git-auto-commit-action@v4 - # id: empty-commit - # with: - # branch: master - # commit_message: "${{ github.event.inputs.version }} release" - # commit_user_name: "${{ github.actor }}" - # commit_user_email: "ghes-releases-team@github.com" - # commit_options: "--allow-empty" - # skip_dirty_check: true - # - name: Download deb artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Download tarball artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # - name: Create Release - # uses: ncipollo/release-action@v1 - # with: - # token: ${{ github.event.inputs.gh-token }} - # repo: backup-utils - # name: | - # GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - # artifacts: | - # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - # github-backup-utils_${{ github.event.inputs.version }}_all.deb - # tag: v${{ github.event.inputs.version }} - # commit: ${{ steps.empty-commit.outputs.commit_hash }} - # bodyFile: release-notes/${{ github.event.inputs.version }}.md - # draft: ${{ github.event.inputs.draft }} - # allowUpdates: true - # artifactContentType: "raw" + - name: Checkout backup-utils + uses: actions/checkout@v4 + with: + token: ${{ github.event.inputs.gh-token }} + repository: github/backup-utils + ref: master + - name: Create empty commit + uses: stefanzweifel/git-auto-commit-action@v4 + id: empty-commit + with: + branch: master + commit_message: "${{ github.event.inputs.version }} release" + commit_user_name: "${{ github.actor }}" + commit_user_email: "ghes-releases-team@github.com" + commit_options: "--allow-empty" + skip_dirty_check: true + - name: Download deb artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Download tarball artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Create Release + uses: ncipollo/release-action@v1 + with: + token: ${{ github.event.inputs.gh-token }} + repo: backup-utils + name: | + GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} + artifacts: | + github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + github-backup-utils_${{ github.event.inputs.version }}_all.deb + tag: v${{ github.event.inputs.version }} + commit: ${{ steps.empty-commit.outputs.commit_hash }} + bodyFile: release-notes/${{ github.event.inputs.version }}.md + draft: ${{ github.event.inputs.draft }} + allowUpdates: true + artifactContentType: "raw" From 43a3a1bc8d953f3b69055e36865ed399ecd9d662 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 18:17:22 +0000 Subject: [PATCH 2256/2421] Checkout backup-utils-private for release notes --- .github/workflows/build-and-release.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c76c0efe8..90b44086e 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -104,6 +104,11 @@ jobs: commit_user_email: "ghes-releases-team@github.com" commit_options: "--allow-empty" skip_dirty_check: true + - name: Checkout backup-utils + uses: actions/checkout@v4 + with: + token: ${{ github.event.inputs.gh-token }} + repository: github/backup-utils-private - name: Download deb artifact uses: actions/download-artifact@v3 with: From d45980fb8cdf53ba2a78983d655693f181d14034 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 26 Sep 2023 19:35:30 +0000 Subject: [PATCH 2257/2421] remove test release notes --- release-notes/12.12.12.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 release-notes/12.12.12.md diff --git a/release-notes/12.12.12.md b/release-notes/12.12.12.md deleted file mode 100644 index 192f42d88..000000000 --- a/release-notes/12.12.12.md +++ /dev/null @@ -1,11 +0,0 @@ -# Release Notes - -### Features - -- To reduce the time to generate a backup using `ghe-backup`, administrators can choose to prune old backup snapshots after a new backup has been generate. For more information, see "[Scheduling backups & snapshot pruning](https://github.com/github/backup-utils/blob/master/docs/scheduling-backups.md)." -- On instances with large MySQL databases , administrators who wish to save storage space can use the new `--incremental` flag with `ghe-backup` and `ghe-restore`. For more information, see "[Incremental MySQL Backups and Restores](https://github.com/github/backup-utils/tree/master/docs/incremental-mysql-backups-and-restores.md)". - -### Changes - -- Removed the `git clone` path for setting up `backup-utils` from the [getting started instructions](https://github.com/github/backup-utils/blob/master/docs/getting-started.md). -- Added `bc` v1.07 or newer to the [requirements](https://github.com/github/backup-utils/blob/master/docs/requirements.md) for a backup host machine. \ No newline at end of file From 87e07fe89daa047a47ad91ef742215ed574f8f5c Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Tue, 26 Sep 2023 18:09:44 -0400 Subject: [PATCH 2258/2421] fix mkdir issues or progress tracking (#612) Fixing https://github.com/github/ghes/issues/7409 --- share/github-backup-utils/ghe-backup-config | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 790d2aaa4..d173b1703 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -655,14 +655,15 @@ restore-secret() { init-progress() { if [ -d /tmp/backup-utils-progress ]; then rm -rf /tmp/backup-utils-progress/* - else - mkdir /tmp/backup-utils-progress fi + + mkdir -p /tmp/backup-utils-progress + chmod -R 777 /tmp/backup-utils-progress + touch /tmp/backup-utils-progress/total touch /tmp/backup-utils-progress/type touch /tmp/backup-utils-progress/progress touch /tmp/backup-utils-progress/info - chmod -R 777 /tmp/backup-utils-progress } From a3a3cecabefd33a280c53d61a8ecc9bc74ae099f Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 27 Sep 2023 18:10:06 +0000 Subject: [PATCH 2259/2421] add link to release documentation --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4ee951f58..472acf87c 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ GitHub Enterprise Server. - **[Backup snapshot file structure](docs/backup-snapshot-file-structure.md)** - **[How does Backup Utilities differ from a High Availability replica?](docs/faq.md)** - **[Docker](docs/docker.md)** +- **[Releases](https://github.com/github/enterprise-releases/blob/master/docs/release-backup-utils.md)** ## Support From d48791bc5e47a208f855d0903ee773d8af2afca9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 27 Sep 2023 21:40:40 +0000 Subject: [PATCH 2260/2421] place values in string --- .github/workflows/build-and-release.yml | 206 +++++++++++++----------- 1 file changed, 112 insertions(+), 94 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 90b44086e..cabccd9fd 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -24,76 +24,19 @@ jobs: steps: # resulting token still gets denied by the backup-utils repo # see: https://github.com/actions/create-github-app-token/pull/46 - # - uses: timreimherr/create-github-app-token@main - # id: app-token - # with: - # # required - # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: backup-utils,backup-utils-private - - name: Checkout backup-utils-private - uses: actions/checkout@v4 - with: - token: ${{ github.event.inputs.gh-token }} - repository: github/backup-utils-private - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag # this is required for the build scripts - run: | - git config user.name "${{ github.actor }}" - git config user.email "ghes-releases-team@github.com" - git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Package deb - run: | - ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - - name: Upload deb artifact - uses: actions/upload-artifact@v3 + - uses: timreimherr/create-github-app-token@main + id: app-token with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - release: - needs: build - runs-on: ubuntu-latest - outputs: - commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} - steps: - # resulting token still gets denied by the backup-utils repo - # see: https://github.com/actions/create-github-app-token/pull/46 - # - uses: timreimherr/create-github-app-token@main - # id: app-token - # with: - # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: backup-utils,backup-utils-private + # required + app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils uses: actions/checkout@v4 with: - token: ${{ github.event.inputs.gh-token }} + token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - ref: master - name: Create empty commit uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit @@ -104,35 +47,110 @@ jobs: commit_user_email: "ghes-releases-team@github.com" commit_options: "--allow-empty" skip_dirty_check: true - - name: Checkout backup-utils - uses: actions/checkout@v4 - with: - token: ${{ github.event.inputs.gh-token }} - repository: github/backup-utils-private - - name: Download deb artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Download tarball artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - - name: Create Release - uses: ncipollo/release-action@v1 - with: - token: ${{ github.event.inputs.gh-token }} - repo: backup-utils - name: | - GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - artifacts: | - github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - github-backup-utils_${{ github.event.inputs.version }}_all.deb - tag: v${{ github.event.inputs.version }} - commit: ${{ steps.empty-commit.outputs.commit_hash }} - bodyFile: release-notes/${{ github.event.inputs.version }}.md - draft: ${{ github.event.inputs.draft }} - allowUpdates: true - artifactContentType: "raw" + - name: Log a message + if: success() + run: echo "The previous step succeeded" + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ github.event.inputs.gh-token }} + # repository: github/backup-utils-private + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip + # - name: Create tag # this is required for the build scripts + # run: | + # git config user.name "${{ github.actor }}" + # git config user.email "ghes-releases-team@github.com" + # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + # git push origin "v${{ github.event.inputs.version }}" + # - name: Package deb + # run: | + # ./script/package-deb + # # many need to remove this once release-notes compilation is automated + # - name: Rename deb artifact + # run: | + # for file in dist/github-backup-utils_*_all.deb; do + # if [[ -f "$file" ]]; then + # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + # fi + # done + # - name: Upload deb artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # path: | + # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Package tarball + # run: | + # ./script/package-tarball + # - name: Upload tarball artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # path: | + # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # release: + # needs: build + # runs-on: ubuntu-latest + # outputs: + # commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} + # steps: + # # resulting token still gets denied by the backup-utils repo + # # see: https://github.com/actions/create-github-app-token/pull/46 + # # - uses: timreimherr/create-github-app-token@main + # # id: app-token + # # with: + # # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # # owner: ${{ github.repository_owner }} + # # repositories: backup-utils,backup-utils-private + # - name: Checkout backup-utils + # uses: actions/checkout@v4 + # with: + # token: ${{ github.event.inputs.gh-token }} + # repository: github/backup-utils + # ref: master + # - name: Create empty commit + # uses: stefanzweifel/git-auto-commit-action@v4 + # id: empty-commit + # with: + # branch: master + # commit_message: "${{ github.event.inputs.version }} release" + # commit_user_name: "${{ github.actor }}" + # commit_user_email: "ghes-releases-team@github.com" + # commit_options: "--allow-empty" + # skip_dirty_check: true + # - name: Checkout backup-utils + # uses: actions/checkout@v4 + # with: + # token: ${{ github.event.inputs.gh-token }} + # repository: github/backup-utils-private + # - name: Download deb artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Download tarball artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # - name: Create Release + # uses: ncipollo/release-action@v1 + # with: + # token: ${{ github.event.inputs.gh-token }} + # repo: backup-utils + # name: | + # GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} + # artifacts: | + # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + # github-backup-utils_${{ github.event.inputs.version }}_all.deb + # tag: v${{ github.event.inputs.version }} + # commit: ${{ steps.empty-commit.outputs.commit_hash }} + # bodyFile: release-notes/${{ github.event.inputs.version }}.md + # draft: ${{ github.event.inputs.draft }} + # allowUpdates: true + # artifactContentType: "raw" From 60d9ed1e9850506b05e45552015a520e8914ec6c Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 27 Sep 2023 21:43:40 +0000 Subject: [PATCH 2261/2421] use test branch --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index cabccd9fd..49a7c0156 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -41,7 +41,7 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: - branch: master + branch: tims-test-branch commit_message: "${{ github.event.inputs.version }} release" commit_user_name: "${{ github.actor }}" commit_user_email: "ghes-releases-team@github.com" From 030580f3a97a685f6170411f43d450f32b59a70a Mon Sep 17 00:00:00 2001 From: Luke Reid Date: Thu, 28 Sep 2023 15:58:08 +0100 Subject: [PATCH 2262/2421] Fix broken upgrade requirements link The link to the upgrade requirements points to the old help pages. I have updated it to the new docs. --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index bba51c252..089a92b46 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -97,7 +97,7 @@ Due to how some components of Backup Utilities (e.g. MSSQL) take incremental bac [5]: https://en.wikipedia.org/wiki/Hard_link [6]: https://en.wikipedia.org/wiki/Symbolic_link [7]: https://en.wikipedia.org/wiki/Case_sensitivity -[8]: https://help.github.com/enterprise/admin/guides/installation/upgrade-requirements/ +[8]: https://docs.github.com/enterprise-server/admin/monitoring-managing-and-updating-your-instance/updating-the-virtual-machine-and-physical-resources/upgrade-requirements [9]: https://joeyh.name/code/moreutils [10]: https://www.gnu.org/software/gawk [11]: https://stedolan.github.io/jq/ From 4ea5ecefa04d5a9507bea016125b760ca685c335 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Thu, 28 Sep 2023 16:16:39 -0600 Subject: [PATCH 2263/2421] Update parallel command to adapt to changes in 3.11 --- share/github-backup-utils/ghe-backup-config | 16 ++++++++++++++++ share/github-backup-utils/ghe-restore-pages | 3 ++- .../github-backup-utils/ghe-restore-repositories | 3 ++- .../ghe-restore-repositories-gist | 3 ++- share/github-backup-utils/ghe-restore-storage | 3 ++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index d173b1703..9e7cc9f47 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -462,6 +462,22 @@ ghe_parse_remote_version() { export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH } +# In 3.11 we started to install 2 different version parallel(s) +# moreutils parallel and GNU parallel. Get parallel command based on version +ghe_remote_parallel() { + if [ -z "$GHE_REMOTE_VERSION" ]; then + ecbk "Error: ghe_remote_version_required needs to be invoked before ghe_remote_parallel" 1>&2 + exit 1 + fi + + if [ "$GHE_VERSION_MINOR" -lt 11 ]; then + PARALLEL_CMD="parallel" + else + PARALLEL_CMD="parallel.moreutils" + fi + export PARALLEL_CMD +} + # Parses the part out of a ":" or just "" string. # This is used primarily to break hostspecs with non-standard ports down for # rsync commands. diff --git a/share/github-backup-utils/ghe-restore-pages b/share/github-backup-utils/ghe-restore-pages index 0b104863e..cbc019345 100755 --- a/share/github-backup-utils/ghe-restore-pages +++ b/share/github-backup-utils/ghe-restore-pages @@ -35,6 +35,7 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" +ghe_remote_parallel # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") @@ -156,7 +157,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <&3 <>$remote_warnings" -- \$chunks + $PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/dgit-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF increment-progress-total-count 1 bm_end "$(basename $0) - Finalizing routes" diff --git a/share/github-backup-utils/ghe-restore-repositories-gist b/share/github-backup-utils/ghe-restore-repositories-gist index 7faae5260..631676ea0 100755 --- a/share/github-backup-utils/ghe-restore-repositories-gist +++ b/share/github-backup-utils/ghe-restore-repositories-gist @@ -35,6 +35,7 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" +ghe_remote_parallel # Generate SSH config for forwarding # Split host:port into parts @@ -159,7 +160,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 <>$remote_warnings" -- \$chunks + $PARALLEL_CMD -i /bin/sh -c "cat {} | github-env ./bin/gist-cluster-restore-finalize 2>>$remote_warnings" -- \$chunks EOF increment-progress-total-count 1 bm_end "$(basename $0) - Finalizing routes" diff --git a/share/github-backup-utils/ghe-restore-storage b/share/github-backup-utils/ghe-restore-storage index 8f0d73c48..64cdbbaa4 100755 --- a/share/github-backup-utils/ghe-restore-storage +++ b/share/github-backup-utils/ghe-restore-storage @@ -39,6 +39,7 @@ fi # Perform a host-check and establish GHE_REMOTE_XXX variables. ghe_remote_version_required "$GHE_HOSTNAME" +ghe_remote_parallel # Split host:port into parts port=$(ssh_port_part "$GHE_HOSTNAME") @@ -171,7 +172,7 @@ if $CLUSTER; then ghe-ssh "$GHE_HOSTNAME" -- /bin/bash >&3 < Date: Thu, 28 Sep 2023 16:20:41 -0600 Subject: [PATCH 2264/2421] Update ghe-backup-config --- share/github-backup-utils/ghe-backup-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 9e7cc9f47..f49cdb0bc 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -466,7 +466,7 @@ ghe_parse_remote_version() { # moreutils parallel and GNU parallel. Get parallel command based on version ghe_remote_parallel() { if [ -z "$GHE_REMOTE_VERSION" ]; then - ecbk "Error: ghe_remote_version_required needs to be invoked before ghe_remote_parallel" 1>&2 + echo "Error: ghe_remote_version_required needs to be invoked before ghe_remote_parallel" 1>&2 exit 1 fi From d9831072a84c6ce1c5417924fa43d265a1470f01 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 29 Sep 2023 00:07:28 -0600 Subject: [PATCH 2265/2421] Fix that janky build wasn't triggered correctly --- .github/workflows/integration-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index efdd23ebe..603f7affa 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -37,6 +37,7 @@ jobs: janky-token: '${{ secrets.API_AUTH_TOKEN }}' job-name: '${{ matrix.jankyJobName }}' branch-name: '${{ env.SOURCE_BRANCH }}' + force : 'false' # enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release) envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ env.TARGET_BRANCH }}" @@ -63,5 +64,6 @@ jobs: janky-token: '${{ secrets.API_AUTH_TOKEN }}' job-name: '${{ matrix.jankyJobName }}' branch-name: '${{ env.SOURCE_BRANCH }}' + force : 'false' # enterprise2 target branch is same as target branch for PR (either master or enterprise-[0-9]*.[0-9]*-release) envVars: "JANKY_ENV_BACKUP_UTILS_BRANCH=${{ env.SOURCE_BRANCH }},JANKY_ENV_ENTERPRISE2_BRANCH=${{ env.TARGET_BRANCH }}" From 53f509e9cb081ac41dca9b925a911fefc1405e7a Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Fri, 29 Sep 2023 00:10:19 -0600 Subject: [PATCH 2266/2421] Update comments --- share/github-backup-utils/ghe-backup-config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index f49cdb0bc..4ac372e0b 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -463,7 +463,8 @@ ghe_parse_remote_version() { } # In 3.11 we started to install 2 different version parallel(s) -# moreutils parallel and GNU parallel. Get parallel command based on version +# moreutils parallel and GNU parallel. When gnu parallel is installed, +# it renames moreutils parallel to parallel.moreutils ghe_remote_parallel() { if [ -z "$GHE_REMOTE_VERSION" ]; then echo "Error: ghe_remote_version_required needs to be invoked before ghe_remote_parallel" 1>&2 From 23a11908523532c46b8bcb3425bec18df8bdf24d Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Fri, 29 Sep 2023 09:52:50 -0600 Subject: [PATCH 2267/2421] Update share/github-backup-utils/ghe-backup-config Co-authored-by: Quinn Murphy --- share/github-backup-utils/ghe-backup-config | 1 + 1 file changed, 1 insertion(+) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 4ac372e0b..86a75a15a 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -465,6 +465,7 @@ ghe_parse_remote_version() { # In 3.11 we started to install 2 different version parallel(s) # moreutils parallel and GNU parallel. When gnu parallel is installed, # it renames moreutils parallel to parallel.moreutils +# set $PARALLEL_CMD envvar to be used in place of parallel commands ghe_remote_parallel() { if [ -z "$GHE_REMOTE_VERSION" ]; then echo "Error: ghe_remote_version_required needs to be invoked before ghe_remote_parallel" 1>&2 From db8fdae5a45719efeb01fdd096da1c262771248f Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Mon, 2 Oct 2023 17:41:28 -0600 Subject: [PATCH 2268/2421] Fix track-progress while progress files are not set --- bin/ghe-backup | 1 + bin/ghe-restore | 3 +++ share/github-backup-utils/track-progress | 8 +++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 5a4eb6c20..8914bddc9 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -118,6 +118,7 @@ cleanup () { rm -rf "$failures_file" rm -f "${GHE_DATA_DIR}/in-progress-backup" + rm -rf /tmp/backup-utils-progress/* # Cleanup SSH multiplexing ghe-ssh --clean diff --git a/bin/ghe-restore b/bin/ghe-restore index c9ac20ec2..1d1159133 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -139,6 +139,9 @@ cleanup () { log_error "Failed to remove in-progress file" 1>&3 fi + # Remove progress files + rm -rf /tmp/backup-utils-progress/* + bm_end "$(basename $0)" } diff --git a/share/github-backup-utils/track-progress b/share/github-backup-utils/track-progress index a560ba540..6f7d1a76b 100755 --- a/share/github-backup-utils/track-progress +++ b/share/github-backup-utils/track-progress @@ -2,11 +2,17 @@ #/ track-progress: track progress of backup or restore tasks progress(){ - + ## Those progress files should be created by init_progress function + ## If they are not present (e.g., individual script is being invoked directly), + ## we will not track progress + if [ -f "/tmp/backup-utils-progress/progress" ] && + [ -f "/tmp/backup-utils-progress/total" ] && + [ -f "/tmp/backup-utils-progress/type" ]; then PROGRESS=$(cat /tmp/backup-utils-progress/progress) PROGRESS_TOTAL=$(cat /tmp/backup-utils-progress/total) PROGRESS_TYPE=$(cat /tmp/backup-utils-progress/type) PROGRESS_PERCENT=$( echo "scale = 2; ($PROGRESS / $PROGRESS_TOTAL) * 100" | bc) echo $((PROGRESS + 1)) > /tmp/backup-utils-progress/progress echo "${PROGRESS_TYPE} progress: $PROGRESS_PERCENT % ($PROGRESS / $PROGRESS_TOTAL ) $1 " > /tmp/backup-utils-progress/info + fi } From 1338786c4d0911b369acbff40f5b5dc5c65a3fca Mon Sep 17 00:00:00 2001 From: David Daly Date: Wed, 4 Oct 2023 12:27:23 +0000 Subject: [PATCH 2269/2421] add new test for passsing -c to restore for actions and checking if new value is present --- test/test-ghe-restore.sh | 88 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index da7fdb06b..3ea47e2b5 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -674,6 +674,94 @@ begin_test "ghe-restore with Actions settings" ) end_test +begin_test "ghe-restore with Actions settings passing -c" +( + set -e + rm -rf "$GHE_REMOTE_ROOT_DIR" + setup_remote_metadata + enable_actions + + required_files=( + "actions-config-db-login" + "actions-config-db-password" + "actions-framework-access-token" + "actions-url-signing-hmac-key-primary" + "actions-url-signing-hmac-key-secondary" + "actions-oauth-s2s-signing-cert" + "actions-oauth-s2s-signing-key" + "actions-oauth-s2s-signing-cert-thumbprint" + "actions-primary-encryption-cert-thumbprint" + "actions-aad-cert-thumbprint" + "actions-delegated-auth-cert-thumbprint" + "actions-runtime-service-principal-cert" + "actions-s2s-encryption-cert" + "actions-secondary-encryption-cert-thumbprint" + "actions-service-principal-cert" + "actions-sps-validation-cert-thumbprint" + "actions-storage-container-prefix" + + "actions-launch-secrets-private-key" + "actions-launch-deployer-hmac" + "actions-launch-client-id" + "actions-launch-client-secret" + "actions-launch-receiver-webhook-secret" + "actions-launch-app-private-key" + "actions-launch-app-public-key" + "actions-launch-app-id" + "actions-launch-app-relay-id" + "actions-launch-action-runner-secret" + "actions-launch-azp-app-cert" + "actions-launch-app-app-private-key" + + ) + + for file in "${required_files[@]}"; do + echo "foo" > "$GHE_DATA_DIR/current/$file" + done + + ghe-restore -v -f -c localhost + + required_secrets=( + "secrets.actions.ConfigurationDatabaseSqlLogin" + "secrets.actions.ConfigurationDatabaseSqlPassword" + "secrets.actions.FrameworkAccessTokenKeySecret" + "secrets.actions.UrlSigningHmacKeyPrimary" + "secrets.actions.UrlSigningHmacKeySecondary" + "secrets.actions.OAuthS2SSigningCert" + "secrets.actions.OAuthS2SSigningKey" + "secrets.actions.OAuthS2SSigningCertThumbprint" + "secrets.actions.PrimaryEncryptionCertificateThumbprint" + "secrets.actions.AADCertThumbprint" + "secrets.actions.DelegatedAuthCertThumbprint" + "secrets.actions.RuntimeServicePrincipalCertificate" + "secrets.actions.S2SEncryptionCertificate" + "secrets.actions.SecondaryEncryptionCertificateThumbprint" + "secrets.actions.ServicePrincipalCertificate" + "secrets.actions.SpsValidationCertThumbprint" + "secrets.actions.storage.container-prefix" + "secrets.launch.actions-secrets-private-key" + "secrets.launch.deployer-hmac-secret" + "secrets.launch.client-id" + "secrets.launch.client-secret" + "secrets.launch.receiver-webhook-secret" + "secrets.launch.app-private-key" + "secrets.launch.app-public-key" + "secrets.launch.app-id" + "secrets.launch.app-relay-id" + "secrets.launch.action-runner-secret" + "secrets.launch.token-oauth-key" + "secrets.launch.token-oauth-cert" + "secrets.launch.azp-app-cert" + "secrets.launch.azp-app-private-key" + + ) + + for secret in "${required_secrets[@]}"; do + [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "foo" ] + done +) +end_test + begin_test "ghe-restore stops and starts Actions" ( set -e From 24bd388b8368f2b057a9feb23a1fb29291a66735 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 5 Oct 2023 15:25:22 -0400 Subject: [PATCH 2270/2421] Added section about rsync compression --- docs/usage.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/usage.md b/docs/usage.md index 8f1a70131..1e9653598 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -115,5 +115,11 @@ Please refer to [GHES Documentation](https://docs.github.com/en/enterprise-serve If you are interested in performing incremental backups of the MySQL data in your GitHub Enterprise Server instance, see [Incremental MySQL Backups and Restores](incremental-mysql-backups-and-restores.md) for details. +## Rsync compression + +From backup-utils v3.11.0 onwards, we have disabled rsync compression by default to improve transfer speed and reduce CPU usage durign the transfer process. + +If you would like to use compression with rsync, you can add `GHE_RSYNC_COMPRESSION_ENABLED=true` in your `backup.config` file. + [1]: https://github.com/github/backup-utils/blob/master/docs/getting-started.md [2]: requirements.md From 2fa406bd449e87fe3e6f03354f6cbe2207acaa2f Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Fri, 6 Oct 2023 17:43:04 -0400 Subject: [PATCH 2271/2421] Fixed typo. --- docs/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 1e9653598..e4ed5b7e2 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -117,7 +117,7 @@ If you are interested in performing incremental backups of the MySQL data in you ## Rsync compression -From backup-utils v3.11.0 onwards, we have disabled rsync compression by default to improve transfer speed and reduce CPU usage durign the transfer process. +From backup-utils v3.11.0 onwards, we have disabled rsync compression by default to improve transfer speed and reduce CPU usage during the transfer process. If you would like to use compression with rsync, you can add `GHE_RSYNC_COMPRESSION_ENABLED=true` in your `backup.config` file. From 63d5932a63f9d77604264ef288c681992b28ce25 Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Mon, 9 Oct 2023 12:03:04 -0400 Subject: [PATCH 2272/2421] correct incremental restore envvar (#642) --- docs/incremental-mysql-backups-and-restores.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/incremental-mysql-backups-and-restores.md b/docs/incremental-mysql-backups-and-restores.md index 0bc5f8ef8..53543c927 100644 --- a/docs/incremental-mysql-backups-and-restores.md +++ b/docs/incremental-mysql-backups-and-restores.md @@ -1,14 +1,14 @@ # Incremental MySQL Backups and Restores Customers who have large MySQL databases who wish to save storage space can use the `--incremental` flag with `ghe-backup` and `ghe-restore`. -Using this flag performs backups for other parts of GHES as normal, but only performs a MySQL backup of the changes to the database from the previous snapshot. +Using this flag performs backups for other parts of GHES as normal, but only performs a MySQL backup of the changes to the database from the previous snapshot. For larger databases this can conserve a lot of storage space for backups. ## Configuring number of backups -In your backup.config file you will need to set the variable `GHE_INCREMENTAL_BACKUP_MAX`. +In your backup.config file you will need to set the variable `GHE_INCREMENTAL_MAX_BACKUPS`. This variable determines how many cycles of full and incremental backups will be performed before the next full backup is created. -For example, if `GHE_INCREMENTAL_BACKUP_MAX` is set to 14, backup-utils will run 1 full backup and then 13 incremental backups before performing another full backup on the next cycle. +For example, if `GHE_INCREMENTAL_MAX_BACKUPS` is set to 14, backup-utils will run 1 full backup and then 13 incremental backups before performing another full backup on the next cycle. Incremental backups require the previous snapshot backups before them to work. This means they do not follow the pruning strategy based on `GHE_NUM_SNAPSHOTS`. @@ -19,7 +19,7 @@ To perform incremental backups: `bin/ghe-backup --incremental` -the program will detect whether it needs to performa full or incremental snapshot based on what is currently in `GHE_DATA_DIR`. +the program will detect whether it needs to performa full or incremental snapshot based on what is currently in `GHE_DATA_DIR`. To see what snapshots are part of your full and incremental backups, you can reference `GHE_DATA_DIR/inc_full_backup` and `GHE_DATA_DIR/inc_snapshot_data`, respectively. @@ -35,4 +35,4 @@ The program will use the MySQL folders from each previous incremental backup and ### Previous cycles -To ensure there is a rolling window of mySQL backups, incremental MySQL backups from the cycle before the current one are kept. Those snapshots are pre-pended with `inc_previous`. To perform a restore from there, just use the full directory name for the snapshot id. +To ensure there is a rolling window of mySQL backups, incremental MySQL backups from the cycle before the current one are kept. Those snapshots are pre-pended with `inc_previous`. To perform a restore from there, just use the full directory name for the snapshot ID. From da35308a675913946084fa83afebcaab359bab93 Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Tue, 10 Oct 2023 18:05:20 +0200 Subject: [PATCH 2273/2421] refactor secrets (#648) --- bin/ghe-backup | 3 + bin/ghe-restore | 15 +- share/github-backup-utils/ghe-backup-config | 10 - share/github-backup-utils/ghe-backup-secrets | 186 ++++++++++++++++++ share/github-backup-utils/ghe-backup-settings | 159 --------------- share/github-backup-utils/ghe-restore-actions | 42 ---- .../ghe-restore-chat-integration | 66 ------- .../ghe-restore-column-encryption-keys | 42 ---- share/github-backup-utils/ghe-restore-mysql | 3 - .../github-backup-utils/ghe-restore-packages | 45 ----- ...he-restore-secret-scanning-encryption-keys | 45 ----- share/github-backup-utils/ghe-restore-secrets | 146 ++++++++++++++ .../github-backup-utils/ghe-restore-settings | 27 --- test/test-ghe-restore.sh | 59 ------ 14 files changed, 336 insertions(+), 512 deletions(-) create mode 100755 share/github-backup-utils/ghe-backup-secrets delete mode 100755 share/github-backup-utils/ghe-restore-chat-integration delete mode 100755 share/github-backup-utils/ghe-restore-column-encryption-keys delete mode 100755 share/github-backup-utils/ghe-restore-packages delete mode 100755 share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys create mode 100755 share/github-backup-utils/ghe-restore-secrets diff --git a/bin/ghe-backup b/bin/ghe-backup index 8914bddc9..1dfaf748b 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -267,6 +267,9 @@ bm_init > /dev/null ghe-backup-store-version || log_warn "Warning: storing backup-utils version remotely failed." +log_info "Backing up GitHub secrets ..." +ghe-backup-secrets || failures="$failures secrets" + log_info "Backing up GitHub settings ..." ghe-backup-settings || failures="$failures settings" diff --git a/bin/ghe-restore b/bin/ghe-restore index 1d1159133..101f19ebc 100755 --- a/bin/ghe-restore +++ b/bin/ghe-restore @@ -466,6 +466,7 @@ else fi CRON_RUNNING=false +ghe-restore-secrets "$GHE_HOSTNAME" # Restore settings and license if restoring to an unconfigured appliance or when # specified manually. @@ -473,19 +474,6 @@ if $RESTORE_SETTINGS; then ghe-restore-settings "$GHE_HOSTNAME" fi -# Always restore column encryption keys -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then - log_info "Always restore encrypted column encryption keys on GHES versions 3.7.0+" -fi -ghe-restore-column-encryption-keys "$GHE_HOSTNAME" - -# Always restore secret scanning encryption keys -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then - log_info "Always restore secret scanning encryption keys on GHES versions 3.8.0+" - increment-progress-total-count 1 - ghe-restore-secret-scanning-encryption-keys "$GHE_HOSTNAME" -fi - # Make sure mysql and elasticsearch are prep'd and running before restoring. # These services will not have been started on appliances that have not been # configured yet. @@ -639,7 +627,6 @@ echo "sudo restart -q memcached 2>/dev/null || true" | ghe-ssh "$GHE_HOSTNAME" -- /bin/sh bm_end "$(basename $0) - Restarting memcached" - # Prevent GitHub Connect jobs running before we've had a chance to reset # the configuration by setting the last run date to now. if ! $RESTORE_SETTINGS; then diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 86a75a15a..6c33ea954 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -659,16 +659,6 @@ prompt_for_confirmation(){ echo } -# Function to restore a secret setting stored in a file. -# restore-secret -restore-secret() { - if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then - echo "Restoring $1 ..." - echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash - fi -} - #initialize progress tracking by clearing out the temp files used to track init-progress() { if [ -d /tmp/backup-utils-progress ]; then diff --git a/share/github-backup-utils/ghe-backup-secrets b/share/github-backup-utils/ghe-backup-secrets new file mode 100755 index 000000000..546be420e --- /dev/null +++ b/share/github-backup-utils/ghe-backup-secrets @@ -0,0 +1,186 @@ +#!/usr/bin/env bash +#/ Usage: ghe-backup-secrets +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-backup command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Grab the host +host="$GHE_HOSTNAME" + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$host" + + +# Function to backup a secret setting to a file. +# backup-secret [--best-effort] +backup-secret() { + best_effort=false + description="" + file="" + setting="" + count=0 + + while [ $# -gt 0 ]; do + case "$1" in + --best-effort) + shift 1 + best_effort=true + ;; + *) + case $count in + 0) + description=$1 + ;; + 1) + file=$1 + ;; + 2) + setting=$1 + ;; + *) + >&2 echo "Too many arguments" + ;; + esac + count=$((count+1)) + shift 1 + esac + done + + log_info "* Transferring $description ..." 1>&3 + ghe-ssh "$host" -- ghe-config "$setting" > "$file+" || ( + if [ "$best_effort" = "false" ]; then + echo "Warning: $description not set" >&2 + fi + ) + if [ -n "$(cat "$file+")" ]; then + mv "$file+" "$file" + else + unlink "$file+" + fi +} + +bm_start "$(basename $0)" + +# Create the snapshot directory if needed and change into it. +mkdir -p "$GHE_SNAPSHOT_DIR" +cd "$GHE_SNAPSHOT_DIR" + +log_info "* Transferring secrets data ..." 1>&3 + +backup-secret "management console password" "manage-password" "secrets.manage" +backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" +backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" +backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" + +# backup encryption keying material and create backup value current encryption for GHES 3.7.0 onwards +# this is for forwards compatibility with GHES 3.8.0 onwards +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then + backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" + cat "$GHE_SNAPSHOT_DIR/encrypted-column-encryption-keying-material" | sed 's:.*;::' > "$GHE_SNAPSHOT_DIR/encrypted-column-current-encryption-key" +fi + +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then + backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" + backup-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" + backup-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" + backup-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" +fi + +if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.11.0)" ]; then + backup-secret "secret scanning encrypted content keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" +fi + +# Backup argon secrets for multiuser from ghes version 3.8 onwards +if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then + backup-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" +fi + +# Backup external MySQL password if running external MySQL DB. +if is_service_external 'mysql'; then + backup-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" +fi + +# Backup Actions settings. +if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then + backup-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" + backup-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" + backup-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" --best-effort + backup-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" + backup-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" + backup-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" + backup-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" + backup-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" + backup-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" + backup-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" --best-effort + backup-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" --best-effort + backup-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" --best-effort + backup-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" + backup-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" + backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" --best-effort + backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" + backup-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" + + backup-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" + backup-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" + backup-secret "Actions Launch Client id" "actions-launch-client-id" "secrets.launch.client-id" + backup-secret "Actions Launch Client secret" "actions-launch-client-secret" "secrets.launch.client-secret" + backup-secret "Actions Launch receiver webhook secret" "actions-launch-receiver-webhook-secret" "secrets.launch.receiver-webhook-secret" + backup-secret "Actions Launch app private key" "actions-launch-app-private-key" "secrets.launch.app-private-key" + backup-secret "Actions Launch app public key" "actions-launch-app-public-key" "secrets.launch.app-public-key" + backup-secret "Actions Launch app id" "actions-launch-app-id" "secrets.launch.app-id" + backup-secret "Actions Launch app relay id" "actions-launch-app-relay-id" "secrets.launch.app-relay-id" + backup-secret "Actions Launch action runner secret" "actions-launch-action-runner-secret" "secrets.launch.action-runner-secret" + backup-secret "Actions Launch service cert" "actions-launch-azp-app-cert" "secrets.launch.azp-app-cert" + backup-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" +fi + +if ghe-ssh "$host" -- ghe-config --true app.packages.enabled; then + backup-secret "Packages aws access key" "packages-aws-access-key" "secrets.packages.aws-access-key" + backup-secret "Packages aws secret key" "packages-aws-secret-key" "secrets.packages.aws-secret-key" + backup-secret "Packages s3 bucket" "packages-s3-bucket" "secrets.packages.s3-bucket" + backup-secret "Packages storage service url" "packages-service-url" "secrets.packages.service-url" + backup-secret "Packages blob storage type" "packages-blob-storage-type" "secrets.packages.blob-storage-type" + backup-secret "Packages azure connection string" "packages-azure-connection-string" "secrets.packages.azure-connection-string" + backup-secret "Packages azure container name" "packages-azure-container-name" "secrets.packages.azure-container-name" +fi + +# Backup Chat Integration settings +if ghe-ssh "$host" -- ghe-config --true app.chatops.enabled; then + backup-secret "Chat Integration MSTeams app id" "chatops-msteams-app-id" "secrets.chatops.msteams.app-id" + backup-secret "Chat Integration MSTeams app password" "chatops-msteams-app-password" "secrets.chatops.msteams.app-password" + backup-secret "Chat Integration MSTeams public endpoint" "chatops-msteams-app-public-endpoint" "secrets.chatops.msteams.public-endpoint" + backup-secret "Chat Integration MSTeams bot handle" "chatops-msteams-bot-handle" "secrets.chatops.msteams.bot-handle" + backup-secret "Chat Integration MSTeams bot name" "chatops-msteams-bot-name" "secrets.chatops.msteams.bot-name" + backup-secret "Chat Integration Slack app id" "chatops-slack-app-id" "secrets.chatops.slack.app-id" + backup-secret "Chat Integration Slack client id" "chatops-slack-client-id" "secrets.chatops.slack.client-id" + backup-secret "Chat Integration Slack client secret" "chatops-slack-client-secret" "secrets.chatops.slack.client-secret" + backup-secret "Chat Integration Slack verification token" "chatops-slack-verification-token" "secrets.chatops.slack.verification-token" + backup-secret "Chat Integration Slack config token" "chatops-slack-config-token" "secrets.chatops.slack.config-token" + backup-secret "Chat Integration Slack public endpoint" "chatops-slack-public-endpoint" "secrets.chatops.slack.public-endpoint" + backup-secret "Chat Integration Slack signing secret" "chatops-slack-signing-secret" "secrets.chatops.slack.signing-secret" + backup-secret "Chat Integration Slack app level token" "chatops-slack-app-level-token" "secrets.chatops.slack.app-level-token" + backup-secret "Chat Integration Slack slack command" "chatops-slack-slash-command" "secrets.chatops.slack.slash-command" + backup-secret "Chat Integration Slack app name" "chatops-slack.app-name" "secrets.chatops.slack.app-name" + backup-secret "Chat Integration Slack socket mode" "chatops-slack.socket-mode" "secrets.chatops.slack.socket-mode" + backup-secret "Chat Integration public endpoint" "chatops-public-endpoint" "secrets.chatops.public-endpoint" + backup-secret "Chat Integration app type" "chatops-app-type" "secrets.chatops.app-type" + backup-secret "Chat Integration app id teams" "chatops-app-id-teams" "secrets.chatops.app-id-teams" + backup-secret "Chat Integration webhook secret teams" "chatops-webhook-secret-teams" "secrets.chatops.webhook-secret-teams" + backup-secret "Chat Integration client secret teams" "chatops-client-secret-teams" "secrets.chatops.client-secret-teams" + backup-secret "Chat Integration clien id teams" "chatops-client-id-teams" "secrets.chatops.client-id-teams" + backup-secret "Chat Integration storage secret" "chatops-storage-secret" "secrets.chatops.storage-secret" + backup-secret "Chat Integration session secret" "chatops-session-secret" "secrets.chatops.session-secret" + backup-secret "Chat Integration app id slack" "chatops-app-id-slack" "secrets.chatops.app-id-slack" + backup-secret "Chat Integration webhook secret slack" "chatops-webhook-secret-slack" "secrets.chatops.webhook-secret-slack" + backup-secret "Chat Integration client secret slack" "chatops-client-secret-slack" "secrets.chatops.client-secret-slack" + backup-secret "Chat Integration client id slack" "chatops-client-id-slack" "secrets.chatops.client-id-slack" +fi + +bm_end "$(basename $0)" + +exit 0 diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings index 7cfd62b8d..f3d262293 100755 --- a/share/github-backup-utils/ghe-backup-settings +++ b/share/github-backup-utils/ghe-backup-settings @@ -25,165 +25,6 @@ ghe-ssh "$host" -- 'ghe-export-settings' > settings.json log_info "* Transferring license data ..." 1>&3 ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl -# Function to backup a secret setting to a file. -# backup-secret [--best-effort] -backup-secret() { - - best_effort=false - description="" - file="" - setting="" - count=0 - - while [ $# -gt 0 ]; do - case "$1" in - --best-effort) - shift 1 - best_effort=true - ;; - *) - case $count in - 0) - description=$1 - ;; - 1) - file=$1 - ;; - 2) - setting=$1 - ;; - *) - >&2 echo "Too many arguments" - ;; - esac - count=$((count+1)) - shift 1 - esac - done - - log_info "* Transferring $description ..." 1>&3 - ghe-ssh "$host" -- ghe-config "$setting" > "$file+" || ( - if [ "$best_effort" = "false" ]; then - echo "Warning: $description not set" >&2 - fi - ) - if [ -n "$(cat "$file+")" ]; then - mv "$file+" "$file" - else - unlink "$file+" - fi -} - -backup-secret "management console password" "manage-password" "secrets.manage" -backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" -backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" -backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" - -# backup encryption keying material and create backup value current encryption for GHES 3.7.0 onwards -# this is for forwards compatibility with GHES 3.8.0 onwards -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then - backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" - cat "$GHE_SNAPSHOT_DIR/encrypted-column-encryption-keying-material" | sed 's:.*;::' > "$GHE_SNAPSHOT_DIR/encrypted-column-current-encryption-key" -fi - -# secret scanning encrypted secrets keys were added in GHES 3.8.0 -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then - backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" - backup-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" - backup-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" - backup-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" -fi - -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.11.0)" ]; then - backup-secret "secret scanning encrypted content keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" -fi - -# Backup argon secrets for multiuser from ghes version 3.8 onwards -if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then - backup-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" -fi - -# Backup external MySQL password if running external MySQL DB. -if is_service_external 'mysql'; then - backup-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" -fi - -# Backup Actions settings. -if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then - backup-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" - backup-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" - backup-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" --best-effort - backup-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" - backup-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" - backup-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" - backup-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" - backup-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" - backup-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" - backup-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" --best-effort - backup-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" --best-effort - backup-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" --best-effort - backup-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" - backup-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" - backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" --best-effort - backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" - backup-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" - - backup-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" - backup-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" - backup-secret "Actions Launch Client id" "actions-launch-client-id" "secrets.launch.client-id" - backup-secret "Actions Launch Client secret" "actions-launch-client-secret" "secrets.launch.client-secret" - backup-secret "Actions Launch receiver webhook secret" "actions-launch-receiver-webhook-secret" "secrets.launch.receiver-webhook-secret" - backup-secret "Actions Launch app private key" "actions-launch-app-private-key" "secrets.launch.app-private-key" - backup-secret "Actions Launch app public key" "actions-launch-app-public-key" "secrets.launch.app-public-key" - backup-secret "Actions Launch app id" "actions-launch-app-id" "secrets.launch.app-id" - backup-secret "Actions Launch app relay id" "actions-launch-app-relay-id" "secrets.launch.app-relay-id" - backup-secret "Actions Launch action runner secret" "actions-launch-action-runner-secret" "secrets.launch.action-runner-secret" - backup-secret "Actions Launch service cert" "actions-launch-azp-app-cert" "secrets.launch.azp-app-cert" - backup-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" -fi - -if ghe-ssh "$host" -- ghe-config --true app.packages.enabled; then - backup-secret "Packages aws access key" "packages-aws-access-key" "secrets.packages.aws-access-key" - backup-secret "Packages aws secret key" "packages-aws-secret-key" "secrets.packages.aws-secret-key" - backup-secret "Packages s3 bucket" "packages-s3-bucket" "secrets.packages.s3-bucket" - backup-secret "Packages storage service url" "packages-service-url" "secrets.packages.service-url" - backup-secret "Packages blob storage type" "packages-blob-storage-type" "secrets.packages.blob-storage-type" - backup-secret "Packages azure connection string" "packages-azure-connection-string" "secrets.packages.azure-connection-string" - backup-secret "Packages azure container name" "packages-azure-container-name" "secrets.packages.azure-container-name" -fi - -# Backup Chat Integration settings -if ghe-ssh "$host" -- ghe-config --true app.chatops.enabled; then - backup-secret "Chat Integration MSTeams app id" "chatops-msteams-app-id" "secrets.chatops.msteams.app-id" - backup-secret "Chat Integration MSTeams app password" "chatops-msteams-app-password" "secrets.chatops.msteams.app-password" - backup-secret "Chat Integration MSTeams public endpoint" "chatops-msteams-app-public-endpoint" "secrets.chatops.msteams.public-endpoint" - backup-secret "Chat Integration MSTeams bot handle" "chatops-msteams-bot-handle" "secrets.chatops.msteams.bot-handle" - backup-secret "Chat Integration MSTeams bot name" "chatops-msteams-bot-name" "secrets.chatops.msteams.bot-name" - backup-secret "Chat Integration Slack app id" "chatops-slack-app-id" "secrets.chatops.slack.app-id" - backup-secret "Chat Integration Slack client id" "chatops-slack-client-id" "secrets.chatops.slack.client-id" - backup-secret "Chat Integration Slack client secret" "chatops-slack-client-secret" "secrets.chatops.slack.client-secret" - backup-secret "Chat Integration Slack verification token" "chatops-slack-verification-token" "secrets.chatops.slack.verification-token" - backup-secret "Chat Integration Slack config token" "chatops-slack-config-token" "secrets.chatops.slack.config-token" - backup-secret "Chat Integration Slack public endpoint" "chatops-slack-public-endpoint" "secrets.chatops.slack.public-endpoint" - backup-secret "Chat Integration Slack signing secret" "chatops-slack-signing-secret" "secrets.chatops.slack.signing-secret" - backup-secret "Chat Integration Slack app level token" "chatops-slack-app-level-token" "secrets.chatops.slack.app-level-token" - backup-secret "Chat Integration Slack slack command" "chatops-slack-slash-command" "secrets.chatops.slack.slash-command" - backup-secret "Chat Integration Slack app name" "chatops-slack.app-name" "secrets.chatops.slack.app-name" - backup-secret "Chat Integration Slack socket mode" "chatops-slack.socket-mode" "secrets.chatops.slack.socket-mode" - backup-secret "Chat Integration public endpoint" "chatops-public-endpoint" "secrets.chatops.public-endpoint" - backup-secret "Chat Integration app type" "chatops-app-type" "secrets.chatops.app-type" - backup-secret "Chat Integration app id teams" "chatops-app-id-teams" "secrets.chatops.app-id-teams" - backup-secret "Chat Integration webhook secret teams" "chatops-webhook-secret-teams" "secrets.chatops.webhook-secret-teams" - backup-secret "Chat Integration client secret teams" "chatops-client-secret-teams" "secrets.chatops.client-secret-teams" - backup-secret "Chat Integration clien id teams" "chatops-client-id-teams" "secrets.chatops.client-id-teams" - backup-secret "Chat Integration storage secret" "chatops-storage-secret" "secrets.chatops.storage-secret" - backup-secret "Chat Integration session secret" "chatops-session-secret" "secrets.chatops.session-secret" - backup-secret "Chat Integration app id slack" "chatops-app-id-slack" "secrets.chatops.app-id-slack" - backup-secret "Chat Integration webhook secret slack" "chatops-webhook-secret-slack" "secrets.chatops.webhook-secret-slack" - backup-secret "Chat Integration client secret slack" "chatops-client-secret-slack" "secrets.chatops.client-secret-slack" - backup-secret "Chat Integration client id slack" "chatops-client-id-slack" "secrets.chatops.client-id-slack" -fi - if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then log_info "* Transferring SAML keys ..." 1>&3 ghe-ssh $host -- sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -cf - "idp.crt saml-sp.p12" > saml-keys.tar diff --git a/share/github-backup-utils/ghe-restore-actions b/share/github-backup-utils/ghe-restore-actions index 303a2abd2..b27dc9aa6 100755 --- a/share/github-backup-utils/ghe-restore-actions +++ b/share/github-backup-utils/ghe-restore-actions @@ -52,48 +52,6 @@ log_rsync "END: actions rsync" 1>&3 # Restore Actions settings. ghe_verbose "* Restoring Actions settings to $host ..." -restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" -restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" -restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" -restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" -restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" -restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" -restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" -restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" -restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" -restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" -restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" -restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" -restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" -restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" -restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" -restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" - -restore-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" -restore-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" -restore-secret "Actions Launch Client id" "actions-launch-client-id" "secrets.launch.client-id" -restore-secret "Actions Launch Client secret" "actions-launch-client-secret" "secrets.launch.client-secret" -restore-secret "Actions Launch receiver webhook secret" "actions-launch-receiver-webhook-secret" "secrets.launch.receiver-webhook-secret" -restore-secret "Actions Launch app private key" "actions-launch-app-private-key" "secrets.launch.app-private-key" -restore-secret "Actions Launch app public key" "actions-launch-app-public-key" "secrets.launch.app-public-key" -restore-secret "Actions Launch app id" "actions-launch-app-id" "secrets.launch.app-id" -restore-secret "Actions Launch app relay id" "actions-launch-app-relay-id" "secrets.launch.app-relay-id" -restore-secret "Actions Launch action runner secret" "actions-launch-action-runner-secret" "secrets.launch.action-runner-secret" -restore-secret "Actions Launch service cert" "actions-launch-azp-app-cert" "secrets.launch.azp-app-cert" -restore-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" - -restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" "secrets.launch.token-oauth-key" -restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert" - -# Restore storage container prefix, but only if it exists, and the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings -if [[ $RESTORE_SETTINGS == "true" ]]; then - if [[ -e "$GHE_RESTORE_SNAPSHOT_PATH/actions-storage-container-prefix" ]]; then - restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" - else - log_warn "Actions storage container prefix not present in backup. Skipping ..." - fi -fi - # Setup the database logins. ghe_verbose "* Restoring database logins and users to $host ..." diff --git a/share/github-backup-utils/ghe-restore-chat-integration b/share/github-backup-utils/ghe-restore-chat-integration deleted file mode 100755 index 0f0ba4b44..000000000 --- a/share/github-backup-utils/ghe-restore-chat-integration +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-chat-integration -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Path to snapshot dir we're restoring from -export GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" - -port=$(ssh_port_part "$GHE_HOSTNAME") -export port -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Restore Chat Integration settings. -ghe_verbose "Restoring Chat Integration settings ..." - -restore-secret "Chat Integration MSTeams app id" "chatops-msteams-app-id" "secrets.chatops.msteams.app-id" -restore-secret "Chat Integration MSTeams app password" "chatops-msteams-app-password" "secrets.chatops.msteams.app-password" -restore-secret "Chat Integration MSTeams public endpoint" "chatops-msteams-app-public-endpoint" "secrets.chatops.msteams.public-endpoint" -restore-secret "Chat Integration MSTeams bot handle" "chatops-msteams-bot-handle" "secrets.chatops.msteams.bot-handle" -restore-secret "Chat Integration MSTeams bot name" "chatops-msteams-bot-name" "secrets.chatops.msteams.bot-name" -restore-secret "Chat Integration Slack app id" "chatops-slack-app-id" "secrets.chatops.slack.app-id" -restore-secret "Chat Integration Slack client id" "chatops-slack-client-id" "secrets.chatops.slack.client-id" -restore-secret "Chat Integration Slack client secret" "chatops-slack-client-secret" "secrets.chatops.slack.client-secret" -restore-secret "Chat Integration Slack verification token" "chatops-slack-verification-token" "secrets.chatops.slack.verification-token" -restore-secret "Chat Integration Slack config token" "chatops-slack-config-token" "secrets.chatops.slack.config-token" -restore-secret "Chat Integration Slack public endpoint" "chatops-slack-public-endpoint" "secrets.chatops.slack.public-endpoint" -restore-secret "Chat Integration Slack signing secret" "chatops-slack-signing-secret" "secrets.chatops.slack.signing-secret" -restore-secret "Chat Integration Slack app level token" "chatops-slack-app-level-token" "secrets.chatops.slack.app-level-token" -restore-secret "Chat Integration Slack slack command" "chatops-slack-slash-command" "secrets.chatops.slack.slash-command" -restore-secret "Chat Integration Slack app name" "chatops-slack.app-name" "secrets.chatops.slack.app-name" -restore-secret "Chat Integration Slack socket mode" "chatops-slack.socket-mode" "secrets.chatops.slack.socket-mode" -restore-secret "Chat Integration public endpoint" "chatops-public-endpoint" "secrets.chatops.public-endpoint" -restore-secret "Chat Integration app type" "chatops-app-type" "secrets.chatops.app-type" -restore-secret "Chat Integration app id teams" "chatops-app-id-teams" "secrets.chatops.app-id-teams" -restore-secret "Chat Integration webhook secret teams" "chatops-webhook-secret-teams" "secrets.chatops.webhook-secret-teams" -restore-secret "Chat Integration client secret teams" "chatops-client-secret-teams" "secrets.chatops.client-secret-teams" -restore-secret "Chat Integration clien id teams" "chatops-client-id-teams" "secrets.chatops.client-id-teams" -restore-secret "Chat Integration storage secret" "chatops-storage-secret" "secrets.chatops.storage-secret" -restore-secret "Chat Integration session secret" "chatops-session-secret" "secrets.chatops.session-secret" -restore-secret "Chat Integration app id slack" "chatops-app-id-slack" "secrets.chatops.app-id-slack" -restore-secret "Chat Integration webhook secret slack" "chatops-webhook-secret-slack" "secrets.chatops.webhook-secret-slack" -restore-secret "Chat Integration client secret slack" "chatops-client-secret-slack" "secrets.chatops.client-secret-slack" -restore-secret "Chat Integration client id slack" "chatops-client-id-slack" "secrets.chatops.client-id-slack" - -bm_end "$(basename $0)" \ No newline at end of file diff --git a/share/github-backup-utils/ghe-restore-column-encryption-keys b/share/github-backup-utils/ghe-restore-column-encryption-keys deleted file mode 100755 index d30cacd51..000000000 --- a/share/github-backup-utils/ghe-restore-column-encryption-keys +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-column-encryption-keys -#/ Restore the column encryption keys from a snapshot to the given . -#/ This script will be run automatically by `ghe-restore -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Path to snapshot dir we're restoring from -: ${GHE_RESTORE_SNAPSHOT_PATH:="$GHE_DATA_DIR/current"} - -# Restore encrypted column encryption keying material for GHES 3.7.0 onward -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then - log_info "Restoring encrypted column encryption keying material" - restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" -fi - -# Restore encrypted column current encryption key for GHES 3.8.0 onwards -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then - log_info "Restoring encrypted column current encryption key" - restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" -fi - - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-mysql b/share/github-backup-utils/ghe-restore-mysql index 8e75ea0f1..a251c820a 100755 --- a/share/github-backup-utils/ghe-restore-mysql +++ b/share/github-backup-utils/ghe-restore-mysql @@ -29,9 +29,6 @@ export GHE_RESTORE_SNAPSHOT # The directory holding the snapshot to restore GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" -# Always restore the password pepper here since it is tied to the MySQL data. -restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" - if is_external_database_snapshot; then if [ -n "$EXTERNAL_DATABASE_RESTORE_SCRIPT" ]; then $EXTERNAL_DATABASE_RESTORE_SCRIPT diff --git a/share/github-backup-utils/ghe-restore-packages b/share/github-backup-utils/ghe-restore-packages deleted file mode 100755 index e9842d095..000000000 --- a/share/github-backup-utils/ghe-restore-packages +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-packages -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-restore command. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Path to snapshot dir we're restoring from -export GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" - -port=$(ssh_port_part "$GHE_HOSTNAME") -export port -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Restore Packages settings. -ghe_verbose "Restoring Packages settings ..." - -restore-secret "Packages aws access key" "packages-aws-access-key" "secrets.packages.aws-access-key" -restore-secret "Packages aws secret key" "packages-aws-secret-key" "secrets.packages.aws-secret-key" -restore-secret "Packages s3 bucket" "packages-s3-bucket" "secrets.packages.s3-bucket" -restore-secret "Packages storage service url" "packages-service-url" "secrets.packages.service-url" -restore-secret "Packages blob storage type" "packages-blob-storage-type" "secrets.packages.blob-storage-type" -restore-secret "Packages azure connection string" "packages-azure-connection-string" "secrets.packages.azure-connection-string" -restore-secret "Packages azure container name" "packages-azure-container-name" "secrets.packages.azure-container-name" - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys b/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys deleted file mode 100755 index 04f7588a7..000000000 --- a/share/github-backup-utils/ghe-restore-secret-scanning-encryption-keys +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore-secret-scanning-encryption-keys -#/ Restore the secret scanning encryption keys from a snapshot to the given . -#/ This script will be run automatically by `ghe-restore` -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config" - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -bm_start "$(basename $0)" - -# Grab host arg -GHE_HOSTNAME="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# The snapshot to restore should be set by the ghe-restore command but this lets -# us run this script directly. -: ${GHE_RESTORE_SNAPSHOT:=current} - -# Path to snapshot dir we're restoring from -: ${GHE_RESTORE_SNAPSHOT_PATH:="$GHE_DATA_DIR/current"} - -# Restore secret scanning encrypted secrets storage keys if present -log_info "Restoring secret scanning encrypted secrets storage keys" -restore-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" -restore-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" - -# Restore secret scanning encrypted secrets transit keys if present -log_info "Restoring secret scanning encrypted secrets transit keys" -restore-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" -restore-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" - -# Restore secret scanning content scanning keys if present -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.11.0)" ]; then - log_info "Restoring secret scanning content scanning keys" - restore-secret "secret scanning user content delimited encryption root keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" -fi - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-restore-secrets b/share/github-backup-utils/ghe-restore-secrets new file mode 100755 index 000000000..3d6b5dd8e --- /dev/null +++ b/share/github-backup-utils/ghe-restore-secrets @@ -0,0 +1,146 @@ +#!/usr/bin/env bash +#/ Usage: ghe-restore-secrets +#/ +#/ Note: This script typically isn't called directly. It's invoked by the +#/ ghe-restore command. +set -e + +# Bring in the backup configuration +# shellcheck source=share/github-backup-utils/ghe-backup-config +. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" + +# Show usage and bail with no arguments +[ -z "$*" ] && print_usage + +bm_start "$(basename $0)" + +# Grab host arg +GHE_HOSTNAME="$1" + +# The snapshot to restore should be set by the ghe-restore command but this lets +# us run this script directly. +: ${GHE_RESTORE_SNAPSHOT:=current} + +# Path to snapshot dir we're restoring from +export GHE_RESTORE_SNAPSHOT_PATH="$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT" + +host=$(ssh_host_part "$GHE_HOSTNAME") + +# Perform a host-check and establish GHE_REMOTE_XXX variables. +ghe_remote_version_required "$host" + +# Otherwise use legacy +# Function to restore a secret setting stored in a file. +# restore-secret +restore-secret() { + if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/$2" ]; then + echo "Restoring $1 ..." + echo "ghe-config '$3' '$(cat "$GHE_RESTORE_SNAPSHOT_PATH/$2")'" | + ghe-ssh "$GHE_HOSTNAME" -- /bin/bash + fi +} + +log_info "Restoring secrets and applying cleanup ..." 1>&3 + +restore-secret "management console password" "manage-password" "secrets.manage" +restore-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" +restore-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" +restore-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" + +restore-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" + +restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" + +restore-secret "Chat Integration MSTeams app id" "chatops-msteams-app-id" "secrets.chatops.msteams.app-id" +restore-secret "Chat Integration MSTeams app password" "chatops-msteams-app-password" "secrets.chatops.msteams.app-password" +restore-secret "Chat Integration MSTeams public endpoint" "chatops-msteams-app-public-endpoint" "secrets.chatops.msteams.public-endpoint" +restore-secret "Chat Integration MSTeams bot handle" "chatops-msteams-bot-handle" "secrets.chatops.msteams.bot-handle" +restore-secret "Chat Integration MSTeams bot name" "chatops-msteams-bot-name" "secrets.chatops.msteams.bot-name" +restore-secret "Chat Integration Slack app id" "chatops-slack-app-id" "secrets.chatops.slack.app-id" +restore-secret "Chat Integration Slack client id" "chatops-slack-client-id" "secrets.chatops.slack.client-id" +restore-secret "Chat Integration Slack client secret" "chatops-slack-client-secret" "secrets.chatops.slack.client-secret" +restore-secret "Chat Integration Slack verification token" "chatops-slack-verification-token" "secrets.chatops.slack.verification-token" +restore-secret "Chat Integration Slack config token" "chatops-slack-config-token" "secrets.chatops.slack.config-token" +restore-secret "Chat Integration Slack public endpoint" "chatops-slack-public-endpoint" "secrets.chatops.slack.public-endpoint" +restore-secret "Chat Integration Slack signing secret" "chatops-slack-signing-secret" "secrets.chatops.slack.signing-secret" +restore-secret "Chat Integration Slack app level token" "chatops-slack-app-level-token" "secrets.chatops.slack.app-level-token" +restore-secret "Chat Integration Slack slack command" "chatops-slack-slash-command" "secrets.chatops.slack.slash-command" +restore-secret "Chat Integration Slack app name" "chatops-slack.app-name" "secrets.chatops.slack.app-name" +restore-secret "Chat Integration Slack socket mode" "chatops-slack.socket-mode" "secrets.chatops.slack.socket-mode" +restore-secret "Chat Integration public endpoint" "chatops-public-endpoint" "secrets.chatops.public-endpoint" +restore-secret "Chat Integration app type" "chatops-app-type" "secrets.chatops.app-type" +restore-secret "Chat Integration app id teams" "chatops-app-id-teams" "secrets.chatops.app-id-teams" +restore-secret "Chat Integration webhook secret teams" "chatops-webhook-secret-teams" "secrets.chatops.webhook-secret-teams" +restore-secret "Chat Integration client secret teams" "chatops-client-secret-teams" "secrets.chatops.client-secret-teams" +restore-secret "Chat Integration clien id teams" "chatops-client-id-teams" "secrets.chatops.client-id-teams" +restore-secret "Chat Integration storage secret" "chatops-storage-secret" "secrets.chatops.storage-secret" +restore-secret "Chat Integration session secret" "chatops-session-secret" "secrets.chatops.session-secret" +restore-secret "Chat Integration app id slack" "chatops-app-id-slack" "secrets.chatops.app-id-slack" +restore-secret "Chat Integration webhook secret slack" "chatops-webhook-secret-slack" "secrets.chatops.webhook-secret-slack" +restore-secret "Chat Integration client secret slack" "chatops-client-secret-slack" "secrets.chatops.client-secret-slack" +restore-secret "Chat Integration client id slack" "chatops-client-id-slack" "secrets.chatops.client-id-slack" + +restore-secret "Packages aws access key" "packages-aws-access-key" "secrets.packages.aws-access-key" +restore-secret "Packages aws secret key" "packages-aws-secret-key" "secrets.packages.aws-secret-key" +restore-secret "Packages s3 bucket" "packages-s3-bucket" "secrets.packages.s3-bucket" +restore-secret "Packages storage service url" "packages-service-url" "secrets.packages.service-url" +restore-secret "Packages blob storage type" "packages-blob-storage-type" "secrets.packages.blob-storage-type" +restore-secret "Packages azure connection string" "packages-azure-connection-string" "secrets.packages.azure-connection-string" +restore-secret "Packages azure container name" "packages-azure-container-name" "secrets.packages.azure-container-name" + +# Restore storage container prefix, but only if it exists, and the `-c` option is used with ghe-restore to avoid staging instances using production bucket settings +if [[ $RESTORE_SETTINGS == "true" ]]; then + if [[ -e "$GHE_RESTORE_SNAPSHOT_PATH/actions-storage-container-prefix" ]]; then + restore-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" + else + log_warn "Actions storage container prefix not present in backup. Skipping ..." + fi +fi + +restore-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" +restore-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" +restore-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" +restore-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" +restore-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" +restore-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" +restore-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" +restore-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" +restore-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" +restore-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" +restore-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" +restore-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" +restore-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" +restore-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" +restore-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" +restore-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" + +restore-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" +restore-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" +restore-secret "Actions Launch Client id" "actions-launch-client-id" "secrets.launch.client-id" +restore-secret "Actions Launch Client secret" "actions-launch-client-secret" "secrets.launch.client-secret" +restore-secret "Actions Launch receiver webhook secret" "actions-launch-receiver-webhook-secret" "secrets.launch.receiver-webhook-secret" +restore-secret "Actions Launch app private key" "actions-launch-app-private-key" "secrets.launch.app-private-key" +restore-secret "Actions Launch app public key" "actions-launch-app-public-key" "secrets.launch.app-public-key" +restore-secret "Actions Launch app id" "actions-launch-app-id" "secrets.launch.app-id" +restore-secret "Actions Launch app relay id" "actions-launch-app-relay-id" "secrets.launch.app-relay-id" +restore-secret "Actions Launch action runner secret" "actions-launch-action-runner-secret" "secrets.launch.action-runner-secret" +restore-secret "Actions Launch service cert" "actions-launch-azp-app-cert" "secrets.launch.azp-app-cert" +restore-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" + +restore-secret "Actions Launch token oauth key" "actions-oauth-s2s-signing-key" "secrets.launch.token-oauth-key" +restore-secret "Actions Launch token oauth cert" "actions-oauth-s2s-signing-cert" "secrets.launch.token-oauth-cert" + +# Restore secret scanning +restore-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" +restore-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" +restore-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" +restore-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" +restore-secret "secret scanning user content delimited encryption root keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" + +# Restore encrypted column +restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" +restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" + +bm_end "$(basename $0)" + +exit 0 diff --git a/share/github-backup-utils/ghe-restore-settings b/share/github-backup-utils/ghe-restore-settings index ad06f30a6..8d20d8333 100755 --- a/share/github-backup-utils/ghe-restore-settings +++ b/share/github-backup-utils/ghe-restore-settings @@ -30,38 +30,11 @@ ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-license' < "$GHE_RESTORE_SNAPSHOT_PATH/en log_info "Restoring settings and applying configuration ..." -# Restore external MySQL password if running external MySQL DB. -restore-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" - -log_info "Restoring packages settings ..." -ghe-restore-packages "$GHE_HOSTNAME" 1>&3 - -echo "Restoring chat integration settings ..." -ghe-restore-chat-integration "$GHE_HOSTNAME" 1>&3 - # work around issue importing settings with bad storage mode values ( cat "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" && echo ) | sed 's/"storage_mode": "device"/"storage_mode": "rootfs"/' | ghe-ssh "$GHE_HOSTNAME" -- '/usr/bin/env GHEBUVER=2 ghe-import-settings' 1>&3 -# Restore management console password hash if present. -restore-secret "management console password" "manage-password" "secrets.manage" - -# Restore management console argon2 secret if present. -restore-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" - -# Restore kredz.credz HMAC key if present. -restore-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" - -# Restore kredz.varz HMAC key if present. -restore-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" - -# Restore encrypted column encryption keying material if present -restore-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" - -# Restore encrypted column current encryption key if present -restore-secret "encrypted column current encryption key" "encrypted-column-current-encryption-key" "secrets.github.encrypted-column-current-encryption-key" - # Restore SAML keys if present. if [ -f "$GHE_RESTORE_SNAPSHOT_PATH/saml-keys.tar" ]; then log_info "Restoring SAML keys ..." diff --git a/test/test-ghe-restore.sh b/test/test-ghe-restore.sh index 3ea47e2b5..2b430e912 100755 --- a/test/test-ghe-restore.sh +++ b/test/test-ghe-restore.sh @@ -389,39 +389,6 @@ begin_test "ghe-restore with encrypted column current encryption key for version ) end_test -begin_test "ghe-restore with secret scanning encrypted secrets encryption keys for versions below 3.8.0" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - required_files=( - "secret-scanning-encrypted-secrets-current-storage-key" - "secret-scanning-encrypted-secrets-delimited-storage-keys" - "secret-scanning-encrypted-secrets-current-shared-transit-key" - "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" - ) - - for file in "${required_files[@]}"; do - echo "foo" >"$GHE_DATA_DIR/current/$file" - done - - GHE_REMOTE_VERSION=3.7.0 ghe-restore -v -f localhost - - required_secrets=( - "secrets.secret-scanning.encrypted-secrets-current-storage-key" - "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" - "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" - "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" - ) - - for secret in "${required_secrets[@]}"; do - [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting these to not be set for versions below 3.8.0 - done -) -end_test - - begin_test "ghe-restore with secret scanning encrypted secrets encryption keys for versions 3.8.0+" ( set -e @@ -454,32 +421,6 @@ begin_test "ghe-restore with secret scanning encrypted secrets encryption keys f ) end_test -begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions below 3.11.0" -( - set -e - rm -rf "$GHE_REMOTE_ROOT_DIR" - setup_remote_metadata - - required_files=( - "secret-scanning-user-content-delimited-encryption-root-keys" - ) - - for file in "${required_files[@]}"; do - echo "foo" >"$GHE_DATA_DIR/current/$file" - done - - GHE_REMOTE_VERSION=3.10.0 ghe-restore -v -f localhost - - required_secrets=( - "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" - ) - - for secret in "${required_secrets[@]}"; do - [ "$(ghe-ssh "$GHE_HOSTNAME" -- ghe-config "$secret")" = "" ] # expecting that this secret was not backed up on versions below 3.11.0, this secret was not present in earlier versions - done -) -end_test - begin_test "ghe-restore with secret scanning encrypted content encryption keys for versions 3.11.0+" ( set -e From 5c1c6fa1309696d5c5b0e417aeeb82eaf6d88f3b Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 12 Oct 2023 11:54:36 -0400 Subject: [PATCH 2274/2421] Attempting to fix linting errors --- docs/usage.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index e4ed5b7e2..2918a34da 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -2,11 +2,10 @@ After the initial backup, use the following commands: - - The `ghe-backup` command creates incremental snapshots of repository data, - along with full snapshots of all other pertinent data stores. - - The `ghe-restore` command restores snapshots to the same or separate GitHub - Enterprise appliance. You must add the backup host's SSH key to the target - GitHub Enterprise Server appliance before using this command. + - The `ghe-backup` command creates incremental snapshots of repository data, long with full snapshots of all other pertinent data stores. + - The `ghe-restore` command restores snapshots to the same or separate GitHub +Enterprise appliance. You must add the backup host's SSH key to the target +GitHub Enterprise Server appliance before using this command. These commands are run on the host you [installed][1] Backup Utilities on. From 676c3041c1e68fddb2e433678e4ccf25faf0d8d2 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 12 Oct 2023 15:23:17 -0400 Subject: [PATCH 2275/2421] Trying to fix linting errors again. --- docs/usage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 2918a34da..8d72ba323 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -2,8 +2,8 @@ After the initial backup, use the following commands: - - The `ghe-backup` command creates incremental snapshots of repository data, long with full snapshots of all other pertinent data stores. - - The `ghe-restore` command restores snapshots to the same or separate GitHub +- The `ghe-backup` command creates incremental snapshots of repository data, long with full snapshots of all other pertinent data stores. +- The `ghe-restore` command restores snapshots to the same or separate GitHub Enterprise appliance. You must add the backup host's SSH key to the target GitHub Enterprise Server appliance before using this command. From 1354eb8e512722c76f6bdefa2b3ea0a470f3e6e8 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 12 Oct 2023 15:28:08 -0400 Subject: [PATCH 2276/2421] Another round of linting error fixes --- docs/usage.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 8d72ba323..29d08de04 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -3,7 +3,7 @@ After the initial backup, use the following commands: - The `ghe-backup` command creates incremental snapshots of repository data, long with full snapshots of all other pertinent data stores. -- The `ghe-restore` command restores snapshots to the same or separate GitHub +- The `ghe-restore` command restores snapshots to the same or separate GitHub Enterprise appliance. You must add the backup host's SSH key to the target GitHub Enterprise Server appliance before using this command. @@ -79,12 +79,12 @@ The `ghe-backup` and `ghe-restore` commands also have a verbose output mode (`-v`) that lists files as they're being transferred. It's often useful to enable when output is logged to a file. -Every time you execute `ghe-backup` we verify the storage and software setup of the host -you [installed][1] Backup Utilities on, to make sure our [requirements][2] for the host are -met. You can disable this check using the `--skip-checks` argument or by +Every time you execute `ghe-backup` we verify the storage and software setup of the host +you [installed][1] Backup Utilities on, to make sure our [requirements][2] for the host are +met. You can disable this check using the `--skip-checks` argument or by adding `GHE_SKIP_CHECKS=true` to your configuration file. -### Restoring settings, TLS certificate, and license +### Restoring settings, TLS certificate, and license When restoring to a new GitHub Enterprise Server instance, settings, certificate, and license data *are* restored. These settings must be reviewed and saved before @@ -99,7 +99,7 @@ forcing settings, certificate, and license data to be overwritten with the backu ## Backup and restore with GitHub Actions enabled GitHub Actions data on your external storage provider is not included in regular GitHub Enterprise Server -backups, and must be backed up separately. When restoring a GitHub Enterprise Server backup with +backups, and must be backed up separately. When restoring a GitHub Enterprise Server backup with GitHub Actions enabled, the following steps are required: 1. Enable GitHub Actions on the replacement appliance and configure it to use the same GitHub Actions From 559f7e62ca2cf1ac466bbc7ae3028a5e7320f84f Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 12 Oct 2023 15:44:43 -0400 Subject: [PATCH 2277/2421] More linting fixes --- docs/usage.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage.md b/docs/usage.md index 29d08de04..4324b58cc 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -15,7 +15,7 @@ You can supply your own configuration file or use the example configuration file An example configuration file with documentation on possible settings can found in [backup.config-example](../backup.config-example). -There are a number of command line options that can also be passed to the `ghe-restore` command. Of particular note, if you use an external MySQL service but are restoring from a snapshot prior to enabling this, or vice versa, you must migrate the MySQL data outside of the context of backup-utils first, then pass the `--skip-mysql` flag to `ghe-restore`. +There are a number of command-line options that can also be passed to the `ghe-restore` command. Of particular note, if you use an external MySQL service but are restoring from a snapshot prior to enabling this, or vice versa, you must migrate the MySQL data outside of the context of backup-utils first, then pass the `--skip-mysql` flag to `ghe-restore`. ## Example backup and restore usage @@ -104,7 +104,7 @@ GitHub Actions enabled, the following steps are required: 1. Enable GitHub Actions on the replacement appliance and configure it to use the same GitHub Actions external storage configuration as the original appliance. -2. Put replacement appliance into maintenance mode. +2. Put replacement appliance into maintenance mode. 3. Use `ghe-restore` to restore the backup. 4. Re-register your self-hosted runners on the replacement appliance. From b53f1d5b599d0595dfd36322fbabdf95ac097d52 Mon Sep 17 00:00:00 2001 From: Hao Jiang <45571951+jianghao0718@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:47:55 -0600 Subject: [PATCH 2278/2421] Remove unused code in ghe-restore-es-rsync --- share/github-backup-utils/ghe-restore-es-rsync | 4 ---- 1 file changed, 4 deletions(-) diff --git a/share/github-backup-utils/ghe-restore-es-rsync b/share/github-backup-utils/ghe-restore-es-rsync index 1ba09afed..80a7f729a 100755 --- a/share/github-backup-utils/ghe-restore-es-rsync +++ b/share/github-backup-utils/ghe-restore-es-rsync @@ -44,10 +44,6 @@ else "$snapshot_dir/elasticsearch/" \ "$(ssh_host_part "$GHE_HOSTNAME"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch-restore" 1>&3 log_rsync "END: elasticsearch rsync" 1>&3 - # restoring in >=2.14 will remove incompatible indices created with 1.x. - if [ "$GHE_VERSION_MAJOR" -eq 2 ] && [ "$GHE_VERSION_MINOR" -ge 14 ]; then - ghe-ssh "$GHE_HOSTNAME" -- "sudo /usr/local/share/enterprise/ghe-es-remove-1x-indices" - fi fi bm_end "$(basename $0)" From 58d94fc0303750861e6e2af1e6f4a751aa98ce56 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 13:48:04 +0000 Subject: [PATCH 2279/2421] test create-github-app-token on test branch --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 49a7c0156..008484729 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -24,7 +24,7 @@ jobs: steps: # resulting token still gets denied by the backup-utils repo # see: https://github.com/actions/create-github-app-token/pull/46 - - uses: timreimherr/create-github-app-token@main + - uses: actions/create-github-app-token@v1 id: app-token with: # required From 2d2a3d3bb4d77af4b108752e5d50a06ba01ddfb6 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 14:05:06 +0000 Subject: [PATCH 2280/2421] update build-and-release to use action --- .github/workflows/build-and-release.yml | 201 +++++++++++------------- 1 file changed, 88 insertions(+), 113 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 008484729..a9e5cf2a5 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -4,10 +4,6 @@ name: Build and Release on: workflow_dispatch: inputs: - gh-token: - description: 'GitHub Token - used to create a commit in the backup-utils repo' - required: true - type: string version: description: 'Version - patch version of the release (e.g. x.y.z)' required: true @@ -22,14 +18,67 @@ jobs: build: runs-on: ubuntu-latest steps: - # resulting token still gets denied by the backup-utils repo - # see: https://github.com/actions/create-github-app-token/pull/46 - uses: actions/create-github-app-token@v1 id: app-token with: # required - app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: "backup-utils,backup-utils-private" + - name: Checkout backup-utils-private + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils-private + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag # this is required for the build scripts + run: | + git config user.name "${{ github.actor }}" + git config user.email "ghes-releases-team@github.com" + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + - name: Package deb + run: | + ./script/package-deb + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + release: + needs: build + runs-on: ubuntu-latest + outputs: + commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + # required + app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils @@ -37,120 +86,46 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils + ref: master - name: Create empty commit uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: - branch: tims-test-branch + branch: master commit_message: "${{ github.event.inputs.version }} release" commit_user_name: "${{ github.actor }}" commit_user_email: "ghes-releases-team@github.com" commit_options: "--allow-empty" skip_dirty_check: true - - name: Log a message - if: success() - run: echo "The previous step succeeded" - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ github.event.inputs.gh-token }} - # repository: github/backup-utils-private - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # - name: Create tag # this is required for the build scripts - # run: | - # git config user.name "${{ github.actor }}" - # git config user.email "ghes-releases-team@github.com" - # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - # git push origin "v${{ github.event.inputs.version }}" - # - name: Package deb - # run: | - # ./script/package-deb - # # many need to remove this once release-notes compilation is automated - # - name: Rename deb artifact - # run: | - # for file in dist/github-backup-utils_*_all.deb; do - # if [[ -f "$file" ]]; then - # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - # fi - # done - # - name: Upload deb artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # path: | - # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Package tarball - # run: | - # ./script/package-tarball - # - name: Upload tarball artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # path: | - # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # release: - # needs: build - # runs-on: ubuntu-latest - # outputs: - # commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} - # steps: - # # resulting token still gets denied by the backup-utils repo - # # see: https://github.com/actions/create-github-app-token/pull/46 - # # - uses: timreimherr/create-github-app-token@main - # # id: app-token - # # with: - # # app_id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # # private_key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # # owner: ${{ github.repository_owner }} - # # repositories: backup-utils,backup-utils-private - # - name: Checkout backup-utils - # uses: actions/checkout@v4 - # with: - # token: ${{ github.event.inputs.gh-token }} - # repository: github/backup-utils - # ref: master - # - name: Create empty commit - # uses: stefanzweifel/git-auto-commit-action@v4 - # id: empty-commit - # with: - # branch: master - # commit_message: "${{ github.event.inputs.version }} release" - # commit_user_name: "${{ github.actor }}" - # commit_user_email: "ghes-releases-team@github.com" - # commit_options: "--allow-empty" - # skip_dirty_check: true - # - name: Checkout backup-utils - # uses: actions/checkout@v4 - # with: - # token: ${{ github.event.inputs.gh-token }} - # repository: github/backup-utils-private - # - name: Download deb artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Download tarball artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # - name: Create Release - # uses: ncipollo/release-action@v1 - # with: - # token: ${{ github.event.inputs.gh-token }} - # repo: backup-utils - # name: | - # GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - # artifacts: | - # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - # github-backup-utils_${{ github.event.inputs.version }}_all.deb - # tag: v${{ github.event.inputs.version }} - # commit: ${{ steps.empty-commit.outputs.commit_hash }} - # bodyFile: release-notes/${{ github.event.inputs.version }}.md - # draft: ${{ github.event.inputs.draft }} - # allowUpdates: true - # artifactContentType: "raw" + - name: Checkout backup-utils-private + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils-private + - name: Download deb artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Download tarball artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Create Release + uses: ncipollo/release-action@v1 + with: + token: ${{ steps.app-token.outputs.token }} + repo: backup-utils + name: | + GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} + artifacts: | + github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + github-backup-utils_${{ github.event.inputs.version }}_all.deb + tag: v${{ github.event.inputs.version }} + commit: ${{ steps.empty-commit.outputs.commit_hash }} + bodyFile: release-notes/${{ github.event.inputs.version }}.md + draft: ${{ github.event.inputs.draft }} + allowUpdates: true + artifactContentType: "raw" From c1a7c09973bb8ace42236631cf8ad5451fcaae5e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 14:05:21 +0000 Subject: [PATCH 2281/2421] test release notes for test --- release-notes/12.12.12.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 release-notes/12.12.12.md diff --git a/release-notes/12.12.12.md b/release-notes/12.12.12.md new file mode 100644 index 000000000..445d9aada --- /dev/null +++ b/release-notes/12.12.12.md @@ -0,0 +1,7 @@ +### Changes + +* Test release notes. + +### Bug fixes + +* More test release notes. \ No newline at end of file From e69f7d1b8220f6475ce82fb1bf4af586bbd2c63d Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 14:50:59 +0000 Subject: [PATCH 2282/2421] test empty commit against master --- .github/workflows/build-and-release.yml | 189 +++++++++++++----------- 1 file changed, 102 insertions(+), 87 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index a9e5cf2a5..d77906fa0 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -17,61 +17,6 @@ on: jobs: build: runs-on: ubuntu-latest - steps: - - uses: actions/create-github-app-token@v1 - id: app-token - with: - # required - app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: "backup-utils,backup-utils-private" - - name: Checkout backup-utils-private - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - repository: github/backup-utils-private - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag # this is required for the build scripts - run: | - git config user.name "${{ github.actor }}" - git config user.email "ghes-releases-team@github.com" - git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Package deb - run: | - ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - - name: Upload deb artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - release: - needs: build - runs-on: ubuntu-latest - outputs: - commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} steps: - uses: actions/create-github-app-token@v1 id: app-token @@ -86,46 +31,116 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - ref: master - name: Create empty commit uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: branch: master - commit_message: "${{ github.event.inputs.version }} release" - commit_user_name: "${{ github.actor }}" + commit_message: "Test ${{ github.event.inputs.version }} release commit" + commit_user_name: "release-controller[bot]" commit_user_email: "ghes-releases-team@github.com" + commit_author: "release-controller[bot]" commit_options: "--allow-empty" + push_options: "--force" skip_dirty_check: true - - name: Checkout backup-utils-private - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - repository: github/backup-utils-private - - name: Download deb artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Download tarball artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - - name: Create Release - uses: ncipollo/release-action@v1 - with: - token: ${{ steps.app-token.outputs.token }} - repo: backup-utils - name: | - GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - artifacts: | - github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - github-backup-utils_${{ github.event.inputs.version }}_all.deb - tag: v${{ github.event.inputs.version }} - commit: ${{ steps.empty-commit.outputs.commit_hash }} - bodyFile: release-notes/${{ github.event.inputs.version }}.md - draft: ${{ github.event.inputs.draft }} - allowUpdates: true - artifactContentType: "raw" + - name: Log a message + if: success() + run: echo "The previous step succeeded" + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip + # - name: Create tag # this is required for the build scripts + # run: | + # git config user.name "${{ github.actor }}" + # git config user.email "ghes-releases-team@github.com" + # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + # git push origin "v${{ github.event.inputs.version }}" + # - name: Package deb + # run: | + # ./script/package-deb + # # many need to remove this once release-notes compilation is automated + # - name: Rename deb artifact + # run: | + # for file in dist/github-backup-utils_*_all.deb; do + # if [[ -f "$file" ]]; then + # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + # fi + # done + # - name: Upload deb artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # path: | + # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Package tarball + # run: | + # ./script/package-tarball + # - name: Upload tarball artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # path: | + # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # release: + # needs: build + # runs-on: ubuntu-latest + # outputs: + # commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} + # steps: + # - uses: actions/create-github-app-token@v1 + # id: app-token + # with: + # # required + # app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: "backup-utils,backup-utils-private" + # - name: Checkout backup-utils + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils + # ref: master + # - name: Create empty commit + # uses: stefanzweifel/git-auto-commit-action@v4 + # id: empty-commit + # with: + # branch: master + # commit_message: "${{ github.event.inputs.version }} release" + # commit_user_name: "${{ github.actor }}" + # commit_user_email: "ghes-releases-team@github.com" + # commit_options: "--allow-empty" + # skip_dirty_check: true + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils-private + # - name: Download deb artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Download tarball artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # - name: Create Release + # uses: ncipollo/release-action@v1 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repo: backup-utils + # name: | + # GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} + # artifacts: | + # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + # github-backup-utils_${{ github.event.inputs.version }}_all.deb + # tag: v${{ github.event.inputs.version }} + # commit: ${{ steps.empty-commit.outputs.commit_hash }} + # bodyFile: release-notes/${{ github.event.inputs.version }}.md + # draft: ${{ github.event.inputs.draft }} + # allowUpdates: true + # artifactContentType: "raw" From 2289bfcafe941eb04896bcf26943479c53133f59 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 14:54:14 +0000 Subject: [PATCH 2283/2421] author --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index d77906fa0..c0c35ea15 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -39,7 +39,7 @@ jobs: commit_message: "Test ${{ github.event.inputs.version }} release commit" commit_user_name: "release-controller[bot]" commit_user_email: "ghes-releases-team@github.com" - commit_author: "release-controller[bot]" + commit_author: "release-controller" commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true From 8553bd8c99dba00546c6e23f3a3a8d9383d03e81 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 14:55:54 +0000 Subject: [PATCH 2284/2421] author 2 --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c0c35ea15..83df40618 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -39,7 +39,7 @@ jobs: commit_message: "Test ${{ github.event.inputs.version }} release commit" commit_user_name: "release-controller[bot]" commit_user_email: "ghes-releases-team@github.com" - commit_author: "release-controller" + commit_author: "release-controller ghes-releases-team@github.com" commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true From 2fdfafe0bb1d0517ea6dbd91fb2efbd834e50055 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 14:57:40 +0000 Subject: [PATCH 2285/2421] don't set author --- .github/workflows/build-and-release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 83df40618..eed8d8de9 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -37,9 +37,8 @@ jobs: with: branch: master commit_message: "Test ${{ github.event.inputs.version }} release commit" - commit_user_name: "release-controller[bot]" + commit_user_name: "release-controller" commit_user_email: "ghes-releases-team@github.com" - commit_author: "release-controller ghes-releases-team@github.com" commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true From f60549f73321af1e6adcde885eeb2d34ce9da4b0 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 15:01:48 +0000 Subject: [PATCH 2286/2421] try release-controller again --- .github/workflows/build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index eed8d8de9..006b24c9d 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -39,6 +39,7 @@ jobs: commit_message: "Test ${{ github.event.inputs.version }} release commit" commit_user_name: "release-controller" commit_user_email: "ghes-releases-team@github.com" + commit_author: "release-controller " commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true From 43978250559a6efd19b605c0bcc2b82f248cce7c Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 15:07:30 +0000 Subject: [PATCH 2287/2421] default author --- .github/workflows/build-and-release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 006b24c9d..8bade7a1f 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -37,9 +37,8 @@ jobs: with: branch: master commit_message: "Test ${{ github.event.inputs.version }} release commit" - commit_user_name: "release-controller" + commit_user_name: "${{ github.actor }}" commit_user_email: "ghes-releases-team@github.com" - commit_author: "release-controller " commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true From a4e63ea04210538074d60e744c7e295fe405ac6b Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 17:37:38 +0000 Subject: [PATCH 2288/2421] set author --- .github/workflows/build-and-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 8bade7a1f..d3293be75 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -37,8 +37,9 @@ jobs: with: branch: master commit_message: "Test ${{ github.event.inputs.version }} release commit" - commit_user_name: "${{ github.actor }}" + commit_user_name: "release-controller" commit_user_email: "ghes-releases-team@github.com" + commit_author: "release-controller " commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true From 05950382eedea3ed27a11fa40d345230fa31824e Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 17:41:42 +0000 Subject: [PATCH 2289/2421] use rc --- .github/workflows/build-and-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index d3293be75..496cefdaf 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -37,9 +37,9 @@ jobs: with: branch: master commit_message: "Test ${{ github.event.inputs.version }} release commit" - commit_user_name: "release-controller" - commit_user_email: "ghes-releases-team@github.com" - commit_author: "release-controller " + commit_user_name: "release-controller[bot]" + commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" + commit_author: "release-controller[bot] <223695+release-controller[bot]@users.noreply.github.com>" commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true From 827d8800f25b3505eb17eaa48ba7021db3801ef9 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 17:52:19 +0000 Subject: [PATCH 2290/2421] remove rc --- .github/workflows/build-and-release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 496cefdaf..0e89ed42b 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -39,7 +39,6 @@ jobs: commit_message: "Test ${{ github.event.inputs.version }} release commit" commit_user_name: "release-controller[bot]" commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" - commit_author: "release-controller[bot] <223695+release-controller[bot]@users.noreply.github.com>" commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true From 0a9894e9a4a90d422427b4ea6e46503d92e9efc2 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 21:31:55 +0000 Subject: [PATCH 2291/2421] enable setting commit sha for release --- .github/workflows/build-and-release.yml | 198 ++++++++++++------------ 1 file changed, 100 insertions(+), 98 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 0e89ed42b..6d6ccbf44 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -13,6 +13,10 @@ on: required: true type: boolean default: true + backup-utils-release-commit: + description: 'Release Commit - true if the release should be a release commit' + required: false + type: string jobs: build: @@ -26,12 +30,69 @@ jobs: private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" + - name: Checkout backup-utils-private + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag # this is required for the build scripts + run: | + git config user.name "${{ github.actor }}" + git config user.email "ghes-releases-team@github.com" + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + - name: Package deb + run: | + ./script/package-deb + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + release: + needs: build + runs-on: ubuntu-latest + outputs: + commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} + release-commit: ${{ steps.resolve-release-commit.outputs.release-commit }} + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils + if: !github.event.inputs.backup-utils-release-commit uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils + ref: master - name: Create empty commit + if: !github.event.inputs.backup-utils-release-commit uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: @@ -42,104 +103,45 @@ jobs: commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true - - name: Log a message - if: success() - run: echo "The previous step succeeded" - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # - name: Create tag # this is required for the build scripts - # run: | - # git config user.name "${{ github.actor }}" - # git config user.email "ghes-releases-team@github.com" - # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - # git push origin "v${{ github.event.inputs.version }}" - # - name: Package deb - # run: | - # ./script/package-deb - # # many need to remove this once release-notes compilation is automated - # - name: Rename deb artifact - # run: | - # for file in dist/github-backup-utils_*_all.deb; do - # if [[ -f "$file" ]]; then - # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - # fi - # done - # - name: Upload deb artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # path: | - # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Package tarball - # run: | - # ./script/package-tarball - # - name: Upload tarball artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # path: | - # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # release: - # needs: build - # runs-on: ubuntu-latest - # outputs: - # commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} - # steps: - # - uses: actions/create-github-app-token@v1 - # id: app-token - # with: - # # required - # app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: "backup-utils,backup-utils-private" - # - name: Checkout backup-utils - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils - # ref: master - # - name: Create empty commit - # uses: stefanzweifel/git-auto-commit-action@v4 - # id: empty-commit - # with: - # branch: master - # commit_message: "${{ github.event.inputs.version }} release" - # commit_user_name: "${{ github.actor }}" - # commit_user_email: "ghes-releases-team@github.com" - # commit_options: "--allow-empty" - # skip_dirty_check: true - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils-private - # - name: Download deb artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Download tarball artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # - name: Create Release - # uses: ncipollo/release-action@v1 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repo: backup-utils - # name: | - # GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - # artifacts: | - # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - # github-backup-utils_${{ github.event.inputs.version }}_all.deb - # tag: v${{ github.event.inputs.version }} - # commit: ${{ steps.empty-commit.outputs.commit_hash }} - # bodyFile: release-notes/${{ github.event.inputs.version }}.md - # draft: ${{ github.event.inputs.draft }} - # allowUpdates: true - # artifactContentType: "raw" + - name: Resolve release commit + id: resolve-release-commit + if: github.event.inputs.backup-utils-release-commit + run: | + echo "Useing sha from input backup-utils-release-commit" + echo "release-commit=${{ github.event.inputs.backup-utils-release-commit }}" >> $GITHUB_OUTPUT + else: + echo "Using sha from empty commit" + echo "release-commit=${{ steps.empty-commit.outputs.commit_hash }}" >> $GITHUB_OUTPUT + - name: Checkout backup-utils-private + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils-private + - name: Download deb artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Download tarball artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Create Release + uses: ncipollo/release-action@v1 + with: + token: ${{ steps.app-token.outputs.token }} + repo: backup-utils + name: | + GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} + artifacts: | + github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + github-backup-utils_${{ github.event.inputs.version }}_all.deb + tag: v${{ github.event.inputs.version }} + # use release-commit value + commit: ${{ steps.resolve-release-commit.outputs.release-commit }} + bodyFile: release-notes/${{ github.event.inputs.version }}.md + draft: ${{ github.event.inputs.draft }} + allowUpdates: true + artifactContentType: "raw" From be24c6e1230efd2223abd88d2f8e9b2442b376ec Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 21:34:16 +0000 Subject: [PATCH 2292/2421] update input description --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 6d6ccbf44..23431075c 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -14,7 +14,7 @@ on: type: boolean default: true backup-utils-release-commit: - description: 'Release Commit - true if the release should be a release commit' + description: 'Backup Utils Release Commit - sha of the commit to associate with backup-utils release, if empty an empty commit will be created on master' required: false type: string From d02b7d68ef495dc9737d4af8a8ba5a51fd4fb048 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 21:35:17 +0000 Subject: [PATCH 2293/2421] update desc --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 23431075c..f4adddf23 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -14,7 +14,7 @@ on: type: boolean default: true backup-utils-release-commit: - description: 'Backup Utils Release Commit - sha of the commit to associate with backup-utils release, if empty an empty commit will be created on master' + description: 'Backup Utils Release Commit - sha of the commit to associate with backup-utils release. If blank, an empty commit will be created on master' required: false type: string From 38b8cdd449448bfb72a7bd9a31e05610c9f39961 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 21:35:53 +0000 Subject: [PATCH 2294/2421] reorder inputs --- .github/workflows/build-and-release.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index f4adddf23..7dd6e6897 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -8,15 +8,15 @@ on: description: 'Version - patch version of the release (e.g. x.y.z)' required: true type: string + backup-utils-release-commit: + description: 'Backup Utils Release Commit - sha of the commit to associate with backup-utils release. If blank, an empty commit will be created on master' + required: false + type: string draft: description: 'Draft - true if the release should be a draft' required: true type: boolean default: true - backup-utils-release-commit: - description: 'Backup Utils Release Commit - sha of the commit to associate with backup-utils release. If blank, an empty commit will be created on master' - required: false - type: string jobs: build: From e164d529f7956097a74fd84d58c4479f3ca77b3a Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 21:38:43 +0000 Subject: [PATCH 2295/2421] fix eval statements --- .github/workflows/build-and-release.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 7dd6e6897..055228c89 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -85,14 +85,15 @@ jobs: owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils - if: !github.event.inputs.backup-utils-release-commit + if: github.event.inputs.backup-utils-release-commit == '' uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils ref: master - name: Create empty commit - if: !github.event.inputs.backup-utils-release-commit + # if github.event.inputs.backup-utils-release-commit is empty string, then create an empty commit + if: github.event.inputs.backup-utils-release-commit == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: @@ -105,7 +106,7 @@ jobs: skip_dirty_check: true - name: Resolve release commit id: resolve-release-commit - if: github.event.inputs.backup-utils-release-commit + if: github.event.inputs.backup-utils-release-commit != '' run: | echo "Useing sha from input backup-utils-release-commit" echo "release-commit=${{ github.event.inputs.backup-utils-release-commit }}" >> $GITHUB_OUTPUT From 77d98638d88690fec292dfbf8f66f426ddfe0984 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 21:42:03 +0000 Subject: [PATCH 2296/2421] fix resolve commit --- .github/workflows/build-and-release.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 055228c89..c3e1d560a 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -106,13 +106,14 @@ jobs: skip_dirty_check: true - name: Resolve release commit id: resolve-release-commit - if: github.event.inputs.backup-utils-release-commit != '' run: | - echo "Useing sha from input backup-utils-release-commit" - echo "release-commit=${{ github.event.inputs.backup-utils-release-commit }}" >> $GITHUB_OUTPUT - else: - echo "Using sha from empty commit" - echo "release-commit=${{ steps.empty-commit.outputs.commit_hash }}" >> $GITHUB_OUTPUT + if [[ -z "${{ github.event.inputs.backup-utils-release-commit }}" ]]; then + echo "Using empty commit sha for release commit" + echo "release-commit=${{ steps.empty-commit.outputs.commit_hash }}" >> $GITHUB_OUTPUT + else + echo "Using provided commit sha for release commit" + echo "release-commit=${{ github.event.inputs.backup-utils-release-commit }}" >> $GITHUB_OUTPUT + fi - name: Checkout backup-utils-private uses: actions/checkout@v4 with: From 5a2c6f1248c76992b730b32ee5898d76dce672e0 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 21:52:06 +0000 Subject: [PATCH 2297/2421] remove blank lines --- .github/workflows/build-and-release.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c3e1d560a..1667f5bf1 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -85,7 +85,7 @@ jobs: owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils - if: github.event.inputs.backup-utils-release-commit == '' + if: ${{ github.event.inputs.backup-utils-release-commit }} == '' uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} @@ -93,7 +93,7 @@ jobs: ref: master - name: Create empty commit # if github.event.inputs.backup-utils-release-commit is empty string, then create an empty commit - if: github.event.inputs.backup-utils-release-commit == '' + if: ${{ github.event.inputs.backup-utils-release-commit }} == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: @@ -143,8 +143,4 @@ jobs: bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} allowUpdates: true - artifactContentType: "raw" - - - - + artifactContentType: "raw" \ No newline at end of file From 00b46d937b8b62d3894705b723eaea09192bcd34 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 21:54:34 +0000 Subject: [PATCH 2298/2421] avoid globbing? --- .github/workflows/build-and-release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 1667f5bf1..bdc2a69db 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -107,13 +107,13 @@ jobs: - name: Resolve release commit id: resolve-release-commit run: | - if [[ -z "${{ github.event.inputs.backup-utils-release-commit }}" ]]; then - echo "Using empty commit sha for release commit" - echo "release-commit=${{ steps.empty-commit.outputs.commit_hash }}" >> $GITHUB_OUTPUT + "if [[ -z '${{ github.event.inputs.backup-utils-release-commit }}' ]]; then + echo 'Using empty commit sha for release commit' + echo 'release-commit=${{ steps.empty-commit.outputs.commit_hash }}' >> $GITHUB_OUTPUT else - echo "Using provided commit sha for release commit" - echo "release-commit=${{ github.event.inputs.backup-utils-release-commit }}" >> $GITHUB_OUTPUT - fi + echo 'Using provided commit sha for release commit' + echo 'release-commit=${{ github.event.inputs.backup-utils-release-commit }}' >> $GITHUB_OUTPUT + fi" - name: Checkout backup-utils-private uses: actions/checkout@v4 with: From c506a52b6247d931ec6cc76ab03edb5d7ec80647 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 22:13:08 +0000 Subject: [PATCH 2299/2421] eval was correct, revert --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index bdc2a69db..aecb756c2 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -85,7 +85,7 @@ jobs: owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils - if: ${{ github.event.inputs.backup-utils-release-commit }} == '' + if: github.event.inputs.backup-utils-release-commit == '' uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} @@ -93,7 +93,7 @@ jobs: ref: master - name: Create empty commit # if github.event.inputs.backup-utils-release-commit is empty string, then create an empty commit - if: ${{ github.event.inputs.backup-utils-release-commit }} == '' + if: github.event.inputs.backup-utils-release-commit == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: From 70f21fffea0849dbcd6d798aa88797aaa4f588e4 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 22:21:18 +0000 Subject: [PATCH 2300/2421] does copilot know the answer? --- .github/workflows/build-and-release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index aecb756c2..62100f420 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -107,13 +107,13 @@ jobs: - name: Resolve release commit id: resolve-release-commit run: | - "if [[ -z '${{ github.event.inputs.backup-utils-release-commit }}' ]]; then - echo 'Using empty commit sha for release commit' - echo 'release-commit=${{ steps.empty-commit.outputs.commit_hash }}' >> $GITHUB_OUTPUT + if [[ -z "${{ github.event.inputs.backup-utils-release-commit }}" ]]; then + echo "Using empty commit sha for release commit" + echo "release-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" else - echo 'Using provided commit sha for release commit' - echo 'release-commit=${{ github.event.inputs.backup-utils-release-commit }}' >> $GITHUB_OUTPUT - fi" + echo "Using provided commit sha for release commit" + echo "release-commit=\"${{ github.event.inputs.backup-utils-release-commit }}\"" >> "$GITHUB_OUTPUT" + fi - name: Checkout backup-utils-private uses: actions/checkout@v4 with: From 425162cce2c6bf2317f1ab22e7dc6c4d0f22d66d Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 23:35:35 +0000 Subject: [PATCH 2301/2421] don't need priavte repo in release? --- .github/workflows/build-and-release.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 62100f420..c727e45ea 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -25,7 +25,6 @@ jobs: - uses: actions/create-github-app-token@v1 id: app-token with: - # required app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} @@ -92,7 +91,6 @@ jobs: repository: github/backup-utils ref: master - name: Create empty commit - # if github.event.inputs.backup-utils-release-commit is empty string, then create an empty commit if: github.event.inputs.backup-utils-release-commit == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit @@ -114,11 +112,11 @@ jobs: echo "Using provided commit sha for release commit" echo "release-commit=\"${{ github.event.inputs.backup-utils-release-commit }}\"" >> "$GITHUB_OUTPUT" fi - - name: Checkout backup-utils-private - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - repository: github/backup-utils-private + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils-private - name: Download deb artifact uses: actions/download-artifact@v3 with: @@ -138,7 +136,6 @@ jobs: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} - # use release-commit value commit: ${{ steps.resolve-release-commit.outputs.release-commit }} bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} From c7dc45529bf4eafb36fb1c86d30c6f2d45101b31 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Mon, 16 Oct 2023 23:39:13 +0000 Subject: [PATCH 2302/2421] add owner --- .github/workflows/build-and-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c727e45ea..62bb55b22 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -129,6 +129,7 @@ jobs: uses: ncipollo/release-action@v1 with: token: ${{ steps.app-token.outputs.token }} + owner: github repo: backup-utils name: | GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} From ea39b5eb1112c7d1e980d8f3d3786d11896362a0 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 17 Oct 2023 09:06:56 -0400 Subject: [PATCH 2303/2421] for release notes --- .github/workflows/build-and-release.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 62bb55b22..1bf9e9124 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -112,11 +112,12 @@ jobs: echo "Using provided commit sha for release commit" echo "release-commit=\"${{ github.event.inputs.backup-utils-release-commit }}\"" >> "$GITHUB_OUTPUT" fi - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils-private + # need backup-utils-private for release notes + - name: Checkout backup-utils-private + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils-private - name: Download deb artifact uses: actions/download-artifact@v3 with: From d9a2830f5d85d40ef06fa764c600f5629b49f543 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 17 Oct 2023 09:13:27 -0400 Subject: [PATCH 2304/2421] can use branch ref also --- .github/workflows/build-and-release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 1bf9e9124..efd0d16b6 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -8,8 +8,8 @@ on: description: 'Version - patch version of the release (e.g. x.y.z)' required: true type: string - backup-utils-release-commit: - description: 'Backup Utils Release Commit - sha of the commit to associate with backup-utils release. If blank, an empty commit will be created on master' + branch-ref-or-commit: + description: 'Branch ref or commit - the backup-utils release will associated with the branch ref or commit provided. If blank, an empty commit will be created on master' required: false type: string draft: @@ -84,14 +84,14 @@ jobs: owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils - if: github.event.inputs.backup-utils-release-commit == '' + if: github.event.inputs.branch-ref-or-commit == '' uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils ref: master - name: Create empty commit - if: github.event.inputs.backup-utils-release-commit == '' + if: github.event.inputs.branch-ref-or-commit == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: @@ -105,12 +105,12 @@ jobs: - name: Resolve release commit id: resolve-release-commit run: | - if [[ -z "${{ github.event.inputs.backup-utils-release-commit }}" ]]; then + if [[ -z "${{ github.event.inputs.branch-ref-or-commit }}" ]]; then echo "Using empty commit sha for release commit" echo "release-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" else echo "Using provided commit sha for release commit" - echo "release-commit=\"${{ github.event.inputs.backup-utils-release-commit }}\"" >> "$GITHUB_OUTPUT" + echo "release-commit=\"${{ github.event.inputs.branch-ref-or-commit }}\"" >> "$GITHUB_OUTPUT" fi # need backup-utils-private for release notes - name: Checkout backup-utils-private From 80d4abea80c44b6db69fbb22f64f4714db4fa358 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 17 Oct 2023 09:26:06 -0400 Subject: [PATCH 2305/2421] reuse app token --- .github/workflows/build-and-release.yml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index efd0d16b6..bf849a8da 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -20,7 +20,10 @@ on: jobs: build: + name: build runs-on: ubuntu-latest + outputs: + token: ${{ steps.app-token.outputs.token }} steps: - uses: actions/create-github-app-token@v1 id: app-token @@ -74,20 +77,13 @@ jobs: runs-on: ubuntu-latest outputs: commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} - release-commit: ${{ steps.resolve-release-commit.outputs.release-commit }} + release-ref-or-commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} steps: - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils if: github.event.inputs.branch-ref-or-commit == '' uses: actions/checkout@v4 with: - token: ${{ steps.app-token.outputs.token }} + token: ${{ needs.build.outputs.token }} repository: github/backup-utils ref: master - name: Create empty commit @@ -107,16 +103,16 @@ jobs: run: | if [[ -z "${{ github.event.inputs.branch-ref-or-commit }}" ]]; then echo "Using empty commit sha for release commit" - echo "release-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" + echo "release-ref-or-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" else echo "Using provided commit sha for release commit" - echo "release-commit=\"${{ github.event.inputs.branch-ref-or-commit }}\"" >> "$GITHUB_OUTPUT" + echo "release-ref-or-commit=\"${{ github.event.inputs.branch-ref-or-commit }}\"" >> "$GITHUB_OUTPUT" fi # need backup-utils-private for release notes - name: Checkout backup-utils-private uses: actions/checkout@v4 with: - token: ${{ steps.app-token.outputs.token }} + token: ${{ needs.build.outputs.token }} repository: github/backup-utils-private - name: Download deb artifact uses: actions/download-artifact@v3 @@ -129,7 +125,7 @@ jobs: - name: Create Release uses: ncipollo/release-action@v1 with: - token: ${{ steps.app-token.outputs.token }} + token: ${{ needs.build.outputs.token }} owner: github repo: backup-utils name: | @@ -138,7 +134,7 @@ jobs: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} - commit: ${{ steps.resolve-release-commit.outputs.release-commit }} + commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} allowUpdates: true From 5641ebcaa212449c74268e1ef9be6ebe629c6075 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 17 Oct 2023 09:41:15 -0400 Subject: [PATCH 2306/2421] fic input name --- .github/workflows/build-and-release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index bf849a8da..12a6e5f7f 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -8,7 +8,7 @@ on: description: 'Version - patch version of the release (e.g. x.y.z)' required: true type: string - branch-ref-or-commit: + branch_ref_or_commit: description: 'Branch ref or commit - the backup-utils release will associated with the branch ref or commit provided. If blank, an empty commit will be created on master' required: false type: string @@ -80,14 +80,14 @@ jobs: release-ref-or-commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} steps: - name: Checkout backup-utils - if: github.event.inputs.branch-ref-or-commit == '' + if: github.event.inputs.branch_ref_or_commit == '' uses: actions/checkout@v4 with: token: ${{ needs.build.outputs.token }} repository: github/backup-utils ref: master - name: Create empty commit - if: github.event.inputs.branch-ref-or-commit == '' + if: github.event.inputs.branch_ref_or_commit == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: @@ -101,12 +101,12 @@ jobs: - name: Resolve release commit id: resolve-release-commit run: | - if [[ -z "${{ github.event.inputs.branch-ref-or-commit }}" ]]; then + if [[ -z "${{ github.event.inputs.branch_ref_or_commit }}" ]]; then echo "Using empty commit sha for release commit" echo "release-ref-or-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" else echo "Using provided commit sha for release commit" - echo "release-ref-or-commit=\"${{ github.event.inputs.branch-ref-or-commit }}\"" >> "$GITHUB_OUTPUT" + echo "release-ref-or-commit=\"${{ github.event.inputs.branch_ref_or_commit }}\"" >> "$GITHUB_OUTPUT" fi # need backup-utils-private for release notes - name: Checkout backup-utils-private From 7b286fc3c08c01d4f9a66affd5c88ed9f2ddf764 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 17 Oct 2023 12:28:06 -0400 Subject: [PATCH 2307/2421] skip token revoke --- .github/workflows/build-and-release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 12a6e5f7f..18a7cb596 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -23,7 +23,7 @@ jobs: name: build runs-on: ubuntu-latest outputs: - token: ${{ steps.app-token.outputs.token }} + rc-app-token: ${{ steps.app-token.outputs.token }} steps: - uses: actions/create-github-app-token@v1 id: app-token @@ -32,6 +32,7 @@ jobs: private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" + skip-token-revoke: true - name: Checkout backup-utils-private uses: actions/checkout@v4 with: @@ -83,7 +84,7 @@ jobs: if: github.event.inputs.branch_ref_or_commit == '' uses: actions/checkout@v4 with: - token: ${{ needs.build.outputs.token }} + token: ${{ needs.build.outputs.rc-app-token }} repository: github/backup-utils ref: master - name: Create empty commit @@ -108,11 +109,10 @@ jobs: echo "Using provided commit sha for release commit" echo "release-ref-or-commit=\"${{ github.event.inputs.branch_ref_or_commit }}\"" >> "$GITHUB_OUTPUT" fi - # need backup-utils-private for release notes - - name: Checkout backup-utils-private + - name: Checkout backup-utils-private for release notes uses: actions/checkout@v4 with: - token: ${{ needs.build.outputs.token }} + token: ${{ needs.build.outputs.rc-app-token }} repository: github/backup-utils-private - name: Download deb artifact uses: actions/download-artifact@v3 @@ -125,7 +125,7 @@ jobs: - name: Create Release uses: ncipollo/release-action@v1 with: - token: ${{ needs.build.outputs.token }} + token: ${{ needs.build.outputs.rc-app-token }} owner: github repo: backup-utils name: | From fef0eec8daf907694a57dda4b1b4163b4230133f Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 17 Oct 2023 13:55:51 -0400 Subject: [PATCH 2308/2421] use create token again --- .github/workflows/build-and-release.yml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 18a7cb596..31eca6eab 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -20,7 +20,6 @@ on: jobs: build: - name: build runs-on: ubuntu-latest outputs: rc-app-token: ${{ steps.app-token.outputs.token }} @@ -31,8 +30,7 @@ jobs: app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} - repositories: "backup-utils,backup-utils-private" - skip-token-revoke: true + repositories: "backup-utils-private" - name: Checkout backup-utils-private uses: actions/checkout@v4 with: @@ -80,11 +78,18 @@ jobs: commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} release-ref-or-commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils if: github.event.inputs.branch_ref_or_commit == '' uses: actions/checkout@v4 with: - token: ${{ needs.build.outputs.rc-app-token }} + token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils ref: master - name: Create empty commit @@ -109,10 +114,14 @@ jobs: echo "Using provided commit sha for release commit" echo "release-ref-or-commit=\"${{ github.event.inputs.branch_ref_or_commit }}\"" >> "$GITHUB_OUTPUT" fi + - name: Check rc-app-token value + if: needs.build.outputs.rc-app-token == '' + run: | + echo "****** rc-app-token is empty ******" - name: Checkout backup-utils-private for release notes uses: actions/checkout@v4 with: - token: ${{ needs.build.outputs.rc-app-token }} + token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils-private - name: Download deb artifact uses: actions/download-artifact@v3 From a8e052d1b0c28a88c523072aba995808db9f54ec Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 17 Oct 2023 14:43:19 -0400 Subject: [PATCH 2309/2421] use app token in release --- .github/workflows/build-and-release.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 31eca6eab..50e86dfef 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -114,10 +114,6 @@ jobs: echo "Using provided commit sha for release commit" echo "release-ref-or-commit=\"${{ github.event.inputs.branch_ref_or_commit }}\"" >> "$GITHUB_OUTPUT" fi - - name: Check rc-app-token value - if: needs.build.outputs.rc-app-token == '' - run: | - echo "****** rc-app-token is empty ******" - name: Checkout backup-utils-private for release notes uses: actions/checkout@v4 with: @@ -134,7 +130,7 @@ jobs: - name: Create Release uses: ncipollo/release-action@v1 with: - token: ${{ needs.build.outputs.rc-app-token }} + token: ${{ steps.app-token.outputs.token }} owner: github repo: backup-utils name: | From 6211c8556fa48fd9ed713cf9fbf1ac333dd96ed3 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Tue, 17 Oct 2023 16:53:58 -0400 Subject: [PATCH 2310/2421] just create draft release --- .github/workflows/build-and-release.yml | 166 ++++++++++++------------ 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 50e86dfef..e55205902 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -19,60 +19,60 @@ on: default: true jobs: - build: - runs-on: ubuntu-latest - outputs: - rc-app-token: ${{ steps.app-token.outputs.token }} - steps: - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: "backup-utils-private" - - name: Checkout backup-utils-private - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag # this is required for the build scripts - run: | - git config user.name "${{ github.actor }}" - git config user.email "ghes-releases-team@github.com" - git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Package deb - run: | - ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - - name: Upload deb artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # build: + # runs-on: ubuntu-latest + # outputs: + # rc-app-token: ${{ steps.app-token.outputs.token }} + # steps: + # - uses: actions/create-github-app-token@v1 + # id: app-token + # with: + # app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: "backup-utils-private" + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip + # - name: Create tag # this is required for the build scripts + # run: | + # git config user.name "${{ github.actor }}" + # git config user.email "ghes-releases-team@github.com" + # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + # git push origin "v${{ github.event.inputs.version }}" + # - name: Package deb + # run: | + # ./script/package-deb + # # many need to remove this once release-notes compilation is automated + # - name: Rename deb artifact + # run: | + # for file in dist/github-backup-utils_*_all.deb; do + # if [[ -f "$file" ]]; then + # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + # fi + # done + # - name: Upload deb artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # path: | + # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Package tarball + # run: | + # ./script/package-tarball + # - name: Upload tarball artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # path: | + # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: - needs: build + # needs: build runs-on: ubuntu-latest outputs: commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} @@ -85,25 +85,25 @@ jobs: private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" - - name: Checkout backup-utils - if: github.event.inputs.branch_ref_or_commit == '' - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - repository: github/backup-utils - ref: master - - name: Create empty commit - if: github.event.inputs.branch_ref_or_commit == '' - uses: stefanzweifel/git-auto-commit-action@v4 - id: empty-commit - with: - branch: master - commit_message: "Test ${{ github.event.inputs.version }} release commit" - commit_user_name: "release-controller[bot]" - commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" - commit_options: "--allow-empty" - push_options: "--force" - skip_dirty_check: true + # - name: Checkout backup-utils + # if: github.event.inputs.branch_ref_or_commit == '' + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # repository: github/backup-utils + # ref: master + # - name: Create empty commit + # if: github.event.inputs.branch_ref_or_commit == '' + # uses: stefanzweifel/git-auto-commit-action@v4 + # id: empty-commit + # with: + # branch: master + # commit_message: "Test ${{ github.event.inputs.version }} release commit" + # commit_user_name: "release-controller[bot]" + # commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" + # commit_options: "--allow-empty" + # push_options: "--force" + # skip_dirty_check: true - name: Resolve release commit id: resolve-release-commit run: | @@ -119,14 +119,14 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils-private - - name: Download deb artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Download tarball artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # - name: Download deb artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Download tarball artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - name: Create Release uses: ncipollo/release-action@v1 with: @@ -135,9 +135,9 @@ jobs: repo: backup-utils name: | GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - artifacts: | - github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - github-backup-utils_${{ github.event.inputs.version }}_all.deb + # artifacts: | + # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + # github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} bodyFile: release-notes/${{ github.event.inputs.version }}.md From 067f6c1bbe6ae6a59703a71ed669f3ac3b97b1ab Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 09:17:29 -0400 Subject: [PATCH 2311/2421] create empty commit on branch ref and use commit sha in release --- .github/workflows/build-and-release.yml | 164 ++++++++++++------------ 1 file changed, 82 insertions(+), 82 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index e55205902..7425d3d6f 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -19,58 +19,58 @@ on: default: true jobs: - # build: - # runs-on: ubuntu-latest - # outputs: - # rc-app-token: ${{ steps.app-token.outputs.token }} - # steps: - # - uses: actions/create-github-app-token@v1 - # id: app-token - # with: - # app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: "backup-utils-private" - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # - name: Create tag # this is required for the build scripts - # run: | - # git config user.name "${{ github.actor }}" - # git config user.email "ghes-releases-team@github.com" - # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - # git push origin "v${{ github.event.inputs.version }}" - # - name: Package deb - # run: | - # ./script/package-deb - # # many need to remove this once release-notes compilation is automated - # - name: Rename deb artifact - # run: | - # for file in dist/github-backup-utils_*_all.deb; do - # if [[ -f "$file" ]]; then - # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - # fi - # done - # - name: Upload deb artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # path: | - # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Package tarball - # run: | - # ./script/package-tarball - # - name: Upload tarball artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # path: | - # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + build: + runs-on: ubuntu-latest + outputs: + rc-app-token: ${{ steps.app-token.outputs.token }} + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: "backup-utils-private" + - name: Checkout backup-utils-private + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag # this is required for the build scripts + run: | + git config user.name "${{ github.actor }}" + git config user.email "ghes-releases-team@github.com" + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + - name: Package deb + run: | + ./script/package-deb + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: # needs: build runs-on: ubuntu-latest @@ -85,35 +85,35 @@ jobs: private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" - # - name: Checkout backup-utils - # if: github.event.inputs.branch_ref_or_commit == '' - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # repository: github/backup-utils - # ref: master - # - name: Create empty commit - # if: github.event.inputs.branch_ref_or_commit == '' - # uses: stefanzweifel/git-auto-commit-action@v4 - # id: empty-commit - # with: - # branch: master - # commit_message: "Test ${{ github.event.inputs.version }} release commit" - # commit_user_name: "release-controller[bot]" - # commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" - # commit_options: "--allow-empty" - # push_options: "--force" - # skip_dirty_check: true - - name: Resolve release commit - id: resolve-release-commit - run: | - if [[ -z "${{ github.event.inputs.branch_ref_or_commit }}" ]]; then - echo "Using empty commit sha for release commit" - echo "release-ref-or-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" - else - echo "Using provided commit sha for release commit" - echo "release-ref-or-commit=\"${{ github.event.inputs.branch_ref_or_commit }}\"" >> "$GITHUB_OUTPUT" - fi + - name: Checkout backup-utils + # if: github.event.inputs.branch_ref_or_commit == '' + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + repository: github/backup-utils + ref: ${{ github.event.inputs.branch_ref_or_commit }}} + - name: Create empty commit + # if: github.event.inputs.branch_ref_or_commit == '' + uses: stefanzweifel/git-auto-commit-action@v4 + id: empty-commit + with: + branch: ${{ github.event.inputs.branch_ref_or_commit }} + commit_message: "Test ${{ github.event.inputs.version }} release commit" + commit_user_name: "release-controller[bot]" + commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" + commit_options: "--allow-empty" + push_options: "--force" + skip_dirty_check: true + # - name: Resolve release commit + # id: resolve-release-commit + # run: | + # if [[ -z "${{ github.event.inputs.branch_ref_or_commit }}" ]]; then + # echo "Using empty commit sha for release commit" + # echo "release-ref-or-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" + # else + # echo "Using provided commit sha for release commit" + # echo "release-ref-or-commit=\"${{ github.event.inputs.branch_ref_or_commit }}\"" >> "$GITHUB_OUTPUT" + # fi - name: Checkout backup-utils-private for release notes uses: actions/checkout@v4 with: @@ -139,7 +139,7 @@ jobs: # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ # github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} - commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} + commit: ${{ steps.empty-commit.outputs.commit_hash }} bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} allowUpdates: true From c3900111e4f76b8988d3806c59cbd01181f6e249 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 09:18:30 -0400 Subject: [PATCH 2312/2421] just release --- .github/workflows/build-and-release.yml | 104 ++++++++++++------------ 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 7425d3d6f..f602d9371 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -19,58 +19,58 @@ on: default: true jobs: - build: - runs-on: ubuntu-latest - outputs: - rc-app-token: ${{ steps.app-token.outputs.token }} - steps: - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: "backup-utils-private" - - name: Checkout backup-utils-private - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag # this is required for the build scripts - run: | - git config user.name "${{ github.actor }}" - git config user.email "ghes-releases-team@github.com" - git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Package deb - run: | - ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - - name: Upload deb artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # build: + # runs-on: ubuntu-latest + # outputs: + # rc-app-token: ${{ steps.app-token.outputs.token }} + # steps: + # - uses: actions/create-github-app-token@v1 + # id: app-token + # with: + # app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: "backup-utils-private" + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip + # - name: Create tag # this is required for the build scripts + # run: | + # git config user.name "${{ github.actor }}" + # git config user.email "ghes-releases-team@github.com" + # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + # git push origin "v${{ github.event.inputs.version }}" + # - name: Package deb + # run: | + # ./script/package-deb + # # many need to remove this once release-notes compilation is automated + # - name: Rename deb artifact + # run: | + # for file in dist/github-backup-utils_*_all.deb; do + # if [[ -f "$file" ]]; then + # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + # fi + # done + # - name: Upload deb artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # path: | + # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Package tarball + # run: | + # ./script/package-tarball + # - name: Upload tarball artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # path: | + # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: # needs: build runs-on: ubuntu-latest From c597504b0cbe25e35a6a520eae6a0a2d43e99046 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 09:20:28 -0400 Subject: [PATCH 2313/2421] fix checkout --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index f602d9371..e1473663e 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -91,7 +91,7 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - ref: ${{ github.event.inputs.branch_ref_or_commit }}} + # ref: ${{ github.event.inputs.branch_ref_or_commit }}} - name: Create empty commit # if: github.event.inputs.branch_ref_or_commit == '' uses: stefanzweifel/git-auto-commit-action@v4 From 7f738f05c47262fcaae1627e59ab7e18990545d5 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 09:29:56 -0400 Subject: [PATCH 2314/2421] try one more time --- .github/workflows/build-and-release.yml | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index e1473663e..79777fadb 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -86,14 +86,14 @@ jobs: owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils - # if: github.event.inputs.branch_ref_or_commit == '' + if: github.event.inputs.branch_ref_or_commit == '' uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils # ref: ${{ github.event.inputs.branch_ref_or_commit }}} - name: Create empty commit - # if: github.event.inputs.branch_ref_or_commit == '' + if: github.event.inputs.branch_ref_or_commit == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: @@ -104,16 +104,16 @@ jobs: commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true - # - name: Resolve release commit - # id: resolve-release-commit - # run: | - # if [[ -z "${{ github.event.inputs.branch_ref_or_commit }}" ]]; then - # echo "Using empty commit sha for release commit" - # echo "release-ref-or-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" - # else - # echo "Using provided commit sha for release commit" - # echo "release-ref-or-commit=\"${{ github.event.inputs.branch_ref_or_commit }}\"" >> "$GITHUB_OUTPUT" - # fi + - name: Resolve release commit + id: resolve-release-commit + run: | + if [[ -z "${{ github.event.inputs.branch_ref_or_commit }}" ]]; then + echo "Using empty commit sha for release commit" + echo "release-ref-or-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" + else + echo "Using provided commit sha for release commit" + echo "release-ref-or-commit=\"${{ github.event.inputs.branch_ref_or_commit }}\"" >> "$GITHUB_OUTPUT" + fi - name: Checkout backup-utils-private for release notes uses: actions/checkout@v4 with: @@ -139,7 +139,7 @@ jobs: # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ # github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} - commit: ${{ steps.empty-commit.outputs.commit_hash }} + commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} allowUpdates: true From 4e343a5ec8503d36cc866f325459f3789ac7e597 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 09:34:48 -0400 Subject: [PATCH 2315/2421] always empty commit on release branch --- .github/workflows/build-and-release.yml | 160 ++++++++++++------------ 1 file changed, 79 insertions(+), 81 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 79777fadb..923fdf727 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -8,9 +8,9 @@ on: description: 'Version - patch version of the release (e.g. x.y.z)' required: true type: string - branch_ref_or_commit: - description: 'Branch ref or commit - the backup-utils release will associated with the branch ref or commit provided. If blank, an empty commit will be created on master' - required: false + release_commit_branch: + description: 'Release Commit Branch - the branch on which the release commit will be made.' + required: true type: string draft: description: 'Draft - true if the release should be a draft' @@ -19,58 +19,58 @@ on: default: true jobs: - # build: - # runs-on: ubuntu-latest - # outputs: - # rc-app-token: ${{ steps.app-token.outputs.token }} - # steps: - # - uses: actions/create-github-app-token@v1 - # id: app-token - # with: - # app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: "backup-utils-private" - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # - name: Create tag # this is required for the build scripts - # run: | - # git config user.name "${{ github.actor }}" - # git config user.email "ghes-releases-team@github.com" - # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - # git push origin "v${{ github.event.inputs.version }}" - # - name: Package deb - # run: | - # ./script/package-deb - # # many need to remove this once release-notes compilation is automated - # - name: Rename deb artifact - # run: | - # for file in dist/github-backup-utils_*_all.deb; do - # if [[ -f "$file" ]]; then - # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - # fi - # done - # - name: Upload deb artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # path: | - # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Package tarball - # run: | - # ./script/package-tarball - # - name: Upload tarball artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # path: | - # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + build: + runs-on: ubuntu-latest + outputs: + rc-app-token: ${{ steps.app-token.outputs.token }} + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: "backup-utils-private" + - name: Checkout backup-utils-private + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag # this is required for the build scripts + run: | + git config user.name "${{ github.actor }}" + git config user.email "ghes-releases-team@github.com" + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + - name: Package deb + run: | + ./script/package-deb + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: # needs: build runs-on: ubuntu-latest @@ -86,47 +86,45 @@ jobs: owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" - name: Checkout backup-utils - if: github.event.inputs.branch_ref_or_commit == '' uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - # ref: ${{ github.event.inputs.branch_ref_or_commit }}} - name: Create empty commit - if: github.event.inputs.branch_ref_or_commit == '' + if: github.event.inputs.release_commit_branch == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: - branch: ${{ github.event.inputs.branch_ref_or_commit }} + branch: ${{ github.event.inputs.release_commit_branch }} commit_message: "Test ${{ github.event.inputs.version }} release commit" commit_user_name: "release-controller[bot]" commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true - - name: Resolve release commit - id: resolve-release-commit - run: | - if [[ -z "${{ github.event.inputs.branch_ref_or_commit }}" ]]; then - echo "Using empty commit sha for release commit" - echo "release-ref-or-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" - else - echo "Using provided commit sha for release commit" - echo "release-ref-or-commit=\"${{ github.event.inputs.branch_ref_or_commit }}\"" >> "$GITHUB_OUTPUT" - fi + # - name: Resolve release commit + # id: resolve-release-commit + # run: | + # if [[ -z "${{ github.event.inputs.release_commit_branch }}" ]]; then + # echo "Using empty commit sha for release commit" + # echo "release-ref-or-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" + # else + # echo "Using provided commit sha for release commit" + # echo "release-ref-or-commit=\"${{ github.event.inputs.release_commit_branch }}\"" >> "$GITHUB_OUTPUT" + # fi - name: Checkout backup-utils-private for release notes uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils-private - # - name: Download deb artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Download tarball artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Download deb artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Download tarball artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - name: Create Release uses: ncipollo/release-action@v1 with: @@ -135,11 +133,11 @@ jobs: repo: backup-utils name: | GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} - # artifacts: | - # github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ - # github-backup-utils_${{ github.event.inputs.version }}_all.deb + artifacts: | + github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} - commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} + commit: ${{ steps.empty-commit.outputs.commit_hash }} bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} allowUpdates: true From 04c7806b092ccec3575555699069dd64c6168018 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 09:36:01 -0400 Subject: [PATCH 2316/2421] after build --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 923fdf727..536c8f971 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -72,7 +72,7 @@ jobs: path: | dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: - # needs: build + needs: build runs-on: ubuntu-latest outputs: commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} From 3ad603b75e6dcbd9fd940b8dbd9c3c0bd2da18e7 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 09:36:52 -0400 Subject: [PATCH 2317/2421] comment out old output --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 536c8f971..d6681ea68 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -76,7 +76,7 @@ jobs: runs-on: ubuntu-latest outputs: commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} - release-ref-or-commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} + # release-ref-or-commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} steps: - uses: actions/create-github-app-token@v1 id: app-token From 1eb6431c5261242cd9f5e2c74998189219302ca1 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 10:39:35 -0400 Subject: [PATCH 2318/2421] one more test --- .github/workflows/build-and-release.yml | 110 ++++++++++++------------ 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index d6681ea68..5419fbbef 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -19,60 +19,60 @@ on: default: true jobs: - build: - runs-on: ubuntu-latest - outputs: - rc-app-token: ${{ steps.app-token.outputs.token }} - steps: - - uses: actions/create-github-app-token@v1 - id: app-token - with: - app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - repositories: "backup-utils-private" - - name: Checkout backup-utils-private - uses: actions/checkout@v4 - with: - token: ${{ steps.app-token.outputs.token }} - - name: Install dependencies - run: | - sudo apt-get update -y - sudo apt-get install -y moreutils debhelper help2man devscripts gzip - - name: Create tag # this is required for the build scripts - run: | - git config user.name "${{ github.actor }}" - git config user.email "ghes-releases-team@github.com" - git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - git push origin "v${{ github.event.inputs.version }}" - - name: Package deb - run: | - ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - - name: Upload deb artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - path: | - dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Package tarball - run: | - ./script/package-tarball - - name: Upload tarball artifact - uses: actions/upload-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - path: | - dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # build: + # runs-on: ubuntu-latest + # outputs: + # rc-app-token: ${{ steps.app-token.outputs.token }} + # steps: + # - uses: actions/create-github-app-token@v1 + # id: app-token + # with: + # app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + # private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + # owner: ${{ github.repository_owner }} + # repositories: "backup-utils-private" + # - name: Checkout backup-utils-private + # uses: actions/checkout@v4 + # with: + # token: ${{ steps.app-token.outputs.token }} + # - name: Install dependencies + # run: | + # sudo apt-get update -y + # sudo apt-get install -y moreutils debhelper help2man devscripts gzip + # - name: Create tag # this is required for the build scripts + # run: | + # git config user.name "${{ github.actor }}" + # git config user.email "ghes-releases-team@github.com" + # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + # git push origin "v${{ github.event.inputs.version }}" + # - name: Package deb + # run: | + # ./script/package-deb + # # many need to remove this once release-notes compilation is automated + # - name: Rename deb artifact + # run: | + # for file in dist/github-backup-utils_*_all.deb; do + # if [[ -f "$file" ]]; then + # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + # fi + # done + # - name: Upload deb artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # path: | + # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Package tarball + # run: | + # ./script/package-tarball + # - name: Upload tarball artifact + # uses: actions/upload-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # path: | + # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: - needs: build + # needs: build runs-on: ubuntu-latest outputs: commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} @@ -91,7 +91,7 @@ jobs: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - name: Create empty commit - if: github.event.inputs.release_commit_branch == '' + # if: github.event.inputs.release_commit_branch == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: @@ -137,7 +137,7 @@ jobs: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} - commit: ${{ steps.empty-commit.outputs.commit_hash }} + commit: 3.9-main bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} allowUpdates: true From 7a88c2c933aabf070d9b0cf87615ec4f5bdd786a Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 10:42:11 -0400 Subject: [PATCH 2319/2421] test, no artifacts --- .github/workflows/build-and-release.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 5419fbbef..953ff86b8 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -117,14 +117,14 @@ jobs: with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils-private - - name: Download deb artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - - name: Download tarball artifact - uses: actions/download-artifact@v3 - with: - name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + # - name: Download deb artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + # - name: Download tarball artifact + # uses: actions/download-artifact@v3 + # with: + # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - name: Create Release uses: ncipollo/release-action@v1 with: From 7ab47f1160153771c246d0531319447df5be84cc Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 11:50:08 -0400 Subject: [PATCH 2320/2421] try stable branch --- .github/workflows/build-and-release.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 953ff86b8..da58c6bb1 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -8,10 +8,6 @@ on: description: 'Version - patch version of the release (e.g. x.y.z)' required: true type: string - release_commit_branch: - description: 'Release Commit Branch - the branch on which the release commit will be made.' - required: true - type: string draft: description: 'Draft - true if the release should be a draft' required: true @@ -76,7 +72,6 @@ jobs: runs-on: ubuntu-latest outputs: commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} - # release-ref-or-commit: ${{ steps.resolve-release-commit.outputs.release-ref-or-commit }} steps: - uses: actions/create-github-app-token@v1 id: app-token @@ -85,17 +80,20 @@ jobs: private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} owner: ${{ github.repository_owner }} repositories: "backup-utils,backup-utils-private" + - name: Get major-feature from version + id: get-major-feature + run: | + echo "major-feature=\"$(echo "${{ github.event.inputs.version }}" | cut -d '.' -f 1,2)\"" >> "$GITHUB_OUTPUT" - name: Checkout backup-utils uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils - name: Create empty commit - # if: github.event.inputs.release_commit_branch == '' uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: - branch: ${{ github.event.inputs.release_commit_branch }} + branch: ${{ steps.get-major-feature.outputs.major-feature}}-stable commit_message: "Test ${{ github.event.inputs.version }} release commit" commit_user_name: "release-controller[bot]" commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" @@ -134,10 +132,10 @@ jobs: name: | GitHub Enterprise Server Backup Utilities v${{ github.event.inputs.version }} artifacts: | - github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, \ + github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} - commit: 3.9-main + commit: ${{ steps.get-major-feature.outputs.major-feature}}-stable bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} allowUpdates: true From 68c71b97f0ad99f34c2b1e6e38f5d960ff307379 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 13:38:05 -0400 Subject: [PATCH 2321/2421] handle major-feature --- .github/workflows/build-and-release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index da58c6bb1..7402a17d7 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -83,7 +83,10 @@ jobs: - name: Get major-feature from version id: get-major-feature run: | - echo "major-feature=\"$(echo "${{ github.event.inputs.version }}" | cut -d '.' -f 1,2)\"" >> "$GITHUB_OUTPUT" + echo "MAJOR_FEATURE=$(echo "${{ github.event.inputs.version }} | cut -d '.' -f 1,2)" >> "$GITHUB_ENV" + - name: Verify major-feature + run: | + echo "major_feature: $MAJOR_FEATURE" - name: Checkout backup-utils uses: actions/checkout@v4 with: @@ -93,7 +96,7 @@ jobs: uses: stefanzweifel/git-auto-commit-action@v4 id: empty-commit with: - branch: ${{ steps.get-major-feature.outputs.major-feature}}-stable + branch: ${{ env.MAJOR_FEATURE }}-stable commit_message: "Test ${{ github.event.inputs.version }} release commit" commit_user_name: "release-controller[bot]" commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" From 56c72781e79d7aff1607b7f5358ebc363a6c2742 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 13:56:36 -0400 Subject: [PATCH 2322/2421] fix major-feature --- .github/workflows/build-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 7402a17d7..48d0a8ca9 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -83,7 +83,7 @@ jobs: - name: Get major-feature from version id: get-major-feature run: | - echo "MAJOR_FEATURE=$(echo "${{ github.event.inputs.version }} | cut -d '.' -f 1,2)" >> "$GITHUB_ENV" + echo "MAJOR_FEATURE=\"$(echo "${{ github.event.inputs.version }}" | cut -d '.' -f 1,2)\"" >> "$GITHUB_ENV" - name: Verify major-feature run: | echo "major_feature: $MAJOR_FEATURE" @@ -138,7 +138,7 @@ jobs: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz, github-backup-utils_${{ github.event.inputs.version }}_all.deb tag: v${{ github.event.inputs.version }} - commit: ${{ steps.get-major-feature.outputs.major-feature}}-stable + commit: ${{ env.MAJOR_FEATURE }}-stable bodyFile: release-notes/${{ github.event.inputs.version }}.md draft: ${{ github.event.inputs.draft }} allowUpdates: true From f147c4e8c8b67e04f80363fab1120044501eac09 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 14:13:22 -0400 Subject: [PATCH 2323/2421] try another fix --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 48d0a8ca9..8f03dec9a 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -83,7 +83,7 @@ jobs: - name: Get major-feature from version id: get-major-feature run: | - echo "MAJOR_FEATURE=\"$(echo "${{ github.event.inputs.version }}" | cut -d '.' -f 1,2)\"" >> "$GITHUB_ENV" + echo "MAJOR_FEATURE=$(echo ${{ github.event.inputs.version }} | cut -d '.' -f 1,2)" >> "$GITHUB_ENV" - name: Verify major-feature run: | echo "major_feature: $MAJOR_FEATURE" From aa80191b74138d6b71997976630f3bfded0440d2 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 14:17:12 -0400 Subject: [PATCH 2324/2421] check release --- release-notes/{12.12.12.md => 3.10.99.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename release-notes/{12.12.12.md => 3.10.99.md} (100%) diff --git a/release-notes/12.12.12.md b/release-notes/3.10.99.md similarity index 100% rename from release-notes/12.12.12.md rename to release-notes/3.10.99.md From 77dad72bc7c6516af482e973d8981bf090ccf1f4 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 14:40:37 -0400 Subject: [PATCH 2325/2421] should be done --- .github/workflows/build-and-release.yml | 132 +++++++++++------------- 1 file changed, 61 insertions(+), 71 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 8f03dec9a..3f6b78648 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -15,60 +15,60 @@ on: default: true jobs: - # build: - # runs-on: ubuntu-latest - # outputs: - # rc-app-token: ${{ steps.app-token.outputs.token }} - # steps: - # - uses: actions/create-github-app-token@v1 - # id: app-token - # with: - # app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} - # private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} - # owner: ${{ github.repository_owner }} - # repositories: "backup-utils-private" - # - name: Checkout backup-utils-private - # uses: actions/checkout@v4 - # with: - # token: ${{ steps.app-token.outputs.token }} - # - name: Install dependencies - # run: | - # sudo apt-get update -y - # sudo apt-get install -y moreutils debhelper help2man devscripts gzip - # - name: Create tag # this is required for the build scripts - # run: | - # git config user.name "${{ github.actor }}" - # git config user.email "ghes-releases-team@github.com" - # git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" - # git push origin "v${{ github.event.inputs.version }}" - # - name: Package deb - # run: | - # ./script/package-deb - # # many need to remove this once release-notes compilation is automated - # - name: Rename deb artifact - # run: | - # for file in dist/github-backup-utils_*_all.deb; do - # if [[ -f "$file" ]]; then - # mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - # fi - # done - # - name: Upload deb artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # path: | - # dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Package tarball - # run: | - # ./script/package-tarball - # - name: Upload tarball artifact - # uses: actions/upload-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - # path: | - # dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + build: + runs-on: ubuntu-latest + outputs: + rc-app-token: ${{ steps.app-token.outputs.token }} + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.RELEASE_CONTROLLER_APP_ID }} + private-key: ${{ secrets.RELEASE_CONTROLLER_APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + repositories: "backup-utils-private" + - name: Checkout backup-utils-private + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + - name: Install dependencies + run: | + sudo apt-get update -y + sudo apt-get install -y moreutils debhelper help2man devscripts gzip + - name: Create tag # this is required for the build scripts + run: | + git config user.name "${{ github.actor }}" + git config user.email "ghes-releases-team@github.com" + git tag -a "v${{ github.event.inputs.version }}" -m "v${{ github.event.inputs.version }}" + git push origin "v${{ github.event.inputs.version }}" + - name: Package deb + run: | + ./script/package-deb + # many need to remove this once release-notes compilation is automated + - name: Rename deb artifact + run: | + for file in dist/github-backup-utils_*_all.deb; do + if [[ -f "$file" ]]; then + mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" + fi + done + - name: Upload deb artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + path: | + dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Package tarball + run: | + ./script/package-tarball + - name: Upload tarball artifact + uses: actions/upload-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + path: | + dist/github-backup-utils-v${{ github.event.inputs.version }}.tar.gz release: - # needs: build + needs: build runs-on: ubuntu-latest outputs: commit_hash: ${{ steps.empty-commit.outputs.commit_hash }} @@ -103,29 +103,19 @@ jobs: commit_options: "--allow-empty" push_options: "--force" skip_dirty_check: true - # - name: Resolve release commit - # id: resolve-release-commit - # run: | - # if [[ -z "${{ github.event.inputs.release_commit_branch }}" ]]; then - # echo "Using empty commit sha for release commit" - # echo "release-ref-or-commit=\"${{ steps.empty-commit.outputs.commit_hash }}\"" >> "$GITHUB_OUTPUT" - # else - # echo "Using provided commit sha for release commit" - # echo "release-ref-or-commit=\"${{ github.event.inputs.release_commit_branch }}\"" >> "$GITHUB_OUTPUT" - # fi - name: Checkout backup-utils-private for release notes uses: actions/checkout@v4 with: token: ${{ steps.app-token.outputs.token }} repository: github/backup-utils-private - # - name: Download deb artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils_${{ github.event.inputs.version }}_all.deb - # - name: Download tarball artifact - # uses: actions/download-artifact@v3 - # with: - # name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz + - name: Download deb artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils_${{ github.event.inputs.version }}_all.deb + - name: Download tarball artifact + uses: actions/download-artifact@v3 + with: + name: github-backup-utils-v${{ github.event.inputs.version }}.tar.gz - name: Create Release uses: ncipollo/release-action@v1 with: From 540ae1cc01cf3bc3c2172feff74078646dc26f83 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 14:50:40 -0400 Subject: [PATCH 2326/2421] remove test message --- .github/workflows/build-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 3f6b78648..c9b6b66e8 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -97,7 +97,7 @@ jobs: id: empty-commit with: branch: ${{ env.MAJOR_FEATURE }}-stable - commit_message: "Test ${{ github.event.inputs.version }} release commit" + commit_message: "${{ github.event.inputs.version }} release" commit_user_name: "release-controller[bot]" commit_user_email: "223695+release-controller[bot]@users.noreply.github.com" commit_options: "--allow-empty" From 30612641edc735f268a73fdcecf6cfe8f6ca8476 Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Wed, 18 Oct 2023 15:45:57 -0400 Subject: [PATCH 2327/2421] remove test release notes --- release-notes/3.10.99.md | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 release-notes/3.10.99.md diff --git a/release-notes/3.10.99.md b/release-notes/3.10.99.md deleted file mode 100644 index 445d9aada..000000000 --- a/release-notes/3.10.99.md +++ /dev/null @@ -1,7 +0,0 @@ -### Changes - -* Test release notes. - -### Bug fixes - -* More test release notes. \ No newline at end of file From 5d2d9a8ada57e543383f585d08c857bee518cfad Mon Sep 17 00:00:00 2001 From: Tim Reimherr Date: Fri, 20 Oct 2023 23:20:02 +0000 Subject: [PATCH 2328/2421] remove file rename step --- .github/workflows/build-and-release.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index c9b6b66e8..edf115738 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -44,14 +44,6 @@ jobs: - name: Package deb run: | ./script/package-deb - # many need to remove this once release-notes compilation is automated - - name: Rename deb artifact - run: | - for file in dist/github-backup-utils_*_all.deb; do - if [[ -f "$file" ]]; then - mv "$file" "dist/github-backup-utils_${{ github.event.inputs.version }}_all.deb" - fi - done - name: Upload deb artifact uses: actions/upload-artifact@v3 with: From dfca0ab97591346f2abc3ad05fa84893de4e3fdf Mon Sep 17 00:00:00 2001 From: Quinn Murphy Date: Mon, 23 Oct 2023 14:03:40 -0400 Subject: [PATCH 2329/2421] Add unit test for track progress (#659) * Add unit test for track progress * add end_test * change test and fix init-progress * Make the test go green * Update ghe-backup-config --- share/github-backup-utils/ghe-backup-config | 14 +++++--------- test/test-ghe-backup.sh | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 6c33ea954..cd9972b59 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -661,17 +661,13 @@ prompt_for_confirmation(){ #initialize progress tracking by clearing out the temp files used to track init-progress() { - if [ -d /tmp/backup-utils-progress ]; then + + if [ -e /tmp/backup-utils-progress ]; then rm -rf /tmp/backup-utils-progress/* fi - - mkdir -p /tmp/backup-utils-progress - chmod -R 777 /tmp/backup-utils-progress - - touch /tmp/backup-utils-progress/total - touch /tmp/backup-utils-progress/type - touch /tmp/backup-utils-progress/progress - touch /tmp/backup-utils-progress/info + # shellcheck disable=SC2174 # We are fine with -m only affecting the deepest directory + mkdir -m 777 -p /tmp/backup-utils-progress + touch /tmp/backup-utils-progress/{total,type,progress,info} } diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index d6391bbef..dabce1ed4 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -1074,3 +1074,18 @@ begin_test "ghe-backup collects information on system where backup-utils is inst ) end_test + +# Check that backup-utils manages track-progress folder correctly +begin_test "ghe-backup manages progress tracking files properly" +( + set -e + + if [ -e /tmp/backup-utils-progress ]; then + rm -rf /tmp/backup-utils-progress/* + fi + + output=$(ghe-backup) + echo "$output" | grep -v "mkdir: cannot create directory /tmp/backup-utils-progress: File exists" + +) +end_test \ No newline at end of file From d9cf3a64fc521f43eb2553e06dbedaf59596be1c Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 24 Oct 2023 09:52:06 -0700 Subject: [PATCH 2330/2421] Use os-release for host info resolves https://github.com/github/ghes/issues/7336 --- bin/ghe-backup | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 1dfaf748b..448a5840e 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -231,9 +231,11 @@ fi # Output system information of the backup host -# If /etc/issue.net exists, use it to get the OS version -if [ -f /etc/issue.net ]; then - echo "Running on: $(cat /etc/issue.net)" +# If /etc/os-release exists, use it to get the OS version +if [ -f /etc/os-release ]; then + OS_NAME=$(grep '^NAME' /etc/os-release | cut -d'"' -f2) + VERSION_ID=$(grep '^VERSION_ID' /etc/os-release | cut -d'"' -f2) + echo "Running on: $OS_NAME $VERSION_ID" else echo "Running on: Unknown OS" fi From 4b477a69b59ef625d606905bda65f74f0a984f7f Mon Sep 17 00:00:00 2001 From: Tony Truong Date: Wed, 25 Oct 2023 16:18:29 +0200 Subject: [PATCH 2331/2421] update warning message (#699) --- share/github-backup-utils/ghe-backup-secrets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-secrets b/share/github-backup-utils/ghe-backup-secrets index 546be420e..6d7ab5db6 100755 --- a/share/github-backup-utils/ghe-backup-secrets +++ b/share/github-backup-utils/ghe-backup-secrets @@ -54,7 +54,7 @@ backup-secret() { log_info "* Transferring $description ..." 1>&3 ghe-ssh "$host" -- ghe-config "$setting" > "$file+" || ( if [ "$best_effort" = "false" ]; then - echo "Warning: $description not set" >&2 + echo "Info: $description not set. Skipping..." >&2 fi ) if [ -n "$(cat "$file+")" ]; then From c30b46422c2b4638a01b1965f41f748612907b74 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 25 Oct 2023 20:59:43 +0000 Subject: [PATCH 2332/2421] check for RO file-system --- bin/ghe-host-check | 35 ++++++++++++++++++++++++++++++++++- test/test-ghe-host-check.sh | 10 ++++++++++ test/testlib.sh | 4 ++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 5cd39abee..4262887e1 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -115,6 +115,39 @@ if [ -z "$version" ]; then exit 2 fi +NON_WRITABLE="" +# ensure all nodes are writable +if "$CLUSTER"; then + if [ -z "$FILE_TO_TEST" ]; then + FILE_TO_TEST="/data/user/tmp/test-ro-file.txt" + fi + + # Iterate through each node in the cluster + nodes=$(ghe-ssh "$host" ghe-cluster-nodes) + first=true + # echo $nodes | while read -r node; do + for node in $nodes; do + if ! $(echo "set -o pipefail; ssh "$node" -- 'touch "$FILE_TO_TEST" && rm "$FILE_TO_TEST"'" | ghe-ssh "$host" /bin/bash); then + #echo "File system is writable on $node" + #else + echo "File system is not writeable on $node" 1>&2 + if [ "$first" = true ]; then + NON_WRITABLE="$node" + first=false + else + NON_WRITABLE="$NON_WRITABLE, $node" + fi + fi || true + done + # Display the comma-separated list of non-writable nodes + if [ ! -z "$NON_WRITABLE" ]; then + echo "Error: Non-writable nodes: $NON_WRITABLE . Please make sure the file systems for all Enterprise nodes are writable." 1>&2 + exit 1 + else + echo "All nodes are writable." + fi +fi + # Block restoring snapshots to older releases of GitHub Enterprise Server if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) @@ -177,7 +210,7 @@ SKIP_MSG #Display dir requirements for repositories and mysql echo -e "\nChecking host for sufficient space for a backup..." - available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') + available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." repos_disk_size=$(transfer_size repositories /tmp) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index f2c5cca54..ebe02f0e6 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -123,3 +123,13 @@ begin_test "ghe-host-check blocks restore to old release" ! GHE_TEST_REMOTE_VERSION=$bu_version_major.$((bu_version_minor-1)).$bu_version_patch ghe-restore -v ) end_test + +# Check ghe-host-check detects RO file system +begin_test "ghe-host-check fails when encountering RO file-system" +( + set -e + + enable_ro_fs + ! FILE_TO_TEST=/run/user/501/test ghe-host-check +) +end_test diff --git a/test/testlib.sh b/test/testlib.sh index edeec8ea2..b72866abe 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -728,3 +728,7 @@ setup_actions_enabled_settings_for_restore() { echo > "$GHE_DATA_DIR/1/settings.json" git config -f "$GHE_DATA_DIR/1/settings.json" --bool app.actions.enabled $1 } + +enable_ro_fs() { + ghe-ssh "$GHE_HOSTNAME" -- 'sudo mount -o remount,rw /run/user/501' +} From 44a59b55378cce06845acb46e71d981b6b91fdb0 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 25 Oct 2023 14:24:21 -0700 Subject: [PATCH 2333/2421] Update test-ghe-backup.sh --- test/test-ghe-backup.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-backup.sh b/test/test-ghe-backup.sh index dabce1ed4..30fc23fcb 100755 --- a/test/test-ghe-backup.sh +++ b/test/test-ghe-backup.sh @@ -1068,7 +1068,9 @@ begin_test "ghe-backup collects information on system where backup-utils is inst set -e output=$(ghe-backup) - echo "$output" | grep "Running on: $(cat /etc/issue.net)" + OS_NAME=$(grep '^NAME' /etc/os-release | cut -d'"' -f2) + VERSION_ID=$(grep '^VERSION_ID' /etc/os-release | cut -d'"' -f2) + echo "$output" | grep "Running on: $OS_NAME $VERSION_ID" echo "$output" | grep "CPUs: $(nproc)" echo "$output" | grep "Memory total/used/free+share/buff/cache:" @@ -1088,4 +1090,4 @@ begin_test "ghe-backup manages progress tracking files properly" echo "$output" | grep -v "mkdir: cannot create directory /tmp/backup-utils-progress: File exists" ) -end_test \ No newline at end of file +end_test From 494a521089c71e595a77983f0f4b02ee3b79685b Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 26 Oct 2023 00:30:52 +0000 Subject: [PATCH 2334/2421] check for tmp dir --- bin/ghe-host-check | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 4262887e1..8bcdb85f0 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -119,7 +119,11 @@ NON_WRITABLE="" # ensure all nodes are writable if "$CLUSTER"; then if [ -z "$FILE_TO_TEST" ]; then - FILE_TO_TEST="/data/user/tmp/test-ro-file.txt" + if [ -d "/data/user/tmp" ]; then + FILE_TO_TEST="/data/user/tmp/test-ro-file.txt" + else + FILE_TO_TEST="/tmp/test-ro-file.txt" + fi fi # Iterate through each node in the cluster From 88f8489b6ebf36703a80754f9bba581a61e556d0 Mon Sep 17 00:00:00 2001 From: djdefi Date: Mon, 30 Oct 2023 15:43:34 -0700 Subject: [PATCH 2335/2421] Shellcheck docker-image.yml --- .github/workflows/docker-image.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 07c44f9df..03050f1d4 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,4 +1,4 @@ -name: Docker Image CI +name: Docker Image Build CI on: push: @@ -13,16 +13,16 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build the Ubuntu Docker image - run: docker build . --file Dockerfile --tag backup-utils:${GITHUB_RUN_ID} + run: docker build . --file Dockerfile --tag backup-utils:"${GITHUB_RUN_ID}" - name: Build the Alpine Docker image - run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:${GITHUB_RUN_ID} + run: docker build . --file Dockerfile.alpine --tag backup-utils-alpine:"${GITHUB_RUN_ID}" - name: Run tests in Ubuntu Docker image run: | - docker run backup-utils:${GITHUB_RUN_ID} ghe-backup --version - docker run backup-utils:${GITHUB_RUN_ID} rsync --version + docker run backup-utils:"${GITHUB_RUN_ID}" ghe-backup --version + docker run backup-utils:"${GITHUB_RUN_ID}" rsync --version - name: Run tests in Alpine Docker image run: | - docker run backup-utils-alpine:${GITHUB_RUN_ID} ghe-backup --version - docker run backup-utils-alpine:${GITHUB_RUN_ID} rsync --version + docker run backup-utils-alpine:"${GITHUB_RUN_ID}" ghe-backup --version + docker run backup-utils-alpine:"${GITHUB_RUN_ID}" rsync --version From d4c2952dda4176289eb9b0375c4efc9786d2d4d1 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 31 Oct 2023 15:15:50 -0700 Subject: [PATCH 2336/2421] Shellcheck fix backuprestore.yml --- .github/workflows/backuprestore.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/backuprestore.yml b/.github/workflows/backuprestore.yml index 13bbf40e0..34cf69032 100644 --- a/.github/workflows/backuprestore.yml +++ b/.github/workflows/backuprestore.yml @@ -28,7 +28,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: github/backup-utils-private ref: ${{ inputs.ref }} @@ -51,13 +51,13 @@ jobs: run: docker load -i backup-utils.tar - uses: actions/checkout@v3 - name: Create backup directory - run: mkdir $HOME/ghe-backup-data + run: mkdir "$HOME"/ghe-backup-data - name: set up ssh SSH_KEY - run: echo -e "${SSH_KEY}\n" > $HOME/backup + run: echo -e "${SSH_KEY}\n" > "$HOME"/backup - name: set up ssh key permissions - run: chmod 0600 $HOME/backup + run: chmod 0600 "$HOME"/backup - name: change version - run: echo "3.8.0" > $HOME/version + run: echo "3.8.0" > "$HOME"/version - name: Perform backup run: | docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ @@ -70,7 +70,7 @@ jobs: --rm \ backup-utils ghe-backup - name: Prepare for restore - run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" + run: ssh -p122 -i "$HOME"/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -s" - name: Restore data to instance run: | docker run -e "GHE_HOSTNAME=${{ inputs.hostname }}" \ @@ -83,5 +83,5 @@ jobs: --rm \ backup-utils ghe-restore ${{ inputs.hostname }} - name: Reset maintenance mode after restore - run: ssh -p122 -i $HOME/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" + run: ssh -p122 -i "$HOME"/backup -o StrictHostKeyChecking=no admin@${{ inputs.hostname }} "ghe-maintenance -u" From d9619a1a5578efd93cf2fea0c0c9d5181d6d9ac1 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 31 Oct 2023 15:16:42 -0700 Subject: [PATCH 2337/2421] Lint fix restore.yml --- .github/workflows/restore.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/restore.yml b/.github/workflows/restore.yml index ab0627751..5f4e723a1 100644 --- a/.github/workflows/restore.yml +++ b/.github/workflows/restore.yml @@ -51,7 +51,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: github/backup-utils-private ref: ${{ inputs.ref }} @@ -69,7 +69,7 @@ jobs: needs: build runs-on: group: larger-hosted-public-runners - labels: ubuntu-latest-xl + labels: ubuntu-latest env: SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }} steps: From 4f8b5de6f45ad2f7ef9819f26579b0726ecd4aa3 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 1 Nov 2023 09:22:12 -0700 Subject: [PATCH 2338/2421] Linter fix backup.yml --- .github/workflows/backup.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 237d8e131..0d50f8f81 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -47,7 +47,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: github/backup-utils-private token: "${{ secrets.INTERNAL_ACTIONS_DX_BOT_ACCOUNT_TOKEN }}" @@ -62,7 +62,7 @@ jobs: needs: build runs-on: group: larger-hosted-public-runners - labels: ubuntu-latest-xl + labels: ubuntu-latest env: SSH_KEY: ${{ secrets.BACKUP_SSH_KEY }} steps: @@ -98,7 +98,7 @@ jobs: sudo tar -czvf "${{ inputs.backup-name }}.tar.gz" -C "$HOME/ghe-backup-data/$current" . - name: Login to Azure - if: ${{ inputs.backup-name }} != "" + if: inputs.backup-name != "" run: | az login \ --service-principal \ @@ -108,11 +108,11 @@ jobs: az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}" - name: Upload backup to Azure - if: ${{ inputs.backup-name }} != "" + if: inputs.backup-name != "" run: | az storage blob upload \ --account-name "${{ secrets.AZURE_ACCOUNT_NAME }}" \ --container-name "${{ secrets.AZURE_CONTAINER_NAME }}" \ --name "${{ inputs.backup-name }}.tar.gz" \ --file "${{ inputs.backup-name }}.tar.gz" \ - --connection-string "${{ secrets.CONNECTIONSTRING }}" \ No newline at end of file + --connection-string "${{ secrets.CONNECTIONSTRING }}" From c8f1a5e28ad3fda848abeaece2bb47845fe2b0d5 Mon Sep 17 00:00:00 2001 From: djdefi Date: Wed, 1 Nov 2023 09:29:15 -0700 Subject: [PATCH 2339/2421] Adjust if statement syntax --- .github/workflows/backup.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 0d50f8f81..cfb154aae 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -98,7 +98,7 @@ jobs: sudo tar -czvf "${{ inputs.backup-name }}.tar.gz" -C "$HOME/ghe-backup-data/$current" . - name: Login to Azure - if: inputs.backup-name != "" + if: "${{ inputs.backup-name != '' }}" run: | az login \ --service-principal \ @@ -108,7 +108,7 @@ jobs: az account set --subscription "${{ secrets.AZURE_SUBSCRIPTION_ID }}" - name: Upload backup to Azure - if: inputs.backup-name != "" + if: "${{ inputs.backup-name != '' }}" run: | az storage blob upload \ --account-name "${{ secrets.AZURE_ACCOUNT_NAME }}" \ From ac1cbb1dc0b39e4d86490f21d7ab25cafa1cb004 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 1 Nov 2023 20:06:49 +0000 Subject: [PATCH 2340/2421] fix test runs --- bin/ghe-host-check | 8 +++++--- test/test-ghe-host-check.sh | 9 +++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 8bcdb85f0..2b77d11ff 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -85,7 +85,9 @@ if [ $rc -ne 0 ]; then exit $rc fi -CLUSTER=false +if [ -z "$CLUSTER" ]; then + CLUSTER=false +fi if ghe-ssh "$host" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then CLUSTER=true @@ -117,7 +119,7 @@ fi NON_WRITABLE="" # ensure all nodes are writable -if "$CLUSTER"; then +if [ "$CLUSTER" == "true" ] ; then if [ -z "$FILE_TO_TEST" ]; then if [ -d "/data/user/tmp" ]; then FILE_TO_TEST="/data/user/tmp/test-ro-file.txt" @@ -164,7 +166,7 @@ if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then fi if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then - if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state 2>/dev/null || true)" = "replica" ]; then + if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state1 2>/dev/null || true)" = "replica" ]; then echo "Error: high availability replica detected." 1>&2 echo "Backup Utilities should be used to backup from the primary node in" 1>&2 echo "high availability environments to ensure consistent and reliable backups." 1>&2 diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index ebe02f0e6..1a32e34cd 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -129,7 +129,12 @@ begin_test "ghe-host-check fails when encountering RO file-system" ( set -e - enable_ro_fs - ! FILE_TO_TEST=/run/user/501/test ghe-host-check + ghe-ssh "$GHE_HOSTNAME" -- 'mkdir -p "~/tmp"' + # Remove write access in ~/tmp + ghe-ssh "$GHE_HOSTNAME" -- 'chmod a-w -R "~/tmp"' + + # File creation fails for CLUSTER + ! FILE_TO_TEST="~/tmp/test" CLUSTER=true ghe-host-check + FILE_TO_TEST="~/tmp/test" CLUSTER=false ghe-host-check ) end_test From c86c42548cafd6e915ee708775751b7fc11d7892 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 1 Nov 2023 20:24:19 +0000 Subject: [PATCH 2341/2421] remove unused function --- test/testlib.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/testlib.sh b/test/testlib.sh index b72866abe..edeec8ea2 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -728,7 +728,3 @@ setup_actions_enabled_settings_for_restore() { echo > "$GHE_DATA_DIR/1/settings.json" git config -f "$GHE_DATA_DIR/1/settings.json" --bool app.actions.enabled $1 } - -enable_ro_fs() { - ghe-ssh "$GHE_HOSTNAME" -- 'sudo mount -o remount,rw /run/user/501' -} From 970cb37787700dd7590e4a4f38dd8aa27e30a77a Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Wed, 1 Nov 2023 21:17:42 +0000 Subject: [PATCH 2342/2421] SC updates --- bin/ghe-host-check | 2 +- test/test-ghe-host-check.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 2b77d11ff..cf62e6453 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -133,7 +133,7 @@ if [ "$CLUSTER" == "true" ] ; then first=true # echo $nodes | while read -r node; do for node in $nodes; do - if ! $(echo "set -o pipefail; ssh "$node" -- 'touch "$FILE_TO_TEST" && rm "$FILE_TO_TEST"'" | ghe-ssh "$host" /bin/bash); then + if ! echo "set -o pipefail; ssh $node -- 'touch $FILE_TO_TEST && rm $FILE_TO_TEST'" | ghe-ssh "$host" /bin/bash; then #echo "File system is writable on $node" #else echo "File system is not writeable on $node" 1>&2 diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 1a32e34cd..a772399d6 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -134,7 +134,7 @@ begin_test "ghe-host-check fails when encountering RO file-system" ghe-ssh "$GHE_HOSTNAME" -- 'chmod a-w -R "~/tmp"' # File creation fails for CLUSTER - ! FILE_TO_TEST="~/tmp/test" CLUSTER=true ghe-host-check - FILE_TO_TEST="~/tmp/test" CLUSTER=false ghe-host-check + ! FILE_TO_TEST="$HOME/tmp/test" CLUSTER=true ghe-host-check + FILE_TO_TEST="$HOME/tmp/test" CLUSTER=false ghe-host-check ) end_test From 0bb47041013c696121843420bd8c4a59b1326b75 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Thu, 2 Nov 2023 20:09:21 +0000 Subject: [PATCH 2343/2421] review updates --- backup.config-example | 4 ++++ bin/ghe-host-check | 11 +++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/backup.config-example b/backup.config-example index 535a2f636..99bcfd232 100644 --- a/backup.config-example +++ b/backup.config-example @@ -32,6 +32,10 @@ GHE_NUM_SNAPSHOTS=10 # disk space validation and software version checks on the backup-host will be disabled. #GHE_SKIP_CHECKS=false +# Cluster filesystem to check if it's writable as part of ghe-host-check +# By default it is /data/user/tmp but can be updated if needed +#GHE_FILE_SYSTEM_CHECK="/data/user/tmp" + # The hostname of the GitHub appliance to restore. If you've set up a separate # GitHub appliance to act as a standby for recovery, specify its IP or hostname # here. The host to restore to may also be specified directly when running diff --git a/bin/ghe-host-check b/bin/ghe-host-check index cf62e6453..b5bdcd1ff 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -120,23 +120,22 @@ fi NON_WRITABLE="" # ensure all nodes are writable if [ "$CLUSTER" == "true" ] ; then - if [ -z "$FILE_TO_TEST" ]; then + if [ -z "$GHE_FILE_SYSTEM_CHECK" ]; then if [ -d "/data/user/tmp" ]; then FILE_TO_TEST="/data/user/tmp/test-ro-file.txt" else FILE_TO_TEST="/tmp/test-ro-file.txt" fi + else + FILE_TO_TEST="$GHE_FILE_SYSTEM_CHECK/test-ro-file.txt" fi # Iterate through each node in the cluster nodes=$(ghe-ssh "$host" ghe-cluster-nodes) first=true - # echo $nodes | while read -r node; do for node in $nodes; do if ! echo "set -o pipefail; ssh $node -- 'touch $FILE_TO_TEST && rm $FILE_TO_TEST'" | ghe-ssh "$host" /bin/bash; then - #echo "File system is writable on $node" - #else - echo "File system is not writeable on $node" 1>&2 + echo "File system is not writeable or no permission on $node" 1>&2 if [ "$first" = true ]; then NON_WRITABLE="$node" first=false @@ -147,7 +146,7 @@ if [ "$CLUSTER" == "true" ] ; then done # Display the comma-separated list of non-writable nodes if [ ! -z "$NON_WRITABLE" ]; then - echo "Error: Non-writable nodes: $NON_WRITABLE . Please make sure the file systems for all Enterprise nodes are writable." 1>&2 + log_error "Error: Following nodes are non-writable - $NON_WRITABLE. Please make sure the filesystem for all GHES nodes are writable." 1>&2 exit 1 else echo "All nodes are writable." From 6d86ba0920b326e3335370939a28de86ba40a34f Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 3 Nov 2023 14:55:07 +0000 Subject: [PATCH 2344/2421] fix typo --- bin/ghe-host-check | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index b5bdcd1ff..24a9ed262 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -165,7 +165,7 @@ if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then fi if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then - if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state1 2>/dev/null || true)" = "replica" ]; then + if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state 2>/dev/null || true)" = "replica" ]; then echo "Error: high availability replica detected." 1>&2 echo "Backup Utilities should be used to backup from the primary node in" 1>&2 echo "high availability environments to ensure consistent and reliable backups." 1>&2 From 6396e77e3100b9eceb5ec3c9fc8eb53977a52277 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 3 Nov 2023 16:28:48 +0000 Subject: [PATCH 2345/2421] log error msg when any node is offline --- bin/ghe-backup | 2 +- bin/ghe-host-check | 9 ++++++--- share/github-backup-utils/ghe-backup-config | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 1dfaf748b..eeb872e3d 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -375,7 +375,7 @@ if [ -z "$failures" ]; then else log_info "Expired and incomplete snapshots to be pruned separately" fi -else +else log_info "Skipping pruning snapshots, since some backups failed..." fi diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 5cd39abee..60bdddf21 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -91,11 +91,13 @@ if ghe-ssh "$host" -- \ CLUSTER=true fi +set +e # ensure all nodes in the cluster are online/reachable and running the same version if "$CLUSTER"; then online_status=$(ghe-ssh "$host" ghe-cluster-host-check) if [ "$online_status" != "Cluster is ready to configure." ]; then - echo "Error: Not all nodes are online! Please ensure cluster is in a healthy state before using backup-utils." 1>&2 + echo "$online_status" 1>&2 + log_error "Error: Not all nodes are online! Please ensure cluster is in a healthy state before using backup-utils." 1>&2 exit 1 fi @@ -103,10 +105,11 @@ if "$CLUSTER"; then distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l) if [ "$distinct_versions" -ne 1 ]; then echo "Version mismatch: $node_version_list" 1>&2 - echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 + log_error "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 exit 1 fi fi +set -e version=$(echo "$output" | grep "GitHub Enterprise" | awk '{print $NF}') @@ -177,7 +180,7 @@ SKIP_MSG #Display dir requirements for repositories and mysql echo -e "\nChecking host for sufficient space for a backup..." - available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') + available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." repos_disk_size=$(transfer_size repositories /tmp) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 6c33ea954..08379ce95 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -667,7 +667,7 @@ init-progress() { mkdir -p /tmp/backup-utils-progress chmod -R 777 /tmp/backup-utils-progress - + touch /tmp/backup-utils-progress/total touch /tmp/backup-utils-progress/type touch /tmp/backup-utils-progress/progress From be270eeeff0bc5684a0b7fd6c8727e5a9445f0b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:44:28 +0000 Subject: [PATCH 2346/2421] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/backup.yml | 2 +- .github/workflows/backuprestore.yml | 2 +- .github/workflows/integration-tests.yml | 4 ++-- .github/workflows/lint.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/rsync-docker-bump.yml | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index cfb154aae..2b59e7894 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -71,7 +71,7 @@ jobs: name: backup-utils - name: Load docker container run: docker load -i backup-utils.tar - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Create backup directory run: mkdir "$HOME/ghe-backup-data" - name: set up ssh SSH_KEY diff --git a/.github/workflows/backuprestore.yml b/.github/workflows/backuprestore.yml index 34cf69032..a87c54ec9 100644 --- a/.github/workflows/backuprestore.yml +++ b/.github/workflows/backuprestore.yml @@ -49,7 +49,7 @@ jobs: name: backup-utils - name: Load docker container run: docker load -i backup-utils.tar - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Create backup directory run: mkdir "$HOME"/ghe-backup-data - name: set up ssh SSH_KEY diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 603f7affa..a2cf68531 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -27,7 +27,7 @@ jobs: - enterprise2-backup-utils-binary-backup - enterprise2-backup-utils-migration steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 1 - name: Queue ${{ matrix.jankyJobName }} build @@ -50,7 +50,7 @@ jobs: - enterprise2-backup-utils-cluster-binary-backup - enterprise2-backup-utils-cluster-migration steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 1 - name: Queue ${{ matrix.jankyJobName }} build diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7fc33e1cd..0f26e9aa1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 50583737b..e1917684d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: tar --xz -xvf "shellcheck-stable.linux.x86_64.tar.xz" sudo cp shellcheck-stable/shellcheck /usr/bin/shellcheck - name: Get Sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Test run: | export PATH="$PATH:/snap/bin" diff --git a/.github/workflows/rsync-docker-bump.yml b/.github/workflows/rsync-docker-bump.yml index 2cfe7782c..0acaae854 100644 --- a/.github/workflows/rsync-docker-bump.yml +++ b/.github/workflows/rsync-docker-bump.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get latest rsync tag id: latest_tag From 5460d8458371414051261e62952478c7d1db8a21 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Fri, 3 Nov 2023 17:03:59 +0000 Subject: [PATCH 2347/2421] test update --- test/test-ghe-host-check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index a772399d6..f1e964da5 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -134,7 +134,7 @@ begin_test "ghe-host-check fails when encountering RO file-system" ghe-ssh "$GHE_HOSTNAME" -- 'chmod a-w -R "~/tmp"' # File creation fails for CLUSTER - ! FILE_TO_TEST="$HOME/tmp/test" CLUSTER=true ghe-host-check - FILE_TO_TEST="$HOME/tmp/test" CLUSTER=false ghe-host-check + ! FILE_TO_TEST="$HOME/tmp/test" CLUSTER=true GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check + FILE_TO_TEST="$HOME/tmp/test" CLUSTER=false GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check ) end_test From 8116c8a0802b5434ca6c3530568a51cec430af84 Mon Sep 17 00:00:00 2001 From: Dax Amin Date: Fri, 3 Nov 2023 13:38:15 -0400 Subject: [PATCH 2348/2421] remove empty line --- share/github-backup-utils/ghe-backup-config | 1 - 1 file changed, 1 deletion(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index 9af250b5f..cd9972b59 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -665,7 +665,6 @@ init-progress() { if [ -e /tmp/backup-utils-progress ]; then rm -rf /tmp/backup-utils-progress/* fi - # shellcheck disable=SC2174 # We are fine with -m only affecting the deepest directory mkdir -m 777 -p /tmp/backup-utils-progress touch /tmp/backup-utils-progress/{total,type,progress,info} From 47abd682e9d8cb8c34bb40a0eafece6224963b67 Mon Sep 17 00:00:00 2001 From: alejndr0 Date: Mon, 6 Nov 2023 15:54:59 +0000 Subject: [PATCH 2349/2421] Disable compression on ghe-backup-repositories by default --- share/github-backup-utils/ghe-backup-repositories | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index e90d8c37a..636e610c8 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -194,7 +194,7 @@ sync_data (){ echo 1>&3 log_info "* Transferring auxiliary files ..." 1>&3 - rsync_repository_data $1:122 $2 -z <&3 log_info "* Transferring packed-refs files ..." 1>&3 - rsync_repository_data $1:122 $2 -z <&3 log_info "* Transferring refs and reflogs ..." 1>&3 - rsync_repository_data $1:122 $2 -z <&3 log_info "* Transferring special data directories from $h..." 1>&3 - rsync_repository_data $h:122 -z < Date: Mon, 6 Nov 2023 15:13:51 -0500 Subject: [PATCH 2350/2421] Update backup.config-example Co-authored-by: Quinn Murphy --- backup.config-example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.config-example b/backup.config-example index 99bcfd232..66dc5731e 100644 --- a/backup.config-example +++ b/backup.config-example @@ -34,7 +34,7 @@ GHE_NUM_SNAPSHOTS=10 # Cluster filesystem to check if it's writable as part of ghe-host-check # By default it is /data/user/tmp but can be updated if needed -#GHE_FILE_SYSTEM_CHECK="/data/user/tmp" +#GHE_FILE_SYSTEM_WRITE_CHECK="/data/user/tmp" # The hostname of the GitHub appliance to restore. If you've set up a separate # GitHub appliance to act as a standby for recovery, specify its IP or hostname From 10a2905c8c37415c21ed18504a2f9ca5f6556e36 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Mon, 6 Nov 2023 22:17:20 +0000 Subject: [PATCH 2351/2421] readability updates --- bin/ghe-host-check | 22 +++++++++------------- test/test-ghe-host-check.sh | 4 ++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index 24a9ed262..a432f3f7c 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -120,36 +120,32 @@ fi NON_WRITABLE="" # ensure all nodes are writable if [ "$CLUSTER" == "true" ] ; then - if [ -z "$GHE_FILE_SYSTEM_CHECK" ]; then + if [ -z "$GHE_FILE_SYSTEM_WRITE_CHECK" ]; then if [ -d "/data/user/tmp" ]; then - FILE_TO_TEST="/data/user/tmp/test-ro-file.txt" + WRITE_CHECK_FILE="/data/user/tmp/test-ro-file.txt" else - FILE_TO_TEST="/tmp/test-ro-file.txt" + WRITE_CHECK_FILE="/tmp/test-ro-file.txt" fi else - FILE_TO_TEST="$GHE_FILE_SYSTEM_CHECK/test-ro-file.txt" + WRITE_CHECK_FILE="$GHE_FILE_SYSTEM_CHECK/test-ro-file.txt" fi # Iterate through each node in the cluster nodes=$(ghe-ssh "$host" ghe-cluster-nodes) first=true for node in $nodes; do - if ! echo "set -o pipefail; ssh $node -- 'touch $FILE_TO_TEST && rm $FILE_TO_TEST'" | ghe-ssh "$host" /bin/bash; then + if ! echo "set -o pipefail; ssh $node -- 'touch $WRITE_CHECK_FILE && rm $WRITE_CHECK_FILE'" | ghe-ssh "$host" /bin/bash; then echo "File system is not writeable or no permission on $node" 1>&2 - if [ "$first" = true ]; then - NON_WRITABLE="$node" - first=false - else - NON_WRITABLE="$NON_WRITABLE, $node" - fi + NON_WRITABLE+="$node " fi || true done # Display the comma-separated list of non-writable nodes - if [ ! -z "$NON_WRITABLE" ]; then + if [ -n "$NON_WRITABLE" ]; then + NON_WRITABLE=$(echo "$NON_WRITABLE" | sed 's/ /, /g; s/, $//') log_error "Error: Following nodes are non-writable - $NON_WRITABLE. Please make sure the filesystem for all GHES nodes are writable." 1>&2 exit 1 else - echo "All nodes are writable." + log_info "All nodes are writable." fi fi diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index f1e964da5..50b4ed996 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -134,7 +134,7 @@ begin_test "ghe-host-check fails when encountering RO file-system" ghe-ssh "$GHE_HOSTNAME" -- 'chmod a-w -R "~/tmp"' # File creation fails for CLUSTER - ! FILE_TO_TEST="$HOME/tmp/test" CLUSTER=true GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check - FILE_TO_TEST="$HOME/tmp/test" CLUSTER=false GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check + ! WRITE_CHECK_FILE="$HOME/tmp/test" CLUSTER=true GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check + WRITE_CHECK_FILE="$HOME/tmp/test" CLUSTER=false GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check ) end_test From 265b9fa06b0fccf22cc743652d13615aa2af398a Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 7 Nov 2023 04:29:12 +0000 Subject: [PATCH 2352/2421] SC fix --- bin/ghe-host-check | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index a432f3f7c..fedc84852 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -132,7 +132,6 @@ if [ "$CLUSTER" == "true" ] ; then # Iterate through each node in the cluster nodes=$(ghe-ssh "$host" ghe-cluster-nodes) - first=true for node in $nodes; do if ! echo "set -o pipefail; ssh $node -- 'touch $WRITE_CHECK_FILE && rm $WRITE_CHECK_FILE'" | ghe-ssh "$host" /bin/bash; then echo "File system is not writeable or no permission on $node" 1>&2 From 18d6113aedd699df376eb25c9089304262aee193 Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 7 Nov 2023 14:26:38 +0000 Subject: [PATCH 2353/2421] progress file for ha instances --- share/github-backup-utils/ghe-backup-repositories | 6 ++++++ share/github-backup-utils/ghe-backup-storage | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index e90d8c37a..f4d3a4b44 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -78,6 +78,12 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi +# hostnames for HA +if ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -i |cut -f 2) +fi + # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index 9752de21d..bac467c8a 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -51,6 +51,12 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi +# hostnames for HA +if ghe-ssh "$GHE_HOSTNAME" -- \ + "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -i |cut -f 2) +fi + # Make sure root backup dir exists if this is the first run mkdir -p "$backup_dir" From eabec3431bf55db7e5e8dc92948aadc582a3371d Mon Sep 17 00:00:00 2001 From: Chuck Pathanjali Date: Tue, 7 Nov 2023 18:32:02 +0000 Subject: [PATCH 2354/2421] re-trigger for cluster --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index f4d3a4b44..abf73a6cd 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -81,7 +81,7 @@ fi # hostnames for HA if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -i |cut -f 2) + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -i | cut -f 2) fi # Make sure root backup dir exists if this is the first run diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index bac467c8a..c64309202 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -54,7 +54,7 @@ fi # hostnames for HA if ghe-ssh "$GHE_HOSTNAME" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -i |cut -f 2) + hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -i | cut -f 2) fi # Make sure root backup dir exists if this is the first run From 11a96f6d24bbd858afa1e594edbf0083bcd305ac Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 7 Nov 2023 10:54:33 -0800 Subject: [PATCH 2355/2421] Update docs/requirements.md --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index af0fc805f..5a8c4347a 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,7 +5,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2] 1.7.6 or newer, [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), and [jq][11] v1.5 or newer. See below for an update on rsync. +Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2] 1.7.6 or newer, [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), [jq][11] v1.5 or newer and [bc][12] v1.0.6 or newer. See below for an update on rsync. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From f19c20639c7e5da9e6b0e52de0c14b6484edc349 Mon Sep 17 00:00:00 2001 From: djdefi Date: Tue, 7 Nov 2023 15:14:02 -0800 Subject: [PATCH 2356/2421] Update requirements.md --- docs/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/requirements.md b/docs/requirements.md index 5a8c4347a..20b3a3fad 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,7 +5,7 @@ storage and must have network connectivity with the GitHub Enterprise Server app ## Backup host requirements -Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2] 1.7.6 or newer, [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), [jq][11] v1.5 or newer and [bc][12] v1.0.6 or newer. See below for an update on rsync. +Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2] 1.7.6 or newer, [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), [jq][11] v1.5 or newer and [bc][12] v1.0.7 or newer. See below for an update on rsync. The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. From cc320085950c6bdb464f4ef1adf85bba19d81bae Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Tue, 14 Nov 2023 23:43:39 +0000 Subject: [PATCH 2357/2421] Merge pull request #726 from github/solvaholic/soften-warning Remove "contact support" from warning about route verification --- share/github-backup-utils/ghe-backup-repositories | 2 +- share/github-backup-utils/ghe-backup-storage | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 68442b527..543effb35 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -384,7 +384,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then done |sort|uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | fix_paths_for_ghe_version | uniq | sort | uniq) > $tempdir/destination_routes - git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance." increment-progress-total-count 1 bm_end "$(basename $0) - Verifying Routes" fi diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index c64309202..c513290bf 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -155,7 +155,7 @@ if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then cat $tempdir/*.rsync | uniq | sort | uniq > $tempdir/source_routes (cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | uniq | sort | uniq) > $tempdir/destination_routes - git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance. Please contact GitHub Enterprise Support for assistance." + git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance." increment-progress-total-count 1 bm_end "$(basename $0) - Verifying Routes" From cc6566b6185875fd12ecaf2f113e58d6646f597d Mon Sep 17 00:00:00 2001 From: Dax Amin Date: Thu, 16 Nov 2023 08:54:45 +0000 Subject: [PATCH 2358/2421] Merge pull request #725 from github/ha-sync Create sync file on HA replica from primary node [cluster] --- share/github-backup-utils/ghe-backup-config | 30 +++++++++++++++++++ .../ghe-backup-repositories | 25 ++++++++++++---- share/github-backup-utils/ghe-backup-storage | 25 ++++++++++++---- share/github-backup-utils/ghe-gc-disable | 18 ++--------- 4 files changed, 72 insertions(+), 26 deletions(-) diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config index cd9972b59..30062a8f6 100755 --- a/share/github-backup-utils/ghe-backup-config +++ b/share/github-backup-utils/ghe-backup-config @@ -676,3 +676,33 @@ increment-progress-total-count() { ((PROGRESS_TOTAL += $1)) echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total } + +## +# This function is used by ghe-gc-disable, ghe-backup-repositories, and ghe-backup-storage +# This function should be used directly to disable and drain GC operations ONLY on HA-replica node +# (as done in ghe-backup-repositories and ghe-backup-storage) +# Otherwise use ghe-gc-disable which will call this function with the correct parameters. +# +# Arguments: +# $1 - path to sync-in-progress file ($SYNC_IN_PROGRESS_FILE) +# $2 - git cooldown period ($GHE_GIT_COOLDOWN_PERIOD) +## +gc_disable() { + set -e + local sync_in_progress="$1" + local git_cooldown_period="$2" + + # Touch the sync-in-progress file, disabling GC operations, and wait for all + # active GC processes to finish on the remote side. + sudo -u git touch "$sync_in_progress" + for _ in $(seq $git_cooldown_period); do + # note: the bracket synta[x] below is to prevent matches against the + # grep process itself. + if ps axo args | grep -E -e "^git( -.*)? nw-repac[k]( |$)" -e "^git( -.*)? g[c]( |$)" >/dev/null; then + sleep 1 + else + exit 0 + fi + done + exit 7 +} diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories index 68442b527..209d81367 100755 --- a/share/github-backup-utils/ghe-backup-repositories +++ b/share/github-backup-utils/ghe-backup-repositories @@ -78,10 +78,9 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi -# hostnames for HA -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -i | cut -f 2) +# Replica hostnames for HA +if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then + ha_replica_hosts=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes --replica) fi # Make sure root backup dir exists if this is the first run @@ -96,11 +95,18 @@ cleanup() { # Enable remote GC operations for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port || { + ghe-gc-enable $ssh_config_file_opt $hostname:$port || { echo "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 } done + # Enable remote GC operations for HA replica + for replica_host in $ha_replica_hosts; do + echo "set -o pipefail; ssh $replica_host -- 'sudo rm -f $SYNC_IN_PROGRESS_FILE'" | ghe-ssh "$host" /bin/bash || { + echo "Re-enable gc on $replica_host failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 + } + done + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir rm -rf $tempdir } @@ -111,6 +117,15 @@ for hostname in $hostnames; do ghe-gc-disable $ssh_config_file_opt $hostname:$port done +# Disable remote GC operations for HA replica +# gc_disable is a function defined in ghe-backup-config +# gc_disable is called on the replica node via the primary node, because replica node is not expected to be reachable from backup host. But replica node is expected to be reachable from primary node. +for replica_host in $ha_replica_hosts; do + echo "set -o pipefail; ssh $replica_host -- '$(declare -f gc_disable); gc_disable \"$SYNC_IN_PROGRESS_FILE\" \"$GHE_GIT_COOLDOWN_PERIOD\"'" | ghe-ssh "$host" /bin/bash || { + echo "Disable gc on $replica_host failed" 1>&2 + } +done + # If we have a previous increment, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$backup_current" ]; then diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage index c64309202..82ec98f2e 100755 --- a/share/github-backup-utils/ghe-backup-storage +++ b/share/github-backup-utils/ghe-backup-storage @@ -51,10 +51,9 @@ if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" fi -# hostnames for HA -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - hostnames=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -i | cut -f 2) +# Replica hostnames for HA +if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then + ha_replica_hosts=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes --replica) fi # Make sure root backup dir exists if this is the first run @@ -65,11 +64,18 @@ mkdir -p "$backup_dir" cleanup() { # Enable remote maintenance operations for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port || { + ghe-gc-enable $ssh_config_file_opt $hostname:$port || { log_warn "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 } done + # Enable remote GC operations for HA replica + for replica_host in $ha_replica_hosts; do + echo "set -o pipefail; ssh $replica_host -- 'sudo rm -f $SYNC_IN_PROGRESS_FILE'" | ghe-ssh "$host" /bin/bash || { + echo "Re-enable gc on $replica_host failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 + } + done + ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir rm -rf $tempdir } @@ -80,6 +86,15 @@ for hostname in $hostnames; do ghe-gc-disable $ssh_config_file_opt $hostname:$port done +# Disable remote GC operations for HA replica +# gc_disable is a function defined in ghe-backup-config +# gc_disable is called on the replica node via the primary node, because replica node is not expected to be reachable from backup host. But replica node is expected to be reachable from primary node. +for replica_host in $ha_replica_hosts; do + echo "set -o pipefail; ssh $replica_host -- '$(declare -f gc_disable); gc_disable \"$SYNC_IN_PROGRESS_FILE\" \"$GHE_GIT_COOLDOWN_PERIOD\"'" | ghe-ssh "$host" /bin/bash || { + echo "Disable gc on $replica_host failed" 1>&2 + } +done + # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's # --link-dest support. This also decreases physical space usage considerably. if [ -d "$GHE_DATA_DIR/current/storage" ] && [ "$(ls -A $GHE_DATA_DIR/current/storage)" ]; then diff --git a/share/github-backup-utils/ghe-gc-disable b/share/github-backup-utils/ghe-gc-disable index 1e5a63bc5..67cdef6d4 100755 --- a/share/github-backup-utils/ghe-gc-disable +++ b/share/github-backup-utils/ghe-gc-disable @@ -32,22 +32,8 @@ done # Exit early when testing [ -n "$GHE_TEST_REMOTE_VERSION" ] && exit 0 -# Touch the sync-in-progress file, disabling GC operations, and wait for all -# active GC processes to finish on the remote side. -echo " - set -e - sudo -u git touch '$SYNC_IN_PROGRESS_FILE' - for i in \$(seq $GHE_GIT_COOLDOWN_PERIOD); do - # note: the bracket synta[x] below is to prevent matches against the - # grep process itself. - if ps axo args | grep -E -e '^git( -.*)? nw-repac[k]( |$)' -e '^git( -.*)? g[c]( |$)' >/dev/null; then - sleep 1 - else - exit 0 - fi - done - exit 7 -" | ghe-ssh $opts "$host" -- /bin/bash || { +# gc_disable is a function defined in ghe-backup-config +echo "set -o pipefail; $(declare -f gc_disable); gc_disable \"$SYNC_IN_PROGRESS_FILE\" \"$GHE_GIT_COOLDOWN_PERIOD\"" | ghe-ssh $opts "$host" -- /bin/bash || { res=$? if [ $res = 7 ]; then log_error "Error: Git GC processes remain after $GHE_GIT_COOLDOWN_PERIOD seconds. Aborting..." 1>&2 From b2131769bb948a91eb325804e41a5c197eb6d81e Mon Sep 17 00:00:00 2001 From: Andrew Mildahl Date: Tue, 28 Nov 2023 15:54:38 -0600 Subject: [PATCH 2359/2421] Update versions --- bin/ghe-host-check | 2 +- share/github-backup-utils/version | 2 +- test/testlib.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/ghe-host-check b/bin/ghe-host-check index abc0b40b2..59bc9b526 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -173,7 +173,7 @@ fi # backup-utils 2.13 onwards limits support to the current and previous two releases # of GitHub Enterprise Server. -supported_minimum_version="3.7.0" +supported_minimum_version="3.9.0" if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then supported=1 diff --git a/share/github-backup-utils/version b/share/github-backup-utils/version index 30291cba2..afad81866 100644 --- a/share/github-backup-utils/version +++ b/share/github-backup-utils/version @@ -1 +1 @@ -3.10.0 +3.11.0 diff --git a/test/testlib.sh b/test/testlib.sh index edeec8ea2..8251fa316 100755 --- a/test/testlib.sh +++ b/test/testlib.sh @@ -48,7 +48,7 @@ export GHE_BACKUP_CONFIG GHE_DATA_DIR GHE_REMOTE_DATA_DIR GHE_REMOTE_ROOT_DIR # The default remote appliance version. This may be set in the environment prior # to invoking tests to emulate a different remote vm version. -: ${GHE_TEST_REMOTE_VERSION:=3.8.0.rc1} +: ${GHE_TEST_REMOTE_VERSION:=3.11.0.rc1} export GHE_TEST_REMOTE_VERSION # Source in the backup config and set GHE_REMOTE_XXX variables based on the From bec5f580420fe65289a6bc32ee90d580516f7377 Mon Sep 17 00:00:00 2001 From: Andrew Mildahl Date: Tue, 28 Nov 2023 16:56:51 -0600 Subject: [PATCH 2360/2421] Fix ghe-host-check unsupported version test for unreleased feature versions --- test/test-ghe-host-check.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 50b4ed996..55f2e6c83 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -68,10 +68,10 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions if [ -z "$supported" ] then #BACKUP_UTILS_VERSION WAS NOT FOUND IN LATEST.JSON, CHECK IF ITS GREATER THAN LAST VERSION - if [ "$(version $bu_major_minor)" -ge "$(version ${keys[$((${#keys[@]} - 2 ))]})" ]; then + if [ "$(version $bu_major_minor)" -ge "$(version ${keys[$((${#keys[@]}))]})" ]; then GHE_TEST_REMOTE_VERSION="$bu_major_minor.0" ghe-host-check - GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]} - 2 ))]}.0" ghe-host-check - GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]} - 3 ))]}.0" ghe-host-check + GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]}))]}.0" ghe-host-check + GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]} - 1 ))]}.0" ghe-host-check fi else #BACKUP_UTILS_VERSION WAS FOUND IN LATEST.JSON From 3cef5b8df620226071a9e4a61d878c638545099b Mon Sep 17 00:00:00 2001 From: Andrew Mildahl Date: Tue, 28 Nov 2023 20:28:02 -0600 Subject: [PATCH 2361/2421] Fix ghe-host-check unsupported version test by sorting supported versions --- test/test-ghe-host-check.sh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 55f2e6c83..fb547bf34 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -63,32 +63,30 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions # Use the modified releases string as needed supported=$(echo "$releases_with_replacement" | jq -r 'select(."'${bu_major_minor}'")') # shellcheck disable=SC2207 # Command required as alternatives fail - keys=($(echo "$releases_with_replacement" | jq -r 'keys[]')) + keys=($(echo "$releases_with_replacement" | jq -r '. | keys_unsorted | sort_by( split(".") | map(tonumber) )[]')) if [ -z "$supported" ] then #BACKUP_UTILS_VERSION WAS NOT FOUND IN LATEST.JSON, CHECK IF ITS GREATER THAN LAST VERSION - if [ "$(version $bu_major_minor)" -ge "$(version ${keys[$((${#keys[@]}))]})" ]; then + if [ "$(version $bu_major_minor)" -ge "$(version ${keys[-1]})" ]; then GHE_TEST_REMOTE_VERSION="$bu_major_minor.0" ghe-host-check - GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]}))]}.0" ghe-host-check - GHE_TEST_REMOTE_VERSION="${keys[$(( ${#keys[@]} - 1 ))]}.0" ghe-host-check + # Test most recent 2 versions + GHE_TEST_REMOTE_VERSION="${keys[-1]}.0" ghe-host-check + GHE_TEST_REMOTE_VERSION="${keys[-2]}.0" ghe-host-check fi else #BACKUP_UTILS_VERSION WAS FOUND IN LATEST.JSON ix=0 - for i in "${keys[@]}";do + for i in "${keys[@]}";do if [ "$i" == "$bu_major_minor" ];then break fi ix=$(( $ix + 1 )) done GHE_TEST_REMOTE_VERSION="${keys[$ix]}.0" ghe-host-check - # sometimes when the latest.json is updated during a release this test gets broken. - if [ "${keys[$(( $ix - 1 ))]}" != "latest" ]; then - GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 1 ))]}.0" ghe-host-check - fi + # Test previous 2 supported versions + GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 1 ))]}.0" ghe-host-check GHE_TEST_REMOTE_VERSION="${keys[$(( $ix - 2 ))]}.0" ghe-host-check - fi ! GHE_TEST_REMOTE_VERSION=11.340.36 ghe-host-check GHE_TEST_REMOTE_VERSION=$bu_version_major.$bu_version_minor.999 ghe-host-check From b4b127f1762b71a1153f660632f9aaf8e23e1e12 Mon Sep 17 00:00:00 2001 From: Andrew Mildahl Date: Wed, 29 Nov 2023 00:16:57 -0600 Subject: [PATCH 2362/2421] Fix ghe-host-check unsupported version test for unreleased versions --- test/test-ghe-host-check.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index fb547bf34..80a62cfc5 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -70,9 +70,10 @@ begin_test "ghe-host-check detects unsupported GitHub Enterprise Server versions #BACKUP_UTILS_VERSION WAS NOT FOUND IN LATEST.JSON, CHECK IF ITS GREATER THAN LAST VERSION if [ "$(version $bu_major_minor)" -ge "$(version ${keys[-1]})" ]; then GHE_TEST_REMOTE_VERSION="$bu_major_minor.0" ghe-host-check - # Test most recent 2 versions + # Test most recent version + # Don't test 2 versions back because it fails when we bump the version on + # master after branching for a feature release, before it's released GHE_TEST_REMOTE_VERSION="${keys[-1]}.0" ghe-host-check - GHE_TEST_REMOTE_VERSION="${keys[-2]}.0" ghe-host-check fi else #BACKUP_UTILS_VERSION WAS FOUND IN LATEST.JSON From 872f6569e73b6eed2cb7dfbf00a33becbc7d0c23 Mon Sep 17 00:00:00 2001 From: Andrew Mildahl Date: Wed, 29 Nov 2023 15:52:58 -0600 Subject: [PATCH 2363/2421] Revert "Merge pull request #717 from github/daxamin-offline-error" This reverts commit c1a2b87fba87766abe57d1b6c4bcfb4d6cb9ad65, reversing changes made to 0889f597bfa044b5d8554e86a13b440863712a3b. --- bin/ghe-backup | 2 +- bin/ghe-host-check | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/bin/ghe-backup b/bin/ghe-backup index 1ae6b868c..448a5840e 100755 --- a/bin/ghe-backup +++ b/bin/ghe-backup @@ -377,7 +377,7 @@ if [ -z "$failures" ]; then else log_info "Expired and incomplete snapshots to be pruned separately" fi -else +else log_info "Skipping pruning snapshots, since some backups failed..." fi diff --git a/bin/ghe-host-check b/bin/ghe-host-check index abc0b40b2..fc0a0b6e2 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -93,13 +93,11 @@ if ghe-ssh "$host" -- \ CLUSTER=true fi -set +e # ensure all nodes in the cluster are online/reachable and running the same version if "$CLUSTER"; then online_status=$(ghe-ssh "$host" ghe-cluster-host-check) if [ "$online_status" != "Cluster is ready to configure." ]; then - echo "$online_status" 1>&2 - log_error "Error: Not all nodes are online! Please ensure cluster is in a healthy state before using backup-utils." 1>&2 + echo "Error: Not all nodes are online! Please ensure cluster is in a healthy state before using backup-utils." 1>&2 exit 1 fi @@ -107,11 +105,10 @@ if "$CLUSTER"; then distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l) if [ "$distinct_versions" -ne 1 ]; then echo "Version mismatch: $node_version_list" 1>&2 - log_error "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 + echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 exit 1 fi fi -set -e version=$(echo "$output" | grep "GitHub Enterprise" | awk '{print $NF}') @@ -213,7 +210,7 @@ SKIP_MSG #Display dir requirements for repositories and mysql echo -e "\nChecking host for sufficient space for a backup..." - available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') + available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." repos_disk_size=$(transfer_size repositories /tmp) From 01f42a98927398a3b49d04a4d345045ff85598aa Mon Sep 17 00:00:00 2001 From: Andrew Mildahl Date: Wed, 29 Nov 2023 15:53:28 -0600 Subject: [PATCH 2364/2421] Revert "Merge pull request #700 from github/check-ro-filesystem" This reverts commit 0aa36fdd1ed87b608feadc07a4585247d36e0970, reversing changes made to c1a2b87fba87766abe57d1b6c4bcfb4d6cb9ad65. --- backup.config-example | 4 ---- bin/ghe-host-check | 35 +---------------------------------- test/test-ghe-host-check.sh | 15 --------------- 3 files changed, 1 insertion(+), 53 deletions(-) diff --git a/backup.config-example b/backup.config-example index 66dc5731e..535a2f636 100644 --- a/backup.config-example +++ b/backup.config-example @@ -32,10 +32,6 @@ GHE_NUM_SNAPSHOTS=10 # disk space validation and software version checks on the backup-host will be disabled. #GHE_SKIP_CHECKS=false -# Cluster filesystem to check if it's writable as part of ghe-host-check -# By default it is /data/user/tmp but can be updated if needed -#GHE_FILE_SYSTEM_WRITE_CHECK="/data/user/tmp" - # The hostname of the GitHub appliance to restore. If you've set up a separate # GitHub appliance to act as a standby for recovery, specify its IP or hostname # here. The host to restore to may also be specified directly when running diff --git a/bin/ghe-host-check b/bin/ghe-host-check index fc0a0b6e2..5cd39abee 100755 --- a/bin/ghe-host-check +++ b/bin/ghe-host-check @@ -85,9 +85,7 @@ if [ $rc -ne 0 ]; then exit $rc fi -if [ -z "$CLUSTER" ]; then - CLUSTER=false -fi +CLUSTER=false if ghe-ssh "$host" -- \ "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then CLUSTER=true @@ -117,37 +115,6 @@ if [ -z "$version" ]; then exit 2 fi -NON_WRITABLE="" -# ensure all nodes are writable -if [ "$CLUSTER" == "true" ] ; then - if [ -z "$GHE_FILE_SYSTEM_WRITE_CHECK" ]; then - if [ -d "/data/user/tmp" ]; then - WRITE_CHECK_FILE="/data/user/tmp/test-ro-file.txt" - else - WRITE_CHECK_FILE="/tmp/test-ro-file.txt" - fi - else - WRITE_CHECK_FILE="$GHE_FILE_SYSTEM_CHECK/test-ro-file.txt" - fi - - # Iterate through each node in the cluster - nodes=$(ghe-ssh "$host" ghe-cluster-nodes) - for node in $nodes; do - if ! echo "set -o pipefail; ssh $node -- 'touch $WRITE_CHECK_FILE && rm $WRITE_CHECK_FILE'" | ghe-ssh "$host" /bin/bash; then - echo "File system is not writeable or no permission on $node" 1>&2 - NON_WRITABLE+="$node " - fi || true - done - # Display the comma-separated list of non-writable nodes - if [ -n "$NON_WRITABLE" ]; then - NON_WRITABLE=$(echo "$NON_WRITABLE" | sed 's/ /, /g; s/, $//') - log_error "Error: Following nodes are non-writable - $NON_WRITABLE. Please make sure the filesystem for all GHES nodes are writable." 1>&2 - exit 1 - else - log_info "All nodes are writable." - fi -fi - # Block restoring snapshots to older releases of GitHub Enterprise Server if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) diff --git a/test/test-ghe-host-check.sh b/test/test-ghe-host-check.sh index 50b4ed996..f2c5cca54 100755 --- a/test/test-ghe-host-check.sh +++ b/test/test-ghe-host-check.sh @@ -123,18 +123,3 @@ begin_test "ghe-host-check blocks restore to old release" ! GHE_TEST_REMOTE_VERSION=$bu_version_major.$((bu_version_minor-1)).$bu_version_patch ghe-restore -v ) end_test - -# Check ghe-host-check detects RO file system -begin_test "ghe-host-check fails when encountering RO file-system" -( - set -e - - ghe-ssh "$GHE_HOSTNAME" -- 'mkdir -p "~/tmp"' - # Remove write access in ~/tmp - ghe-ssh "$GHE_HOSTNAME" -- 'chmod a-w -R "~/tmp"' - - # File creation fails for CLUSTER - ! WRITE_CHECK_FILE="$HOME/tmp/test" CLUSTER=true GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check - WRITE_CHECK_FILE="$HOME/tmp/test" CLUSTER=false GHE_ALLOW_REPLICA_BACKUP=no ghe-host-check -) -end_test From 3bc10598b490069c033ef7c05ba89a6ba24819e9 Mon Sep 17 00:00:00 2001 From: Andrew Mildahl Date: Wed, 29 Nov 2023 19:51:17 -0600 Subject: [PATCH 2365/2421] Add 3.11.0 release notes --- release-notes/3.11.0.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 release-notes/3.11.0.md diff --git a/release-notes/3.11.0.md b/release-notes/3.11.0.md new file mode 100644 index 000000000..197501c92 --- /dev/null +++ b/release-notes/3.11.0.md @@ -0,0 +1,18 @@ +### Bug Fixes + +* `ghe-backup-myql` and `ghe-restore-mysql` will now exit 1 on errors. +* On an instance with Actions enabled, incorrect backup and restore settings prevented the storage container name from being restored. This made the logs from that container inaccessible, and caused Actions to create a new storage container in a different location. +* When backups are run for HA instances in both primary and replica nodes a `.sync-in-progress` file will be created. This will disable `NetworkMaintenance` jobs from running and queueing up when backups are running from the primary node. + +### Changes + +* Estimated transfer sizes will be calculated on appropriate nodes for clustered environments. +* Added support for finding the `parallel` command from the `moreutils` tool suite on more Linux distributions, including Arch Linux and Alpine Linux. +* `ghe-restore` avoids unnecessary `rsync` operations when restoring to non-clustered environments. +* `ghe-backup` and `ghe-restore` output their total runtime +* `rsync` compression is now disabled by default. The `-z` flag has been removed from the `ghe-rsync` command in multiple files to improve transfer speed and reduce CPU usage. To enable `rsync` compression globally, add `GHE_RSYNC_COMPRESSION_ENABLED=yes` to the `backup.config` file. +* Updates the Host OS version output to use `/etc/os-release` for better compatibility with other Linux distributions. + +### Backups and Disaster Recovery + +* When a NFS mount is detected for snapshots on backup hosts, backup logs will show a warning to notify the user that such a setup may incur performance issues as highlighted in [storage requirements](https://github.com/github/backup-utils-private/blob/master/docs/requirements.md#storage-requirements) documentation. From 5534c57f0ea41c31c8d3e4aab9330836cf241598 Mon Sep 17 00:00:00 2001 From: Andrew Mildahl Date: Wed, 29 Nov 2023 20:01:02 -0600 Subject: [PATCH 2366/2421] Add 3.11.0 debian/changelog --- debian/changelog | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/debian/changelog b/debian/changelog index fb6b9940b..0d6f1e8d4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,49 @@ +github-backup-utils (3.11.0) UNRELEASED; urgency=medium + + * `ghe-backup-myql` and `ghe-restore-mysql` will now exit 1 on errors. + * On an instance with Actions enabled, incorrect backup and restore settings prevented the storage container name from being restored. This made the logs from that container inaccessible, and caused Actions to create a new storage container in a different location. + * When backups are run for HA instances in both primary and replica nodes a `.sync-in-progress` file will be created. This will disable `NetworkMaintenance` jobs from running and queueing up when backups are running from the primary node. + * Estimated transfer sizes will be calculated on appropriate nodes for clustered environments. + * Added support for finding the `parallel` command from the `moreutils` tool suite on more Linux distributions, including Arch Linux and Alpine Linux. + * `ghe-restore` avoids unnecessary `rsync` operations when restoring to non-clustered environments. + * `ghe-backup` and `ghe-restore` output their total runtime + * `rsync` compression is now disabled by default. The `-z` flag has been removed from the `ghe-rsync` command in multiple files to improve transfer speed and reduce CPU usage. To enable `rsync` compression globally, add `GHE_RSYNC_COMPRESSION_ENABLED=yes` to the `backup.config` file. + * Updates the Host OS version output to use `/etc/os-release` for better compatibility with other Linux distributions. + * When a NFS mount is detected for snapshots on backup hosts, backup logs will show a warning to notify the user that such a setup may incur performance issues as highlighted in [storage requirements](https://github.com/github/backup-utils-private/blob/master/docs/requirements.md#storage-requirements) documentation. + + -- Andrew Mildahl Thu, 30 Nov 2023 01:57:12 +0000 + +github-backup-utils (3.10.0) UNRELEASED; urgency=medium + + -- Balwinder Sohi Wed, 30 Aug 2023 17:39:31 +0000 + +github-backup-utils (3.10.0) UNRELEASED; urgency=medium + + * Remove -o option from ps use #341 + * Switch to TMPDIR before initiating SSH multiplexing workaround to prevent locking the destination filesystem #348 + * Move check for git for ssh muxing into ghe-ssh #378 + * Check filesystem supports hardlinks #388 + * Remove check for git from ghe-ssh #393 + * Clean up stale HA nodes on restore #396 + + -- Balwinder Sohi Wed, 09 Aug 2023 19:37:10 +0000 + +github-backup-utils (3.9.0) UNRELEASED; urgency=medium + + * Set restore status on all cluster nodes #274 + * Fix pages backups and restores in GitHub Enterprise 11.10 #275 + * Backup and restore custom CA certificates #281 + * Set the benchmark file path consistently #283 + * Suppress dd output noise #289 + * Track completeness of Elasticsearch JSON dumps #298 + * Use existing Elasticsearch indices to speed up transfer during a restore #310 + * Include the user data directory in the benchmark name #311 + * Use calculated routes when backing up storage data from a cluster #318 + * Refresh the existing indices when restoring Elasticsearch indices to cluster #328 + * Use git to generate short name for SSH multiplex control path #335 + + -- Junior Eluhu Mon, 12 Jun 2023 20:46:10 +0000 + github-backup-utils (3.8.0) focal; urgency=medium -- Daniel Johnson Tue, 07 Feb 2023 21:43:26 +0000 From 07686532d824e3384183453ae7eaf2a1621b2e56 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 30 Nov 2023 11:59:38 -0500 Subject: [PATCH 2367/2421] Simplified the Support section --- README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4ee951f58..8e1d1adb2 100644 --- a/README.md +++ b/README.md @@ -44,11 +44,8 @@ GitHub Enterprise Server. ## Support -If you find a bug or would like to request a feature in Backup Utilities, please -open an issue or pull request on this repository. If you have a question related -to your specific GitHub Enterprise Server setup or would like assistance with -backup site setup or recovery, please contact our [Enterprise support team][3] -instead. +If you have a question related to your specific GitHub Enterprise Server setup, would like assistance with +backup site setup or recovery, or would like to report a bug or a feature request, please contact our [Enterprise support team][3]. [1]: https://github.com/enterprise [2]: docs/requirements.md#github-enterprise-version-requirements From a0d9dc18d3072051aac10636eee7d183af8a167d Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 30 Nov 2023 12:19:02 -0500 Subject: [PATCH 2368/2421] Added details about the repository settings changes we made on 2023-11-30 I copied and pasted the contents from this issue (https://github.com/github/backup-utils/issues/1140) into the README file. --- README.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/README.md b/README.md index 8e1d1adb2..8376f371c 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,63 @@ GitHub Enterprise Server. If you have a question related to your specific GitHub Enterprise Server setup, would like assistance with backup site setup or recovery, or would like to report a bug or a feature request, please contact our [Enterprise support team][3]. + +## Repository updates - November 2023 + +In October 2023 we announced a number of changes to this repository. These changes will improve our (GitHub’s) ability to ship enhancements and new features to backup-utils, as well as simplify how GitHub Enterprise Server customers interact with backup-utils. + +Our process for shipping new versions of backup-utils prior to November 2023 involved a 2-way sync between this repository and an internal repository. This 2-way sync became significantly more problematic once we started regularly shipping patches in alignment with GitHub Enterprise Server. + +As of 2023-11-30 we have stopped this 2-way sync so that our internal repository becomes the source of truth for the backup-utils source code. With the the 2-way sync stopped, this public repository will be used to host documentation about backup-utils and to publish new versions of backup-utils. You will be able to access a specific version of backup-utils (which includes the full source code) from the [release page](https://github.com/github/backup-utils/releases) of this repository. + +This change has not affected the functionality of the backup-utils tool or a customer’s ability to backup or restore their GitHub Enterprise Server instance. + +### Details + +There are three specific areas that have been affected by us stop the 2-way sync between our internal repository and this public repository on 2023-11-30: + +1. **Pull requests**: Customers should no longer open pull requests in this repository. These pull requests will not be reviewed or merged. This is necessary because we will no longer be syncing changes between this repository and our internal repository. +2. **Issues**: Customers cannot open issues in this repository. Instead, customers will need to follow the standard support process and open a support ticket for any questions/concerns/problems with backup-utils. This will ensure all customer requests are handled consistently. +3. **Installing/upgrading backup-utils**: Customers will not be able to use a clone of the repository to install and upgrade backup-utils. Customers will need to download a specific version of backup-utils from the [release page](https://github.com/github/backup-utils/releases) (either as a Debian package or as an archive file - see below for details on how to incorporate this change). + +### Timeline + +Below is the two phase timeline we will follow to roll out the changes described above: + +* **Phase 1 (rolled out on 2023-11-30):** We have closed all open pull requests and issues (after reviewing each one and porting them to our internal repository if merited), and updated the repository settings so that new issues cannot be opened. Also, we have stop syncing code from our internal repository to this repository. + * As of 2023-11-30, you can still get a working copy of backup-utils by cloning the repository. But the code will not be updated in the repository; you can access updated versions of backup-utils via the [release page](https://github.com/github/backup-utils/releases). +* **Phase 2 (rolling out 2024-02-20):** The backup-utils code will be removed and the repository will be used to host documentation for backup-utils. After this date, you will no longer be able to clone a working copy of backup-utils from the repository. Instead, you will need to download a specific version of backup-utils from the [release page](https://github.com/github/backup-utils/releases). + +### Updating your backup-utils upgrade process + +#### Clone of repository + +If your current process for upgrading backup-utils involves a clone of the repository, you will need to modify your process to download a new version of backup-utils and set it up. + +For example, you could download the v3.10.0 (github-backup-utils-v3.10.0.tar.gz) artifact from the [releases page](https://github.com/github/backup-utils/releases/tag/v3.10.0) with: + +``` +$ wget https://github.com/github/backup-utils/releases/download/v3.10.0/github-backup-utils-v3.10.0.tar.gz +``` +And then extract it: + +``` +$ tar xzvf github-backup-utils-v3.10.0.tar.gz +``` + +This will give you a new folder, `github-backup-utils-v3.10.0`, which contains the code for version 3.10.0 of backup-utils. Once you copy over your backup.config file from a previous installation of backup-utils your new version of backup-utils will be ready to use. + +#### Docker + +For customers that currently use Docker to create a backup-utils image, their existing process may need updating as a result of this change. Previously customers could execute this command to build a Docker image of backup-utils: + +``` +$ docker build github.com/github/backup-utils +``` + +This will not work after phase 2 roles out. You will need to update your process to first download an archive from the [release page](https://github.com/github/backup-utils/releases), extract it, and then build the Dockerfile inside the extracted directory. + + [1]: https://github.com/enterprise [2]: docs/requirements.md#github-enterprise-version-requirements [3]: https://support.github.com/ From d68e166e580caf64ae3ab84ba4f8dd039547ffa1 Mon Sep 17 00:00:00 2001 From: "Roger D. Winans" Date: Thu, 30 Nov 2023 13:12:19 -0500 Subject: [PATCH 2369/2421] Delete docs/SUPPORT.md --- docs/SUPPORT.md | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 docs/SUPPORT.md diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md deleted file mode 100644 index a05a91f5b..000000000 --- a/docs/SUPPORT.md +++ /dev/null @@ -1,13 +0,0 @@ -# Support - -## How to file issues and get help - -**github/backup-utils** uses GitHub issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. - -For non-urgent help, feature requests, and questions about using this project, please [open an issue](https://github.com/github/backup-utils/issues/new/choose). - -For urgent help with **backup-utils**, for example when restoring a backup to recover from a site failure or other disaster, please [open a ticket in GitHub's support portal](https://support.github.com/contact) and work with GitHub Support directly. - -## GitHub Support Policy - -**github/backup-utils** is an MIT-licensed open source project under active development and maintained by GitHub staff. We will do our best to respond to support, feature requests, and community questions in a timely manner. From 687b17889378ea16edb1372eca367060edd71031 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 30 Nov 2023 14:42:41 -0500 Subject: [PATCH 2370/2421] Fixing linting errors --- README.md | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8376f371c..a36add80a 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,16 @@ backup site setup or recovery, or would like to report a bug or a feature reques ## Repository updates - November 2023 -In October 2023 we announced a number of changes to this repository. These changes will improve our (GitHub’s) ability to ship enhancements and new features to backup-utils, as well as simplify how GitHub Enterprise Server customers interact with backup-utils. +In October 2023 we announced a number of changes to this repository. +These changes will improve our (GitHub’s) ability to ship enhancements and new features to backup-utils, +as well as simplify how GitHub Enterprise Server customers interact with backup-utils. -Our process for shipping new versions of backup-utils prior to November 2023 involved a 2-way sync between this repository and an internal repository. This 2-way sync became significantly more problematic once we started regularly shipping patches in alignment with GitHub Enterprise Server. +Our process for shipping new versions of backup-utils prior to November 2023 involved a 2-way sync between this repository and an internal repository. +This 2-way sync became significantly more problematic once we started regularly shipping patches in alignment with GitHub Enterprise Server. -As of 2023-11-30 we have stopped this 2-way sync so that our internal repository becomes the source of truth for the backup-utils source code. With the the 2-way sync stopped, this public repository will be used to host documentation about backup-utils and to publish new versions of backup-utils. You will be able to access a specific version of backup-utils (which includes the full source code) from the [release page](https://github.com/github/backup-utils/releases) of this repository. +As of 2023-11-30 we have stopped this 2-way sync so that our internal repository becomes the source of truth for the backup-utils source code. +With the the 2-way sync stopped, this public repository will be used to host documentation about backup-utils and to publish new versions of backup-utils. +You will be able to access a specific version of backup-utils (which includes the full source code) from the [release page](https://github.com/github/backup-utils/releases) of this repository. This change has not affected the functionality of the backup-utils tool or a customer’s ability to backup or restore their GitHub Enterprise Server instance. @@ -62,17 +67,27 @@ This change has not affected the functionality of the backup-utils tool or a cus There are three specific areas that have been affected by us stop the 2-way sync between our internal repository and this public repository on 2023-11-30: -1. **Pull requests**: Customers should no longer open pull requests in this repository. These pull requests will not be reviewed or merged. This is necessary because we will no longer be syncing changes between this repository and our internal repository. -2. **Issues**: Customers cannot open issues in this repository. Instead, customers will need to follow the standard support process and open a support ticket for any questions/concerns/problems with backup-utils. This will ensure all customer requests are handled consistently. -3. **Installing/upgrading backup-utils**: Customers will not be able to use a clone of the repository to install and upgrade backup-utils. Customers will need to download a specific version of backup-utils from the [release page](https://github.com/github/backup-utils/releases) (either as a Debian package or as an archive file - see below for details on how to incorporate this change). +1. **Pull requests**: Customers should no longer open pull requests in this repository. +These pull requests will not be reviewed or merged. +This is necessary because we will no longer be syncing changes between this repository and our internal repository. +2. **Issues**: Customers cannot open issues in this repository. +Instead, customers will need to follow the standard support process and open a support ticket for any questions/concerns/problems with backup-utils. +This will ensure all customer requests are handled consistently. +3. **Installing/upgrading backup-utils**: Customers will not be able to use a clone of the repository to install and upgrade backup-utils. +Customers will need to download a specific version of backup-utils from the [release page](https://github.com/github/backup-utils/releases) +(either as a Debian package or as an archive file - see below for details on how to incorporate this change). ### Timeline Below is the two phase timeline we will follow to roll out the changes described above: -* **Phase 1 (rolled out on 2023-11-30):** We have closed all open pull requests and issues (after reviewing each one and porting them to our internal repository if merited), and updated the repository settings so that new issues cannot be opened. Also, we have stop syncing code from our internal repository to this repository. - * As of 2023-11-30, you can still get a working copy of backup-utils by cloning the repository. But the code will not be updated in the repository; you can access updated versions of backup-utils via the [release page](https://github.com/github/backup-utils/releases). -* **Phase 2 (rolling out 2024-02-20):** The backup-utils code will be removed and the repository will be used to host documentation for backup-utils. After this date, you will no longer be able to clone a working copy of backup-utils from the repository. Instead, you will need to download a specific version of backup-utils from the [release page](https://github.com/github/backup-utils/releases). +* **Phase 1 (rolled out on 2023-11-30):** We have closed all open pull requests and issues (after reviewing each one and porting them to our internal repository if merited), +and updated the repository settings so that new issues cannot be opened. Also, we have stop syncing code from our internal repository to this repository. + * As of 2023-11-30, you can still get a working copy of backup-utils by cloning the repository. + But the code will not be updated in the repository; you can access updated versions of backup-utils via the [release page](https://github.com/github/backup-utils/releases). +* **Phase 2 (rolling out 2024-02-20):** The backup-utils code will be removed and the repository will be used to host documentation for backup-utils. +After this date, you will no longer be able to clone a working copy of backup-utils from the repository. +Instead, you will need to download a specific version of backup-utils from the [release page](https://github.com/github/backup-utils/releases). ### Updating your backup-utils upgrade process @@ -82,12 +97,12 @@ If your current process for upgrading backup-utils involves a clone of the repos For example, you could download the v3.10.0 (github-backup-utils-v3.10.0.tar.gz) artifact from the [releases page](https://github.com/github/backup-utils/releases/tag/v3.10.0) with: -``` +```shell $ wget https://github.com/github/backup-utils/releases/download/v3.10.0/github-backup-utils-v3.10.0.tar.gz ``` And then extract it: -``` +```shell $ tar xzvf github-backup-utils-v3.10.0.tar.gz ``` @@ -97,7 +112,7 @@ This will give you a new folder, `github-backup-utils-v3.10.0`, which contains t For customers that currently use Docker to create a backup-utils image, their existing process may need updating as a result of this change. Previously customers could execute this command to build a Docker image of backup-utils: -``` +```shell $ docker build github.com/github/backup-utils ``` From 2525298bd4ac3ce9ede78eef54bd2702c7a71f14 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 30 Nov 2023 14:50:57 -0500 Subject: [PATCH 2371/2421] Fix linting errors with dollar sign --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a36add80a..a186c5b3f 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Below is the two phase timeline we will follow to roll out the changes described * **Phase 1 (rolled out on 2023-11-30):** We have closed all open pull requests and issues (after reviewing each one and porting them to our internal repository if merited), and updated the repository settings so that new issues cannot be opened. Also, we have stop syncing code from our internal repository to this repository. - * As of 2023-11-30, you can still get a working copy of backup-utils by cloning the repository. + * As of 2023-11-30, you can still get a working copy of backup-utils by cloning the repository. But the code will not be updated in the repository; you can access updated versions of backup-utils via the [release page](https://github.com/github/backup-utils/releases). * **Phase 2 (rolling out 2024-02-20):** The backup-utils code will be removed and the repository will be used to host documentation for backup-utils. After this date, you will no longer be able to clone a working copy of backup-utils from the repository. @@ -98,12 +98,12 @@ If your current process for upgrading backup-utils involves a clone of the repos For example, you could download the v3.10.0 (github-backup-utils-v3.10.0.tar.gz) artifact from the [releases page](https://github.com/github/backup-utils/releases/tag/v3.10.0) with: ```shell -$ wget https://github.com/github/backup-utils/releases/download/v3.10.0/github-backup-utils-v3.10.0.tar.gz +\$ wget https://github.com/github/backup-utils/releases/download/v3.10.0/github-backup-utils-v3.10.0.tar.gz ``` And then extract it: ```shell -$ tar xzvf github-backup-utils-v3.10.0.tar.gz +\$ tar xzvf github-backup-utils-v3.10.0.tar.gz ``` This will give you a new folder, `github-backup-utils-v3.10.0`, which contains the code for version 3.10.0 of backup-utils. Once you copy over your backup.config file from a previous installation of backup-utils your new version of backup-utils will be ready to use. @@ -113,7 +113,7 @@ This will give you a new folder, `github-backup-utils-v3.10.0`, which contains t For customers that currently use Docker to create a backup-utils image, their existing process may need updating as a result of this change. Previously customers could execute this command to build a Docker image of backup-utils: ```shell -$ docker build github.com/github/backup-utils +\$ docker build github.com/github/backup-utils ``` This will not work after phase 2 roles out. You will need to update your process to first download an archive from the [release page](https://github.com/github/backup-utils/releases), extract it, and then build the Dockerfile inside the extracted directory. From c06ec959046894bdff1ad7a17470f235b461caec Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 30 Nov 2023 20:12:57 -0500 Subject: [PATCH 2372/2421] Fixed a typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f9f7838e6..c0ceedb0e 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Customers will need to download a specific version of backup-utils from the [rel Below is the two phase timeline we will follow to roll out the changes described above: * **Phase 1 (rolled out on 2023-11-30):** We have closed all open pull requests and issues (after reviewing each one and porting them to our internal repository if merited), -and updated the repository settings so that new issues cannot be opened. Also, we have stop syncing code from our internal repository to this repository. +and updated the repository settings so that new issues cannot be opened. Also, we have stopped syncing code from our internal repository to this repository. * As of 2023-11-30, you can still get a working copy of backup-utils by cloning the repository. But the code will not be updated in the repository; you can access updated versions of backup-utils via the [release page](https://github.com/github/backup-utils/releases). * **Phase 2 (rolling out 2024-02-20):** The backup-utils code will be removed and the repository will be used to host documentation for backup-utils. From 2e668ce05f65f020127325f0348537713190eba9 Mon Sep 17 00:00:00 2001 From: David Jarzebowski Date: Thu, 30 Nov 2023 20:17:28 -0500 Subject: [PATCH 2373/2421] Updating requirement about rsync's '--trust-sender' flag --- docs/requirements.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/requirements.md b/docs/requirements.md index 58dfe16ae..27e490fc3 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -22,6 +22,7 @@ CPU and memory requirements are dependent on the size of the GitHub Enterprise S The [fix in rsync `3.2.5`](https://github.com/WayneD/rsync/blob/master/NEWS.md#news-for-rsync-325-14-aug-2022) for [CVE-2022-29154](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29154) can cause severe performance degradation to `backup-utils`. If you encounter this degradation you can mitigate it by using the `--trust-sender` flag, which is available in rsync >= v3.2.5. +**Note**: If you are using backup-utils 3.9 or greater, `--trust-sender` is automatically used if your rsync version supports it and no further changes are needed. If your backup host is running rsync < v3.2.5 you may or may not need to make changes to your rsync package, depending on whether your rsync package has backported the fix for CVE-2022-29154 without also backporting the `--trust-sender` flag. From d0a6f5aa9fedce484d9ee01c38abbea2a053ce2c Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 5 Dec 2023 11:12:26 -0700 Subject: [PATCH 2374/2421] auto close PR from fork repo to prevent custoemr submitting PRs --- .github/workflows/close-pulls.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/close-pulls.yml diff --git a/.github/workflows/close-pulls.yml b/.github/workflows/close-pulls.yml new file mode 100644 index 000000000..ab3126b25 --- /dev/null +++ b/.github/workflows/close-pulls.yml @@ -0,0 +1,21 @@ +--- +name: Auto Close Pull Requests + +on: + schedule: + - cron: '0 * * * *' + +jobs: + close-fork-pulls: + runs-on: ubuntu-latest + + steps: + - name: Close Pull Requests + uses: peter-evans/close-fork-pulls@v2 + with: + comment: | + As of 2023-11-30 we have stopped this 2-way sync so that our internal repository becomes the source of truth for the backup-utils source code. With the the 2-way sync stopped, this public repository will be used to host documentation about backup-utils and to publish new versions of backup-utils. You will be able to access a specific version of backup-utils (which includes the full source code) from the [release page](https://github.com/github/backup-utils/releases) of this repository. + + Customers should no longer open pull requests in this repository. These pull requests will not be reviewed or merged. We will automatically close all PRs opened in this repository. + + Customers cannot open issues in this repository. Instead, customers will need to follow the standard support process and open a support ticket for any questions/concerns/problems with backup-utils. This will ensure all customer requests are handled consistently. From 2b993ac3bd90430513cbf050178546dd012526e3 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 5 Dec 2023 11:45:34 -0700 Subject: [PATCH 2375/2421] Update with comments --- .github/workflows/close-pulls.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/close-pulls.yml b/.github/workflows/close-pulls.yml index ab3126b25..24f0391ba 100644 --- a/.github/workflows/close-pulls.yml +++ b/.github/workflows/close-pulls.yml @@ -14,7 +14,7 @@ jobs: uses: peter-evans/close-fork-pulls@v2 with: comment: | - As of 2023-11-30 we have stopped this 2-way sync so that our internal repository becomes the source of truth for the backup-utils source code. With the the 2-way sync stopped, this public repository will be used to host documentation about backup-utils and to publish new versions of backup-utils. You will be able to access a specific version of backup-utils (which includes the full source code) from the [release page](https://github.com/github/backup-utils/releases) of this repository. + As of 2023-11-30 we have stopped the 2-way sync between this repository and our internal repository, so that our internal repository becomes the source of truth for the backup-utils source code. With the the 2-way sync stopped, this public repository will be used to host documentation about backup-utils and to publish new versions of backup-utils. You will be able to access a specific version of backup-utils (which includes the full source code) from the [release page](https://github.com/github/backup-utils/releases) of this repository. Customers should no longer open pull requests in this repository. These pull requests will not be reviewed or merged. We will automatically close all PRs opened in this repository. From e4f3ae78261da0b1ec9ce5ebd437db14637b5848 Mon Sep 17 00:00:00 2001 From: "release-controller[bot]" Date: Thu, 15 Feb 2024 22:34:51 +0000 Subject: [PATCH 2376/2421] 3.12.0 release --- docs/getting-started.md | 2 +- docs/requirements.md | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 02f2cbe9b..ac85e5073 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,6 +1,6 @@ # Getting started - 1. [Download the latest release version][1] and extract the repository using `tar`: + 1. [Download the latest version of backup-utils][1] and extract the repository using `tar`: `tar -xzvf /path/to/github-backup-utils-vMAJOR.MINOR.PATCH.tar.gz` diff --git a/docs/requirements.md b/docs/requirements.md index 27e490fc3..6fa54e567 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -7,12 +7,10 @@ storage and must have network connectivity with the GitHub Enterprise Server app Backup host software requirements are modest: Linux or other modern Unix operating system (Ubuntu is highly recommended) with [bash][1], [git][2] 1.7.6 or newer, [OpenSSH][3] 5.6 or newer, [rsync][4] v2.6.4 or newer* (see [below](april-2023-update-of-rsync-requirements) for exceptions), [jq][11] v1.5 or newer and [bc][12] v1.0.7 or newer. See below for an update on rsync. -Ubuntu is the operating system we use to test `backup-utils` and it’s what we recommend you use too. You are welcome to use a different operating system, and we'll do our best to help you if you run into issues. But we can't guarantee that we'll be able to resolve issues that are specific to that operating system. - -Additionally, we encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. - The parallel backup and restore feature will require [GNU awk][10] and [moreutils][9] to be installed. +We encourage the use of [Docker](docker.md), as it ensures compatible versions of the aforementioned software are available to backup-utils. + The backup host must be able to establish outbound network connections to the GitHub appliance over SSH. TCP port 122 is used to backup GitHub Enterprise Server. CPU and memory requirements are dependent on the size of the GitHub Enterprise Server appliance. We recommend a minimum of 4 cores and 8GB of RAM for the host running [GitHub Enterprise Backup Utilities](https://github.com/github/backup-utils). We recommend monitoring the backup host's CPU and memory usage to ensure it is sufficient for your environment. @@ -67,23 +65,23 @@ Please avoid using an NFS mount for the data directory (where backup data is sto Starting with Backup Utilities v2.13.0, version support is inline with that of the [GitHub Enterprise Server upgrade requirements][8] and as such, support is limited to three versions of GitHub Enterprise Server: the version that corresponds with the version -of Backup Utilities, and the two releases prior to it. +of Backup Utilities, and the two versions prior to it. For example, Backup Utilities v2.13.0 can be used to backup and restore all patch -releases from 2.11.0 to the latest patch release of GitHub Enterprise Server 2.13. +versions from 2.11.0 to the latest patch version of GitHub Enterprise Server 2.13. Backup Utilities v2.14.0 will be released when GitHub Enterprise Server 2.14.0 is released -and will then be used to backup all releases of GitHub Enterprise Server from 2.12.0 -to the latest patch release of GitHub Enterprise Server 2.14. +and will then be used to backup all versions of GitHub Enterprise Server from 2.12.0 +to the latest patch version of GitHub Enterprise Server 2.14. Backup Utilities v2.11.4 and earlier offer support for GitHub Enterprise Server 2.10 -and earlier releases up to GitHub Enterprise Server 2.2.0. Backup Utilities v2.11.0 and earlier +and earlier versions up to GitHub Enterprise Server 2.2.0. Backup Utilities v2.11.0 and earlier offer support for GitHub Enterprise Server 2.1.0 and earlier. -**Note**: You can restore a snapshot that's at most two feature releases behind +**Note**: You can restore a snapshot that's at most two feature versions behind the restore target's version of GitHub Enterprise Server. For example, to restore a snapshot of GitHub Enterprise Server 2.11, the target GitHub Enterprise Server appliance must be running GitHub Enterprise Server 2.12.x or 2.13.x. You can't restore a snapshot from -2.10 to 2.13, because that's three releases ahead. +2.10 to 2.13, because that's three versions ahead. **Note**: You _cannot_ restore a backup created from a newer version of GitHub Enterprise Server to an older version. For example, an attempt to restore a snapshot of GitHub Enterprise Server 2.21 to a GitHub Enterprise Server 2.20 environment will fail with an error of `Error: Snapshot can not be restored to an older release of GitHub Enterprise Server.`. From 9a8c195637871a17b0f670d7c8f6e28482714fa2 Mon Sep 17 00:00:00 2001 From: Hao Jiang Date: Tue, 19 Mar 2024 17:47:46 -0600 Subject: [PATCH 2377/2421] Remove code from backup-utils --- CONTRIBUTING.md | 12 - Dockerfile | 76 -- Dockerfile.alpine | 20 - LICENSE | 20 - Makefile | 27 - STYLEGUIDE.md | 250 ---- backup.config-example | 123 -- bin/ghe-backup | 406 ------ bin/ghe-backup-progress | 56 - bin/ghe-host-check | 265 ---- bin/ghe-restore | 727 ----------- debian/changelog | 666 ---------- debian/clean | 1 - debian/compat | 1 - debian/control | 32 - debian/copyright | 33 - debian/install | 2 - debian/manpages | 1 - debian/rules | 18 - debian/source/format | 1 - ownership.yaml | 29 - release-notes/3.11.0.md | 18 - script/package-deb | 42 - script/package-tarball | 42 - script/release | 506 -------- script/test | 28 - share/github-backup-utils/bm.sh | 63 - share/github-backup-utils/ghe-backup-actions | 51 - share/github-backup-utils/ghe-backup-config | 708 ----------- .../ghe-backup-es-audit-log | 58 - share/github-backup-utils/ghe-backup-es-rsync | 86 -- share/github-backup-utils/ghe-backup-fsck | 91 -- .../github-backup-utils/ghe-backup-git-hooks | 114 -- share/github-backup-utils/ghe-backup-minio | 55 - share/github-backup-utils/ghe-backup-mssql | 363 ------ share/github-backup-utils/ghe-backup-mysql | 48 - .../ghe-backup-mysql-binary | 60 - .../ghe-backup-mysql-logical | 27 - share/github-backup-utils/ghe-backup-pages | 89 -- share/github-backup-utils/ghe-backup-redis | 55 - .../ghe-backup-repositories | 407 ------ share/github-backup-utils/ghe-backup-secrets | 186 --- share/github-backup-utils/ghe-backup-settings | 50 - share/github-backup-utils/ghe-backup-storage | 179 --- .../ghe-backup-store-version | 23 - share/github-backup-utils/ghe-backup-strategy | 20 - share/github-backup-utils/ghe-backup-userdata | 64 - .../ghe-cluster-find-nodes | 41 - .../ghe-detect-leaked-ssh-keys | 140 --- share/github-backup-utils/ghe-docker-init | 12 - share/github-backup-utils/ghe-gc-disable | 42 - share/github-backup-utils/ghe-gc-enable | 35 - .../ghe-incremental-backup-restore | 380 ------ .../ghe-maintenance-mode-status | 30 - share/github-backup-utils/ghe-prune-snapshots | 130 -- share/github-backup-utils/ghe-restore-actions | 68 - .../ghe-restore-es-audit-log | 76 -- .../github-backup-utils/ghe-restore-es-rsync | 49 - ...tore-external-database-compatibility-check | 44 - .../github-backup-utils/ghe-restore-git-hooks | 99 -- share/github-backup-utils/ghe-restore-minio | 57 - share/github-backup-utils/ghe-restore-mssql | 91 -- share/github-backup-utils/ghe-restore-mysql | 82 -- .../ghe-restore-mysql-binary | 125 -- .../ghe-restore-mysql-legacy | 55 - .../ghe-restore-mysql-logical | 52 - share/github-backup-utils/ghe-restore-pages | 166 --- share/github-backup-utils/ghe-restore-redis | 26 - .../ghe-restore-repositories | 248 ---- .../ghe-restore-repositories-gist | 175 --- share/github-backup-utils/ghe-restore-secrets | 146 --- .../github-backup-utils/ghe-restore-settings | 52 - .../ghe-restore-snapshot-path | 32 - .../github-backup-utils/ghe-restore-ssh-keys | 28 - share/github-backup-utils/ghe-restore-storage | 181 --- share/github-backup-utils/ghe-rsync | 72 -- .../ghe-rsync-feature-checker | 47 - share/github-backup-utils/ghe-rsync-size | 106 -- share/github-backup-utils/ghe-ssh | 86 -- share/github-backup-utils/ghe-ssh-config | 86 -- .../ghe-ssh-leaked-host-keys-list.txt | 531 -------- share/github-backup-utils/requirements.txt | 3 - share/github-backup-utils/track-progress | 18 - share/github-backup-utils/version | 1 - test/STYLEGUIDE.md | 36 - test/backup.config | 11 - test/bin/chown | 1 - test/bin/cron | 1 - test/bin/curl | 22 - test/bin/dgit-cluster-backup-routes | 31 - test/bin/dgit-cluster-restore-finalize | 1 - test/bin/dgit-cluster-restore-routes | 9 - test/bin/dpages-cluster-restore-finalize | 1 - test/bin/dpages-cluster-restore-routes | 9 - test/bin/enterprise-configure | 6 - test/bin/ghe-actions-console | 1 - test/bin/ghe-actions-start | 1 - test/bin/ghe-actions-stop | 1 - test/bin/ghe-cluster-config-apply | 6 - test/bin/ghe-cluster-config-update | 6 - test/bin/ghe-cluster-each | 35 - test/bin/ghe-cluster-host-check | 5 - test/bin/ghe-cluster-nodes | 41 - test/bin/ghe-config | 18 - test/bin/ghe-config-apply | 6 - test/bin/ghe-dpages | 1 - test/bin/ghe-es-load-json | 5 - test/bin/ghe-es-remove-1x-indices | 1 - test/bin/ghe-es-snapshot | 6 - test/bin/ghe-export-authorized-keys | 1 - test/bin/ghe-export-mssql | 1 - test/bin/ghe-export-mysql | 1 - test/bin/ghe-export-redis | 1 - test/bin/ghe-export-settings | 1 - test/bin/ghe-export-ssh-host-keys | 18 - test/bin/ghe-export-ssl-ca-certificates | 1 - test/bin/ghe-fake-export-command | 6 - test/bin/ghe-fake-finalize-command | 16 - test/bin/ghe-fake-import-command | 6 - test/bin/ghe-fake-true | 4 - test/bin/ghe-hook-env-update | 11 - test/bin/ghe-import-authorized-keys | 1 - test/bin/ghe-import-license | 1 - test/bin/ghe-import-mssql | 1 - test/bin/ghe-import-mysql | 1 - test/bin/ghe-import-mysql-mysqldump | 1 - test/bin/ghe-import-mysql-xtrabackup | 1 - test/bin/ghe-import-redis | 1 - test/bin/ghe-import-settings | 1 - test/bin/ghe-import-ssh-host-keys | 1 - test/bin/ghe-import-ssl-ca-certificates | 1 - test/bin/ghe-maintenance | 1 - test/bin/ghe-mssql-console | 21 - test/bin/ghe-negotiate-version | 7 - test/bin/ghe-nomad-cleanup | 5 - test/bin/ghe-nomad-jobs | 7 - test/bin/ghe-redis-cli | 37 - test/bin/ghe-reset-gh-connect | 1 - test/bin/ghe-service-ensure-elasticsearch | 6 - test/bin/ghe-service-ensure-mysql | 6 - test/bin/ghe-service-wait-mysql | 6 - test/bin/ghe-spokes | 16 - test/bin/ghe-storage | 1 - test/bin/gist-cluster-restore-finalize | 1 - test/bin/gist-cluster-restore-routes | 9 - test/bin/github-env | 1 - test/bin/ionice-stub | 3 - test/bin/nomad | 6 - test/bin/python | 28 - test/bin/service | 1 - test/bin/ssh | 51 - test/bin/storage-cluster-backup-routes | 10 - test/bin/storage-cluster-restore-finalize | 1 - test/bin/storage-cluster-restore-routes | 10 - test/bin/systemctl | 1 - test/cluster.conf | 65 - test/test-docker-build.sh | 63 - test/test-ghe-backup-config.sh | 227 ---- test/test-ghe-backup-parallel.sh | 12 - test/test-ghe-backup.sh | 1093 ----------------- test/test-ghe-cluster-find-nodes.sh | 41 - test/test-ghe-detect-leaked-ssh-keys.sh | 61 - test/test-ghe-host-check.sh | 124 -- test/test-ghe-incremental-restore.sh | 82 -- test/test-ghe-prune-snapshots.sh | 111 -- test/test-ghe-restore-external-database.sh | 194 --- test/test-ghe-restore-parallel.sh | 24 - test/test-ghe-restore.sh | 1022 --------------- test/test-ghe-rsync-feature-checker.sh | 156 --- test/test-ghe-ssh-config.sh | 103 -- test/test-ghe-ssh.sh | 53 - test/test-shellcheck.sh | 66 - test/testlib.sh | 730 ----------- 173 files changed, 14612 deletions(-) delete mode 100644 CONTRIBUTING.md delete mode 100644 Dockerfile delete mode 100644 Dockerfile.alpine delete mode 100644 LICENSE delete mode 100644 Makefile delete mode 100644 STYLEGUIDE.md delete mode 100644 backup.config-example delete mode 100755 bin/ghe-backup delete mode 100755 bin/ghe-backup-progress delete mode 100755 bin/ghe-host-check delete mode 100755 bin/ghe-restore delete mode 100644 debian/changelog delete mode 100644 debian/clean delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/install delete mode 100644 debian/manpages delete mode 100755 debian/rules delete mode 100644 debian/source/format delete mode 100644 ownership.yaml delete mode 100644 release-notes/3.11.0.md delete mode 100755 script/package-deb delete mode 100755 script/package-tarball delete mode 100755 script/release delete mode 100755 script/test delete mode 100755 share/github-backup-utils/bm.sh delete mode 100755 share/github-backup-utils/ghe-backup-actions delete mode 100755 share/github-backup-utils/ghe-backup-config delete mode 100755 share/github-backup-utils/ghe-backup-es-audit-log delete mode 100755 share/github-backup-utils/ghe-backup-es-rsync delete mode 100755 share/github-backup-utils/ghe-backup-fsck delete mode 100755 share/github-backup-utils/ghe-backup-git-hooks delete mode 100755 share/github-backup-utils/ghe-backup-minio delete mode 100755 share/github-backup-utils/ghe-backup-mssql delete mode 100755 share/github-backup-utils/ghe-backup-mysql delete mode 100755 share/github-backup-utils/ghe-backup-mysql-binary delete mode 100755 share/github-backup-utils/ghe-backup-mysql-logical delete mode 100755 share/github-backup-utils/ghe-backup-pages delete mode 100755 share/github-backup-utils/ghe-backup-redis delete mode 100755 share/github-backup-utils/ghe-backup-repositories delete mode 100755 share/github-backup-utils/ghe-backup-secrets delete mode 100755 share/github-backup-utils/ghe-backup-settings delete mode 100755 share/github-backup-utils/ghe-backup-storage delete mode 100755 share/github-backup-utils/ghe-backup-store-version delete mode 100755 share/github-backup-utils/ghe-backup-strategy delete mode 100755 share/github-backup-utils/ghe-backup-userdata delete mode 100755 share/github-backup-utils/ghe-cluster-find-nodes delete mode 100755 share/github-backup-utils/ghe-detect-leaked-ssh-keys delete mode 100755 share/github-backup-utils/ghe-docker-init delete mode 100755 share/github-backup-utils/ghe-gc-disable delete mode 100755 share/github-backup-utils/ghe-gc-enable delete mode 100644 share/github-backup-utils/ghe-incremental-backup-restore delete mode 100755 share/github-backup-utils/ghe-maintenance-mode-status delete mode 100755 share/github-backup-utils/ghe-prune-snapshots delete mode 100755 share/github-backup-utils/ghe-restore-actions delete mode 100755 share/github-backup-utils/ghe-restore-es-audit-log delete mode 100755 share/github-backup-utils/ghe-restore-es-rsync delete mode 100755 share/github-backup-utils/ghe-restore-external-database-compatibility-check delete mode 100755 share/github-backup-utils/ghe-restore-git-hooks delete mode 100755 share/github-backup-utils/ghe-restore-minio delete mode 100755 share/github-backup-utils/ghe-restore-mssql delete mode 100755 share/github-backup-utils/ghe-restore-mysql delete mode 100755 share/github-backup-utils/ghe-restore-mysql-binary delete mode 100755 share/github-backup-utils/ghe-restore-mysql-legacy delete mode 100755 share/github-backup-utils/ghe-restore-mysql-logical delete mode 100755 share/github-backup-utils/ghe-restore-pages delete mode 100755 share/github-backup-utils/ghe-restore-redis delete mode 100755 share/github-backup-utils/ghe-restore-repositories delete mode 100755 share/github-backup-utils/ghe-restore-repositories-gist delete mode 100755 share/github-backup-utils/ghe-restore-secrets delete mode 100755 share/github-backup-utils/ghe-restore-settings delete mode 100755 share/github-backup-utils/ghe-restore-snapshot-path delete mode 100755 share/github-backup-utils/ghe-restore-ssh-keys delete mode 100755 share/github-backup-utils/ghe-restore-storage delete mode 100755 share/github-backup-utils/ghe-rsync delete mode 100755 share/github-backup-utils/ghe-rsync-feature-checker delete mode 100644 share/github-backup-utils/ghe-rsync-size delete mode 100755 share/github-backup-utils/ghe-ssh delete mode 100755 share/github-backup-utils/ghe-ssh-config delete mode 100644 share/github-backup-utils/ghe-ssh-leaked-host-keys-list.txt delete mode 100644 share/github-backup-utils/requirements.txt delete mode 100755 share/github-backup-utils/track-progress delete mode 100644 share/github-backup-utils/version delete mode 100644 test/STYLEGUIDE.md delete mode 100644 test/backup.config delete mode 120000 test/bin/chown delete mode 120000 test/bin/cron delete mode 100755 test/bin/curl delete mode 100755 test/bin/dgit-cluster-backup-routes delete mode 120000 test/bin/dgit-cluster-restore-finalize delete mode 100755 test/bin/dgit-cluster-restore-routes delete mode 120000 test/bin/dpages-cluster-restore-finalize delete mode 100755 test/bin/dpages-cluster-restore-routes delete mode 100755 test/bin/enterprise-configure delete mode 100755 test/bin/ghe-actions-console delete mode 120000 test/bin/ghe-actions-start delete mode 120000 test/bin/ghe-actions-stop delete mode 100755 test/bin/ghe-cluster-config-apply delete mode 100755 test/bin/ghe-cluster-config-update delete mode 100755 test/bin/ghe-cluster-each delete mode 100755 test/bin/ghe-cluster-host-check delete mode 100755 test/bin/ghe-cluster-nodes delete mode 100755 test/bin/ghe-config delete mode 100755 test/bin/ghe-config-apply delete mode 120000 test/bin/ghe-dpages delete mode 100755 test/bin/ghe-es-load-json delete mode 120000 test/bin/ghe-es-remove-1x-indices delete mode 100755 test/bin/ghe-es-snapshot delete mode 120000 test/bin/ghe-export-authorized-keys delete mode 120000 test/bin/ghe-export-mssql delete mode 120000 test/bin/ghe-export-mysql delete mode 120000 test/bin/ghe-export-redis delete mode 120000 test/bin/ghe-export-settings delete mode 100755 test/bin/ghe-export-ssh-host-keys delete mode 120000 test/bin/ghe-export-ssl-ca-certificates delete mode 100755 test/bin/ghe-fake-export-command delete mode 100755 test/bin/ghe-fake-finalize-command delete mode 100755 test/bin/ghe-fake-import-command delete mode 100755 test/bin/ghe-fake-true delete mode 100755 test/bin/ghe-hook-env-update delete mode 120000 test/bin/ghe-import-authorized-keys delete mode 120000 test/bin/ghe-import-license delete mode 120000 test/bin/ghe-import-mssql delete mode 120000 test/bin/ghe-import-mysql delete mode 120000 test/bin/ghe-import-mysql-mysqldump delete mode 120000 test/bin/ghe-import-mysql-xtrabackup delete mode 120000 test/bin/ghe-import-redis delete mode 120000 test/bin/ghe-import-settings delete mode 120000 test/bin/ghe-import-ssh-host-keys delete mode 120000 test/bin/ghe-import-ssl-ca-certificates delete mode 120000 test/bin/ghe-maintenance delete mode 100755 test/bin/ghe-mssql-console delete mode 100755 test/bin/ghe-negotiate-version delete mode 100755 test/bin/ghe-nomad-cleanup delete mode 100755 test/bin/ghe-nomad-jobs delete mode 100755 test/bin/ghe-redis-cli delete mode 120000 test/bin/ghe-reset-gh-connect delete mode 100755 test/bin/ghe-service-ensure-elasticsearch delete mode 100755 test/bin/ghe-service-ensure-mysql delete mode 100755 test/bin/ghe-service-wait-mysql delete mode 100755 test/bin/ghe-spokes delete mode 120000 test/bin/ghe-storage delete mode 120000 test/bin/gist-cluster-restore-finalize delete mode 100755 test/bin/gist-cluster-restore-routes delete mode 120000 test/bin/github-env delete mode 100755 test/bin/ionice-stub delete mode 100755 test/bin/nomad delete mode 100755 test/bin/python delete mode 120000 test/bin/service delete mode 100755 test/bin/ssh delete mode 100755 test/bin/storage-cluster-backup-routes delete mode 120000 test/bin/storage-cluster-restore-finalize delete mode 100755 test/bin/storage-cluster-restore-routes delete mode 120000 test/bin/systemctl delete mode 100644 test/cluster.conf delete mode 100755 test/test-docker-build.sh delete mode 100755 test/test-ghe-backup-config.sh delete mode 100755 test/test-ghe-backup-parallel.sh delete mode 100755 test/test-ghe-backup.sh delete mode 100755 test/test-ghe-cluster-find-nodes.sh delete mode 100755 test/test-ghe-detect-leaked-ssh-keys.sh delete mode 100755 test/test-ghe-host-check.sh delete mode 100755 test/test-ghe-incremental-restore.sh delete mode 100755 test/test-ghe-prune-snapshots.sh delete mode 100755 test/test-ghe-restore-external-database.sh delete mode 100755 test/test-ghe-restore-parallel.sh delete mode 100755 test/test-ghe-restore.sh delete mode 100755 test/test-ghe-rsync-feature-checker.sh delete mode 100755 test/test-ghe-ssh-config.sh delete mode 100755 test/test-ghe-ssh.sh delete mode 100755 test/test-shellcheck.sh delete mode 100755 test/testlib.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 042d7c71a..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,12 +0,0 @@ -# Contributing - -Looking to contribute something to this project? That is great, we always appreciate pull requests! Here's how you can help: - -1. Fork the project to your account. -2. Clone the fork (`git clone https://github.com/[username]/backup-utils.git`). -3. Create a new feature branch (`git checkout -b my-feature-branch`). -4. Add and then commit your changes (`git commit -am "Add a new backup endpoint."`). -5. Push your feature branch to GitHub.com (`git push -u origin my-feature-branch`). -6. Open a [Pull Request](https://github.com/github/backup-utils/compare/) and wait for our feedback. - -Have a look at the [styleguide](https://github.com/github/backup-utils/tree/master/STYLEGUIDE.md) to make sure your code style is consistent with the code in this repository. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 710cb9d52..000000000 --- a/Dockerfile +++ /dev/null @@ -1,76 +0,0 @@ -# Multi stage build for backup-utils -# Build layer is for compiling rsync from source -# Runtime layer is for running backup-utils -# https://docs.docker.com/develop/develop-images/multistage-build/ -# https://docs.docker.com/engine/userguide/eng-image/multistage-build/ - -# Build layer -FROM ubuntu:focal AS build - -# Install build dependencies -RUN apt-get update && apt-get install --no-install-recommends -y \ - gcc \ - g++ \ - gawk \ - autoconf \ - make \ - automake \ - python3-cmarkgfm \ - acl \ - libacl1-dev \ - attr \ - libattr1-dev \ - libxxhash-dev \ - libzstd-dev \ - liblz4-dev \ - libssl-dev \ - git \ - jq \ - bc \ - curl \ - tar \ - gzip \ - ca-certificates \ - && rm -rf /var/lib/apt/lists/* - -# Download rsync source from https://github.com/WayneD/rsync/archive/refs/tags/[TAG].tar.gz pinned to specified tag -ARG RSYNC_TAG=v3.2.7 -RUN curl https://github.com/WayneD/rsync/archive/refs/tags/${RSYNC_TAG}.tar.gz -L -o ${RSYNC_TAG}.tar.gz -RUN mkdir -p /rsync-${RSYNC_TAG}&& tar -xzf ${RSYNC_TAG}.tar.gz -C /rsync-${RSYNC_TAG} --strip-components=1 && ls -la -# Change to the working directory of the rsync source -WORKDIR /rsync-${RSYNC_TAG} -RUN ls -la && ./configure -RUN make -RUN make install - -# Reset working directory -WORKDIR / - -# Runtime layer -FROM ubuntu:focal AS runtime - -# Install runtime dependencies - bash, git, OpenSSH 5.6 or newer, and jq v1.5 or newer. -RUN apt-get update && apt-get install --no-install-recommends -y \ - bash \ - git \ - openssh-client \ - jq \ - bc \ - moreutils \ - gawk \ - ca-certificates \ - xxhash \ - && rm -rf /var/lib/apt/lists/* - -# Copy rsync from build layer -COPY --from=build /usr/local/bin/rsync /usr/local/bin/rsync - -# Copy backup-utils from repository into /backup-utils -COPY ./ /backup-utils/ - -WORKDIR /backup-utils - -RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init - -ENTRYPOINT ["/backup-utils/share/github-backup-utils/ghe-docker-init"] -CMD ["ghe-host-check"] diff --git a/Dockerfile.alpine b/Dockerfile.alpine deleted file mode 100644 index 2c21bf2cd..000000000 --- a/Dockerfile.alpine +++ /dev/null @@ -1,20 +0,0 @@ -FROM alpine:latest - -RUN apk --update --no-cache add \ - tar \ - rsync \ - ca-certificates \ - openssh \ - git \ - bash \ - gawk \ - procps \ - coreutils - -COPY ./ /backup-utils/ -WORKDIR /backup-utils - -RUN chmod +x /backup-utils/share/github-backup-utils/ghe-docker-init - -ENTRYPOINT ["/backup-utils/share/github-backup-utils/ghe-docker-init"] -CMD ["ghe-host-check"] diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 4d231b456..000000000 --- a/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2014 GitHub Inc. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile deleted file mode 100644 index c8eaa0ff1..000000000 --- a/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -SHELL = /bin/sh - -test: info - @echo Running tests - @script/test - -info: - @echo This is github/backup-utils - @echo shell is $(shell ls -l $(SHELL) | sed 's@.*/bin/sh@/bin/sh@') - @rsync --version | head -1 - @echo - -dist: - @script/package-tarball - -deb: - @script/package-deb - -clean: - rm -rf dist - -# List pull requests that need to be merged into stable -# (helpful for the release notes) -pending-prs: - @git log stable...master | grep "Merge pull request" - -.PHONY: test info dist clean pending-prs diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md deleted file mode 100644 index 9c1fc1e86..000000000 --- a/STYLEGUIDE.md +++ /dev/null @@ -1,250 +0,0 @@ -## Bash Style Guide - -If you've not done much Bash development before you may find these debugging tips useful: http://wiki.bash-hackers.org/scripting/debuggingtips. - ---- -##### Scripts must start with `#!/usr/bin/env bash` - ---- -##### Use `set -e` - -If the return value of a command can be ignored, suffix it with `|| true`: - -```bash -set -e -command_that_might_fail || true -command_that_should_not_fail -``` - -Note that ignoring an exit status with `|| true` is not a good practice though. Generally speaking, it's better to handle the error. - ---- -##### Avoid manually checking exit status with `$?` - -Rely on `set -e` instead: - -```bash -cmd -if [ $? -eq 0 ]; then - echo worked -fi -``` - -should be written as: - -```bash -set -e -if cmd; then - echo worked -fi -``` - ---- -##### Include a usage, description and optional examples - -Use this format: - -```bash -#!/usr/bin/env bash -#/ Usage: ghe-this-is-my-script [options] -#/ -#/ This is a brief description of the script's purpose. -#/ -#/ OPTIONS: -#/ -h | --help Show this message. -#/ -l | --longopt An option. -#/ -c Another option. -#/ -#/ EXAMPLES: (optional section but nice to have when not trivial) -#/ -#/ This will do foo and bar: -#/ $ ghe-this-is-my-script --longopt foobar -c 2 -#/ -set -e -``` - -If there are no options or required arguments, the `OPTIONS` section can be ignored. - ---- -##### Customer-facing scripts must accept both -h and --help arguments - -They should also print the usage information and exit 2. - -For example: - -```bash -#!/usr/bin/env bash -#/ Usage: ghe-this-is-my-script [options] -#/ -#/ This is a brief description of the script's purpose. -set -e - -if [ "$1" = "--help" -o "$1" = "-h" ]; then - grep '^#/' <"$0" | cut -c 4- - exit 2 -fi - -``` - ---- -##### Avoid Bash arrays - -Main issues: - -* Portability -* Important bugs in Bash versions < 4.3 - ---- -##### Use `test` or `[` whenever possible - -```bash -test -f /etc/passwd -test -f /etc/passwd -a -f /etc/group -if [ "string" = "string" ]; then - true -fi -``` - ---- -##### Scripts may use `[[` for advanced bash features - -```bash -if [[ "$(hostname)" = *.iad.github.net ]]; then - true -fi -``` - ---- -##### Scripts may use Bash for loops - -Preferred: - -```bash -for i in $(seq 0 9); do -done -``` - -or: - -```bash -for ((n=0; n<10; n++)); do -done -``` - ---- -##### Use `$[x+y*z]` for mathematical expressions - -```bash -local n=1 -let n++ -n=$[n+1] # preferred -n=$[$n+1] -n=$((n+1)) -n=$(($n+1)) -``` - ---- -##### Use variables sparingly - -Short paths and other constants should be repeated liberally throughout code since they -can be search/replaced easily if they ever change. - -```bash -DATA_DB_PATH=/data/user/db -mkdir -p $DATA_DB_PATH -rsync $DATA_DB_PATH remote:$DATA_DB_PATH -``` - -versus the much more readable: - -```bash -mkdir -p /data/user/db -rsync /data/user/db remote:/data/user/db -``` - ---- -##### Use lowercase and uppercase variable names - -Use lowercase variables for locals and internal variables, and uppercase for variables inherited or exported via the environment - -```bash -#!/usr/bin/env bash -#/ Usage: [DEBUG=0] process_repo -nwo=$1 -[ -n $DEBUG ] && echo "** processing $nwo" >&2 - -export GIT_DIR=/data/repos/$nwo.git -git rev-list -``` - ---- -##### Use `${var}` for interpolation only when required - -```bash -greeting=hello -echo $greeting -echo ${greeting}world -``` - ---- -##### Use functions sparingly, opting for small/simple/sequential scripts instead whenever possible - -When defining functions, use the following style: - -```bash -my_function() { - local arg1=$1 - [ -n $arg1 ] || return - ... -} -``` - ---- -##### Use `< /etc/foo # interpolated before ssh - chmod 0600 /etc/foo -eof -``` - ---- -##### Quote variables that could reasonably have a space now or in the future - -```bash -if [ ! -z "$packages" ]; then - true -fi -``` - ---- -##### Use two space indentation - ---- -##### Scripts should not produce errors or warnings when checked with ShellCheck - -Use inline comments to disable specific tests, and explain why the test has been disabled. - -```bash -hexToAscii() { - # shellcheck disable=SC2059 # $1 needs to be interpreted as a formatted string - printf "\x$1" -} -``` - -### Testing - -See [the style guide](https://github.com/github/backup-utils/blob/master/test/STYLEGUIDE.md) diff --git a/backup.config-example b/backup.config-example deleted file mode 100644 index 535a2f636..000000000 --- a/backup.config-example +++ /dev/null @@ -1,123 +0,0 @@ -# GitHub Enterprise Server backup configuration file - -# The hostname of the GitHub Enterprise Server appliance to back up. The host -# must be reachable via SSH from the backup host. -GHE_HOSTNAME="github.example.com" - -# Path to where backup data is stored. By default this is the "data" -# directory next to this file but can be set to an absolute path -# elsewhere for backing up to a separate partition / mount point. -GHE_DATA_DIR="data" - -# The number of backup snapshots to retain. Old snapshots are pruned after each -# successful ghe-backup run. This option should be tuned based on the frequency -# of scheduled backup runs. If backups are scheduled hourly, snapshots will be -# available for the past N hours; if backups are scheduled daily, snapshots will -# be available for the past N days ... -GHE_NUM_SNAPSHOTS=10 - -# Pruning snapshots can be scheduled outside of the backup process. -# If set to 'yes', snapshots will not be pruned by ghe-backup. -# Instead, ghe-pruning-snapshots will need to be invoked separately via cron -#GHE_PRUNING_SCHEDULED=yes - -# If --incremental is used to generate incremental MySQL backups with ghe-backup, -# then you need to specify how many cycles of full and incremental backups will be -# performed before the next full backup is created. -# For example, if `GHE_INCREMENTAL_BACKUP_MAX` is set to 14, backup-utils will -# run 1 full backup and then 13 incremental backups before performing another full backup on the next cycle. -#GHE_INCREMENTAL_MAX_BACKUPS=14 - -# If GHE_SKIP_CHECKS is set to true (or if --skip-checks is used with ghe-backup) then ghe-host-check -# disk space validation and software version checks on the backup-host will be disabled. -#GHE_SKIP_CHECKS=false - -# The hostname of the GitHub appliance to restore. If you've set up a separate -# GitHub appliance to act as a standby for recovery, specify its IP or hostname -# here. The host to restore to may also be specified directly when running -# ghe-restore so use of this variable isn't strictly required. -# -#GHE_RESTORE_HOST="github-standby.example.com" - -# If set to 'yes', ghe-restore will omit the restore of audit logs. -# -#GHE_RESTORE_SKIP_AUDIT_LOGS=no - -# When verbose output is enabled with `-v`, it's written to stdout by default. If -# you'd prefer it to be written to a separate file, set this option. -# -#GHE_VERBOSE_LOG="/var/log/backup-verbose.log" - -# Any extra options passed to the SSH command. -# In a single instance environment, nothing is required by default. -# In a clustering environment, "-i abs-path-to-ssh-private-key" is required. -# -#GHE_EXTRA_SSH_OPTS="" - -# Any extra options passed to the rsync command. Nothing required by default. -# -#GHE_EXTRA_RSYNC_OPTS="" - -# If set to 'yes', rsync will be set to use compression during backups and restores transfers. Defaults to 'no'. -# -#GHE_RSYNC_COMPRESSION_ENABLED=yes - -# If enabled and set to 'no', rsync warning message during backups will be suppressed. -#RSYNC_WARNING=no - - -# If set to 'yes', logging output will be colorized. -# -#OUTPUT_COLOR=no - -# If set to 'no', GHE_DATA_DIR will not be created automatically -# and restore/backup will exit 8 -# -#GHE_CREATE_DATA_DIR=yes - -# If set to 'yes', git fsck will run on the repositories -# and print some additional info. -# -# WARNING: do not enable this, only useful for debugging/development -#GHE_BACKUP_FSCK=no - -# Cadence of MSSQL backups -# ,, all in minutes -# e.g. -# - Full backup every week (10080 minutes) -# - Differential backup every day (1440 minutes) -# - Transactionlog backup every 15 minutes -# -#GHE_MSSQL_BACKUP_CADENCE=10080,1440,15 - -# If set to 'yes', ghe-backup jobs will run in parallel. Defaults to 'no'. -# -#GHE_PARALLEL_ENABLED=yes - -# Sets the maximum number of jobs to run in parallel. Defaults to the number -# of available processing units on the machine. -# -#GHE_PARALLEL_MAX_JOBS=2 - -# Sets the maximum number of rsync jobs to run in parallel. Defaults to the -# configured GHE_PARALLEL_MAX_JOBS, or the number of available processing -# units on the machine. -# -# GHE_PARALLEL_RSYNC_MAX_JOBS=3 - -# When jobs are running in parallel wait as needed to avoid starting new jobs -# when the system's load average is not below the specified percentage. Defaults to -# unrestricted. -# -#GHE_PARALLEL_MAX_LOAD=50 - -# When running an external mysql database, run this script to trigger a MySQL backup -# rather than attempting to backup via backup-utils directly. -#EXTERNAL_DATABASE_BACKUP_SCRIPT="/bin/false" - -# When running an external mysql database, run this script to trigger a MySQL restore -# rather than attempting to backup via backup-utils directly. -#EXTERNAL_DATABASE_RESTORE_SCRIPT="/bin/false" - -# If set to 'yes', Pages data will be included in backup and restore. Defaults to 'yes' -#GHE_BACKUP_PAGES=no diff --git a/bin/ghe-backup b/bin/ghe-backup deleted file mode 100755 index 448a5840e..000000000 --- a/bin/ghe-backup +++ /dev/null @@ -1,406 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup [-hv] [--version] -#/ -#/ Take snapshots of all GitHub Enterprise data, including Git repository data, -#/ the MySQL database, instance settings, GitHub Pages data, etc. -#/ -#/ OPTIONS: -#/ -v | --verbose Enable verbose output. -#/ -h | --help Show this message. -#/ --version Display version information. -#/ -i | --incremental Incremental backup -#/ --skip-checks Skip storage/sw version checks -#/ - -set -e - -# Parse arguments -while true; do - case "$1" in - -h|--help) - export GHE_SHOW_HELP=true - shift - ;; - --version) - export GHE_SHOW_VERSION=true - shift - ;; - -v|--verbose) - export GHE_VERBOSE=true - shift - ;; - -i|--incremental) - export GHE_INCREMENTAL=true - shift - ;; - --skip-checks) - export GHE_SKIP_CHECKS=true - shift - ;; - -*) - echo "Error: invalid argument: '$1'" 1>&2 - exit 1 - ;; - *) - break - ;; - esac -done - - -export CALLING_SCRIPT="ghe-backup" - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" - - -# Check to make sure moreutils parallel is installed and working properly -ghe_parallel_check - - -# Used to record failed backup steps -failures= -failures_file="$(mktemp -t backup-utils-backup-failures-XXXXXX)" - -# CPU and IO throttling to keep backups from thrashing around. -export GHE_NICE=${GHE_NICE:-"nice -n 19"} -export GHE_IONICE=${GHE_IONICE:-"ionice -c 3"} - -# Create the timestamped snapshot directory where files for this run will live, -# change into it, and mark the snapshot as incomplete by touching the -# 'incomplete' file. If the backup succeeds, this file will be removed -# signifying that the snapshot is complete. -mkdir -p "$GHE_SNAPSHOT_DIR" -cd "$GHE_SNAPSHOT_DIR" -touch "incomplete" - -# Exit early if the snapshot filesystem doesn't support hard links, symlinks and -# if rsync doesn't support hardlinking of dangling symlinks -trap 'rm -rf src dest1 dest2' EXIT -mkdir -p src -touch src/testfile -if ! ln -s /data/does/not/exist/hooks/ src/ >/dev/null 2>&1; then - log_error "Error: the filesystem containing $GHE_DATA_DIR does not support symbolic links. \nGit repositories contain symbolic links that need to be preserved during a backup." 1>&2 - exit 1 -fi - -if ! output=$(rsync -a src/ dest1 2>&1 && rsync -av src/ --link-dest=../dest1 dest2 2>&1); then - log_error "Error: rsync encountered an error that could indicate a problem with permissions,\n hard links, symbolic links, or another issue that may affect backups." 1>&2 - echo "$output" - exit 1 -fi - -if [ "$(stat -c %i dest1/testfile)" != "$(stat -c %i dest2/testfile)" ]; then - log_error "Error: the filesystem containing $GHE_DATA_DIR does not support hard links.\n Backup Utilities use hard links to store backup data efficiently." 1>&2 - exit 1 -fi -rm -rf src dest1 dest2 - -# To prevent multiple backup runs happening at the same time, we create a -# in-progress file with the timestamp and pid of the backup process, -# giving us a form of locking. -# -# Set up a trap to remove the in-progress file if we exit for any reason but -# verify that we are the same process before doing so. -# -# The cleanup trap also handles disabling maintenance mode on the appliance if -# it was automatically enabled. -cleanup () { - if [ -f ../in-progress ]; then - progress=$(cat ../in-progress) - snapshot=$(echo "$progress" | cut -d ' ' -f 1) - pid=$(echo "$progress" | cut -d ' ' -f 2) - if [ "$snapshot" = "$GHE_SNAPSHOT_TIMESTAMP" ] && [ "$$" = "$pid" ]; then - unlink ../in-progress - fi - fi - - rm -rf "$failures_file" - rm -f "${GHE_DATA_DIR}/in-progress-backup" - rm -rf /tmp/backup-utils-progress/* - - # Cleanup SSH multiplexing - ghe-ssh --clean - - bm_end "$(basename $0)" -} - -# Setup exit traps -trap 'cleanup' EXIT -trap 'exit $?' INT # ^C always terminate - - -# Check to see if there is a running restore -ghe_restore_check - -# Check to see if there is a running backup -if [ -h ../in-progress ]; then - - log_error "Detected a backup already in progress from a previous version of ghe-backup. \nIf there is no backup in progress anymore, please remove \nthe $GHE_DATA_DIR/in-progress file." >&2 - exit 1 -fi - -if [ -f ../in-progress ]; then - progress=$(cat ../in-progress) - snapshot=$(echo "$progress" | cut -d ' ' -f 1) - pid=$(echo "$progress" | cut -d ' ' -f 2) - if ! ps -p "$pid" >/dev/null 2>&1; then - # We can safely remove in-progress, ghe-prune-snapshots - # will clean up the failed backup. - unlink ../in-progress - else - log_error "Error: A backup of $GHE_HOSTNAME may still be running on PID $pid. \nIf PID $pid is not a process related to the backup utilities, please remove \nthe $GHE_DATA_DIR/in-progress file and try again." 1>&2 - exit 1 - fi -fi - -# Perform a host connection check and establish the remote appliance version. -# The version is available in the GHE_REMOTE_VERSION variable and also written -# to a version file in the snapshot directory itself. -# ghe_remote_version_required should be run before any other instances of ghe-ssh -# to ensure that there are no problems with host key verification. -ghe_remote_version_required -echo "$GHE_REMOTE_VERSION" > version - -# Setup progress tracking -init-progress -export PROGRESS_TOTAL=14 # Minimum number of steps in backup is 14 -echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total -export PROGRESS_TYPE="Backup" -echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type -export PROGRESS=0 # Used to track progress of backup -echo "$PROGRESS" > /tmp/backup-utils-progress/progress - -OPTIONAL_STEPS=0 -# Backup actions+mssql -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2)) -fi - -# Backup fsck -if [ "$GHE_BACKUP_FSCK" = "yes" ]; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi - -# Backup minio -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi - -# Backup pages -if [ "$GHE_BACKUP_PAGES" != "no" ]; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi - -PROGRESS_TOTAL=$((OPTIONAL_STEPS + PROGRESS_TOTAL)) # Minimum number of steps in backup is 14 -echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total - -# check that incremental settings are valid if set -is_inc=$(is_incremental_backup_feature_on) - -if [ "$is_inc" = true ]; then -if [ "$GHE_VERSION_MAJOR" -lt 3 ]; then - log_error "Can only perform incremental backups on enterprise version 3.10 or higher" - exit 1 -fi -if [ "$GHE_VERSION_MINOR" -lt 10 ]; then - log_error "Can only perform incremental backups on enterprise version 3.10 or higher" - exit 1 -fi - - incremental_backup_check - # If everything is ok, check if we have hit GHE_MAX_INCREMENTAL_BACKUPS, performing pruning actions if necessary - check_for_incremental_max_backups - # initialize incremental backup if it hasn't been done yet - incremental_backup_init -fi - -echo "$GHE_SNAPSHOT_TIMESTAMP $$" > ../in-progress -echo "$GHE_SNAPSHOT_TIMESTAMP $$" > "${GHE_DATA_DIR}/in-progress-backup" - -bm_start "$(basename $0)" -START_TIME=$(date +%s) -log_info "Starting backup of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP" - - - -if [ -n "$GHE_ALLOW_REPLICA_BACKUP" ]; then - echo "Warning: backing up a high availability replica may result in inconsistent or unreliable backups." -fi - -# Output system information of the backup host - -# If /etc/os-release exists, use it to get the OS version -if [ -f /etc/os-release ]; then - OS_NAME=$(grep '^NAME' /etc/os-release | cut -d'"' -f2) - VERSION_ID=$(grep '^VERSION_ID' /etc/os-release | cut -d'"' -f2) - echo "Running on: $OS_NAME $VERSION_ID" -else - echo "Running on: Unknown OS" -fi - -# If nproc command exists, use it to get the number of CPUs -if command -v nproc >/dev/null 2>&1; then - echo "CPUs: $(nproc)" -else - echo "CPUs: Unknown" -fi - -# If the free command exists, use it to get the memory details -if command -v free >/dev/null 2>&1; then - echo "Memory $(free -m | grep '^Mem:' | awk '{print "total/used/free+share/buff/cache: " $2 "/" $3 "/" $4 "+" $5 "/" $6 "/" $7}')" -else - echo "Memory: Unknown" -fi - - -# Log backup start message in /var/log/syslog on remote instance -ghe_remote_logger "Starting backup from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION in snapshot $GHE_SNAPSHOT_TIMESTAMP ..." - -export GHE_BACKUP_STRATEGY=${GHE_BACKUP_STRATEGY:-$(ghe-backup-strategy)} - -# Record the strategy with the snapshot so we will know how to restore. -echo "$GHE_BACKUP_STRATEGY" > strategy - -# Create benchmark file -bm_init > /dev/null - -ghe-backup-store-version || -log_warn "Warning: storing backup-utils version remotely failed." - -log_info "Backing up GitHub secrets ..." -ghe-backup-secrets || failures="$failures secrets" - -log_info "Backing up GitHub settings ..." -ghe-backup-settings || failures="$failures settings" - -log_info "Backing up SSH authorized keys ..." -bm_start "ghe-export-authorized-keys" -ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-authorized-keys' > authorized-keys.json || -failures="$failures authorized-keys" -bm_end "ghe-export-authorized-keys" - -log_info "Backing up SSH host keys ..." -bm_start "ghe-export-ssh-host-keys" -ghe-ssh "$GHE_HOSTNAME" -- 'ghe-export-ssh-host-keys' > ssh-host-keys.tar || -failures="$failures ssh-host-keys" -bm_end "ghe-export-ssh-host-keys" - -ghe-backup-mysql || failures="$failures mysql" - -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_info "Backing up MSSQL databases ..." - ghe-backup-mssql 1>&3 || failures="$failures mssql" - - log_info "Backing up Actions data ..." - ghe-backup-actions 1>&3 || failures="$failures actions" -fi - -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - log_info "Backing up Minio data ..." - ghe-backup-minio 1>&3 || failures="$failures minio" -fi - -cmd_title=$(log_info "Backing up Redis database ...") -commands=(" -echo \"$cmd_title\" -ghe-backup-redis > redis.rdb || printf %s \"redis \" >> \"$failures_file\"") - -cmd_title=$(log_info "Backing up audit log ...") -commands+=(" -echo \"$cmd_title\" -ghe-backup-es-audit-log || printf %s \"audit-log \" >> \"$failures_file\"") - -cmd_title=$(log_info "Backing up Git repositories ...") -commands+=(" -echo \"$cmd_title\" -ghe-backup-repositories || printf %s \"repositories \" >> \"$failures_file\"") - -# Pages backups are skipped only if GHE_BACKUP_PAGES is explicitly set to 'no' to guarantee backward compatibility. -# If a customer upgrades backup-utils but keeps the config file from a previous version, Pages backups still work as expected. - -if [ "$GHE_BACKUP_PAGES" != "no" ]; then - cmd_title=$(log_info "Backing up GitHub Pages artifacts ...") - commands+=(" - echo \"$cmd_title\" - ghe-backup-pages || printf %s \"pages \" >> \"$failures_file\"") -fi - -cmd_title=$(log_info "Backing up storage data ...") -commands+=(" -echo \"$cmd_title\" -ghe-backup-storage || printf %s \"storage \" >> \"$failures_file\"") - -cmd_title=$(log_info "Backing up custom Git hooks ...") -commands+=(" -echo \"$cmd_title\" -ghe-backup-git-hooks || printf %s \"git-hooks \" >> \"$failures_file\"") - -if [ "$GHE_BACKUP_STRATEGY" = "rsync" ]; then - increment-progress-total-count 1 - cmd_title=$(log_info "Backing up Elasticsearch indices ...") - commands+=(" - echo \"$cmd_title\" - ghe-backup-es-rsync || printf %s \"elasticsearch \" >> \"$failures_file\"") -fi - -if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - "$GHE_PARALLEL_COMMAND" "${GHE_PARALLEL_COMMAND_OPTIONS[@]}" -- "${commands[@]}" -else - for c in "${commands[@]}"; do - eval "$c" - done -fi - -if [ -s "$failures_file" ]; then - failures="$failures $(cat "$failures_file")" -fi - -# git fsck repositories after the backup -if [ "$GHE_BACKUP_FSCK" = "yes" ]; then - log_info "Running git fsck on repositories ..." - ghe-backup-fsck "$GHE_SNAPSHOT_DIR" || failures="$failures fsck" -fi - -# If everything was successful, mark the snapshot as complete, update the -# current symlink to point to the new snapshot and prune expired and failed -# snapshots. -if [ -z "$failures" ]; then - rm "incomplete" - - rm -f "../current" - ln -s "$GHE_SNAPSHOT_TIMESTAMP" "../current" - - if [[ $GHE_PRUNING_SCHEDULED != "yes" ]]; then - ghe-prune-snapshots - else - log_info "Expired and incomplete snapshots to be pruned separately" - fi -else - log_info "Skipping pruning snapshots, since some backups failed..." -fi - -END_TIME=$(date +%s) -log_info "Runtime: $((END_TIME - START_TIME)) seconds" -log_info "Completed backup of $GHE_HOSTNAME in snapshot $GHE_SNAPSHOT_TIMESTAMP at $(date +"%H:%M:%S")" - -# Exit non-zero and list the steps that failed. -if [ -z "$failures" ]; then - ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP successfully." -else - steps="${failures// /, }" - ghe_remote_logger "Completed backup from $(hostname) / snapshot $GHE_SNAPSHOT_TIMESTAMP with failures: ${steps}." - log_error "Error: Snapshot incomplete. Some steps failed: ${steps}. " - ghe_backup_finished - exit 1 -fi - -# Detect if the created backup contains any leaked ssh keys -log_info "Checking for leaked ssh keys ..." -ghe-detect-leaked-ssh-keys -s "$GHE_SNAPSHOT_DIR" || true - -log_info "Backup of $GHE_HOSTNAME finished." - -# Remove in-progress file -ghe_backup_finished diff --git a/bin/ghe-backup-progress b/bin/ghe-backup-progress deleted file mode 100755 index 7ab36e084..000000000 --- a/bin/ghe-backup-progress +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-progress [--once] -#/ Tracks the completed steps of a backup or restore operation. -#/ -#/ By default the progress is printed every continuously or until a key is pressed. -#/ Use the --once option to print the current progress once and exit. -#/ -#/ Options: -#/ --once Don't loop, just print the current progress once. -# -set -e - -while true; do - case "$1" in - -o|--once) - ONCE=1 - shift - ;; - -h|--help) - export GHE_SHOW_HELP=true - shift - ;; - -*) - echo "Unknown option: $1" >&2 - exit 1 - ;; - *) - break - ;; - esac -done - -check_for_progress_file() { - if [ ! -f /tmp/backup-utils-progress/info ]; then - echo "No progress file found. Has a backup or restore been started?" - exit 1 - fi -} - -if [ -n "$ONCE" ]; then - check_for_progress_file - cat /tmp/backup-utils-progress/info -else - check_for_progress_file - clear - cat /tmp/backup-utils-progress/info - while true; do - if read -r -t 1 -n 1; then - clear - exit ; - else - clear - cat /tmp/backup-utils-progress/info - fi - done -fi diff --git a/bin/ghe-host-check b/bin/ghe-host-check deleted file mode 100755 index 73a984c30..000000000 --- a/bin/ghe-host-check +++ /dev/null @@ -1,265 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-host-check [-h] [--version] [] -#/ -#/ Verify connectivity with the GitHub Enterprise Server host. -#/ -#/ OPTIONS: -#/ -h | --help Show this message. -#/ --version Display version information. -#/ The GitHub Enterprise Server host to check. When no -#/ is provided, the $GHE_HOSTNAME configured in -#/ backup.config is assumed. -#/ - -set -e - -while true; do - case "$1" in - -h | --help) - export GHE_SHOW_HELP=true - shift - ;; - --version) - export GHE_SHOW_VERSION=true - shift - ;; - -*) - echo "Error: invalid argument: '$1'" 1>&2 - exit 1 - ;; - *) - break - ;; - esac -done - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-backup-config" - -# Use the host provided on the command line if provided, or fallback on the -# $GHE_HOSTNAME configured in backup.config when not present. -host="${1:-$GHE_HOSTNAME}" - -# Options to pass to SSH during connection check -options=" - -o PasswordAuthentication=no - -o ConnectTimeout=5 - -o ConnectionAttempts=1 -" - -# Split host:port into parts -port=$(ssh_port_part "$host") -hostname=$(ssh_host_part "$host") - -set +e -# ghe-negotiate-version verifies if the target is a GitHub Enterprise Server instance -output=$(echo "ghe-negotiate-version backup-utils $BACKUP_UTILS_VERSION" | ghe-ssh -o BatchMode=no $options $host -- /bin/sh 2>&1) -rc=$? -set -e - -if [ $rc -ne 0 ]; then - case $rc in - 255) - if echo "$output" | grep -i "port 22: Network is unreachable\|port 22: connection refused\|port 22: no route to host\|ssh_exchange_identification: Connection closed by remote host\|Connection timed out during banner exchange\|port 22: Connection timed out" >/dev/null; then - exec "$(basename $0)" "$hostname:122" - fi - - echo "$output" 1>&2 - echo "Error: ssh connection with '$host' failed" 1>&2 - echo "Note that your SSH key needs to be setup on $host as described in:" 1>&2 - echo "* https://docs.github.com/enterprise-server/admin/configuration/configuring-your-enterprise/accessing-the-administrative-shell-ssh" 1>&2 - ;; - 101) - echo "Error: couldn't read GitHub Enterprise Server fingerprint on '$host' or this isn't a GitHub appliance." 1>&2 - ;; - 1) - if [ "${port:-22}" -eq 22 ] && echo "$output" | grep "use port 122" >/dev/null; then - exec "$(basename $0)" "$hostname:122" - else - echo "$output" 1>&2 - fi - ;; - - esac - exit $rc -fi - -CLUSTER=false -if ghe-ssh "$host" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then - CLUSTER=true -fi - -# ensure all nodes in the cluster are online/reachable and running the same version -if "$CLUSTER"; then - online_status=$(ghe-ssh "$host" ghe-cluster-host-check) - if [ "$online_status" != "Cluster is ready to configure." ]; then - echo "Error: Not all nodes are online! Please ensure cluster is in a healthy state before using backup-utils." 1>&2 - exit 1 - fi - - node_version_list=$(ghe-ssh "$host" ghe-cluster-each -- ghe-version) - distinct_versions=$(echo "$node_version_list" | awk '{split($0, a, ":"); print a[2]}' | awk '{print $4}' | uniq | wc -l) - if [ "$distinct_versions" -ne 1 ]; then - echo "Version mismatch: $node_version_list" 1>&2 - echo "Error: Not all nodes are running the same version! Please ensure all nodes are running the same version before using backup-utils." 1>&2 - exit 1 - fi -fi - -version=$(echo "$output" | grep "GitHub Enterprise" | awk '{print $NF}') - -if [ -z "$version" ]; then - echo "Error: failed to parse version on '$host' or this isn't a GitHub appliance." 1>&2 - exit 2 -fi - -# Block restoring snapshots to older releases of GitHub Enterprise Server -if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then - snapshot_version=$(cat $GHE_RESTORE_SNAPSHOT_PATH/version) - # shellcheck disable=SC2046 # Word splitting is required to populate the variables - read -r snapshot_version_major snapshot_version_minor _ <<<$(ghe_parse_version $snapshot_version) - if [ "$(version $GHE_REMOTE_VERSION)" -lt "$(version $snapshot_version_major.$snapshot_version_minor.0)" ]; then - echo "Error: Snapshot can not be restored to an older release of GitHub Enterprise Server." >&2 - exit 1 - fi -fi - -if [ -z "$GHE_ALLOW_REPLICA_BACKUP" ]; then - if [ "$(ghe-ssh $host -- cat $GHE_REMOTE_ROOT_DIR/etc/github/repl-state 2>/dev/null || true)" = "replica" ]; then - echo "Error: high availability replica detected." 1>&2 - echo "Backup Utilities should be used to backup from the primary node in" 1>&2 - echo "high availability environments to ensure consistent and reliable backups." 1>&2 - exit 1 - fi -fi - -# backup-utils 2.13 onwards limits support to the current and previous two releases -# of GitHub Enterprise Server. -supported_minimum_version="3.9.0" - -if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then - supported=1 -fi - -if [ -z "$supported" ]; then - echo "Error: unsupported release of GitHub Enterprise Server detected." 1>&2 - echo "Backup Utilities v$BACKUP_UTILS_VERSION requires GitHub Enterprise Server v$supported_minimum_version or newer." 1>&2 - echo "Please update your GitHub Enterprise Server appliance or use an older version of Backup Utilities." 1>&2 - exit 1 -fi - -if [[ "$CALLING_SCRIPT" == "ghe-backup" && "$GHE_SKIP_CHECKS" != "true" ]]; then - cat << SKIP_MSG -**You can disable the following storage & version checks by running ghe-backup with option "--skip-checks" -OR updating GHE_SKIP_CHECKS to 'true' in your backup.config file. - -SKIP_MSG - - # Bring in the requirements file - min_rsync="" - min_openssh="" - min_jq="" - # shellcheck source=share/github-backup-utils/requirements.txt - . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/requirements.txt" - - #source disk size file - # shellcheck source=share/github-backup-utils/ghe-rsync-size - . "$(dirname "${BASH_SOURCE[0]}")/../share/github-backup-utils/ghe-rsync-size" - - #Check if GHE_DATA_DIR is NFS mounted - fs_info=$(stat -f -c "%T" "$GHE_DATA_DIR") || true - if [ "$fs_info" == "nfs" ]; then - echo "Warning: NFS (Network File System) detected for $GHE_DATA_DIR" 1>&2 - echo "Please review https://gh.io/backup-utils-storage-requirements for details." 1>&2 - fi - - #Display dir requirements for repositories and mysql - echo -e "\nChecking host for sufficient space for a backup..." - available_space=$(df -B 1k $GHE_DATA_DIR | awk 'END{printf "%.0f", $4 * 1024}') - echo " We recommend allocating at least 5x the amount of storage allocated to the primary GitHub appliance for historical snapshots and growth over time." - - repos_disk_size=$(transfer_size repositories /tmp) - pages_disk_size=$(transfer_size pages /tmp) - es_disk_size=$(transfer_size elasticsearch /tmp) - stor_disk_size=$(transfer_size storage /tmp) - minio_disk_size=$(transfer_size minio /tmp) - mysql_disk_size=$(transfer_size mysql /tmp) - actions_disk_size=$(transfer_size actions /tmp) - mssql_disk_size=$(transfer_size mssql /tmp) - - min_disk_req=$((repos_disk_size + pages_disk_size + es_disk_size + stor_disk_size + minio_disk_size + mysql_disk_size + actions_disk_size + mssql_disk_size)) - recommended_disk_req=$((min_disk_req * 5)) - echo " - Available space: $((available_space / (1024 ** 2))) MB" - echo " - Min Disk required for this backup is at least $min_disk_req MB" - echo -e " - Recommended Disk requirement is $recommended_disk_req MB\n" - - printf '### Estimated Data Transfer Sizes - - - repositories: %d MB - - pages: %d MB - - elasticsearch: %d MB - - storage: %d MB - - minio: %d MB - - mysql: %d MB - - actions: %d MB - - mssql: %d MB -\n' \ - "$repos_disk_size" "$pages_disk_size" "$es_disk_size" "$stor_disk_size" "$minio_disk_size" "$mysql_disk_size" "$actions_disk_size" "$mssql_disk_size" - - if [[ $((available_space / (1024 * 1024))) -lt $min_disk_req ]]; then - echo "There is not enough disk space for the backup. Please allocate more space and continue." 1>&2 - exit 1 - fi - - #Check rsync, openssh & jq versions - commands=("jq" "rsync" "ssh") - missing_command="" - for cmd in "${commands[@]}"; do - if ! command -v "$cmd" > /dev/null 2>&1; then - missing_command+="$cmd " - fi - done - - # Check if any command is missing - if [[ -n "$missing_command" ]]; then - echo "One or more required tools not found: $missing_command" 1>&2 - echo "Please make sure the following utils are installed and available in your PATH: $missing_command" 1>&2 - exit 1 - fi - - echo "### Software versions" - rsync_version=$(rsync --version | grep 'version' | awk '{print $3}' | tr -cd '[:digit:].\n') - if awk "BEGIN {exit !($rsync_version < $min_rsync)}" &> /dev/null; then - echo "rsync version $rsync_version in backup-host does not meet minimum requirements." 1>&2 - echo "Please make sure you have the minimum required version of rsync: $min_rsync installed" 1>&2 - exit 1 - elif [[ $rsync_version < 3.2.5 ]] && [[ $RSYNC_WARNING != "no" ]]; then - printf "\n **WARNING:** rsync version %s on backup host is less than 3.2.5, which could result in performance degradation. - For more details, please read documentation at https://gh.io/april-2023-update-of-rsync-requirements - You can disable this warning by changing RSYNC_WARNING to 'no' in your backup.config file.\n\n" \ - "$rsync_version" - fi - echo " - rsync ${rsync_version} >= required ($min_rsync)" - - ssh_version=$(ssh -V 2>&1 | awk '{print $1}'|grep -oPm 1 '[\d\.]+' |head -1 | tr -cd '[:digit:].\n') - if awk "BEGIN {exit !($ssh_version < $min_openssh)}" &> /dev/null; then - echo "openSSH version $ssh_version in backup-host does not meet minimum requirements." 1>&2 - echo "Please make sure the minimum required version of openSSH: $min_openssh is installed" 1>&2 - exit 1 - else - echo " - openSSH ${ssh_version} >= required ($min_openssh)" - fi - - jq_version=$(jq --version |awk -F\- '{print $2}' | tr -cd '[:digit:].\n') - if awk "BEGIN {exit !($jq_version < $min_jq)}" &> /dev/null; then - echo "jq version $jq_version in backup-host does not meet minimum requirements." 1>&2 - echo "Please make sure you have the minimum required version of jq: $min_jq installed" 1>&2 - exit 1 - else - echo " - jq ${jq_version} >= required ($min_jq)" - fi -fi - -echo -e "\nConnect $hostname:$port OK (v$version)" diff --git a/bin/ghe-restore b/bin/ghe-restore deleted file mode 100755 index 101f19ebc..000000000 --- a/bin/ghe-restore +++ /dev/null @@ -1,727 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-restore [-cfhv] [--version] [--skip-mysql] [-s ] [] -#/ -#/ Restores a GitHub instance from local backup snapshots. -#/ -#/ Note that the GitHub Enterprise host must be reachable and your SSH key must -#/ be setup as described in the following help article: -#/ -#/ -#/ -#/ OPTIONS: -#/ -c | --config Restore appliance settings and license in addition to -#/ datastores. Settings are not restored by default to -#/ prevent overwriting different configuration on the -#/ restore host. -#/ -f | --force Don't prompt for confirmation before restoring. -#/ -h | --help Show this message. -#/ -v | --verbose Enable verbose output. -#/ --skip-mysql Skip MySQL restore steps. Only applicable to external databases. -#/ --version Display version information and exit. -#/ -#/ -s Restore from the snapshot with the given id. Available -#/ snapshots may be listed under the data directory. -#/ -#/ The is the hostname or IP of the GitHub Enterprise -#/ instance. The may be omitted when the -#/ GHE_RESTORE_HOST config variable is set in backup.config. -#/ When a argument is provided, it always overrides -#/ the configured restore host. -#/ - -set -e - -# Parse arguments -: "${RESTORE_SETTINGS:=false}" -export RESTORE_SETTINGS - -: "${FORCE:=false}" -export FORCE - -: "${SKIP_MYSQL:=false}" -export SKIP_MYSQL - -while true; do - case "$1" in - --skip-mysql) - SKIP_MYSQL=true - shift - ;; - -f|--force) - FORCE=true - shift - ;; - -s) - snapshot_id="$(basename "$2")" - shift 2 - ;; - -c|--config) - RESTORE_SETTINGS=true - shift - ;; - -h|--help) - export GHE_SHOW_HELP=true - shift - ;; - --version) - export GHE_SHOW_VERSION=true - shift - ;; - -v|--verbose) - export GHE_VERBOSE=true - shift - ;; - -i|--incremental) - export GHE_INCREMENTAL=true - shift - ;; - -*) - echo "Error: invalid argument: '$1'" 1>&2 - exit 1 - ;; - *) - if [ -n "$1" ]; then - GHE_RESTORE_HOST_OPT="$1" - shift - else - break - fi - ;; - esac -done - - - -start_cron () { - log_info "Starting cron ..." - if $CLUSTER; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo timeout 120s service cron start"; then - log_warn "Failed to start cron on one or more nodes" - fi - else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo timeout 120s service cron start"; then - log_warn "Failed to start cron" - fi - fi -} - -cleanup () { - log_info " Exiting, cleaning up ..." - if [ -n "$1" ]; then - update_restore_status "$1" - fi - - if $ACTIONS_STOPPED && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_info "Restarting Actions after restore ..." - # In GHES 3.3+, ghe-actions-start no longer has a -f (force) flag. In GHES 3.2 and below, we must provide the - # force flag to make sure it can start in maintenance mode. Use it conditionally based on whether it exists - # in the --help output - if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start --help' | grep -q force; then - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start -f' 1>&3 - else - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-start' 1>&3 - fi - fi - - if ! $CRON_RUNNING; then - start_cron - fi - - # Cleanup SSH multiplexing - log_info "Cleaning up SSH multiplexing ..." - if ! ghe-ssh --clean; then - log_info "Failed to clean up SSH multiplexing" - fi - - # Remove in-progress file - log_info "Removing in-progress file ..." 1>&3 - if ! rm -f "${GHE_DATA_DIR}/in-progress-restore"; then - log_error "Failed to remove in-progress file" 1>&3 - fi - - # Remove progress files - rm -rf /tmp/backup-utils-progress/* - - bm_end "$(basename $0)" -} - -# This function's type definition is being passed to a remote host via `ghe-ssh` but is not used locally. -# because it doesn't run locally does not redirect output to fd 3 or use log_info/log_warn/log_error. -# shellcheck disable=SC2034 -cleanup_cluster_nodes() { - uuid="$1" - if [ -z "$uuid" ]; then - log_error "Node UUID required." - exit 2 - fi - - echo "Cleaning up spokes" - ghe-spokes server evacuate "git-server-$uuid" 'Removing replica' - ghe-spokes server destroy "git-server-$uuid" - - echo "Cleaning up storage" - ghe-storage destroy-host "storage-server-$uuid" --force - - echo "Cleaning up dpages" - ghe-dpages offline "pages-server-$uuid" - ghe-dpages remove "pages-server-$uuid" - - echo "Cleaning up redis" - ghe-redis-cli del "resque:queue:maint_git-server-$uuid" - ghe-redis-cli srem resque:queues "maint_git-server-$uuid" -} - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config" - - - - - -# Check to make sure moreutils parallel is installed and working properly -ghe_parallel_check - -# Check to make sure another restore process is not running -ghe_restore_check - -# Grab the host arg -GHE_HOSTNAME="${GHE_RESTORE_HOST_OPT:-$GHE_RESTORE_HOST}" - -# Hostname without any port suffix -hostname=$(echo "$GHE_HOSTNAME" | cut -f 1 -d :) - -# Show usage with no -[ -z "$GHE_HOSTNAME" ] && print_usage - -# Flag to indicate if this script has stopped Actions. -ACTIONS_STOPPED=false - -# ghe-restore-snapshot-path validates it exists, determines what current is, -# and if there's any problem, exit for us -GHE_RESTORE_SNAPSHOT_PATH="$(ghe-restore-snapshot-path "$snapshot_id")" -GHE_RESTORE_SNAPSHOT=$(basename "$GHE_RESTORE_SNAPSHOT_PATH") -export GHE_RESTORE_SNAPSHOT - -# Check to make sure backup is not running -ghe_backup_check - -# Detect if the backup we are restoring has a leaked ssh key -echo "Checking for leaked keys in the backup snapshot that is being restored ..." -ghe-detect-leaked-ssh-keys -s "$GHE_RESTORE_SNAPSHOT_PATH" || true - -# Figure out whether to use the tarball or rsync restore strategy based on the -# strategy file written in the snapshot directory. -GHE_BACKUP_STRATEGY=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/strategy") - -# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. -ghe_remote_version_required "$GHE_HOSTNAME" - -# Figure out if this instance has been configured or is entirely new. -instance_configured=false -if is_instance_configured; then - instance_configured=true -else - RESTORE_SETTINGS=true -fi - -# Figure out if we're restoring into cluster -CLUSTER=false -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ]"; then - CLUSTER=true -fi -export CLUSTER - -# Restoring a cluster backup to a standalone appliance is not supported -if ! $CLUSTER && [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - log_error "Error: Snapshot from a GitHub Enterprise cluster cannot be restored to a standalone appliance. Aborting." >&2 - exit 1 -fi - -# Ensure target appliance and restore snapshot are a compatible combination with respect to BYODB -if ! ghe-restore-external-database-compatibility-check; then - exit 1 -fi - -# Figure out if this appliance is in a replication pair -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - log_error "Error: Restoring to an appliance with replication enabled is not supported. Please teardown replication before restoring." >&2 - exit 1 -fi - -# Prompt to verify the restore host given is correct. Restoring overwrites -# important data on the destination appliance that cannot be recovered. This is -# mostly to prevent accidents where the backup host is given to restore instead -# of a separate restore host since they're used in such close proximity. -if $instance_configured && ! $FORCE; then - echo - echo "WARNING: All data on GitHub Enterprise appliance $hostname ($GHE_REMOTE_VERSION)" - echo " will be overwritten with data from snapshot ${GHE_RESTORE_SNAPSHOT}." - echo - - if is_external_database_snapshot && $RESTORE_SETTINGS; then - echo "WARNING: This operation will also restore the external MySQL connection configuration," - echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." - echo - fi - - prompt_for_confirmation "Please verify that this is the correct restore host before continuing." -fi - -# Prompt to verify that restoring BYODB snapshot to unconfigured instance -# will result in BYODB connection information being restored as well. -if is_external_database_snapshot && ! $instance_configured && ! $FORCE; then - echo - echo "WARNING: This operation will also restore the external MySQL connection configuration," - echo " which may be dangerous if the GHES appliance the snapshot was taken from is still online." - echo - - prompt_for_confirmation "Please confirm this before continuing." -fi -# Calculate the actual amounts of steps in the restore process -# taking into account the options passed to the script and the appliance configuration -# calculate restore steps -OPTIONAL_STEPS=0 - -# Restoring UUID -if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi -# Restoring Actions + MSSQL -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 2)) -fi -# Restoring minio -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi -# Restoring Elasticsearch -if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi -# Restoring audit log -if $CLUSTER || [ "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.12.9)" ]; then - if [[ "$GHE_RESTORE_SKIP_AUDIT_LOG" != "yes" ]]; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) - fi -fi -# Replica cleanup -if ! $CLUSTER && $instance_configured; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 1)) -fi -# Restoring settings + restore-chat-integration + restore-packages -if $RESTORE_SETTINGS; then - OPTIONAL_STEPS=$((OPTIONAL_STEPS + 3)) -fi - -# Minimum number of steps is 7 -export PROGRESS_TOTAL=$((OPTIONAL_STEPS + 7)) - -init-progress -echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total -export PROGRESS_TYPE="Restore" -echo "$PROGRESS_TYPE" > /tmp/backup-utils-progress/type -export PROGRESS=0 # Used to track progress of restore -echo "$PROGRESS" > /tmp/backup-utils-progress/progress - -# Log restore start message locally and in /var/log/syslog on remote instance -bm_start "$(basename $0)" -START_TIME=$(date +%s) -log_info "Starting restore of $GHE_HOSTNAME with backup-utils v$BACKUP_UTILS_VERSION from snapshot $GHE_RESTORE_SNAPSHOT" - -if [ "$GHE_INCREMENTAL" ]; then - if [ "$GHE_VERSION_MAJOR" -lt 3 ]; then - log_error "Can only perform incremental restores on enterprise version 3.10 or higher" - exit 1 -fi -if [ "$GHE_VERSION_MINOR" -lt 10 ]; then - log_error "Can only perform incremental restores on enterprise version 3.10 or higher" - exit 1 -fi - log_info "Incremental restore from snapshot $GHE_RESTORE_SNAPSHOT" - # If we see 'inc_previous' prepended to the snapshot name, then - # we set $INC_FULL_BACKUP and $INC_SNAPSHOT_DATA to $INC_PREVIOUS_FULL_BACKUP and - # $INC_PREVIOUS_SNAPSHOT_DATA respectively. Otherwise, leave them at default setting - # so that incremental restore is from current cycle - if [[ "$GHE_RESTORE_SNAPSHOT" =~ ^inc_previous ]]; then - INC_FULL_BACKUP=$INC_PREVIOUS_FULL_BACKUP - INC_SNAPSHOT_DATA=$INC_PREVIOUS_SNAPSHOT_DATA - log_info "Incremental restore from previous cycle snapshot. Using $INC_FULL_BACKUP" - log_info "Incremental restore from previous cycle snapshot. Using $INC_SNAPSHOT_DATA" - fi - log_info "Validating snapshot $GHE_RESTORE_SNAPSHOT" - validate_inc_snapshot_data "$GHE_RESTORE_SNAPSHOT" -fi -ghe_remote_logger "Starting restore from $(hostname) with backup-utils v$BACKUP_UTILS_VERSION / snapshot $GHE_RESTORE_SNAPSHOT ..." -# Create an in-progress-restore file to prevent simultaneous backup or restore runs -echo "${START_TIME} $$" > "${GHE_DATA_DIR}/in-progress-restore" - -# Keep other processes on the VM or cluster in the loop about the restore status. -# -# Other processes will look for these states: -# "restoring" - restore is currently in progress -# "failed" - restore has failed -# "complete" - restore has completed successfully -update_restore_status () { - if $CLUSTER; then - echo "ghe-cluster-each -- \"echo '$1' | sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null\"" | - ghe-ssh "$GHE_HOSTNAME" /bin/bash - else - echo "$1" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/ghe-restore-status' >/dev/null" - fi -} - -CRON_RUNNING=true -# Update remote restore state file and setup failure trap -trap "cleanup failed" EXIT -update_restore_status "restoring" - -# Make sure the GitHub appliance is in maintenance mode. -if $instance_configured; then - if ! ghe-maintenance-mode-status "$GHE_HOSTNAME"; then - log_error "Error: $GHE_HOSTNAME must be put in maintenance mode before restoring. Aborting." 1>&2 - exit 1 - fi -fi - -# Get GHES release version in major.minor format -RELEASE_VERSION=$(ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --get core.package-version' | cut -d '.' -f 1,2) - -# If the backup being restored is from an appliance with Actions disabled, restoring it onto an appliance with Actions enabled will cause -# mismatches in the secrets needed for Actions which ultimately results in Actions not working properly. Note: xargs is to remove whitespace -ACTIONS_ENABLED_IN_BACKUP=$(git config -f "$GHE_RESTORE_SNAPSHOT_PATH/settings.json" --bool app.actions.enabled | xargs) -if [[ $ACTIONS_ENABLED_IN_BACKUP != true ]] && ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_error "Restoring a backup with Actions disabled onto an appliance with Actions enabled is not supported." >&2 - exit 1 -fi - -# Make sure the GitHub appliance has Actions enabled if the snapshot contains Actions data. -# If above is true, also check if ac is present in appliance then snapshot should also contains ac databases -if [ -d "$GHE_RESTORE_SNAPSHOT_PATH/mssql" ] || [ -d "$GHE_RESTORE_SNAPSHOT_PATH/actions" ]; then - if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - ac_db_ghe=$(echo 'ghe-mssql-console -y -n -q "SELECT name FROM sys.databases" | grep -i "ArtifactCache" | wc -l | tr -d " "' | ghe-ssh "$GHE_HOSTNAME" /bin/bash) - ac_db_snapshot=$(find "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/mssql/" -maxdepth 1 -name 'ArtifactCache*.bak' | wc -l | tr -d " ") - if [[ $ac_db_ghe -gt 0 && $ac_db_snapshot -eq 0 ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service enabled but no Actions Cache data is present in snapshot to restore. Aborting \n Please disable Actions cache service in $GHE_HOSTNAME and retry\nTo disable Actions Cache service run as admin: ghe-actions-cache-disable" 1>&2 - exit 1 - fi - if [[ $ac_db_ghe -eq 0 && $ac_db_snapshot -gt 0 && ! $RESTORE_SETTINGS ]]; then - log_error "$GHE_HOSTNAME has Actions Cache service disabled but the snapshot is attempting to restore data for the service. Aborting. \n Please enable Actions cache service in $GHE_HOSTNAME and retry \n To enable Actions Cache service run as admin: ghe-actions-cache-enable" 1>&2 - exit 1 - fi - else - log_error "$GHE_HOSTNAME must have GitHub Actions enabled before restoring since the snapshot contains Actions data. Aborting. \n Setup details for enabling Actions can be found here: https://docs.github.com/en/enterprise-server@$RELEASE_VERSION/admin/github-actions/advanced-configuration-and-troubleshooting/backing-up-and-restoring-github-enterprise-server-with-github-actions-enabled" 1>&2 - exit 1 - fi -fi - -# Create benchmark file -bm_init > /dev/null - -ghe-backup-store-version || -log_warn "Warning: storing backup-utils version remotely failed." - -# Stop cron and timerd, as scheduled jobs may disrupt the restore process. -log_info "Stopping cron and github-timerd ..." -if $CLUSTER; then - bm_start "$(basename $0) - Stopping cron and github-timerd on cluster" - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service cron stop"; then - log_warn "Failed to stop cron on one or more nodes" 1>&3 - fi - bm_end "$(basename $0) - Stopping cron and github-timerd on cluster" - if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then - log_warn "Failed to stop github-timerd on one or more nodes" 1>&3 - fi - fi - else - if ! ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- sudo service github-timerd stop"; then - log_warn "Failed to stop github-timerd on one or more nodes" 1>&3 - fi - fi - -else - bm_start "$(basename $0) - Stopping cron and github-timerd" - echo "$(basename $0) - Stopping cron and github-timerd" - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service cron stop"; then - log_warn "Failed to stop cron" 1>&3 - fi - bm_end "$(basename $0) - Stopping cron and github-timerd" - if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - if ghe-ssh "$GHE_HOSTNAME" -- "systemctl -q is-active nomad && nomad job status --short github-timerd &>/dev/null"; then - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo nomad stop github-timerd 1>/dev/null"; then - log_warn "Failed to stop github-timerd" 1>&3 - fi - fi - else - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo service github-timerd stop"; then - log_warn "Failed to stop github-timerd" 1>&3 - fi - fi - -fi -CRON_RUNNING=false - -ghe-restore-secrets "$GHE_HOSTNAME" - -# Restore settings and license if restoring to an unconfigured appliance or when -# specified manually. -if $RESTORE_SETTINGS; then - ghe-restore-settings "$GHE_HOSTNAME" -fi - -# Make sure mysql and elasticsearch are prep'd and running before restoring. -# These services will not have been started on appliances that have not been -# configured yet. -if ! $CLUSTER; then - echo "sudo ghe-service-ensure-mysql && sudo ghe-service-ensure-elasticsearch" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 -fi - -# Restore UUID if present and not restoring to cluster. -if [ -s "$GHE_RESTORE_SNAPSHOT_PATH/uuid" ] && ! $CLUSTER; then - log_info "Restoring UUID ..." - - bm_start "$(basename $0) - Restore UUID" - ghe-ssh "$GHE_HOSTNAME" -- "sudo sponge '$GHE_REMOTE_DATA_USER_DIR/common/uuid' 2>/dev/null" <"$GHE_RESTORE_SNAPSHOT_PATH/uuid" - ghe-ssh "$GHE_HOSTNAME" -- "sudo systemctl stop consul" || true - ghe-ssh "$GHE_HOSTNAME" -- "sudo rm -rf /data/user/consul/raft" - bm_end "$(basename $0) - Restore UUID" -fi - - -if is_external_database_snapshot; then - appliance_strategy="external" - backup_snapshot_strategy="external" -else - if is_binary_backup_feature_on; then - appliance_strategy="binary" - else - appliance_strategy="logical" - fi - - if is_binary_backup "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT"; then - backup_snapshot_strategy="binary" - else - backup_snapshot_strategy="logical" - fi -fi - -if is_external_database_target_or_snapshot && $SKIP_MYSQL; then - log_info "Skipping MySQL restore." -else - log_info "Restoring MySQL database from ${backup_snapshot_strategy} backup snapshot on an appliance configured for ${appliance_strategy} backups ..." - increment-progress-total-count 2 - ghe-restore-mysql "$GHE_HOSTNAME" 1>&3 -fi - - - -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.actions.enabled'; then - log_info "Stopping Actions before restoring databases ..." - # We mark Actions as stopped even if the `ghe-actions-stop` - # fails to ensure that we cleanly start actions when performing cleanup. - ACTIONS_STOPPED=true - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-actions-stop' 1>&3 - - log_info "Restoring MSSQL databases ..." - ghe-restore-mssql "$GHE_HOSTNAME" 1>&3 - - log_info "Restoring Actions data ..." - ghe-restore-actions "$GHE_HOSTNAME" 1>&3 - echo "* WARNING: Every self-hosted Actions runner that communicates with the restored GHES server must be restarted or reconfigured in order to continue functioning." - echo "See https://docs.github.com/en/actions/hosting-your-own-runners/adding-self-hosted-runners for more details on how to reconfigure self-hosted Actions runners." -fi - -if ghe-ssh "$GHE_HOSTNAME" -- 'ghe-config --true app.minio.enabled'; then - log_info "Restoring MinIO data ..." - ghe-restore-minio "$GHE_HOSTNAME" 1>&3 -fi - -# log input into a variable for the parallel command, as the functions don't work with eval -cmd_title=$(log_info "Restoring Redis database ...") -commands=(" -echo \"$cmd_title\" -ghe-restore-redis \"$GHE_HOSTNAME\" \"$GHE_RESTORE_SNAPSHOT_PATH\"") - -cmd_title=$(log_info "Restoring Git Repositories ...") -commands+=(" -echo \"$cmd_title\" -ghe-restore-repositories \"$GHE_HOSTNAME\"") - -cmd_title=$(log_info "Restoring Gists ...") -commands+=(" -echo \"$cmd_title\" -ghe-restore-repositories-gist \"$GHE_HOSTNAME\"") - -if [ "$GHE_BACKUP_PAGES" != "no" ]; then - cmd_title=$(log_info "Restoring Pages ...") - commands+=(" - echo \"$cmd_title\" - ghe-restore-pages \"$GHE_HOSTNAME\" 1>&3") -fi - -cmd_title=$(log_info "Restoring SSH authorized keys ...") -commands+=(" -echo \"$cmd_title\" -ghe-restore-ssh-keys \"$GHE_HOSTNAME\" \"$GHE_RESTORE_SNAPSHOT_PATH\"") - -cmd_title=$(log_info "Restoring storage data ...") -commands+=(" -echo \"$cmd_title\" -ghe-restore-storage \"$GHE_HOSTNAME\" 1>&3") - -cmd_title=$(log_info "Restoring custom Git hooks ...") -commands+=(" -echo \"$cmd_title\" -ghe-restore-git-hooks \"$GHE_HOSTNAME\" 1>&3") - -if ! $CLUSTER && [ -d "$GHE_RESTORE_SNAPSHOT_PATH/elasticsearch" ]; then - cmd_title=$(log_info "Restoring Elasticsearch indices ...") - commands+=(" - echo \"$cmd_title\" - ghe-restore-es-rsync \"$GHE_HOSTNAME\" 1>&3") -fi - -# Restore the audit log migration sentinel file, if it exists in the snapshot -if test -f "$GHE_RESTORE_SNAPSHOT_PATH/es-scan-complete"; then - log_info "Restoring Elasticsearch audit log migration sentinel file ..." 1>&3 - if ! ghe-ssh "$GHE_HOSTNAME" -- "sudo touch $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - log_info "Failed to restore Elasticsearch audit log migration sentinel file." 1>&3 - fi -fi - -# Restore exported audit logs to 2.12.9 and newer single nodes and -# all releases of cluster -if $CLUSTER || [ "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.12.9)" ]; then - if [[ "$GHE_RESTORE_SKIP_AUDIT_LOGS" = "yes" ]]; then - log_info "Skipping restore of audit logs." - else - cmd_title=$(log_info "Restoring Audit logs ...") - commands+=(" - echo \"$cmd_title\" - ghe-restore-es-audit-log \"$GHE_HOSTNAME\" 1>&3") - fi - -fi - -if [ "$GHE_PARALLEL_ENABLED" = "yes" ]; then - log_info "Restoring data in parallel ..." - "$GHE_PARALLEL_COMMAND" "${GHE_PARALLEL_COMMAND_OPTIONS[@]}" -- "${commands[@]}" -else - log_info "Restoring data serially ..." 1>&3 - for c in "${commands[@]}"; do - . "$( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/bm.sh" - eval "$c" - done -fi - -# Restart an already running memcached to reset the cache after restore -log_info "Restarting memcached ..." 1>&3 -bm_start "$(basename $0) - Restarting memcached" -echo "sudo restart -q memcached 2>/dev/null || true" | -ghe-ssh "$GHE_HOSTNAME" -- /bin/sh -bm_end "$(basename $0) - Restarting memcached" - -# Prevent GitHub Connect jobs running before we've had a chance to reset -# the configuration by setting the last run date to now. -if ! $RESTORE_SETTINGS; then - log_info "Setting last run date for GitHub Connect jobs ..." 1>&3 - echo "now=$(date +%s.0000000); ghe-redis-cli mset timer:UpdateConnectInstallationInfo \$now timer:UploadEnterpriseServerUserAccountsJob \$now timer:UploadConnectMetricsJob \$now timer:GitHubConnectPushNewContributionsJob \$now" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 -fi - -# When restoring to a host that has already been configured, kick off a -# config run to perform data migrations. -if $CLUSTER; then - log_info "Configuring cluster ..." - bm_start "$(basename $0) - configure cluster" - if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-nomad-cleanup" 1>&3 2>&3 - elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-each -- /usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 - fi - ghe-ssh "$GHE_HOSTNAME" -- "ghe-cluster-config-apply" 1>&3 2>&3 - bm_end "$(basename $0) - configure cluster" -elif $instance_configured; then - log_info "Configuring appliance ..." - bm_start "$(basename $0) - configure appliance" - if [ "$GHE_VERSION_MAJOR" -eq "3" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "ghe-nomad-cleanup" 1>&3 2>&3 - elif [ "$GHE_VERSION_MAJOR" -eq "2" ] && [ "$GHE_VERSION_MINOR" -eq "22" ]; then - ghe-ssh "$GHE_HOSTNAME" -- "/usr/local/share/enterprise/ghe-nomad-cleanup" 1>&3 2>&3 - fi - ghe-ssh "$GHE_HOSTNAME" -- "ghe-config-apply" 1>&3 2>&3 - bm_end "$(basename $0) - configure appliance" -fi - -# Clear GitHub Connect settings stored in the restored database. -# This needs to happen after `ghe-config-apply` to ensure all migrations have run. -if ! $RESTORE_SETTINGS; then - log_info "Clearing GitHub Connect settings ..." 1>&3 - echo "if [ -f /usr/local/share/enterprise/ghe-reset-gh-connect ]; then /usr/local/share/enterprise/ghe-reset-gh-connect -y; fi" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 -fi - -# Start cron. Timerd will start automatically as part of the config run. -start_cron -CRON_RUNNING=true - -# Clean up all stale replicas on configured instances. -if ! $CLUSTER && $instance_configured; then - log_info "Cleaning up replicas..." 1>&3 - bm_start "$(basename $0) - Cleanup replicas" - restored_uuid=$(cat "$GHE_RESTORE_SNAPSHOT_PATH/uuid") - other_nodes=$(echo " - set -o pipefail; \ - ghe-spokes server show --json \ - | jq -r '.[] | select(.host | contains(\"git-server\")).host' \ - | sed 's/^git-server-//g' \ - | ( grep -F -x -v \"$restored_uuid\" || true )" \ - | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash) - if [ -n "$other_nodes" ]; then - log_info "Cleaning up stale nodes ..." - for uuid in $other_nodes; do - # shellcheck disable=SC2034 - echo "set -o pipefail; $(typeset -f cleanup_cluster_nodes); cleanup_cluster_nodes $uuid" | ghe-ssh "$GHE_HOSTNAME" 1>&3 - done - fi - bm_end "$(basename $0) - Cleanup replicas" -fi - -# Update the remote status to "complete". This has to happen before importing -# ssh host keys because subsequent commands will fail due to the host key -# changing otherwise. -trap "cleanup" EXIT -update_restore_status "complete" - -# Log restore complete message in /var/log/syslog on remote instance -ghe_remote_logger "Completed restore from $(hostname) / snapshot ${GHE_RESTORE_SNAPSHOT}." - -if ! $CLUSTER; then - log_info "Restoring SSH host keys ..." - ghe-ssh "$GHE_HOSTNAME" -- 'ghe-import-ssh-host-keys' < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 -else - # This will make sure that Git over SSH host keys (babeld) are - # copied to all the cluster nodes so babeld uses the same keys. - log_info "Restoring Git over SSH host keys ..." - ghe-ssh "$GHE_HOSTNAME" -- "sudo tar -xpf - -C $GHE_REMOTE_DATA_USER_DIR/common" < "$GHE_RESTORE_SNAPSHOT_PATH/ssh-host-keys.tar" 1>&3 - ghe-ssh "$GHE_HOSTNAME" -- "sudo chown babeld:babeld $GHE_REMOTE_DATA_USER_DIR/common/ssh_host_*" 1>&3 - echo "if [ -f /usr/local/share/enterprise/ghe-cluster-config-update ]; then /usr/local/share/enterprise/ghe-cluster-config-update -s; else ghe-cluster-config-update -s; fi" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/sh 1>&3 -fi - -END_TIME=$(date +%s) -log_info "Runtime: $((END_TIME - START_TIME)) seconds" -log_info "Completed restore of $GHE_HOSTNAME from snapshot $GHE_RESTORE_SNAPSHOT at $(date +"%H:%M:%S")" - -log_info "Restore of $GHE_HOSTNAME finished." - -if ! $instance_configured; then - echo "To complete the restore process, please visit https://$hostname/setup/settings to review and save the appliance configuration." -fi - diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 011d50f79..000000000 --- a/debian/changelog +++ /dev/null @@ -1,666 +0,0 @@ -github-backup-utils (3.11.0) UNRELEASED; urgency=medium - - * `ghe-backup-myql` and `ghe-restore-mysql` will now exit 1 on errors. - * On an instance with Actions enabled, incorrect backup and restore settings prevented the storage container name from being restored. This made the logs from that container inaccessible, and caused Actions to create a new storage container in a different location. - * When backups are run for HA instances in both primary and replica nodes a `.sync-in-progress` file will be created. This will disable `NetworkMaintenance` jobs from running and queueing up when backups are running from the primary node. - * Estimated transfer sizes will be calculated on appropriate nodes for clustered environments. - * Added support for finding the `parallel` command from the `moreutils` tool suite on more Linux distributions, including Arch Linux and Alpine Linux. - * `ghe-restore` avoids unnecessary `rsync` operations when restoring to non-clustered environments. - * `ghe-backup` and `ghe-restore` output their total runtime - * `rsync` compression is now disabled by default. The `-z` flag has been removed from the `ghe-rsync` command in multiple files to improve transfer speed and reduce CPU usage. To enable `rsync` compression globally, add `GHE_RSYNC_COMPRESSION_ENABLED=yes` to the `backup.config` file. - * Updates the Host OS version output to use `/etc/os-release` for better compatibility with other Linux distributions. - * When a NFS mount is detected for snapshots on backup hosts, backup logs will show a warning to notify the user that such a setup may incur performance issues as highlighted in [storage requirements](https://github.com/github/backup-utils-private/blob/master/docs/requirements.md#storage-requirements) documentation. - - -- Andrew Mildahl Thu, 30 Nov 2023 01:57:12 +0000 - -github-backup-utils (3.10.0) UNRELEASED; urgency=medium - - * Remove -o option from ps use #341 - * Switch to TMPDIR before initiating SSH multiplexing workaround to prevent locking the destination filesystem #348 - * Move check for git for ssh muxing into ghe-ssh #378 - * Check filesystem supports hardlinks #388 - * Remove check for git from ghe-ssh #393 - * Clean up stale HA nodes on restore #396 - - -- Balwinder Sohi Wed, 09 Aug 2023 19:37:10 +0000 - -github-backup-utils (3.9.0) UNRELEASED; urgency=medium - - * Set restore status on all cluster nodes #274 - * Fix pages backups and restores in GitHub Enterprise 11.10 #275 - * Backup and restore custom CA certificates #281 - * Set the benchmark file path consistently #283 - * Suppress dd output noise #289 - * Track completeness of Elasticsearch JSON dumps #298 - * Use existing Elasticsearch indices to speed up transfer during a restore #310 - * Include the user data directory in the benchmark name #311 - * Use calculated routes when backing up storage data from a cluster #318 - * Refresh the existing indices when restoring Elasticsearch indices to cluster #328 - * Use git to generate short name for SSH multiplex control path #335 - - -- Junior Eluhu Mon, 12 Jun 2023 20:46:10 +0000 - -github-backup-utils (3.8.0) focal; urgency=medium - - -- Daniel Johnson Tue, 07 Feb 2023 21:43:26 +0000 - -github-backup-utils (3.7.0) UNRELEASED; urgency=medium - - - -- Devin Dooley Tue, 25 Oct 2022 00:35:38 +0000 - -github-backup-utils (3.6.0) UNRELEASED; urgency=medium - - - -- Joe Franks Wed, 17 Aug 2022 19:20:54 +0000 - -github-backup-utils (3.5.0) UNRELEASED; urgency=medium - - * Simplify complex redirects for ghe-rsync #881 - * On restore failure, restart cron on target host #883 - - -- Bon Sohi Thu, 12 May 2022 21:06:56 +0000 - -github-backup-utils (3.4.1) UNRELEASED; urgency=medium - - * Simplify complex redirects for ghe-rsync #881 - * On restore failure, restart cron on target host #883 - - -- Donal Ellis Fri, 22 Apr 2022 04:00:00 +0000 - -github-backup-utils (3.3.2) UNRELEASED; urgency=medium - - * Simplify complex redirects for ghe-rsync #881 - * On restore failure, restart cron on target host #883 - - -- Donal Ellis Fri, 22 Apr 2022 00:53:45 +0000 - -github-backup-utils (3.4.0) UNRELEASED; urgency=medium - - * Add anchor to usage doc for settings restore #865 - - -- Steve Culver Tue, 15 Feb 2022 19:25:09 +0000 - -github-backup-utils (3.3.1) UNRELEASED; urgency=medium - - * Fix compat issue with ghe-actions-start during maintenance mode #836 - - -- Balwinder Sohi Tue, 21 Dec 2021 23:38:01 +0000 - -github-backup-utils (3.3.0) UNRELEASED; urgency=medium - - -- Balwinder Sohi Wed, 08 Dec 2021 03:12:53 +0000 - -github-backup-utils (3.3.0.rc1) UNRELEASED; urgency=medium - - -- Nick Iodice Tue, 09 Nov 2021 19:56:08 +0000 - -github-backup-utils (3.2.0) UNRELEASED; urgency=medium - - -- Brett Westover Tue, 28 Sep 2021 16:50:00 +0000 - -github-backup-utils (3.2.0.rc3) UNRELEASED; urgency=medium - - * Move GitHub Connect reset to after ghe-config-apply #783 - - -- Brett Westover Fri, 17 Sep 2021 00:44:59 +0000 - -github-backup-utils (3.2.0.rc1) UNRELEASED; urgency=medium - - * Leaked host key check: Avoid false positives from FIPS mode #748 - * Always restore user-password-secrets #762 - * Make some of the actions setting best effort #767 - * Remove reference to `ghe-cluster-cleanup-nodes` #768 - * Stop/Restart Actions in ghe-restore #769 - * Clear GitHub Connect settings when not restoring settings #770 - * GitHub Connect Reset Issue #776 - - -- Brett Westover Fri, 10 Sep 2021 20:10:07 +0000 - -github-backup-utils (3.2.0) UNRELEASED; urgency=medium - - * Leaked host key check: Avoid false positives from FIPS mode #748 - * Always restore user-password-secrets #762 - * Make some of the actions setting best effort #767 - * Remove reference to `ghe-cluster-cleanup-nodes` #768 - * Stop/Restart Actions in ghe-restore #769 - * Clear GitHub Connect settings when not restoring settings #770 - - -- Brett Westover Thu, 09 Sep 2021 16:42:24 +0000 - -github-backup-utils (3.1.0) UNRELEASED; urgency=medium - - -- Zachary Mark Thu, 03 Jun 2021 16:55:16 +0000 - -github-backup-utils (3.1.0~rc1) UNRELEASED; urgency=medium - - [ Zachary Mark ] - * Update repository backups to use ghe-gc-* for lock file management #188 - * A faster way to restore storage blobs (clusters) #212 - * Bug fix: Be more specific in restore routes globbing #715 - * fix(docker): add coreutils to get flags for date #717 - * Add backup cadence variable to the appliance #719 - * Fix is_default_external_database_snapshot function #720 - - [ Hideki Yamane ] - * debian/rules - - Drop unnecessary build-indep: - - Add manpages generation. - * debian/changelog - - Fix some lintian warnings for old entries. - * debian/source/format - - Upgrade to newer source format 3.0 (native). - * debian/copyright - - Format it as Machine-readable debian/copyright format 1.0 - - Add entries Twan Wolthof and me for debian/* since - enough code was written by non-github.com employees, at least. - * debian/control - - Update descriptions in debian/control - - Fix "Architecture: all", instead of "any". - - Declare its Homepage as https://github.com/github/backup-utils - - Add Vcs-* metadata field. - - Specify "Rules-Requires-Root: no" - - Drop unnecessary "Build-Depends: devscripts" - - Set Standards-Version: 4.5.1 - - Update Maintainer as Zachary Mark - * debian/{clean,manpages} - - Add files to support manpages handles. - - -- Zachary Mark Thu, 06 May 2021 17:11:18 +0000 - -github-backup-utils (3.0.0) UNRELEASED; urgency=medium - - * Fix restoring the password pepper for already configured instances #683 - - -- Michael Dang Tue, 16 Feb 2021 22:32:25 +0000 - -github-backup-utils (3.0.0.rc1) UNRELEASED; urgency=medium - - * Cleanup nomad container when restore for 2.22 #670 - * Use ghe-cluster-nomad-cleanup for cluster mode #663 - * Only run ghe-nomad-cleanup in 3.0 #662 - * Revert backup-utils gitHub env and a few more fixes #661 - * Note how to test filesystem symlink / hardlink support #660 - * stop github-timerd based on its running environment #659 - * Backup and restore password pepper #656 - * github-env -> github-env-dispatch #654 - * Rename redis-cli to ghe-redis-cli #639 - - -- Michael Dang Thu, 14 Jan 2021 21:17:53 +0000 - -github-backup-utils (2.22.0) UNRELEASED; urgency=medium - - * Added basic timing around the ghe-restore process #625 - * Improve python3 & finding moreutils parallel #627 - * Turn off POSIX for ghe-backup-config #632 - * Add parallelized restore capability to ghe-restore-storage #635 - * Update backup-utils for new features in 2.22 #641 - - -- Hao Jiang Wed, 23 Sep 2020 15:48:54 +0000 - -github-backup-utils (2.21.0) UNRELEASED; urgency=medium - - * Introduce option to skip restoring of audit logs #596 - * Beta: Execute ghe-backup tasks in parallel #597 - * Beta: Execute ghe-restore tasks in parallel #601 - * Run repositories restore in parallel #603 - * Fix mismatched `bm_start` and `bm_end` commands #607 - * remove rsync restore method used by GHES versions prior to 2.13 #608 - * Output MySQL backup strategy for clarity during backup and restore #610 - - -- Hao Jiang Tue, 09 Jun 2020 17:59:06 +0000 - -github-backup-utils (2.19.5) UNRELEASED; urgency=medium - - * In legacy mode we should use ghe-import-mysql #581 - - -- Caine Jette Fri, 21 Feb 2020 19:13:17 +0000 - -github-backup-utils (2.20.2) UNRELEASED; urgency=medium - - * In legacy mode we should use ghe-import-mysql #581 - - -- Hao Jiang Thu, 20 Feb 2020 22:47:09 +0000 - -github-backup-utils (2.20.1) UNRELEASED; urgency=medium - - * Fixes gist route calculation for GHES version 2.20 - - -- Caine Jette Wed, 19 Feb 2020 21:47:18 +0000 - -github-backup-utils (2.19.4) UNRELEASED; urgency=medium - - * Fix the way we connect to mysql master using ssh forwarding for binary backups #567 - - -- Hao Jiang Tue, 18 Feb 2020 17:54:31 +0000 - -github-backup-utils (2.20.0) UNRELEASED; urgency=medium - - * Fix `ghe-backup-repositories` performance for large instances #541 - * Fix two issues with binary backup (slow gzip compression and support for restore from instances other than SQL master) #551 - - -- Alejandro Figueroa Tue, 11 Feb 2020 20:47:17 +0000 - -github-backup-utils (2.19.3) UNRELEASED; urgency=medium - - * Fix two issues with binary backup (slow gzip compression and support for restore from instances other than SQL master) #551 - - -- Hao Jiang Tue, 11 Feb 2020 19:31:55 +0000 - -github-backup-utils (2.19.2) UNRELEASED; urgency=medium - - * Fix `ghe-backup-repositories` performance for large instances #541 - - -- Evgenii Khramkov Fri, 31 Jan 2020 19:13:46 +0000 - -github-backup-utils (2.19.1) UNRELEASED; urgency=medium - - * Cater for more explicit gist paths used in routes file #524 - * Suppress "*.rsync': No such file or directory" errors when no data to backup or restore #525 - - -- Colin Seymour Wed, 11 Dec 2019 09:33:01 +0000 - -github-backup-utils (2.19.0) UNRELEASED; urgency=medium - - * Remove temporary exclude file from the backup host not the target GHES appliance #516 - * Update Debian package depends to include git #520 - - -- Colin Seymour Tue, 12 Nov 2019 18:57:12 +0000 - -github-backup-utils (2.18.0) UNRELEASED; urgency=medium - - * Replace "sed -E" in ghe-host-check with a more portable solution #509 - - -- Colin Seymour Tue, 20 Aug 2019 18:49:44 +0000 - -github-backup-utils (2.17.1) UNRELEASED; urgency=medium - - * Redirect ghe-export-audit-logs stderr output unless using verbose output #497 - - -- Colin Seymour Wed, 05 Jun 2019 08:43:25 +0000 - -github-backup-utils (2.17.0) UNRELEASED; urgency=medium - - * Restore target is ignored when specified on the command line #476 - * Support incremental backups for MySQL-stored audit logs #485 - - -- Colin Seymour Thu, 23 May 2019 08:20:15 +0000 - -github-backup-utils (2.16.1) UNRELEASED; urgency=medium - - * Detect storage user on each cluster host being backed up or restored #472 - - -- Colin Seymour Tue, 26 Feb 2019 16:37:04 +0000 - -github-backup-utils (2.16.0) UNRELEASED; urgency=medium - - * (There was no descriptions) - - -- Colin Seymour Tue, 22 Jan 2019 20:25:34 +0000 - -github-backup-utils (2.15.1) UNRELEASED; urgency=medium - - * Restoring to an un-configured appliance fails due to a missing license file #449 - - -- Colin Seymour Tue, 13 Nov 2018 17:34:21 +0000 - -github-backup-utils (2.15.0) UNRELEASED; urgency=medium - - * (There was no descriptions) - - -- Colin Seymour Tue, 16 Oct 2018 16:40:03 +0000 - -github-backup-utils (2.15.0) UNRELEASED; urgency=medium - - * (There was no descriptions) - - -- Colin Seymour Tue, 16 Oct 2018 16:07:36 +0000 - -github-backup-utils (2.14.3) UNRELEASED; urgency=medium - - * Improve multi-platform detection of simultaneous ghe-backup runs #435 - - -- Colin Seymour Tue, 11 Sep 2018 17:03:42 +0000 - -github-backup-utils (2.14.2) UNRELEASED; urgency=medium - - * Capture and display repository/gist warnings during cluster restore #423 - * Use remote tempdir when finalizing Pages routes #424 - * Use old rsync restore method for pages prior to 2.13 #426 - - -- Colin Seymour Tue, 21 Aug 2018 13:57:20 +0000 - -github-backup-utils (2.14.1) UNRELEASED; urgency=medium - - * Don't fail a backup if the Management Console password isn't set #416 - * Fix permissions issues when repeat restoring to configured cluster instance #417 - * Add missing dependencies to debian packaging #418 - * Prevent restoring snapshots to older releases #420 - - -- Colin Seymour Tue, 07 Aug 2018 16:00:36 +0000 - -github-backup-utils (2.14.0) UNRELEASED; urgency=medium - - * Disable pager and context when running git-diff #411 - * Optimise hookshot and audit log backups and restores and MySQL restores #413 - - -- Colin Seymour Thu, 12 Jul 2018 15:11:11 +0000 - -github-backup-utils (2.13.2) UNRELEASED; urgency=medium - - * Treat missing repository networks, gists, and storage objects as a non-critical error #386 - * Clean up stale HA nodes on restore #396 - * Cleanup all SSH muxes in a non blocking way #402 - * Raise an error if the current symlink doesn't exist when attempting to restore it #404 - - -- Colin Seymour Fri, 22 Jun 2018 10:08:22 +0000 - -github-backup-utils (2.13.1) UNRELEASED; urgency=medium - - * Retry with the admin ssh port on network unreachable too. #377 - * Output backup utils version on backup and restore #384 - * Check filesystem supports hardlinks #388 - * Switch back to optimised restore route calculation #389 - * Optionally log verbose output to a file instead of stdout #391 - * Switch back to optimised backup route calculation #392 - * Remove check for git from ghe-ssh #393 - * Use remote's mktemp to create temp dir on remote host #395 - - -- Colin Seymour Wed, 09 May 2018 10:16:18 +0000 - -github-backup-utils (2.13.0) UNRELEASED; urgency=medium - - * Unify the backup & restore process #375 - - -- Colin Seymour Tue, 27 Mar 2018 16:01:43 +0000 - -github-backup-utils (2.11.4) UNRELEASED; urgency=medium - - * Move check for git for ssh muxing into ghe-ssh #378 - * Make it clear the settings need to be applied after restoring to an unconfigured instance #381 - - -- Colin Seymour Tue, 27 Mar 2018 13:20:18 +0000 - -github-backup-utils (2.11.3) UNRELEASED; urgency=medium - - * Update argument parsing and help/usage consistency #320 - * Fix failures variable #353 - * Remove other snapshot contents before removing the "incomplete" file #358 - * Backup and restore the management console password #361 - * Check for git before allowing SSH multiplex #362 - * Cleanup SSH multiplexing on exit #363 - * Filter cluster nodes by role during backup and restore #367 - * Optimise route generation and finalisation during cluster restores of pages #369 - * Allow extra rsync options to override default options #370 - - -- Colin Seymour Wed, 28 Feb 2018 16:32:07 +0000 - -github-backup-utils (2.11.2) UNRELEASED; urgency=medium - - * Allow the restoration of configuration to Cluster #347 - * Switch to TMPDIR before initiating SSH multiplexing workaround to prevent locking the destination filesystem #348 - - -- Colin Seymour Thu, 09 Nov 2017 12:16:23 +0000 - -github-backup-utils (2.11.1) UNRELEASED; urgency=medium - - * Refresh the existing indices when restoring Elasticsearch indices to cluster #328 - * Fix failure to restore 2.9/2.10 backups to 2.11 prevented by incorrect detection of the audit log migration #333 - * Use git to generate short name for SSH multiplex control path #335 - * Remove use of --literally when computing arbitrary shasum #338 - * Remove -o option from ps use #341 - - -- Colin Seymour Thu, 05 Oct 2017 14:47:56 +0000 - -github-backup-utils (2.11.0) UNRELEASED; urgency=medium - - * Use calculated routes when backing up storage data from a cluster #318 - * Add SSH multiplexing support #321 - * Optimise route generation and finalisation during cluster restores #322 - * Prefer the SSH port specified on the command line #324 - - -- Colin Seymour Wed, 13 Sep 2017 16:31:20 +0000 - -github-backup-utils (2.10.0) UNRELEASED; urgency=medium - - * Include the user data directory in the benchmark name #311 - * Use existing Elasticsearch indices to speed up transfer during a restore #310 - * Improve detection of failures in cluster backup rsync threads #301 - * Improve redis backup robustness #306 - * Use default niceness for restores #308 - * Add additional case to SSH port detection logic #304 - * Suppress additional dd output noise #289 - * Track completeness of Elasticsearch JSON dumps #298 - - -- Steven Honson Thu, 08 Jun 2017 09:06:16 +1000 - -github-backup-utils (2.9.0) UNRELEASED; urgency=medium - - * Block restores to appliances with HA configured #291 - * Add a `--version` flag #284 - * Check backup-utils are not being run on GitHub Enterprise host #286 - * Backup and restore custom CA certificates #281 - * Hookshot backup/restores optimisations #276 - - -- Sergio Rubio Wed, 01 Mar 2017 09:39:26 -0800 - -github-backup-utils (2.8.3) UNRELEASED; urgency=medium - - * Set restore status on all cluster nodes #274 - * Fix pages backups and restores in GitHub Enterprise 11.10 #275 - - -- Steven Honson Wed, 21 Dec 2016 21:01:20 +1100 - -github-backup-utils (2.8.2) UNRELEASED; urgency=medium - - * Backup and restore the appliance UUID #272 - - -- Sergio Rubio Thu, 17 Nov 2016 15:58:08 +0100 - -github-backup-utils (2.8.1) UNRELEASED; urgency=medium - - * Stop cron and timerd during restore #269 - * Fix compatibility issue with older versions of OpenSSH #263 - - -- Sergio Rubio Mon, 14 Nov 2016 22:04:48 +0100 - -github-backup-utils (2.8.0) UNRELEASED; urgency=low - - * Adds support for GitHub Enterprise 2.8.0 - * Speedup storage restores #247 - * More portable backup-utils #260 - - -- rubiojr Wed, 09 Nov 2016 06:35:21 -0800 - -github-backup-utils (2.7.1) UNRELEASED; urgency=medium - - * Cluster: fix offline cluster node detection #250 - * Detect leaked ssh keys in backup snapshots #253 - - -- Sergio Rubio Tue, 20 Sep 2016 20:15:12 +0200 - -github-backup-utils (2.7.0) UNRELEASED; urgency=medium - - * GitHub Enterprise 2.7.0 support - - -- Sergio Rubio Wed, 03 Aug 2016 20:25:31 +0200 - -github-backup-utils (2.6.4) UNRELEASED; urgency=medium - - * Instrument/benchmark backups #238 - * Cluster: remove restoring cluster.conf on restore #242 - * Cluster: Prevent restoring to a standalone GHE appliance #244 - - -- Sergio Rubio Wed, 27 Jul 2016 19:15:53 +0200 - -github-backup-utils (2.6.3) UNRELEASED; urgency=medium - - * Cluster: git-hooks backup fixes #235 - - -- Sergio Rubio Wed, 29 Jun 2016 21:05:21 +0200 - -github-backup-utils (2.6.2) UNRELEASED; urgency=medium - - * git-hooks fixes #231 - * Cluster: speedup repositories restore #232 (requires GitHub Enterprise - 2.6.4) - * Cluster: restore Git over SSH keys #230 - * Benchmark restores #219 - - -- Sergio Rubio Wed, 22 Jun 2016 19:36:06 +0200 - -github-backup-utils (2.6.1) UNRELEASED; urgency=medium - - * Cluster: faster gist restores #220 - * Cluster: faster storage restores #212 - * Cluster: fix git-hooks restores #204 - - -- Sergio Rubio Tue, 31 May 2016 20:54:11 +0200 - -github-backup-utils (2.6.0) UNRELEASED; urgency=medium - - * Adds support for GitHub Enterprise 2.6 - * Adds an extra supported location for the backup configuration #197 - * New config option to check for corrupted repositories after the backup #195 - * General improvements and bug fixes - - -- Sergio Rubio Tue, 26 Apr 2016 18:03:01 +0200 - -github-backup-utils (2.5.2) UNRELEASED; urgency=medium - - * New configuration variable: GHE_CREATE_DATA_DIR #186 - * Require that snapshots originated from an instance running GitHub - Enterprise 2.5.0 or above when restoring to a cluster #182 - * Prevent Git GC operations and some other maintenance jobs from running - while repositories are being restored #179 - * Fix Solaris and SmartOS support, using Bash everywhere #177 - - -- Sergio Rubio Wed, 30 Mar 2016 14:32:15 +0200 - -github-backup-utils (2.5.1) UNRELEASED; urgency=medium - - * Fixes for cluster restores #173 - * Fix Elasticsearch backups for GitHub Enterprise <= 2.2 #175 - * Removed experimental S3 support #167 - * Remote logging output fixes #170 - * Update ghe-host-check to detect extra port 22 error #162 - - -- Sergio Rubio Wed, 09 Mar 2016 14:44:05 +0100 - -github-backup-utils (2.5.0) UNRELEASED; urgency=medium - - * Adds GitHub Enterprise 2.5 support - * Adds GitHub Enterprise Clustering support - * Backups and restores SAML keypairs - - -- Sergio Rubio Tue, 9 Feb 2016 00:02:37 +0000 - -github-backup-utils (2.4.0) UNRELEASED; urgency=medium - - * Moves the in-progress detection to a separate file with PID which is - removed if the process is no longer running after the backup. #145, #99 - * Updates the README to explain why backup-utils is useful even if you have - the high availability replica running. #140 - * Changes the use of the --link-dest option to only occur when backing up - populated directories. #138 - * Adds logging to /var/log/syslog on the remote GitHub Enterprise appliance - to both ghe-backup and ghe-restore. #131 - * Restarts memcached after restoring to an already configured appliance to - ensure it doesn't contain out-of-sync information. #130 - * Removes the temporary /data/user/repositories-nw-backup directory that - remains after successfully migrating the repository storage layout to the - new format used on GitHub Enterprise 2.2.0 and later after restoring a - backup from an older release of GitHub Enterprise. #129 - * Add devscripts to Debian's build-depends for checkbashisms. #101 - * Documents the -c option which forces the restoration of the configuration - information to an already configured appliance. #96 - - -- Colin Seymour Tue, 20 Oct 2015 00:02:37 +0000 - -github-backup-utils (2.2.0) UNRELEASED; urgency=medium - - * Adds support for the new repositories filesystem layout include in - GitHub Enterprise v2.2. #122, #124 - * ghe-restore now performs a config run on the instance after an incremental - restore to 11.10.x and 2.x instances. #100 - * ghe-restore now fails fast when run against a GHE instance with replication - enabled. Replication should be disabled during a restore and then setup - after the restore completes. #121 - * Fixes an issue with special port 122 detection failing when port is - overridden in an ssh config file. #102 - * Removes a warning message when running ghe-backup against an instance with - GitHub Pages disabled. #117 - * backup-utils release version numbers now track GitHub Enterprise releases - to ease the process of determining which version of backup-utils is - required for a given GitHub Enterprise version. - - -- Ryan Tomayko Wed, 29 Apr 2015 07:29:04 +0000 - -github-backup-utils (2.0.2) UNRELEASED; urgency=medium - - * ghe-restore now requires that an already-configured appliance be put into - maintenance mode manually. This is a safeguard against accidentally - overwriting data on the wrong instance. #62, #84 - * ghe-backup and ghe-restore now run a ghe-negotiate-version program on the - appliance to determine whether the backup-utils and GHE versions are - compatible. #91 - * Various portability fixes for problems surfaced when running on Solaris - and FreeBSD. #86, #87 - * Fixes an issue in ghe-backup where mysqldump failures weren't being - reported properly. #90 - * Automated builds are now run on Travis CI. #77 - - -- Ryan Tomayko Tue, 20 Jan 2015 16:00:00 +0000 - -github-backup-utils (2.0.1) UNRELEASED; urgency=medium - - * Adds /etc/github-backup-utils/backup.config as a default config file search - location for deb / system installs. - * Enables SSH BatchMode for all remote command invocation except initial host - check / version identification. - * Fixes a bug in ghe-backup where Git GC process detection would misclassify - long-running server processes matching /git.*gc/, causing the backup operation - to timeout. - * Adds a note and link to the Migrating from GitHub Enterprise v11.10.34x to - v2.0 documentation in the README. - * Adds example / documentation for the GHE_EXTRA_SSH_OPTS config value to the - backup.config-example file. - - -- Ryan Tomayko Mon, 17 Nov 2014 12:47:22 +0000 - -github-backup-utils (2.0.0) UNRELEASED; urgency=medium - - * Support for GitHub Enterprise 2.0. - * Support for migrating from GitHub Enterprise 11.10.34x to 2.0 (including from - VMware to AWS). - * ghe-backup retains hardlinks present on VM in backup snapshots, saving space. - * ghe-restore retains hardlinks present in backup snapshot when restoring to VM. - * backup-utils now includes debian packaging support. - * Fixes an issue with ghe-restore -s not using the snapshot specified. - * Fixes an issue with ghe-backup not waiting for nw-repack processes to finish - in some instances. - - -- Ryan Tomayko Mon, 10 Nov 2014 10:48:36 +0000 - -github-backup-utils (1.1.0) UNRELEASED; urgency=medium - - * Updated documentation on minimum GitHub Enterprise version requirements for - online and incremental backups from v11.10.341 to at least v11.10.342. - * The ghe-restore command now prompts for confirmation of the host to restore to - before performing any destructive operation. This is to reduce the chances of - restoring to the wrong host. The prompt may be bypassed in automated scenarios - by providing the --force option. - * Added a -c option to ghe-restore for restoring base appliance settings in - addition to primary datastores. See ghe-restore --help for more information. - * Added a note about disabling maintenance mode on the appliance after a - successful ghe-restore operation. - * Added support for filesystem layout changes and upgraded server components in - * future versions of GitHub Enterprise. - - -- Twan Wolthof Sat, 18 Oct 2014 19:14:47 +0000 - -github-backup-utils (1.0.1) UNRELEASED; urgency=medium - - * Initial release. - - -- Twan Wolthof Tue, 23 Sep 2014 08:34:55 +0000 diff --git a/debian/clean b/debian/clean deleted file mode 100644 index 0f651869c..000000000 --- a/debian/clean +++ /dev/null @@ -1 +0,0 @@ -debian/*.1 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec635144f..000000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control deleted file mode 100644 index b2cd7c945..000000000 --- a/debian/control +++ /dev/null @@ -1,32 +0,0 @@ -Source: github-backup-utils -Maintainer: Zachary Mark -Section: misc -Priority: optional -Standards-Version: 4.5.1 -Build-Depends: debhelper (>= 9), git, moreutils, jq, rsync (>= 2.6.4), help2man, -Homepage: https://github.com/github/backup-utils -Vcs-Git: https://github.com/github/backup-utils.git -Vcs-Browser: https://github.com/github/backup-utils -Rules-Requires-Root: no - -Package: github-backup-utils -Architecture: all -Depends: ${misc:Depends}, rsync (>= 2.6.4), moreutils, jq, git -Description: Backup and recovery utilities for GitHub Enterprise Server - The backup utilities implement a number of advanced capabilities for backup - hosts, built on top of the backup and restore features already included in - GitHub Enterprise Server. - . - These advanced features include: - - Complete GitHub Enterprise Server backup and recovery system via two simple - utilities: `ghe-backup` and `ghe-restore`. - - Online backups. The GitHub appliance need not be put in maintenance mode for - the duration of the backup run. - - Incremental backup of Git repository data. Only changes since the last - snapshot are transferred, leading to faster backup runs and lower network - bandwidth and machine utilization. - - Efficient snapshot storage. Only data added since the previous snapshot - consumes new space on the backup host. - - Multiple backup snapshots with configurable retention periods. - - Backup runs under the lowest CPU/IO priority on the GitHub appliance, - reducing performance impact while backups are in progress. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 8879cfae8..000000000 --- a/debian/copyright +++ /dev/null @@ -1,33 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: GitHub Enterprise Server Backup Utilities -Source: https://github.com/github/backup-utils - -Files: * -Copyright: 2014-2021, GitHub Inc. -License: MIT - -Files: debian/* -Copyright: 2014-2021, GitHub Inc. - 2014 Twan Wolthof - 2021 Hideki Yamane -License: MIT - -License: MIT - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - "Software"), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - . - The above copyright notice and this permission notice shall be - included in all copies or substantial portions of the Software. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/debian/install b/debian/install deleted file mode 100644 index bc992fc49..000000000 --- a/debian/install +++ /dev/null @@ -1,2 +0,0 @@ -bin/* usr/bin -share/* usr/share diff --git a/debian/manpages b/debian/manpages deleted file mode 100644 index 0f651869c..000000000 --- a/debian/manpages +++ /dev/null @@ -1 +0,0 @@ -debian/*.1 diff --git a/debian/rules b/debian/rules deleted file mode 100755 index af3d39d08..000000000 --- a/debian/rules +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/make -f - -VERSION=$$(cat $(CURDIR)/share/github-backup-utils/version) - -override_dh_auto_build: - # generate manpages for ghe-backup, ghe-host-check and ghe-restore - help2man $(CURDIR)/bin/ghe-backup -N -o $(CURDIR)/debian/ghe-backup.1 \ - -n "Take snapshots of all GitHub Enterprise data" \ - --version-string="ghe-backup $(VERSION)" - help2man $(CURDIR)/bin/ghe-host-check -N -o $(CURDIR)/debian/ghe-host-check.1 \ - -n "Restores a GitHub instance from local backup snapshots" \ - --version-string="ghe-host-check $(VERSION)" - help2man $(CURDIR)/bin/ghe-restore -N -o $(CURDIR)/debian/ghe-restore.1 \ - -n "Verify connectivity with the GitHub Enterprise Server host" \ - --version-string="ghe-restore $(VERSION)" - -%: - dh $@ diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 89ae9db8f..000000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) diff --git a/ownership.yaml b/ownership.yaml deleted file mode 100644 index bde619edc..000000000 --- a/ownership.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -version: 1 -ownership: -- name: ghes-backup-utilities - long_name: GHES Backup Utilities - description: GitHub Enterprise Disaster Recover Solution - kind: logical - repo: https://github.com/github/backup-utils-private - qos: best_effort - team_slack: ghes-lifecycle-aor - team: github/ghes-lifecycle - maintainer: whitneyimura - exec_sponsor: jakuboleksy - tier: 3 - product_manager: davidjarzebowski - sev1: - slack: ghes-on-call - alert_slack: ghes-backup-utils - pagerduty: https://github.pagerduty.com/escalation_policies#PBQWK20 - tta: 30 minutes - sev2: - issue: https://github.com/github/ghes/issues/new - tta: 1 business day - sev3: - issue: https://github.com/github/ghes/issues - tta: 1 week - support_squad: - slack: support-squad-infrastructure - issue: https://github.com/github/support-squad-infrastructure/issues diff --git a/release-notes/3.11.0.md b/release-notes/3.11.0.md deleted file mode 100644 index 197501c92..000000000 --- a/release-notes/3.11.0.md +++ /dev/null @@ -1,18 +0,0 @@ -### Bug Fixes - -* `ghe-backup-myql` and `ghe-restore-mysql` will now exit 1 on errors. -* On an instance with Actions enabled, incorrect backup and restore settings prevented the storage container name from being restored. This made the logs from that container inaccessible, and caused Actions to create a new storage container in a different location. -* When backups are run for HA instances in both primary and replica nodes a `.sync-in-progress` file will be created. This will disable `NetworkMaintenance` jobs from running and queueing up when backups are running from the primary node. - -### Changes - -* Estimated transfer sizes will be calculated on appropriate nodes for clustered environments. -* Added support for finding the `parallel` command from the `moreutils` tool suite on more Linux distributions, including Arch Linux and Alpine Linux. -* `ghe-restore` avoids unnecessary `rsync` operations when restoring to non-clustered environments. -* `ghe-backup` and `ghe-restore` output their total runtime -* `rsync` compression is now disabled by default. The `-z` flag has been removed from the `ghe-rsync` command in multiple files to improve transfer speed and reduce CPU usage. To enable `rsync` compression globally, add `GHE_RSYNC_COMPRESSION_ENABLED=yes` to the `backup.config` file. -* Updates the Host OS version output to use `/etc/os-release` for better compatibility with other Linux distributions. - -### Backups and Disaster Recovery - -* When a NFS mount is detected for snapshots on backup hosts, backup logs will show a warning to notify the user that such a setup may incur performance issues as highlighted in [storage requirements](https://github.com/github/backup-utils-private/blob/master/docs/requirements.md#storage-requirements) documentation. diff --git a/script/package-deb b/script/package-deb deleted file mode 100755 index 15a698e9c..000000000 --- a/script/package-deb +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -# Usage: script/package-deb -# Script to build a deb release package from the current HEAD version. -# The package version comes from the debian/changelog file so that should -# be edited before running this. -set -e - -# Change into project root -cd "$(dirname "$0")"/.. - -# Fetch tags from remote repository -git fetch --tags - -# Basic package name and version. -PKG_BASE="github-backup-utils" -PKG_VERS="$(git describe --tags)" -PKG_NAME="${PKG_BASE}-${PKG_VERS}" -PKG_HEAD="$(git rev-parse HEAD)" - -# Run git-archive to generate tarball -rm -rf dist/debuild -trap "rm -rf dist/debuild" EXIT -mkdir -p dist/debuild - -distdir="$(pwd)/dist/debuild/$PKG_NAME" -git clone -q . "$distdir" -cd "$distdir" - -echo "Removing files listed in .releaseignore ..." -while IFS= read -r line; do - rm -rf "$line" -done < .releaseignore - -echo "Removing .releaseignore ..." -rm -f .releaseignore -git checkout -q "$PKG_HEAD" - -debuild -uc -us 1>&2 -cd .. -files=$(ls -1 *.deb *.tar.xz *.dsc *.changes) -mv $files ../ -for f in $files; do echo "dist/$f"; done diff --git a/script/package-tarball b/script/package-tarball deleted file mode 100755 index bf1510e8f..000000000 --- a/script/package-tarball +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -# Usage: script/package-tarball -# Script to build a tarball release package from the current HEAD version. -# The package version comes from `git-describe --tags' so the release tag should -# be in place before this command is run. -set -e - -# Change into project root -cd "$(dirname "$0")"/.. - -# Fetch tags from remote repository -git fetch --tags - -# Basic package name and version. -PKG_BASE="github-backup-utils" -PKG_VERS="$(git describe --tags)" -PKG_NAME="${PKG_BASE}-${PKG_VERS}" - -# Remove all files or directories listed in .releaseignore -echo "Removing files listed in .releaseignore ..." -while IFS= read -r line; do - rm -rf "$line" -done < .releaseignore - -# Remove the .releaseignore file itself -echo "Removing .releaseignore ..." -rm -f .releaseignore - -# Run git-archive to generate tarball -echo "Creating ${PKG_NAME}.tar.gz ..." -mkdir -p dist -git archive \ - --format=tar.gz \ - --prefix="$PKG_NAME/" \ - --output="dist/${PKG_NAME}.tar.gz" \ - HEAD - -# List archive contents for review -gzip -dc < "dist/${PKG_NAME}.tar.gz" | tar tf - - -# Output location -echo "Package dist/${PKG_NAME}.tar.gz OK" diff --git a/script/release b/script/release deleted file mode 100755 index 9629cacff..000000000 --- a/script/release +++ /dev/null @@ -1,506 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -#/ Usage: release [--dry-run] [--skip-version-bump-check] [min_version] -#/ -#/ Publish a backup-utils release: -#/ * Updates the package changelog -#/ * Bumps the backup-utils version if required -#/ * Creates the release pull request -#/ * Merges the release pull request -#/ * Creates the release draft -#/ * Tags the release -#/ * Builds the release assets and uploads them -#/ -#/ Notes: -#/ * Needs GH_RELEASE_TOKEN and GH_AUTHOR set in the environment. -#/ * Export GH_OWNER and GH_REPO if you want to use a different owner/repo -#/ * Only pull requests labeled with bug, feature or enhancement will show up in the -#/ release page and the changelog. -#/ * If this is a X.Y.0 release, a minimum supported version needs to be supplied too. -#/ -require "json" -require "net/http" -require "time" -require "erb" -require "English" - -API_HOST = ENV["GH_HOST"] || "api.github.com" -API_PORT = 443 -GH_REPO = ENV["GH_REPO"] || "backup-utils" -GH_OWNER = ENV["GH_OWNER"] || "github" -GH_AUTHOR = ENV["GH_AUTHOR"] -DEB_PKG_NAME = "github-backup-utils" -GH_BASE_BRANCH = ENV["GH_BASE_BRANCH"] || "master" # TODO: should we even allow a default or require all params get set explicitly? -GH_STABLE_BRANCH = "" - -# If PUBLISH is false, we leave the release in a draft state to be manually published later through the UI -PUBLISH = ENV["PUBLISH"] == "true" || false - -CHANGELOG_TMPL = "" '<%= package_name %> (<%= package_version %>) UNRELEASED; urgency=medium - -<%- changes.each do |ch| -%> - * <%= ch.strip.chomp %> -<% end -%> - - -- <%= GH_AUTHOR %> <%= Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S %z") %> - -' "" - -# Override Kernel.warn -def warn(msg) - Kernel.warn msg unless @no_warn -end - -def client(host = API_HOST, port = API_PORT) - @http ||= begin - c = Net::HTTP.new(host, port) - c.use_ssl = true - c - end -end - -def get(path) - req = Net::HTTP::Get.new(path) - req["Authorization"] = "token #{release_token}" - client.request(req) -end - -def post(path, body) - req = Net::HTTP::Post.new(path) - req["Authorization"] = "token #{release_token}" - req.body = body - client.request(req) -end - -def post_file(path, body) - req = Net::HTTP::Post.new(path) - req["Authorization"] = "token #{release_token}" - req["Content-Type"] = path.match?(/.*\.tar\.gz$/) ? "application/tar+gzip" : "application/vnd.debian.binary-package" - req.body = body - client.request(req) -end - -def put(path, body) - req = Net::HTTP::Put.new(path) - req["Authorization"] = "token #{release_token}" - req.body = body - client.request(req) -end - -def patch(path, body) - req = Net::HTTP::Patch.new(path) - req["Authorization"] = "token #{release_token}" - req.body = body - client.request(req) -end - -def release_token - token = ENV["GH_RELEASE_TOKEN"] - raise "GH_RELEASE_TOKEN environment variable not set" if token.nil? - - token -end - -# Create a lightweight tag -def tag(name, sha) - body = { - "ref": "refs/tags/#{name}", - "sha": sha, - }.to_json - res = post("/repos/#{GH_OWNER}/#{GH_REPO}/git/refs", body) - - raise "Creating tag ref failed (#{res.code})" unless res.is_a? Net::HTTPSuccess -end - -def bug_or_feature?(issue_hash) - return true if issue_hash["labels"].find { |label| ["bug", "feature", "enhancement"].include?(label["name"]) } - false -end - -def issue_from(issue) - res = get("/repos/#{GH_OWNER}/#{GH_REPO}/issues/#{issue}") - raise "Issue ##{issue} not found in #{GH_OWNER}/#{GH_REPO}" unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -def beautify_changes(changes) - out = [] - changes.each do |chg| - next unless chg =~ /#(\d+)/ - begin - issue = issue_from Regexp.last_match(1) - out << "#{issue["title"]} ##{Regexp.last_match(1)}" if bug_or_feature?(issue) - rescue => e - warn "Warning: #{e.message}" - end - end - - out -end - -def changelog - puts "building changelog by comparing origin/#{GH_STABLE_BRANCH}...origin/#{GH_BASE_BRANCH}" - changes = `git log --pretty=oneline origin/#{GH_STABLE_BRANCH}...origin/#{GH_BASE_BRANCH} --reverse --grep "Merge pull request" | sort -t\# -k2`.lines.map(&:strip) - raise "Building the changelog failed" if $CHILD_STATUS != 0 - - changes -end - -def build_changelog(changes, package_name, package_version) - ERB.new(CHANGELOG_TMPL, nil, "-").result(binding) -end - -def update_changelog(changes, name, version, path = "debian/changelog") - raise "debian/changelog not found" unless File.exist?(path) - File.open("#{path}.new", "w") do |f| - f.puts build_changelog changes, name, version - f.puts(File.read(path)) - end - File.rename("#{path}.new", path) -end - -def create_release(tag_name, branch, rel_name, rel_body, draft = true) - body = { - 'tag_name': tag_name, - 'target_commitish': branch, - 'name': rel_name, - 'body': rel_body, - 'draft': draft, - 'prerelease': false, - }.to_json - res = post("/repos/#{GH_OWNER}/#{GH_REPO}/releases", body) - - raise "Failed to create release (#{res.code})" unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -def publish_release(release_id) - body = { - 'draft': false, - }.to_json - res = patch("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}", body) - - raise "Failed to update release (#{res.code})" unless res.is_a? Net::HTTPSuccess -end - -def list_releases - res = get("/repos/#{GH_OWNER}/#{GH_REPO}/releases") - raise "Failed to retrieve releases" unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -def release_available?(tag_name) - return true if list_releases.find { |r| r["tag_name"] == tag_name } - - false -end - -def bump_version(new_version, min_version = nil, path = "share/github-backup-utils/version") - current_version = Gem::Version.new(File.read(path).strip.chomp) - if !@skip_version_bump_check && (Gem::Version.new(new_version) < current_version) - raise "New version should be newer than #{current_version}" - end - File.open("#{path}.new", "w") { |f| f.puts new_version } - File.rename("#{path}.new", path) - - unless min_version.nil? - content = File.read("bin/ghe-host-check") - new_content = content.gsub(/supported_minimum_version="[0-9]\.[0-9]+\.0"/, "supported_minimum_version=\"#{min_version}\"") - File.open("bin/ghe-host-check", "w") { |file| file.puts new_content } - - content = File.read("test/testlib.sh") - new_content = content.gsub(/GHE_TEST_REMOTE_VERSION:=[0-9]\.[0-9]+\.0/, "GHE_TEST_REMOTE_VERSION:=#{new_version}") - File.open("test/testlib.sh", "w") { |file| file.puts new_content } - end -end - -def push_release_branch(version) - unless (out = `git checkout --quiet -b release-#{version}`) - raise "Creating release branch failed:\n\n#{out}" - end - - unless (out = `git commit --quiet -m 'Bump version: #{version} [ci skip]' debian/changelog share/github-backup-utils/version bin/ghe-host-check test/testlib.sh script/test`) - raise "Error committing changelog and version:\n\n#{out}" - end - - unless (out = `git push --quiet origin release-#{version}`) - raise "Failed pushing the release branch:\n\n#{out}" - end -end - -def update_stable_branch - `git checkout --quiet #{GH_STABLE_BRANCH}` - unless (out = `git merge --quiet --ff-only origin/#{GH_BASE_BRANCH}`) - warn "Merging #{GH_BASE_BRANCH} into #{GH_STABLE_BRANCH} failed:\n\n#{out}" - end - unless (out = `git push --quiet origin #{GH_STABLE_BRANCH}`) - warn "Failed pushing the #{GH_STABLE_BRANCH} branch:\n\n#{out}" - end -end - -def create_release_pr(version, release_body) - body = { - 'title': "Bump version: #{version}", - 'body': release_body, - 'head': "release-#{version}", - 'base': GH_BASE_BRANCH, - }.to_json - res = post("/repos/#{GH_OWNER}/#{GH_REPO}/pulls", body) - raise "Creating release PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -def merge_pr(number, sha, version) - body = { - 'commit_title': "Merge pull request ##{number} from github/release-#{version}", - 'commit_message': "Bump version: #{version}", - 'sha': sha, - 'merge_method': "merge", - }.to_json - pr_mergeable? number - res = put("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}/merge", body) - raise "Merging PR failed (#{res.code})" unless res.is_a? Net::HTTPSuccess - - JSON.parse(res.body) -end - -class RetryError < StandardError -end - -def pr_mergeable?(number) - begin - retries ||= 5 - res = get("/repos/#{GH_OWNER}/#{GH_REPO}/pulls/#{number}") - raise RetryError if JSON.parse(res.body)["mergeable"].nil? - mergeable = JSON.parse(res.body)["mergeable"] - rescue RetryError - sleep 1 - retry unless (retries -= 1).zero? - raise "PR is unmergable." - end - - mergeable || false -end - -def can_auth? - !ENV["GH_RELEASE_TOKEN"].nil? -end - -def repo_exists? - res = get("/repos/#{GH_OWNER}/#{GH_REPO}") - res.is_a? Net::HTTPSuccess -end - -def can_build_deb? - system("which debuild > /dev/null 2>&1") -end - -def package_tarball - unless (out = `script/package-tarball 2>&1`) - raise "Failed to package tarball:\n\n#{out}" - end - out -end - -def package_deb - unless (out = `DEB_BUILD_OPTIONS=nocheck script/package-deb 2>&1`) - raise "Failed to package Debian package:\n\n#{out}" - end - out -end - -def attach_assets_to_release(upload_url, release_id, files) - @http = nil - client(URI(upload_url.gsub(/{.*}/, "")).host) - begin - files.each do |file| - raw_file = File.open(file).read - res = post_file("/repos/#{GH_OWNER}/#{GH_REPO}/releases/#{release_id}/assets?name=#{File.basename(file)}", raw_file) - raise "Failed to attach #{file} to release (#{res.code})" unless res.is_a? Net::HTTPSuccess - end - rescue => e - raise e - end - @http = nil -end - -def clean_up(version) - `git checkout --quiet #{GH_BASE_BRANCH}` - `git fetch --quiet origin --prune` - `git pull --quiet origin #{GH_BASE_BRANCH} --prune` - `git branch --quiet -D release-#{version} >/dev/null 2>&1` - `git push --quiet origin :release-#{version} >/dev/null 2>&1` - `git branch --quiet -D tmp-packaging >/dev/null 2>&1` -end - -def is_base_branch_valid?(branch) - if branch == "master" || branch.match(/^\d+\.\d+-main$/) - return true - else - return false - end -end - -def get_stable_branch_name(branch) - ## derive the proper stable branch. if the base branch is "master" the stable branch is just "stable" - ## if the base branch is a release branch, the stable branch will be "x.y-stable" - result = "" - if branch == "master" - result = "stable" - else - result = branch.gsub(/-main$/, "-stable") - end - - result -end - -#### All the action starts #### -if $PROGRAM_NAME == __FILE__ - begin - ## validate base branch. this must either be "master" or a release branch which will match the pattern "x.y-main" - raise "The branch #{GH_BASE_BRANCH} is not valid for releasing backup-utils. branch name must be master or match x.y-main" if !is_base_branch_valid?(GH_BASE_BRANCH) - - GH_STABLE_BRANCH = get_stable_branch_name(GH_BASE_BRANCH) - - puts "base branch = " + GH_BASE_BRANCH - puts "stable branch = " + GH_STABLE_BRANCH - - args = ARGV.dup - dry_run = false - skip_version_bump_check = false - if args.include?("--dry-run") - dry_run = true - args.delete "--dry-run" - end - - if args.include?("--no-warn") - @no_warn = true - args.delete "--no-warn" - end - - if args.include?("--skip-version-bump-check") - @skip_version_bump_check = true - args.delete "--skip-version-bump-check" - end - - raise "Usage: release [--dry-run] [--skip-version-bump-check] [min_version]" if args.empty? - - begin - version = Gem::Version.new(args[0]) - min_version = args[1] ? args[1] : nil - rescue ArgumentError - raise "Error parsing version #{args[0]}" - end - - raise "Minimum supported version is required for X.Y.0 releases\n\nUsage: release [--dry-run] [min_version]" if /[0-9]\.[0-9]+\.0/ =~ version.to_s && min_version.nil? - - raise "The repo #{GH_REPO} does not exist for #{GH_OWNER}" unless repo_exists? - - raise "GH_AUTHOR environment variable is not set" if GH_AUTHOR.nil? - - release_changes = [] - release_changes = beautify_changes changelog if can_auth? - release_a = false - release_a = release_available? "v#{version}" - - puts "Bumping version to #{version}..." - bump_version version, min_version - - if dry_run - puts "Existing release?: #{release_a}" - puts "New version: #{version}" - puts "Min version: #{min_version}" unless min_version.nil? - puts "Owner: #{GH_OWNER}" - puts "Repo: #{GH_REPO}" - puts "Author: #{GH_AUTHOR}" - puts "Token: #{ENV["GH_RELEASE_TOKEN"] && "set" || "unset"}" - puts "Base branch: #{GH_BASE_BRANCH}" - puts "Changelog:" - if release_changes.empty? - puts " => No new bug fixes, enhancements or features." - else - release_changes.each { |c| puts " * #{c}" } - end - puts "Changes:" - puts `git diff --color` - `git checkout -- share/github-backup-utils/version` - `git checkout -- bin/ghe-host-check` - `git checkout -- test/testlib.sh` - exit - end - - raise 'Unable to build Debian pkg: "debuild" not found.' unless can_build_deb? - - raise "Release #{version} already exists." if release_a - - `git fetch --quiet origin --prune` - branches = `git branch --all | grep release-#{version}$` - unless branches.empty? - out = "Release branch release-#{version} already exists. " - out += "Branches found:" - branches.each_line { |l| out += "\n* #{l.strip.chomp}" } - raise out - end - - puts "Updating changelog..." - update_changelog release_changes, DEB_PKG_NAME, version - release_body = "Includes general improvements & bug fixes" - release_body += " and support for GitHub Enterprise Server v#{version}" unless min_version.nil? - release_changes.each do |c| - release_body += "\n* #{c}" - end - - puts "Pushing release branch and creating release PR..." - push_release_branch version - res = create_release_pr(version, "#{release_body}\n\n/cc @github/backup-utils") - - puts "Merging release PR..." - res = merge_pr res["number"], res["head"]["sha"], version - - puts "Tagging and publishing release..." - tag "v#{version}", res["sha"] - - puts "Creating release..." - release_title = "GitHub Enterprise Server Backup Utilities v#{version}" - res = create_release "v#{version}", GH_BASE_BRANCH, release_title, release_body, true - - # Tidy up before building tarball and deb pkg - clean_up version - - puts "Building release tarball..." - package_tarball - - puts "Building Debian pkg..." - package_deb - - puts "Attaching Debian pkg and tarball to release..." - base_dir = File.expand_path(File.join(File.dirname(__FILE__), "..")) - attach_assets_to_release res["upload_url"], res["id"], ["#{base_dir}/dist/#{DEB_PKG_NAME}-v#{version}.tar.gz"] - attach_assets_to_release res["upload_url"], res["id"], ["#{base_dir}/dist/#{DEB_PKG_NAME}_#{version}_all.deb"] - - if PUBLISH - puts "Publishing release..." - publish_release res["id"] - end - - puts "Cleaning up..." - clean_up version - - puts "Updating #{GH_STABLE_BRANCH} branch..." - update_stable_branch - - if !PUBLISH - puts 'Release left in a "Draft" state. Go to the https://github.com/github/backup-utils/releases and publish when ready.' - end - - puts "Released!" - rescue RuntimeError => e - $stderr.puts "Error: #{e}" - exit 1 - end -end diff --git a/script/test b/script/test deleted file mode 100755 index d30bfa8df..000000000 --- a/script/test +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# Usage: script/test -set -e - -ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" -TMPDIR="$ROOTDIR/test/tmp" - -# Remove possible remnants of previous test runs -rm -rf "${TMPDIR:?}/*" - -print_test_results() { - if [ -n "$GITHUB_STEP_SUMMARY" ]; then - echo -e "### Test results\n" >> "$GITHUB_STEP_SUMMARY" - echo "| Test suite | Result | Successful | Failed | Skipped | Duration |" >> "$GITHUB_STEP_SUMMARY" - echo "|---|---|--:|--:|--:|--:|" >> "$GITHUB_STEP_SUMMARY" - sort -V "$TMPDIR/results" >> "$GITHUB_STEP_SUMMARY" - fi -} - -# Enable verbose logging of ssh commands -export GHE_VERBOSE_SSH=true - -if ! find test -name "test-*.sh" -print0 | sort -z |xargs -0 -n 1 /bin/bash; then - print_test_results - exit 1 -fi - -print_test_results diff --git a/share/github-backup-utils/bm.sh b/share/github-backup-utils/bm.sh deleted file mode 100755 index 561bcfffb..000000000 --- a/share/github-backup-utils/bm.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env bash -# bm.sh: benchmarking Bash code blocks -# -# Example: -# bm_start "wget request" -# wget --quiet https://www.google.com -# bm_end "wget request" -# -# Sample output: -# $ bash test.sh -# wget request took 2s - -bm_desc_to_varname(){ - echo "__bm$(echo "$@" | tr -cd '[[:alnum:]]')" -} - -bm_start() -{ - eval "$(bm_desc_to_varname "$@")_start=$(date +%s)" - if [ -n "$GHE_DEBUG" ]; then - echo "Debug: $1 (bm_start)" - fi - bm_init > /dev/null -} - -bm_init() { - if [ -n "$BM_FILE_PATH" ]; then - echo $BM_FILE_PATH - return - fi - - local logfile="benchmark.${BM_TIMESTAMP:-$(date +"%Y%m%dT%H%M%S")}.log" - if [ -n "$GHE_RESTORE_SNAPSHOT_PATH" ]; then - export BM_FILE_PATH=$GHE_RESTORE_SNAPSHOT_PATH/benchmarks/$logfile - else - export BM_FILE_PATH=$GHE_SNAPSHOT_DIR/benchmarks/$logfile - fi - - mkdir -p "$(dirname $BM_FILE_PATH)" - echo $BM_FILE_PATH -} - -bm_end() { - if [ -z "$BM_FILE_PATH" ]; then - echo "Call bm_start first" >&2 - exit 1 - fi - - local tend tstart total - tend=$(date +%s) - tstart=$(eval "echo \$$(bm_desc_to_varname "$@")_start") - - total=$(($tend - $tstart)) - - echo "$1 took ${total}s" >> $BM_FILE_PATH - # also log timing information in the verbose log - echo "$1 took ${total}s" 1>&3 - if [ -n "$GHE_DEBUG" ]; then - echo "Debug: $1 took ${total}s (bm_end)" - fi - # track progress - progress "$1 took ${total}s" -} diff --git a/share/github-backup-utils/ghe-backup-actions b/share/github-backup-utils/ghe-backup-actions deleted file mode 100755 index b3f51741e..000000000 --- a/share/github-backup-utils/ghe-backup-actions +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-actions -#/ Take an online, incremental snapshot of all Actions data (excluding -#/ what is stored in MSSQL) -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Set up remote host and root backup snapshot directory based on config -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") -backup_dir="$GHE_SNAPSHOT_DIR/actions" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - log_error "Error: rsync not found." 1>&2 - exit 1 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Make sure root backup dir exists if this is the first run -mkdir -p "$backup_dir" - -# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$GHE_DATA_DIR/current/actions" ] && [ "$(ls -A $GHE_DATA_DIR/current/actions)" ]; then - link_dest="--link-dest=$GHE_DATA_DIR/current/actions" -fi - -# Transfer all Actions data from the user data directory using rsync. -ghe_verbose "* Transferring Actions files from $host ..." -log_rsync "BEGIN: actions rsync" 1>&3 -ghe-rsync -av \ - -e "ghe-ssh -p $port" \ - --rsync-path='sudo -u actions rsync' \ - --exclude "mutexes" --exclude "dumps" --exclude "tmp" \ - $link_dest \ - "$host:$GHE_REMOTE_DATA_USER_DIR/actions/" \ - "$GHE_SNAPSHOT_DIR/actions" 1>&3 -log_rsync "END: actions rsync" 1>&3 - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-config b/share/github-backup-utils/ghe-backup-config deleted file mode 100755 index 30062a8f6..000000000 --- a/share/github-backup-utils/ghe-backup-config +++ /dev/null @@ -1,708 +0,0 @@ -#!/usr/bin/env bash -# Usage: . ghe-backup-config -# GitHub Enterprise backup shell configuration. -# -# This file is sourced by the various utilities under bin and share/github-backup-utils to -# load in backup configuration and ensure things are configured properly. -# -# All commands in share/github-backup-utils/ should start with the following: -# -# . $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config -# -# And all commands in bin/ should start with the following: -# -# . $( dirname "${BASH_SOURCE[0]}" )/../share/github-backup-utils/ghe-backup-config -# -set +o posix -# Terminal colors -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[0;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color - - -# Assume this script lives in share/github-backup-utils/ when setting the root -GHE_BACKUP_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" - -# Get the version from the version file. -BACKUP_UTILS_VERSION="$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/version")" - -# If a version check was requested, show the current version and exit -if [ -n "$GHE_SHOW_VERSION" ]; then - echo "GitHub backup-utils v$BACKUP_UTILS_VERSION" - exit 0 -fi - -# Check for "--help|-h" in args or GHE_SHOW_HELP=true and show usage -# shellcheck disable=SC2120 # Our arguments are optional and not meant to be the owning script's -print_usage() { - grep '^#/' <"$0" | cut -c 4- - exit "${1:-1}" -} - -if [ -n "$GHE_SHOW_HELP" ]; then - print_usage -else - for a in "$@"; do - if [ "$a" = "--help" ] || [ "$a" = "-h" ]; then - print_usage - fi - done -fi - -# Save off GHE_HOSTNAME from the environment since we want it to override the -# backup.config value when set. -GHE_HOSTNAME_PRESERVE="$GHE_HOSTNAME" - -# Source in the backup config file from the copy specified in the environment -# first and then fall back to the backup-utils root, home directory and system. -config_found=false -for f in "$GHE_BACKUP_CONFIG" "$GHE_BACKUP_ROOT/backup.config" \ - "$HOME/.github-backup-utils/backup.config" "/etc/github-backup-utils/backup.config"; do - if [ -f "$f" ]; then - GHE_BACKUP_CONFIG="$f" - # shellcheck disable=SC1090 # This is a user-supplied value that can't be predicted - . "$GHE_BACKUP_CONFIG" - config_found=true - break - fi -done - -GHE_RESTORE_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-restore") -GHE_BACKUP_IN_PROGRESS=$(readlink -fm "${GHE_DATA_DIR}/in-progress-backup") - -export GHE_RESTORE_IN_PROGRESS -export GHE_BACKUP_IN_PROGRESS - -# Logging display and formatting functions - -log_level() { - local level=$1 - shift - local message=$* - local display="" - local timestamp - timestamp=$(date -u "+%FT%TZ") - - - if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then - if [ "$level" = "info" ]; then - display="INFO" - elif [ "$level" = "warn" ]; then - display="WARN" - elif [ "$level" = "error" ]; then - display="ERROR" - elif [ "$level" = "verbose" ]; then - display="INFO" - elif [ "$level" = "rsync" ]; then - display="RSYNC" - elif [ "$level" = "ssh" ]; then - display="SSH" - else - display="-" - fi - else - if [ "$level" = "info" ]; then - display="${GREEN}INFO${NC}" - elif [ "$level" = "warn" ]; then - display="${YELLOW}WARN${NC}" - elif [ "$level" = "error" ]; then - display="${RED}ERROR${NC}" - elif [ "$level" = "verbose" ]; then - display="${GREEN}INFO${NC}" - elif [ "$level" = "rsync" ]; then - display="${GREEN}RSYNC${NC}" - elif [ "$level" = "ssh" ]; then - display="${GREEN}SSH${NC}" - else - display="-" - fi - fi - echo -e "$timestamp $display $message" -} - -log_info(){ - log_level "info" "$1" -} - -log_warn(){ - log_level "warn" "$1" -} - -log_error(){ - log_level "error" "$1" -} - -log_verbose(){ - log_level "verbose" "$1" -} - -log_rsync(){ - log_level "rsync" "$1" -} - -log_ssh(){ - log_level "ssh" "$1" -} - -# Add the bin and share/github-backup-utils dirs to PATH -PATH="$GHE_BACKUP_ROOT/bin:$GHE_BACKUP_ROOT/share/github-backup-utils:$PATH" -# shellcheck source=share/github-backup-utils/bm.sh -. "$GHE_BACKUP_ROOT/share/github-backup-utils/bm.sh" -# shellcheck source=share/github-backup-utils/ghe-incremental-backup-restore -. "$GHE_BACKUP_ROOT/share/github-backup-utils/ghe-incremental-backup-restore" -# shellcheck source=share/github-backup-utils/track-progress -. "$GHE_BACKUP_ROOT/share/github-backup-utils/track-progress" - - -ghe_restore_check() { - if [ -h "$GHE_RESTORE_IN_PROGRESS" ]; then - echo " Error: detected a restore already in progress from a previous version of ghe-restore." 1>&2 - echo " If there is no restore in progress anymore, please remove" 1>&2 - echo " the $GHE_RESTORE_IN_PROGRESS file and try again." 1>&2 - exit 1 - fi - - if [ -f "$GHE_RESTORE_IN_PROGRESS" ]; then - progress=$(cat "$GHE_RESTORE_IN_PROGRESS") - pid=$(echo "$progress" | cut -d ' ' -f 2) - echo " Error: A restore of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 - echo " If PID $pid is not a process related to the restore utilities, please remove" 1>&2 - echo " the $GHE_RESTORE_IN_PROGRESS file and try again." 1>&2 - exit 1 - fi -} - -ghe_backup_check() { - if [ -h "$GHE_BACKUP_IN_PROGRESS" ]; then - echo " Error: detected a backup already in progress from a previous version of ghe-backup." 1>&2 - echo " If there is no backup in progress anymore, please remove" 1>&2 - echo " the $GHE_DATA_DIR/$GHE_BACKUP_IN_PROGRESS file and try again." 1>&2 - exit 1 - fi - - if [ -f "$GHE_BACKUP_IN_PROGRESS" ]; then - progress=$(cat "$GHE_BACKUP_IN_PROGRESS") - pid=$(echo "$progress" | cut -d ' ' -f 2) - echo " Error: A backup of $GHE_HOSTNAME may still be running on PID $pid." 1>&2 - echo " If PID $pid is not a process related to the backup utilities, please remove" 1>&2 - echo " the $GHE_BACKUP_IN_PROGRESS file and try again." 1>&2 - exit 1 - fi -} - -ghe_restore_finished() { - if [ -f "$GHE_RESTORE_IN_PROGRESS" ]; then - rm -f "$GHE_RESTORE_IN_PROGRESS" - fi -} - -ghe_backup_finished() { - if [ -f "$GHE_BACKUP_IN_PROGRESS" ]; then - rm -f "$GHE_BACKUP_IN_PROGRESS" - fi -} - -ghe_parallel_check() { - GHE_PARALLEL_COMMAND_OPTIONS=() - GHE_PARALLEL_RSYNC_COMMAND_OPTIONS=() - - if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then - return 0 - fi - - # Some machines may have both moreutils parallel and GNU parallel installed. - # Check some variants to find it - GHE_PARALLEL_COMMAND="parallel" - local x - for x in \ - /usr/bin/parallel-moreutils \ - /usr/bin/parallel.moreutils \ - /usr/bin/parallel_moreutils \ - /usr/bin/moreutils-parallel \ - /usr/bin/moreutils.parallel \ - /usr/bin/moreutils_parallel \ - ; do - if [ -x "${x}" ]; then - GHE_PARALLEL_COMMAND="${x}" - break - fi - done - - # Check that the GHE_PARALLEL_COMMAND is pointing to moreutils parallel - if ! "$GHE_PARALLEL_COMMAND" -h | grep -q "parallel \[OPTIONS\] command -- arguments"; then - echo "Error: moreutils not found. Please install https://joeyh.name/code/moreutils" 1>&2 - exit 1 - fi - - if [ -n "$GHE_PARALLEL_MAX_JOBS" ]; then - GHE_PARALLEL_COMMAND_OPTIONS+=(-j "$GHE_PARALLEL_MAX_JOBS") - # Default to the number of max rsync jobs to the same as GHE_PARALLEL_MAX_JOBS, if not set. - # This is only applicable to ghe-restore-repositories currently. - : "${GHE_PARALLEL_RSYNC_MAX_JOBS:="$GHE_PARALLEL_MAX_JOBS"}" - fi - - if [ -n "$GHE_PARALLEL_RSYNC_MAX_JOBS" ]; then - GHE_PARALLEL_RSYNC_COMMAND_OPTIONS+=(-j "$GHE_PARALLEL_RSYNC_MAX_JOBS") - fi - - if [ -n "$GHE_PARALLEL_MAX_LOAD" ]; then - GHE_PARALLEL_COMMAND_OPTIONS+=(-l "$GHE_PARALLEL_MAX_LOAD") - GHE_PARALLEL_RSYNC_COMMAND_OPTIONS+=(-l "$GHE_PARALLEL_MAX_LOAD") - fi -} - -# Check that the config file exists before we source it in. -if ! $config_found; then - echo "Error: No backup configuration file found. Tried:" 1>&2 - [ -n "$GHE_BACKUP_CONFIG" ] && echo " - $GHE_BACKUP_CONFIG" 1>&2 - echo " - $GHE_BACKUP_ROOT/backup.config" 1>&2 - echo " - $HOME/.github-backup-utils/backup.config" 1>&2 - echo " - /etc/github-backup-utils/backup.config" 1>&2 - exit 2 -fi - -# If verbose logging is enabled, redirect fd 3 to stdout or the specified log file; -# otherwise, redirect it to /dev/null. Write verbose output to fd 3. -if [ -n "$GHE_VERBOSE" ]; then - if [ -n "$GHE_VERBOSE_LOG" ]; then - if [ "$GHE_PARALLEL_ENABLED" != "yes" ]; then - exec 3>>"$GHE_VERBOSE_LOG" - else - calling_script_name="$(caller | sed 's:.*/::')" - if [ "$TERM" = "dumb" ] || [[ "$OUTPUT_COLOR" != "yes" ]]; then - exec 3>>"$GHE_VERBOSE_LOG" - log_info "$calling_script_name $*" 1>&3 - else - # colorize the input if supported. - display_caller="${BLUE}$calling_script_name${NC}" - exec 3>>"$GHE_VERBOSE_LOG" - log_info "$display_caller $*" 1>&3 - fi - fi - else - exec 3>&1 - fi -else - exec 3>/dev/null -fi - - -# Restore saved off hostname. -[ -n "$GHE_HOSTNAME_PRESERVE" ] && GHE_HOSTNAME="$GHE_HOSTNAME_PRESERVE" - -# Check that the GHE hostname is set. -if [ -z "$GHE_HOSTNAME" ]; then - echo "Error: GHE_HOSTNAME not set in config file." 1>&2 - exit 2 -fi - -# Check that the GHE data directory is set. -if [ -z "$GHE_DATA_DIR" ]; then - echo "Error: GHE_DATA_DIR not set in config file." 1>&2 - exit 2 -fi - -# Convert the data directory path to an absolute path, basing any relative -# paths on the backup-utils root, and use readlink to canonicalize the path. -if [ "${GHE_DATA_DIR:0:1}" != "/" ]; then - GHE_DATA_DIR="$(cd "$GHE_BACKUP_ROOT" && readlink -m "$GHE_DATA_DIR")" -fi -export GHE_DATA_DIR - -# Assign the Release File path if it hasn't been provided (eg: by test suite) -: "${GHE_RELEASE_FILE:="/etc/github/enterprise-release"}" - -# Check that utils are not being run directly on GHE appliance. -if [ -f "$GHE_RELEASE_FILE" ]; then - echo "Error: Backup Utils cannot be run on the GitHub Enterprise host." 1>&2 - echo " The backup utilities should be run on a host dedicated to" 1>&2 - echo " long-term permanent storage and must have network connectivity" 1>&2 - echo " with the GitHub Enterprise appliance." 1>&2 - exit 1 -fi - -GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes} - -# Check that the data directory is set and create it if it doesn't exist. -if [ ! -d "$GHE_DATA_DIR" ] && [ "$GHE_CREATE_DATA_DIR" = "yes" ]; then - echo "Creating the backup data directory ..." 1>&3 - mkdir -p "$GHE_DATA_DIR" -fi - -if [ ! -d "$GHE_DATA_DIR" ]; then - echo "Error: GHE_DATA_DIR $GHE_DATA_DIR does not exist." >&2 - exit 8 -fi - -# Set some defaults if needed. -: "${GHE_NUM_SNAPSHOTS:=10}" - -# Generate a backup timestamp if one has not already been generated. -# We export the variable so the process group shares the same value. -: "${GHE_SNAPSHOT_TIMESTAMP:=$(date +"%Y%m%dT%H%M%S")}" -export GHE_SNAPSHOT_TIMESTAMP - -# Set the current snapshot directory to /. This is where -# all backups should be written for the current invocation. -GHE_SNAPSHOT_DIR="$GHE_DATA_DIR"/"$GHE_SNAPSHOT_TIMESTAMP" -export GHE_SNAPSHOT_DIR - -# The root filesystem location. This must be used so that tests can override -# the root as a local directory location. -: "${GHE_REMOTE_ROOT_DIR:=""}" - -# The root location of persistent data and applications on the remote side. This -# is always "/data" for GitHub instances. Use of this variable allows -# the location to be overridden in tests. -: "${GHE_REMOTE_DATA_DIR:="/data"}" - -# The root location of user data stores such as git repositories, pages sites, -# elasticsearch indices, etc. This is "/data" under 1.x filesystem layouts and -# "/data/user" under the 2.x filesystem layout. The location is adjusted -# dynamically in ghe_remote_version_config() immediately after obtaining the -# remote version. Utilities that transfer data in and out of the appliance -# should use this variable to ensure proper behavior under different versions. -: "${GHE_REMOTE_DATA_USER_DIR:="$GHE_REMOTE_DATA_DIR"}" - -# The location of the license file on the remote side. This is always -# "/data/enterprise/enterprise.ghl" for GitHub instances. Use of this variable -# allows the location to be overridden in tests. -: "${GHE_REMOTE_LICENSE_FILE:="$GHE_REMOTE_DATA_DIR/enterprise/enterprise.ghl"}" - -# The number of seconds to wait for in progress git-gc processes to complete -# before starting the sync of git data. See share/github-backup-utils/ghe-backup-repositories-rsync -# for more information. Default: 10 minutes. -: "${GHE_GIT_COOLDOWN_PERIOD:=600}" - -# Set "true" to get verbose logging of all ssh commands on stderr -: "${GHE_VERBOSE_SSH:=false}" - -# The location of the cluster configuration file on the remote side. -# This is always "/data/user/common/cluster.conf" for GitHub Cluster instances. -# Use of this variable allows the location to be overridden in tests. -: "${GHE_REMOTE_CLUSTER_CONF_FILE:="$GHE_REMOTE_DATA_DIR/user/common/cluster.conf"}" - -# The location of the file used to disable GC operations on the remote side. -: "${SYNC_IN_PROGRESS_FILE:="$GHE_REMOTE_DATA_USER_DIR/repositories/.sync_in_progress"}" - -# Base path for temporary directories and files. -: "${TMPDIR:="/tmp"}" - -# Backup cadence for MS SQL. Determines the kind of backup taken, either full, differential, -# or transaction log, based on when the last backup of that kind was taken. This defaults to -# taking a full backup once a week, a differential backup once a day, and transaction logs every -# 15 minutes. -: "${GHE_MSSQL_BACKUP_CADENCE:=10080,1440,15}" - -############################################################################### -### Dynamic remote version config - -# Adjusts remote paths based on the version of the remote appliance. This is -# called immediately after the remote version is obtained by -# ghe_remote_version_required(). Child processes inherit the values set here. -ghe_remote_version_config() { - GHE_REMOTE_DATA_USER_DIR="$GHE_REMOTE_DATA_DIR/user" - export GHE_REMOTE_DATA_DIR GHE_REMOTE_DATA_USER_DIR - export GHE_REMOTE_LICENSE_FILE -} - -############################################################################### -### Utility functions - -# Run ghe-host-check and establish the version of the remote GitHub instance in -# the exported GHE_REMOTE_VERSION variable. If the remote version has already -# been established then don't perform the host check again. Utilities in share/github-backup-utils -# that need the remote version should use this function instead of calling -# ghe-host-check directly to reduce ssh roundtrips. The top-level ghe-backup and -# ghe-restore commands establish the version for all subcommands. -# shellcheck disable=SC2120 # Our arguments are optional and not meant to be the owning script's -ghe_remote_version_required() { - if [ -z "$GHE_REMOTE_VERSION" ]; then - _out=$(ghe-host-check "$@") - echo "$_out" - _out_hostname=$(echo "$_out" | tail -n 1) - - # override hostname w/ ghe-host-check output because the port could have - # been autodetected to 122. - GHE_HOSTNAME="${_out_hostname/Connect /}" - GHE_HOSTNAME="${GHE_HOSTNAME/ OK*/}" - export GHE_HOSTNAME - - GHE_REMOTE_VERSION="${_out_hostname#*\(}" - GHE_REMOTE_VERSION="${GHE_REMOTE_VERSION%%\)*}" - export GHE_REMOTE_VERSION - - ghe_parse_remote_version "$GHE_REMOTE_VERSION" - ghe_remote_version_config "$GHE_REMOTE_VERSION" - fi - true -} - -# Parse a version string into major, minor and patch parts and echo. -ghe_parse_version() { - local version_major version_minor version_patch - - IFS=. read -r version_major version_minor version_patch _ <<<"${1#v}" - version_patch=${version_patch%%[a-zA-Z]*} - - echo "$version_major $version_minor $version_patch" -} -# Parse major, minor, and patch parts of the remote appliance version and store -# in GHE_VERSION_MAJOR, GHE_VERSION_MINOR, and GHE_VERSION_PATCH variables. All -# parts are numeric. This is called automatically from -# ghe_remote_version_required so shouldn't be used directly. -# -# Scripts use these variables to alter behavior based on what's supported on the -# appliance version. -ghe_parse_remote_version() { - # shellcheck disable=SC2046 # Word splitting is required to populate the variables - read -r GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH < <(ghe_parse_version "$1") - export GHE_VERSION_MAJOR GHE_VERSION_MINOR GHE_VERSION_PATCH -} - -# In 3.11 we started to install 2 different version parallel(s) -# moreutils parallel and GNU parallel. When gnu parallel is installed, -# it renames moreutils parallel to parallel.moreutils -# set $PARALLEL_CMD envvar to be used in place of parallel commands -ghe_remote_parallel() { - if [ -z "$GHE_REMOTE_VERSION" ]; then - echo "Error: ghe_remote_version_required needs to be invoked before ghe_remote_parallel" 1>&2 - exit 1 - fi - - if [ "$GHE_VERSION_MINOR" -lt 11 ]; then - PARALLEL_CMD="parallel" - else - PARALLEL_CMD="parallel.moreutils" - fi - export PARALLEL_CMD -} - -# Parses the part out of a ":" or just "" string. -# This is used primarily to break hostspecs with non-standard ports down for -# rsync commands. -ssh_host_part() { - [ "${1##*:}" = "$1" ] && echo "$1" || echo "${1%:*}" -} - -# Parses the part out of a ":" or just "" string. -# This is used primarily to break hostspecs with non-standard ports down for -# rsync commands. -ssh_port_part() { - if [ "${1##*:}" != "$1" ] && [ "${1##*:}" -ne "122" ]; then - echo "Error: SSH port has to be 122 connecting to GitHub Enterprise Server, current value is ${1##*:} for $1." 1>&2 - exit 1 - fi - - echo 122 -} - -# Usage: ghe_remote_logger ... -# Log a message to /var/log/syslog on the remote instance. -# Note: Use sparingly. Remote logging requires an ssh connection per invocation. -ghe_remote_logger() { - echo "$@" | - ghe-ssh "$GHE_HOSTNAME" -- logger -t backup-utils || true -} - -# Usage: ghe_verbose -# Log if verbose mode is enabled (GHE_VERBOSE or `-v`). -ghe_verbose() { - if [ -n "$GHE_VERBOSE" ]; then - log_verbose "$@" 1>&3 - fi -} - -# Usage: ghe_debug OR echo | ghe_debug -# Log if debug mode is enabled (GHE_DEBUG). -ghe_debug() { - [ -z "$GHE_DEBUG" ] && return - - if [ $# -ne 0 ]; then - echo -e "Debug: $*" 1>&3 - elif [ -p /dev/stdin ]; then - echo -e "\n" 1>&3 - while read -r line; do - echo -e "Debug: $line" 1>&3 - done /dev/null || true -} - -# The list of gists returned by the source changed in 2.16.23, 2.17.14, -# 2.18.8, and 2.19.3. We need to account for this difference here. -# In older versions, all paths need to be truncated with `dirname`. -# In newer versions, gist paths are unmodified, and only other repo types -# are truncated with `dirname`. -fix_paths_for_ghe_version() { - if [[ "$GHE_REMOTE_VERSION" =~ 2.16. && "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.16.23)" ]] || - [[ "$GHE_REMOTE_VERSION" =~ 2.17. && "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.17.14)" ]] || - [[ "$GHE_REMOTE_VERSION" =~ 2.18. && "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.18.8)" ]] || - [[ "$(version "$GHE_REMOTE_VERSION")" -ge "$(version 2.19.3)" ]]; then - GIST_FILTER=(-e "/gist/b") - else - unset GIST_FILTER - fi - - # This sed expression is equivalent to running `dirname` on each line, - # but without all the fork+exec overhead of calling `dirname` that many - # times: - # 1. strip off trailing slashes - # 2. if the result has no slashes in it, the dirname is "." - # 3. truncate from the final slash (if any) to the end - # If the GIST_FILTER was set above (because we're on a modern version of - # GHES), then don't modify lines with "gist" in them. - sed "${GIST_FILTER[@]}" -e 's/\/$//; s/^[^\/]*$/./; s/\/[^\/]*$//' -} - -is_binary_backup_feature_on() { - ghe-ssh "$GHE_HOSTNAME" ghe-config --true "mysql.backup.binary" -} - -# Check if the backup is binary by looking up the sentinel file -is_binary_backup() { - test -f "$1/mysql-binary-backup-sentinel" -} - -# Check if a given service is managed externally on the appliance or in a snapshot. -# Usage: is_service_external $service [$config_file] -# Pass in the config file to check if the service is managed externally in the snapshot. -is_service_external(){ - service=$1 - config_file=$2 - case $service in - "mysql") - if [ -n "$config_file" ]; then - enabled=$(GIT_CONFIG="$config_file" git config mysql.external.enabled) - [ "$enabled" == "true" ]; - else - ghe-ssh "$GHE_HOSTNAME" -- ghe-config --true "mysql.external.enabled" - fi - ;; - *) - return 1 - ;; - esac -} - -is_instance_configured(){ - ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/configured' ]" -} - -# Helper method that returns true if: -# - the target appliance uses the internal MySQL database (aka NOT BYODB), and -# - the snapshot being restored is from an appliance using an external MySQL database (BYODB) -external_database_snapshot_to_internal_database(){ - ! is_external_database_target && is_external_database_snapshot -} - -# Helper method that returns true if: -# - the target appliance uses an external MySQL database (BYODB), and -# - the snapshot being restored is from an appliance using an internal MySQL database (aka NOT BYODB) -internal_database_snapshot_to_external_database(){ - is_external_database_target && ! is_external_database_snapshot -} - -is_external_database_target_or_snapshot(){ - # If restoring settings, only check if the snapshot being restored was from an appliance with external DB configured. - if $RESTORE_SETTINGS; then - is_external_database_snapshot - else - # Check if restoring a snapshot with an external database configured, or restoring - # to an appliance with an external database configured. - is_external_database_snapshot || is_external_database_target - fi -} - -is_external_database_target(){ - is_service_external "mysql" -} - -is_external_database_snapshot(){ - is_service_external "mysql" "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/settings.json" -} - -# This file exists if this is a backup for an external database AND the backup was -# taken via our logical backup strategy. -is_default_external_database_snapshot(){ - is_external_database_snapshot && test -f "$GHE_DATA_DIR/$GHE_RESTORE_SNAPSHOT/logical-external-database-backup-sentinel" -} - -prompt_for_confirmation(){ - echo "$1" - printf "Type 'yes' to continue: " - - while read -r response; do - case $response in - yes|Yes|YES) - break - ;; - '') - printf "Type 'yes' to continue: " - ;; - *) - echo "Restore aborted." 1>&2 - exit 1 - ;; - esac - done - - echo -} - -#initialize progress tracking by clearing out the temp files used to track -init-progress() { - - if [ -e /tmp/backup-utils-progress ]; then - rm -rf /tmp/backup-utils-progress/* - fi - # shellcheck disable=SC2174 # We are fine with -m only affecting the deepest directory - mkdir -m 777 -p /tmp/backup-utils-progress - touch /tmp/backup-utils-progress/{total,type,progress,info} -} - - -#increase total count of progress -increment-progress-total-count() { - ((PROGRESS_TOTAL += $1)) - echo "$PROGRESS_TOTAL" > /tmp/backup-utils-progress/total -} - -## -# This function is used by ghe-gc-disable, ghe-backup-repositories, and ghe-backup-storage -# This function should be used directly to disable and drain GC operations ONLY on HA-replica node -# (as done in ghe-backup-repositories and ghe-backup-storage) -# Otherwise use ghe-gc-disable which will call this function with the correct parameters. -# -# Arguments: -# $1 - path to sync-in-progress file ($SYNC_IN_PROGRESS_FILE) -# $2 - git cooldown period ($GHE_GIT_COOLDOWN_PERIOD) -## -gc_disable() { - set -e - local sync_in_progress="$1" - local git_cooldown_period="$2" - - # Touch the sync-in-progress file, disabling GC operations, and wait for all - # active GC processes to finish on the remote side. - sudo -u git touch "$sync_in_progress" - for _ in $(seq $git_cooldown_period); do - # note: the bracket synta[x] below is to prevent matches against the - # grep process itself. - if ps axo args | grep -E -e "^git( -.*)? nw-repac[k]( |$)" -e "^git( -.*)? g[c]( |$)" >/dev/null; then - sleep 1 - else - exit 0 - fi - done - exit 7 -} diff --git a/share/github-backup-utils/ghe-backup-es-audit-log b/share/github-backup-utils/ghe-backup-es-audit-log deleted file mode 100755 index 84da8953a..000000000 --- a/share/github-backup-utils/ghe-backup-es-audit-log +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-es-audit-log -#/ Take a backup of audit logs in Elasticsearch. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Set up remote host and root elastic backup directory based on config -host="$GHE_HOSTNAME" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Make sure root backup dir exists if this is the first run -mkdir -p "$GHE_SNAPSHOT_DIR/audit-log" - -if ! indices=$(ghe-ssh "$host" "curl -s \"localhost:9201/_cat/indices/audit_log*?h=index,pri.store.size&bytes=b\""); then - log_error "ghe-backup-es-audit-log: Failed to retrieve audit log indices." 1>&2 - exit 1 -fi - -# Exit if no indices were found -[ -z "$indices" ] && exit - -# Determine if the audit log migration has occurred or is needed. -if echo 'set -o pipefail; ! test -e /data/user/common/es-scan-complete && test -f /usr/local/share/enterprise/run-audit-log-transitions.sh' | ghe-ssh "$host" /bin/bash; then - if echo 'set -o pipefail; echo n | /usr/local/share/enterprise/run-audit-log-transitions.sh > /dev/null 2>&1 && touch /data/user/common/es-scan-complete' | ghe-ssh "$host" /bin/bash; then - touch $GHE_SNAPSHOT_DIR/es-scan-complete - fi -fi - -IFS=$'\n' -for index in $indices; do - IFS=' ' - set $index - index_name=$1 - index_size=$2 - - if [[ -f $GHE_DATA_DIR/current/audit-log/$index_name.gz && $(cat $GHE_DATA_DIR/current/audit-log/$index_name.gz.size 2>/dev/null || true) -eq $index_size ]]; then - ghe_verbose "* Linking unchanged audit log index: $index_name" - # Hard link any indices that have not changed since the last backup - ln $GHE_DATA_DIR/current/audit-log/$index_name.gz $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz - ln $GHE_DATA_DIR/current/audit-log/$index_name.gz.size $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size - else - ghe_verbose "* Performing audit log export for index: $index_name" - echo "/usr/local/share/enterprise/ghe-es-dump-json \"http://localhost:9201/$index_name\" | gzip" | ghe-ssh "$host" -- /bin/bash > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz - echo $index_size > $GHE_SNAPSHOT_DIR/audit-log/$index_name.gz.size - fi -done - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-es-rsync b/share/github-backup-utils/ghe-backup-es-rsync deleted file mode 100755 index fce7043bb..000000000 --- a/share/github-backup-utils/ghe-backup-es-rsync +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-es-rsync -#/ Take an online, incremental snapshot of Elasticsearch indices. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup when the rsync strategy is used. -# shellcheck disable=SC2086 -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Set up remote host and root elastic backup directory based on config -host="$GHE_HOSTNAME" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - log_error "rsync not found." 1>&2 - exit 1 -fi - -# Make sure root backup dir exists if this is the first run -mkdir -p "$GHE_SNAPSHOT_DIR/elasticsearch" - -# Verify that the /data/elasticsearch directory exists. -if ! ghe-ssh "$host" -- "[ -d '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' ]"; then - ghe_verbose "* The '$GHE_REMOTE_DATA_USER_DIR/elasticsearch' directory doesn't exist." - exit 0 -fi - -# If we have a previous increment, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$GHE_DATA_DIR/current/elasticsearch" ]; then - link_dest="--link-dest=../../current/elasticsearch" -fi - -# Transfer ES indices from a GitHub instance to the current snapshot -# directory, using a previous snapshot to avoid transferring files that have -# already been transferred. -ghe_verbose "* Performing initial sync of ES indices ..." -log_rsync "BEGIN elasticsearch rsync" 1>&3 -ghe-rsync -av \ - -e "ghe-ssh -p $(ssh_port_part "$host")" \ - --rsync-path="sudo -u elasticsearch rsync" \ - $link_dest \ - "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ - "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 -log_rsync "END elasticsearch rsync" 1>&3 -# Set up a trap to re-enable flushing on exit and remove temp file -cleanup () { - ghe_verbose "* Enabling ES index flushing ..." - echo '{"index":{"translog.flush_threshold_size":"512MB"}}' | - ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null -} -trap 'cleanup' EXIT -trap 'exit $?' INT # ^C always terminate - -# Disable ES flushing and force a flush right now -ghe_verbose "* Disabling ES index flushing ..." -echo '{"index":{"translog.flush_threshold_size":"1PB"}}' | -ghe-ssh "$host" -- curl -s -XPUT "localhost:9200/_settings" -d @- >/dev/null -ghe-ssh "$host" -- curl -s -XPOST "localhost:9200/_flush" >/dev/null - -# Transfer all ES indices again -ghe_verbose "* Performing follow-up sync of ES indices ..." -log_rsync "BEGIN: elasticsearch followup rsync" 1>&3 -ghe-rsync -av \ - -e "ghe-ssh -p $(ssh_port_part "$host")" \ - --rsync-path="sudo -u elasticsearch rsync" \ - $link_dest \ - "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/elasticsearch/" \ - "$GHE_SNAPSHOT_DIR/elasticsearch" 1>&3 -log_rsync "END: elasticsearch followup rsync" 1>&3 - -# "Backup" audit log migration sentinel file -if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/es-scan-complete"; then - touch $GHE_SNAPSHOT_DIR/es-scan-complete -fi - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-fsck b/share/github-backup-utils/ghe-backup-fsck deleted file mode 100755 index d255e036f..000000000 --- a/share/github-backup-utils/ghe-backup-fsck +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-fsck [--print-nwo] -#/ -#/ Run git fsck on backed up repositories. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -echo "Running git fsck on repos..." - -# Verify git is available. -if ! git --version 1>/dev/null 2>&1; then - log_error "git not found." 1>&2 - exit 1 -fi - -sdir=$1 -repos=0 -errors=0 -log=$(mktemp -t ghe-backup-fsck-XXXXXX) -t_start=$(date +%s) -if git fsck -h | grep -q '\-\-dangling'; then - git_cmd='git fsck --no-dangling' -else - log_warn "ghe-backup-fsck: old git version, --no-dangling not available" 1>&3 - git_cmd='git fsck' -fi - -if [ -z "$sdir" ] || [ ! -d "$sdir" ]; then - print_usage -fi - -if [ ! -d "$sdir/repositories" ]; then - log_error "ghe-backup-fsck: $sdir is not a valid snapshot." >&2 - exit 1 -fi - -# shellcheck disable=SC2044 # Snapshot and repository directory names are safe for find iteration. -for repo in $(find $sdir/repositories/ -type d -name \*.git); do - repos=$(($repos+1)) - before_time=$(date +%s) - - status=$( - set -e - - cd $repo - - nwo="-" - if [ "$2" = "--print-nwo" ] && [ -f info/nwo ]; then - nwo="$(cat info/nwo)" - fi - - if [ ! -f objects/info/alternates ] || grep -q '^\.\.' objects/info/alternates; then - $git_cmd >$log 2>&1 && { - echo "OK $repo $nwo"; exit - } - else - GIT_ALTERNATE_OBJECT_DIRECTORIES=../network.git/objects $git_cmd >$log 2>&1 && { - echo "WARN $repo $nwo (alternates absolute path)"; exit - } - fi - - echo "ERROR $repo $nwo" - ) - - elapsed_time=$(($(date +%s) - before_time)) - - if [[ ! "$status" =~ ^OK ]] || [ $elapsed_time -gt 5 ]; then - echo "$status ${elapsed_time}s" 1>&3 - [ -n "$GHE_VERBOSE" ] && cat $log - fi - - case "$status" in - OK*) - ;; - ERROR*) - errors=$(($errors+1)) - ;; - esac - -done - -log_info "* Repos verified: $repos, Errors: $errors, Took: $(($(date +%s) - $t_start))s" - -rm -f $log - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-git-hooks b/share/github-backup-utils/ghe-backup-git-hooks deleted file mode 100755 index 1763501c7..000000000 --- a/share/github-backup-utils/ghe-backup-git-hooks +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-git-hooks -#/ Take an online, incremental snapshot of custom Git hooks configuration. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - log_error "rsync not found." 1>&2 - exit 1 -fi - -backup_dir="$GHE_SNAPSHOT_DIR/git-hooks" -# Location of last good backup for rsync --link-dest -backup_current="$GHE_DATA_DIR/current/git-hooks" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$host -ssh_config_file_opt= -tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -opts="$GHE_EXTRA_SSH_OPTS" - -# git server hostnames under cluster -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") - ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" -fi - -# Removes the remote sync-in-progress file on exit, re-enabling GC operations -# on the remote instance. -cleanup() { - rm -rf $tempdir -} -trap 'cleanup' EXIT -trap 'exit $?' INT # ^C always terminate - -# Transfer Git hooks data from a GitHub instance to the current snapshot -# directory, using a previous snapshot to avoid transferring files that have -# already been transferred. A set of rsync filter rules are provided on stdin -# for each invocation. -rsync_git_hooks_data () { - port=$(ssh_port_part "$1") - host=$(ssh_host_part "$1") - - subpath=$2 - shift 2 - - # If we have a previous increment and it is not empty, avoid transferring existing files via rsync's - # --link-dest support. This also decreases physical space usage considerably. - if [ -d "$backup_current/$subpath" ] && [ "$(ls -A $backup_current/$subpath)" ]; then - subdir="git-hooks/$subpath" - link_path=".." - while true; do - if [ "$(dirname $subdir)" = "." ]; then - break - fi - - if [ "$(dirname $subdir)" = "/" ]; then - break - fi - - link_path="../$link_path" - subdir=$(dirname $subdir) - done - - local link_dest="--link-dest=../${link_path}/current/git-hooks/$subpath" - fi - - # Ensure target directory exists, is needed with subdirectories - mkdir -p "$backup_dir/$subpath" - log_rsync "BEGIN: git-hooks sync" 1>&3 - ghe-rsync -av \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" $link_dest \ - --rsync-path='sudo -u git rsync' \ - "$host:$GHE_REMOTE_DATA_USER_DIR/git-hooks/$subpath/" \ - "$backup_dir/$subpath" 1>&3 - log_rsync "END: git-hooks sync" 1>&3 -} - -hostname=$(echo $hostnames | awk '{ print $1; }') -if ghe-ssh $ssh_config_file_opt "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/environments/tarballs' ]"; then - rsync_git_hooks_data $hostname:122 environments/tarballs -else - ghe_verbose "git-hooks environment tarballs not found. Skipping ..." -fi - -if ghe-ssh $ssh_config_file_opt "$hostname:122" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/git-hooks/repos' ]"; then - rsync_git_hooks_data $hostname:122 repos -else - ghe_verbose "git-hooks repositories not found. Skipping ..." -fi - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-minio b/share/github-backup-utils/ghe-backup-minio deleted file mode 100755 index bf7a429d4..000000000 --- a/share/github-backup-utils/ghe-backup-minio +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-minio -#/ Take an online, incremental snapshot of all minio data -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$(dirname "${BASH_SOURCE[0]}")/ghe-backup-config" - -bm_start "$(basename "${0}")" - -# Set up remote host and root backup snapshot directory based on config -port="$(ssh_port_part "${GHE_HOSTNAME}")" -host="$(ssh_host_part "${GHE_HOSTNAME}")" -backup_dir="${GHE_SNAPSHOT_DIR}/minio" - -# Verify rsync is available. -if ! command -v rsync 1> /dev/null 2>&1; then - log_error "rsync not found." 1>&2 - exit 1 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "${host}" - -# Make sure root backup dir exists if this is the first run -mkdir -p "${backup_dir}" - -# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -# Hilariously, this HAS to stay unquoted when you call `rsync` further -# down because when the shell interpolates this out, `rsync` will throw -# an absolute fit if this variable is quoted. Surprise! -if [[ -d "${GHE_DATA_DIR}/current/minio" ]] && - [[ "$(ls -A "${GHE_DATA_DIR}/current/minio")" ]]; then - link_dest="--link-dest=${GHE_DATA_DIR}/current/minio" -fi - -# Transfer all minio data from the user data directory using rsync. -ghe_verbose "* Transferring minio files from ${host} ..." -log_rsync "BEGIN: minio rsync" 1>&3 -ghe-rsync \ - --archive \ - --verbose \ - --rsh="ghe-ssh -p ${port}" \ - --rsync-path='sudo -u minio rsync' \ - --exclude=".minio.sys" \ - ${link_dest} \ - "${host}:${GHE_REMOTE_DATA_USER_DIR}/minio/" \ - "${GHE_SNAPSHOT_DIR}/minio" 1>&3 -log_rsync "END: minio rsync" 1>&3 -bm_end "$(basename "${0}")" diff --git a/share/github-backup-utils/ghe-backup-mssql b/share/github-backup-utils/ghe-backup-mssql deleted file mode 100755 index 0975dea11..000000000 --- a/share/github-backup-utils/ghe-backup-mssql +++ /dev/null @@ -1,363 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-mssql -#/ -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Set up remote host and root backup snapshot directory based on config -backup_dir="$GHE_SNAPSHOT_DIR/mssql" -last_mssql= -backup_command= -backup_type= -full_expire= -diff_expire= -tran_expire= - -# Check if the export tool is available in this version -export_tool_available() { - if [ -z "$GHE_TEST_REMOTE_VERSION" ]; then - ghe_ssh_mssql "test -e /usr/local/bin/ghe-export-mssql" - else - # Always return available for test - return 0 - fi -} - -ghe_ssh_mssql() { - ghe-ssh "${opts[@]}" "${ssh_config_file_opt[@]}" "$GHE_MSSQL_PRIMARY_HOST" "$@" -} - -cleanup() { - rm -rf "$tempdir" -} -trap 'cleanup' EXIT INT - -# use the mssql primary host if GHES cluster configuration contains a mssql-master or use the ghe server if the mssql-master is not available. -GHE_MSSQL_PRIMARY_NODE="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.mssql-master" || true)" -GHE_MSSQL_PRIMARY_HOST="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.$GHE_MSSQL_PRIMARY_NODE.hostname" || true)" - -if [ -z "$GHE_MSSQL_PRIMARY_HOST" ]; then - GHE_MSSQL_PRIMARY_HOST="$GHE_HOSTNAME" -fi - -tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) -ssh_config_file_opt=() -opts=() - -isHA="$(ghe-ssh "$GHE_HOSTNAME" -- "ghe-config cluster.ha" || true)" - -# get server hostnames under cluster and HA -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ] || [ "$isHA" = "true" ] ; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt=("-F" "$ssh_config_file") - opts=("-o" "UserKnownHostsFile=/dev/null" "-o" "StrictHostKeyChecking=no" "-o" "PasswordAuthentication=no") - ghe-ssh-config "$GHE_HOSTNAME" "$GHE_MSSQL_PRIMARY_HOST" > "$ssh_config_file" -fi - -if ! export_tool_available ; then - log_error "ghe-export-mssql is not available" 1>&2 - exit 1 -fi - -add_minute() { - # Expect date string in the format of yyyymmddTHHMMSS - # Here parse date differently depending on GNU Linux vs BSD MacOS - if date -v -1d > /dev/null 2>&1; then - date -v +"$2"M -ujf'%Y%m%dT%H%M%S' "$1" +%Y%m%dT%H%M%S - else - dt=$1 - date -u '+%Y%m%dT%H%M%S' -d "${dt:0:8} ${dt:9:2}:${dt:11:2}:${dt:13:2} $2 minutes" - fi -} - -find_timestamp() { - filename="${1##*/}" - IFS='@' read -ra parts <<< "$filename" - datetime_part=${parts[1]:0:15} - echo "$datetime_part" -} - -actions_dbs() { - all_dbs=$(echo 'set -o pipefail; ghe-mssql-console -y -n -q "SET NOCOUNT ON; SELECT name FROM sys.databases"' | ghe_ssh_mssql /bin/bash) - for db in $all_dbs; do - if [[ ! "$db" =~ ^(master|tempdb|model|msdb)$ ]] && [[ "$db" =~ ^[a-zA-Z0-9_-]+$ ]]; then - echo "$db" - fi - done -} - -ensure_same_dbs() { - locals=() - while read -r file; do - filename=$(basename "$file") - locals+=("$filename") - done < <(find "$1" \( -name "*.bak" -o -name "*.diff" -o -name "*.log" \)) - - for remote in $(actions_dbs); do - remaining_locals=() - for local in "${locals[@]}"; do - if ! [[ "$local" == "$remote"* ]]; then - remaining_locals+=("$local") - fi - done - locals=("${remaining_locals[@]}") - done - - if [[ "${#locals[@]}" -ne 0 ]]; then - log_warn "Warning: Found following ${#locals[@]} backup files that can't be traced back to the specified GHES host." - log_warn "Warning: Did you recently reconfigure the GHES host? Move or delete these backup files if no longer needed." - for local in "${locals[@]}"; do - ghe_verbose "$1/$local" - done - - exit 1 - fi -} - -run_query() { - echo "set -o pipefail; ghe-mssql-console -y -n -q \"SET NOCOUNT ON; $1\"" | ghe_ssh_mssql /bin/bash | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' -} - -get_latest_backup_file() { - backups_dir=$1 - db=$2 - ext=$3 - - latest_full_backup=$(find "$backups_dir" -type f -name "$db*.$ext" | grep -E '[0-9]{8}T[0-9]{6}' | sort | tail -n 1) - latest_full_backup_file="${latest_full_backup##*/}" - echo "$latest_full_backup_file" -} - -get_backup_val() { - db=$1 - filename=$2 - column=$3 - run_query " - SELECT s.$column - FROM msdb.dbo.backupset s - JOIN msdb.dbo.backupmediafamily f - ON s.media_set_id = f.media_set_id - WHERE s.database_name = '$db' AND f.physical_device_name LIKE '%$filename'" -} - -get_backup_checkpoint_lsn() { - get_backup_val "$1" "$2" "checkpoint_lsn" -} - -get_backup_last_lsn() { - get_backup_val "$1" "$2" "last_lsn" -} - -get_next_log_backup_starting_lsn() { - db=$1 - # last_log_backup_lsn: The starting log sequence number of the next log backup - # https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-database-recovery-status-transact-sql - run_query " - SELECT last_log_backup_lsn - FROM sys.database_recovery_status drs - JOIN sys.databases db on drs.database_id = db.database_id - WHERE db.name = '$db'" -} - -get_next_diff_backup_base_lsn() { - db=$1 - # differential_base_lsn: Base for differential backups. Data extents changed after this LSN will be included in a differential backup. - # https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-master-files-transact-sql - run_query " - SELECT differential_base_lsn - FROM sys.master_files mf - WHERE mf.name = '$db'" -} - -last_mssql=$GHE_DATA_DIR/current/mssql - -if [ ! -d "$last_mssql" ] \ - || [ -z "$(find "$last_mssql" -type f -name '*.bak' | head -n 1)" ]; then - ghe_verbose "Taking first full backup" - backup_type="full" -else - ensure_same_dbs "$last_mssql" - - # Check schedule to determine backup type - IFS=',' read -ra cadence <<< "$GHE_MSSQL_BACKUP_CADENCE" - - current=$(date -u +%Y%m%d%H%M%S) - - full=$(find "$last_mssql" -type f -name "*.bak" | head -n 1) - full=$(find_timestamp "$full") - full_expire=$(add_minute "$full" "${cadence[0]}") - full_expire="${full_expire//T}" - - diff=$(find "$last_mssql" -type f -name "*.diff" | head -n 1) - if [ -f "$diff" ]; then - diff=$(find_timestamp "$diff") - diff_expire=$(add_minute "$diff" "${cadence[1]}") - diff_expire="${diff_expire//T}" - else - diff_expire=$(add_minute "$full" "${cadence[1]}") - diff_expire="${diff_expire//T}" - fi - - tran=$(find "$last_mssql" -type f -name "*.log" | grep -E '[0-9]{8}T[0-9]{6}' | sort | tail -1) - tran=$(find_timestamp "$tran") - tran_expire=$(add_minute "$tran" "${cadence[2]}") - tran_expire="${tran_expire//T}" - - ghe_verbose "current $current, full expire $full_expire, \ -diff expire $diff_expire, tran expire $tran_expire" - - # Determine the type of backup to take based on expiry time - if [ "$current" -gt "$full_expire" ]; then - backup_type='full' - elif [ "$current" -gt "$diff_expire" ]; then - backup_type='diff' - elif [ "$current" -gt "$tran_expire" ]; then - backup_type='transaction' - fi - - # Upgrade to a full backup if the diff/transaction backup might not be restorable due to other backup mechanisms interfering - # with the transaction LSN chain or differential base LSN. - if [ "$backup_type" == 'diff' ] || [ "$backup_type" == 'transaction' ]; then - ghe_verbose "Checking for conflicting backups to ensure a $backup_type backup is sufficient" - - for db in $(actions_dbs); do - # Ensure that a diff backup will be based on the full backup file we have (rather than one another backup mechanism took) - if [ "$backup_type" == 'diff' ]; then - full_backup_file=$(get_latest_backup_file "$last_mssql" "$db" "bak") - if [[ "$full_backup_file" == "" ]]; then - log_warn "Taking a full backup instead of a diff backup because for $db a full backup file wasn't found" - backup_type="full" - break - fi - - full_backup_file_checkpoint_lsn=$(get_backup_checkpoint_lsn "$db" "$full_backup_file") - if [[ "$full_backup_file_checkpoint_lsn" = "NULL" ]] || [[ "$full_backup_file_checkpoint_lsn" == "" ]]; then - log_warn "Taking a full backup instead of a diff backup because for $db the checkpoint LSN for $full_backup_file couldn't be determined" - backup_type="full" - break - fi - - next_diff_backup_base_lsn=$(get_next_diff_backup_base_lsn "$db") - if [[ "$next_diff_backup_base_lsn" = "NULL" ]] || [[ "$next_diff_backup_base_lsn" == "" ]]; then - log_warn "Taking a full backup instead of a $backup_type backup because for $db the base LSN for the next diff backup couldn't be determined" - backup_type="full" - break - fi - - # The base of the diff backup we're about to take must exactly match the checkpoint LSN of the full backup file we have - if [[ "$next_diff_backup_base_lsn" -ne "$full_backup_file_checkpoint_lsn" ]]; then - log_warn "Taking a full backup instead of a $backup_type backup because for $db the diff would have base LSN $next_diff_backup_base_lsn yet our full backup has checkpoint LSN $full_backup_file_checkpoint_lsn" - backup_type="full" - break - fi - fi - - # Ensure that a transaction log backup will immediately follow the previous one - latest_log_backup_file=$(get_latest_backup_file "$last_mssql" "$db" "log") - if [[ "$latest_log_backup_file" == "" ]]; then - log_warn "Taking a full backup instead of a $backup_type backup because for $db a previous transaction log backup wasn't found" - backup_type="full" - break - fi - - latest_log_backup_last_lsn=$(get_backup_last_lsn "$db" "$latest_log_backup_file") - if [[ "$latest_log_backup_last_lsn" = "NULL" ]] || [[ "$latest_log_backup_last_lsn" == "" ]]; then - log_warn "Taking a full backup instead of a $backup_type backup because for $db the LSN range for $latest_log_backup_file couldn't be determined" - backup_type="full" - break - fi - - next_log_backup_starting_lsn=$(get_next_log_backup_starting_lsn "$db") - if [[ "$next_log_backup_starting_lsn" = "NULL" ]] || [[ "$next_log_backup_starting_lsn" == "" ]]; then - log_warn "Taking a full backup instead of a $backup_type backup because for $db the starting LSN for the next log backup couldn't be determined" - backup_type="full" - break - fi - - # The starting LSN of the backup we're about to take must be equal to (or before) the last LSN from the last backup, - # otherwise there'll be a gap and the logfiles won't be restorable - if [[ "$next_log_backup_starting_lsn" -gt "$latest_log_backup_last_lsn" ]]; then - log_warn "Taking a full backup instead of a $backup_type backup because for $db a gap would exist between the last backup ending at LSN $latest_log_backup_last_lsn and next backup starting at $next_log_backup_starting_lsn" - backup_type="full" - break - fi - done - fi -fi - -# Make sure root backup dir exists if this is the first run -mkdir -p "$backup_dir" - -# Use hard links to "copy" over previous applicable backups to the new snapshot folder to save disk space and time -if [ -d "$last_mssql" ]; then - for p in "$last_mssql"/* - do - [[ -e "$p" ]] || break - - filename="${p##*/}" - extension="${filename##*.}" - transfer= - - # Copy full backups unless we're taking a new full backup - if [ "$extension" = "bak" ] && [ "$backup_type" != 'full' ]; then - transfer=1 - fi - - # Copy diff backups unless we're taking a new full or diff backup - if [ "$extension" = "diff" ] && [ "$backup_type" != 'full' ] && [ "$backup_type" != 'diff' ]; then - transfer=1 - fi - - # Copy transaction log backups unless we're taking a new full or diff backup - if [ "$extension" = "log" ] && [ "$backup_type" != 'full' ] && [ "$backup_type" != 'diff' ]; then - transfer=1 - fi - - if [ -n "$transfer" ]; then - ghe_verbose "Creating hard link to $filename" - ln "$last_mssql"/"$filename" "$backup_dir"/"$filename" - fi - done -fi - -if [ -n "$backup_type" ]; then - ghe_verbose "Taking $backup_type backup" - - backup_command='ghe-export-mssql' - if [ "$backup_type" = "diff" ]; then - backup_command='ghe-export-mssql -d' - elif [ "$backup_type" = "transaction" ]; then - backup_command='ghe-export-mssql -t' - fi - - backup_failed= - - bm_start "$(basename "$0")" - # record if generating the backup failed, this will allow us to collect any backups that may have been produced, even if they are not complete they are better than nothing - ghe_ssh_mssql -- "$backup_command" || backup_failed='true' - bm_end "$(basename "$0")" - - # Configure the backup cadence on the appliance, which is used for diagnostics - ghe_ssh_mssql "ghe-config mssql.backup.cadence $GHE_MSSQL_BACKUP_CADENCE" - - # Transfer backup files from appliance to backup host - appliance_dir="$GHE_REMOTE_DATA_DIR/user/mssql/backups" - backups=$(echo "set -o pipefail; if sudo test -d \"$appliance_dir\"; then \ - sudo ls \"$appliance_dir\"; fi" | ghe_ssh_mssql /bin/bash) - for b in $backups - do - ghe_verbose "Transferring to backup host $b" - ghe_ssh_mssql "sudo cat $appliance_dir/$b" > "$backup_dir"/"$b" - done - - if [ -n "$backup_failed" ]; then - log_error 'ghe-export-mssql failed to backup at least one mssql database' 1>&2 - exit 1 - fi -fi diff --git a/share/github-backup-utils/ghe-backup-mysql b/share/github-backup-utils/ghe-backup-mysql deleted file mode 100755 index 733051bc4..000000000 --- a/share/github-backup-utils/ghe-backup-mysql +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-mysql -#/ Backup MySQL from a GitHub instance. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup command. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. -ghe_remote_version_required "$GHE_HOSTNAME" - -if is_external_database_target; then - if [ -n "$EXTERNAL_DATABASE_BACKUP_SCRIPT" ]; then - log_info "Backing up external MySQL database using customer-provided script..." - $EXTERNAL_DATABASE_BACKUP_SCRIPT - bm_end "$(basename $0)" - exit 0 - else - if is_binary_backup_feature_on; then - log_warn "Binary backups are configured on the target environment." - log_warn "Binary backup is not supported with an external MySQL database. Backing up using logical backup strategy. Please disable binary backups with 'ghe-config mysql.backup.binary false', or provide a custom backup script using EXTERNAL_DATABASE_BACKUP_SCRIPT" - fi - - ghe-backup-mysql-logical - fi -else - if is_binary_backup_feature_on; then - ghe-backup-mysql-binary - else - # if incremental backups are turned on, we can't do them with - # logical backups, so we need to tell the user and exit - is_inc=$(is_incremental_backup_feature_on) - if [ $is_inc = true ]; then - log_warn "Incremental backups are configured on the target environment." - log_warn "Incremental backup is not supported with a logical MySQL backup. Please disable incremental backups with 'ghe-config mysql.backup.incremental false'" - exit 1 - fi - ghe-backup-mysql-logical - fi -fi - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-mysql-binary b/share/github-backup-utils/ghe-backup-mysql-binary deleted file mode 100755 index 106757c71..000000000 --- a/share/github-backup-utils/ghe-backup-mysql-binary +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-mysql-binary -#/ Backup MySQL from a GitHub instance using binary backup strategy. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup command. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. -ghe_remote_version_required "$GHE_HOSTNAME" - -log_verbose "Backing up MySQL database using binary backup strategy ..." -is_inc=$(is_incremental_backup_feature_on) -if [ $is_inc = true ]; then - log_verbose "Incremental backups are configured on the target environment." - log_info "Performing incremental backup of MySQL database ..." 1>&3 - INC_TYPE=$(full_or_incremental_backup) - INC_LSN="" - if [ "$INC_TYPE" == "full" ]; then - log_info "Incremental backup type: $INC_TYPE" 1>&3 - INC_LSN=0 # 0 means full backup - else - validate_inc_snapshot_data - log_info "Incremental backup type: $INC_TYPE" 1>&3 - INC_LSN=$(retrieve_last_lsn) - fi - echo "set -o pipefail; env INC_BACKUP=$INC_LSN ghe-export-mysql" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" - echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" - # Ensure that we capture the xtrabackup_checkpoints file from the remote host - log_info "Checking if incremental backup is part of a cluster" - GET_LSN=$(get_cluster_lsn "$GHE_HOSTNAME") - ghe-ssh "$GHE_HOSTNAME" "$GET_LSN" > "$GHE_SNAPSHOT_DIR/xtrabackup_checkpoints" - if [ "$INC_TYPE" == "full" ]; then - log_info "Adding $GHE_SNAPSHOT_DIR to the list of full backups" 1>&3 - update_inc_full_backup "$GHE_SNAPSHOT_DIR" - else - log_info "Adding $GHE_SNAPSHOT_DIR to the list of incremental backups" 1>&3 - update_inc_snapshot_data "$GHE_SNAPSHOT_DIR" - fi - bm_end "$(basename $0)" - exit 0 -fi -# if incremental backup isn't enabled, or we are performing a full backup as part of the process, -# fall through and do a full backup - echo "set -o pipefail; ghe-export-mysql" | - ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" - echo "NO_ADDITIONAL_COMPRESSION" > "$GHE_SNAPSHOT_DIR/mysql-binary-backup-sentinel" - is_inc=$(is_incremental_backup_feature_on) - if [ $is_inc = true ]; then - update_inc_full_backup "$GHE_SNAPSHOT_DIR" - fi -bm_end "$(basename $0)" - diff --git a/share/github-backup-utils/ghe-backup-mysql-logical b/share/github-backup-utils/ghe-backup-mysql-logical deleted file mode 100755 index 77040b8b9..000000000 --- a/share/github-backup-utils/ghe-backup-mysql-logical +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-mysql-logical -#/ Backup MySQL from a GitHub instance using logical backup strategy. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup command. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Perform a host-check and establish the remote version in GHE_REMOTE_VERSION. -ghe_remote_version_required "$GHE_HOSTNAME" - -log_verbose "Backing up MySQL database using logical backup strategy ..." - -echo "set -o pipefail; ghe-export-mysql | pigz" | -ghe-ssh "$GHE_HOSTNAME" -- /bin/bash > "$GHE_SNAPSHOT_DIR/mysql.sql.gz" - -if is_external_database_target; then - echo "LOGICAL_EXTERNAL_BACKUP" > "$GHE_SNAPSHOT_DIR/logical-external-database-backup-sentinel" -fi - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-pages b/share/github-backup-utils/ghe-backup-pages deleted file mode 100755 index 2b79825cf..000000000 --- a/share/github-backup-utils/ghe-backup-pages +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-pages -#/ Take an online, incremental snapshot of all Pages data -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Set up remote host and root backup snapshot directory based on config -host="$GHE_HOSTNAME" -backup_dir="$GHE_SNAPSHOT_DIR/pages" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - log_error "rsync not found." 1>&2 - exit 1 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$host -ssh_config_file_opt= -tempdir=$(mktemp -d -t backup-utils-restore-XXXXXX) -opts="$GHE_EXTRA_SSH_OPTS" - -# Pages server hostnames under cluster -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "pages-server") - ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" -fi - -# Make sure root backup dir exists if this is the first run -mkdir -p "$backup_dir" - -# Removes the remote sync-in-progress file on exit, re-enabling GC operations -# on the remote instance. -cleanup() { - rm -rf $tempdir -} -trap 'cleanup' EXIT INT - -# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$GHE_DATA_DIR/current/pages" ] && [ "$(ls -A $GHE_DATA_DIR/current/pages)" ]; then - link_dest="--link-dest=../../current/pages" -fi - -count=0 -for hostname in $hostnames; do - bm_start "$(basename $0) - $hostname" - echo 1>&3 - ghe_verbose "* Starting backup for host: $hostname" - # Sync all auxiliary repository data. This includes files and directories like - # HEAD, audit_log, config, description, info/, etc. No refs or object data - # should be transferred here. - echo 1>&3 - ghe_verbose "* Transferring pages files ..." - log_rsync "BEGIN: pages rsync" 1>&3 - # Transfer all data from the user data directory using rsync. - ghe-rsync -av \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - --rsync-path='sudo -u git rsync' \ - $link_dest \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/pages/" \ - "$GHE_SNAPSHOT_DIR/pages" 1>&3 - log_rsync "END: pages rsync" 1>&3 - bm_end "$(basename $0) - $hostname" - count=$((count + 1)) -done -increment-progress-total-count $count -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-redis b/share/github-backup-utils/ghe-backup-redis deleted file mode 100755 index b0eb44949..000000000 --- a/share/github-backup-utils/ghe-backup-redis +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-redis -#/ Take a snapshot of all Redis data. This is needed because older versions of -#/ the remote side ghe-export-redis command use a blocking SAVE instead of a -#/ non-blocking BGSAVE. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup command. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$GHE_HOSTNAME" - -# Force a redis BGSAVE, and wait for it to complete. -ghe-ssh "$GHE_HOSTNAME" /bin/bash < /dev/null; then - redis_cli=ghe-redis-cli - redis_arg=--remote - else - redis_cli=redis-cli - redis_arg= - fi - redis_host=\$(ghe-config cluster.redis-master 2>/dev/null || echo "localhost") - timestamp=\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE) - - for i in \$(seq 10); do - if ! \$redis_cli \$redis_arg -h \$redis_host BGSAVE | grep -q ERR; then - break - fi - sleep 15 - done - for n in \$(seq 3600); do - if [ "\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE)" != "\$timestamp" ]; then - break - fi - sleep 1 - done - [ "\$(\$redis_cli \$redis_arg -h \$redis_host LASTSAVE)" != "\$timestamp" ] # exits 1 if bgsave didn't work - - if [ "\$redis_host" != "localhost" ]; then - ssh \$redis_host sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' - else - sudo cat '$GHE_REMOTE_DATA_USER_DIR/redis/dump.rdb' - fi -EOF - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-repositories b/share/github-backup-utils/ghe-backup-repositories deleted file mode 100755 index 4e142e29f..000000000 --- a/share/github-backup-utils/ghe-backup-repositories +++ /dev/null @@ -1,407 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-repositories -#/ Take an online, incremental snapshot of all Git repository data. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# This command is designed to allow for transferring active Git repository data -# from a GitHub instance to a backup site in a way that ensures data is -# captured in a consistent state even when being written to. -# -# - All Git GC operations are disabled on the GitHub instance for the duration of -# the backup. This removes the possibly of objects or packs being removed -# while the backup is in progress. -# -# - In progress Git GC operations are given a cooldown window to complete. The -# script will sleep for up to 60 seconds waiting for GC operations to finish. -# -# - Git repository data is transferred in a specific order: auxiliary files, -# packed refs, loose refs, reflogs, and finally objects and pack files in that -# order. This ensures that all referenced objects are captured. -# -# - Git GC operations are re-enabled on the GitHub instance. -# -# The script uses multiple runs of rsync to transfer repository files. Each run -# includes a list of filter rules that ensure only specific types of files are -# transferred. -# -# See the "FILTER RULES" and "INCLUDE/EXCLUDE PATTERN RULES" sections of the -# rsync(1) manual for more information: -# - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Set up remote host and root backup snapshot directory based on config -host="$GHE_HOSTNAME" -backup_dir="$GHE_SNAPSHOT_DIR/repositories" - -# Location of last good backup for rsync --link-dest -backup_current="$GHE_DATA_DIR/current/repositories" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - log_error "rsync not found." 1>&2 - exit 1 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$host -ssh_config_file_opt= -tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) -remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-backup-XXXXXX) -routes_list=$tempdir/routes_list -remote_routes_list=$remote_tempdir/remote_routes_list -opts="$GHE_EXTRA_SSH_OPTS" - -# git server hostnames under cluster -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "git-server") - ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" -fi - -# Replica hostnames for HA -if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - ha_replica_hosts=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes --replica) -fi - -# Make sure root backup dir exists if this is the first run -mkdir -p "$backup_dir" - -# Removes the remote sync-in-progress file on exit, re-enabling GC operations -# on the remote instance. -cleanup() { - for pid in $(jobs -p); do - kill -KILL $pid > /dev/null 2>&1 || true - done - - # Enable remote GC operations - for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port || { - echo "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 - } - done - - # Enable remote GC operations for HA replica - for replica_host in $ha_replica_hosts; do - echo "set -o pipefail; ssh $replica_host -- 'sudo rm -f $SYNC_IN_PROGRESS_FILE'" | ghe-ssh "$host" /bin/bash || { - echo "Re-enable gc on $replica_host failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 - } - done - - ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir - rm -rf $tempdir -} -trap 'cleanup' EXIT INT - -# Disable remote GC operations -for hostname in $hostnames; do - ghe-gc-disable $ssh_config_file_opt $hostname:$port -done - -# Disable remote GC operations for HA replica -# gc_disable is a function defined in ghe-backup-config -# gc_disable is called on the replica node via the primary node, because replica node is not expected to be reachable from backup host. But replica node is expected to be reachable from primary node. -for replica_host in $ha_replica_hosts; do - echo "set -o pipefail; ssh $replica_host -- '$(declare -f gc_disable); gc_disable \"$SYNC_IN_PROGRESS_FILE\" \"$GHE_GIT_COOLDOWN_PERIOD\"'" | ghe-ssh "$host" /bin/bash || { - echo "Disable gc on $replica_host failed" 1>&2 - } -done - -# If we have a previous increment, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$backup_current" ]; then - link_dest="--link-dest=../../current/repositories" -fi - -# Calculate sync routes. This will store the healthy repo paths for each node -# -# This gets a repo path and stores the path in the $node.sync file -# a/nw/a8/3f/02/100000855 dgit-node1 >> dgit-node1.sync -# a/nw/a8/bc/8d/100000880 dgit-node3 >> dgit-node3.sync -# a/nw/a5/06/81/100000659 dgit-node2 >> dgit-node2.sync -# ... -# One route per line. -# -# NOTE: The route generation is performed on the appliance as it is considerably -# more performant than performing over an SSH pipe. -# -bm_start "$(basename $0) - Generating routes" -echo "github-env ./bin/dgit-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug -bm_end "$(basename $0) - Generating routes" - -bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list -< $routes_list ghe_debug -bm_end "$(basename $0) - Fetching routes" - -bm_start "$(basename $0) - Processing routes" -if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then - server=$host -fi -< $routes_list awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' -ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" -bm_end "$(basename $0) - Processing routes" - -if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - log_warn "no routes found, skipping repositories backup ..." - exit 0 -else - increment-progress-total-count 3 -fi - -# Transfer repository data from a GitHub instance to the current snapshot -# directory, using a previous snapshot to avoid transferring files that have -# already been transferred. A set of rsync filter rules are provided on stdin -# for each invocation. -rsync_repository_data () { - port=$(ssh_port_part "$1") - host=$(ssh_host_part "$1") - - #check if we are syncing from a given file list - if [[ "$2" == *".rsync" ]]; then - files_list="$2" - shift - shift - log_rsync "BEGIN: repositories rsync" 1>&3 - ghe-rsync -avr \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --include-from=- --exclude=\* \ - --files-from="$files_list" \ - --ignore-missing-args \ - "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 2>&3 - log_rsync "END: repositories rsync" 1>&3 - else - shift - log_rsync "BEGIN: repositories rsync" 1>&3 - ghe-rsync -avr \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - $link_dest "$@" \ - --rsync-path='sudo -u git rsync' \ - --include-from=- --exclude=\* \ - --ignore-missing-args \ - "$host:$GHE_REMOTE_DATA_USER_DIR/repositories/" \ - "$backup_dir" 1>&3 2>&3 - log_rsync "END: repositories rsync" 1>&3 - fi -} - -sync_data (){ - # Sync all auxiliary repository data. This includes files and directories like - # HEAD, audit_log, config, description, info/, etc. No refs or object data - # should be transferred here. - echo 1>&3 - - log_info "* Transferring auxiliary files ..." 1>&3 - rsync_repository_data $1:122 $2 <&3 - log_info "* Transferring packed-refs files ..." 1>&3 - rsync_repository_data $1:122 $2 <&3 - log_info "* Transferring refs and reflogs ..." 1>&3 - rsync_repository_data $1:122 $2 <&3 - log_info "* Transferring objects and packs ..." 1>&3 - rsync_repository_data $1:122 $2 -H <&3 - -} - -# rsync all the repositories -bm_start "$(basename $0) - Repo sync" -for file_list in $tempdir/*.rsync; do - hostname=$(basename $file_list .rsync) - - repo_num=$(< $file_list wc -l) - ghe_verbose "* Transferring $repo_num repositories from $hostname" - - sync_data $hostname $file_list & -done - -for pid in $(jobs -p); do - wait $pid -done -bm_end "$(basename $0) - Repo sync" - -# Since there are no routes for special data directories, we need to do this -# serially for all hostnames. Good candidate for future optimizations. - -bm_start "$(basename $0) - Special Data Directories Sync" -for h in $hostnames; do - # Sync __special__ data directories, including the __alambic_assets__, - # __hookshot__, and __purgatory__ directories. The __nodeload_archives__, - # __gitmon__, and __render__ directories are excludes since they act only as - # caches. - # - # Under v2.x and greater, only the special __purgatory__ directory remains under - # /data/repositories. All other special user data directories have been moved under - # the /data/user directory. - echo 1>&3 - log_info "* Transferring special data directories from $h..." 1>&3 - rsync_repository_data $h:122 <&3 -done -bm_end "$(basename $0) - Special Data Directories Sync" - -if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then - bm_start "$(basename $0) - Verifying Routes" - for file_lst in $tempdir/*.rsync; do - < $file_lst sort | uniq - done |sort|uniq > $tempdir/source_routes - (cd $backup_dir/ && find * -mindepth 5 -maxdepth 6 -type d -name \*.git | fix_paths_for_ghe_version | uniq | sort | uniq) > $tempdir/destination_routes - - git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more repository networks and/or gists were not found on the source appliance." - increment-progress-total-count 1 - bm_end "$(basename $0) - Verifying Routes" -fi - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-secrets b/share/github-backup-utils/ghe-backup-secrets deleted file mode 100755 index 6d7ab5db6..000000000 --- a/share/github-backup-utils/ghe-backup-secrets +++ /dev/null @@ -1,186 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-secrets -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup command. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Grab the host -host="$GHE_HOSTNAME" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - - -# Function to backup a secret setting to a file. -# backup-secret [--best-effort] -backup-secret() { - best_effort=false - description="" - file="" - setting="" - count=0 - - while [ $# -gt 0 ]; do - case "$1" in - --best-effort) - shift 1 - best_effort=true - ;; - *) - case $count in - 0) - description=$1 - ;; - 1) - file=$1 - ;; - 2) - setting=$1 - ;; - *) - >&2 echo "Too many arguments" - ;; - esac - count=$((count+1)) - shift 1 - esac - done - - log_info "* Transferring $description ..." 1>&3 - ghe-ssh "$host" -- ghe-config "$setting" > "$file+" || ( - if [ "$best_effort" = "false" ]; then - echo "Info: $description not set. Skipping..." >&2 - fi - ) - if [ -n "$(cat "$file+")" ]; then - mv "$file+" "$file" - else - unlink "$file+" - fi -} - -bm_start "$(basename $0)" - -# Create the snapshot directory if needed and change into it. -mkdir -p "$GHE_SNAPSHOT_DIR" -cd "$GHE_SNAPSHOT_DIR" - -log_info "* Transferring secrets data ..." 1>&3 - -backup-secret "management console password" "manage-password" "secrets.manage" -backup-secret "password pepper" "password-pepper" "secrets.github.user-password-secrets" -backup-secret "kredz.credz HMAC key" "kredz-credz-hmac" "secrets.kredz.credz-hmac-secret" -backup-secret "kredz.varz HMAC key" "kredz-varz-hmac" "secrets.kredz.varz-hmac-secret" - -# backup encryption keying material and create backup value current encryption for GHES 3.7.0 onwards -# this is for forwards compatibility with GHES 3.8.0 onwards -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.7.0)" ]; then - backup-secret "encrypted column encryption keying material" "encrypted-column-encryption-keying-material" "secrets.github.encrypted-column-keying-material" - cat "$GHE_SNAPSHOT_DIR/encrypted-column-encryption-keying-material" | sed 's:.*;::' > "$GHE_SNAPSHOT_DIR/encrypted-column-current-encryption-key" -fi - -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" ]; then - backup-secret "secret scanning encrypted secrets current storage key" "secret-scanning-encrypted-secrets-current-storage-key" "secrets.secret-scanning.encrypted-secrets-current-storage-key" - backup-secret "secret scanning encrypted secrets delimited storage keys" "secret-scanning-encrypted-secrets-delimited-storage-keys" "secrets.secret-scanning.encrypted-secrets-delimited-storage-keys" - backup-secret "secret scanning encrypted secrets current shared transit key" "secret-scanning-encrypted-secrets-current-shared-transit-key" "secrets.secret-scanning.encrypted-secrets-current-shared-transit-key" - backup-secret "secret scanning encrypted secrets delimited shared transit keys" "secret-scanning-encrypted-secrets-delimited-shared-transit-keys" "secrets.secret-scanning.encrypted-secrets-delimited-shared-transit-keys" -fi - -if [ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.11.0)" ]; then - backup-secret "secret scanning encrypted content keys" "secret-scanning-user-content-delimited-encryption-root-keys" "secrets.secret-scanning.secret-scanning-user-content-delimited-encryption-root-keys" -fi - -# Backup argon secrets for multiuser from ghes version 3.8 onwards -if [[ "$(version $GHE_REMOTE_VERSION)" -ge "$(version 3.8.0)" && "$(version $GHE_REMOTE_VERSION)" -lt "$(version 3.8.2)" ]]; then - backup-secret "management console argon2 secret" "manage-argon-secret" "secrets.manage-auth.argon-secret" -fi - -# Backup external MySQL password if running external MySQL DB. -if is_service_external 'mysql'; then - backup-secret "external MySQL password" "external-mysql-password" "secrets.external.mysql" -fi - -# Backup Actions settings. -if ghe-ssh "$host" -- ghe-config --true app.actions.enabled; then - backup-secret "Actions configuration database login" "actions-config-db-login" "secrets.actions.ConfigurationDatabaseSqlLogin" - backup-secret "Actions configuration database password" "actions-config-db-password" "secrets.actions.ConfigurationDatabaseSqlPassword" - backup-secret "Actions framework access token key secret" "actions-framework-access-token" "secrets.actions.FrameworkAccessTokenKeySecret" --best-effort - backup-secret "Actions Url signing HMAC key primary" "actions-url-signing-hmac-key-primary" "secrets.actions.UrlSigningHmacKeyPrimary" - backup-secret "Actions Url signing HMAC key secondary" "actions-url-signing-hmac-key-secondary" "secrets.actions.UrlSigningHmacKeySecondary" - backup-secret "Actions OAuth S2S signing cert" "actions-oauth-s2s-signing-cert" "secrets.actions.OAuthS2SSigningCert" - backup-secret "Actions OAuth S2S signing key" "actions-oauth-s2s-signing-key" "secrets.actions.OAuthS2SSigningKey" - backup-secret "Actions OAuth S2S signing cert thumbprint" "actions-oauth-s2s-signing-cert-thumbprint" "secrets.actions.OAuthS2SSigningCertThumbprint" - backup-secret "Actions primary encryption cert thumbprint" "actions-primary-encryption-cert-thumbprint" "secrets.actions.PrimaryEncryptionCertificateThumbprint" - backup-secret "Actions AAD cert thumbprint" "actions-aad-cert-thumbprint" "secrets.actions.AADCertThumbprint" --best-effort - backup-secret "Actions delegated auth cert thumbprint" "actions-delegated-auth-cert-thumbprint" "secrets.actions.DelegatedAuthCertThumbprint" --best-effort - backup-secret "Actions runtime service principal cert" "actions-runtime-service-principal-cert" "secrets.actions.RuntimeServicePrincipalCertificate" --best-effort - backup-secret "Actions S2S encryption cert" "actions-s2s-encryption-cert" "secrets.actions.S2SEncryptionCertificate" - backup-secret "Actions secondary encryption cert thumbprint" "actions-secondary-encryption-cert-thumbprint" "secrets.actions.SecondaryEncryptionCertificateThumbprint" - backup-secret "Actions service principal cert" "actions-service-principal-cert" "secrets.actions.ServicePrincipalCertificate" --best-effort - backup-secret "Actions SPS validation cert thumbprint" "actions-sps-validation-cert-thumbprint" "secrets.actions.SpsValidationCertThumbprint" - backup-secret "Actions storage container prefix" "actions-storage-container-prefix" "secrets.actions.storage.container-prefix" - - backup-secret "Actions Launch secrets encryption/decryption" "actions-launch-secrets-private-key" "secrets.launch.actions-secrets-private-key" - backup-secret "Actions Launch deployer HMAC key" "actions-launch-deployer-hmac" "secrets.launch.deployer-hmac-secret" - backup-secret "Actions Launch Client id" "actions-launch-client-id" "secrets.launch.client-id" - backup-secret "Actions Launch Client secret" "actions-launch-client-secret" "secrets.launch.client-secret" - backup-secret "Actions Launch receiver webhook secret" "actions-launch-receiver-webhook-secret" "secrets.launch.receiver-webhook-secret" - backup-secret "Actions Launch app private key" "actions-launch-app-private-key" "secrets.launch.app-private-key" - backup-secret "Actions Launch app public key" "actions-launch-app-public-key" "secrets.launch.app-public-key" - backup-secret "Actions Launch app id" "actions-launch-app-id" "secrets.launch.app-id" - backup-secret "Actions Launch app relay id" "actions-launch-app-relay-id" "secrets.launch.app-relay-id" - backup-secret "Actions Launch action runner secret" "actions-launch-action-runner-secret" "secrets.launch.action-runner-secret" - backup-secret "Actions Launch service cert" "actions-launch-azp-app-cert" "secrets.launch.azp-app-cert" - backup-secret "Actions Launch service private key" "actions-launch-app-app-private-key" "secrets.launch.azp-app-private-key" -fi - -if ghe-ssh "$host" -- ghe-config --true app.packages.enabled; then - backup-secret "Packages aws access key" "packages-aws-access-key" "secrets.packages.aws-access-key" - backup-secret "Packages aws secret key" "packages-aws-secret-key" "secrets.packages.aws-secret-key" - backup-secret "Packages s3 bucket" "packages-s3-bucket" "secrets.packages.s3-bucket" - backup-secret "Packages storage service url" "packages-service-url" "secrets.packages.service-url" - backup-secret "Packages blob storage type" "packages-blob-storage-type" "secrets.packages.blob-storage-type" - backup-secret "Packages azure connection string" "packages-azure-connection-string" "secrets.packages.azure-connection-string" - backup-secret "Packages azure container name" "packages-azure-container-name" "secrets.packages.azure-container-name" -fi - -# Backup Chat Integration settings -if ghe-ssh "$host" -- ghe-config --true app.chatops.enabled; then - backup-secret "Chat Integration MSTeams app id" "chatops-msteams-app-id" "secrets.chatops.msteams.app-id" - backup-secret "Chat Integration MSTeams app password" "chatops-msteams-app-password" "secrets.chatops.msteams.app-password" - backup-secret "Chat Integration MSTeams public endpoint" "chatops-msteams-app-public-endpoint" "secrets.chatops.msteams.public-endpoint" - backup-secret "Chat Integration MSTeams bot handle" "chatops-msteams-bot-handle" "secrets.chatops.msteams.bot-handle" - backup-secret "Chat Integration MSTeams bot name" "chatops-msteams-bot-name" "secrets.chatops.msteams.bot-name" - backup-secret "Chat Integration Slack app id" "chatops-slack-app-id" "secrets.chatops.slack.app-id" - backup-secret "Chat Integration Slack client id" "chatops-slack-client-id" "secrets.chatops.slack.client-id" - backup-secret "Chat Integration Slack client secret" "chatops-slack-client-secret" "secrets.chatops.slack.client-secret" - backup-secret "Chat Integration Slack verification token" "chatops-slack-verification-token" "secrets.chatops.slack.verification-token" - backup-secret "Chat Integration Slack config token" "chatops-slack-config-token" "secrets.chatops.slack.config-token" - backup-secret "Chat Integration Slack public endpoint" "chatops-slack-public-endpoint" "secrets.chatops.slack.public-endpoint" - backup-secret "Chat Integration Slack signing secret" "chatops-slack-signing-secret" "secrets.chatops.slack.signing-secret" - backup-secret "Chat Integration Slack app level token" "chatops-slack-app-level-token" "secrets.chatops.slack.app-level-token" - backup-secret "Chat Integration Slack slack command" "chatops-slack-slash-command" "secrets.chatops.slack.slash-command" - backup-secret "Chat Integration Slack app name" "chatops-slack.app-name" "secrets.chatops.slack.app-name" - backup-secret "Chat Integration Slack socket mode" "chatops-slack.socket-mode" "secrets.chatops.slack.socket-mode" - backup-secret "Chat Integration public endpoint" "chatops-public-endpoint" "secrets.chatops.public-endpoint" - backup-secret "Chat Integration app type" "chatops-app-type" "secrets.chatops.app-type" - backup-secret "Chat Integration app id teams" "chatops-app-id-teams" "secrets.chatops.app-id-teams" - backup-secret "Chat Integration webhook secret teams" "chatops-webhook-secret-teams" "secrets.chatops.webhook-secret-teams" - backup-secret "Chat Integration client secret teams" "chatops-client-secret-teams" "secrets.chatops.client-secret-teams" - backup-secret "Chat Integration clien id teams" "chatops-client-id-teams" "secrets.chatops.client-id-teams" - backup-secret "Chat Integration storage secret" "chatops-storage-secret" "secrets.chatops.storage-secret" - backup-secret "Chat Integration session secret" "chatops-session-secret" "secrets.chatops.session-secret" - backup-secret "Chat Integration app id slack" "chatops-app-id-slack" "secrets.chatops.app-id-slack" - backup-secret "Chat Integration webhook secret slack" "chatops-webhook-secret-slack" "secrets.chatops.webhook-secret-slack" - backup-secret "Chat Integration client secret slack" "chatops-client-secret-slack" "secrets.chatops.client-secret-slack" - backup-secret "Chat Integration client id slack" "chatops-client-id-slack" "secrets.chatops.client-id-slack" -fi - -bm_end "$(basename $0)" - -exit 0 diff --git a/share/github-backup-utils/ghe-backup-settings b/share/github-backup-utils/ghe-backup-settings deleted file mode 100755 index f3d262293..000000000 --- a/share/github-backup-utils/ghe-backup-settings +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-settings -#/ Backup settings from a snapshot to the given . -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -bm_start "$(basename $0)" - -# Grab the host -host="$GHE_HOSTNAME" - -# Create the snapshot directory if needed and change into it. -mkdir -p "$GHE_SNAPSHOT_DIR" -cd "$GHE_SNAPSHOT_DIR" - -log_info "* Transferring settings data ..." 1>&3 -ghe-ssh "$host" -- 'ghe-export-settings' > settings.json - -log_info "* Transferring license data ..." 1>&3 -ghe-ssh "$host" -- "sudo cat '$GHE_REMOTE_LICENSE_FILE'" > enterprise.ghl - -if ghe-ssh "$host" -- "test -f $GHE_REMOTE_DATA_USER_DIR/common/idp.crt"; then - log_info "* Transferring SAML keys ..." 1>&3 - ghe-ssh $host -- sudo tar -C $GHE_REMOTE_DATA_USER_DIR/common/ -cf - "idp.crt saml-sp.p12" > saml-keys.tar -fi - -if ghe-ssh "$host" -- "which ghe-export-ssl-ca-certificates 1>/dev/null"; then - log_info "* Transferring CA certificates ..." 1>&3 - ghe-ssh "$host" -- "ghe-export-ssl-ca-certificates" > ssl-ca-certificates.tar -fi - -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - log_info "* Transferring cluster configuration ..." 1>&3 - if ! ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_CLUSTER_CONF_FILE 2>/dev/null" > cluster.conf; then - log_error "Error: Enterprise Cluster is not configured yet, backup will fail" >&2 - exit 1 - fi -else - if ghe-ssh "$host" -- "sudo cat $GHE_REMOTE_DATA_USER_DIR/common/uuid 2>/dev/null" > uuid; then - log_info "* Transferring UUID ..." 1>&3 - fi -fi - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-storage b/share/github-backup-utils/ghe-backup-storage deleted file mode 100755 index c80c39a29..000000000 --- a/share/github-backup-utils/ghe-backup-storage +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-storage -#/ Take an online, incremental snapshot of all Alambic Storage data using the -#/ calculated routes method. -#/ -#/ Note: This command typically isn't called directly. It's invoked by -#/ ghe-backup. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -# Set up remote host and root backup snapshot directory based on config -host="$GHE_HOSTNAME" -backup_dir="$GHE_SNAPSHOT_DIR/storage" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - log_error "rsync not found." 1>&2 - exit 1 -fi - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Split host:port into parts -port=$(ssh_port_part "$GHE_HOSTNAME") -host=$(ssh_host_part "$GHE_HOSTNAME") - -# Add user / -l option -user="${host%@*}" -[ "$user" = "$host" ] && user="admin" - -hostnames=$host -ssh_config_file_opt= -tempdir=$(mktemp -d -t backup-utils-backup-XXXXXX) -remote_tempdir=$(ghe-ssh "$GHE_HOSTNAME" -- mktemp -d -t backup-utils-backup-XXXXXX) -routes_list=$tempdir/routes_list -remote_routes_list=$remote_tempdir/remote_routes_list -opts="$GHE_EXTRA_SSH_OPTS" - -# storage server hostnames under cluster -if [ "$GHE_BACKUP_STRATEGY" = "cluster" ]; then - ssh_config_file="$tempdir/ssh_config" - ssh_config_file_opt="-F $ssh_config_file" - opts="$opts -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no" - hostnames=$(ghe-cluster-find-nodes "$GHE_HOSTNAME" "storage-server") - ghe-ssh-config "$GHE_HOSTNAME" "$hostnames" > "$ssh_config_file" -fi - -# Replica hostnames for HA -if ghe-ssh "$GHE_HOSTNAME" -- "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - ha_replica_hosts=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes --replica) -fi - -# Make sure root backup dir exists if this is the first run -mkdir -p "$backup_dir" - -# Removes the remote sync-in-progress file on exit, re-enabling GC operations -# on the remote instance. -cleanup() { - # Enable remote maintenance operations - for hostname in $hostnames; do - ghe-gc-enable $ssh_config_file_opt $hostname:$port || { - log_warn "Re-enable gc on $hostname failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 - } - done - - # Enable remote GC operations for HA replica - for replica_host in $ha_replica_hosts; do - echo "set -o pipefail; ssh $replica_host -- 'sudo rm -f $SYNC_IN_PROGRESS_FILE'" | ghe-ssh "$host" /bin/bash || { - echo "Re-enable gc on $replica_host failed, please manually delete $SYNC_IN_PROGRESS_FILE" 1>&2 - } - done - - ghe-ssh "$GHE_HOSTNAME" -- rm -rf $remote_tempdir - rm -rf $tempdir -} -trap 'cleanup' EXIT INT - -# Disable remote maintenance operations -for hostname in $hostnames; do - ghe-gc-disable $ssh_config_file_opt $hostname:$port -done - -# Disable remote GC operations for HA replica -# gc_disable is a function defined in ghe-backup-config -# gc_disable is called on the replica node via the primary node, because replica node is not expected to be reachable from backup host. But replica node is expected to be reachable from primary node. -for replica_host in $ha_replica_hosts; do - echo "set -o pipefail; ssh $replica_host -- '$(declare -f gc_disable); gc_disable \"$SYNC_IN_PROGRESS_FILE\" \"$GHE_GIT_COOLDOWN_PERIOD\"'" | ghe-ssh "$host" /bin/bash || { - echo "Disable gc on $replica_host failed" 1>&2 - } -done - -# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$GHE_DATA_DIR/current/storage" ] && [ "$(ls -A $GHE_DATA_DIR/current/storage)" ]; then - link_dest="--link-dest=../../current/storage" -fi - -# Calculate sync routes. This will store the healthy object paths for each node -# -# This gets a repo path and stores the path in the $node.sync file -# a/nw/a8/3f/02/100000855 storage-server-node1 >> storage-server-node1.sync -# a/nw/a8/bc/8d/100000880 storage-server-node3 >> storage-server-node3.sync -# a/nw/a5/06/81/100000659 storage-server-node2 >> storage-server-node2.sync -# ... -#one route per line. -# -# NOTE: The route generation is performed on the appliance as it is considerably -# more performant than performing over an SSH pipe. -# -bm_start "$(basename $0) - Generating routes" -echo "github-env ./bin/storage-cluster-backup-routes > $remote_routes_list" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash -ghe-ssh "$GHE_HOSTNAME" -- cat $remote_routes_list | ghe_debug -bm_end "$(basename $0) - Generating routes" - -bm_start "$(basename $0) - Fetching routes" -ghe-ssh "$GHE_HOSTNAME" -- gzip -c $remote_routes_list | gzip -d > $routes_list -cat $routes_list | ghe_debug -bm_end "$(basename $0) - Fetching routes" - -bm_start "$(basename $0) - Processing routes" -if [ "$GHE_BACKUP_STRATEGY" != "cluster" ]; then - server=$host -fi -cat $routes_list | awk -v tempdir="$tempdir" -v server="$server" '{ for(i=2;i<=NF;i++){ server != "" ? host=server : host=$i; print $1 > (tempdir"/"host".rsync") }}' -ghe_debug "\n$(find "$tempdir" -maxdepth 1 -name '*.rsync')" -bm_end "$(basename $0) - Processing routes" - -if [ -z "$(find "$tempdir" -maxdepth 1 -name '*.rsync')" ]; then - log_warn "no routes found, skipping storage backup ..." - exit 0 -else - increment-progress-total-count 2 -fi - -# rsync all the storage objects -bm_start "$(basename $0) - Storage object sync" -for file_list in $tempdir/*.rsync; do - hostname=$(basename $file_list .rsync) - storage_user=$(ghe-ssh $ssh_config_file_opt $hostname:$port -- stat -c %U /data/user/storage || echo git) - - object_num=$(cat $file_list | wc -l) - ghe_verbose "* Transferring $object_num objects from $hostname" - log_rsync "BEGIN: storage rsync" 1>&3 - ghe-rsync -avr \ - -e "ssh -q $opts -p $port $ssh_config_file_opt -l $user" \ - $link_dest "$@" \ - --rsync-path="sudo -u $storage_user rsync" \ - --files-from="$file_list" \ - --ignore-missing-args \ - --size-only \ - "$hostname:$GHE_REMOTE_DATA_USER_DIR/storage/" \ - "$backup_dir" 1>&3 & - log_rsync "END: storage rsync" 1>&3 -done - -for pid in $(jobs -p); do - wait $pid -done -bm_end "$(basename $0) - Storage object sync" - -if [ -z "$GHE_SKIP_ROUTE_VERIFICATION" ]; then - bm_start "$(basename $0) - Verifying Routes" - - cat $tempdir/*.rsync | uniq | sort | uniq > $tempdir/source_routes - (cd $backup_dir/ && find * -mindepth 3 -maxdepth 3 -type f -print | uniq | sort | uniq) > $tempdir/destination_routes - - git --no-pager diff --unified=0 --no-prefix -- $tempdir/source_routes $tempdir/destination_routes || echo "Warning: One or more storage objects were not found on the source appliance." - - increment-progress-total-count 1 - bm_end "$(basename $0) - Verifying Routes" -fi - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-store-version b/share/github-backup-utils/ghe-backup-store-version deleted file mode 100755 index 6faffff99..000000000 --- a/share/github-backup-utils/ghe-backup-store-version +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-store-version -#/ Stores information about the used version of backup-utils on -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0)" - -version_info="$BACKUP_UTILS_VERSION" -if [ -d $GHE_BACKUP_ROOT/.git ]; then - ref=$(git --git-dir=$GHE_BACKUP_ROOT/.git rev-parse HEAD || true) - if [ -n "$ref" ]; then - version_info="$version_info:$ref" - fi -fi - -echo "$version_info" | - ghe-ssh "$GHE_HOSTNAME" -- "sudo dd of=$GHE_REMOTE_DATA_USER_DIR/common/backup-utils-version >/dev/null 2>&1" - -bm_end "$(basename $0)" diff --git a/share/github-backup-utils/ghe-backup-strategy b/share/github-backup-utils/ghe-backup-strategy deleted file mode 100755 index b9a919f3c..000000000 --- a/share/github-backup-utils/ghe-backup-strategy +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-strategy -#/ -#/ Determine the backup strategy that will be used. -#/ -#/ The rsync strategy should be used for single VMs and all HA configurations. -#/ -#/ The cluster strategy should be used to backup GHE clusters. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -if ghe-ssh "$GHE_HOSTNAME" -- \ - "[ -f '$GHE_REMOTE_ROOT_DIR/etc/github/cluster' ] && [ ! -f '$GHE_REMOTE_ROOT_DIR/etc/github/repl-state' ]"; then - echo "cluster" -else - echo "rsync" -fi diff --git a/share/github-backup-utils/ghe-backup-userdata b/share/github-backup-utils/ghe-backup-userdata deleted file mode 100755 index d7c7dc233..000000000 --- a/share/github-backup-utils/ghe-backup-userdata +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-backup-userdata -#/ Take an online, incremental snapshot of a user data directory. This is used -#/ for a number of different simple datastores kept under /data/user on the -#/ remote appliance, including: hookshot, alambic_assets, and pages data. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -bm_start "$(basename $0) - $1" - -# Verify rsync is available. -if ! rsync --version 1>/dev/null 2>&1; then - log_error "rsync not found." 1>&2 - exit 1 -fi - -# Grab the host and /data/user directory name. -host="$GHE_HOSTNAME" -dirname="$1" - -# Perform a host-check and establish GHE_REMOTE_XXX variables. -ghe_remote_version_required "$host" - -# Verify that the user data directory exists. Bail out if not, which may be due -# to an older version of GHE or no data has been added to this directory yet. -ghe-ssh "$host" -- "sudo -u git [ -d '$GHE_REMOTE_DATA_USER_DIR/$dirname' ]" || exit 0 - -# If we have a previous increment and it is not empty, avoid transferring existing files via rsync's -# --link-dest support. This also decreases physical space usage considerably. -if [ -d "$GHE_DATA_DIR/current/$dirname" ] && [ "$(ls -A $GHE_DATA_DIR/current/$dirname)" ]; then - - subdir=$dirname - link_path=".." - while true; do - if [ "$(dirname $subdir)" = "." ]; then - break - fi - - if [ "$(dirname $subdir)" = "/" ]; then - break - fi - - link_path="../$link_path" - subdir=$(dirname $subdir) - done - - link_dest="--link-dest=../${link_path}/current/$dirname" -fi - -# Ensure target directory exists, is needed with subdirectories -mkdir -p "$GHE_SNAPSHOT_DIR/$dirname" -log_rsync "BEGIN: userdata rsync" 1>&3 -# Transfer all data from the user data directory using rsync. -ghe-rsync -av \ - -e "ghe-ssh -p $(ssh_port_part "$host")" \ - --rsync-path='sudo -u git rsync' \ - $link_dest \ - "$(ssh_host_part "$host"):$GHE_REMOTE_DATA_USER_DIR/$dirname/" \ - "$GHE_SNAPSHOT_DIR/$dirname" 1>&3 -log_rsync "END: userdata rsync" 1>&3 -bm_end "$(basename $0) - $1" diff --git a/share/github-backup-utils/ghe-cluster-find-nodes b/share/github-backup-utils/ghe-cluster-find-nodes deleted file mode 100755 index 2a1f7ef48..000000000 --- a/share/github-backup-utils/ghe-cluster-find-nodes +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-cluster-find-nodes -#/ -#/ Finds all nodes of the cluster using the config on . -#/ If it is a 2.8 and later cluster version the results are returned as -#/ prefix-uuid, otherwise the configured hostnames are returned. -#/ Also filters nodes based on the prefix role. -#/ -#/ Note: This script typically isn't called directly. It's invoked by the -#/ ghe-backup-* and ghe-restore-* commands in cluster environments. -set -e - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -# Check if the REMOTE DATA USER directory is set -if [ -z $GHE_REMOTE_DATA_USER_DIR ]; then - log_error "Env variable GHE_REMOTE_DATA_USER_DIR is not set. Exiting" - exit 1 -fi - -# Show usage and bail with no arguments -[ -z "$*" ] && print_usage - -GHE_HOSTNAME="$1" -prefix="$2" -role=$(echo "$prefix" | cut -d '-' -f1) - -if ghe-ssh "$GHE_HOSTNAME" test -f $GHE_REMOTE_ROOT_DIR/etc/github/cluster; then - node_uuids=$(ghe-ssh "$GHE_HOSTNAME" ghe-cluster-nodes -r "$role" -u | cut -f 2) - hostnames='' - for uuid in $node_uuids; do - hostnames+="$prefix-$uuid " - done -else - uuid=$(ghe-ssh "$GHE_HOSTNAME" cat $GHE_REMOTE_DATA_USER_DIR/common/uuid) - hostnames="$prefix-$uuid" -fi - -echo "$hostnames" diff --git a/share/github-backup-utils/ghe-detect-leaked-ssh-keys b/share/github-backup-utils/ghe-detect-leaked-ssh-keys deleted file mode 100755 index a71fd812e..000000000 --- a/share/github-backup-utils/ghe-detect-leaked-ssh-keys +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-detect-leaked-ssh-key [-s ] -#/ -#/ This utility will check each snapshot's existing SSH host keys against the list -#/ of known leaked SSH host keys from GitHub Enterprise packages. -#/ -#/ OPTIONS: -#/ -h | --help Show this message. -#/ -s |--snapshot Scan the snapshot with the given id. -#/ Available snapshots may be listed under the data directory. -#/ -set -e - -usage() { - grep '^#/' < "$0" | cut -c 4- - exit 2 -} - -TEMPDIR=$(mktemp -d) - -while [ $# -gt 0 ]; do - case "$1" in - -h|--help) - usage - ;; - -s|--snapshot) - snapshot=$2 - shift - ;; - *) - usage - ;; - esac - shift -done - -ppid_script=$(ps -o args= $PPID 2>/dev/null | awk '{print $2}') -if [ -n "$ppid_script" ]; then - ppid_name=$(basename $ppid_script) -fi - -sshkeygen_multiple_hash_formats=false -if (ssh-keygen -E 2>&1 | head -1 | grep -q 'option requires an argument'); then - sshkeygen_multiple_hash_formats=true -fi - -# Bring in the backup configuration -# shellcheck source=share/github-backup-utils/ghe-backup-config -. "$( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config" - -FINGERPRINT_BLACKLIST="${FINGERPRINT_BLACKLIST:-$(cat "$GHE_BACKUP_ROOT/share/github-backup-utils/ghe-ssh-leaked-host-keys-list.txt")}" - -keys="ssh_host_dsa_key.pub ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub ssh_host_rsa_key.pub" - -# Get all the host ssh keys tar from all snapshots directories -if [ -n "$snapshot" ]; then - if [ ! -d "$snapshot" ]; then - echo "Invalid snapshot directory: $snapshot" >&2 - exit 1 - fi - ssh_tars=$(find "$snapshot" -maxdepth 1 -type f -iname 'ssh-host-keys.tar') -else - ssh_tars=$(find "$GHE_DATA_DIR" -maxdepth 2 -type f -iname 'ssh-host-keys.tar') -fi - -# Store the current backup snapshot folder -if [ -L "$GHE_DATA_DIR/current" ]; then - current_dir=$(cd "$GHE_DATA_DIR/current"; pwd -P) -fi - -leaked_keys_found=false -leaked_keys_skippedcheck=false -current_bkup=false -for tar_file in $ssh_tars; do - for key in $keys; do - if tar -tvf "$tar_file" $key &>/dev/null; then - tar -C $TEMPDIR -xvf "$tar_file" $key &>/dev/null - if $sshkeygen_multiple_hash_formats; then - fingerprint=$(ssh-keygen -l -E md5 -f $TEMPDIR/$key | cut -d ' ' -f 2 | cut -f2- -d':') - else - fingerprint=$(ssh-keygen -lf $TEMPDIR/$key | cut -d ' ' -f 2) - fi - if [ -z "$fingerprint" ]; then - leaked_keys_skippedcheck=true - elif echo "$FINGERPRINT_BLACKLIST" | grep -q "$fingerprint"; then - leaked_keys_found=true - if [ "$current_dir" == "$(dirname "$tar_file")" ]; then - current_bkup=true - log_warn "* Leaked key found in current backup snapshot." - else - log_warn "* Leaked key found in backup snapshot." - fi - echo "* Snapshot file: $tar_file" - echo "* Key file: $key" - echo "* Key: $fingerprint" - echo - fi - fi - done -done - -if $leaked_keys_found; then - if echo "$ppid_name" | grep -q 'ghe-restore'; then - echo - echo "* The snapshot that is being restored contains a leaked SSH host key." - echo "* We recommend rolling the SSH host keys after completing the restore." - echo "* Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance." - echo "* (An upgrade may be required)" - echo - elif echo "$ppid_name" | grep -q 'ghe-backup'; then - echo "* The current backup contains leaked SSH host keys." - echo "* We strongly recommend rolling your SSH host keys and making a new backup." - echo "* Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance." - echo "* (An upgrade may be required)" - else - if $current_bkup; then - echo "* The current backup contains leaked SSH host keys." - echo "* Current backup directory: $current_dir" - echo "* We strongly recommend rolling your SSH host keys and making a new backup." - echo "* Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance." - echo "* (An upgrade may be required)" - fi - echo - echo "* One or more older backup snapshots contain leaked SSH host keys." - echo "* No immediate action is needed but when you use one of these older snapshots for a restore, " - echo "* please make sure to roll the SSH host keys after restore." - echo "* Roll the keys either manually or with ghe-ssh-roll-host-keys on the appliance." - echo "* (An upgrade may be required)" - echo - fi -else - if $leaked_keys_skippedcheck; then - log_info "* No result - check not performed since host key fingerprint was empty" - else - log_info "* No leaked keys found" - fi -fi - -# Cleanup temp dir -rm -rf $TEMPDIR diff --git a/share/github-backup-utils/ghe-docker-init b/share/github-backup-utils/ghe-docker-init deleted file mode 100755 index 76e6086b8..000000000 --- a/share/github-backup-utils/ghe-docker-init +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -set -e - -PATH=$PATH:/backup-utils/bin - -mkdir -p /etc/github-backup-utils - -touch /etc/github-backup-utils/backup.config - -env | grep ^GHE_ | sed -r "s/(.[^=]+)=(.*)/\1=\"\2\"/g" >> /etc/github-backup-utils/backup.config - -exec "$@" diff --git a/share/github-backup-utils/ghe-gc-disable b/share/github-backup-utils/ghe-gc-disable deleted file mode 100755 index 67cdef6d4..000000000 --- a/share/github-backup-utils/ghe-gc-disable +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -#/ Usage: ghe-gc-disable [