Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/ghe-backup
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down
44 changes: 27 additions & 17 deletions share/github-backup-utils/ghe-backup-git-hooks-cluster
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)"