Is Rsyncing git repo good enough backup solution?
Solution 1
rsync
is a good solution for this. It may be a good idea to run git gc
and git repack
(neither with any arguments) before doing your backup; this may significantly reduce the number of files, and increase the chance of the data not changing too much by next time. Neither will lose any data.
See http://sethrobertson.github.com/GitBestPractices/#backups for a write-up of why doing this with git isn't such a good solution.
Solution 2
rsync is interesting if you really want to backup everything (including hooks and private files).
However:
- it doesn't guarantee the integrity of your repo once sync'ed (ie is git still working from the rsync'ed repo?)
- it has a higher probability of data corruption (you have to save many many files)
A nicer (and cleaner) solution would be to use git bundle (which is essentially a bar repo seen as one file).
You update your local bundle, and save rsync it to your remote media.
Except that, this time, you only "rsync" (actually a simple copy is enough) one file.
And you can directly clone or pull from that one file, that bundle.
DavidW
Updated on June 06, 2022Comments
-
DavidW almost 2 years
I often backup my laptop to an external hard drive. Is rsyncing git repos over good enough backup solution or are there any problems with this method?
-
Matt Curtis about 11 yearsBig advantage of using
rsync
(ortar
or whatever) vs.git clone
:clone
doesn't clone local things like stashes. -
Alexis Wilke about 9 yearsHe was asking about making a backup, not doing work with the repo!?
-
VonC about 9 years@Ale the bundle can be incremental: that is still one file, but much smaller.