Skip to main content

Restore a repository

Restoring needs only git. You do not need the worker, the dashboard or an account.

1. Find the archive​

Archives are named <owner>__<repository>.bundle, in lower case. The repository Octo-Org/Website is octo-org__website.bundle.

StorageWhere the archive is
A folderBACKUP_LOCAL_DIR/octo-org__website.bundle. The copy before the last change is octo-org__website.bundle.prev.
A bucketThe object under your BACKUP_S3_PREFIX, for example github/octo-org__website.bundle. Download it with your provider's tool, for example aws s3 cp s3://my-github-backups/github/octo-org__website.bundle . (add --endpoint-url for any store other than AWS S3). Earlier copies are older versions of the object when versioning is on.
A git repositoryClone it with git clone <BACKUP_REPO_PATH> backups; the archive is backups/octo-org__website.bundle. Earlier copies are in the history: git -C backups log -- octo-org__website.bundle.

With a folder, check the file against its recorded checksum first:

sha256sum -c octo-org__website.bundle.sha256

2. Restore it​

To work with the code:

git clone octo-org__website.bundle website
git -C website branch -r # every branch, as origin/<name>
git -C website tag # every tag

To put the whole repository, with every branch and tag, back on GitHub or another host, create an empty repository there first, then:

git clone --mirror octo-org__website.bundle website.git
git -C website.git push --mirror git@github.com:octo-org/website.git

Check that backups restore​

Test a restore before you need one. The worker can check every archive it has stored:

github-backup-worker verify
github-backup-worker verify --only octo-org/website # one repository

verify reads every archive back, compares it with the recorded checksum and size, and restores it in a temporary folder to make sure git can read the whole history. It changes nothing. When an archive is damaged or missing, it prints the command that backs that repository up again. It needs free disk space for the largest archive and its clone.

To check one bundle by hand:

git clone --bare octo-org__website.bundle check.git
git -C check.git fsck --full

git bundle verify alone is not enough: it reads only the bundle's header.

Older archives​

Backups made before the bundle format may be .tar.gz files that hold only the default branch, without history. Unpack one with tar -xzf octo-org__website.tar.gz.