Using git for backup?

snotnose

Ars Praefectus
3,453
Subscriptor
I've used a few different backup programs and haven't been happy with any of them. Basically they all take too damned long (hours) to do a backup when, in hindsight, they saved maybe 10k of data.

I use git often enough to be dangerous, but not good. It works for me, myself, and I. But I've never used it large scale.

I've got a 2 TB drive I back my 1 TB laptop to. The laptop is only using 300 gigs (including the OS), the 2 TB drive holds all my pictures, movies, music. Is there any reason I shouldn't open up a window, go to c:\, and checkin everything? Then let git do all the backup stuff?

If I do so, how do I point my repository to my 2 TB drive (Windows calls it backup, cygwin calls it /cygdrive/l, Linux can't access it (Fuck you Buffalo for not saying you aren't Linux compatible anywhere).

And if my hard drive goes tits up and I need to recover everything, what git command would do it?

I guess the unasked questions above show how little I really know about git.

Guess I should mention my main laptop has Win10, cygwin, and a Linux partition. I have another Linux laptop that uses the 2 TB drive for /home. And a Rasperry PI running Plex that access the 2 TB drive.

I'm only worried about backing up the Win10 laptop and it's cygwin folder, everything else is on the 2 TB NAS.
 
git is going to do a bunch of comparisons assuming that the files are text based, to find differences, and that's going to be way slower than whatever backup software you are using now. I would recommend rsync, it's very fast. I use FreeFileSync, personally, and paid for the donation version that allows you to use more than two threads for comparisons and file copies. It's probably the fastest synchronization software I've ever used: it zipped through 12 TB for me over the network between two SMB shares mighty quick. It's completely free, but if you donate, you get access to a slightly faster version. You can donate any amount you wish.
 
D

Deleted member 43669

Guest
By default, Git is extremely inefficient for large repos of files, esp. if they don't compress well. On an interesting note, the .git directory on a non-bare repo has a full copy of the repo (this is not entirely accurate). So, unless you work on a bare repo (which is not very practical), you're likely going to double the amount of storage...

There are many projects that try to solve Git's inefficiency- even some of them are designed to do efficient backups. For backups, there's bup and git-annex (and git-annex is very interesting). Git LFS might also help. However, I don't think they really solve the "fast diff" calculation problem.

The fancy solution to that are copy-on-write filesystems. With ZFS (and btrfs, I think) snapshots are low-cost operations that scale well with filesystem size. And they have efficient mechanisms to replicate snapshots. I use ZFS and snapshots for backups and I like it so much, I'm probably going to create two more ZFS installs this weekend to simplify my backups :)

I think NTFS has similar abilities (shadow copies?) and I believe there are programs that can leverage that for efficient backups.
 

minnmass

Ars Tribunus Militum
2,087
Subscriptor
I'll throw in my 2¢, agreeing with the "git won't work well for this purpose" consensus.

I've used a few different backup programs and haven't been happy with any of them. Basically they all take too damned long (hours) to do a backup when, in hindsight, they saved maybe 10k of data.

Initial seed or incremental backups? 'Cause, just reading 300GB across a 1GBps switch from a rusty-metal HDD took me 3.5 hours (just time tar c source | pv > /dev/null from a WSL VM attached to the SMB share through Windows, since I happened to have a ~300GB folder handy). Heck: just running that command directly on the box with said drive took 40 minutes.

That same rusty metal drive and switch can run an incremental backup of 1.7 TB (~1.5 GB new) to a WD My Cloud box inside of 8 minutes using restic (and, can run an incremental backup to Backblaze B2 inside of 20 minutes, helped by Restic speaking B2 natively).
 

fitten

Ars Legatus Legionis
55,632
Subscriptor++
Yeah... I'd think it wouldn't do well, either. A long time ago when I was mostly a Unix jockey, I had the bright idea of making my home directory a repository using cvs, I think it was. It was pretty neat... any time I messed up one of my many scripts, I could just revert it. The same for any document I was working on! But.... it got to be lots and lots of files and many were binaries and in the end, it was just a major hassle so I dumped it and went back to being normal ;)
 
D

Deleted member 43669

Guest
Yes, you will find many scripts online for keeping dotfiles in Git. For work, I use GNU Stow with... Google Drive, although Stow can be used with Git. You'll find many different ways to implement this.

Personally, most of my files are already in Git repos, in NextCloud, or in a shared drive. All of those get backed up...
 
D

Deleted member 43669

Guest
Re-reading a bit the OP...

I've got a 2 TB drive I back my 1 TB laptop to. The laptop is only using 300 gigs (including the OS), the 2 TB drive holds all my pictures, movies, music. Is there any reason I shouldn't open up a window, go to c:\, and checkin everything? Then let git do all the backup stuff?

I hadn't noticed this. I think file-based backup of the entire C:\ drive is a bad idea. I don't think such a file-based backup would be easily restorable, and unless you really really want to restore the whole system, it's going to be very inefficient (i.e. you'll be backing up a lot of changes that have no value). If you really want a whole system backup, I'd look into image backups.

(And Git in this kind of backup would make things even worse, as it doesn't store all the file metadata that Windows allows.)
 

sryan2k1

Ars Legatus Legionis
46,877
Subscriptor++
You really do want file based backups. Doing image based means you need to scan the entire thing every time for changes no matter what, also you have to be able to restore the entire thing to pick individual files out of it, or have a backup product that has a "Explorer" that lets you pull individual things out.


in either case git is a really awful idea for a whole system backup
 
D

Deleted member 43669

Guest
Oh, I prefer file-based backups. But not of c:\ :)

The Wikipedia article about Shadow Copy does not seem to be very clear on whether shadow copies are file-based or "block-based"? It's for whole volumes, but it sounds file-ish? ZFS snapshots do allow efficient image-based backups, but I'm not so sure about Windows...

edit: I think there's value to image backups. It's just that more frequently, file backups are the way to go...
 
D

Deleted member 43669

Guest
The problem with image based backups is you are rarely restoring an image to the same hardware. In most (but not all) situations the stuff is all you care about, so a new OS install and all of your files back is what most people want/need.

Yes, we're on the same page. I see imaging useful if you *REALLY* want exactly the same stuff installed, you don't have good provisioning, etc.

Checking in your dot files into version control is normal; my understanding is many people do this. Some go the extra mile and check in more things, so they can "hydrate" a user on a new machine with one command.

BRB, committing my passwords.txt file into git 👍

There are quite a few password managers that apparently work well if storing the passwords in Git (e.g. the pass tool). It's cool if you don't want to use the password manager on a smartphone and you already rely on Git for other things (e.g. Ansible Vaults make plenty of sense as they are stored along with playbooks, etc.). I run my Vaultwarden server, though, thank you (and there are nice CLI tools for that which are handy...).
 

nahtaN

Seniorius Lurkius
21
This is about as insane as using a wifi router to wirelessly charge your cell phone. In theory, it could work, but it would take an insane amount of time and would not be worth the effort.

If you don't care about storage space, block-based backup would be your friend if you are looking to back up massive amounts of data. However, I don't know of an end user program that could do that for your use case. File-based backups will be considerably slower. From what others have said about BBB and incremental backups is incorrect: BBB can handle incrementals very well if implemented correctly. It often requires a driver installed on the user's system in order to do fast incremental backups, but not always.