Mistral workflows and schedulers
This section provides a guide for automating Cinder volume backups in OpenStack using Mistral workflows. Mistral allows you to define workflows to create full and incremental backups, manage backup rotation, and automate backup retention policies.
Available Mistral Workflows for Volume Backups
Three predefined Mistral workflows are available for automating Cinder volume backups:
1. cinder_volume_backup_full
- Creates a full backup of a specified volume.
- If a backup already exists, it will create a new independent full backup.
2. cinder_volume_backup_full_incremental
- Creates a full backup if no existing backup is found.
- If a full backup already exists, it will create an incremental backup instead.
3. cinder_volume_backup_rotation
- Creates a full backup and incremental backups based on defined rotation policy.
- Allows you to set limits on the number of full and incremental backups.
- Automatically deletes all incremental backups and creates a new full backup when the incremental backup limit is reached.
- Automatically deletes the oldest full backup when the full backup limit is reached.
- To run workflow provide the following arguments:
volume_id
– ID of the volume to back up.backup_name
– Name of the backup.max_full_backups
– Maximum number of full backups to keep.max_incremental_backups
– Maximum number of incremental backups to keep per full backup.
Running Mistral Workflow Using Horizon
- Log in to the Horizon Dashboard.
- Navigate to Workflows → Workflows.
- Find the workflow you want to run (e.g.,
cinder_volume_backup_full
,cinder_volume_backup_full_incremental
, orcinder_volume_backup_rotation
). - In the Actions column, click "Execute" next to the desired workflow.
- In the Parameters field, enter the required arguments.
Running Mistral workflow using CLI
To use the openstack workflow
command, you need to install the python-mistralclient library:
dnf/apt/pip install python-mistralclient
Running workflow examples:
- Create a Full Backup:
openstack workflow execution create cinder_volume_backup_full \ '{"volume_id":"<volume_id>", "backup_name":"<backup_name>"}'
- Create a Full or Incremental Backup (if full exists):
openstack workflow execution create cinder_volume_backup_full_incremental \ '{"volume_id":"<volume_id>", "backup_name":"<backup_name>"}'
- Create Backup with Rotation Policy:
openstack workflow execution create cinder_volume_backup_rotation \ '{"volume_id":"<volume_id>", "backup_name":"bkp1", "max_full_backups":2, "max_incremental_backups":5}'
Checking Workflow Status in Horizon
- Navigate to Workflows → Workflow Executions.
- The status of the workflow will be displayed under the State column:
SUCCESS
– Workflow completed successfully.RUNNING
– Workflow is still executing.FAILED
– Workflow execution failed (check logs for details).
- Click on the workflow execution ID to see detailed information about the execution.
Creating a Cron Trigger in Mistral
You can automate volume backups by setting up a cron trigger in Mistral. Cron triggers allow you to schedule Mistral workflows to run at specific times or intervals using cron expressions.
Creating a Cron Trigger
To create a cron trigger for volume backups using the openstack cron trigger create
command:
openstack cron trigger create <trigger_name> cinder_volume_backup_rotation \ '{"volume_id":"<volume_id>","backup_name":"<backup_name>","max_full_backups":2,"max_incremental_backups":5}' \ --pattern "0 * * * *"
Explanation:
Parameter | Description |
---|---|
<trigger_name> | Name of the cron trigger. |
cinder_volume_backup_rotation | Workflow name to execute. |
{"volume_id": ..., "backup_name": ..., ...} | JSON data containing workflow input parameters. |
--pattern "0 * * * *" | Cron pattern defining the schedule. |
Cron Pattern Format:
The cron pattern follows the format:
* * * * * | | | | | | | | | +---- Day of the week (0-7, Sunday=0 or 7) | | | +------ Month (1-12) | | +-------- Day of the month (1-31) | +---------- Hour (0-23) +------------ Minute (0-59)
Examples:
Cron Pattern | Schedule |
---|---|
0 * * * * | Every hour |
0 2 * * * | Every day at 2:00 AM |
0 2 * * 1 | Every Monday at 2:00 AM |
*/15 * * * * | Every 15 minutes |
0 0 1 * * | First day of every month at midnight |
Key Notes
- Mistral cron triggers are ideal for automating backups at regular intervals.
- The cron pattern follows standard Linux cron format.
- Ensure that the
python-mistralclient
package is installed before creating a cron trigger. - You can manage cron triggers using the
openstack cron trigger
commands.