
This article is created to provide guidance when doing VM Migration from One Proxmox Node to Another. One major need for migrating a virtual machine between proxmox servers is old servers decommissioning or balancing the VMs workloads distribution across hypervisor nodes. A Virtual Machine can also be migrated in disaster recovery scenarios.
The tool that will be used in this article is Vzdump. This is a utility available in every Proxmox server installation, and it allows you to create consistent snapshots of running virtual machines in a tar archive. This archive will contain VM configuration files. We will demonstrate how to use the vzdump command line tool to export a virtual machine as backup archive, moving generated file to a different PVE host, importing, and running the instance on the new host.
Essentially, imigrating a virtual machine from one Proxmox server to another can be achieved by following 3 actions:
- Backup Proxmox Virtual Machine using vzdump
- Move the generated VM backup archive to the new server
- Restore the VM from Backup archive on the new Proxmox Server
1 – Backup Proxmox Virtual Machine using vzdump
The basic usage of vzdump
utility is simple dump of guest operating system without snapshot. This process simply archives the guest’s private data and configuration files to the default dump directory, typically located at /var/lib/vz/dump/.
The command usage syntax is:
vzdump <VMID> <OPTIONS>
Available options that can be used with the utility:
<vmid>
The ID of the guest system you want to backup.--compress <0 | 1 | gzip | lzo | zstd>
Compress dump file.--dumpdir <string>
Store resulting files to specified directory.
List running Virtual Machines on host 1:
# qm list
VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID
101 AD-Server-2022 stopped 8192 100.00 0
102 pfsense stopped 4096 32.00 0
104 Ubuntu-22-Desktop running 16384 50.00 1231
For containers:
pct list
Backup the Virtual Machine by executing the following commands:
vzdump --compress <VMID>
vzdump --compress <ContainerID>
During backup process, compression of the file can be done with one of the following algorithms: lzo, gzip, or zstd. If you don’t specify backup algorithm the default is lzo.
vzdump --compress gzip <VMID>
Resulting file extensions from compression
- .zst: For Zstandard (zstd) compression
- .gz or .tgz: For gzip compression
- .lzo: For lzo compression
You can also specify the directory where the backups are to be saved.
vzdump --compress gzip <VMID> --dumpdir /home/backups
For Container:
vzdump --compress gzip <ContainerID> --dumpdir /home/backups
As a valid example given the virtual machines listed above, in order to move the Ubuntu desktop VM we would first back it up (in this example to a specific folder) by running the following commands:
mkdir /home/backups
vzdump --compress gzip 101 --dumpdir /home/backups
The backup file will be located in the backup directory we created:
# ls /home/backups/
vzdump-qemu-104-2024_12_06-21_28_43.log vzdump-qemu-104-2024_12_06-21_28_43.vma.gz
2 – Move the generated VM backup archive to the new Proxmox server
After backup file is generated, use scp or rsync to migrate the file to a destination compute host for restoration.
scp /home/backups/vzdump-qemu-104-2024_12_06-21_28_43.vma.gz root@PVE2IP:/var/lib/vz/dump/
Where;
- /home/backups/vzdump-qemu-104-2024_12_06-21_28_43.vma.gz is the path to VM backup
- PVE2IP is to be replaced with actual IP address of destination Proxmox server
- We’re copying the backup to the /var/lib/vz/dump/ in the destination server
3 – Restore the VM from Backup archive on the new Proxmox Server
Use the qmrestore
command to restore the virtual machine from QemuServer vzdump Backups.
qmrestore <archive> <vmid> [OPTIONS]
Restore QemuServer vzdump backups.
<archive>: <string>
The backup file. You can pass - to read from standard input.
<vmid>: <integer> (100 - 999999999)
The (unique) ID of the VM.
--bwlimit <number> (0 - N)
Override I/O bandwidth limit (in KiB/s).
--force <boolean>
Allow to overwrite existing VM.
--live-restore <boolean>
Start the VM immediately from the backup and restore in background. PBS only.
--pool <string>
Add the VM to the specified pool.
--storage <string>
Default storage.
--unique <boolean>
Assign a unique random ethernet address.
Make sure the VM is in stopped state:
qm stop <VMID>
To stop container use:
pct stop <ContainerID>
For our example, to restore our backup from file and VM ID 601, we would run on the new Proxmox server:
qmrestore /var/lib/vz/dump/vzdump-qemu-104-2024_12_06-21_28_43.vma.gz 601
To get a list of available storage pools, run the following command:
root@pve02:~# pvesm status
Name Type Status Total Used Available %
local dir active 100597760 11813608 88784152 11.74%
local-lvm lvmthin active 365760512 7790698 357969813 2.13%
A storage pool can be specified using --storage
.
Example of restoring to local-zfs
instead of local-lvm
:
qmrestore --storage local-zfs /var/lib/vz/dump/vzdump-qemu-104-2024_12_06-21_28_43.vma.lzo 601
Example of Restoring an LXC Container:
pct restore <NEWID> zdump-lxc-104-2024_01_17-00_38_15.tar.gz
# Specifying storage pool
pct restore --storage local-zfs<NEWID> zdump-lxc-104-2024_01_17-00_38_15.tar.gz
Use the qm
command to list virtual machines on the destination server.
# qm list
VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID
100 pfsense running 16384 32.00 3638583
102 Fedora-39 running 2048 32.00 460944
103 WinServer-2019 running 8192 50.00 3226348
104 WinServer-2022 running 8192 50.00 3229915
198 Ubuntu-Bionic running 8192 30.00 1248387
199 workstation running 8192 30.00 3671877
201 k8smaster1 running 8192 50.00 20651
211 k8sworker1 running 16384 30.00 21307
212 k8sworker2 running 16384 30.00 21357
213 k8sworker3 running 16384 30.00 21428
601 Ubuntu-22-Desktop stopped 16384 50.00 0
Start the VM after complete migration.
qm start <VMID>
If your virtual machine had a static IP address configured, and the networking configuration differs on the new host, you’ll need to log into the instance and assign an IP address.