Skip to content

Backup & Restore

PiVirt provides robust backup and disaster recovery capabilities covering etcd distributed state, VM metadata definitions, and underlying block storage volumes.

Terminal window
# Manual backup
pvcli cluster backup create --name backup-2024-01-15
# Automated backup (cron)
0 2 * * * pvcli cluster backup create --name "backup-$(date +\%Y-\%m-\%d)" --retention 7d
  • etcd cluster state
  • VM definitions
  • Network configurations
  • Storage pool configurations
  • RBAC policies
Terminal window
# List available backups
pvcli cluster backup list
# Restore from backup
pvcli cluster backup restore --name backup-2024-01-15
# Restore to specific point
pvcli cluster backup restore --name backup-2024-01-15 --force
Terminal window
# Create VM snapshot
pvcli vm snapshot create web-01 --name "backup-before-update"
# List snapshots
pvcli vm snapshot list web-01
# Restore from snapshot
pvcli vm snapshot restore web-01 --name "backup-before-update"
Terminal window
# Backup VM to external storage
pvcli vm backup create web-01 \
--destination s3://backups.pilab.hu/vms/ \
--name "web-01-backup-2024-01-15"
# Restore VM from backup
pvcli vm backup restore \
--source s3://backups.pilab.hu/vms/web-01-backup-2024-01-15 \
--name web-01-restored
Terminal window
# Create volume snapshot
pvcli storage snapshot create --volume data-01 --name "data-01-backup"
# List snapshots
pvcli storage snapshot list --volume data-01
# Restore from snapshot
pvcli storage snapshot restore --volume data-01 --name "data-01-backup"
Terminal window
# Backup volume
pvcli storage volume backup create data-01 \
--destination s3://backups.pilab.hu/volumes/ \
--name "data-01-backup-2024-01-15"
# Restore volume
pvcli storage volume backup restore \
--source s3://backups.pilab.hu/volumes/data-01-backup-2024-01-15 \
--name data-01-restored
apiVersion: pivirt.pilab.hu/v1
kind: BackupPolicy
metadata:
name: daily-incremental
spec:
schedule: "0 2 * * *"
type: "incremental"
retention:
daily: 7
weekly: 4
monthly: 12
targets:
- type: "vm"
selector:
namespace: "production"
- type: "volume"
selector:
pool: "default"
apiVersion: pivirt.pilab.hu/v1
kind: BackupPolicy
metadata:
name: weekly-full
spec:
schedule: "0 3 * * 0"
type: "full"
retention:
weekly: 4
monthly: 12
targets:
- type: "cluster"
- type: "vm"
selector:
namespace: "production"
spec:
destination:
type: "local"
path: "/var/backups/pivirt"
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"
Terminal window
# Verify backup integrity
pvcli cluster backup verify --name backup-2024-01-15
# Test restore to isolated environment
pvcli cluster backup test-restore --name backup-2024-01-15 --namespace test-restore
Terminal window
# Check backup status
pvcli cluster backup get backup-2024-01-15 -o yaml
# View backup logs
pvcli cluster backup logs backup-2024-01-15
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