SkillAgentSearch skills...

Virtnbdbackup

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

Install / Use

/learn @abbbi/Virtnbdbackup

README

ci package-build

virtnbdbackup

Backup utility for libvirt, using the latest changed block tracking features. Create online, thin provisioned full and incremental or differential backups of your kvm/qemu virtual machines.

Alt text

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->

About

Existing backup solutions or scripts for libvirt/kvm usually depend on the external snapshot feature to create backups, sometimes even require to shutdown or pause the virtual machine.

Recent additions to both the libvirt and qemu projects have introduced new capabilities that allow to create online (full and incremental) backups, by using so called dirty bitmaps (or changed block tracking).

virtnbdbackup uses these features to create online full and incremental or differential backups.

virtnbdrestore can be used to re-construct the complete image from the thin provisioned backups.

virtnbdmap can be used to map an thin provisioned backup image into a block device on-the-fly, for easy single file restore or even instant boot from an backup image.

For backing up standalone qemu virtual machines not managed by libvirt, see this project: qmpbackup

Prerequisites

Obviously you require a libvirt/qemu version that supports the incremental backup features. Since libvirt v7.6.0 and qemu-6.1 the required features are enabled by default and are considered production ready: everything will work out of the box.

Following, you will find a short overview which older libvirt versions may require further adjustments to the virtual machine config.

Libvirt versions <= 7.6.0 (Debian Bullseye, Ubuntu 20.x)

If you are using Debian Bullseye or Ubuntu 20.x, the included libvirt version already has an almost complete support for incremental backup, although it doesn't work properly with migration or some block jobs.

If you don't want to use migration or other blockjobs you can enable the incremental backup feature on these libvirt versions. Change the virtual machine config using virsh edit <vm> like so: (the first line must be changed, too!):

 <domain type='kvm' id='1' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
 [..]
 <qemu:capabilities>
   <qemu:add capability='incremental-backup'/>
 </qemu:capabilities>
 [..]
 </domain>

Note:

You must power cycle the virtual machine after enabling the feature! Upstream libvirt strongly discourages enabling the feature on production systems for these libvirt versions.

RHEL/Centos Stream, Alma, Rocky Linux

Version <= 8.5

Up to RHEL/Centos8/Almalinux 8.5, libvirt packages from the advanced virtualization stream support all required features. To install libvirt from the stream use:

yum install centos-release-advanced-virtualization
yum makecache
yum module install virt

and enable the feature by adjusting the virtual machine config.

Version >= 8.6

As of RHEL 8.6, the advanced virtualization stream has been deprecated, and all components supporting the new feature are included in the virt:rhel module, the feature is enabled by default. (Details)

Environment dependencies

  • python libvirt module version >= 6.0.0 (yum install python3-libvirt)
  • python libnbd bindings (https://github.com/libguestfs/libnbd) version >= 1.5.5 (yum install python3-libnbd)
  • The virtual machine should use qcow version 3 images to support the full feature set.

Installation

There are several ways to install the utility, below you will find an short description for each of them. For Debian and RHEL/SuSE based derivates see releases for pre-built packages.

Note:

Please consider to check past issues related to installation if you face any troubles before opening a new issue.

Python package

 git clone https://github.com/abbbi/virtnbdbackup && cd virtnbdbackup
 pip install .

Note:

Do not install the "nbd" package available on PyPI, it does not provide the required nbd bindings (unfortunately has the same name). You have to additionally install the provided python3-libnbd packages by your distribution, or compile the libnbd bindings by yourself.

RPM package

Packages for RHEL/Fedora and OpenSUSE are available via releases.

To create an

Related Skills

View on GitHub
GitHub Stars491
CategoryCustomer
Updated7d ago
Forks54

Languages

Python

Security Score

100/100

Audited on Mar 20, 2026

No findings