Backup or move an LXC container

You can not just copy an LXC container, wat you need to do is among the lines of

cd /var/lib/lxc
tar --numeric-owner -cf container_125_fs.tar vm125

The magic is mainly about maintaining the numeric owner of files, which is lost when you copy the files using the host machine 😉

you can untar it the same way you untar any other tar file.

for example, to untar it to a different location, you can use the command

tar -xf container_125_fs.tar -C /target/directory

This whole thing is very useful in moving a container to a different directory, then modifying the config file to point to that directory, as well as moving it to a different machine, the reason you can’t just move it is that moving will cause some issues as the move command does not take the ownership differences between host and guest into account.

Leave a Reply

Your email address will not be published. Required fields are marked *