Categories
SysOps

How to copy Proxmox virtual machine to another server

Copy Proxmox virtual machine to another server.

List virtual machines.

basilisk:~$ qm list
      VMID NAME                   STATUS     MEM(MB)    BOOTDISK(GB) PID       
     10001 ubuntu-jammy-jellyfish running    2048              20.00 714306  qm info 1 

Display virtual machine configuration.

basilisk:~$ qm config 10001
boot: order=scsi0;ide2;net0
cores: 2
ide2: none,media=cdrom
memory: 2048
meta: creation-qemu=6.2.0,ctime=1656270900
name: ubuntu-jammy-jellyfish
net0: virtio=6A:1D:86:B4:CF:43,bridge=vmbr0,firewall=1
numa: 0
ostype: l26
scsi0: local-lvm:vm-10001-disk-0,cache=writethrough,iothread=1,replicate=0,size=20G,ssd=1
scsihw: virtio-scsi-single
smbios1: uuid=a85af7d3-4a02-4a82-b612-9271c1de907f
sockets: 1
vga: std
vmgenid: 675763b6-d75e-40fc-919b-5e932aca8407

Stop virtual machine.

basilisk:~$ qm stop 10001

Create compressed backup.

basilisk:~$ vzdump 10001 --compress zstd
INFO: starting new backup job: vzdump 10001 --compress zstd
INFO: Starting Backup of VM 10001 (qemu)
INFO: Backup started at 2022-07-13 22:23:48
INFO: status = stopped
INFO: backup mode: stop
INFO: ionice priority: 7
INFO: VM Name: ubuntu-jammy-jellyfish
INFO: include disk 'scsi0' 'local-lvm:vm-10001-disk-0' 20G
INFO: creating vzdump archive '/var/lib/vz/dump/vzdump-qemu-10001-2022_07_13-22_23_48.vma.zst'
INFO: starting kvm to execute backup task
INFO: started backup task '9b70f2d1-1be0-4811-ba11-b676d5f595fa'
INFO:  10% (2.0 GiB of 20.0 GiB) in 3s, read: 682.7 MiB/s, write: 156.2 MiB/s
INFO:  12% (2.6 GiB of 20.0 GiB) in 6s, read: 203.0 MiB/s, write: 146.2 MiB/s
INFO:  15% (3.1 GiB of 20.0 GiB) in 9s, read: 174.0 MiB/s, write: 170.4 MiB/s
INFO:  17% (3.6 GiB of 20.0 GiB) in 12s, read: 164.3 MiB/s, write: 155.1 MiB/s
INFO:  21% (4.3 GiB of 20.0 GiB) in 15s, read: 252.5 MiB/s, write: 150.7 MiB/s
INFO:  30% (6.1 GiB of 20.0 GiB) in 18s, read: 611.4 MiB/s, write: 130.8 MiB/s
INFO:  35% (7.0 GiB of 20.0 GiB) in 21s, read: 303.3 MiB/s, write: 140.8 MiB/s
INFO:  37% (7.4 GiB of 20.0 GiB) in 24s, read: 149.8 MiB/s, write: 135.7 MiB/s
INFO:  40% (8.0 GiB of 20.0 GiB) in 27s, read: 205.4 MiB/s, write: 150.3 MiB/s
INFO:  42% (8.5 GiB of 20.0 GiB) in 30s, read: 163.1 MiB/s, write: 148.4 MiB/s
INFO:  48% (9.7 GiB of 20.0 GiB) in 33s, read: 415.7 MiB/s, write: 147.9 MiB/s
INFO:  57% (11.5 GiB of 20.0 GiB) in 36s, read: 610.2 MiB/s, write: 114.4 MiB/s
INFO:  81% (16.4 GiB of 20.0 GiB) in 39s, read: 1.6 GiB/s, write: 49.1 MiB/s
INFO: 100% (20.0 GiB of 20.0 GiB) in 41s, read: 1.8 GiB/s, write: 4.0 KiB/s
INFO: backup is sparse: 14.74 GiB (73%) total zero data
INFO: transferred 20.00 GiB in 41 seconds (499.5 MiB/s)
INFO: stopping kvm after backup task
INFO: archive file size: 2.14GB
trying to acquire lock...
 OK
INFO: Finished Backup of VM 10001 (00:00:44)
INFO: Backup finished at 2022-07-13 22:24:32
INFO: Backup job finished successfully

Copy backup archive to another server.

basilisk:~$ scp /var/lib/vz/dump/vzdump-qemu-10001-2022_07_13-22_23_48.vma.zst manticore:~/
vzdump-qemu-10001-2022_07_13-22_23_48.vma.zst                                                                         100% 2188MB 111.9MB/s   00:19 

Restore backup on remote server.

manticore:~$ qmrestore vzdump-qemu-10001-2022_07_13-22_23_48.vma.zst 10001
restore vma archive: zstd -q -d -c /root/vzdump-qemu-10001-2022_07_13-22_23_48.vma.zst | vma extract -v -r /var/tmp/vzdumptmp647964.fifo - /var/tmp/vzdumptmp647964
CFG: size: 499 name: qemu-server.conf
DEV: dev_id=1 size: 21474836480 devname: drive-scsi0
CTIME: Wed Jul 13 22:23:49 2022
  Logical volume "vm-10001-disk-0" created.
new volume ID is 'local-lvm:vm-10001-disk-0'
map 'drive-scsi0' to '/dev/pve/vm-10001-disk-0' (write zeros = 0)
progress 1% (read 214761472 bytes, duration 1 sec)
progress 2% (read 429522944 bytes, duration 1 sec)
progress 3% (read 644284416 bytes, duration 1 sec)
progress 4% (read 859045888 bytes, duration 1 sec)
progress 5% (read 1073741824 bytes, duration 1 sec)
progress 6% (read 1288503296 bytes, duration 1 sec)
progress 7% (read 1503264768 bytes, duration 1 sec)
progress 8% (read 1718026240 bytes, duration 1 sec)
progress 9% (read 1932787712 bytes, duration 1 sec)
progress 10% (read 2147483648 bytes, duration 1 sec)
progress 11% (read 2362245120 bytes, duration 2 sec)
progress 12% (read 2577006592 bytes, duration 2 sec)
progress 13% (read 2791768064 bytes, duration 2 sec)
progress 14% (read 3006529536 bytes, duration 3 sec)
progress 15% (read 3221225472 bytes, duration 3 sec)
progress 16% (read 3435986944 bytes, duration 3 sec)
progress 17% (read 3650748416 bytes, duration 4 sec)
progress 18% (read 3865509888 bytes, duration 4 sec)
progress 19% (read 4080271360 bytes, duration 4 sec)
progress 20% (read 4294967296 bytes, duration 5 sec)
progress 21% (read 4509728768 bytes, duration 8 sec)
progress 22% (read 4724490240 bytes, duration 13 sec)
progress 23% (read 4939251712 bytes, duration 13 sec)
progress 24% (read 5154013184 bytes, duration 13 sec)
progress 25% (read 5368709120 bytes, duration 13 sec)
progress 26% (read 5583470592 bytes, duration 13 sec)
progress 27% (read 5798232064 bytes, duration 13 sec)
progress 28% (read 6012993536 bytes, duration 13 sec)
progress 29% (read 6227755008 bytes, duration 13 sec)
progress 30% (read 6442450944 bytes, duration 14 sec)
progress 31% (read 6657212416 bytes, duration 15 sec)
progress 32% (read 6871973888 bytes, duration 16 sec)
progress 33% (read 7086735360 bytes, duration 16 sec)
progress 34% (read 7301496832 bytes, duration 16 sec)
progress 35% (read 7516192768 bytes, duration 17 sec)
progress 36% (read 7730954240 bytes, duration 18 sec)
progress 37% (read 7945715712 bytes, duration 20 sec)
progress 38% (read 8160477184 bytes, duration 21 sec)
progress 39% (read 8375238656 bytes, duration 22 sec)
progress 40% (read 8589934592 bytes, duration 23 sec)
progress 41% (read 8804696064 bytes, duration 24 sec)
progress 42% (read 9019457536 bytes, duration 25 sec)
progress 43% (read 9234219008 bytes, duration 27 sec)
progress 44% (read 9448980480 bytes, duration 27 sec)
progress 45% (read 9663676416 bytes, duration 27 sec)
progress 46% (read 9878437888 bytes, duration 27 sec)
progress 47% (read 10093199360 bytes, duration 28 sec)
progress 48% (read 10307960832 bytes, duration 29 sec)
progress 49% (read 10522722304 bytes, duration 30 sec)
progress 50% (read 10737418240 bytes, duration 30 sec)
progress 51% (read 10952179712 bytes, duration 30 sec)
progress 52% (read 11166941184 bytes, duration 30 sec)
progress 53% (read 11381702656 bytes, duration 30 sec)
progress 54% (read 11596464128 bytes, duration 30 sec)
progress 55% (read 11811160064 bytes, duration 30 sec)
progress 56% (read 12025921536 bytes, duration 31 sec)
progress 57% (read 12240683008 bytes, duration 34 sec)
progress 58% (read 12455444480 bytes, duration 40 sec)
progress 59% (read 12670205952 bytes, duration 42 sec)
progress 60% (read 12884901888 bytes, duration 42 sec)
progress 61% (read 13099663360 bytes, duration 42 sec)
progress 62% (read 13314424832 bytes, duration 42 sec)
progress 63% (read 13529186304 bytes, duration 42 sec)
progress 64% (read 13743947776 bytes, duration 42 sec)
progress 65% (read 13958643712 bytes, duration 42 sec)
progress 66% (read 14173405184 bytes, duration 42 sec)
progress 67% (read 14388166656 bytes, duration 42 sec)
progress 68% (read 14602928128 bytes, duration 42 sec)
progress 69% (read 14817689600 bytes, duration 42 sec)
progress 70% (read 15032385536 bytes, duration 42 sec)
progress 71% (read 15247147008 bytes, duration 42 sec)
progress 72% (read 15461908480 bytes, duration 42 sec)
progress 73% (read 15676669952 bytes, duration 42 sec)
progress 74% (read 15891431424 bytes, duration 42 sec)
progress 75% (read 16106127360 bytes, duration 42 sec)
progress 76% (read 16320888832 bytes, duration 42 sec)
progress 77% (read 16535650304 bytes, duration 42 sec)
progress 78% (read 16750411776 bytes, duration 42 sec)
progress 79% (read 16965173248 bytes, duration 42 sec)
progress 80% (read 17179869184 bytes, duration 42 sec)
progress 81% (read 17394630656 bytes, duration 42 sec)
progress 82% (read 17609392128 bytes, duration 42 sec)
progress 83% (read 17824153600 bytes, duration 42 sec)
progress 84% (read 18038915072 bytes, duration 42 sec)
progress 85% (read 18253611008 bytes, duration 42 sec)
progress 86% (read 18468372480 bytes, duration 42 sec)
progress 87% (read 18683133952 bytes, duration 42 sec)
progress 88% (read 18897895424 bytes, duration 42 sec)
progress 89% (read 19112656896 bytes, duration 42 sec)
progress 90% (read 19327352832 bytes, duration 42 sec)
progress 91% (read 19542114304 bytes, duration 42 sec)
progress 92% (read 19756875776 bytes, duration 42 sec)
progress 93% (read 19971637248 bytes, duration 42 sec)
progress 94% (read 20186398720 bytes, duration 42 sec)
progress 95% (read 20401094656 bytes, duration 42 sec)
progress 96% (read 20615856128 bytes, duration 42 sec)
progress 97% (read 20830617600 bytes, duration 42 sec)
progress 98% (read 21045379072 bytes, duration 42 sec)
progress 99% (read 21260140544 bytes, duration 42 sec)
progress 100% (read 21474836480 bytes, duration 42 sec)
total bytes read 21474836480, sparse bytes 15824703488 (73.7%)
space reduction due to 4K zero blocks 3.41%
rescan volumes...

List virtual machines on remote server.

manticore:~$ qm list
      VMID NAME                 STATUS     MEM(MB)    BOOTDISK(GB) PID       
     10001 ubuntu-jammy-jellyfish stopped    2048              20.00 0    

Now you can use it right away or just convert it to a template.