How to prepare OS for supporting consistent backup#

To ensure snapshot consistency during backup, install and configure QEMU Guest Agent used by the backup service to freeze I/O to/from the guest OS. In case of Linux, additional preparation of applications is required to provide application data consistency.

Windows preparation#

To ensure consistency of backups of Windows instances, it is enough to install QEMU Guest Agent. It calls Volume Shadow Copy Service (VSS) to freeze the file system and applications such as Windows SQL Server. Thus, no additional setup is required, since VSS ensures the necessary preparation of compatible applications.

To install QEMU Guest Agent on a guest Windows:

  1. Download the image with qemu-guest-agent and drivers.

  2. Mount the downloaded ISO image within a VM.

  3. Install the Virtioserial driver.

  4. Install qemu-guest-agent.

  5. Reboot the operating system.

Linux preparation#

To ensure file system consistency during backup, install QEMU Guest Agent on an instance. To ensure application data consistency, also download hooks for the corresponding applications. The choice of hooks depends on the installed applications.

Hooks are executable utilities/scripts. Actions performed by the hook depend on the application whose data consistency needs to be ensured. By default, NGN Cloud images do not have pre-installed hooks.


This instruction assumes the use of Ubuntu 20.04 or CentOS 8.2.

QEMU Guest Agent installation#

  1. To install QEMU Guest Agent on a guest OS, run the following commands:

    apt install qemu-guest-agent
    systemctl enable qemu-guest-agent
    yum install qemu-guest-agent
    systemctl enable qemu-guest-agent --now
  2. To freeze applications, the unit file of the service must be configured to start a script, which in turn starts the necessary hooks:

    ExecStart=-/usr/sbin/qemu-ga -F/etc/qemu/fsfreeze-hook
    ExecStart=-/usr/bin/qemu-ga -F/etc/qemu-ga/fsfreeze-hook
  3. Restart the service:

    systemctl daemon-reload
    systemctl restart qemu-guest-agent

Hook preparation#

The required executable files of the hooks should be stored in the following directories:


Freeze/thaw process#

Before making a volume snapshot, the backup service sends the freeze command to QEMU Guest Agent to stop I/O. Having received the command, the agent calls the script specified in the settings (see step 2 of QEMU Guest Agent installation), which in turn starts hooks from fsfreeze-hook.d directory. The freeze value is passed to each hook as the first argument.

After hooks start, their output is logged in /var/log/qga-fsfreeze-hook.log file. Hook execution results do not impact subsequent file system freezing. The master script simply writes the hook completion status to the log.

Hooks are executed first, then fsfreeze command runs, which saves the file system cache to a volume and freezes I/O. Thawing uses the reversed sequence: the file system is thawed first, and then the hooks (with the thaw argument) are started.