System Backup
A database backup is of no use unless you have a backup of the system encryption key. To retrieve the encryption key, see the section Encryption Key Backup. It will not be included in any of your backups.
Backup
Automated Backup
VirtFusion supports automated backups of its database using either local storage, SCP or a combination of both. You can find the settings in the admin area System -> System Backup
. All the options should be self explanatory.
Manual Backup
We know some people like to be in full control of their backups are prefer to offload backups using different methods. Below you will find a few examples on how to dump the database.
Dumping the Database
Simple dump:
mariadb-dump --skip-ssl --user=root `cat /opt/virtfusion/app/control/.env | grep 'DB_DATABASE' | cut -d'"' -f2` > /tmp/database.sql
Single transaction using gzip
compression:
mariadb-dump --skip-ssl --single-transaction --opt --user=root `cat /opt/virtfusion/app/control/.env | grep 'DB_DATABASE' | cut -d'"' -f2` | gzip > /tmp/database.gz
Encryption Key Backup
The system encryption key must be securely stored in a safe location. Without this key, certain parts of the database will be inaccessible and unusable. The encryption key is not included in backups.
To retrieve the encryption key, run the following command via SSH on the control server as a privileged user:
vfcli-ctrl app:retrieve-key
Restore
Restoring on a New Control Server
Database
For this guide, we’ll assume your database backup is saved in the /tmp
folder and called either database.sql
or database.gz
. If your file has a different name, just replace it with the correct one when following the steps.
If the database is not compressed:
mariadb --user=root `cat /opt/virtfusion/app/control/.env | grep 'DB_DATABASE' | cut -d'"' -f2` < /tmp/database.sql
If the database is gzip
compressed:
gzip -d /tmp/database.gz
mariadb --user=root `cat /opt/virtfusion/app/control/.env | grep 'DB_DATABASE' | cut -d'"' -f2` < /tmp/database
Encryption Key
Edit /opt/virtfusion/app/control/.env
:
nano /opt/virtfusion/app/control/.env
Replace the APP_KEY
value and save the configuration.
Example:
APP_KEY=base64:/Ph6OtUdimmo2EiYlUbd9zx+BKM72NNRWnVAd3pE498=