backup LXC -> restore in VM

Merican

New Member
Jun 22, 2023
1
0
1
Hi guys,
I'd like to know what's the best way to backup a LXC Container and restore it in a virtual machine.
I can install whatever OS in the OS to restore the LXC data, or create an empty vm disk and restore all the data inside.

Actually i do :

#from proxmox host :
pct stop lxc_id
pct mount lxc_id
cd /var/lib/lxc/lxc_id/rootfs
tar -czvf ../root.tar.gz --numeric-owner --exclude=./proc --exclude=./boot --exclude=./sys -exclude=./dev ./
cd /
pct unmount lxc_id

i scp the /root.tar.gz --> to the VM (installed in Deb11 same version as host), at the rootfs /
in the vm i have /root.tar.gz

at this point, i take a snapshot....

i can use two methods .. ( and they fail :') ).
Method1 :
#from inside the vm
tar xzvf /root.tar.gz -C /
--> untar is ok but system totaly fail whatever command i do after this ....
if i reboot from this point --> black screen ...

Method2 :
(for a rescue live cd last version )
mkdir /mnt/disk
mount /dev/sda5 /mnt/disk
chroot /mnt/disk /bin/bash
tar xzvf /root.tar.gz -C /
reboot

and black screen ...

So i rollback with my snap.. and i search since fews days...

I know some ppl will tell me "don't restore lxc to vm" or "reinstall the programs /data of the LXC in the VM" but this not that i want.
I need to restore the LXC --> in the VM.

Can someone please teach me the ways?!
Thanskl you a lot ! (and sorry for my eng!)