Coder Social home page Coder Social logo

abbbi / virtnbdbackup Goto Github PK

View Code? Open in Web Editor NEW
273.0 13.0 43.0 1.69 MB

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

Home Page: http://libvirtbackup.grinser.de/

License: GNU General Public License v3.0

Python 85.89% Shell 13.19% Makefile 0.40% Dockerfile 0.52%
cbt libvirt nbd-client backup backup-utility qemu qemu-kvm backup-image nbd virtual-machine

virtnbdbackup's Introduction

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

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

pip3 install -r requirements.txt
python3 setup.py 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 RPM package from source by yourself you can follow the steps from the github build workflow.

Debian package

Official packages are available: https://packages.debian.org/virtnbdbackup and are maintained on the Debian salsa codespace.

For the latest packages available check releases.

To create an Debian package from source by yourself you can follow the steps from the github build workflow.

Virtualenv

For setup within an virtualenv see venv scripts.

Docker images

You can build an docker image using the existing Dockerfile README

All released versions and master branch are published via github container registry, too. Example:

 docker run -it ghcr.io/abbbi/virtnbdbackup:master virtnbdbackup

See packages.

Backup Format

Currently, there are two output formats implemented:

  • stream: the resulting backup image is saved in a streamlined format, where the backup file consists of metadata about offsets and lengths of zeroed or allocated contents of the virtual machines disk. This is the default. The resulting backup image is thin provisioned.
  • raw: The resulting backup image will be a full provisioned raw image, this should mostly be used for debugging any problems with the extent handler, it won't work with incremental backups.

Backup Operation

Following backup modes can be used:

  • copy: Full, thin provisioned backup of the virtual machine disks, no checkpoint is created for further incremental backups, existing checkpoints will be left untouched. This is the default mode and works with qcow images not supporting persistent bitmaps.

  • full: Full, thin provisioned backup of the virtual machine, a new checkpoint named virtnbdbackup will be created, all existent checkpoints from prior backups matching this name will be removed: a new backup chain is created. The Virtual machine must be online and running for this backup mode to work.

  • inc: Perform incremental backup, based on the last full or incremental backup. A checkpoint for each incremental backup is created and saved.

  • diff: Perform differential backup: saves the current delta to the last incremental or full backup.

  • auto: If the target folder is empty, attempt to execute full backup, otherwise switch to backup mode incremental: allows rotation of backup into monthly folders.

All required information for restore is stored to the same directory, including the latest virtual machine configuration, checkpoint information, disk data and logfiles.

The target directory must be rotated if a new backup set is created.

If the virtual domain is active and running, a backup job operation via libvirt api is started, which in turn initializes a new nbd server backend listening on a local unix socket. This nbd backend provides consistent access to the virtual machines, disk data and dirty blocks. After the backup process finishes, the job is stopped and the nbd server quits operation.

It is possible to backup multiple virtual machines on the same host system at the same time, using separate calls to the application with a different target directory to store the data.

Supported disk formats / raw disks

libvirt/qemu supports dirty bitmaps, required for incremental backups only with qcow(v3) based disk images. If you are using older image versions, you can only create copy backups, or consider converting the images to a newer format using qemu-img:

qemu-img convert -O qcow2 -o compat=1.1 disk-old.qcow2 disk.qcow2

By default virtnbdbackup will exclude all disks with format raw as well as direct attached (passthrough) disks such as LVM or ZVOL and ISCSI volumes. These type of virtual disks do not support storing checkpoint/bitmap metadata and do not support incremental/differential backup. (more info)

This behavior can be changed if option --raw is specified, raw disks will then be included during a full backup. This of course means that no thin provisioned backup is created for these particular disks.

During restore, these files can be copied "as is" from the backup folder and must not be processed using virtnbdrestore.

Note:

The backup data for raw disks will only be crash consistent, be aware that this might result in inconsistent filesystems after restoring!

Backup Examples

Each backup for a virtual machine must be saved to an individual target directory. Once the target directory includes an full backup, it can be used as base for further incremental or differential backups.

Local full/incremental backup

Start full backup of domain vm1, save data to /tmp/backupset/vm1:

virtnbdbackup -d vm1 -l full -o /tmp/backupset/vm1

Start incremental backup for domain vm1, backup only changed blocks to the last full backup, the same directory is used as backup target:

virtnbdbackup -d vm1 -l inc -o /tmp/backupset/vm1

The resulting directory will contain both backups and all other files required to restore the virtual machine. Created logfiles can be used for analyzing backup issues:

/tmp/backupset/vm1
├── backup.full.05102021161752.log
├── backup.inc.05102021161813.log
├── checkpoints
│   ├── virtnbdbackup.0.xml
│   ├── virtnbdbackup.1.xml
├── sda.full.data
├── sda.inc.virtnbdbackup.1.data
├── vm1.cpt
├── vmconfig.virtnbdbackup.0.xml
├── vmconfig.virtnbdbackup.1.xml

Backing up offline virtual domains

If the virtual domain is not in running state (powered off) virtnbdbackup supports copy and inc/diff backup modes. Incremental and differential backups will then save the changed blocks since last created checkpoint.

Backup mode full is changed to mode copy, because libvirt does not allow to create checkpoints for offline domains.

This behavior can be changed using the -S (--start-domain) option: prior to executing the backup, the virtual domain will then be started in paused state for the time the backup is created: The virtual machines CPU's are halted, but the running QEMU Process will allow all operations required to execute backups.

The option won't alter the virtual domain state if it is already online, thus it can be used for backing up virtual machines whose state is unknown prior to backup.

Application consistent backups

During backup virtnbdbackup attempts to freeze all file systems within the domain using the qemu guest agent filesystem freeze and thaw functions. In case no qemu agent is installed or filesystem freeze fails, a warning is shown during backup:

WARNING [..] Guest agent is not responding: QEMU guest agent is not connected

In case you receive this warning, check if the qemu agent is installed and running in the domain.

It is also possible to specify one or multiple mountpoints used within the virtual machine to freeze only specific filesystems, like so:

virtnbdbackup -d vm1 -l inc -o /tmp/backupset/vm1 -F /mnt,/var

this way only the underlying filesystems on /mnt and /var are frozen and thawed.

Note:

It is highly recommended to have an qemu agent running in the virtual domain to ensure file system consistency during backup!

Rotating backups

With backup mode auto it is possible to have a monthly rotation/retention. If the target folder is empty, backup mode auto will create an full backup. On the following executions, it will automatically switch to backup mode incremental, if the target folder already includes an full backup. Example:

virtnbdbackup -d vm1 -l auto -o /tmp/2022-06 -> creates full backup
virtnbdbackup -d vm1 -l auto -o /tmp/2022-06 -> creates inc backup
virtnbdbackup -d vm1 -l auto -o /tmp/2022-06 -> creates inc backup
virtnbdbackup -d vm1 -l auto -o /tmp/2022-07 -> creates full backup
virtnbdbackup -d vm1 -l auto -o /tmp/2022-07 -> creates inc backup

Excluding disks

Option -x can be used to exclude certain disks from the backup. The name of the disk to be excluded must match the disks target device name as configured in the domains xml definition, for example:

virtnbdbackup -d vm1 -l full -o /tmp/backupset/vm1 -x sda

Special devices such as cdrom/floppy or direct attached luns are excluded by default, as they are not supported by the changed block tracking layer.

It is also possible to only backup specific disks using the include option (--include, or -i):

virtnbdbackup -d vm1 -l full -o /tmp/backupset/vm1 -i sdf

Estimating backup size

Sometimes it can be useful to estimate the data size prior to executing the next incremental or differential backup. This can be done by using the option -p which will query the virtual machine checkpoint information for the current size:

virtnbdbackup -d vm1 -l inc -o /tmp/backupset/vm1 -p
[..]
[..] INFO virtnbdbackup - handleCheckpoints [MainThread]: Using checkpoint name: [virtnbdbackup.1].
[..] INFO virtnbdbackup - main [MainThread]: Estimated checkpoint backup size: [24248320] Bytes

Note:

Not all libvirt versions support the flag required to read the checkpoint size. If the estimated checkpoint size is always 0, your libvirt version might miss the required features.

Backup threshold

If an incremental or differential backup is attempted and the virtual machine is active, it is possible to specify an threshold for executing the backup using the --threshold option. The backup will then only be executed if the amount of data changed meets the specified threshold (in bytes):

virtnbdbackup -d vm1 -l inc -o /tmp/backupset/vm1 --threshold 3311264
[..]
[..] INFO virtnbdbackup - handleCheckpoints [MainThread]: Using checkpoint name: [virtnbdbackup.1].
[..] ]virtnbdbackup - main [MainThread]: Backup size [3211264] does not meet required threshold [3311264], skipping backup.

Backup concurrency

If virtnbdbackup saves data to a regular target directory, it starts one thread for each disk it detects to speed up the backup operation.

This behavior can be changed using the --worker option to define an amount of threads to be used for backup. Depending on how many disks your virtual machine has attached, it might make sense to try a different amount of workers to see which amount your hardware can handle best.

If standard output (-) is defined as backup target, the amount of workers is always limited to 1, to ensure a valid Zip file format.

Compression

It is possible to enable compression for the stream format via lz4 algorithm by using the --compress option. The saved data is compressed inline and the saveset file is appended with compression trailer including information about the compressed block offsets. By default compression level 2 is set if no parameter is applied. Higher compression levels can be set via:

--compress=16

During the restore, virtnbdrestore will automatically detect such compressed backup streams and attempts to decompress saved blocks accordingly.

Using compression will come with some CPU overhead, both lz4 checksums for block and original data are enabled.

Remote Backup

It is also possible to backup remote libvirt systems. The most convenient way is to use ssh for initiating the libvirt connection (key authentication mandatory).

Before attempting an remote backup, please validate your environment meets the following criteria:

  • DNS resolution (forward and reverse) must work on all involved systems.
  • SSH Login to the remote system via ssh key authentication (using ssh agent or passwordless ssh key) should work without issues.
  • Unique hostnames must be set on all systems involved. (background)
  • Firewall must allow connection on all ports involved.

If the virtual machine has additional files configured, as described in Kernel/initrd and additional files, these files will be copied from the remote system via SSH(SFTP).

QEMU Sessions

In order to backup virtual machines from a remote host, you must specify an libvirt URI to the remote system.

The following example saves the virtual machine vm1 from the remote libvirt host hypervisor to the local directory /tmp/backupset/vm1, it uses the root user for both the libvirt and ssh authentication:

virtnbdbackup -U qemu+ssh://root@hypervisor/system --ssh-user root -d vm1 -o  /tmp/backupset/vm1

See also: Authentication

Note:

If you want to run multiple remote backups at the same time you need to pass an unique port for the NBD service used for data transfer via --nbd-port option for each backup session.

NBD with TLS (NBDSSL)

By default disk data received from a remote system will be transferred via regular NBD protocol. You can enable TLS for this connection, using the --tls option. Before being able to use TLS, you must configure the required certificates on both sides. See this script.

See the following documentation by the libvirt project for detailed instructions how setup:

https://wiki.libvirt.org/page/TLSCreateCACert

Note:

You should have installed at least version 1.12.6 of the libnbd library which makes the transfer via NBDS more stable full background

Using a separate network for data transfer

In case you want to use a dedicated network for the data transfer via NBD, you can specify an specific IP address to bind the remote NBD service to via --nbd-ip option.

Piping data to other hosts

If the output target points to standard out (-), virtnbdbackup puts the resulting backup data into an uncompessed zip archive.

A such, it is possible to transfer the backup data to different hosts, or pipe it to other programs.

However, keep in mind that in case you want to perform incremental backups, you must keep the checkpoint files on the host you are executing the backup utility from, until you create another full backup.

If output is set to standard out, virtnbdbackup will create the required checkpoint files in the directory it is executed from.

Here is an example:

 # mkdir backup-weekly; cd backup-weekly
 # virtnbdbackup -d vm1 -l full -o - | ssh root@remotehost 'cat > backup-full.zip'
 # [..]
 # INFO outputhelper - __init__: Writing zip file stream to stdout
 # [..]
 # INFO virtnbdbackup - main: Finished
 # INFO virtnbdbackup - main: Adding vm config to zipfile
 # [..]

Any subsequent incremental backup operations must be called from within this directory:

 # cd backup-weekly
 # virtnbdbackup -d vm1 -l inc -o - | ssh root@remotehost 'cat > backup-inc1.zip'
 [..]

You may consider adding the created checkpoint files to some VCS system, like git, to have some kind of central backup history tracking.

During restore unzip the data from both zip files into a single directory: (use virtnbdrestore to reconstruct the virtual machine images):

 # unzip -o -d restoredata backup-full.zip
 # unzip -o -d restoredata backup-inc1.zip

Kernel/initrd and additional files

If an domain has configured custom kernel, initrd, loader or nvram images (usually the case if the domain boots from OVM UEFI BIOS), these files will be saved to the backup folder as well.

Restore examples

For restoring, virtnbdrestore can be used. It reconstructs the streamed backup format back into a usable qemu qcow image.

The restore process will create a qcow image with the original virtual size.

In a second step, the qcow image is then mapped to a ndb server instance where all data blocks are sent to and are applied accordingly. The resulting image can be mounted (using guestmount) or attached to a running virtual machine in order to recover required files.

Dumping backup information

As a first start, the dump parameter can be used to dump the saveset information of an existing backup:

virtnbdrestore -i /tmp/backupset/vm1 -o dump
INFO:root:Dumping saveset meta information
{'checkpointName': 'virtnbdbackup',
 'dataSize': 704643072,
 'date': '2020-11-15T20:50:36.448938',
 'diskName': 'sda',
 'incremental': False,
 'parentCheckpoint': False,
 'streamVersion': 1,
 'virtualSize': 32212254720}
[..]

The output includes information about the thick and thin provisioned disk space that is required for recovery, date of the backup and checkpoint chain.

Verifying created backups

As with version >= 1.9.40 virtnbdbackup creates an check sum for each created data file. Using virtnbdrestore you can check the integrity for the created data files without having to restore:

virtnbdrestore -i /tmp/backup/vm1 -o verify
[..] INFO lib common - printVersion [MainThread]: Version: 1.9.39 Arguments: ./virtnbdrestore -i /tmp/backup/vm1 -o verify
[..] INFO root virtnbdrestore - verify [MainThread]: Computing checksum for: /tmp/backup/vm1/sda.full.data
[..] INFO root virtnbdrestore - verify [MainThread]: Checksum result: 541406837
[..] INFO root virtnbdrestore - verify [MainThread]: Comparing checksum with stored information
[..] INFO root virtnbdrestore - verify [MainThread]: OK

this makes it easier to spot corrupted backup files due to storage issues. (background)

Complete restore

To restore all disks within the backupset into a usable qcow image use command:

virtnbdrestore -i /tmp/backupset/vm1 -o /tmp/restore

All incremental backups found will be applied to the target images in the output directory /tmp/restore

Note:

The restore utility will copy the latest virtual machine config to the target directory, but won't alter its contents. You have to adjust the config file for the new paths and/or excluded disks to be able to define and run it.

Process only specific disks during restore

A single disk can be restored by using the option -d, the disk name has to match the virtual disks target name, for example:

virtnbdrestore -i /tmp/backupset/vm1 -o /tmp/restore -d sda

Point in time recovery

Option --until allows to perform a point in time restore up to the desired checkpoint. The checkpoint name has to be specified as reported by the dump output (field checkpointName), for example:

virtnbdrestore -i /tmp/backupset/vm1 -o /tmp/restore --until virtnbdbackup.2

It is also possible to specify the source data files specifically used for the rollback via --sequence option, but beware: you must be sure the sequence you apply has the right order, otherwise the restored image might be errnous, example:

virtnbdrestore -i /tmp/backupset/vm1 -o /tmp/restore --sequence vdb.full.data,vdb.inc.virtnbdbackup.1.data

Restoring with modified virtual machine config

Option -c can be used to adjust the virtual machine configuration during restore accordingly, the following changes are done:

  • UUID of the virtual machine is removed from the config file
  • Name of the virtual machine is prefixed with "restore_" (use option --name to specify desired vm name)
  • The disk paths to the virtual machine are changed to the new target directory.
  • If virtual machine was operating on snapshots/backing store images, the references to the configured backing stores will be removed.
  • Raw devices are removed from VM config if --raw is not specified, as well as floppy or cdrom devices (which aren't part of the backup).

Note:

If missing, Kernel, UEFI or NVRAM files are restored to their original location as set in the virtual machine configuration.

A restored virtual machine can then be defined and started right from the restored directory (or use option -D to define automatically):

virtnbdrestore -c -i /tmp/backupset/vm1 -o /tmp/restore
[..]
[..] INFO virtnbdrestore - restoreConfig [MainThread]: Adjusted config placed in: [/tmp/restore/vmconfig.virtnbdbackup.0.xml]
[..] INFO virtnbdrestore - restoreConfig [MainThread]: Use 'virsh define /tmp/restore/vmconfig.virtnbdbackup.0.xml' to define VM

Remote Restore

Restoring to a remote host is possible too, same options as during backup apply. The following example will restore the virtual machine from the local directory /tmp/backupset to the remote system "hypervisor", alter its configuration and register the virtual machine:

virtnbdrestore -U qemu+ssh://root@hypervisor/system --ssh-user root -cD -i /tmp/backupset/vm1 -o /remote/target

Post restore steps and considerations

If you restore the virtual machine with its original name on the same hypervisor, you may have to cleanup checkpoint information, otherwise backing up the restored virtual machine may fail, see this discussion

Single file restore and instant recovery

The virtnbdmap utility can be used to map uncompressed backup images from the stream format into an accessible block device on the fly. This way, you can restore single files or even boot from an existing backup image without having to restore the complete dataset.

The utility requires nbdkit with the python plugin to be installed on the system along with required qemu tools (qemu-nbd) and an loaded nbd kernel module. It must be executed with superuser (root) rights or via sudo.

The following example maps an existing backup image to the network block device /dev/nbd0:

 # modprobe nbd max_partitions=15
 # virtnbdmap -f /backupset/vm1/sda.full.data
 [..] INFO virtnbdmap - <module> [MainThread]: Done mapping backup image to [/dev/nbd0]
 [..] INFO virtnbdmap - <module> [MainThread]: Press CTRL+C to disconnect

While the process is running, you can access the backup image like a regular block device:

fdisk -l /dev/nbd0
Disk /dev/nbd0: 2 GiB, 2147483648 bytes, 4194304 sectors

You can also create an mapped "point in time" recovery image by passing a sequence of full and incremental backups as parameter. The changes from the incremental backups will then be replayed to the block device on the fly and the image will represent the latest state:

virtnbdmap -f /backupset/vm1/sda.full.data,/backupset/vm1/sda.inc.virtnbdbackup.1.data,/backupset/vm1/sda.inc.virtnbdbackup.2.data
[..]
[..] INFO virtnbdmap - main [MainThread]: Need to replay incremental backups
[..] INFO virtnbdmap - main [MainThread]: Replaying offset 420 from /backup/sda.inc.virtnbdbackup.1.data
[..] INFO virtnbdmap - main [MainThread]: Replaying offset 131534 from /backup/sda.inc.virtnbdbackup.1.data
[..]
[..] INFO virtnbdmap - main [MainThread]: Replaying offset 33534 from /backup/sda.inc.virtnbdbackup.2.data
[..] INFO virtnbdmap - <module> [MainThread]: Done mapping backup image to [/dev/nbd0]
[..] INFO virtnbdmap - <module> [MainThread]: Press CTRL+C to disconnect
[..]

The original image will be left untouched as nbdkits copy on write filter is used to replay the changes.

Further you can create an overlay image via qemu-img and boot from it right away (or boot directly from the /dev/nbd0 device).

qemu-img create -b /dev/nbd0 -f qcow2 bootme.qcow2
qemu-system-x86_64 -enable-kvm -m 2000 -hda bootme.qcow2

To remove the mappings, stop the utility via "CTRL-C"

Note:

If the virtual machine includes volume groups, the system will attempt to set them online as you create the mapping, because the copy on write device is writable by default. If your host system is using the same volume group names this could lead to issues (check dmesg or journalctl then). In case the volume groups are online, it is recommended to change them to offline just before you remove the mapping, to free all references to the mapped nbd device (vgchange -a n <vg_name>)

Note:

If you map the image device with the --readonly option you may need to pass certain options to the mount command (-o norecovery,ro) in order to be able to mount the filesystems. This may also be the case if no qemu agent was installed within the virtual machine during backup.

Extents

In order to save only used data from the images, dirty blocks are queried from the NBD server. The behavior can be changed by using the option -q to use common qemu tools (nbdinfo). By default virtnbdbackup uses a custom implemented extent handler.

Transient virtual machines: checkpoint persistency

In case virtual machines are started in transient environments, such as using cluster solutions like pacemaker situations can appear where the checkpoints for the virtual machine defined by libvirt are not in sync with the bitmap information in the qcow files.

In case libvirt creates a checkpoint, the checkpoint information is stored in two places:

  • var/lib/libvirt/qemu/checkpoint/<domain_name>
  • In the bitmap file of the virtual machines qcow image.

Depending on the cluster solution, in case virtual machines are destroyed on host A and are re-defined on host B, libvirt loses the information about those checkpoints. Unfortunately libvirtd scans the checkpoint only once during startup.

This can result in a situation, where the bitmap is still defined in the qcow image, but libvirt doesn't know about the checkpoint, backup then fails with:

Unable to execute QEMU command 'transaction': Bitmap already exists

By default virtnbdbackup attempts to store the checkpoint information in the default backup directory, in situations where it detects a checkpoint is missing, it attempts to redefine them from the prior backups.

In order to store the checkpoint information at some central place the option --checkpointdir can be used, this allows having persistent checkpoints stored across multiple nodes:

As example:

  1. Create backup on host A, store checkpoints in a shared directory between hosts in /mnt/shared/vm1:

virtnbdbackup -d vm1 -l full -o /tmp/backup_hosta --checkpointdir /mnt/shared/vm1

  1. After backup, the virtual machine is relocated to host B and loses its information about checkpoints and bitmaps, thus, the next full backup usually fails with:
virtnbdbackup -d vm1 -l full -o /tmp/backup_hostb
[..]
unable to execute QEMU command 'transaction': Bitmap already exists: virtnbdbackup.0
  1. Now pass the checkpoint dir and files written from host A, and virtnbdbackup will redefine missing checkpoints and execute a new full backup. As the new full backup removes all prior checkpoints the bitmap information is in sync after this operation and backup succeeds:
virtnbdbackup -d vm1 -l full -o /tmp/backup_hostb --checkpointdir /mnt/shared/vm1
[..]
redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.0
[..]

See also: #10

Hypervisors

virtnbdbackup uses the lowest layer on top of libvirt to allow its functionality, you can also use it with more advanced hypervisors solutions such as ovirt, RHEV or OpenNebula, but please bear in mind that it was not developed to target all of those solutions specifically!

Ovirt, RHEV or OLVM

If you are using the ovirt node based hypervisor hosts you should consider creating a virtualenv via the venv scripts and transferring it to the node system.

On regular centos/alma/rhel based nodes, installation via RPM package should be preferred. The incremental backup functionality can be enabled via ovirt management interface.

Usually ovirt restricts access to the libvirt daemon via different authentication methods. Use the -U parameter in order to specify an authentication file, if you chose to run the utility locally on the hypervisor:

virtnbdbackup -U qemu:///system?authfile=/etc/ovirt-hosted-engine/virsh_auth.conf -d vm1 -o /tmp/backupset/vm1

You can also use remote backup functionality:

  • System must be reachable via ssh public key auth as described in the Remote Backup section.
  • Some OVIRT based setups may deny SASL based authentication if the hostname used to connect to does not match the hostname from the libvirt certificate. more info
  • Firewall port for NBD must be open:
 root@hv-node~# firewall-cmd --zone=public --add-port=10809/tcp

and then backup via:

virtnbdbackup -U qemu+ssh://root@hv-node/session -d vm -o /backup --password password --user root --ssh-user root

Note:

virtnbdrestore has not been adopted to cope with the ovirt specific domain xml format, so redefining and virtual machine on the node might not work.

OpenNebula

See past issues

Authentication

Both virtnbdbackup and virtnbdrestore commands support authenticating against libvirtd with the usual URIs. Consider using the following options:

-U: Specify an arbitrary connection URI to use against libvirt

--user: Username to use for the specified connection URI

--password: Password to use for the specified connection URI.

It is also possible to specify the credentials stored as authentication file like it would be possible using the virsh -c option:

 -U qemu:///system?authfile=/etc/virsh_auth.conf ..

Note:

The default connection URI used is qemu:///system which is usually the case if virtual machines operate as root user. Use the qemu:///session URI to backup virtual machines as regular user.

Backup I/O and performance: scratch files

If virtual domains handle heavy I/O load during backup (such as writing or deleting lots of data while the backup is active) you might consider using the --scratchdir option to change the default scratch file location.

During the backup operation qemu will use the created scratch files for fleecing, thus it is recommended to store these files on storage that meets the same I/O performance requirements as the backup target.

The free space on the default scratch directory (/var/tmp) must be enough to be able to keep all fleecing data while the backup is active.

FAQ

The thin provisioned backups are bigger than the original qcow images

Virtual machines using the qcow format do compress data. During backup, the image contents are exposed as NBD device which is a RAW device. The backup data will be at least as big as the used data within the virtual machine.

You can use the --compress option or other tools to compress the backup images in order to save storage space or consider using a deduplication capable target file system.

Backup fails with "Cannot store dirty bitmaps in qcow2 v2 files"

If the backup fails with error:

ERROR [..] internal error: unable to execute QEMU command dirty bitmaps in qcow2 v2 files

consider migrating your qcow files to version 3 format. QEMU qcow image version 2 does not support storing advanced bitmap information, as such only backup mode copy is supported.

Backup fails with "Timed out during operation: cannot acquire state change lock"

If backups fail with error:

ERROR [..] Timed out during operation: cannot acquire state change lock (held by monitor=remoteDispatchDomainBackupBegin)

there is still some block jobs operation active on the running domain, for example a live migration or another backup job. It may also happen that virtnbdbackup crashes abnormally or is forcibly killed during backup operation, unable to stop its own backup job.

You can use option -k to forcibly kill any running active block jobs for the domain, but use with care. It is better to check which operation is active with the virsh domjobinfo command first.

virtnbdbackup  -d vm2 -l copy -k  -o -
[..]
  INFO virtnbdbackup - main: Stopping domain jobs

Backup fails with "Failed to bind socket to /var/tmp/virtnbdbackup.XX: Permission denied"

The issue is most likely an active apparmor profile that prevents the qemu daemon from creating its socket file for the nbd server. Try to disable apparmor using the aa-teardown command for the current session you are executing a backup or restore. You can also add the following lines:

/var/tmp/virtnbdbackup.* rw,
/var/tmp/backup.* rw,

to the configuration files (might not exist by default):

/etc/apparmor.d/usr.lib.libvirt.virt-aa-helper
/etc/apparmor.d/local/abstractions/libvirt-qemu
/etc/apparmor.d/local/usr.sbin.libvirtd

See also: #7

High memory usage during backup

libnbd python implementation has had various memory leaks in older versions which cause such problems.

For centos 8 based distributions these fixes have been backported to libnbd 1.4.0.

The fix itself was released with libnbd 1.5.2, so be sure to use at least this version if using virtnbdbackup on any other distribution.

See also: #8

Test your backups!

The utility is provided "as is", i take no responsibility or warranty if you face any issues recovering your data! The only way to ensure your backups are valid and your backup plan works correctly is to repeatedly test the integrity by restoring them! If you discover any issues, please do not hesitate to report them.

Links

Backup howto for Debian Bullseye: https://abbbi.github.io/debian/

Short video: https://youtu.be/dOE0iB-CEGM

virtnbdbackup's People

Contributors

abbbi avatar ccrssaa avatar dependabot[bot] avatar gaby avatar inode64 avatar max252 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

virtnbdbackup's Issues

Add compression option

Add compression via python lz4 bindings during backup. Ideas:

To support inline compression during backup, using the sparsestream format, the following has to be taken into account:

  1. Enhance sparsestream format for version 2, add information about compression method and wether if compression was enabled to metadata header
  2. After saving all data to backup stream, dump json information about the data blocks original and compressed size as json array at the end of the backup stream (after the last STOP frame)
  3. After the json information has been dumped to the file, add new sparsestream frame type "comp" which is a regular header with offset and size information about the size of the dumped json information as very last entry to the stream file.

During restore:

  1. read metadata header and check if compression is enabled
  2. if compression is enabled, seek to the very end of the file and read the last frame type, which holds the "comp" information
  3. Seek back the size read from the "comp" metadata header
  4. Read the json array with hold the original and compressed data size.
  5. Use this information for reading the data blocks in compressed size, decompress and write to target file, check if decompressed size matches the original size of the data.

virtnbdmap: Single file restore / instant recovery with backup chains

Its possible to mount a full backup image via nbdkit plugin, i should also be possible to do the same with a full backup chain consisting of one base full and N incremental backups. The nbdkit plugin could be designed in a way to use the block dumps from all available images and return the most actual blocks on request.

ubuntu 20.X compatibility

Hello,

In the documentation it is said about the qemu/libvirt requirement:
"Debian bullseye or Ubuntu 20.x include libvirt versions supporting this feature already."

It made me think virtnbdbackup was natively compatible with Ubuntu 20.4 (LTS).

However on the libnbd requirement it said :
"python libnbd bindings (https://github.com/libguestfs/libnbd) version >= 1.5.5 (yum install python3-libnbd)"

Ubuntu 20.X comes with libnbd 1.2.2:

$ apt search python3-libnbd
Sorting... Done
Full Text Search... Done
python3-libnbd/focal 1.2.2-1ubuntu2 amd64
  Network Block Device client library -- Python 3 bindings

And indeed, I couldnt make virtnbdbackup work with libnbd 1.2.2...

Am I right in saying that to make virtnbdbackup work on Ubuntu 20.X, it is needed to add a custom version of libnbd ?

Thanks

Adjust pathes in restored virtual machine configuration

Add option to adjust pathes to the disk files if virtual machine is restored to a new path, so it can be registered using "virsh" or an direct api call right away, instead of the user having to manually alter the restored configuration file. This would also involve adjusting and copying restored nvram/bios pathes.

Would also require taking into account:

  • change pathes to vm disks to restore folder [x]
  • if only specific disks are restore, remove others from vm config [x]
  • change vm name [x]
  • remove uuid [x]
  • remove floppy/cdrom devices. [x]
  • remove possible raw devices [TODO]
  • add testcases [x]

Ignore CDROM / Direct attached block devices

Currently virtnbdbackup attempts to enable CBT for existing CDROM and/or direct attached block devices, which do not support this operation. These devices should be ignored. See also #2

Different exit code if warnings issued during backup operation

Currently exit code for utility only changes if fatal situations or erros are reported.
If a warning is caused during backup, it should be possible to check for with external scripts.

One approach would be to count the warnings reported by the logging facility, like so:

b5cf6c6

using this method, its required to redesign the logging handler, because it will work only on
the toplevel class overriding the method handler, not with submodules that cause error warnings.

Error Bitmap with the same name is already stored

Hi
I'm setting up new backups of my VMS.
In one of them I am facing this problem.
I searched for the error but didn't find much.
Error:
[root@lnx-kvm2 ~]# virtnbdbackup -d CIA-199 -l full -o /mnt/vms/backup/CIA-199
[2022-04-01 08:42:46] INFO common - printVersion [MainThread]: Version: 0.35 Arguments: /usr/bin/virtnbdbackup -d CIA-199 -l full -o /mnt/vms/backup/CIA-199
[2022-04-01 08:42:46] INFO virtnbdbackup - main [MainThread]: Backup level: [full]
[2022-04-01 08:42:46] INFO virtnbdbackup - main [MainThread]: Domain has 1 disks attached which support changed block tracking.
[2022-04-01 08:42:46] INFO virtnbdbackup - main [MainThread]: Concurrent backup processes: [1]
[2022-04-01 08:42:46] INFO virtnbdbackup - main [MainThread]: Check for missing checkpoints from: /mnt/vms/backup/CIA-199/checkpoints
[2022-04-01 08:42:46] INFO libvirthelper - redefineCheckpoints [MainThread]: Loading checkpoint list from: [/mnt/vms/backup/CIA-199/checkpoints]
[2022-04-01 08:42:46] INFO virtnbdbackup - main [MainThread]: Checkpoint handling
[2022-04-01 08:42:46] INFO virtnbdbackup - main [MainThread]: Using checkpoint name: virtnbdbackup.0
[2022-04-01 08:42:46] INFO virtnbdbackup - main [MainThread]: Temporary scratch file target directory: /var/tmp
[2022-04-01 08:42:46] INFO virtnbdbackup - main [MainThread]: NDB Endpoint socket: /var/tmp/virtnbdbackup.30963
[2022-04-01 08:42:46] INFO virtnbdbackup - main [MainThread]: Starting backup job.
[2022-04-01 08:42:53] INFO libvirthelper - fsFreeze [MainThread]: Freeze filesystems.
[2022-04-01 08:42:54] INFO libvirthelper - fsThaw [MainThread]: Thawed filesystems.
[2022-04-01 08:42:54] ERROR virtnbdbackup - main [MainThread]: internal error: unable to execute QEMU command 'transaction': Can't make bitmap 'virtnbdbackup.0' persistent in 'libvirt-1-format': Bitmap with the same name is already stored

virtnbdbackup: checkpoint option doesn't seem to work

Hi,

I'm trying to make differential backups against the full backup (checkpoint named virtnbdbackup.0) with the option --checkpoint virtnbdbackup.0, but although virtnbdbackup says it uses the virtnbdbackup.0 as parent it uses virtnbdbackup.1 (first incrementall) as parent.

Relevant part of the log output of the second incremental run:
[2022-02-18 20:33:10] INFO common - printVersion [MainThread]: Version: 0.43 Arguments: /usr/bin/virtnbdbackup --domain X --level inc --output X --checkpoint virtnbdbackup.0 -n -v
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Backup level: [inc]
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Domain has 1 disks attached which support changed block tracking.
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Concurrent backup processes: [1]
[2022-02-18 20:33:10] INFO libvirthelper - redefineCheckpoints [MainThread]: Loading checkpoint list from: [X/checkpoints]
[2022-02-18 20:33:10] DEBUG libvirthelper - redefineCheckpoints [MainThread]: Loading checkpoint config from: [X/checkpoints/virtnbdbackup.0.xml]
[2022-02-18 20:33:10] DEBUG libvirthelper - redefineCheckpoints [MainThread]: Checkpoint [virtnbdbackup.0] found
[2022-02-18 20:33:10] DEBUG libvirthelper - redefineCheckpoints [MainThread]: Loading checkpoint config from: [X/checkpoints/virtnbdbackup.1.xml]
[2022-02-18 20:33:10] DEBUG libvirthelper - redefineCheckpoints [MainThread]: Checkpoint [virtnbdbackup.1] found
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Checkpoint handling
[2022-02-18 20:33:10] WARNING virtnbdbackup - main [MainThread]: Overriding parent checkpoint: virtnbdbackup.0
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Next checkpoint id: 2
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Parent checkpoint name virtnbdbackup.0
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Using checkpoint name: virtnbdbackup.2
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Temporary scratch file target directory: /var/tmp
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: NDB Endpoint socket: /var/tmp/virtnbdbackup.741704
[2022-02-18 20:33:10] INFO virtnbdbackup - main [MainThread]: Starting backup job.

After the backup I ran virsh checkpoint-list X --tree and this is the output:
virtnbdbackup.0
|
+- virtnbdbackup.1
|
+- virtnbdbackup.2

Although I would expect the .2 checkpoint to be a child of the .0 checkpoint (the output got scrambled by the editor, but checkpoint .2 has .1 as parent and .1 has .0 as parent).

Futhermore the checkpoint xml states (in the checkpoint directory of the backup):

virtnbdbackup.2
Backup checkpoint

virtnbdbackup.1

1645212791


Am I missing something or did I hit a bug?

Kind regards,
Stefan

virtnbdmap: wrong nbdkit PID reported in log

After recent changes nbdkit process is forked into background. Thus the PID reported by virtnbdmap:

Started nbdkit process pid: [1008553],

is wrong. This also results in situations where the nbdkit process is leftover on the system if mapping the device fails.
Pass --pidfile option to nbdkit process and return pid from pidfile instead of PPID.

virtnbdbackup already uses pidfile in during offline backup and has killNbdServer which could used to kill
leftover process.

Concurrent backup of multiple disks

Currently disks are backed up in sequence. As the nbd endpoint exports disk data for all disks related to a backup job, backup time could be improved by making the backup process multithreaded.

  1. move some code passages to functions
  2. use concurrent.futures module for executing the backupDisk() function in seperate threads
  3. add argument to allow user to specify how many threads should be used.

Dependency Issues Inside of a Virtualenv (nbd)

Hello, I am attempting to get your wonderful looking project working inside of a virtualenv. In the end I have issues with nbd (I think) and obtain some errors that I don't understand...

  • Install as root inside of a virtualenv
mkdir ~/virtualenvs 1> /dev/null 2> /dev/null ; cd ~/virtualenvs && git clone https://github.com/abbbi/virtnbdbackup.git && virtualenv -p $(which python3) virtnbdbackup && source virtnbdbackup/bin/activate &&  cd ~/virtualenvs/virtnbdbackup && python3 setup.py install
  • Exit the shell, open a new shell, then activate
cd ~/virtualenvs/virtnbdbackup && source bin/activate
  • Try to run
# cd /var/lib/libvirt/images && mkdir backups-test && virtnbdbackup -d Seeborgs_-_01-10 -l full -o /var/lib/libvirt/images/backups-test

Traceback (most recent call last):
  File "/root/virtualenvs/virtnbdbackup/bin/virtnbdbackup", line 4, in <module>
    __import__('pkg_resources').run_script('virtnbdbackup==0.61', 'virtnbdbackup')
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/pkg_resources/__init__.py", line 672, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1479, in run_script
    exec(script_code, namespace, namespace)
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/virtnbdbackup-0.61-py3.9.egg/EGG-INFO/scripts/virtnbdbackup", line 32, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/virtnbdbackup-0.61-py3.9.egg/libvirtnbdbackup/common/__init__.py", line 21, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/virtnbdbackup-0.61-py3.9.egg/libvirtnbdbackup/common/common.py", line 12, in <module>
ModuleNotFoundError: No module named 'lz4'
  • ... Didn't the requirements get installed?
# python -m pip install -r ~/virtualenvs/virtnbdbackup/requirements.txt

Collecting libvirt-python>=6.0.0
  Using cached libvirt_python-8.4.0-cp39-cp39-linux_x86_64.whl
Collecting tqdm
  Using cached tqdm-4.64.0-py2.py3-none-any.whl (78 kB)
Collecting lz4>=2.1.2
  Using cached lz4-4.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)
Installing collected packages: libvirt-python, tqdm, lz4
Successfully installed libvirt-python-8.4.0 lz4-4.0.1 tqdm-4.64.0
  • No nbd?
# virtnbdbackup -d Seeborgs_-_01-10 -l full -o /var/lib/libvirt/images/backups-test

Traceback (most recent call last):
  File "/root/virtualenvs/virtnbdbackup/bin/virtnbdbackup", line 4, in <module>
    __import__('pkg_resources').run_script('virtnbdbackup==0.61', 'virtnbdbackup')
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/pkg_resources/__init__.py", line 672, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1479, in run_script
    exec(script_code, namespace, namespace)
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/virtnbdbackup-0.61-py3.9.egg/EGG-INFO/scripts/virtnbdbackup", line 33, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/virtnbdbackup-0.61-py3.9.egg/libvirtnbdbackup/nbdhelper/__init__.py", line 21, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/virtnbdbackup-0.61-py3.9.egg/libvirtnbdbackup/nbdhelper/nbdhelper.py", line 20, in <module>
ModuleNotFoundError: No module named 'nbd'
# python -m pip install nbd
Collecting nbd
  Using cached nbd-0.2-py3-none-any.whl
Collecting nbconvert
  Using cached nbconvert-6.5.0-py3-none-any.whl (561 kB)
Collecting ipython
  Using cached ipython-8.4.0-py3-none-any.whl (750 kB)
Collecting nbformat
  Using cached nbformat-5.4.0-py3-none-any.whl (73 kB)
Collecting jedi>=0.16
  Using cached jedi-0.18.1-py2.py3-none-any.whl (1.6 MB)
Collecting pickleshare
  Using cached pickleshare-0.7.5-py2.py3-none-any.whl (6.9 kB)
Collecting matplotlib-inline
  Using cached matplotlib_inline-0.1.3-py3-none-any.whl (8.2 kB)
Collecting backcall
  Using cached backcall-0.2.0-py2.py3-none-any.whl (11 kB)
Collecting prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0
  Using cached prompt_toolkit-3.0.29-py3-none-any.whl (381 kB)
Collecting pygments>=2.4.0
  Using cached Pygments-2.12.0-py3-none-any.whl (1.1 MB)
Collecting traitlets>=5
  Using cached traitlets-5.3.0-py3-none-any.whl (106 kB)
Requirement already satisfied: setuptools>=18.5 in /root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages (from ipython->nbd) (62.1.0)
Collecting stack-data
  Using cached stack_data-0.3.0-py3-none-any.whl (23 kB)
Collecting decorator
  Using cached decorator-5.1.1-py3-none-any.whl (9.1 kB)
Collecting pexpect>4.3
  Using cached pexpect-4.8.0-py2.py3-none-any.whl (59 kB)
Collecting tinycss2
  Using cached tinycss2-1.1.1-py3-none-any.whl (21 kB)
Collecting packaging
  Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting MarkupSafe>=2.0
  Using cached MarkupSafe-2.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting bleach
  Using cached bleach-5.0.0-py3-none-any.whl (160 kB)
Collecting pandocfilters>=1.4.1
  Using cached pandocfilters-1.5.0-py2.py3-none-any.whl (8.7 kB)
Collecting nbclient>=0.5.0
  Using cached nbclient-0.6.4-py3-none-any.whl (71 kB)
Collecting jinja2>=3.0
  Using cached Jinja2-3.1.2-py3-none-any.whl (133 kB)
Collecting jupyterlab-pygments
  Using cached jupyterlab_pygments-0.2.2-py2.py3-none-any.whl (21 kB)
Collecting entrypoints>=0.2.2
  Using cached entrypoints-0.4-py3-none-any.whl (5.3 kB)
Collecting beautifulsoup4
  Using cached beautifulsoup4-4.11.1-py3-none-any.whl (128 kB)
Collecting jupyter-core>=4.7
  Using cached jupyter_core-4.10.0-py3-none-any.whl (87 kB)
Collecting defusedxml
  Using cached defusedxml-0.7.1-py2.py3-none-any.whl (25 kB)
Collecting mistune<2,>=0.8.1
  Using cached mistune-0.8.4-py2.py3-none-any.whl (16 kB)
Collecting fastjsonschema
  Using cached fastjsonschema-2.15.3-py3-none-any.whl (22 kB)
Collecting jsonschema>=2.6
  Using cached jsonschema-4.6.0-py3-none-any.whl (80 kB)
Collecting parso<0.9.0,>=0.8.0
  Using cached parso-0.8.3-py2.py3-none-any.whl (100 kB)
Collecting pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0
  Using cached pyrsistent-0.18.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (115 kB)
Collecting attrs>=17.4.0
  Using cached attrs-21.4.0-py2.py3-none-any.whl (60 kB)
Collecting jupyter-client>=6.1.5
  Using cached jupyter_client-7.3.4-py3-none-any.whl (132 kB)
Collecting nest-asyncio
  Using cached nest_asyncio-1.5.5-py3-none-any.whl (5.2 kB)
Collecting ptyprocess>=0.5
  Using cached ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Collecting wcwidth
  Using cached wcwidth-0.2.5-py2.py3-none-any.whl (30 kB)
Collecting soupsieve>1.2
  Using cached soupsieve-2.3.2.post1-py3-none-any.whl (37 kB)
Collecting webencodings
  Using cached webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
Collecting six>=1.9.0
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pyparsing!=3.0.5,>=2.0.2
  Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB)
Collecting asttokens
  Using cached asttokens-2.0.5-py2.py3-none-any.whl (20 kB)
Collecting pure-eval
  Using cached pure_eval-0.2.2-py3-none-any.whl (11 kB)
Collecting executing
  Using cached executing-0.8.3-py2.py3-none-any.whl (16 kB)
Collecting pyzmq>=23.0
  Using cached pyzmq-23.2.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.1 MB)
Collecting tornado>=6.0
  Using cached tornado-6.1-cp39-cp39-manylinux2010_x86_64.whl (427 kB)
Collecting python-dateutil>=2.8.2
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Installing collected packages: webencodings, wcwidth, pure-eval, ptyprocess, pickleshare, mistune, fastjsonschema, executing, backcall, traitlets, tornado, tinycss2, soupsieve, six, pyzmq, pyrsistent, pyparsing, pygments, prompt-toolkit, pexpect, parso, pandocfilters, nest-asyncio, MarkupSafe, jupyterlab-pygments, entrypoints, defusedxml, decorator, attrs, python-dateutil, packaging, matplotlib-inline, jupyter-core, jsonschema, jinja2, jedi, bleach, beautifulsoup4, asttokens, stack-data, nbformat, jupyter-client, nbclient, ipython, nbconvert, nbd
Successfully installed MarkupSafe-2.1.1 asttokens-2.0.5 attrs-21.4.0 backcall-0.2.0 beautifulsoup4-4.11.1 bleach-5.0.0 decorator-5.1.1 defusedxml-0.7.1 entrypoints-0.4 executing-0.8.3 fastjsonschema-2.15.3 ipython-8.4.0 jedi-0.18.1 jinja2-3.1.2 jsonschema-4.6.0 jupyter-client-7.3.4 jupyter-core-4.10.0 jupyterlab-pygments-0.2.2 matplotlib-inline-0.1.3 mistune-0.8.4 nbclient-0.6.4 nbconvert-6.5.0 nbd-0.2 nbformat-5.4.0 nest-asyncio-1.5.5 packaging-21.3 pandocfilters-1.5.0 parso-0.8.3 pexpect-4.8.0 pickleshare-0.7.5 prompt-toolkit-3.0.29 ptyprocess-0.7.0 pure-eval-0.2.2 pygments-2.12.0 pyparsing-3.0.9 pyrsistent-0.18.1 python-dateutil-2.8.2 pyzmq-23.2.0 six-1.16.0 soupsieve-2.3.2.post1 stack-data-0.3.0 tinycss2-1.1.1 tornado-6.1 traitlets-5.3.0 wcwidth-0.2.5 webencodings-0.5.1
# virtnbdbackup -d Seeborgs_-_01-10 -l full -o /var/lib/libvirt/images/backups-test

Traceback (most recent call last):
  File "/root/virtualenvs/virtnbdbackup/bin/virtnbdbackup", line 4, in <module>
    __import__('pkg_resources').run_script('virtnbdbackup==0.61', 'virtnbdbackup')
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/pkg_resources/__init__.py", line 672, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1479, in run_script
    exec(script_code, namespace, namespace)
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/virtnbdbackup-0.61-py3.9.egg/EGG-INFO/scripts/virtnbdbackup", line 34, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/virtnbdbackup-0.61-py3.9.egg/libvirtnbdbackup/extenthandler/__init__.py", line 21, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/virtnbdbackup-0.61-py3.9.egg/libvirtnbdbackup/extenthandler/extenthandler.py", line 18, in <module>
ImportError: cannot import name 'CONTEXT_BASE_ALLOCATION' from 'nbd' (/root/virtualenvs/virtnbdbackup/lib/python3.9/site-packages/nbd/__init__.py)

At this point, I do not understand what to try next. Thank you for taking the time to read!

virtnbdbackup: redefining checkpoints failes

Hi,

I found a bug in the redefining of checkpoints. I migrated a vm from host a to b and try to make a (diff) backup, now I'm getting the output below. It doesn't matter if I use the --checkpointdir option. When I manually redefine the checkpoint it works (virsh checkpoint-create X --redefine --xmlfile /X/backupset.15/checkpoints/virtnbdbackup.0.xml).

Kind regards,
Stefan

[2022-04-11 20:44:02] INFO common - printVersion [MainThread]: Version: 0.55 Arguments: /usr/bin/virtnbdbackup -d X -l diff -o /X/backupset.15
[2022-04-11 20:44:02] INFO virtnbdbackup - main [MainThread]: Backup level: [diff]
[2022-04-11 20:44:02] INFO virtnbdbackup - main [MainThread]: Domain has 1 disks attached which support changed block tracking.
[2022-04-11 20:44:02] INFO virtnbdbackup - main [MainThread]: Concurrent backup processes: [1]
[2022-04-11 20:44:02] INFO libvirthelper - redefineCheckpoints [MainThread]: Loading checkpoint list from: [X/backupset.15/checkpoints]
[2022-04-11 20:44:02] INFO libvirthelper - redefineCheckpoints [MainThread]: Redefine missing checkpoint: [virtnbdbackup.0]
Traceback (most recent call last):
File "/usr/bin/virtnbdbackup", line 893, in
main()
File "/usr/bin/virtnbdbackup", line 472, in main
handleCheckpoints(args, virtClient, domObj, lib)
File "/usr/bin/virtnbdbackup", line 147, in handleCheckpoints
if virtClient.redefineCheckpoints(domObj, args) is False:
File "/usr/lib/python3/dist-packages/libvirtnbdbackup/libvirthelper/libvirthelper.py", line 438, in redefineCheckpoints
domObj.checkpointCreateXML(
File "/usr/lib/python3/dist-packages/libvirt.py", line 1267, in checkpointCreateXML
ret = libvirtmod.virDomainCheckpointCreateXML(self._o, xmlDesc, flags)
TypeError: virDomainCheckpointCreateXML() argument 2 must be str or None, not bytes

Remove xml based check for required incremental-backup capability

[root@oplx7010 virt]# virtnbdbackup -d centos7.0 -l full -o backup -i vda ERROR:root:Domain is missing required incremental-backup capability.

Then I remembered, I forgot to add "<qemu:add capability='incremental-backup'/>" like I did before.
Well, now I can't:
[root@oplx7010 qemu]# rpm -q --last libvirt-libs-6.6.0-5.fc33.x86_64 libvirt-libs-6.6.0-5.fc33.x86_64 Thu 18 Mar 2021 04:38:08 PM PDT

hm.. not sure, but maybe things have changed now with more recent libvirt versions, it seems to be enabled by
default now:

https://bugzilla.redhat.com/show_bug.cgi?id=1799015

Originally posted by @abbbi in #2 (comment)

virtnbdbackup: cannot import name 'CONTEXT_BASE_ALLOCATION' from nbd in Debian Bullseye

First thanks for the awesome tool!

Im trying to use it on my debian 11 bullseye, installed from the git repository and followed the steps but Im facing the following error when trying to execute it:

Traceback (most recent call last): File "/usr/local/bin/virtnbdbackup", line 4, in <module> __import__('pkg_resources').run_script('virtnbdbackup==0.43', 'virtnbdbackup') File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 651, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1455, in run_script exec(script_code, namespace, namespace) File "/usr/local/lib/python3.9/dist-packages/virtnbdbackup-0.43-py3.9.egg/EGG-INFO/scripts/virtnbdbackup", line 31, in <module> File "<frozen zipimport>", line 259, in load_module File "/usr/local/lib/python3.9/dist-packages/virtnbdbackup-0.43-py3.9.egg/libvirtnbdbackup/extenthandler/__init__.py", line 4, in <module> File "<frozen zipimport>", line 259, in load_module File "/usr/local/lib/python3.9/dist-packages/virtnbdbackup-0.43-py3.9.egg/libvirtnbdbackup/extenthandler/extenthandler.py", line 18, in <module> ImportError: cannot import name 'CONTEXT_BASE_ALLOCATION' from 'nbd' (/usr/local/lib/python3.9/dist-packages/nbd/__init__.py)
I have checked the version of the libnbd library in debian and is up to 1.6.1 so this shouldn't be the problem.

Any help will be really appreciated, thanks in advance!

Cannot get it running on alma 8.6

when i try to install rpm i get this error:

dnf install -y virtnbdbackup-0.66-1.noarch.rpm
Last metadata expiration check: 3:49:33 ago on Fri 01 Jul 2022 11:08:14 BST.
Error:
Problem: conflicting requests

  • nothing provides nbdkit-plugin-python3 needed by virtnbdbackup-0.66-1.noarch
    (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

i don't find such an "nbdkit-plugin-python3"


./virtnbdbackup
Traceback (most recent call last):
File "./virtnbdbackup", line 34, in
from libvirtnbdbackup import extenthandler
File "/root/virtnbdbackup-0.66/libvirtnbdbackup/extenthandler/init.py", line 21, in
from .extenthandler import ExtentHandler
File "/root/virtnbdbackup-0.66/libvirtnbdbackup/extenthandler/extenthandler.py", line 18, in
from nbd import CONTEXT_BASE_ALLOCATION
ImportError: cannot import name 'CONTEXT_BASE_ALLOCATION'

seems there are dependencies missing not part of the requirements.txt

Zeroed regions in restored images are reported as data (will be backing up full provisioned)

If a virtual machine has once been fully restored via virtnbdrestore, the next executing backup of the virtual machine is thick provisioned.
Looking at an qemu-img mapping of the original and the restored qcow image, it seems the zeroed regions within the data image are reported with "data:true" instead of "data:false", means the current nbd client extention treats them as dirty blocks:

-{ "start": 131072, "length": 917504, "depth": 0, "zero": true, "data": false, "offset": 131072},
+{ "start": 131072, "length": 917504, "depth": 0, "zero": true, "data": true, "offset": 131072},

While the qcow image itself is correctly thin provisioned, this will make blocks appear as "dirty". Not sure how to solve this atm, probably some options for the qemu-nbd process started during restore are necessary.

Error attempting to run incremental backup

I am using v0.36. I am running into the following error when trying to run incremental backups.

Traceback (most recent call last):
  File "/usr/local/bin/virtnbdbackup", line 4, in <module>
    __import__('pkg_resources').run_script('virtnbdbackup==0.36', 'virtnbdbackup')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 651, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1455, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python3.9/dist-packages/virtnbdbackup-0.36-py3.9.egg/EGG-INFO/scripts/virtnbdbackup", line 645, in <module>
  File "/usr/local/lib/python3.9/dist-packages/virtnbdbackup-0.36-py3.9.egg/EGG-INFO/scripts/virtnbdbackup", line 300, in main
  File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This seems to be happening on the 2nd incremental backup. First one seems to run OK.

I've noticed one commonality. The .cpt file is 0 length on all of the VMs I'm having this issue with.

README errors

  1. There is a typo in Backup fails with "Failed to bind socket to /var/tmp/virtnbdbackup.XX: Permission denied":
/var/tmp/virtnbdbackup.* rw
/var/tmp/backup.* rw,

should be a comma (,) at the end of first line:

/var/tmp/virtnbdbackup.* rw,
/var/tmp/backup.* rw,
  1. In Installation of Debian package:

In a standard Debian 11 (Bullseye) installation one more package is missing that is required: python3-lz4

Should be:

sudo apt-get install python3-all python3-stdeb dh-python python3-libnbd python3-tqdm python3-lz4
python3 setup.py --command-packages=stdeb.command bdist_deb

Backup uefi/nvram settings

For virtual machines which boot via UEFI, it would be good to backup the nvram settings file too.
Virtual machine XML for example:

  <os>
    <type arch='x86_64' machine='pc-q35-5.2'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE_4M.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/archlinux_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>

the file specified in nvram setting can contain uefi settings that would be good to have within
the backup too.

  1. detect if option is set
  2. copy file to backup directory during backup
  3. add files to zip if output target is stdout
  4. add note that files have to be copied during restore to appropriate target pathes.

Installation issue on v0.29 requirements.txt missing.

Unable to install v0.29 from the tarball.
'''

python3 setup.py install

Traceback (most recent call last):
File "/tmp/virtnbdbackup-0.29/setup.py", line 23, in
install_requires=open("requirements.txt").read().splitlines(),
FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'
'''

I tried searching the repo for requirements.txt and couldn't find the actual file.

Error: unable to rename file

Hi,
First, thank you for creating this :)

I got this error twice during a backup:
ERROR virtnbdbackup - backupDisk [vda]: Unable to rename file: [Errno 16] Device or resource busy: '/mnt/backup-nas/server-docker/vda.inc.virtnbdbackup.1.data.partial' -> '/mnt/backup-nas/vda.inc.virtnbdbackup.1.data'

What could be the reason?
The target is a mounted smb share.

Regards,
Dorian

ERROR virtnbdbackup - main: 'NBD' object has no attribute 'get_block_size'

I am attempting to use this on an Ubuntu 20.04.3 LTS system and getting the following error:

[2021-10-22 10:04:40] ERROR virtnbdbackup - main: Unable to backup Disk: 'NBD' object has no attribute 'get_block_size'
[2021-10-22 10:04:40] ERROR virtnbdbackup - main: 'NBD' object has no attribute 'get_block_size'
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/virtnbdbackup-0.25-py3.8.egg/EGG-INFO/scripts/virtnbdbackup", line 347, in main
  File "/usr/local/lib/python3.8/dist-packages/virtnbdbackup-0.25-py3.8.egg/EGG-INFO/scripts/virtnbdbackup", line 405, in backupDisk
  File "/usr/local/lib/python3.8/dist-packages/virtnbdbackup-0.25-py3.8.egg/libvirtnbdbackup/nbdhelper/nbdhelper.py", line 55, in connect
    self.getBlockInfo()
  File "/usr/local/lib/python3.8/dist-packages/virtnbdbackup-0.25-py3.8.egg/libvirtnbdbackup/nbdhelper/nbdhelper.py", line 36, in getBlockInfo
    maxSize = self._nbdHandle.get_block_size(nbd.SIZE_MAXIMUM)
AttributeError: 'NBD' object has no attribute 'get_block_size'

I see this was referenced back in issue #7 but I'm unclear what the resolution is.

unable to execute QEMU command 'transaction': Bitmap already exists

Hi

could you please explain what's wrong with following scenario:

  1. initial state, VM is running, no checkpoints yet

root@d02l:~# virsh list
 Id   Name          State
-----------------------------
 3    vm-template   running

root@d02l:~# virsh checkpoint-list vm-template
 Name   Creation Time
-----------------------
  1. do backup
root@d02l:~# mkdir /backup/vm-template.20210501-1
root@d02l:~# virtnbdbackup -d vm-template -l full -o /backup/vm-template.20210501-1
2021-05-01 17:55:24 INFO common - printVersion: Version: 0.18 Arguments: /usr/local/bin/virtnbdbackup -d vm-template -l full -o /backup/vm-template.20210501-1
2021-05-01 17:55:24 INFO virtnbdbackup - main: Domain has 1 disks attached which support changed block tracking.
2021-05-01 17:55:24 INFO virtnbdbackup - main: Looking for checkpoints
2021-05-01 17:55:24 INFO virtnbdbackup - main: Using checkpoint name: virtnbdbackup
2021-05-01 17:55:24 INFO virtnbdbackup - main: Temporary scratch file target directory: /var/tmp
2021-05-01 17:55:24 INFO virtnbdbackup - main: Starting backup job.
2021-05-01 17:55:25 INFO libvirthelper - startBackup: Freezed filesystems.
2021-05-01 17:55:25 INFO libvirthelper - startBackup: Thawed filesystems.
2021-05-01 17:55:25 INFO virtnbdbackup - main: Started backup job with checkpoint, saving information.
2021-05-01 17:55:25 INFO nbdhelper - version: 1.6.3
2021-05-01 17:55:25 INFO virtnbdbackup - backupDisk: NDB Endpoint socket: /var/tmp/virtnbdbackup.11541
2021-05-01 17:55:25 INFO virtnbdbackup - backupDisk: Using nbd to query extents
2021-05-01 17:55:25 INFO virtnbdbackup - backupDisk: Got 3157 extents
2021-05-01 17:55:25 INFO virtnbdbackup - backupDisk: 42949672960 bytes disk size
saving disk vda: 100%|████████████████████████████████████████████████████████████████████| 3.65G/3.65G [01:13<00:00, 49.3MB/s]
2021-05-01 17:56:39 INFO virtnbdbackup - backupDisk: Backup of disk vda finished, file: /backup/vm-template.20210501-1/vda.full.data
2021-05-01 17:56:39 INFO virtnbdbackup - backupConfig: Saving VM config to: /backup/vm-template.20210501-1/vmconfig.virtnbdbackup.xml
2021-05-01 17:56:39 INFO virtnbdbackup - main: Stopping backup task
2021-05-01 17:56:39 INFO virtnbdbackup - main: Finished
root@d02l:~#
  1. now VM have checkpoint:
root@d02l:~# virsh checkpoint-list vm-template
 Name            Creation Time
--------------------------------------------
 virtnbdbackup   2021-05-01 17:55:25 +0300

root@d02l:~#

  1. stop VM and start it again
root@d02l:~# pcs resource disable vm-template
root@d02l:~# virsh list
 Id   Name   State
--------------------

root@d02l:~# pcs resource enable vm-template
root@d02l:~# virsh list
 Id   Name          State
-----------------------------
 4    vm-template   running

(It's a pacemaker cluster, therefore pcs resource disable/enable instead of
virsh shutdown/start)

  1. checkpoint disappeared
root@d02l:~# virsh checkpoint-list vm-template
root@d02l:~# virsh checkpoint-list vm-template
 Name   Creation Time
-----------------------


 6. and virtnbdbackup is now getting "bitmap already exists" error

root@d02l:~# mkdir /backup/vm-template.20210501-2
root@d02l:~# virtnbdbackup -d vm-template -l full -o /backup/vm-template.20210501-2
2021-05-01 18:04:39 INFO common - printVersion: Version: 0.18 Arguments: /usr/local/bin/virtnbdbackup -d vm-template -l full -o /backup/vm-template.20210501-2
2021-05-01 18:04:39 INFO virtnbdbackup - main: Domain has 1 disks attached which support changed block tracking.
2021-05-01 18:04:39 INFO virtnbdbackup - main: Looking for checkpoints
2021-05-01 18:04:39 INFO virtnbdbackup - main: Using checkpoint name: virtnbdbackup
2021-05-01 18:04:39 INFO virtnbdbackup - main: Temporary scratch file target directory: /var/tmp
2021-05-01 18:04:39 INFO virtnbdbackup - main: Starting backup job.
2021-05-01 18:04:39 INFO libvirthelper - startBackup: Freezed filesystems.
2021-05-01 18:04:40 ERROR virtnbdbackup - main: internal error: unable to execute QEMU command 'transaction': Bitmap already exists: virtnbdbackup
  1. and it's surely exists
root@d02l:~# virsh domfsthaw vm-template
Thawed 1 filesystem(s)

root@d02l:~# pcs resource disable vm-template
root@d02l:~# qemu-img info /var/lib/libvirt/images.drbd0/template.qcow2
image: /var/lib/libvirt/images.drbd0/template.qcow2
file format: qcow2
virtual size: 40 GiB (42949672960 bytes)
disk size: 1.61 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    bitmaps:
        [0]:
            flags:
                [0]: auto
            name: virtnbdbackup
            granularity: 65536
    refcount bits: 16
    corrupt: false
    extended l2: false
root@d02l:~#
  1. but virtnbdbackup doesn't work until manual removal of bitmap
root@d02l:~# qemu-img bitmap --remove /var/lib/libvirt/images.drbd0/template.qcow2 virtnbdbackup
root@d02l:~# qemu-img info /var/lib/libvirt/images.drbd0/template.qcow2
image: /var/lib/libvirt/images.drbd0/template.qcow2
file format: qcow2
virtual size: 40 GiB (42949672960 bytes)
disk size: 1.61 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false
root@d02l:~#
  1. libvirt and qemu are more or less recent this time:
root@d02l:~# virsh version
Compiled against library: libvirt 7.0.0
Using library: libvirt 7.0.0
Using API: QEMU 7.0.0
Running hypervisor: QEMU 5.2.0

Instant recovery with nbdkit plugin

It should be possible to create an nbdkit plugin in python that opens the thin provisioned backup stream files and
on block request, maps the internal offsets of the sparsestream format to the regular data offsets and returns the right data to nbdkit.

This way it would be possible to mount the thin provisioned backup images without having to restore all the data, or having to map the complete file into memory.

Match backup target directory to virtual machine

Currently following might possible if virtual machine has the same amount of checkpoints:

virtnbdbackup -l full -d vm1 -o /tmp/backup
virtnbdbackup -l inc -d vm2 -o /tmp/backup

its not checked wether if the already existing data-set in the target directory matches the virtual machine
that is backed up.

No way to exclude disks

An interesting project. I tried virtnbdbackup on a CentOS 7 VM on a Fedora 33 host. The VM has a small, QCOW2 system disk and a large, raw storage disk, and a CDROM drive that is unused, but it got created by default. I only wanted to back up the system disk, vda.

At first it couldn't get past the CDROM drive, sda:
ERROR:root:unsupported configuration: disk 'sda' has no media
I attached an iso file to the CDROM drive and then got:
ERROR:root:unsupported configuration: disk 'sda' is empty or readonly
So I deleted the CDROM drive and then it couldn't get past the raw storage drive, vdb
ERROR:root:unsupported configuration: checkpoint for disk vdb unsupported for storage type raw
So I deleted the vdb disk device, and only then it succeeded in creating a backup of the system disk, vda.

I found in the code the "--include" commandline switch:
parser.add_argument("-i", "--include", default=None, type=str, help="Backup only disk with target dev name specified")
That seems like just what I needed.
[root@oplx7010 2TBpart]# virtnbdbackup -d centos7.0 -i vda -l full -o centos7.0.virtnbdbackup

But I still failed the same way with the same messages. The "include" switch had no apparent effect. It did not result in the other disks being ignored as I would have expected.

Thank you.
Richard Ketcham

Change default backup mode to auto

Currently the default backup mode is 'copy'. As more distributions will ship newer libvirt/qemu versions (>7.6.0) which have incremental backup support enabled by default, it could be considered to change the default backup mode to "auto", based on the libvirt version or in general.

Add backup support for offline/shutdown domains

Currently backing up offline/shutdown domains is not possible, as there is no qemu process running that could be queried for the required data. virtnbdbackup could check state of the domain before attempting to execute the backup job and if domain is not in running state, spawn its own qemu-nbd process to query disk data.

Work ongoing in branch: https://github.com/abbbi/virtnbdbackup/tree/offline-backup

Todos:

  1. Check if there is a way to offline backup via NBD, and use this one if possible

Support incremental backup for offline virtual domains

Current version creates a copy backup type (full, thin provisioned data backup) if a virtual machine is offline.
It should work to create incremental backups of offline virtual machines too:

  • During offline backup, the last existant bitmap that was created on the Virtual machine is determined
  • The qemu-nbd process which is spawned for each disk gets passed the name of the bitmap to expose via -B option
  • The Meta context for the NBD connection is set to match the bitmaps meta context (qemu:dirty-bitmap:checkpoint_name)
  • The extent query will only return changed regions within this checkpoint.

Work ongoing in branch:
https://github.com/abbbi/virtnbdbackup/tree/offline-incremental-backup

It needs some careful testing, first tests look OK so far:

  1. create full backup of running domain:
./virtnbdbackup -d offline -l full -o /tmp/XXX
backupDisk [vda]: 4596563968 bytes of data extents to backup
  1. Shutdown the virtual machine and create incremental backup:
./virtnbdbackup -d offline -l inc -o /tmp/XXX
backupDisk [vda]: 14352384 bytes of data extents to backup

-> only changes are saved which happened during shutdown operation

  1. start vm, create another incremental backup, changes tracked during startup are saved, new checkpoint is created:
./virtnbdbackup -d offline -l inc -o /tmp/XXX
 backupDisk [vda]: 18677760 bytes of data extents to backup
  1. Now, startup VM, and shutdown again: from this time on, any additional offline incremental backup will save the accumulated changes since the last checkpoint, overwriting the existing data file (as it has the same checkpoint name) but the size of the to be saved data grows with each change applied.

I came along situations where i couldnt use the bitmap because it was "inconsistent": this happened if i forcfully destroyed the domain via "virsh destroy" instead of shutting it down gracefully:

qemu-nbd: Bitmap 'virtnbdbackup.3' is inconsistent and cannot be used

This is the case if the bitmap in the qcow image has the "in-use" flag:
this needs to be handled gracefully and backup must fail in this case.

Question about CBT/Dirty Blocks

@abbbi Hello,

the Program looks very interesting.

what i think is from quick look > its may complex to handle "Traditional Backups" when lots activities

  • Full Backup
  • then Diff or Inc
  • then archive/retention

is there may any chance a Feature Request to an real "CBT" Modern Backup Method + Retention Logic.

CBT Modern Backup = its always a Full Backup... just new blocks getting backed up and merged into Base.

when restoring seeing only 1x backup set. .... rather into diff/inc complexity.

when restoring a VM from vmare for example i always see only 1 Image.

may kinda Idea can be done on Linux with this App also?.

Ubuntu 20.04.2 LTS

Hi, nice tool, thanks a lot

tried it in Ubuntu 20.04.2 LTS

  1. apparmor issues - libvirtd not allowed to create sockets in /var/tmp

2021-04-20 17:38:50 INFO common - printVersion: Version: 0.17 Arguments: /usr/local/bin/virtnbdbackup -d vm-template -l full -o /mnt/backup/vm-template
2021-04-20 17:38:50 INFO virtnbdbackup - main: Domain has 1 disks attached which support changed block tracking.
2021-04-20 17:38:50 INFO virtnbdbackup - main: Looking for checkpoints
2021-04-20 17:38:50 INFO virtnbdbackup - main: Using checkpoint name: virtnbdbackup
2021-04-20 17:38:50 INFO virtnbdbackup - main: Temporary scratch file target directory: /var/tmp
2021-04-20 17:38:50 INFO virtnbdbackup - main: Starting backup job.
2021-04-20 17:38:50 WARNING libvirthelper - startBackup: Guest agent is not responding: QEMU guest agent is not connected
2021-04-20 17:38:50 ERROR virtnbdbackup - main: internal error: unable to execute QEMU command 'nbd-server-start': Failed to bind socket to /var/tmp/virtnbdbackup.868194: Permission denied

obvious workaround is to disable apparmor

extenthandler.py:
def _setRequestAligment(self):
align = self._nbdFh.get_block_size(0)
if align == 0:
align = self._align
return self._maxRequestBlock - align + 1

Ubuntu has libnbd 1.2.2 with missing get_block_size()
is it safe to skip get_block_size() and use self._align if no get_block_size() available ?

virtnbdmap: support mapping compressed backup images

It should be possible to map compressed images too. One idea would be:

  1. detect compressed image and read trailer in virtnbdmap
  2. add info about the compressed block (length and original length / offset) to the blockmap json
  3. in virtnbd-nbdkit-plugin detect if requested block is compressed, decompress and return decompressed data

How to automatically create daily backups?

Hi, we would like to perform daily backups with virtnbdbackup.
Therefore, we want to always keep one full backup and two snapshots, e.g.:

2021-04-09.img -> full backup
2021-04-10.img -> snapshot
2021-04-11.img -> snapshot
<currently running state>

How would I configure this with virtnbdbackup?
Also, how do we restore a backup?

Fails to restore missing checkpoints after the 11th backup

Hello there,

Under a server crash event (with multiple VMs running,) I've found it's able to recover missing checkpoints correctly. For example:

INFO common - printVersion: Version: 0.23 Arguments: /usr/local/bin/virtnbdbackup -d Server1 -l inc -o /mnt/user/Backup/vm-backups/Server1 --compress
INFO virtnbdbackup - main: Store checkpoints in: /mnt/user/Backup/vm-backups/Server1/checkpoints
WARNING libvirthelper - getDomainDisks: Raw disk hdb excluded by default, use option --raw to include.
INFO virtnbdbackup - main: Domain has 1 disks attached which support changed block tracking.
INFO virtnbdbackup - main: Attempting to redefine checkpoints from: /mnt/user/Backup/vm-backups/Server1/checkpoints
INFO libvirthelper - redefineCheckpoints: Loading checkpoint list from: /mnt/user/Backup/vm-backups/Server1/checkpoints
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.0
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.1
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.2
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.3
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.4
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.5
INFO virtnbdbackup - main: Looking for checkpoints
INFO virtnbdbackup - main: Found checkpoints, next checkpoint id: 6
INFO virtnbdbackup - main: Parent checkpoint name virtnbdbackup.5
INFO virtnbdbackup - main: Using checkpoint name: virtnbdbackup.6
INFO virtnbdbackup - main: Temporary scratch file target directory: /var/tmp
INFO virtnbdbackup - main: Starting backup job.
INFO libvirthelper - fsFreeze: Freeze filesystems.
INFO libvirthelper - fsThaw: Thawed filesystems.
INFO virtnbdbackup - main: Started backup job with checkpoint, saving information.
INFO libvirthelper - backupCheckpoint: Saving checkpoint config to /mnt/user/Backup/vm-backups/Server1/checkpoints/virtnbdbackup.6.xml
INFO virtnbdbackup - backupDisk: INC backup: set context to qemu:dirty-bitmap:backup-hdc
INFO nbdhelper - version: 1.6.1
INFO virtnbdbackup - backupDisk: NDB Endpoint socket: /var/tmp/virtnbdbackup.1
INFO nbdhelper - getBlockInfo: Using Maximum Block size supported by nbd server: 33554432
INFO virtnbdbackup - backupDisk: Using nbd to query extents
INFO virtnbdbackup - backupDisk: Got 12965 extents
INFO virtnbdbackup - backupDisk: 214748364800 bytes disk size
INFO virtnbdbackup - backupDisk: 1349189632 bytes of data extents to backup
INFO virtnbdbackup - backupDisk: Write data to target file: /mnt/user/Backup/vm-backups/Server1/hdc.inc.virtnbdbackup.6.data.partial
INFO virtnbdbackup - backupDisk: Creating thin provisioned stream backup image
INFO virtnbdbackup - backupDisk: Compression enabled
INFO virtnbdbackup - backupDisk: Backup of disk hdc finished, file: /mnt/user/Backup/vm-backups/Server1/hdc.inc.virtnbdbackup.6.data
INFO virtnbdbackup - backupConfig: Saving VM config to: /mnt/user/Backup/vm-backups/Server1/vmconfig.virtnbdbackup.6.xml
INFO virtnbdbackup - main: Stopping backup task
INFO virtnbdbackup - main: Finished

In this particular case, sudden incremental backups didn't show missing checkpoints again.

But in other cases I found that chance to recover missing checkpoints is zero when the 11th checkpoint (virtnbdbackup.10) exists, failing almost invariably in this way:

INFO common - printVersion: Version: 0.23 Arguments: /usr/local/bin/virtnbdbackup -d Server2 -l inc -o /mnt/user/Backup/vm-backups/Server2 --compress
INFO virtnbdbackup - main: Store checkpoints in: /mnt/user/Backup/vm-backups/Server2/checkpoints
WARNING libvirthelper - getDomainDisks: Raw disk hdb excluded by default, use option --raw to include.
INFO virtnbdbackup - main: Domain has 1 disks attached which support changed block tracking.
INFO virtnbdbackup - main: Attempting to redefine checkpoints from: /mnt/user/Backup/vm-backups/Server2/checkpoints
INFO libvirthelper - redefineCheckpoints: Loading checkpoint list from: /mnt/user/Backup/vm-backups/Server2/checkpoints
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.0
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.1
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.10
ERROR libvirthelper - redefineCheckpoints: Unable to redefine checkpoint virtnbdbackup.10: invalid argument: parent virtnbdbackup.9 for moment virtnbdbackup.10 not found
WARNING virtnbdbackup - main: Unable to redefine checkpoints
INFO virtnbdbackup - main: Looking for checkpoints
INFO virtnbdbackup - main: Found checkpoints, next checkpoint id: 11
INFO virtnbdbackup - main: Parent checkpoint name virtnbdbackup.10
INFO virtnbdbackup - main: Using checkpoint name: virtnbdbackup.11
INFO virtnbdbackup - main: Temporary scratch file target directory: /var/tmp
INFO virtnbdbackup - main: Starting backup job.
INFO libvirthelper - fsFreeze: Freeze filesystems.
INFO libvirthelper - fsThaw: Thawed filesystems.
ERROR virtnbdbackup - main: invalid argument: missing or broken bitmap 'virtnbdbackup.10' for disk 'hdc'
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/virtnbdbackup-0.23-py3.9.egg/EGG-INFO/scripts/virtnbdbackup", line 271, in main
File "/usr/local/lib/python3.9/dist-packages/virtnbdbackup-0.23-py3.9.egg/libvirtnbdbackup/libvirthelper/libvirthelper.py", line 260, in startBackup
domObj.backupBegin(backupXml, checkpointXml)
File "/usr/lib/python3/dist-packages/libvirt.py", line 797, in backupBegin
raise libvirtError('virDomainBackupBegin() failed')
libvirt.libvirtError: invalid argument: missing or broken bitmap 'virtnbdbackup.10' for disk 'hdc'

Where the sequence:

INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.0
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.1
INFO libvirthelper - redefineCheckpoints: Redefine missing checkpoint virtnbdbackup.10
ERROR libvirthelper - redefineCheckpoints: Unable to redefine checkpoint virtnbdbackup.10: invalid argument: parent virtnbdbackup.9 for moment virtnbdbackup.10 not found

Repeats invariably, regardless the number of checkpoints and if the backup chain grew up without issues to a high number (e.g. virtnbdbackup.35.) It's like if it gets stuck because it's restoring them in a bad sequence.

virsh --version
Compiled against library: libvirt 6.5.0
Using library: libvirt 6.5.0
Using API: QEMU 6.5.0
Running hypervisor: QEMU 5.1.0


I'm not good enough at python like to check the code and point out, but as I've been dealing with libvirt for a while, this looks similar as how 'virsh checkpoint-list ' throws by default:

Name Creation Time
-----------------------------------------------
virtnbdbackup.0 2021-09-02 21:14:57 +0200
virtnbdbackup.1 2021-09-02 21:31:31 +0200
virtnbdbackup.10 2021-09-21 03:00:18 +0200
virtnbdbackup.11 2021-09-22 03:00:18 +0200
virtnbdbackup.2 2021-09-03 18:37:05 +0200
virtnbdbackup.3 2021-09-04 04:40:04 +0200
virtnbdbackup.4 2021-09-05 04:40:09 +0200
virtnbdbackup.5 2021-09-06 04:40:14 +0200
virtnbdbackup.6 2021-09-14 04:40:29 +0200
virtnbdbackup.7 2021-09-15 03:00:19 +0200
virtnbdbackup.8 2021-09-16 03:00:29 +0200
virtnbdbackup.9 2021-09-20 03:00:22 +0200

If this is related with the issue, '--topological' flag shows a correct sequence, where no child is listed before its ancestors (https://libvirt.org/manpages/virsh.html#id261)

Name Creation Time
-----------------------------------------------
virtnbdbackup.0 2021-09-02 21:14:57 +0200
virtnbdbackup.1 2021-09-02 21:31:31 +0200
virtnbdbackup.2 2021-09-03 18:37:05 +0200
virtnbdbackup.3 2021-09-04 04:40:04 +0200
virtnbdbackup.4 2021-09-05 04:40:09 +0200
virtnbdbackup.5 2021-09-06 04:40:14 +0200
virtnbdbackup.6 2021-09-14 04:40:29 +0200
virtnbdbackup.7 2021-09-15 03:00:19 +0200
virtnbdbackup.8 2021-09-16 03:00:29 +0200
virtnbdbackup.9 2021-09-20 03:00:22 +0200
virtnbdbackup.10 2021-09-21 03:00:18 +0200
virtnbdbackup.11 2021-09-22 03:00:18 +0200

Along with the flag '--name', generates a clean list of checkpoints as they should be (apparently) restored.

Thanks for reading. Open to help with further info as much as I can.

Almalinux 8 - error run

I'm trying to run a backup on Almalinux 8 and I get an error after running:

virtnbdbackup -d vm1 -l full -o /media/backup_repo/
Traceback (most recent call last):
File "/usr/bin/virtnbdbackup", line 31, in
from libvirtnbdbackup import version
ImportError: cannot import name 'version'

High memory usage during backup of big disk images

Hi

noticed OOM on big amount of data

Apr 28 23:17:04 d02l kernel: Tasks state (memory values in pages):
Apr 28 23:17:04 d02l kernel: [ pid ] uid tgid total_vm rss pgtables_bytes swapents oom_score_adj name
...
Apr 28 23:17:05 d02l kernel: [ 378468] 0 378468 28402621 27067014 227512320 1300054 0 virtnbdbackup
...
Apr 28 23:17:05 d02l kernel: Out of memory: Killed process 378468 (virtnbdbackup) total-vm:113610484kB, anon-rss:108264172kB, file-rss:3884kB, shmem-rss:0kB, UID:0 pgtables:222180kB oom_score_adj:0

It was a VM with 150+ Gb of data to backup

Can you reproduce it in your environment ?
Have --verbose log (another run, hit Ctrl-C at ~10+ Gb VSZ) if needed

virtnbdmap: creates big logfile during mapping

The nbdkit plugin currently logs quite some debug messages. Depending on the size of the mapped image, the created nbdkit logfile might grow a few hundred megabytes in size.

Change virtnbdmap to pass debug= flag to the nbdkit call if -v is set. Only log debug messages in the nbdkit plugin if debugging option is set to have a smaller logfile size in default settings.

"Permission denied" in Debian 11 without apparmor (opennebula)

Hi,

I tried using in Debian 11 where AppArmor was removed. I have this error:

libvirt.libvirtError:internal error: could not execute command QEMU "blockdev-add": Could not open '/var/tmp/backup.EAWMR.vda': Permission denied

I saw this error in #7 , but in this case, AppArmor is not present. Any idea?

Implement differential backup option

Sometimes it might be handy to create a differencial backup instead of an incremental, see: #34 for full discussion.
Merged to master, for anyone interested in testing the new feature, feedback welcome.

Restore: --until option does not work with differencial backups

The --unitl option uses the checkpoint from the metadata header to stop processing any further savesets.
This wont work with diff backups or if diff and inc backups are mixed in one directory, because differencial backups set the checkpoint name of the last checkpoint in the metadata header.

Argument type error during checkpoint create XML

Hi!

First of all, thanks for your work! :)

Currently I am using the v0.55.
During some testing in my environment I got some errors, while I was creating a backup:

Traceback (most recent call last):
  File "./virtnbdbackup", line 895, in <module>
    main()
  File "./virtnbdbackup", line 474, in main
    handleCheckpoints(args, virtClient, domObj, lib)
  File "./virtnbdbackup", line 149, in handleCheckpoints
    if virtClient.redefineCheckpoints(domObj, args) is False:
  File "/data/virtnbdbackup_v0.55/libvirtnbdbackup/libvirthelper/libvirthelper.py", line 443, in redefineCheckpoints
    checkpointConfig, libvirt.VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 1267, in checkpointCreateXML
    ret = libvirtmod.virDomainCheckpointCreateXML(self._o, xmlDesc, flags)
TypeError: virDomainCheckpointCreateXML() argument 2 must be str or None, not bytes

After some debugging I found out that in libvirthelper.py line 410 it opens the checkpoint files as binary "rb", but later at lines 442-443, when it calls the libvirt.py's checkpointCreateXML function it's secound argument 'xmlDesc' needs to be a string, or none. After I changed it to simply "r" it works just fine.

I don't know if it was only a problem for me, but I hope it helps.

Keep up the good work!

Dockerfile - python3-lxml

HI Abbbi

Thanks so much for a great project and it's something we are busy testing and may roll it out to all production servers.

When building the Dockerfile on Ubuntu22.04, I had to add the python3-lxml package to the Dockerfile to get it to run

JG

Complete backup Dump to stdout

It is possible to make a full backup and that this is sent stdout instead of a directory
To be able to send it for example to borgbackup

Thanks for you good job!!

Add backup mode "auto"

If backup is executed to a target folder, virtnbdbackup could automatically decide which backup mode to use.

Example:

virtnbdbackup -d domain -l auto -o /tmp/TARGET

  1. if target directory /tmp/TARGET is empty, attempt to create a full backup
  2. if target directory /tmp/TARGET already includes an full backup, switch to backup mode incremental

Thus, an easy rotation would be possible, for example monthly based:

virtnbdbackup -d domain -l auto -o /tmp/2022-06 -> creates full backup
virtnbdbackup -d domain -l auto -o /tmp/2022-06-> creates inc backup
virtnbdbackup -d domain -l auto -o /tmp/2022-06-> creates inc backup
virtnbdbackup -d domain -l auto -o /tmp/2022-07-> creates full backup
virtnbdbackup -d domain -l auto -o /tmp/2022-07-> creates inc backup

new "full" backup / main: operation failed: domain moment virtnbdbackup.1 already exists

Hello,

I tried to start a new full backup in a new directory and even though the full backup worked, I can't seem to be able to create a incremental one on top of the full one :

$ sudo /home/virtu/virtnbdbackup/virtnbdbackup -d ubuntuCI -l inc -o /mnt/backups/ci_20211004 --compress
[2021-10-05 08:43:00] INFO common - printVersion: Version: 0.25 Arguments: /home/virtu/virtnbdbackup/virtnbdbackup -d ubuntuCI -l inc -o /mnt/backups/ci_20211004 --compress
[2021-10-05 08:43:00] INFO virtnbdbackup - main: Store checkpoints in: /mnt/backups/ci_20211004/checkpoints
[2021-10-05 08:43:00] INFO virtnbdbackup - main: Domain has 1 disks attached which support changed block tracking.
[2021-10-05 08:43:00] INFO virtnbdbackup - main: Attempting to redefine checkpoints from: /mnt/backups/ci_20211004/checkpoints
[2021-10-05 08:43:00] INFO libvirthelper - redefineCheckpoints: Loading checkpoint list from: /mnt/backups/ci_20211004/checkpoints
[2021-10-05 08:43:00] INFO virtnbdbackup - main: Looking for checkpoints
[2021-10-05 08:43:00] INFO virtnbdbackup - main: Found checkpoints, next checkpoint id: 1
[2021-10-05 08:43:00] INFO virtnbdbackup - main: Parent checkpoint name virtnbdbackup.0
[2021-10-05 08:43:00] INFO virtnbdbackup - main: Using checkpoint name: virtnbdbackup.1
[2021-10-05 08:43:00] INFO virtnbdbackup - main: Temporary scratch file target directory: /var/tmp
[2021-10-05 08:43:00] INFO virtnbdbackup - main: Starting backup job.
[2021-10-05 08:43:00] WARNING libvirthelper - fsFreeze: Guest agent is not responding: QEMU guest agent is not connected
[2021-10-05 08:43:00] ERROR virtnbdbackup - main: operation failed: domain moment virtnbdbackup.1 already exists
Traceback (most recent call last):
  File "/home/virtu/virtnbdbackup/virtnbdbackup", line 315, in main
    virtClient.startBackup(
  File "/home/virtu/virtnbdbackup/libvirtnbdbackup/libvirthelper/libvirthelper.py", line 262, in startBackup
    domObj.backupBegin(backupXml, checkpointXml)
  File "/usr/lib/python3/dist-packages/libvirt.py", line 704, in backupBegin
    if ret == -1: raise libvirtError ('virDomainBackupBegin() failed', dom=self)
libvirt.libvirtError: operation failed: domain moment virtnbdbackup.1 already exists

The old "bitmaps" seem to be present in the disk image:

$ sudo qemu-img info -f qcow2 -U /data/libvirt/images/cibuild/ubuntu20.04.qcow2
image: /data/libvirt/images/cibuild/ubuntu20.04.qcow2
file format: qcow2
virtual size: 300 GiB (322122547200 bytes)
disk size: 178 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
    bitmaps:
        [0]:
            flags:
                [0]: in-use
            name: virtnbdbackup.2
            granularity: 65536
        [1]:
            flags:
                [0]: in-use
            name: virtnbdbackup.1
            granularity: 65536
        [2]:
            flags:
                [0]: in-use
                [1]: auto
            name: virtnbdbackup.3
            granularity: 65536
        [3]:
            flags:
                [0]: in-use
                [1]: auto
            name: virtnbdbackup.0
            granularity: 65536
    refcount bits: 16
    corrupt: false

I can't seem to be able to delete it (qemu-img on ubuntu LTS does not have the "bitmap" command).

Can you please advise ?
Thanks a lot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.