Live backup of lxd containers


(Chris Kruijntjens) #1

Hi all,

I am new to containers. I changed from kvm to lxd. I know how to create a tar file backup from a container. However when i do this the container is stopped. Is it also possible to do this while the container is running? Or any option to do a live backup of containers?


#2

If you use LXD >= 3.8, you can do a lxc export
this is doing a snapshot so I think it means that live backup is done.
Note: LXD 3.8 implies usage of snap packaged lxd on most linux distributions.


(Chris Kruijntjens) #3

Hi,

i use the latest version, however if i take a snapshot the lxd container is stopped.


#4

Did you actually try to do a lxc export ? this has never stopped a container for me.


(Chris Kruijntjens) #5

yes but do we need to use the command lxc publish before the export?

I once did an lxc export but when i tried to restore the container it started to complain that it could not found a yaml file.

I will try again with the lxc export command.


#6

no


(Chris Kruijntjens) #7

ok that worked. how can we restore the image?

lxc import?


#8

Yes, for your information for most lxd commands you can get help with --help, so
lxc import --help
will say that you need to provide the .tar.gz file name.
As there is no way to change the container name when restoring, you have to actually delete your container before importing it back. Renaming it is possible but it’s a bit tricky.


(Chris Kruijntjens) #9

hi

thank you it worked indeed while container is running. Thank you.


#10

Well in this case you can mark the thread as solved by selecting the post that gave you the solution clicking the three dots button then clicking the (newly displayed) mark button (to the left)