Backups VM data in SwissBackup using Restic
This tutorial aims to present the different steps to back up and restore data from your VMs in the SwissBackup infrastructure which replicates your data 3 times in our datacenters in Switzerland. The backup tool used is restic.
Instead of infomaniak SwissBackup you can use your public cloud swift storage or any OpenStack Swift storage
Restic is an efficient and secure backup tool developed in Golang :
- Compatible with SwissBackup (OpenStack Swift backend)
- No complexe setup
- Only transfers detected changes to saved files / folders
- Uses robust cryptographic tools to ensure the integrity and security of your data
- Make sure you can restore your data when you need it
- Full opensource tool : restic official Github
You have 90 free days of SwissBackup product. You can easily create your account in the Infomaniak manager.
- Add a device:
- Choose Free storage space:
- See your Swiss Backup credentials:
$ apk add restic
$ yum install yum-plugin-copr
$ yum copr enable copart/restic
$ yum install restic
$ apt-get install restic
$ dnf install restic
$ pkg install restic
$ apt-get install restic
$ zypper install restic
If you have a problem going through the official directories of the distributions listed above or you install on another distribution you can still install restic through the official binaries.
wget -O restic.bz2 https://github.com/restic/restic/releases/download/v0.12.0/restic_0.12.0_linux_amd64.bz2
chmod +x restic
mv restic /usr/bin/
Verify restic install
$ restic version restic 0.12.0 compiled with go1.15.8 on linux/amd64
Create an encryption key
You must first create an encryption key that will be used encrypt your data in our infrastructure. Please note that this encryption key can't be changed and in the event of its loss your data will no longer be readable.
To generate a strong key you can use the command
$ openssl rand -base64 14
You must store this key in a single text file so that it can be read by restic when using it. For example:
$ echo <My-password> > /path/to/your/file/containing_the_key
Create the Restic configuration file:
Based on the credentials you received after the creation of your SwissBackup account, create for example the file
/home/user/restic_credentials with the following content, replace the different variables accordingly to your credentials.
export OS_AUTH_URL=https://swift02-api.cloud.infomaniak.ch/identity/v3 export OS_REGION_NAME=RegionOne export OS_PROJECT_NAME=sb_project_SBI-XXXX export OS_PASSWORD=<SwissBackup password> export OS_USER_DOMAIN_NAME=default export OS_USERNAME=SBI-XXXX export OS_PROJECT_DOMAIN_NAME=default export RESTIC_REPOSITORY=swift:sb_project_SBI-XXXX:/<bucket name> export RESTIC_PASSWORD_FILE=</path/to/your/file/containing_the_key>
OS_AUTH_URL: Url to access the SwissBackup cluster. https://swift02-api.cloud.infomaniak.ch/identity/v3 or https://swift01-api.cloud.infomaniak.ch/identity/v3
OS_PROJECT_NAME: SBI-XXX is your SwissBackup username provided by mail and on your manager
RESTIC_REPOSITORY: Bucket name is container in swift used to store data. Bucket name could be
My_VM_name for example.
Source the restic configuration file
You can now load your credentials and initialize your directory to perform your first backup
Initialise the repository
restic -r swift:sb_project_SBI-XXXX:/<bucket name> init
Launch your first backup in SwissBackup !
restic backup /path/to/folder/to/backup
$ restic snapshots repository aa122fb4 opened successfully, password is correct ID Time Host Tags Paths ----------------------------------------------------------------------- e4a5efe5 2021-07-17 15:51:17 node50252-env-0519885 /root/ /root 81ccf1c7 2021-07-17 15:52:04 node50252-env-0519885 /root/ /root 93fe4ac2 2021-07-17 15:52:42 node50252-env-0519885 /root/ /root 8542ab6b 2021-07-17 15:53:49 node50252-env-0519885 /root/ /root 479e18bb 2021-07-17 15:55:08 node50252-env-0519885 /root/ /root fe37266f 2021-07-17 20:00:01 node50252-env-0519885 /root/ /root 001c4236 2021-07-18 16:12:23 node50252-env-0519885 /root/ /root 6eb3949a 2021-07-18 20:00:01 node50252-env-0519885 /root/ /root cf41fc20 2021-07-19 20:00:01 node50252-env-0519885 /root/ /root ----------------------------------------------------------------------- 9 snapshots
You can back up your entire filesystem excluding system folders or categorize your backups by tag or machine name more details here: Restic backup doc
Load restic credentials
You must load your restic credentials before each backup / list / restore action.
restic backup /path/to/my/folder
restic backup --one-file-system /
Take the id of the snapshot to restore
restic restore <snapshot-ID> --target </destination/folder/to/restore/data>
More details about restic restoration: Restic restoration doc