Back to Help and Info

Backup and Restore Commands

This section provides commands for backing up and restoring virtual machines and containers in Proxmox VE. Learn how to create backups, restore from backups, manage backup storage, and schedule automated backups.

VM Backup

CommandDescriptionAction
vzdump <vmid>Create a backup of a specific VM/CT
vzdump <vmid> --storage <storage>Backup VM to specific storage
vzdump <vmid> --mode snapshotCreate snapshot backup (for VMs)
vzdump <vmid> --mode suspendSuspend VM during backup
vzdump <vmid> --mode stopStop VM during backup
vzdump --allBackup all VMs and containers
vzdump --exclude <vmid1>,<vmid2>Backup all except specified VMs

Backup Options

CommandDescriptionAction
vzdump <vmid> --compress zstdUse zstd compression for backup
vzdump <vmid> --pigz <threads>Use pigz with multiple threads
vzdump <vmid> --notes <text>Add notes to backup
vzdump <vmid> --mailto <email>Send notification email
vzdump <vmid> --maxfiles <n>Keep only n backups per VM
vzdump <vmid> --stdexcludes 0Don't exclude temporary files
vzdump <vmid> --quiet 1Suppress output messages

Restore Backups

CommandDescriptionAction
qmrestore <backup-file> <vmid>Restore VM from backup
qmrestore <backup-file> <vmid> --storage <storage>Restore to specific storage
qmrestore <backup-file> <vmid> --uniqueCreate a VM with unique ID
pct restore <vmid> <backup-file>Restore container from backup
pct restore <vmid> <backup-file> --storage <storage>Restore container to specific storage
pct restore <vmid> <backup-file> --rootfs <storage>Restore to specific rootfs
pct restore <vmid> <backup-file> --unprivileged 1Restore as unprivileged CT

Backup Management

CommandDescriptionAction
ls -la /var/lib/vz/dump/List backups in default location
find /var/lib/vz/dump/ -name "*.vma*"Find VM backups
find /var/lib/vz/dump/ -name "*.tar*"Find container backups
pvesm list <storage>List backups in specific storage
rm /var/lib/vz/dump/<backup-file>Delete a backup file
cat /etc/vzdump.confShow backup configuration

Scheduled Backups

CommandDescriptionAction
cat /etc/cron.d/vzdumpShow backup schedule
nano /etc/vzdump.confEdit backup configuration
systemctl list-timersList all scheduled tasks
systemctl status cronCheck cron service status
grep vzdump /var/log/syslogCheck backup logs in syslog
tail -f /var/log/vzdump.logMonitor backup log in real-time

Advanced Operations

CommandDescriptionAction
qmrestore <backup> <vmid> --forceForce restore, overwriting existing VM
vzdump <vmid> --dumpdir <directory>Specify custom backup directory
vzdump <vmid> --script <script>Run hook script during backup
vzdump <vmid> --exclude-path <path>Exclude specific paths from backup
vzdump <vmid> --ionice <priority>Set I/O priority for backup process
vzdump <vmid> --lockwait <minutes>Wait for lock
qm importdisk <vmid> <backup> <storage>Import disk from backup

Backup Best Practices

  • Replace <vmid> with your VM or container ID
  • Replace <storage> with your storage name
  • Replace <backup-file> with the path to your backup file
  • Schedule regular backups during off-peak hours to minimize impact on production workloads
  • Store backups on a separate storage device or location for better disaster recovery protection
  • Test your backups regularly by performing test restores to ensure they are working correctly
  • Use --maxfiles to implement backup rotation and prevent storage from filling up
  • Consider using --compress zstd for better compression ratio and performance