Skip to main content

This version of GitHub Enterprise Server was discontinued on 2024-09-25. No patch releases will be made, even for critical security issues. For better performance, improved security, and new features, upgrade to the latest version of GitHub Enterprise Server. For help with the upgrade, contact GitHub Enterprise support.

Backing up a repository

You can use Git or the API to back up your repository.

You may want to take backups of repositories for archiving or disaster recovery purposes.

Depending on the GitHub features you use and your requirements (for example whether you need to be able to restore the backup), there are different backup options which include different data.

You may want to store your backups on an external hard drive and/or upload them to a cloud-based backup or storage service such as Azure Blob Storage, Google Drive, or Dropbox.

Backing up a Git repository with the Git CLI

A Git repository includes all of the files and folders associated with a project, along with each file's revision history. For more information, see About Git.

You can take a backup of a Git repository, including the revision history, by performing a mirror clone with the Git CLI.

To perform a mirror clone, use the git clone command with the --mirror option.

git clone --mirror https://github.com/EXAMPLE-USER/REPOSITORY.git

If the repository includes Git Large File Storage objects, pull in the objects. For more details on Git Large File Storage and how to install it, see About Git Large File Storage.

git lfs fetch --all

Once you have cloned the Git repository, you can compress it into an archive (for example a .zip or .tar.gz file) and move it to a location for safe-keeping.

You can restore your backup by decompressing the archive and then pushing the Git repository to a Git remote.

Backing up a wiki with the Git CLI

Wikis in GitHub are stored as Git repositories. This means that you can back up a wiki by cloning it. For more details on how to clone a wiki using Git, see Adding or editing wiki pages.

Once you have cloned the wiki, you can compress it into an archive (for example a .zip or .tar.gz file) and move it to a location for safe-keeping.

You can restore your backup by decompressing the archive and then pushing the wiki repository to a Git remote.

Backing up a Git repository and selected metadata with migration archives

You can use the REST API to generate a migration archive for a repository. For more information, see REST API endpoints for organization migrations.

These archives are designed for moving data between GitHub products, but they can also be used as backups.

Warning

Migration archives do not include all data related to a repository. For example, Git Large File Storage objects, discussions, or packages are not included. For more information on what is included in migration archives, see About migrations between GitHub products.

Once you have generated an archive, you can move it to a location of your choice for safe-keeping.

Migration archives can be restored to your GitHub Enterprise Server instance using the ghe-migrator tool, which is accessible over SSH. For more information, see Migrating data to GitHub Enterprise Server.

Warning

Migration archives are not designed to be used as backups, and it is not guaranteed that a migration archive generated today will be restorable in future versions of GitHub Enterprise Server.