Make Your Own Simple Backup System
Table of Contents
When I switched from using a Mac as my main computer to Linux, one of the only things I missed was Apple's Time Machine backup solution. There are plenty of alternative backup approaches I could switch to, but I decided to try creating my own first.
This process doesn't have all of the features from Time Machine. The goal was a simple, minimal backup solution that could be built quickly and easily maintained.
You'll need the following to use this backup approach:
- External hard drive
- Cloud storage account (Google Drive, Dropbox, etc.)
These instructions assume you have a Linux operating system, but you can find zip tools and gnupg available on other operating systems, too.
Create a Backup Zip File
I use a variation of the following bash script to create a zip file backup of my home directory and store it in my ~/Downloads directory. You'll want to adjust the paths and exclusions according to your own use case.
#!/bin/bash home_dir=/home/bryan set -x backup_date=`date +%Y-%m-%d-%H%M` cd $home_dir zip -r "$home_dir/Downloads/home_backup_$backup_date.zip" $home_dir/ \ --exclude $home_dir/Downloads/\* \ $home_dir/.cache/\* \ $home_dir/.local/share/Trash/\*
Encryption with GnuPG
Once we have our zip file created, it's time to encrypt it. This gives us some peace of mind that we can safely store it wherever we like, including keeping a copy on a cloud storage provider such as Google Drive or Dropbox.
If you don't care about encryption, or you plan to store your backups on an encrypted drive, or you don't plan on storing any backups with a cloud storage provider, then you can skip this step.
Use the following command to encrypt your zip file with gnupg using a symmetric cipher. You'll be prompted for a passphrase to use for the encryption.
gpg --sign --symmetric --cipher-algo AES256 --encrypt backup_2017-09-10-2126.zip
Once your zip file has been encrypted, delete the original, unencrypted zip file.
Transfer Your Backup File
Lastly, you should copy your encrypted zip file to your external hard drive and optionally to one or more cloud storage accounts for redundancy. And that's it! You can certainly make a more complicated backup process, but I've found that this simple approach does just fine for me.