Want to get Lullabot article, videocast, and podcast announcements delivered right to your in-box?
Let us know your email address (we won't share it) and we'll let you know when anything exciting happens.
How do you backup your webserver?
Everyone has heard the mantra "make regular backups", but how many people really do it? And how is it done? I have just started using duplicity and the ftp space provided by my web host, Strato.de to make my backups. I've also experimented with mondorescue which was very handy for making bootable iso images of my server. Here's the recipe for duplicity + Debian Etch + ftp. What's your recipe?
Making full and incremental backups of a Debian Etch webserver using ftp and duplicity
These instructions are only slightly modified from this article on the lovely Drupal-powered Go2Linux.org.
- Install pgp.
apt-get update
apt-get install pgp - Install duplicity.
apt-get install duplicity - Generate a key.
gpg --gen-key
This command will take you through a series of questions which you must answer. It will ask you for a pass phrase. Remember this! Write it down somewhere so that you never forget it. Otherwise you won't be able to use your backup to restore any data.Furthermore, during the key generation the gpg program uses system entropy to generate random numers. An idle system doesn't generate enough entropy to satisfy the programs needs for randomness. I had to open a second shell and run
grep -r "Hello World" /in order to have the system be active enough to generate entropy. If you run into this problem, just open a shell, type the grep command I suggest, and wait for gpg to finish. It will eventually notice and keep going. - Look at your available keys.
gpg --list-key
The results will resemble this:
/root/.gnupg/pubring.gpg
------------------------
pub 1024D/67F85ABC 2007-07-04
uid Robert Douglass (Hello World) <robert@example.com>
sub 1024g/6C
You're interested in the 67F85ABC bit. - Make a script to do the backup. I put this in /usr/local/sbin and called it duplicity-backup.
#!/bin/sh
export PASSPHRASE=Ididntforgetmypassphrase
export FTP_PASSWORD=s3kret
duplicity --encrypt-key "67F85ABC" --sign-key "67F85ABC" \
--exclude /sys \
--exclude /mnt \
--exclude /tmp \
--exclude /proc \
--exclude /dev \
/ ftp://username@ftpserver/directory \
| mail -s "duplicity backup report" robert@example.comNote the next to the last line of the script is the from=>to part of the command. In my case, since I want to back up the entire server, the from part is / (the root of the file system) and the to part is the ftp connection string for my ftp server. One GOTCHA I ran into here was the directory bit. I tried without it but got an error. As a minimum you have to provide / as the remote directory.
The last line of the script tells duplicity to direct its output to the mail program. Mail will send an Email to robert@example.com with the results of the backup. This is how you can keep track of whether your backups are going smoothly or not.
- Make sure your script is executable:
chmod u+x /usr/local/sbin/duplicity-backup - Test it! I tested my script by running the following:
cd /usr/local/sbin
./duplicity-backup
It took a while to run, but I was able to confirm that duplicity was sending things to ftp by logging into the ftp server and looking around. The next step would be for me to restore something... I'll do that next. - Automate it! Since I don't want to run this command every time I want a backup made, I've set up a cron task to run the script for me every night at 3:15 AM.
crontab -e
... and then enter something like this:
15 3 * * * /usr/local/sbin/duplicity-backup > /dev/null 2>&1
I'll get back with updates on how it's working out for me. In the meantime, has anyone got a successful Amazon S3 webserver backup working? What tools did you use? I spent a ton of time looking at things and nothing worked for me as well as this solution. I'd really like to utilize S3 for this task, though, so please share your experiences.
Comments on this post will automatically be closed three months from the original post date.



RSS Feed


Comments
Symmetric Encryption
It's also possible to use symmetric encryption, that is what I used to use.
Cool. Please share the
Cool. Please share the details =)
Backup?
WHAT'S THAT???!
LOL - Too true
Unfortunately I suspect (based on my personal historical behavior) that this is a summary of the common mindset.
Rsync...
Rsync + hard links, like on:
http://www.mikerubel.org/computers/rsync_snapshots/
+ few custom scripts (eg run dpkg --get-selections to get a list of installed .deb's and create dumps of your database)
To restore, just install a minimal debian, use dpkg to set the previously copied list of installed packages, install them and rsync /etc and all your data. Reboot.
I use 2 custom scripts, one
I use 2 custom scripts, one for mysql dbs and the other to backup the webserver. I rotate them to have 7 full days, one week, and one month backed.
For the webserver I just backup the www and etc dirs.
Kind regards, Simon.
scp
If you would like to use scp instead of ftp, make sure you define a passwordless SSH connection.
More info: http://www.rsync.net/resources/howto/duplicity.txt
backup-manager
I found backup-manager to be a nice tool, after some tuning depending on your host :
http://www2.backup-manager.org/Home
It is a bunch of shell code that uses usual backup tools to provide a nice feature set (incremental, encryption, mysql, upload/transfers via rsync, ssh, ftp). It is configurable by a global config file, which is also a nice source of information on how to configure the whole thing. It also seems to handle uploads to Amazon S3.
Worth a try.
Here is another approach with rsync
I wrote an article that includes a script detailing how to do incremental backup of Drupal using rsync (and optionally iBackup.com).
backing up drupal on a wamp system
How do i go about backing up drupal on a wamp system?
Duplicity have backup to S3.
Duplicity have backup to S3. Get the lastest version. You'll need a couple of environment variables like
export AWS_ACCESS_KEY=MYACCESSKEY
export AWS_SECRET_ACCESS_KEY=MYSECRETKEY
The url type for the amazon servers is s3+http://bucketname
works like a champ.