virtnbdbackup

Backup utility for Libvirt / qemu / kvm supporting incremental and differential backups + instant recovery (agentless).

Overview:

This dockerfile is intended for scenarios where isn’t viable for SysAdmins to provide a up-to-date dependencies (stable distros); or when this is totally impossible due to system constraints (inmutable / embedded rootfs, docker oriented OSes, etc.)

This image includes ‘virtnbdbackup’ and ‘virtnbdrestore’ utils installed along with required dependencies, and currently is being built from debian:bookworm-slim as base.

It has been successfully tested on UnRaid v6.9.2, but should work the same on many other distros, as much as below requirements can be accomplished.

Requirements:

Note: This image carries latest ‘qemu-utils’ as of its base OS for internal processing of images during restoration.

Bind mounts:

Usage Examples:

Full Backup:

docker run --rm \

-v /run:/run -v /var/tmp:/var/tmp -v /mnt/backups:/mnt/backups \

docker-virtnbdbackup \

virtnbdbackup -d <domain-name> -l full -o /mnt/backups/<domain-name>

Incremental Backup:

docker run --rm \

-v /run:/run -v /var/tmp:/var/tmp -v /mnt/backups:/mnt/backups \

docker-virtnbdbackup \

virtnbdbackup -d <domain-name> -l inc -o /mnt/backups/<domain-name>

Restoration of Backup:

docker run --rm \

-v /run:/run -v /var/tmp:/var/tmp -v /mnt/backups:/mnt/backups -v /mnt/restored:/mnt/restored \

docker-virtnbdbackup \

virtnbdrestore -i /mnt/-backups/<domain-backup> -a restore -o /mnt/restored

Where /mnt/restored is an example folder in your system, where virtnbdrestore will rebuild virtual disk(s) based on existing backups, with its internal block device name, such as ‘sda’, ‘vda’, ‘hdc’, etc.

Persistent container:

In the above examples, the container will be removed as soon the invoked command has been executed. This is the optimal behaviour when you intend to automate operations (such as incremental backups.)

In addition, you can set a persistent container with all necessary bind mounts with:

docker create --name <container-name>

-v /var/tmp:/var/tmp -v /run:/run -v /mnt/backups:/mnt/backups -v /mnt/restored:/mnt/restored' \

docker-virtnbdbackup \

/bin/bash

And attach to its Shell with: docker start -i <container-name> to perform manual backups/restorations or for debugging purposes. Exiting the Shell will stop it immediately.