Duplicity With Wasabi

Prev Next

How do I use Duplicity with Wasabi?

Wasabi has been validated for use with Duplicity. Duplicity backs directories by producing encrypted tar-format volumes and uploading them to a remote or local file server and cloud storage providers.

1. Prerequisites

2. Configuring a Backup Job

There are many ways to configure the scripts for the backup jobs. This section references an example configuration from this article.

2.1. Login to the server with Duplicity installed. Create a backup script using the following command.

vim /usr/local/sbin/backup.sh

2.2. Add the following code to the backup.sh script. Provide the Wasabi account and bucket details for the below parameters - 

  • AWS_ACCESS_KEY_ID="XXXXXX" <---provide your Wasabi access key.

  • AWS_SECRET_ACCESS_KEY="XXXXXXX" <---- provide your Wasabi secret key

  • PASSPHRASE-"****" <-----provide a password to encrypt the backups

  • DEST="s3://s3.us-west-1.wasabisys.com/duplicity-2/" <--- endpoint URL of the Wasabi region, followed by the bucket name. 

Note: This script is an example, please modify it per your requirements.

#!/bin/bash

# Export some ENV variables so you don't have to type anything
export AWS_ACCESS_KEY_ID="XXXXXX" 
export AWS_SECRET_ACCESS_KEY="XXXXXXX"
export PASSPHRASE="*****"

# The S3 destination followed by bucket name
DEST="s3://s3.us-west-1.wasabisys.com/duplicity-2/"


# Set up some variables for logging
LOGFILE="/var/log/duplicity/backup.log"
DAILYLOGFILE="/var/log/duplicity/backup.daily.log"
FULLBACKLOGFILE="/var/log/duplicity/backup.full.log"
HOST=`hostname`
DATE=`date +%Y-%m-%d`
TODAY=$(date +%d%m%Y)

is_running=$(ps -ef | grep duplicity | grep python | wc -l)

if [ ! -d /var/log/duplicity ];then
mkdir -p /var/log/duplicity
fi

if [ ! -f $FULLBACKLOGFILE ]; then
touch $FULLBACKLOGFILE
fi

if [ $is_running -eq 0 ]; then
# Clear the old daily log file
cat /dev/null > ${DAILYLOGFILE}

# Trace function for logging, don't change this
trace () {
stamp=`date +%Y-%m-%d_%H:%M:%S`
echo "$stamp: $*" >> ${DAILYLOGFILE}
}

# How long to keep backups for
OLDER_THAN="1M"

# The source of your backup
SOURCE=/

FULL=
tail -1 ${FULLBACKLOGFILE} | grep ${TODAY} > /dev/null
if [ $? -ne 0 -a $(date +%d) -eq 1 ]; then
FULL=full
fi;

trace "Backup for local filesystem started"

trace "... removing old backups"

duplicity remove-older-than ${OLDER_THAN} ${DEST} >> ${DAILYLOGFILE} 2>&1

trace "... backing up filesystem"

duplicity \
${FULL} \
--include=/var/rsnap-mysql \
--include=/var/www \
--include=/etc \
--include=/home/user1/ \
--exclude=/** \
${SOURCE} ${DEST} >> ${DAILYLOGFILE} 2>&1

trace "Backup for local filesystem complete"
trace "------------------------------------"

# Append the daily log file to the main log file
cat "$DAILYLOGFILE" >> $LOGFILE
fi

Note: This configuration example discusses the use of Wasabi's us-west-1 storage region. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in our Wasabi Service URLs article.

2.3. Run the backup job by running the following command. 

bash /usr/local/sbin/backup.sh

3. Configuring a Restore Job

3.1. Create a restore script using the following command.

vim /usr/local/sbin/restore.sh

3.2 Add the following code to the script.


#!/bin/bash
# Export some ENV variables so you don't have to type anything
export AWS_ACCESS_KEY_ID="5V5RQJTUGBPO3W7FGXXB"
export AWS_SECRET_ACCESS_KEY="h57aWfAguptJf3LHwezHM5aZ05VDa63qfgMCFNjy"
export PASSPHRASE="wasabi"

# The S3 destination followed by bucket name
DEST="s3://s3.us-west-1.wasabisys.com/duplicity-2/"

# Your GPG key
#GPG_KEY=YOUR_GPG_KEY

if [ $# -lt 3 ]; then echo "Usage $0   "; exit; fi

duplicity \
--restore-time $1 \
--file-to-restore $2 \
${DEST} $3

Note: This configuration example discusses the use of Wasabi's us-west-1 storage region. To use other Wasabi storage regions, please use the appropriate Wasabi service URL as described in our Wasabi Service URLs article.

3.3. Run the following command to perform a restore. 

bash /usr/local/sbin/restore.sh