Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ac15b30
Use sentinel file to identify type of mysql backup
jianghao0718 Dec 16, 2019
452b692
We need to support legacy version of GHES without new import scripts
jianghao0718 Dec 16, 2019
dbbfc11
Add synbolic link for mocked ghe-import-mysql-xtrabackup and ghe-impo…
jianghao0718 Dec 16, 2019
b32ed4e
Merge pull request #532 from github/hao/mysql-binary-backup-sentinel
jianghao0718 Dec 18, 2019
03f3817
make sure the absence of audit_entries table is not fatal
juruen Dec 6, 2019
cba1574
Merge pull request #534 from github/juruen/audit-entries
juruen Jan 21, 2020
8cb7d3a
Suffix existing script with '-rsync' to differentiate against incomin…
cainejette Jan 21, 2020
b2ed6b0
Add placeholder script 'ghe-backup-repositories-gitbackups'
cainejette Jan 21, 2020
b5691c7
Call backup-repositories script
cainejette Jan 22, 2020
16bc3ec
Introduce fork in backup flow for backup mechanism
cainejette Jan 22, 2020
6c36e99
Change ghe-ssh target from host to GHE_HOSTNAME
cainejette Jan 22, 2020
c7159e3
Update comments
cainejette Jan 22, 2020
add11d4
update permissions on backup script
Jan 23, 2020
da4321b
Log which mechanism is being used for repository backup
cainejette Jan 24, 2020
30fb1d8
Protect against appliance not supporting gitbackups-powered repositor…
cainejette Jan 24, 2020
5bed84c
Remove comment after confirming existing config setting is OK to re-use.
cainejette Jan 24, 2020
566902e
Exit early if the appliance is set to use gitbackups for repositories…
cainejette Jan 24, 2020
91f8cc2
Update bin/ghe-backup
oakeyc Jan 24, 2020
db977bb
Merge pull request #536 from github/gitbackups-for-backing-up
oakeyc Jan 27, 2020
4df05f5
Allow specifying GH_BASE_BRANCH for release script
Jan 31, 2020
bfcd0d7
Add ghe- prefix to script
cainejette Feb 3, 2020
a9c2acb
Update test for script existence
cainejette Feb 3, 2020
0ed5df9
Merge pull request #544 from github/release-base-branch
Feb 4, 2020
a664812
Merge branch 'master' into rename-script
cjonsmith Feb 5, 2020
39f93a2
Merge pull request #545 from github/rename-script
cjonsmith Feb 5, 2020
fdb09ab
Bump version: 2.20.0 [ci skip]
Feb 11, 2020
886575b
Merge pull request #555 from github/release-2.20.0
thejandroman Feb 11, 2020
7d92a0d
Revert "Bump version: 2.20.0"
thejandroman Feb 11, 2020
e0964c8
Merge pull request #559 from github/revert-555-release-2.20.0
thejandroman Feb 11, 2020
a2011c9
Bump version: 2.20.0 [ci skip]
Feb 11, 2020
7d00c77
Merge pull request #562 from github/release-2.20.0
thejandroman Feb 11, 2020
87e2c73
Revert "Bump version: 2.20.0"
thejandroman Feb 11, 2020
c4fbaee
Merge pull request #563 from github/revert-562-release-2.20.0
thejandroman Feb 11, 2020
894d733
Bump version: 2.20.0 [ci skip]
Feb 11, 2020
d342b5e
merge conflicts
oakeyc Feb 13, 2020
262f739
Merge branch 'stable' into release-2.20.0
cainejette Feb 19, 2020
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
9 changes: 7 additions & 2 deletions bin/ghe-backup
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,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
2 changes: 1 addition & 1 deletion bin/ghe-host-check
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 2.20?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. We support N-2 releases like we do for GHES upgrades as we need to support migrations.


if [ "$(version $version)" -ge "$(version $supported_minimum_version)" ]; then
supported=1
Expand Down
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ github-backup-utils (2.19.4) UNRELEASED; urgency=medium

-- Hao Jiang <[email protected]> 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 <[email protected]> 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
Expand Down
2 changes: 1 addition & 1 deletion script/cibuild
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions script/release
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand All @@ -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
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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.'
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion share/github-backup-utils/ghe-backup-audit-log
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"
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, 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)"
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
8 changes: 7 additions & 1 deletion share/github-backup-utils/ghe-restore-audit-log
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -90,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"
}

Expand Down
2 changes: 1 addition & 1 deletion share/github-backup-utils/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.19.4
2.20.0
2 changes: 1 addition & 1 deletion test/testlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down