Backup of a computer system is very important as it can prevent you from data loss in case of system failure. Duplicity is an open-source data backup tool that provides encrypted, digitally signed, and versioned local or remote backup of files.
In this article, I will discuss how to install and use Duplicity in Ubuntu Linux.
Features of Duplicity data backup software
The key features of Duplicity data backup software are –
- Relatively easy to automate backup
- Encrypts and compresses your backups by default
- Takes incremental backups
- Allows incremental restoration from backups
- Supports multiple different protocols
- It can self-heal if a backup goes wrong
- Supports AWS S3 very well by default
How to install Duplicity in Ubuntu
Before you run the command to install Duplicity on your system make sure to update the apt package index to get the latest version of it.
Use the following command to update the apt package index –
sudo apt install update
Next, run the given command to install Duplicity in your system –
sudo apt install duplicity
Now when it asks for your confirmation press y and then enter.
You can verify the installation by using the given command –
Configure passwordless SSH
First, generate the SSH keys to securely authenticate the remote system that doesn’t require a password for taking backup. Use the given command to generate an RSA key with the following command.
ssh-keygen -t rsa -m PEM
Next, use the following command to copy the create RSA key to the remote server that you want to backup.
ssh-copy-id [email protected]_ip_address
For example –
ssh-copy-id [email protected]
Create GPG keys
GPG keys are used to provide an extra layer of security and encryption of the data transferred across the servers. So we need to generate it to encrypt data before we transfer it to the remote backup server
Use the following command on the Duplicity server to generate the GPG key –
You can list the GPG keys by using the given command –
Create a backup directory
After completing the above steps run the given command to create a backup directory on the backup server.
mkdir -p /lalit/Duplicity/
Once completed you can start backing up a system.
Backing up a directory
Run the following command to back up a directory named
/etc of a system to the remote backup server inside
duplicity /etc/ sftp://[email protected]//lalit/Duplicity/
This will ask you to enter the password of your GPG key, enter it to perform the backup operations.
Now on your backup server, you can verify the backup by using the given command.
This will display the list of backed-up files.
Restoring from backup
You can restore files and directories that you have backed up earlier to the remote server by using the option
For example to restore the directory named
/etc from the backup server to the
/etc directory on your system run the following command –
PASSPHRASE="[email protected]" duplicity --encrypt-key 6683A9D4720C5895BF7A7AE9E8A334EB747BAD6A --file-to-restore etc sftp://[email protected]//lalit/Duplicity/ /etc
This will start the restoration process on your system.
Ok, that is how you can use duplicity to backup and restore your system. You can automate the backup operations by using the cron.
Now if you have a query then write us in the comments below.