Last active
July 6, 2023 20:00
-
-
Save gsdefender/00e55ad3f41f8e5ca9c039b281d6e20a to your computer and use it in GitHub Desktop.
Restore Proxmox VM backup to another server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# usage: ./restore-proxmox-vm backup.zst local:111 newlocal | |
tempdir=$(mktemp -d -u) # do not create directory or vma extract will fail | |
if [ -f "$1" ]; then zstd -d "$1"; fi | |
vma extract "$(basename $1 .zst)" "$tempdir" | |
vmid=$(($(ls -1 /etc/pve/qemu-server/*.conf | tr '\n' '\0' | xargs -0 -n 1 basename | sed -e 's:\.conf::g' | sort -n | tail -1)+1)) | |
mv "$tempdir/qemu-server.conf" /etc/pve/qemu-server/$vmid.conf | |
newdisk="$3:$vmid" | |
sed -i -e "s:$2:$newdisk:g" /etc/pve/qemu-server/$vmid.conf | |
mkdir -p "$3/images/$vmid" | |
mv "$tempdir/disk-drive-scsi0.raw" "$3/images/$vmid" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment