Backups

From /tech/ Wiki
Jump to navigationJump to search
Tip: IG Import, going to merge with the article on external hard drives and rewrite whole thing.

There are two types of data: Backed up data, and data you're prepared to lose. The process of backing up is dead simple. Deciding what to backup and getting into the habit of backing up is the trickier part.

A reasonable defense against all of these requires a minimum of three independent copies of the data. One or more of those copies must be powered down (offline) and at a different physical location (offsite). Remember, RAID is no substitute for a backup. Using a modern file system like BTRFS or ZFS with ECC RAM can help protect against bitrot. Surge protectors and UPS are essential protection from power irregularities. However, no protection system can guarantee absolute safety from a lightning strike, so always unplug during thunderstorms. If using RAID, a controller with built in battery backup helps prevent write failures during unexpected power outages.

Backup Methods

Manual

You can keep a manual backup of essential files including, but not limited to: password manager database, cryptocurrency wallets, PGP keys, important documents.

rsync

With all your data in a central location, you're ready to back it up.

Depending on your needs, investing in a file server, NAS or SAN may be worthwhile. A simple option is to get yourself an external hard drive of sufficient capacity for you data. Encrypt it if you want.

Once it's mounted:

 $ rsync -av --delete /path/to/mydata/ /path/to/externaldrive/
  • -v being verbose
  • --delete [optional] delete files on your /externaldrive/ which no longer exist in /mydata/
  • -a being "archive mode, which includes:
    • -r recursive mode
    • -p preserve permissions
    • -t preserve times
    • -g preserve groups
    • -o preserve owner
    • -l copy symlinks as symlinks

rsync will update any modified files and create any new ones.

rsync can be combined with cron to automatically keep your backup in sync on a time schedule.

Unison is an alternative to rsync.

Keep the external drive unplugged and stored away when not in use. You don't want a power surge taking out your computer and your backup in one hit.

Shucking

Tip: For an even better deal, wait for a sale.

Western Digital sells a line of direct-attached storage called EasyStore. Inside one of these babies is a premium, server-grade hard drive (such as a WD Red or White). These come nearly 50% cheaper than the same drives sold separately. You could use one of these as is, but if you want to use your own case/put the drive in a NAS you will have to do a little work and pry open the casing, aka shuck it. This is what works for me:

  • Cut a spent gift card into four quadrants. Stick each quadrant into one side of the casing to loosen it.
  • Pop it open.

You may want to set up the drive with a fresh partition table and the filesystem of your choosing. Run lsblk to identify your drive and either fdisk or gdisk to re-partition.

After re-partitioning, run mkfs.filesystem (ext4, xfs, etc) to write

Cloud storage

Cloud storage is a bad idea because if you:

  • don't have network access
  • have a slow connection
  • have a data limited connection which costs extra for excessive data
  • lose your password
  • get phished/hacked
  • get banned from the service

then you don't have a backup and have lost your data.

Other considerations:

  • Unencrypted backups can be read by the cloud provider
  • Cloud provider could go offline/shutdown without warning
  • Cloud provider may be in a different legal jurisdiction than you

If you're fairly confident in your backup, wipe your computer and test it. It's better to find out today that something was lost than finding out when it really matters. If this seems too scary, recheck your backed up data until it gives you confidence.