How to Backup and Restore LXC containers

Posted on 12-01-2017 by Nadir Latif


It describes how to backup and restore LXC containers. One option for backing up a LXC container is to create a tar acrhive using the commands:

lxc-stop -n ContainerName;
cd /var/lib/lxc/ContainerName/
tar --numeric-owner -czvf container_fs.tar.gz ./*

The backup of the container may be restored using the command:

rsync -avh container_fs.tar.gz user@server_name:/var/lib/lxc/
tar --numeric-owner -xzvf container_fs.tar.gz ./*