๐ธ VM Snapshots & Backup System
Zorvia's VM Snapshots & Backup System provides production-grade snapshot management for disaster recovery and VM lifecycle management.
Requires PVC/DataVolume-backed disks. A snapshot is a real KubeVirt
VirtualMachineSnapshot, which only captures volumes backed by aPersistentVolumeClaimorDataVolume. A VM whose disks are allcontainerDisk/emptyDisk/cloud-init (no PVC anywhere) still gets a snapshot that reportsSucceeded, but it captured only the VM's spec โ zero disk data, nothing to restore from disk. The web console and API flag this with awarningfield on the affected backup/snapshot; the CLI does not surface it yet, so checkkubectl get virtualmachinesnapshot <name> -o jsonpath='{.status.snapshotVolumes}'if a CLI-created snapshot looks suspiciously fast or small.
๐ฏ Featuresโ
โ Create Snapshots - Capture VM state at any point in time โ List & Browse - View all snapshots with detailed status โ Restore Operations - Restore to new VM or in-place โ Retention Policies - Automatic snapshot cleanup โ Health Monitoring - Track snapshot status and readiness โ Themed CLI - Beautiful colored output with status symbols
๐ Quick Startโ
Create a Snapshotโ
# Create snapshot with auto-generated name
zorvia snapshot-create my-vm
# Create snapshot with custom name
zorvia snapshot-create my-vm --name pre-upgrade-backup
# Create snapshot with description
zorvia snapshot-create my-vm \
--name before-update \
--description "Before OS upgrade to Ubuntu 24.04"
๐ List Snapshotsโ
# List all snapshots in namespace
zorvia snapshot-list
# List snapshots for specific VM
zorvia snapshot-list my-vm
# List in different formats
zorvia snapshot-list --output yaml
zorvia snapshot-list --output json
๐ Get Snapshot Detailsโ
# Get snapshot details (YAML format)
zorvia snapshot-get my-snapshot
# Get details in JSON format
zorvia snapshot-get my-snapshot --output json
๐ Restore from Snapshotโ
# Restore to new VM
zorvia snapshot-restore my-snapshot --target restored-vm
# Restore and start immediately
zorvia snapshot-restore my-snapshot --target restored-vm --start
# Restore in-place (overwrite existing VM)
zorvia snapshot-restore my-snapshot --in-place
# Restore in-place with custom target
zorvia snapshot-restore my-snapshot --target my-vm --in-place
๐๏ธ Delete Snapshotโ
# Delete snapshot (with confirmation)
zorvia snapshot-delete old-snapshot
# Delete snapshot (skip confirmation)
zorvia snapshot-delete old-snapshot --yes
๐ Command Referenceโ
zorvia snapshot-createโ
Create a VM snapshot.
Options:
<VM>- VM name (required)--name, -n <NAME>- Snapshot name (optional, auto-generated if not provided)--description, -d <DESC>- Description of the snapshot
Examples:
zorvia snapshot-create prod-db --name daily-backup
zorvia snapshot-create web-server --description "Before deployment"
zorvia snapshot-listโ
List snapshots.
Options:
[VM]- VM name (optional, shows all snapshots if not provided)--all-namespaces, -A- Show snapshots from all namespaces--output, -o <FORMAT>- Output format (table, yaml, json)
Examples:
zorvia snapshot-list # All snapshots
zorvia snapshot-list prod-db # Snapshots for prod-db
zorvia snapshot-list -A # All namespaces
zorvia snapshot-list --output json # JSON format
zorvia snapshot-getโ
Show detailed snapshot information.
Options:
<NAME>- Snapshot name (required)--output, -o <FORMAT>- Output format (yaml, json)
Examples:
zorvia snapshot-get my-snapshot
zorvia snapshot-get my-snapshot --output json
zorvia snapshot-deleteโ
Delete a snapshot.
Options:
<NAME>- Snapshot name (required)--yes, -y- Skip confirmation prompt
Examples:
zorvia snapshot-delete old-snapshot
zorvia snapshot-delete old-snapshot --yes
zorvia snapshot-restoreโ
Restore VM from snapshot.
Options:
<SNAPSHOT>- Snapshot name (required)--target, -t <VM>- Target VM name (optional, defaults to<snapshot>-restored)--in-place- Restore in-place (overwrite existing VM)--start- Start VM after restore
Examples:
zorvia snapshot-restore backup-20260205 --target restored-vm
zorvia snapshot-restore backup-20260205 --in-place
zorvia snapshot-restore backup-20260205 --target new-vm --start
๐ก Usage Examplesโ
Example 1: Daily Backup Workflowโ
# Create daily snapshot
zorvia snapshot-create prod-db \
--name "prod-db-daily-$(date +%Y%m%d)" \
--description "Daily backup"
# List recent snapshots
zorvia snapshot-list prod-db
# Verify snapshot is ready
zorvia snapshot-get prod-db-daily-20260205
Example 2: Pre-Deployment Backupโ
# Create snapshot before deployment
zorvia snapshot-create web-server \
--name pre-deploy-v2.0 \
--description "Before v2.0 deployment"
# Deploy new version
# ... deploy your application ...
# If deployment fails, restore
zorvia snapshot-restore pre-deploy-v2.0 \
--target web-server \
--in-place \
--start
Example 3: Test Environment Cloningโ
# Create snapshot of production
zorvia snapshot-create prod-db --name prod-snapshot
# Restore to new VM for testing
zorvia snapshot-restore prod-snapshot \
--target test-db \
--start
# Verify test VM
zorvia status test-db
Example 4: Disaster Recoveryโ
# List available snapshots
zorvia snapshot-list prod-db
# Check snapshot details
zorvia snapshot-get prod-db-daily-20260204
# Restore to recover
zorvia snapshot-restore prod-db-daily-20260204 \
--target prod-db-recovered \
--start
# Verify recovered VM
zorvia health prod-db-recovered
๐ Output Examplesโ
Snapshot List (Table Format)โ
All Snapshots in namespace: default
NAME VM STATUS SIZE AGE
----------------------------------------------------------------------------------
prod-db-daily-20260205 prod-db Running 15Gi 2h0m
prod-db-daily-20260204 prod-db Running 15Gi 1d2h
web-server-pre-deploy web-server Pending - 30m
test-db-backup test-db Running 8Gi 5d
Snapshot Details (Formatted)โ
Snapshot: prod-db-daily-20260205
VM: prod-db
Namespace: default
Status: โ READY
Description: Daily backup
Size: 15Gi
Age: 2h30m
Duration: 3m45s
Ready: Yes
Snapshot Creationโ
Creating snapshot for VM: prod-db
Snapshot name: prod-db-snapshot-20260205-140530
Description: Daily backup
โ Snapshot creation started
Status: InProgress
โน Check snapshot status with:
zorvia snapshot-get prod-db-snapshot-20260205-140530
Snapshot Restoreโ
Restoring snapshot to new VM: prod-db-recovered
Snapshot: prod-db-daily-20260204
Target VM: prod-db-recovered
Start: Yes
โ Restore started
Restore name: prod-db-recovered-restore
Status: InProgress
โน VM will be started after restore completes
๐ง Advanced Featuresโ
Retention Policiesโ
Snapshots support retention policies to automatically manage snapshot lifecycle:
use zorvia::snapshots::{RetentionPolicy, SnapshotConfig};
let mut config = SnapshotConfig::new("my-vm", "snapshot-name");
config.retention = RetentionPolicy {
max_snapshots: Some(10), // Keep max 10 snapshots
max_age_days: Some(30), // Delete snapshots older than 30 days
keep_last_n: Some(5), // Always keep last 5 snapshots
};
Snapshot Labelsโ
Add custom labels to snapshots for organization:
use zorvia::snapshots::SnapshotConfig;
let config = SnapshotConfig::new("my-vm", "snapshot-name")
.with_label("env", "production")
.with_label("backup-type", "daily")
.with_label("app", "database");
Programmatic Usageโ
Use snapshots in your Rust applications:
use zorvia::snapshots::{SnapshotManager, SnapshotConfig};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let manager = SnapshotManager::new("default");
// Create snapshot
let config = SnapshotConfig::new("my-vm", "backup-20260205")
.with_description("Automated backup");
let snapshot = manager.create_snapshot(&config).await?;
println!("Snapshot created: {}", snapshot.name);
// List snapshots
let snapshots = manager.list_snapshots_for_vm("my-vm").await?;
for snap in snapshots {
println!(" - {} ({}) - {}", snap.name, snap.status, snap.age());
}
Ok(())
}
๐ Integration with Other Featuresโ
With Health Checksโ
# Create snapshot
zorvia snapshot-create my-vm --name pre-update
# Check VM health before restore
zorvia health my-vm
# Restore if needed
zorvia snapshot-restore pre-update --in-place
With Profilesโ
# Create VM with profile
zorvia create my-vm --template ubuntu-22.04 --profile database
# Create snapshot
zorvia snapshot-create my-vm --name initial-state
# Restore maintains the same resource configuration
zorvia snapshot-restore initial-state --target my-vm-copy
With Blueprintsโ
# Deploy blueprint
zorvia deploy lamp --prefix prod
# Snapshot all VMs in the stack
zorvia snapshot-create prod-mysql-db --name lamp-backup-db
zorvia snapshot-create prod-web-server --name lamp-backup-web
# Restore entire stack if needed
zorvia snapshot-restore lamp-backup-db --in-place
zorvia snapshot-restore lamp-backup-web --in-place
๐จ Status Symbolsโ
Snapshots use color-coded status symbols for quick visual feedback:
- โ Green = Ready/Succeeded
- โ Yellow = In Progress
- โ Red = Failed
- ? Gray = Unknown
๐งช Testingโ
All snapshot features include comprehensive tests:
# Test snapshot module
cargo test --lib snapshots
# Test specific functionality
cargo test --lib snapshots::manager::tests
cargo test --lib snapshots::restore::tests
cargo test --lib snapshots::types::tests
Test Results:
running 16 tests
test snapshots::manager::tests::test_create_snapshot ... ok
test snapshots::manager::tests::test_list_snapshots_for_vm ... ok
test snapshots::manager::tests::test_list_all_snapshots ... ok
test snapshots::manager::tests::test_get_snapshot ... ok
test snapshots::manager::tests::test_is_snapshot_ready ... ok
test snapshots::restore::tests::test_restore_to_new_vm ... ok
test snapshots::restore::tests::test_restore_in_place ... ok
test snapshots::restore::tests::test_get_restore_status ... ok
test snapshots::restore::tests::test_list_restores ... ok
test snapshots::restore::tests::test_validate_snapshot ... ok
test snapshots::restore::tests::test_estimate_restore_time ... ok
test snapshots::types::tests::test_snapshot_info_creation ... ok
test snapshots::types::tests::test_restore_info_creation ... ok
test snapshots::types::tests::test_snapshot_status_display ... ok
test snapshots::tests::test_snapshot_config ... ok
test snapshots::tests::test_default_retention_policy ... ok
test result: ok. 16 passed; 0 failed
Retention (shipped)โ
Retention policies are modeled in src/snapshots/retention.rs and applied when snapshot configs include a RetentionPolicy (max count / age). Operators can also delete snapshots explicitly via CLI and the web console.
Future Enhancementsโ
Still open for future releases:
- Scheduled snapshots (cron-like)
- Snapshot chains visualization
- Incremental snapshot support
- Snapshot encryption
- Cross-namespace snapshots
- Snapshot import/export
- Snapshot size prediction
- Multi-VM snapshot coordination
๐ Related Documentationโ
- INNOVATIVE_FEATURES.md - All innovative features
- OS_TEMPLATES.md - OS template catalog
- QUICK_REFERENCE.md - Quick reference card
- README.md - Main documentation
๐ Summaryโ
Zorvia's VM Snapshots & Backup System provides:
โ 5 CLI commands for comprehensive snapshot management โ 16 unit tests ensuring reliability โ Production-ready disaster recovery capabilities โ Beautiful CLI with themed colored output โ Flexible restore options (new VM or in-place) โ Automatic snapshot naming and metadata โ Integration with existing Zorvia features
Critical for production environments - No other KubeVirt CLI offers this level of snapshot management! ๐