An LXC Experiment for Backups – Take 2

Remember this recent article:  An LXC Experiment for Live Backups?

It was out first attempt to perform live migrations of one LXC container on one physical machine, to a new container running on a completely different machine.  The idea being to create live containers with real-world very current information that can act as part of a complete disaster-resistant backup strategy.

The plan failed as the copy process gave us errors.  This may be due to a timeout of SSH (but it shouldn’t as the files were not THAT big for our LAN network speed).  It could also have been due to trying to restore container cpu states on a different machine – maybe it’s too much for lxc.  It doesn’t matter, it just failed and so we had to rethink.

We have…a new plan.  What if we take a SNAPSHOT of a container and IMMEDIATELY copy that (in a ‘stopped’ state of course)?  No cpu registers and memory to worry so much about as part of a copy.  The container is in a re-start-able form, not a running state.

Something like:

lxc snapshot Nextcloud Snapshot-name 

lxc copy Nextcloud/Snapshot-name NEWMACHINE:NextcloudMirror

lxc start NEWMACHINE:NextcloudMirror

This series of non-sudo user commands (that’s right, no scary super-user stuff again) creates then copies the container ‘Nextcloud’ snapshot named ‘Snapshot-name’ to a new lxc node called ‘NEWMACHINE’.  The node is an lxc remote system – can be anywhere: same machine, same network, different machine in a different country connected via internet over public-private ssh connection – all handled by lxc).

Well we tried this…it WORKS.  Lots of testing to do, but we are very excited at this prospect.  More to come!