Score:0

Can I restore a Vzdump tar archive to an LXD/LXC container

in flag

I have a number of "tar" files created from an old proxmox 6 server, using the vzdump tool.

The person that originally created them has left the company, and the company has changed it's container server from "Proxmox VE" to a standard Linux Ubuntu 20.04 LTS server running the latest version of LXD for it's container system.

I've now been asked if I can take these Vzdump tar files, and turn them into regular standard LXC based deployments running on the new server.

Every search I do seems to ONLY turn up converting bare bones LXC containers to Proxmox VE containers, and asking in the proxmox forums is getting me no where, because all they want to do is get me back onto proxmox, which my client no longer wishes to use.

I can vzrestore onto the new server, but the meta data in the containers is not compatible with LXD/LXC so that's proven to be a dead end so far.

In the same vein, I've also tried converting the container to an LXC template image, and building from that, but again, that's not worked as I'd hoped.

djdomi avatar
za flag
proxmox is using a standard lxc setup. please just try to use it
in flag
Ummm... did you actually read my question properly? I'm well aware of what Proxmox uses under the hood, but that's not what I'm asking is it?
djdomi avatar
za flag
i read and used the backuo file which are basically just a copy of the filesystem to copy and start a container, the only thing you may to think about is to restore this because its a backup file and not a template
in flag
That's the answer I'm looking for, how to take the archive file created by vzdump, and make it work with normal LXD/LXC that is NOT installed as part of Proxmox, if you can explain that, then that will be the answer.
djdomi avatar
za flag
i thibk you just need to use lxc import tarfile
in flag
OK thanks, will try that and see what happens.
in flag
Tried that, got the following : "Error: Backup is missing index.yaml" so at least I have something to hunt on.
Score:1
in flag

So after 2 weeks of research and reading many, many blog posts, I finally figured out how to do it.

It's not particularly staright forward, but it's not rocket science either, I do however get the feeling (and the hostility) from asking in the proxmox forums that they would rather you didn't move away from the proxmox platform, temporary or otherwise.

Anyway, the steps you need to follow are essentially

  1. at the proxmox command line, "pct list" to get the ID of the container you want to copy.

  2. at the same command line "vzdump -compress gzip -dumpdir /tmp" , you don't need the dump dir parameter, but the default is nested a stupid amount of folders deep, so I'd advise to use the tmp dir for easiness.

  3. you then need to create a "meta data file" using the following commands (Please NOTE: the # symbols need to be changed to BACKTICKS before you copy and paste/use the command, I've had to use the # symbol as markdown in a SO post cannot display the backtick symbol due to the way markdown uses it) :

    echo architecture: #pct config $1 | grep arch: | awk '{print $2}'# > metadata.yaml

    echo creation_date: #date +%s# >> metadata.yaml

    tar -czvf metadata.tar.gz metadata.yaml

    rm metadata.yaml
  1. Move the ".tar.gz" files that you created, across to the target machine running a modern version of LXD, I used rsync for this.

  2. ON the command line of your LXD machine, use the following command to import the metadata and dump file into an lxc image:

    sudo lxc image import metadata.tar.gz <vzdump name>.tar.gz

This will import the container as an image, which is not directly runnable, type

lxc image list

and get the fingerprint of the image you just created

LXC image list

  1. still at the LXD command line, using the fingerprint from your image use:

    lxc launch <fingerprint> <name you want to give your container>

At this point, you'll have a new container, that is an exact duplicate of your original proxmox one running.

What you may not have are the same network settings however. For me, I have everything on my network running off of DHCP, including the static leases, so it was important that my new containers had the same MAC address, that was easily done by using

pct config <container id>

on the proxmox cli to display the hardware configuration, then copy and pasting the MAC address from that, followed by

lxc stop <container name>
lxc config set <container name> volatile.eth0.hwaddr <copied mac address>
lxc start <container name>

If your DHCP static leases are driven from the mac address, then this will ensure that they get the same IP address, as long as your LXD host is set up to bridge IP's on the same network as your original proxmox host.

I've written a blog post which can be found at : https://shawtyds.wordpress.com/2021/11/16/converting-containers-from-proxmox-ve-back-to-plain-old-lxd-lxc/ that goes into a little more detail.

Once your copied container is running, then it's just a matter of using lxc to delete the temporary image (unless you want to keep it) and to erase the ".tar.gz" files from both servers, and possibly removing the old container from proxmox if you no longer need it.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.