A schedule with 'a full backup every N backups' above one makes a
checkpoint with each running VM's backup. The next builds on the
schedule's newest ready backup: the changed blocks are pushed into qcow2
volumes made with the base's file as backing file, by its name, as the
target pool's directory differs per host. The base is used only when its
chain is shorter than N, its disks are the VM's, every file of the chain
is in the target, and its checkpoint has a sized bitmap for every disk;
otherwise the backup is full and starts a chain.
Before each scheduled backup of a running VM, the VM's backup
checkpoints are pruned to each schedule's newest base. A checkpoint
libvirt no longer lists, as after a migration, is redefined first so
that its bitmap goes too.
A shut-off VM's backup checkpoints are forgotten before its external
snapshot: libvirt 11.10 makes no offline external snapshot while a
checkpoint exists. The next scheduled backup is then full.
The VM's disks are copied from the backup as new volumes beside the old
ones, which stay until removed by hand. Then the switch, recorded first and
finished by recovery: the NVRAM file and the TPM state are replaced by the
backup's, and the VM's own definition points at the copies with a new
generation ID. Its devices, MACs and UUID stay. A VM that is not shut off,
has snapshots or a saved state, or whose disks, UEFI firmware or TPM are
not the backup's, is refused; the checks run again before the switch.
The restore writes the backup's TPM state files into libvirt's swtpm
directory of the new VM's UUID before the VM is defined; libvirt makes
them swtpm's when the VM starts and keeps the state, so the guest keeps
its TPM identity. A file name from a manifest that is not a plain name is
refused before anything is made, a host without swtpm is refused, and
recovery of a restore that did not define its VM removes the files.
A VM with the panel's emulated TPM 2.0 is backed up when it is shut off:
each state file of libvirt's swtpm directory for the VM, read through a
transient pool on it, becomes a small file of the backup (role tpm),
written and read back like the NVRAM file. A running or paused VM with a
TPM is refused, and so is a TPM with its own settings (encryption, a
state path, another backend). The manifest says whether the TPM state was
copied or never written.
A ready backup has a Restore button (Backups page and the VM's tab) and
POST /api/v1/backups/<uuid>/restore/. The form takes the new VM's name
(default <vm>-restored), a compute that has the target's pool, the pool
for its disks, Connect the network (off by default: the restored guest
keeps the VM's addresses and host name) and Start after restore. The job
page follows the restore.
The backup.restore job holds what a new VM's job holds, the backup
(shared) and the target. Before anything is made it checks again: the
host is not in maintenance; the name is free in the panel and on the
host (a VM made with virsh too); the backup's files are in the target,
the disks at their size and the small files with their SHA-256; the
host offers the definition's emulator, machine type and firmware, its
networks, bridges and network filters; the destination pool has room
and none of the copies' names. The new VM's UUID, MACs, volume names and
NVRAM path are recorded first. Then the disks are copied from the
target, the NVRAM file uploaded, maintenance checked once more, and the
VM defined last and given to the superuser who restored it.
The definition is the kept one rewritten as a clone's (rewrite_for_new_vm,
taken out of _clone_definition for both): new name, UUID and SMBIOS
UUID, MACs and filter parameters, a VNC password, no cloud-init seed of
the VM's; with a new generation ID, each disk's source the restored file
without the old chain, the NVRAM path, and links down unless connected.
Recovery records a VM defined by the recorded UUID; otherwise it removes
the copies and the NVRAM file by their recorded names.
wvmBackup.backup_plan reads a VM's persistent definition and says what a
backup copies: each file disk (qcow2 or raw) with its pool and virtual
size, the NVRAM file, and what is left out (CD-ROMs, floppies). It
refuses, naming the reason, what a backup could not restore as it is:
encrypted, block, network, volume, directory and shareable disks, other
disk formats, a disk in no storage pool, shared host directories, a
kernel file boot, host devices, a saved state, TPM state (a later
layer), an NVRAM file outside libvirt's directory, and a running VM
whose disks change at its next start.
The target side: the files' names from the backup's UUID only, the free
space check (virtual size plus the snapshots' margin), small files
written and read back with their SHA-256, read, removed and the
manifests listed. download_volume is taken out of copy_nvram for both.
Every user of the NVRAM pool runs in the worker, so its process lock
holds.
A push backup target of a raw disk (live backup or live clone) is made
without qcow2's compat and features, which libvirt refuses for raw.
A backup target is a dir or NFS storage pool the administrator makes on
the hosts and registers on the new Backup targets page (Backups in the
menu, superusers only). Each compute's pool is kept with its UUID, so a
pool replaced by another of the same name is refused. A second compute's
pool is accepted only when it is the same directory as the target's
first (the exclusive-create check migrations use). The target page shows
each pool's space and warns when the target is inside another pool's
directory, as its backups would share that storage's failures.
The storage pages refuse to delete a target's pool, and a volume of a
backup (page and API): backups are deleted from the Backups pages.