Mirror your GitHub world to somewhere local
Backup all your GitHub code, so you can rest more easily
We use GitHub for nearly all of our projects. All day people here are typing, and that content goes to live in the GitHub cloud. GitHub is a great service, but we feel more comfortable also having all our work backed up somewhere local.
For a while, we have run a local Gitolite server, that we have tended to use for projects that don’t need all the GitHub features (and for clients who don’t want their projects living in the cloud). Recently, we started mirroring all our GitHub repositories to our own Gitolite server. We are now protected against the rogue account owner who inadvertently deletes all our things, against the sudden disappearance of github.com, or other unhappy accidents. As a bonus, we can now straightforwardly weed out inactive projects from our GitHub account when we like, knowing that they are archived. This means that we can start new projects without needing to upgrade our plan.
Get Christopher Knox’s stories in your inbox
Join Medium for free to get updates from this writer.
We automated this using an open-source BSD licensed python script (available on GitHub of course). The script has the following main options:
- mirror repositories from a user or an organization
- mirror repositories to a Gitolite server (or to a local filesystem)
- create a webhook on GitHub repositories to enable the script to be triggered automatically whenever repositories are updated
The script could be run on occasion from the command line, or set up to run regularly. This might suit someone who wants to make sure all their code is copied across to their own computer. We make use of webhooks, so our continuous integration server is notified of any changes to the repositories. This ensures our mirror is always up to date. The process is strictly from GitHub to Gitolite and not in the other direction.
Please feel welcome to check the project out and make use of it. Issues and pull requests welcome.










