Backing up your Debian/Ubuntu VPS to Rackspace Cloud Files

Backing up your Debian/Ubuntu VPS to Rackspace Cloud Files

There are quite a number of tutorials available on backing up to Amazon S3, which is popular due to its redundancy and low cost (15cents per gigabyte). I prefer Rackspace Cloud Files though due to its lower upload fees (8cents vs 10cents per gigabyte of bandwidth).  We will use duplicity to create the backups because it is bandwidth efficient and also allows us to encrypt our backups.

We will also be setting up the cloudcity script to make it easier to automate the backup and restore process.

First set up build essential so that you can do necessary compiling later.

apt-get install build-essential

Install duplicity

Debian Lenny and Ubuntu < 10.04 come with older versions of Duplicity. We need to add additional repositories to install a newer version of duplicity from.

On Debian Lenny

nano /etc/apt/sources.list

add this line

deb lenny-backports main contrib non-free

Next run the following commands in succession

apt-get update
apt-get install debian-backports-keyring
apt-get -t lenny-backports install duplicity

On Ubuntu 9.10 and earlier

sudo add-apt-repository ppa:duplicity-team/ppa

On older (pre 9.10) Ubuntu systems:

sudo nano /etc/apt/sources.list

Add the relevant Duplicity source; for Ubuntu 8.04 it would be:

deb hardy main

deb-src hardy main

Next run these commands

sudo apt-key adv –keyserver –recv-keys 7A86F4A2

sudo apt-get update

sudo apt-get install duplicity

Check that the installed version is > 0.5

duplicity –version

Setup your GPG keys for encryption of your backups

gpg –gen-key

You’ll be walked through a few options for your key, select the following:

Key type – DSA and Elgamal (Default)
Key size – 2048 bits (Again, the default)
Expiration – Do not expire
Name, Comment and Email – You can enter whatever you like here
Password – Make sure you remember whatever you type, there’s no way to get it back if you forget!

When it talks about “generating entropy” to make the key, it means that the server needs to be in use in order for it to get some random numbers. Just go refresh a webpage on the server a few times, or run some commands in another terminal window.


Create backups of your keys by following the steps here:

Copy the backups to a safe and secure location – OFF this computer.

Install python-cloudfiles

Browse to

Download and extract the tgz of the latest release. Then install it.


tar xzvf rackspace-python-cloudfiles-48dd7c8.tar.gz

cd rackspace-python-cloudfiles-48dd7c8

python install

Setup cloudcity

Browse to
Copy the text of the cloudcity script and edit the following lines at minimum:

# Cloud Files information you can get from
export CLOUDFILES_USERNAME=your_username
export CLOUDFILES_APIKEY=your_api_key

#This is the password you typed in when creating your GPG keys earlier
export PASSPHRASE=your_gpg_passphrase

# Specify the name of the container/directory in your Cloud Files account where the backup files are to be stored

# List ONLY the directories that you want to backup, for instance
INCLUDE_LIST=( “/home” “/root” “/var/www”)

Edit the other parameters as desired.

Create a file for the script


and paste the edited script contents discussed above.

Next give it permissions to run

chmod +x

Ok you’re ready to backup!


When completed, you will see

“Backup complete”.

You may wish to setup a cron job to call this script every night.

To view restore options

./ –help

Be sure to keep a copy of!

Restoring on another computer

In the event of a catastrophic crash, the computer you are restoring your backups to will need to be set up the same way as above but with ONE difference; do not create GPG keys again, but restore your keys (that you’d backed up earlier) following the steps here

Now use to restore your backed up files!

Note: Here is a similar tutorial on backing up your MySQL databases to Rackspace Cloud Files

  • Major thanks for the article post. Will read on…