Backup & Restore
PiVirt provides robust backup and disaster recovery capabilities covering etcd distributed state, VM metadata definitions, and underlying block storage volumes.
Cluster State Backup
Section titled “Cluster State Backup”etcd Backup
Section titled “etcd Backup”# Manual backuppvcli cluster backup create --name backup-2024-01-15
# Automated backup (cron)0 2 * * * pvcli cluster backup create --name "backup-$(date +\%Y-\%m-\%d)" --retention 7dBackup Contents
Section titled “Backup Contents”- etcd cluster state
- VM definitions
- Network configurations
- Storage pool configurations
- RBAC policies
Restore Cluster
Section titled “Restore Cluster”# List available backupspvcli cluster backup list
# Restore from backuppvcli cluster backup restore --name backup-2024-01-15
# Restore to specific pointpvcli cluster backup restore --name backup-2024-01-15 --forceVM Backup
Section titled “VM Backup”Snapshot Backup
Section titled “Snapshot Backup”# Create VM snapshotpvcli vm snapshot create web-01 --name "backup-before-update"
# List snapshotspvcli vm snapshot list web-01
# Restore from snapshotpvcli vm snapshot restore web-01 --name "backup-before-update"Full VM Backup
Section titled “Full VM Backup”# Backup VM to external storagepvcli vm backup create web-01 \ --destination s3://backups.pilab.hu/vms/ \ --name "web-01-backup-2024-01-15"
# Restore VM from backuppvcli vm backup restore \ --source s3://backups.pilab.hu/vms/web-01-backup-2024-01-15 \ --name web-01-restoredStorage Volume Backup
Section titled “Storage Volume Backup”Volume Snapshot
Section titled “Volume Snapshot”# Create volume snapshotpvcli storage snapshot create --volume data-01 --name "data-01-backup"
# List snapshotspvcli storage snapshot list --volume data-01
# Restore from snapshotpvcli storage snapshot restore --volume data-01 --name "data-01-backup"Volume Backup to External Storage
Section titled “Volume Backup to External Storage”# Backup volumepvcli storage volume backup create data-01 \ --destination s3://backups.pilab.hu/volumes/ \ --name "data-01-backup-2024-01-15"
# Restore volumepvcli storage volume backup restore \ --source s3://backups.pilab.hu/volumes/data-01-backup-2024-01-15 \ --name data-01-restoredBackup Strategies
Section titled “Backup Strategies”Incremental Backups
Section titled “Incremental Backups”apiVersion: pivirt.pilab.hu/v1kind: BackupPolicymetadata: name: daily-incrementalspec: schedule: "0 2 * * *" type: "incremental" retention: daily: 7 weekly: 4 monthly: 12 targets: - type: "vm" selector: namespace: "production" - type: "volume" selector: pool: "default"Full Backups
Section titled “Full Backups”apiVersion: pivirt.pilab.hu/v1kind: BackupPolicymetadata: name: weekly-fullspec: schedule: "0 3 * * 0" type: "full" retention: weekly: 4 monthly: 12 targets: - type: "cluster" - type: "vm" selector: namespace: "production"Backup Destinations
Section titled “Backup Destinations”Local Storage
Section titled “Local Storage”spec: destination: type: "local" path: "/var/backups/pivirt"S3-Compatible Storage
Section titled “S3-Compatible Storage”spec: destination: type: "s3" endpoint: "https://s3.pilab.hu" bucket: "pivirt-backups" region: "eu-central-1" credentials_ref: "vault:secret/data/s3/backup#credentials"spec: destination: type: "nfs" server: "nas.pilab.hu" export: "/exports/backups/pivirt" mount_options: "rw,noatime,hard,intr"Backup Verification
Section titled “Backup Verification”# Verify backup integritypvcli cluster backup verify --name backup-2024-01-15
# Test restore to isolated environmentpvcli cluster backup test-restore --name backup-2024-01-15 --namespace test-restoreTroubleshooting
Section titled “Troubleshooting”Backup Failures
Section titled “Backup Failures”# Check backup statuspvcli cluster backup get backup-2024-01-15 -o yaml
# View backup logspvcli cluster backup logs backup-2024-01-15Common Issues
Section titled “Common Issues”| Issue | Resolution |
|---|---|
| Backup timeout | Increase timeout, check network connectivity |
| Insufficient space | Clean up old backups, increase storage |
| Permission denied | Verify credentials, check destination permissions |
| Corrupted backup | Verify checksum, restore from previous backup |