Backup scripts
Annoyed by complicated backup solutions, I've written my own simple scripts
to back up only what I care about in a format that's easily unpacked on a fresh
install of the system, that is, a tarball. There's no reason you couldn't
use dump, btrfs send, zfs send or similar, though and this script
supports handling that as long as you can pipe it over stdout and save to a file.
Not for everyone, and I don't even use it for backups of my largest files, for instance photos, videos, etc I use rclone and rsync instead of these scripts.
HOW TO
Clone this repo down to the system that'll run the backups, set up a
ssh key in ssh/id_ed25519 ( ssh-keygen -t ed25519 -f ssh/id_ed25519 or so )
and then set up your SSH config ( jump boxes, etc ) in ssh/config
From there create a directory for each server that you're backing up, for
instance if I want to back up a server called example.com, mkdir example.com.
From there, we need a script that will generate a tarball, examples can be
found in openbsd.sh, and alpine.sh, copy it to example.com/backup.sh,
and then chmod +x the file. This will be copied and then executed as root
on the remote machine.
Another example worth calling out directly since it utilizes a slightly
different method, alpine-diskless.sh can be used to back up the config
using alpine's built in lbu, though it's worth passing in -suffix tar.gz
to the backup script.
Example crontab:
@monthly sh -c 'set -e;cd /home/backupdir;./backup.sh -type monthly -svr example.com'
@weekly sh -c 'set -e;cd /home/backupdir;./backup.sh -type weekly -svr example.com'
@daily sh -c 'set -e;cd /home/backupdir;./backup.sh -type daily -svr example.com'
# Clean up the old backups daily, see the clean.sh for an example
@daily sh -c 'set -e;cd /home/backupdir;./clean.sh
