How to Create Encrypted and Bandwidth-efficient Backups Using ‘Duplicity’ in Linux

Experience shows that you can never be too paranoid about system backups. When it comes to protecting and preserving precious data, it is best to go the extra mile and make sure you can...

Spread the love

Experience shows that you can never be too paranoid about system backups. When it comes to protecting and preserving precious data, it is best to go the extra mile and make sure you can depend on your backups if the need arises.

Create Encrypted Linux File System Backups

Duplicity – Create Encrypted Linux File System Backups

Even today, when some cloud and hosting providers offer automated backups for VPS’s at a relatively low cost, you will do well to create your own backup strategy using your own tools in order to save some money and then perhaps use it to buy extra storage or get a bigger VPS.

Sounds interesting? In this article we will show you how to use a tool called Duplicity to backup and encrypt file and directories. In addition, using incremental backups for this task will help us to save space.

That said, let’s get started.

Installing Duplicity

To install duplicity in Fedora-based distros, you will have to enable the EPEL repository first (you can omit this step if you’re using Fedora itself):

# yum update && yum install epel-release

Then run,

# yum install duplicity

For Debian and derivatives:

# aptitude update && aptitude install duplicity

In theory, many methods for connecting to a file server are supported although only ssh/scp/sftp, local file access, rsync, ftp, HSI, WebDAV and Amazon S3 have been tested in practice so far.

Once the installation completes, we will exclusively use sftp in various scenarios, both to back up and to restore the data.

Our test environment consists of a CentOS 7 box (to be backed up) and a Debian 8 machine (backup server).

Creating SSH keys to access remote servers and GPG keys for encryption

Let’s begin by creating the SSH keys in our CentOS box and transfer them to the Debian backup server.

The below commands assumes the sshd daemon is listening on port XXXXX in the Debian server. Replace AAA.BBB.CCC.DDD with the actual IP of the remote server.

# ssh-keygen -t rsa
# ssh-copy-id -p XXXXX [email protected]

Then you should make sure that you can connect to the backup server without using a password:

Create SSH Keys

Create SSH Keys

Now we need to create the GPG keys that will be used for encryption and decryption of our data:

# gpg --gen-key

You will be prompted to enter:

  1. Kind of key
  2. Key size
  3. How long the key should be valid
  4. A passphrase
Create GPG Keys

Create GPG Keys

To create the entropy needed for the creation of the keys, you can log on to the server via another terminal window and perform a few tasks or run some commands to generate entropy (otherwise you will have to wait for a long time for this part of the process to finish).

Once the keys have been generated, you can list them as follows:

# gpg --list-keys
List Generated GPG Keys

List Generated GPG Keys

The string highlighted in yellow above is known as the public key ID, and is a requested argument to encrypt your files.

Facebook Comments

More Stuff

Deal: Learn Application Building with ‘The Complete API Mastery Bu... An API (Application Programming Interface) is a collection of program definitions, plus some protocols and different tools for development of software...
Virtual Reality’s Latest Use? Diagnosing Mental Illness Diagnosing psychiatric and neurological conditions is tricky. Physicians have long reported that diagnoses are fraught with complications and subtleti...
Beginners Guide to Web Hosting This guide is designed to walk you through which elements are the key components of web hosting. We will address the various kinds of web hosting, the...
How to Install MongoDB on Ubuntu 16.04/14.04 LTS In this how to guide we shall go through the various steps of installing the latest version of MongoDB in Ubuntu 16.04 and Ubuntu 14.04 LTS systems. R...
Spread the love

Posted by News Monkey