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

John Legend Is Your New Google Assistant—Listen for Yourself Google started an unusual artificial intelligence experiment this month. If you instruct its Siri-style virtual assistant to “talk like a Legend,” it ...
What you missed in cybersecurity this week It’s been a busy week — it’s tough to keep up with all the cybersecurity news. We’ve collected some of the biggest cybersecurity stories from the week...
Boston Dynamics debuts the production version of SpotMini Last year at our TC Sessions: Robotics conference, Boston Dynamics announced that SpotMini will be its first commercially available product. A revampe...
Platforms Want Centralized Censorship. That Should Scare You In the immediate aftermath of the horrific attacks at the Al Noor Mosque and Linwood Islamic Centre in Christchurch, New Zealand, internet companies f...
Spread the love

Posted by News Monkey