rsync git server and repo issues


I am having two devices with one of them for backup. I have a local git server and a cloned repo in one device.

Is it ok to use rsync to sync the git repo to the backup device? If there is any power failure during rsync, do we see any corruption of those files on the backup device. Can git server on the backup device come up fine with those files?

Hi @unniboy,

If you have the option, it might be worthwile to have Git installed on both servers and use continuous integration to keep both servers up to date.


Hello @that-pat,

In a way rsync is continuously synchronizing with the backup device. 

Maybe my question can be more clear with the example.
Lets assume that for a particular commit, the objects directory is copied to the backup device.
But the refs directory was not copied. 
Now, when the backup device tries to do any git operation (pull or push), it would fail due to inconsistencies.
Can I revert back to my last successful commit?

I found two options that lets me copy the complete repo as a file - repack and bundle.
While repack packs(compresses) the contents inside the objects folder into one pack, bundle compresses the complete repo with history meta data, ready to be copied to another machine.
Could you comment on my understanding?

Thank you.

Hi @unniboy,

I think your best option in this scenario is still to use Git to sync to the backup server. If you do want to use rsync, however, you should be able to. In the situation that you described, your repository would not be corrept if a write was interrupted. It might mean that you get into an inconsistent state, but you should always be able to revert to the last successful commit.

Does that help?