Creating a backup of your croit configuration

Securing the configuration is an essential task, which has to be mastered in the daily administrative work with all IT components. To make this task as easy as possible for you, we have created an example script.

Most of the configuration is within Ceph itself, so only a very small backup is required. We recommend backing up the SQL database and the croit base configuration as a whole.

In general, it would be sufficient to back up the admin key, but this would make the recovery considerably more difficult. Especially when it comes to backup, reliability as well as quick and easy availability are absolutely mandatory.

What data does croit store?

Our croit-data docker container holds the following data:

/config croit Server configuration like port, SSL certificate, etc.
/var/lib/mysql SQL database with information about the configured networks, users, ceph.conf, etc.
/logs log data of all servers
/stats Graphite database with cluster and server statistics
/images operating system images that can be downloaded again at any time

Note: If you do not want to lose historical log and statistics data, you must save all these folders, unlike the example below.

Create a backup

As described above, the folders /config and /var/lib/mysql contain all data that are really important from our point of view. To make a simple backup possible, we have created an example script.

We deliver these directly in the Docker container under /scripts starting with the v1710 release. Alternatively, you can find our example script at github.com/croit/scripts. The scripts are named config.backup.sh and config.restore.sh and require the tool tar on the host.

After you have saved the backup script on the management server, you can adjust the included backup path.

# adjust backup dir as needed
BACKUP_DIR="/backups/croit/$(date +%s)"

Note: We strongly recommend that you store the backup on a separate storage medium!

When you start the program, the backup will be created in the backup directory:

~ $ ./config.backup.sh 
Starting backup to /backups/croit/1505384885
croit
create database backup from /var/lib/docker/volumes/401a2b3e6358d00e4c24f24fa3b13e03fd29cbe3b10534701453413912eff448/_data
create config backup from /var/lib/docker/volumes/13ad6bdb46c31973afd1c0013fef1f7dd24675c45f67747c158f63c9a9be2016/_data
backup based on a container with tags croit:latest
croit

Note: During execution, the management interface is not available for a short period of time and about 15 seconds after completion. However, the cluster’s operations are not adversely affected in any way.

Optional: Backup of server logs and statistics

Of course, you can also backup the directories described above under /logs and /stats. Please adapt the example script to your individual requirements.

You should also note that logs and statistics in larger installations mean many hundreds of gigabytes of data and represent purely historical information. In addition, recovery times are considerably longer, therefore why we advise against it.

Restore a backup

As for the backup, we provide a config.restore.sh sample script. Please adapt the directory to your individual needs.

# adjust backup dir as needed
BACKUP_DIR="$(ls -v1d /backups/croit/* |tail -n 1)" # gets the latest backup directory

To restore a backup, no docker container named croit and croit-data must exist on the system. These are automatically generated by the script and filled with the backup data. Any old, faulty or defective containers can be deleted before the recovery via “docker rm -f croit croit-data”.

Now run the script to restore the croit management interface:

~ $ ./config.restore.sh 
Restoring Backup from /backups/croit/1505384885
with container release version croit:latest
aa4203846ed75211bf3eaea1b077155e241f584223776856edc4862be003b243
Restoring MySQL/MariaDB
Source      = /backups/croit/1505384885/db.tgz
Destination = /var/lib/docker/volumes/1416c18b37fddf2ebd01852c51f560457fe03eb3adf64a78ffe9f027d31fcc0a/_data
Restoring croit config
Source      = /backups/croit/1505384885/config.tgz
Destination = /var/lib/docker/volumes/6f05321df9e7d12d5e56898754b3d21f5801770ef25cd50f1c9108b0595b8425/_data
backup restored to data container 'croit-data', starting container croit now
45ced47ee56444573d63ee3a78fd04740947a7548c9e5a39369fc91057f35562

After about 15-30 seconds you can access the restored interface as usual.

Important information about backups

Whenever you create a backup, please keep in mind that a backup is not secure without a regular check of the recoverability. You should therefore actively try and make sure that your backup is working properly at regular intervals. This is the only way to ensure that your backup will work reliably when it matters.