Site Replication and Disaster Recovery (DR)
Cockpit provides hypervisor-level disaster recovery through active-passive virtual machine replication. This enables workloads running at a primary datacenter (Site A) to replicate block storage devices asynchronously to a secondary disaster recovery site (Site B) over a WAN or secondary network.
1. Architectural Design
Replication is coordinated by Cockpit but executes directly peer-to-peer between physical virtualization hosts (Vapor daemons) to optimize network throughput and reduce management plane bottlenecking.
- Data Transfer Protocol: Files and incremental block delta patches are streamed over secure TLS using the TUS (Resumable Upload) Protocol (
PATCHHTTP requests). - Asynchronous Storage Snapshots: Uses QCOW2 backing chains to transfer blocks without disrupting active virtual machines.
2. Replication Mechanism
Replication runs in a two-stage process using snapshot layers:
Phase 1: Baseline Sync (Full Copy)
- Cockpit instructs the Source Vapor host to create a full backup.
- The hypervisor freezes the guest filesystem temporarily (via the QEMU Guest Agent) and runs
qemu-img convertto stream the disk volume. - Cockpit registers the upload session on the Target Vapor host.
- The Source Vapor streams the base
.qcow2file block-by-block using the TUS protocol. - The Target Vapor registers the baseline disk image.
Phase 2: Incremental Sync (RPO-driven)
- At the configured Recovery Point Objective (RPO) interval (e.g., 15 minutes), Cockpit triggers an incremental sync.
- The Source Vapor locks QEMU, creates a new overlay file, and runs
qemu-img convertreferencing the parent snapshot:bashqemu-img convert -O qcow2 -o backing_file=parent.qcow2,backing_fmt=qcow2 source.qcow2 delta.qcow2 - Source Vapor streams only the
delta.qcow2patch file via TUS patch requests to the target host. - Target Vapor writes the delta block patch into the replication backing chain, creating a Point-in-Time (PIT) recovery state.
3. Configuration Steps
3.1 Link Site Pairs
Before enrolling workloads, administrators must pair the Cockpit sites:
- Log in to the target (DR) Cockpit instance and extract the active authorization token (from
cockpit:authin local storage). - Log in to the primary Cockpit instance, navigate to Configure -> Site Pairs, and click Link Site Pair.
- Input the remote site name, endpoint API URL (e.g.,
https://192.168.122.128:7771/api/v1), token, and optional TLS certificates.
3.2 Enroll Virtual Machines
- Select the target VM in the inventory tree and navigate to the Replication tab.
- Configure the replication policy:
- Target Site: Select the paired DR site.
- Target Datastore: Select the storage pool at the DR site.
- RPO (Recovery Point Objective): Select synchronization intervals (
15 Minutes,30 Minutes,1 Hour,4 Hours, or24 Hours). - PIT Snapshots: The maximum number of historical checkpoints to retain on the DR site (Multiple Point-in-Time count).
- Data Compression: Option to compress the disk stream during transit to optimize WAN bandwidth.
- Click Enable Replication to trigger the baseline synchronization.
4. Disaster Recovery Workflows
Administrators initiate recovery and validation procedures from the ACTIONS ▾ menu of the VM's Replication status panel:
4.1 Test Failover (Disaster Recovery Drills)
To verify recovery viability without disrupting the production VM or stopping replication:
- Select Test Failover and click Start Drill.
- Backend Action: Cockpit clones the target replica storage from the latest PIT snapshot, creates a temporary VM instance, and boots it inside an isolated host network (bubble network).
- Verify the VM's guest OS services via the console.
- Select Stop Test Failover to power off the sandbox VM and delete the temporary clones from the DR storage pool.
4.2 Planned Migration (Graceful Switchover)
Used to permanently relocate workloads during scheduled maintenance:
- Select Planned Migration and click Start Migration.
- Backend Action:
- The primary VM is gracefully powered off.
- A final catch-up replication sync executes to transfer any remaining dirty blocks.
- The VM registration is deleted from the primary host, and the VM is registered and booted on the DR host.
4.3 Emergency Failover (Unplanned Outage)
Used when the primary datacenter is offline due to disaster:
- Select Emergency Failover and click Emergency Failover.
- Backend Action: Cockpit skips primary VM shutdown and final synchronization. It registers the VM on the DR host immediately using the last successfully synced PIT snapshot and powers the VM on.