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 me@myserver.com::/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' me@myserver.com::/mnt/Laptop/backups/me
You can see how this can be scripted to make things easy:
#!/bin/sh
# 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 me@myserver.com::/mnt/Laptop/backups/me
# Backup /var, including the package list and cache and all the logs
rdiff-backup --remote-schema '$Schema' /var me@myserver.com::/mnt/Laptop/backups/var
# Backup /etc, including the firewall script and upstart/init scripts
rdiff-backup --remote-schema '$Schema' /etc me@myserver.com::/mnt/Laptop/backups/etc
# Backup /opt, mostly unpackaged non-debian stuff
rdiff-backup --remote-schema '$Schema' /opt me@myserver.com::/mnt/Laptop/backups/opt
# Do post-backup stuff
exit 0
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.
Your remote-schema doesn't work. Rdiff-backup seems to be fixated on using only 22.
ReplyDeleteWell, it seemed to work for me three years ago.
ReplyDeleteI use something else now, so I'm not very motivated to investigate.