How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Linux

Creating Incremental and Encrypted Backups with Duplicity

How VPS by How VPS
January 1, 2020
in Linux
0
0
SHARES
132
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Overview
  2. Setting up environment
    1. Terminology
    2. Installing Duplicity
      1. Ubuntu 14.04:
      2. CentOS (requires EPEL):
      3. Ubuntu 12.04/Debian 7:
    3. Setting up key-less authentication for SSH
  3. Backups
    1. Running the first (full) backup
    2. Running incremental backup
  4. Automation
    1. Write automated scripts
      1. Full backup script
      2. Incremental backup script
      3. Make scripts executable
    2. Setup cron
  5. Restoration
  6. Want to contribute?


Overview

While Vultr does have a backup system for entire system images, this works at the block level, and requires that the backup is restored to a VM before the data can be restored. Additionally, backups are only stored for a short amount of time, and do not provide a true incremental backup solution.

Enter Duplicity – Duplicity builds upon the legendary rsync and provides the ability to store incremental backups along with encrypting the data at rest via GPG. It is Posix compliant, and only transfers deltas between backup runs, thus reducing the overall bandwidth requirement.

Setting up environment

Terminology

  • Source host – Server which will have its data backed up. For this tutorial, it has the IP address: 10.1.10.1
  • Backup host – Destination server for backups. For this tutorial, it has the IP address: 10.1.10.2
  • /backupdir – Source directory on source host used for backups in this tutorial. You can change this to match your environment.
  • /destdir – Destination directory on backup host used for backups in this tutorial. You can change this to match your environment.
  • Full backup – Entire copy of the source dataset.
  • Incremental backup – Copy of all the changes made since the last backup.

Installing Duplicity

Ubuntu 14.04:
sudo apt-get update
sudo apt-get install duplicity python-paramiko
CentOS (requires EPEL):
sudo yum install duplicity python-paramiko
Ubuntu 12.04/Debian 7:
sudo apt-get update 
sudo apt-get install ncftp python-paramiko python-pycryptopp lftp python-boto python-dev librsync-dev
wget https://launchpad.net/duplicity/0.7-series/0.7.02/+download/duplicity-0.7.02.tar.gz
tar xzvf duplicity*
cd duplicity*
sudo python setup.py install

We have to install from source as the Duplicity package within Debian 7 and Ubuntu 12.04 are broken due to a change in the backend SSH library.

Double check that Duplicity is installed by running:

duplicity -v

It should return the following output (version may be different):

duplicity 0.6.18

Setting up key-less authentication for SSH

The next step is to setup certificate-based authentication for SSH between the backup host and the source host. This will enable the source server to SSH into the backup host without typing in a passphrase. Vultr has a great article which explains how to do this: How Do I Generate SSH Keys.

Backups

Running the first (full) backup

Let’s run a full backup! This will send a full copy of data from the source server to the destination.

duplicity full -v --no-encryption --include="/sourcedir/" --exclude="**" /  ssh://[email protected]:22/destdir/

You can add additional folders by including multiple --include="[dir]" statements.

The --no-encryption specifies that the data is not to be encrypted at the destination. Data will be encrypted during transport as it’s passing through the SSH tunnel.

The --exclude="**" / option is a trick to backup everything that is only in the include list (and nothing else).

Running incremental backup

Running an incremental backup is very simple – just change the full flag to the incremental flag.

duplicity incremental -v --no-encryption --include="/sourcedir/" --exclude="**" /  ssh://[email protected]:22/destdir/

Automation

Write automated scripts

Having to run these commands every time you need a backup is a drag – what if we had scripts to handle it for us?

Full backup script

Run the command.

nano /usr/local/bin/backup-full

Add the following content.

#!/bin/bash
duplicity full -v --no-encryption --include="/sourcedir/" --exclude="**" /  ssh://[email protected]:22/destdir/
Incremental backup script
nano /usr/local/bin/backup-incremental

Add the following content.

#!/bin/bash
duplicity incremental -v --no-encryption --include="/sourcedir/" --exclude="**" /  ssh://[email protected]:22/destdir/
Make scripts executable

To make the scripts executable, run the following command.

chmod +x /usr/local/bin/backup-*

Now you can perform a backup by running backup-full and backup-incremental from within the shell. Pretty cool!

Setup cron

Let’s make the backups automatic! By setting up cron to run the above scripts at specified times, we can make sure that backups are performed at regular intervals.

Run the following command.

crontab -e

Add the following to the bottom of the file.

10 01 * * 1,2,3,4,5,6 backup-incremental
10 01 * * 7 backup-full

This will run a full backup every Sunday at 1:10 AM, and will run incremental backups every other day at 1:10 AM as well.

Restoration

Godzilla has destroyed Seattle and we need to be able to get the data back from the backup VPS in New York!

duplicity --no-encryption --file-to-restore / ssh://[email protected]:22/destdir/

If we need to restore data from 3 days ago:

duplicity --no-encryption -t 3D --file-to-restore / ssh://[email protected]:22/destdir/

The -t 3D option means restore a backup from three days ago. Similar options like -t 1M (for one month ago) or -t 5H (for 5 hours ago) also work.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
How VPS

How VPS

Related Posts

How to Install Apache Tomcat 8 on CentOS 7
Linux

How to Install Apache Tomcat 8 on CentOS 7?

February 11, 2020
Linux

Setup IonCube Loader on Ubuntu 14

January 1, 2020
Linux

Converting from MySQL to MariaDB on Ubuntu

January 1, 2020
Next Post

Hot Backups with Percona XtraBackup on the One-Click WordPress App

Setup LetsEncrypt On Linux

Creating a Jekyll Blog on Ubuntu 16.04

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

Setup Timezone and NTP on Ubuntu 14.04

3 years ago

How to Install Pagekit 1.0 CMS on a FreeBSD 11 FAMP VPS

3 years ago

How to Install ARK Survival Evolved (ArkSE) on CentOS 7

3 years ago

Converting from MySQL to MariaDB on Ubuntu

3 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.