A Minimal Backup Script
#Backups #FreeBSD #GPG #SystemAdministration
#!/usr/bin/env bash
dobackup()
{
TARGET="$(date +"%s").dmp.gpg"
dump -0 -L -f - / | gpg --passphrase-file $FILEPATH --symmetric --pinentry-mode loopback | tee \
>(ssh -p XXXX YYYY@ZZZZ dd of=WWWW/$TARGET) \ # offsite
>(ssh -p XXXX YYYY@ZZZZ dd of=WWWW/$TARGET) # onsite
}
dobackup 2>&1 >/dev/null
The backup is created with dump. The backup is symmetrically encrypted with GPG using a password placed into a file in your $HOME
directory called .backuppasswd
. The backup is then pushed over SSH to two different locations. In this example, very similar to my actual backup setup, the backup is copied to an offsite host and an onsite host.
Replace XXXX
, YYYY
, ZZZZ
, and WWWW
with your target host(s) values.
Restore may be used to restore the backups created to the source host or others.
EOF