7

Say I want to use Git to back up my PC.

I don't care about a full system backup. I don't mind having to reinstall things if my hard drive crashes. I just want to back up my data files, which are all on one partition.

To back up with Git, I could create a repo on that partiion, clone it (bare) on a separate drive or system, and periodically commit and push to back up my files.

What, if any, are the drawbacks to using Git for backup in this way?

Ryan Lundy
  • 204,559
  • 37
  • 180
  • 211

2 Answers2

8

Git repository takes as much space as every version of your files, compressed. If you're planning to archive precompressed data like photos, be prepared for enormous .git growth.

As of 2011 Git does not use binary diffs like, for example, Subversion, and stores binary files as they are, compressed.

If you're short of disk space consider using other, more efficient in terms of disk space usage, specialized backup solutions. Borg, attic, restic, duplicity, zbackup come to mind.

sanmai
  • 29,083
  • 12
  • 64
  • 76
  • I realized this after I added a few folders as a test. Obviously I knew the Git repository would be on the same drive as my original stuff, but I guess I was used to the compression I get with source code. A lot of the stuff I'm backing up doesn't compress anywhere near as well as text does. – Ryan Lundy Aug 10 '11 at 14:48
1

It's a pretty decent solution, and much better than nothing. Dead simple too, if you're familiar with git.

One downside is that history will be kept forever; there's no easy way to roll off older, stale versions of files, or even to thin older versions. For example, you might like to discard everything older than 3 years, and anything older than a year you only want monthly snapshots. So your backup will continuously grow until it consumes your entire disk.

Graham Perks
  • 23,007
  • 8
  • 61
  • 83
  • There is, in fact, a way to squash past versions: http://stackoverflow.com/questions/250238/collapsing-a-git-repositorys-history – sanmai Aug 10 '11 at 02:22