Why full copies don't work
If you want disaster recovery on KVM (oVirt, RHV, OLVM or Proxmox VE) that can take you back to a point only seconds or minutes ago, you cannot copy every disk in full each time. The copy would take longer than the gap you are trying to protect.
The piece that makes it work is changed block tracking (CBT). This post explains how CBT works on KVM and how a near sync replica is built from it.
1. How it works: the dirty bitmap
A virtual disk is a set of fixed size blocks. CBT keeps a dirty bitmap that records which blocks have been written since a chosen point.
On KVM this tracking lives in QEMU on the hypervisor, not inside the guest. So you don't need an agent in each VM.
Each cycle is simple:
- read the bitmap to learn which blocks changed
- read only those regions
- send them to the DR site
- reset the bitmap and start tracking the next interval
Data that hasn't changed is never read or sent again.
2. Compared with full copies
| Periodic full or image copy | Changed block deltas | |
|---|---|---|
| Data moved per cycle | The whole disk | Only blocks changed since the last cycle |
| What drives the cost | Total capacity | How much the workload writes |
| Achievable RPO | Hours | Seconds to minutes |
| Impact on the guest | Agent in the guest, or a full read | No agent, changed blocks only |
Moving from "copy everything" to "track and send only what changed" is what makes a recent recovery copy affordable on ordinary hardware.
3. Why track changes in the hypervisor
Tracking writes in QEMU rather than with an agent inside the guest has two advantages:
- It doesn't depend on the OS. Linux and Windows guests are protected the same way, with no software to install in each guest, nothing to patch, and nothing to break on a kernel update.
- It catches every write at block level. Anything that touches the disk is recorded, not only what a file aware agent decides to watch.
4. The replication cycle
A near sync replica is built by running CBT cycles at short intervals. A robust implementation runs each cycle in this order:
- Mark: create or update a dirty bitmap on every protected disk.
- Export: expose the changed regions through a block interface such as NBD.
- Capture: read only the changed ranges as a delta.
- Apply: write the delta to the matching replica disk through a safe path.
- Record: log the cycle in a journal, which gives you recovery points to keep.
In QEMU terms, marking is a QMP command, and an NBD export can publish the bitmap so a client can ask which ranges are dirty:
{ "execute": "block-dirty-bitmap-add", "arguments": { "node": "drive-scsi0", "name": "cbt-1" } } # list the dirty extents of an NBD export that publishes the bitmap nbdinfo --map=qemu:dirty-bitmap:cbt-1 nbd://dr-host/drive-scsi0 5. Crash consistency across disks
An application spread over several disks, or several VMs, has to be captured as one unit. Put the related disks in a consistency group and mark their bitmaps in one atomic operation. Every recovery point is then crash consistent across the whole application: the same guarantee as cutting power to all its disks at the same instant.
QEMU supports this with a transaction, which applies all the actions together or none of them:
{ "execute": "transaction", "arguments": { "actions": [ { "type": "block-dirty-bitmap-add", "data": { "node": "drive-scsi0", "name": "cbt-1" } }, { "type": "block-dirty-bitmap-add", "data": { "node": "drive-scsi1", "name": "cbt-1" } } ] } } Summary
- CBT on KVM records changed blocks in QEMU dirty bitmaps, so guests need no agent.
- The data moved depends on how much changes, not on disk size, which makes short cycles and an RPO of seconds to minutes realistic.
- Multi disk applications stay crash consistent when their bitmaps are marked together in one consistency group.
We build KVMDR, near sync DR for KVM. If you run Proxmox VE, oVirt or OLVM at home, there's a free homelab licence at kvmdr.ai/community.