How do I backup a LXC container?
How to backup LXD containers
- lxc copy. The easiest way is to copy an LXD container to another computer.
- lxc export and lxc publish. With LXD you can also export a container as a compressed image and then back it up to a NAS, an offsite backup or a cloud storage.
Where is LXC container stored?
/var/lib/lxc
By default, containers are located under /var/lib/lxc for the root user.
How do Lxc containers work?
Instead of creating a full-fledged virtual machine, LXC enables a virtual environment with its own process and network space. Note: LXC uses namespaces to enforce process isolation, alongside the kernel’s very own cgroups to account for and limit CPU, memory, disk I/O and network usage across one or more processes.
How do you stop a lxc container?
lxc-stop reboots, cleanly shuts down, or kills all the processes inside the container. By default, it will request a clean shutdown of the container by sending lxc. signal. halt (defaults to SIGPWR) to the container’s init process, waiting up to 60 seconds for the container to exit, and then returning.
How to make a snapshot of a LXD container?
To make a snapshot for LXD, run: lxc snapshot containerName. Create a snapshot named backup01 for Linux container named www1 using the lxc command: lxc snapshot www1 backup01. Restore LXD container named www2 from snapshots named snap2, on Linux: lxc restore www2 snap2.
Is it possible to move LXC containers between systems?
In case you stumbled upon this post, my answer is really about moving the LXC containers between systems, since that seemed to be the question being asked. If you want to backup your LXC containers, see @Stuart’s answer for some great options. This is how I migrate LXC containers between systems.
How to backup LXC containers to a remote host?
To backup an lxc container quickly to a remote host without a btrfs filesystem I mount a filesystem from the remote host with sshfs & cd into the mount. Stop the container & create a tar.xz archive of it.
Is it possible to SSH into a LXC container?
Apps that use LXC, however, are meant to be persistent. You can ssh into an LXC container as you’d do into a remote Linux host and manage the environment. Docker does not allow this, and you’ll be using specialized tools to manage deployment and testing.