How do you back up your Git repositories outside your main hosting service?
Asked by
MellowHarbor42
Recent outages made me realize I've been relying too heavily on a single Git hosting provider. Aside from the copies on my development machine, I don't currently have another remote or downloaded backup of my repositories. I'm considering mirroring my most important repositories, encrypting the backups, and storing them with an object-storage provider. How are others handling off-site repository backups, and what should I make sure not to overlook?
Answers
A Git clone is already a backup of the repository itself, and you can keep multiple remotes so changes are pushed to more than one location. For important projects, Iโd use a bare mirror with `git clone --mirror`, then run `git remote update` on a schedule. That preserves all branches and tags better than zipping up a working copy.
Reply to this answer
I run a small self-hosted Git service on my NAS and push important repositories to it regularly. The NAS itself gets nightly backups to separate storage. Self-hosting can work well, but keep it patched and isolatedโan exposed service can introduce a different security problem.
Reply to this answer
A second cloud location is a reasonable option, but donโt stop at uploading an archive. Encrypt the backups, automate the mirroring, and perform a restore test on another machine periodically. The backup only counts if you know you can recover the repository when you need it.
Reply to this answer
I follow a 3-2-1 approach: three copies, stored on at least two different types of media, with one copy off-site. For example, the working copy, a removable local drive, and an encrypted cloud backup. Automating the process is important, since a backup that depends on remembering to run it usually gets neglected.
BrightCedar31: The definition is specifically three total copies, two different storage media, and one copy kept off-site. Extra copies are fine, but thatโs the basic rule.
Reply to this answer
Add your answer
Answers are reviewed before publication.
QuietMaple19: Keep in mind that issues, pull requests, wikis, and other hosting-service metadata usually arenโt included in the Git repository. Back those up separately through the providerโs API if they matter.