Table of Contents
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Proxmox KVM : How to restore files from dump/backup
Just a simple procedure that was a bit tricky to find on the web. I needed to restore a few files that got overwritten on a server which is a KVM virtual machine running on a Proxmox host. They are several ways to achieve this but I found this to be the simplest and cleanest way :
-
Do a manual restore by using a non existing VMID (YYY): qmrestore dump/vzdump-qemu-XXX-DATE-TIME.vma YYY
-
Mount the partition : modprobe nbd max_part=16 qemu-nbd --connect=/dev/nbd0 images/YYY/vm-YYY-disk-1.qcow2 vgscan Reading all physical volumes. This may take a while... Found volume group "vgmain" using metadata type lvm2 Found volume group "pve" using metadata type lvm2 vgchange -ay vgmain 2 logical volume(s) in volume group "vgmain" now active mount /dev/vgmain/root /mnt/XXX
-
Do not forget to unmount the drive afterwards : umount /mnt/XXX vgchange -an vgmain qemu-nbd -d /dev/nbd0 /dev/nbd0 disconnected rmmod nbd
-
You can then remove wour fake VM if you do not need to recover any more files : qm destroy YYY
Troubleshooting
If vgscan
doesn’t return anything and a manual partprobe returns the
following :
partprobe /dev/nbd0
Error: Error informing the kernel about modifications to partition /dev/nbd0p1 -- Invalid argument. This means Linux won't know about any changes you made to /dev/nbd0p1 until you reboot -- so you shouldn't mount it or use it in any way before rebooting.
Error: Failed to add partition 1 (Invalid argument)
then you have forgotten to add the max_part
parameters to your
modprobe
command