Using the Duplicity restoration utility

Procédure

Duplicity

Duplicity is a software package that provides encrypted remote backup.

Duplicity designs a scheme where the first archive is a full backup, and subsequent incremental backups only add differences to the last full or incremental backup. Chains consisting of a full backup and a series of incremental backups can be recovered when one of the incremental steps has been performed. If one of the incremental backups is missing, the subsequent incremental backups cannot be reconstructed.

Duplicity uses the SFTP and FTP(S) protocols so it can work from a local GNU/Linux machine or a VPS server to a VPS server or a LWS Drive "rsyncscpdrive" backup formula.

Install Duplicity

Included as a package with most distributions.

To install Duplicity on your local machine or VPS server, a simple command is required.

apt install duplicity

Application

The script below makes backups of your websites available for a period of two months. Old backups are deleted. A new full backup is made on the first day of each month.

Separate backups for individual directories can be created using the DIRS variable in the script.

For example, the script can be edited and saved as /root/backup.sh:

$ nano /root/backup.sh

Access details such as username, password and hostname must be adjusted accordingly before being used. Similarly, the GPG passphrase used for backup encryption.

As an example, we will use a user from the LWS Drive backup formula "rsyncscpdrive" under the name cdXXXX.

#!/bin/bash # # Simple script for creating backups with Duplicity. # Full backups are made on the 1st day of each month or with the 'full' option. # Incremental backups are made on any other days. # # USAGE: backup.sh [full] # # get day of the month DATE=`date +%d` # Set protocol (use SFTP or FTP, see manpage for more) PROTO=sftp # set user and hostname of backup account USER='cdXXXXX' HOST='rs1.cloudlws.com' # Setting the password for the Backup account that the # backup files will be transferred to. # for sftp a public key can be used, see: PASSWORD='password' # directories to backup DIRS="/var/www/monsiteweb.fr/web /home" TDIR="files/"$(hostname -s) # Setting the pass phrase to encrypt the backup files. Will use symmetrical keys in this case. PASSPHRASE='yoursecretgpgpassphrase' export PASSPHRASE ############################## if [ $PASSWORD ]; then BAC="$PROTO://$USER:$PASSWORD@$HOST" else BAC="$PROTO://$USER@$HOST" fi # Check to see if we're at the first of the month. # If we are on the 1st day of the month, then run # a full backup. If not, then run an incremental # backup.

if [ $DATE = 01 ] || [ "$1" = 'full' ]; then TYPE='full' else TYPE='incremental' fi for DIR in $DIRS do # first remove everything older than 2 months duplicity remove-older-than 2M -v5 --force $BAC/$TDIR/$DIR # do a backup duplicity $TYPE -v5 $DIR $BAC/$TDIR/$DIR done # Check the manpage for all available options for Duplicity.
# Unsetting the confidential variables unset PASSPHRASE unset PASSWORD exit 0

Then to make it executable:

$ chmod 755 /root/backup.sh

To create a full backup at time T using the backup.sh script:

$ /root/backup.sh full

Files or directories not to be backed up are passed to Duplicity using --exclude.

The script can be run through a daily cron job, /etc/cron.weekly or /etc/cron.monthly. A crontab can also be used to set an exact time by configuring a file under /etc/cron.d/:

0 0 * * * /root/backup.sh >/dev/null 2>&1

By following this documentation, you will be able to install and use the Duplicity utility to restore your data.
You can consult our various online backup offers on our sales site.

Rate this article :

This article was useful to you ?

Article utileYes

Article non utileNo

Vous souhaitez nous laisser un commentaire concernant cet article ?

Si cela concerne une erreur dans la documentation ou un manque d'informations, n'hésitez pas à nous en faire part depuis le formulaire.

Pour toute question non liée à cette documentation ou problème technique sur l'un de vos services, contactez le support commercial ou le support technique

MerciMerci ! N'hésitez pas à poser des questions sur nos documentations si vous souhaitez plus d'informations et nous aider à les améliorer.


Vous avez noté 0 étoile(s)

Similar articles

0mn reading

Backing up your PC with Cobian Backup

0mn reading

Windows mount point

1mn reading

Using Borg Backup for your backups


Ask the LWS team and its community a question