I tried backup-manager and rsnapshot, but neither really met my needs for a simple, scriptable, push-to-remote-server-via-ssh backup solution.
Let's try rdiff-backup.
Here's what I think I want:
- Triggered by laptop connecting to the network and/or cronjob
- If the server's backup drive is not mounted, mount it
- Do a diff-based backups
- Unmount the backup drive
# The basic rdiff-backup syntax is: rdiff-backup [options] [machine::]/path/to/original [machine::]/path/to/backup # Here's a test command to backup my laptop /home directory to the server via ssh: # option: --terminal-verbosity 5 (tell me a lot) # option: --remote-schema (necessary for nonstandard ssh ports) rdiff-backup --terminal-verbosity 5 --remote-schema 'ssh -p $PortNumber %s rdiff-backup --server' /home/me firstname.lastname@example.org::/mnt/Laptop/backups/me/
# Here's a test command to see how many backups are stored
rdiff-backup -l --terminal-verbosity 5 --remote-schema 'ssh -p $PortNumber %s rdiff-backup --server' email@example.com::/mnt/Laptop/backups/me
You can see how this can be scripted to make things easy:
# This script backs up my laptop to the server's /mnt/Laptop-backup/backups directory
# Do pre-backup stuff
Schema="ssh -p $PortNumber %s rdiff-backup --server"
# Backup the home folder
rdiff-backup --remote-schema '$Schema' /home/me firstname.lastname@example.org::/mnt/Laptop/backups/me
# Backup /var, including the package list and cache and all the logs
rdiff-backup --remote-schema '$Schema' /var email@example.com::/mnt/Laptop/backups/var
# Backup /etc, including the firewall script and upstart/init scripts
rdiff-backup --remote-schema '$Schema' /etc firstname.lastname@example.org::/mnt/Laptop/backups/etc
# Backup /opt, mostly unpackaged non-debian stuff
rdiff-backup --remote-schema '$Schema' /opt email@example.com::/mnt/Laptop/backups/opt
# Do post-backup stuff
What kind of pre- or post- backup actions? How about sanity checks, like that the server is available?
Since the server requires root to mount the backup drive, we need to create a socket for backups. The server will see which machine is asking to send or complete a backup, and mount/unmount the appropriate drive.
We need to write some logic to trigger the process.