DEV Community

Discussion on: How do you back up your data?

Collapse
 
5bentz profile image
5bentz • Edited

First, I have to say every backups are not equal

Some will prevent hardware failure, others won't. Some backups may be daily, others monthly. RAIDx0/5/6 can prevent a hardware failure, but it is useless against a user deleting something. RAID is not a backup solution. Hopefully nobody here is using RAID as a backup :)

Before

I would simply rsync my personal data (pictures, documents, videos...) once in a while to an external HDD or thumb drive. I often take the HDD with me in my bag, just in case something happens to my house...

3 months ago

It just happened. I messed with a rsync command (see below [1] for the details) while backuping my parents' data and it just deleted the home directory in 2 seconds: the time to press Ctrl+C. Hopefully, I was able to recover everyting from backups and extundelete...All in all, my parents weren't too bothered: the data they care about was fine. However as far as I was concerned, I realized I had to prevent this from happening again.

Automatic snapshots

Thus, to prevent me from deleting my data: snapshots are automatically and regularly taken, and saved on the same drive. Note: It is useless in case of hardware failure! So I still need to manually backup once in a while.

Copy On Write ftw

For my laptop running GNU/Linux Debian, I take BTRFS (a filesystem similar to ZFS) snapshots with btrbk:

  • daily snapshots of my home subvolume (/home)
  • monthly snapshots of my system subvolume (/) I have a subvolume named Scratch for unimportant big files which is not saved.
Rsync <3

For my family computer running GNU/Linux Ubuntu with an EXT4 partition, I chose backintime for a couple of reasons:

  • takes file-based snapshots: I can read & recover the files without backintime, with a simple filemanager.
  • uses rsync (I still like rsync ;).
  • takes read-only snapshots to survive rm -r /. The native backup tool for Ubuntu does not.
  • hard-links snapshots to save space.
  • can save to a remote through SSH.
  • can be run as root easily.
  • supports a GUI (for my parents!).
  • supports several profiles.

I have two profiles:

  • weekly snapshots of /home
  • every other month snapshots of /etc and /var. I might snapshot the whole system soon since I have enough disk space :)

I exclude computer-generated files that aren't necessary such as caches. BiT also excludes a bunch by itself.
For changing files I care about saving one time and not their many states (such as a Windows XP VM), I just added them to the first snapshot and excluded them from the other snapshots.

And now? Automatic remote backup!

I plan to build my own NAS/Backup machine to automatically backup my computers.
I'm aiming at rockstore for now: an OpenSource BTRFS & Linux powered Advanced NAS server.

Peace and backup your data. It deserves it <3

[1] Tutorial: How to delete © your data

For the record, Valve has already done something similar here.

  1. Use variables for SOURCE and DESTINATION directories:

SRC=SOURCE
DEST=DESTINATION

  1. Use rsync with --delete option and don't forget the very very nasty / ####rsync -auvP --delete "${SRC}/" "${DEST}"
  2. Now, run tmux
    tmux

  3. Run the same rsync command (actually it isn't)

Pown'd! Tmux resets the variables SRC and DEST that are empty string "" now. The rsync command becomes:
####rsync -auvP --delete "/" "" #"" means current directory
Basically, it copies / to the current directory. Let's say it is /home/$USER. Cool !

Note: To keep the same behavior as --delete while deleting after the transfer, I recommend --delete-delay.