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
28 changes: 26 additions & 2 deletions bin/ghe-backup
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
Expand Down Expand Up @@ -197,8 +216,13 @@ ghe-backup-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 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 GitHub Pages ..."
ghe-backup-pages || failures="$failures pages"
Expand Down
17 changes: 17 additions & 0 deletions share/github-backup-utils/ghe-backup-repositories-gitbackups
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/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

# 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/backup-repositories" | ghe-ssh "$GHE_HOSTNAME" -- /bin/bash

bm_end "$(basename $0)"
Original file line number Diff line number Diff line change
@@ -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.
Expand Down