Trilio Database Backup
OpenStack VM Database Backups with Trilio
1. Basic Backup Snapshot
Use case: Quick VM backup, no setup, acceptable minor data loss.
Follow steps mentioned in a basic Trilio Usage.
https://docs.uniccloud.org/docs/IaaS/Backups/Trilio/Create
This method does not automatically guarantee database-level consistency, if there are transactions in memory not persisted to disk, they won't be in the backup.
If write ahead logs/redo files are also in a bad state the DB might not start cleanly but in practice most modern DBs are designed to recover from a crash consistent state (Innodb or WAL)
2. VM-Consistent Backup (with QEMU Guest Agent)
Use case: Reduce filesystem corruption risk. Acceptable memory transantions loss.
Steps
A. Install QEMU Guest Agent
- Install QGA:
sudo apt update && sudo apt install qemu-guest-agent -y
sudo systemctl enable qemu-guest-agent
B. Enable QGA in OpenStack
- Set VM flavor/image property:
openstack flavor set <flavor> --property hw_qemu_guest_agent=yes - Reboot VM if needed.
- Perform Trilio Backup as in the previous step.
Recovery: Restore VM. Filesystem is consistent; database may need checks.
3. Application-Consistent Backup(with Custom Hooks)
Use case: Guarantee database full consistency with no transaction loss.
Steps
A. Install QEMU Guest Agent (as above)
B. Add Custom Hooks
-
Create hook directory:
sudo mkdir -p /etc/qemu/fsfreeze-hook.d/ -
Add pre-freeze hook (MySQL example):
echo '#!/bin/bash
mysql -e "FLUSH TABLES WITH READ LOCK; SYSTEM sync;"' | sudo tee /etc/qemu/fsfreeze-hook.d/mysql-pre-freeze.sh
sudo chmod +x /etc/qemu/fsfreeze-hook.d/mysql-pre-freeze.sh -
Add post-thaw hook:
echo '#!/bin/bash
mysql -e "UNLOCK TABLES;"' | sudo tee /etc/qemu/fsfreeze-hook.d/mysql-post-thaw.sh
sudo chmod +x /etc/qemu/fsfreeze-hook.d/mysql-post-thaw.sh -
Check database logs.
-
Perform Trilio Backup as in the previous step.