Backup LXC container for disaster recovery

was playing around with snapshots and accidentally deleted a container instead of a snapshot.

So I was thinking I’d like to back up my containers to either an off disk or in my cloud drive.

just to be sure I have everything correct -

lxc image export DATE_CONTAINER_BACKUP /backupdir/
lxc image delete DATE_CONTAINER_BACKUP
lxc image delete DATE_CONTAINER_BACKUP

Are there any additional considerations I should make if I choose to back this up to the cloud drive like amazon or google?

1 Like


If you are using LXD > 3.1 you can create a tarball directly from a container with the command lxc export

If you backup your containers to a cloud drive you may want to encrypt everything first.

can you run the export while the box is running? or do you need to shut it off

You can export while the container is running but I don’t know what kind of consistency you’ll get. I guess it depends on the underlying storage engine.

thanks for the info!

I don’t have enough storage space for an “export”.

I created an “image” via “publish” (presumably compressed by the parameter I used, but I don’t know how to verify).

Does the image need to be exported? Or can I copy the export file to another offsite location?

How do I directly export to somewhere in the cloud (Google Drive, Amazon S3, Blackblaze)?

Or is there a way to do the backup (export) that doesn’t consume as much storage space?

You can configure where the backup/image files get stored using the daemon.backups_volume and daemon.images_volume config options, letting you use an empty custom volume on one of your storage pools rather than system space.