1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Backing up web hosting with Restic on Swiss Backup (Swift)
This guide details how to back up data from your Web hosting (Starter, shared, or Managed Cloud Server) using the restic application via the OpenStack Swift protocol on Swiss Backup, the backup solution in an independent Swiss cloud.
Other solutions for backing up your web data exist: read this guide (click here).
Prerequisites
- Use a Web hosting
- Own an Infomaniak Swiss Backup space with an available device quota (minimum 1) for Cloud backup
- Add 1 Cloud type device to get OpenStack Swift settings
⚠️ Swiss Backup is compatible with any application supporting Openstack Swift, S3 Compatible, or SFTP. For additional help, contact the support of the used software or a partner — also read the host's role
Install Restic
- Download the linux_amd64 binary from the restic github repository
uid@h2web:~$ wget -O restic.bz2 https://github.com/restic/restic/releases/download/v0.14.0/restic_0.14.0_linux_amd64.bz2⚠️ the download link may vary when a new version is released; version 0.14 uses default compression - Decompress the archive and make the binary executable
uid@h2web:~$ bunzip2 restic.bz2
uid@h2web:~$ chmod +x restic
Configure Restic
Create an encryption key to encrypt data
- the key cannot be changed, and in case of loss, the data will no longer be readable
- Place this key in a file readable by Restic
- Example of generating a key:
uid@h2web:~$ openssl rand -base64 16 > restickey
Restic configuration
To configure the backup:
- Create a resticconfig file with the following content to adapt according to the specific information of your device (read this guide - click here):
echo "export OS_AUTH_URL=https://swiss-backupXX.infomaniak.com/identity/v3
export OS_REGION_NAME=RegionOne
export OS_PROJECT_NAME=sb_project_SBI-XXXX
export OS_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:/
export RESTIC_PASSWORD_FILE=restickey" > resticconfOS_AUTH_URL
Access URL to the Swiss Backup clusterOS_PROJECT_NAME
andOS_USERNAME
replace SBI-XXXX with your IDOS_PASSWORD
replace with the password generated during activationRESTIC_REPOSITORY
- replace SBI-XXXX with your ID
- replace the
bucket name
with the name you want to give to your container that stores the backups
RESTIC_PASSWORD_FILE
replace with the full path to the file containing the encryption key
- Load the Restic configuration by running the following command:
source resticconf - Initialize the bucket with the following command:
uid@h2:~$ ./restic -r $RESTIC_REPOSITORY init
Back up your files
To back up your files, simply run the following command:
uid@h2:~$ ./restic backup
The first snapshot takes a long time (several hours depending on the amount of data) because all files are copied, while subsequent ones will use the differential principle.
Back up databases
Restic allows reading data from stdin to record the output of a program.
Use the following command to back up an individual MySQL database:
mysqldump --databases database_name -u database_user -p | restic backup --stdin --stdin-filename database_dump.sqlTo back up all databases, run the mysqldump command to extract all databases from the server, then redirect the output to Restic:
mysqldump -u database_user -p --all-databases | restic backup --stdin --stdin-filename all_databases.sql
List backups
To list your backups, you can use the following command:
uid@h2:~$ ./restic snapshotsRestore a backup
You can restore a backup with the following command:
uid@h2:~$ ./restic restoreAutomate
On Managed Cloud Server, it is possible to add a cron task to automate the backup launch.
On shared hosting, this option is not available.