Skip to content

Instantly share code, notes, and snippets.

@mmaridev
Last active February 26, 2023 10:44
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmaridev/477b65ae1245033e2118417380644ec2 to your computer and use it in GitHub Desktop.
Save mmaridev/477b65ae1245033e2118417380644ec2 to your computer and use it in GitHub Desktop.
Backup & restore for VM migration on the fly, without cluster
#!/bin/bash
# run command on new node
ssh root@oldnode vzdump VMID --mode snapshot --compress 0 --remove 0 --node NODE --stdout | (
sleep 5;
/usr/sbin/qmrestore - NEWVMID --storage local-zfs
)
# also works (vice-versa) for containers
vzdump PCTID --mode snapshot --compress 0 --remove 0 --node NODE --stdout | (
sleep 2
ssh NEWNODE pct restore NEWPCTID - --storage local-zfs --rootfs 0
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment