You can use the API or a third-party tool to back up your repository.

To download an archive of your repository, you can use the API for user or organization migrations. For more information, see "Migrations" in the GitHub Developer documentation.

Once you have downloaded your archive, you can copy it to an external hard drive and/or upload it to a cloud-based backup service such as Google Drive or Dropbox.

For information about backups that GitHub makes for security purposes, see "File system and backups."

Third-party backup tools

A number of self-service tools exist that automate backups of repositories. Unlike archival projects, which archive all public repositories on GitHub and make the data accessible to anyone, backup tools will download data from specific repositories and organize it within a new branch or directory.

You can back up all of a repository's Git data (such as project files and commit history), as well as much data from GitHub (such as issues and pull requests), with BackHub, which creates daily recurring backups of your repositories with snapshots up to 30 days back in time. BackHub is available in GitHub Marketplace.