...
An alternative to repeating all the steps here multiple times is to use the automation script below, where one can set up a configuration file detailing all the instances, volumes, etc, to be backed up, and run the script a single time.
Scheduling backups
It is often quite useful to schedule a backup for a specific time in the future, as well as to repeat that scheduled backup regularly, to ensure the preservation of any changes. In order to prepare a scheduled backup, with or without repetition, one can set up a cron job that will run in the background and perform the necessary operations. A full tutorial on how to use cron is beyond the scope of this page, more details can be found elsewhere, e.g. https://crontab.guru/. Here only a few examples will be shown.
First, it is worth reminding that it it advisable that the creation of snapshots and backups is done in a different machine that the one backing up. Consequently, the cron job should also be run in a different machine. To run a cron job, ensure that cron is installed in the machine, e.g.
| Code Block |
|---|
sudo apt update && sudo apt install cron |
in Ubuntu distributions, and start the cron services with
| Code Block |
|---|
sudo systemctl enable cron |
Once cron is running, to configure a cron job, one must edit the crontab file with
| Code Block |
|---|
crontab -e |
and add there the command to be executed and the frequency. For example, to create an image snapshot of a VM every Saturday at 12pm, the crontab entry will look like
| Code Block |
|---|
0 12 * * Sat openstack server image create --name <image_name> <server> |
.Note that this job will necessarily fail, since the cron service does not use the environment varriables with the OpenStack credentials that are needed to use the OpenStack CLI. Hence, a better solution is to write a shell script that will load the appropriate environment variables and run any operations. Thus, the same example with the correct OS credentials will look like
| Code Block |
|---|
0 12 * * Sat run_backup_job.sh |
with the script run_backup_job.sh
| Code Block |
|---|
for var in $(env | sed -n 's/^\(OS.*\)=.*/\1/p'); do unset "$var"; done
export OS_AUTH_URL=https://keystone.cloudferro.com:5000/v3
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
export OS_USERNAME="<username>"
export OS_REGION_NAME="WAW3-1"
export OS_PROJECT_ID="<project_id>"
export OS_PROJECT_NAME="<project_name>"
export OS_PROJECT_DOMAIN_ID="<domain_id>"
export OS_PASSWORD="<password>"
export OS_CLIENT_ID=openstack
export OS_CLIENT_SECRET=08eb53c3-3cac-4a01-8406-d72f6a70948b
export OS_PROTOCOL=openid
export OS_IDENTITY_PROVIDER=eumetsat_provider
export OS_AUTH_TYPE=v3oidcpassword
export OS_DISCOVERY_ENDPOINT="https://identity.cloudferro.com/auth/realms/Eumetsat-elasticity/.well-known/openid-configuration"
openstack server stop <server>
openstack server image create --name <image_name> <server>
openstack server start <server> |
WIP
Backup automation
| Anchor | ||||
|---|---|---|---|---|
|
The multi-step procedure for creating backups of instances and volumes, including the scheduling and repetition of backups, can been performed in a single step using the script found in the repository
TODO: Link to repository
A simple configuration YAML file detailing the instances and volumes to back up, as well as the start and frequency of the scheduling, can be used to run the script. Instructions on how to run the script can be found in the README file in the repository itself.WIP