Can LXC backup be restored to OpenVZ?

gkovacs

Renowned Member
Dec 22, 2008
514
51
93
Budapest, Hungary
We have started the upgrade of our cluster to Proxmox VE 4.1, but there are so many problems (and no solution in sight for them) that we are thinking about returning to PVE 3.4.

Problem is we have a few containers that are already converted to LXC, is there any way of converting them back to OpenVZ? Simply renaming the LXC backup from vzdump-lxc-NNN to vzdump-openvz-NNN is not enough, the restore completes but gives the following error:

TASK ERROR: container NNN does not exists

Is it a config file that's missing? Is there a way of recreating it?
 
I noticed that after the restore the container files are properly present in /var/lib/vz/private/NNN/

However the following are missing:
- there is no config file for the container at /etc/pve/openvz/
- there is no filesystem under /var/lib/vz/root/NNN

Looking at the config files I think I could recreate one, however I don't see how to present the /var/lib/vz/root/NNN folder (there seems to be no link to private for other containers). Anyone know how to proceed and if I missed anything else?
 
I'd like to know this too... I'm hitting space issues after doing our upgrade because the imported containers are seemingly taking far more space than before. And you can't shrink the images.

So now I've managed to restore 3 of our VMs, with another 3 that won't fit. Wishing I had just left things alone now. :(
 
I have tried to restore LXC backups to OpenVZ with the following procedure:
- unpacking the tar.lzo (first lzop -d, then tar xvf)
- recreating the original OpenVZ config file by creating an empty container with identical specs
- copying config file from /etc/pve/openvz/XXX.conf into the archive at /etc/vzdump/vps.conf
- repacking the tar.lzo
- restoring with vzrestore / web interface

The restore completes without an error, however the containers are unable to boot (complaining about missing devices, like /dev/urandom).
 
I cheated a little bit with mine. I only needed to recover 1 LXC container back to VZ, and it was only 20GB.

I shut down the LXC container, then copied the raw image file to our NAS.
Then I reinstalled 3.4, and recovered the old VZ version of the backup for that container.
Once it was restored, before starting it up, I mounted the raw image, and rsynced the data I needed that had changed (not the entire OS) into the VZ container's "private" folder.
Started the VZ container, and it was all good.

I'm not sure what would happen if you just dumped the entire LXC image contents out into the private folder - I get the impression Proxmox makes LXC specific changes that might cause issues booting.
 
So I streamlined the conversion of LXC containers back to OpenVZ, if anyone else needs it. I got the information about missing devices from the OpenVZ P2V tutorial:
https://openvz.org/Physical_to_container

Here are the steps to take converting LXC to OpenVZ:

Prerequisites

I have an NFS server that all Proxmox hosts can see, so I can work with backup files on all hosts. Please note that if you want consistency of logfiles and databases, you should stop the LXC container before this procedure.

LXC host
1. Create backup from LXC container to vzdump-lxc-XXX.tar.lzo

OpenVZ host
2. Create an empty OpenVZ container with the same specs (CPU, memory, disk, etc.) as your LXC container, ID will be XXX

3. SSH into OpenVZ host, copy container config file
Code:
cp /etc/pve/openvz/XXX.conf /etc/vzdump/vps.conf

4. Get to a temp folder, unpack tar file from compressed LXC backup
Code:
lzop -d vzdump-lxc-XXX.tar.lzo

5. Add container config file to LXC backup tar file
Code:
tar -rvf vzdump-lxc-XXX.tar /etc/vzdump/vps.conf

6. Delete empty OpenVZ container created in step 2

7. Restore LXC backup to OpenVZ container
Code:
vzrestore vzdump-lxc-XXX.tar XXX

8. Create missing devices in OpenVZ container private area
Code:
cd /var/lib/vz/private/XXX/
rm -f dev/null
mknod -m 666 dev/null c 1 3
mknod -m 666 dev/zero c 1 3
mknod -m 444 dev/random c 1 8
mknod -m 444 dev/urandom c 1 9
mknod -m 666 dev/ptmx c 5 2
mkdir dev/pts
cp -a /dev/ttyp* /dev/ptyp* dev/

9. Start OpenVZ container and check console and dmesg / messages for any remaining problems.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!