To make sure we can generate a GPG Key, we need to create some entropy. We suggest using Haveged constantly on your server to generate a small amount of entropy.
Transferring your data from Dedibox to Elastic Metal
- dedibox
- elastic-metal
- migration
This tutorial provides information about how to migrate your existing data from a Dedibox to an Elastic Metal server. Its purpose is to guide you in your migration to the resources that best fit your needs for improved stability, performance, and reliability.
We use Duplicity to encrypt the backup and upload it to Object Storage. Then we download and decrypt the data on the Elastic Metal server.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- An SSH key
- A Dedibox server
- Created and installed an Elastic Metal server
Creating an Object Storage bucket
- Log in to the Scaleway console.
- Click Storage on the side menu. A list of your buckets appears. If you have not created a bucket yet, the list will be empty.
- Click Create a Bucket.
- Name your bucket and validate your bucket creation. The bucket name must be unique and contain only alphanumeric and lowercase characters.
Installing software requirements on the Dedibox server
Run the following command to update the APT package manager, upgrade the software already installed on the server, and download and install Duplicity:
apt update && apt upgradeapt install -y python3-boto python3-pip haveged gettext librsync-devwget https://gitlab.com/duplicity/duplicity/-/archive/rel.2.2.2/duplicity-rel.2.2.2.tar.gztar xaf duplicity-2.2.*.tar.gzcd duplicity-2.2.*/python3 -m pip install -r requirements.txtpython3 -m pip install
In the command above, we download Duplicity version 2.2.2
. Check the Duplicity website for the latest version of the tool.
Creating a GPG key
-
To generate the GPG key, launch this command.
gpg --full-generate-keyEnter a passphrase. You will be asked to define the characteristics of your key. We will go with the default settings:
- What kind of key you want: (1) RSA and RSA (default)
- What keysize do you want: (3072)
- How long the key should be valid: 0 = key does not expire
- GPG will then ask how to call your key, an address, and a description.
-
You need to use the GPG Key fingerprint, it could be an 8, 16, or 40 char long hash. You can also find the fingerprint of your key with the command:
gpg --list-keysgpg: checking the trustdbgpg: marginals needed: 3 completes needed: 1 trust model: pgpgpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u/home/me/.gnupg/pubring.kbx------------------------------pub rsa3072 2022-01-25 [SC]XXXXXXXXXXXXX-FINGERPRINT-XXXXXXXXXXXXXXuid [ultimate] backups (Scaleway Object Storage backups) <me@scaleway.com>sub rsa3072 2022-01-25 [E]
Transferring the PGP key to the Elastic Metal server
- Export the keys so you can decrypt your files on the Elastic Metal server. Also having the GPG private and public keys stored somewhere else will come in handy in case you lose access to your machine. Export the GPG keys with:
gpg --export-secret-key keyname > ~/my-key.asc
- Transfer the key to the Elastic Metal server using
rsync
.scp /root/my-key.asc root@<elastic-metal>:/root/
Backing up your Dedibox
- Create the required folders and a configuration file for Duplicity:
touch scw-backup.sh .scw-configrcchmod 700 scw-backup.shchmod 600 .scw-configrcmkdir -p /var/log/duplicitytouch /var/log/duplicity/logfile{.log,-recent.log}
- Add the following lines to
.scw-configrc
:# Scaleway credentials keysexport AWS_ACCESS_KEY_ID="<SCALEWAY ACCESS KEY>"export AWS_SECRET_ACCESS_KEY="<SCALEWAY SECRET ACCESS KEY>"export SCW_BUCKET="s3://s3.fr-par.scw.cloud/<NAME OF YOUR BUCKET>"# GPG Key informationexport PASSPHRASE="<YOUR GPG KEY PASSPHRASE>"export GPG_FINGERPRINT="<YOUR GPG KEY FINGERPRINT>"# Folder to back upexport SOURCE="<PATH TO FOLDER TO BACKUP>"# Log filesexport LOGFILE_RECENT="/var/log/duplicity/logfile-recent.log"export LOGFILE="/var/log/duplicity/logfile.log"log () {date=`date +%Y-%m-%d`hour=`date +%H:%M:%S`echo "$date $hour $*" >> ${LOGFILE_RECENT}}export -f log - Copy the following script to
scw-backup.sh
:#!/bin/bashsource <FULL PATH TO>/.scw-configrccurrently_backuping=$(ps -ef | grep duplicity | grep python | wc -l)if [ $currently_backuping -eq 0 ]; then# Clear the recent log filecat /dev/null > ${LOGFILE_RECENT}log ">>> creating and uploading backup to Object Storage"duplicity \full \--asynchronous-upload \--encrypt-key=${GPG_FINGERPRINT} \--sign-key=${GPG_FINGERPRINT} \${SOURCE} ${SCW_BUCKET} >> ${LOGFILE_RECENT} 2>&1cat ${LOGFILE_RECENT} >> ${LOGFILE}fi - Run the backup:
./scw-backup.sh
- Check if everything went well:
cat /var/log/duplicity/logfile-recent.log
Restoring data on your Elastic Metal server
- Install the required prerequisites and duplicity on the Elastic Metal server:
apt update && apt upgradeapt install -y python3-boto python3-pip gettext librsync-devwget https://launchpad.net/duplicity/0.8-series/0.8.21/+download/duplicity-0.8.21.tar.gztar xaf duplicity-0.8.*.tar.gzcd duplicity-0.8.*/pip3 install -r requirements.txtpython3 setup.py install
- Import the GPG key on the Elastic Metal server:
gpg --import my-key.asc
- Create the required folders and a configuration file for Duplicity:
touch scw-restore.sh .scw-configrcchmod 700 scw-restore.shchmod 600 .scw-configrcmkdir -p /var/log/duplicitytouch /var/log/duplicity/logfile{.log,-recent.log}
- Add the following lines to
.scw-configrc
:# Scaleway credentials keysexport AWS_ACCESS_KEY_ID="<SCALEWAY ACCESS KEY>"export AWS_SECRET_ACCESS_KEY="<SCALEWAY SECRET ACCESS KEY>"export SCW_BUCKET="s3://s3.fr-par.scw.cloud/<NAME OF YOUR BUCKET>"# GPG Key informationexport PASSPHRASE="<YOUR GPG KEY PASSPHRASE>"export GPG_FINGERPRINT="<YOUR GPG KEY FINGERPRINT>"# Folder to back upexport SOURCE="<PATH TO FOLDER TO BACKUP>"# Log filesexport LOGFILE_RECENT="/var/log/duplicity/logfile-recent.log"export LOGFILE="/var/log/duplicity/logfile.log"log () {date=`date +%Y-%m-%d`hour=`date +%H:%M:%S`echo "$date $hour $*" >> ${LOGFILE_RECENT}}export -f log - Edit the file
scw-restore.sh
, and add the following:#!/bin/bashsource .scw-configrcecho -e "Downloading full backup to:" $1duplicity \--time 0D \${SCW_BUCKET} $1 - Download the data from your bucket to the Elastic Metal server:
./scw-restore.sh /tmp/backup-recovery/
Once downloaded you can move the data to its final destination onto your new machine.
You can also use Duplicity for regular and incremental backups of your data on the Object Storage platform. Follow our tutorial How to back up your dedicated server on Object Storage with Duplicity for more information.