I wanted to make a quick backup of the blog, the files in /var/www/html and the MySQL database dump to another server. This is the process I followed on Ubuntu but works on any system.
Install Duplicity.
I found on my cloud providers image I had to also install python-paramiko (YMMV). Obviously other OS have different package managers, or you can install from source
Secure the transport between servers
Now generate a key pair, pressing enter at the prompt asking for a password. You want a password-less SSH key.
Copy the key across to the server you will be backing up to (obviously use your own account name, not mine :)
Check that you can now login to the backup server without a password, and create your backup directory while there, then exit.
Setup the file encryption
For the encryption we are using GPG, and the following commands will store our keys in /root/.gnupg/
The defaults are fine, with your email address. You want a password for your backups here. Where the ssh key pair protects the connection between your server and the backup server, this password will encrypt your data, and you will need it to decrypt your backups.
You will be setting up a passphrase to use with GPG, and then it will generate some randimosity.
You can then view your keys with
We will put this passphrase for encrypting in a safe file.
Setup MySQL
We want to run MySQL commands without entering password, so we store the user and password in the ~/.my.cnf configuration file.
Set the permissions so only owner can read or write, and check that it works
The Script
Create a script to run daily
Create a script to run weekly
Viola! To restore fully (You will need to unpack your db and import to MySQL however):
And it will suck all those files back onto your server ...or you can just grab a file that you may need with