I want to use duplicity to backup my cloud server on Linode (You can use AWS as well or any other provider through which you can scp/ssh). Why I want to use duplicity is also because or partial backups, since the first backup will be full and all continuous ones will be only for the difference in files.
Why Raspberry pi? It’s cheap, low power and very portable :)d
So let’s proceed with the setup.
- ssh keys
Installation and configuration:
Before anythign else, it is highly recomended your Raspberry Pi is up to date and that you run:
sudo apt-get update
For installation of duplicity, after the update, it should run fairly smoothly with the following command:
sudo apt-get install duplicity
In case you want encryption which I highly recommend, setting up GPG keys is recommended and supported by Duplicity. For that we first need to install GPG with:
sudo apt-get install gnupg
Perfect, now we have the proper tool installed and need to generate appropriate key with all the info you will be required in the command prompt. Run this command and follow the instructions, and most importantly note them down somewhere! You don’t want to lose your password.
At one point you will encounter “Not enough random bytes available. Please do some other work to give
the OS a chance to collect more entropy!”
And i simply didn’t have enough entropy.
But if you want to know how big your entropy is you can check with cating:
For me it was 34. After that I have installed:
sudo apt-get install rng-tools
And it increased to over 1000. which is absolutely great. After that the GPG key got automatically generated. Do however note, that you need to run this entropy related commands in parallel to your terminal in another window.
gpg –list-key you should be able to see now your newly created gpg key.
Then let’s try it with:
duplicity full ssh:root:password@IPofHOST// home/pi/backup
This will fail. I just wished to demonstrate this so other people don’t need to investigate through the same problem, that is that duplicity can’t use remote as source.
As a solution I am mounting remote to be a fake local mount with:
apt-get install sshfs
After that we will run:
mkdir -p /mnt/remote &&
sshfs root:password@IPofHOST:/ /mnt/remote
This will mount it locally and you can therefore specify your local backup paths for Duplicity
The mentioned tool has a range of commands, but one of them that you could potentially use for that would be then:
duplicity /home/directory file://some/other/directory