Skip to main content

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

info

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

  1. Install QGA:
    sudo apt update && sudo apt install qemu-guest-agent -y
    sudo systemctl enable qemu-guest-agent

B. Enable QGA in OpenStack

  1. Set VM flavor/image property:
    openstack flavor set <flavor> --property hw_qemu_guest_agent=yes
  2. Reboot VM if needed.
  3. 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

  1. Create hook directory:

    sudo mkdir -p /etc/qemu/fsfreeze-hook.d/
  2. 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
  3. 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
  4. Check database logs.

  5. Perform Trilio Backup as in the previous step.