A SHORT INTRODUCTION TO DUPLICITY WITH CLOUD OBJECT STORAGE Version 1.12 2014-07-01
PAGE _ 2 TABLE OF CONTENTS 1. Introduction....Page 03 2. System Configuration....Page 04 3. Create Backup Script....Page 05 4. Setup Periodic Backups....Page 07 5. Restore Files....Page 08
PAGE _ 3 1. INTRODUCTION Welcome to Cloud&Heat! The purpose of this document is to show you how to use the Duplicity software in combination with Cloud Object Storage. Duplicity is free software available under the GNU General Public License (GPL) and provides encrypted remote backups of files and directories. We will provide you with a backup script and walk you though how to set it up to perform a backup on a regular basis. Duplicity works best on an all Unix-like system like Linux and MacOSX, but can also be used to backup Windows systems under Cygwin. Duplicity supports deleted files, Unix permissions, directories and symbolic links. The steps we will go though are the following: 1) System configuration (Section 2). 2) Create backup script (Section 3). 3) Setup periodic backups (Section 4). In Section 5, we also show how to restore the files that were backed up. The backup script runs on all systems where python-2, duplicity-0.6.22 and python-swift client are installed. Instructions on how to make your system meet these requirements are included in Section 2. The instructions in this document have been tested with Ubuntu 12.04 and 13.10 with the Desktop and Server alternatives, respectively.
PAGE _ 4 2. SYSTEM CONFIGURATION The steps we need to perform to setup the system that should be backed up are as follows: 1) Log in to the machine that you want to backup. This could be your local computer or a VM running in the Cloud. For instructions on how to log in to a Cloud&Heat VM, please see A Short Introduction to Cloud Compute. 2) Make sure the system is up-to-date: sudo apt-get update sudo apt-get -y upgrade 3) In order to get the newest version of Duplicity, we now add an external repository. sudo add-apt-repository -y ppa:duplicity-team/ppa 4) On Ubuntu 12.04 we also need to execute sudo add-apt-repository -y cloud-archive:havana Note: On Ubuntu you can find out which version you have by executing the following command: lsb_ release -a 5) Then we install the necessary programs: sudo apt-get update sudo apt-get install -y duplicity python-swiftclient anacron 6) Verify that the correct version of Duplicity was installed - at least 0.6.22 is required. duplicity --version
PAGE _ 5 3. CREATE BACKUP SCRIPT We will now create the backup script itself. In this example we name the file backup_home.py, assuming we want to backup the home directories located in /home. 1) Create a directory for the backup script: sudo mkdir -p /usr/local/bin 2) Download the backup script template from the Cloud&Heat Dashboard under Access & Security API Access Download Duplicity Script. See A Short Introduction to Cloud Compute for instructions on how to log in to the Cloud&Heat Dashboard. Save the template as /usr/local/bin/backup _ home.py. 3) Modify the backup script template by setting the values for all variables starting and ending with @@. The values for all these variables should be chosen according to the following guidelines: @@DASHBOARD _ PASSWORD@@: This the password used to log in to the Cloud&Heat Dashboard. Warning: If the password contains the character, it has to be preceded by a backslash (\). @@PASSWORD _ BACKUP@@: Password used to symmetrically encrypt the backup. Warning: If the password contains the character, it has to be preceded by a backslash (\). @@CONTAINER _ NAME@@: The name of the container in which the backup should be stored in the Cloud. The name can only contain the characters a-z, A-Z, 0-9 or -. The container may already exist and will be accessible under the Containers tab in the Cloud&Heat Dashboard. See A Short Introduction to Cloud Object Storage for instructions on how to access it. @@BACKUP _ DIRECTORY@@: Path of the directory to be backed up, e.g., /home. @@BACKUP _ EXCEPTIONS@@: A list of absolute paths of directories within @@BACKUP _ DIRECTORY@@ that should not be backed up. Multiple entries are possible and given in a (possibly empty) list. For example, if the directories @@ BACKUP _ DIRECTORY@@/paul and @@BACKUP _ DIRECTORY@@/anja/Downloads should be excluded from the backup, the variable @@BACKUP _ EXCEPTIONS@@ in the backup script, should be replaced by the following: [ /home/paul/, /home/anja/downloads ]
PAGE _ 6 4) Finally the access should be limited to the root user: sudo chown root:root /usr/local/bin/backup _home.py sudo chmod 700 /usr/local/bin/backup_ home.py 5) To check that the script works one can now run it using: sudo /usr/local/bin/backup _ home.py It should exit without errors. To verify that the backup was stored in the Cloud Object Storage, log in to the Cloud&Heat Dashboard (see A Short Introduction to Cloud Compute for instructions) and go to the Containers tab in the side bar on the left. Here you should see a container with the name you chose (the @@CONTAINER _ NAME@@ from Section 3) and if you click on its name you should see the backup as its content.
PAGE _ 7 4. SETUP PERIODIC BACKUPS To automatically perform the backup on a regular basis, we recommend using the program anacron. It is already installed, so all we need to do is the following: Create a symbolic link with the following command: sudo ln -s /usr/local/bin/backup _ home.py /etc/cron.daily/backup_ home Note that the name of the link in /etc/cron.daily cannot contain the. character, and thus we call it backup _ home instead of backup _ home.py. Apart for the directory cron.daily (used for daily backups) the directories cron.hourly, cron.monthly and cron.weekly also exist. See the man page for anacron for more information. Note: The files in the cron directories must have names that only consist of the following characters: Capital and lower case letters (A-Za-z), digits (0-9), underscores (_) and dashes (-). Otherwise they will not be executed.
PAGE _ 8 5. RESTORE FILES To restore the backup, the following command can be used (the values to use for the variables are described below): SWIFT _ USERNAME= OS _ PROJECT _ NAME:OS _ USERNAME \ SWIFT _ AUTHURL= OS _ AUTH _ URL \ SWIFT _ AUTHVERSION=2 \ SWIFT _ PASSWORD= @@CLOUDANDHEAT _ DASHBOARD _ PASSWORD@@ \ duplicity swift://@@container _ NAME@@ @@TARGET _ DIRECTORY@@ The @@ variables, must all be set to the same values as they had in the backup script that performed the backup (see Section 3). @@TARGET _ DIRECTORY@@ should be the name of the directory where the backup should be restored. Directories that were excluded when performing the backup will not be created. To find the values for variables starting with OS_, download the RC file from the Cloud&Heat Dashboard under Access & Security API Access Download OpenStack RC File. After executing the command you will be asked for a passphrase. This is the @@PASSWORD _ BACKUP@@ that was used in the backup script.