How to backup and restore LXD containers

How to backup and restore LXD containers

To back up an LXD container, you can use the lxc export command. This command will create a tar archive containing the container's root filesystem and metadata. To restore the container from the backup, you can use the lxc import command.

Here's an example of how you might use these commands to back up and restore an LXD container:

  1. To back up the container, run the following command:
refe‮l:ot r‬autturi.com
lxc export container_name backup.tar.gz

This will create a tar archive named backup.tar.gz containing the container's root filesystem and metadata.

  1. To restore the container from the backup, run the following command:
lxc import backup.tar.gz container_name

This will create a new container with the same name and configuration as the original container, using the data from the backup.

Note that these commands only work for local LXD containers. If you want to back up or restore a container on a remote LXD server, you will need to use the lxc copy command instead.

lxc copy <source>:<container> <destination>:<container>

For example, to copy a container from a local LXD instance to a remote LXD instance, you could use a command like this:

lxc copy local:container_name remote:container_name

This will create a new container on the remote LXD instance with the same name and configuration as the original container, using data transferred over the network.

Created Time:2017-10-28 21:38:58  Author:lautturi