Duplicity is a command-line utility for backup and recovery. Backups can be uploaded to storage using protocols such as SCP, SFTP, WebDAV, S3, Swift, and others. By default, the utility encrypts backups using GnuPG.
Below is an example of setting up Duplicity for backing up data to Hostman object storage using the Swift protocol.
Create a separate bucket for backups.
Install the duplicity package on the server along with the required dependencies.
For Duplicity versions below 0.8.x (which use Python 2), you need the python-swiftclient
package.
For Duplicity version 0.8.x and above, install python3-swiftclient
.
Use the following commands:
sudo apt-get install duplicity
sudo apt-get install python3-swiftclient
Create a file named backup.sh
with the following content, replacing the variable values with your actual credentials. You can find them in the Swift parameters section in your bucket Settings.
#!/usr/bin/env bash
export SWIFT_PASSWORD="storage_password"
export SWIFT_AUTHVERSION=2
export SWIFT_TENANTNAME="account_login"
export SWIFT_USERNAME="account_login"
export SWIFT_AUTHURL="URL"
export PASSPHRASE="encryption_password"
source=/home # Path to the directory to be backed up
dest=bucket_name # Destination bucket for backups
duplicity "$source" swift://"$dest"
Run the following command to make the script executable:
chmod +x backup.sh
Execute the script with the following command:
./backup.sh