zoominfo

Q: How to recover a deleted repository in GitHub

A:

 

For those that need a little more peace of mind than what GitHub offers, a BaaS cloud solution like Rewind is the best option. While BackHub, powered by Rewind is a paid service, it offers several important features on top of simple repository recovery:

  • Nightly backups
  • Sync to Amazon S3
  • Audit log
  • Backing up issues, milestones, pull requests, etc.
  • Restore directly to GitHub
  • No 90-day limit on backup retention

 

If peace of mind is worth the cost (plans start at just $12/mo), then sign up for a free trial to give BackHub a try. Here’s the process for installing and recovering a GitHub repository using BackHub.

Install BackHub

After signing up for a free trial, you’ll be directed to an install screen that sets up permissions with your GitHub account.

Select “All repositories” to back up everything or use the dropdown to choose the relevant repositories.

From there, log in to GitHub and authorize BackHub as an app.

Wait for a second for things to get set up…

Once BackHub is configured, you’ll be taken to the BackHub dashboard. You will see a list of all the repositories you selected, including a timestamp of the last backup. BackHub will keep your backups up to date so you can recover them at any time.

Here’s a sample of some of the information it displays on each repository:

Restore from BackHub

To complete the process, try restoring a repository from BackHub’s backups. Since I just created my account, I know that it’s up to date with my latest code changes.

Click the Restore button in the repo dropdown.

In the restore popup, you will be asked to authorize the BackHub app again. This installs a temporary app that you can remove after restoration is complete.

 

Once the app is authorized click the Restore button in the BackHub dashboard again. You’ll get a chance to name your repo. In this case, we’ll stick with the default <REPOSITORY_NAME>-restored format and leave it private.

 

Once you hit restore, BackHub will get to work in the background. There is a status message at the top of the dashboard telling you the current state.

That will quickly change to a success message.

Now when I go to my GitHub account, I see the restored repository:

If your code is stored in a GitHub organization account, BackHub requires a new plan for each organization. These can be set up from the dashboard as well.

Conclusion

BackHub allows you to store your backups in your own S3 bucket where they’re unaffected by GitHub downtime, but you have to plan ahead because it’s not built into GitHub by default.

Just like database backups, code backups should be considered early in the software development lifecycle. Once a repository is more than a toy project, you should have a backup and recovery plan as mission-critical code could be lost in a data breach, account compromise, or accidental deletion. If you’re interested in getting serious about code backups, check out BackHub’s GitHub repository backup and recovery tool.