Backup LXC container for disaster recovery


(mjr2015) #1

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 publish CONTAINER_NAME/SNAPSHOT_NAME --alias DATE_CONTAINER_BACKUP
lxc image export DATE_CONTAINER_BACKUP /backupdir/
lxc image delete DATE_CONTAINER_BACKUP
lxc image import TARBALL-NAME --alias DATE_CONTAINER_BACKUP
lxc launch DATE_CONTAINER_BACKUP RESTORED_CONTAINER
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?


(Dell Rusk) #2

Hi,

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.


(mjr2015) #3

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


(Dell Rusk) #4

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.


(noura) #5

While running Yes, but the problem is all data in memory will not be that simply saved.


(mjr2015) #6

thanks for the info!