Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Rsyncing git repo good enough backup solution?

Tags:

git

backup

rsync

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?

like image 595
DavidW Avatar asked Feb 17 '12 20:02

DavidW


People also ask

Can I use git as a backup?

git is not a backup system.

Why is rsync not a good backup solution?

If your system is being actively accessed by some other systems on the network, it is not a better solution. Because, the contents of the systems might be constantly updated every minute, and some files may change during the rsync process.

What should I not store in git?

You shouldn't store credentials like usernames, passwords, API keys and API secrets. If someone else steals your credentials, they can do nasty things with it.

How do I backup a git repository?

Clone Everything in Git Repository You can backup every file in your git repository by doing the normal git clone <git-url. git> command. By doing that, you download every file in your repository with their actual size and you can do git workflow in it. It's basically the usual way to clone a git repository.


2 Answers

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.

like image 176
FauxFaux Avatar answered Nov 10 '22 00:11

FauxFaux


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.

like image 26
VonC Avatar answered Nov 10 '22 01:11

VonC