Backing up an LXC container is quite straightforward and can be done by following these steps:
1. First, ensure your container is stopped. You cannot backup an LXC container while it is running. Use the following command to stop the container:
\`\`\` lxc-stop -n container\_name \`\`\` Replace “container\_name” with the name of your container.1. Once your container is stopped, navigate to the directory where your LXC containers are stored. By default, this is “/var/lib/lxc”.
\`\`\` cd /var/lib/lxc \`\`\`1. From here, you can create a .tar.gz archive of your container’s directory. This will include all the necessary files to restore your container later.
\`\`\` tar -czvf container_name.tar.gz container_name/ \`\`\` Replace “container\_name” with the name of your container.And that’s it! You now have a backup of your LXC container. To restore this backup, you would simply extract the archive in the same directory (“/var/lib/lxc”) and start the container with `lxc-start`.
Please note: The backup only includes the container’s filesystem and configuration. It does not include any snapshots or other metadata. If you have snapshots, you will need to backup those separately.