How do you create a snapshot, a backup and then restore with lxc

distro: Debian Buster
lxc ver: 3.0.3-8
fs: btrfs

Sorry but there’s something wrong with my system or the man page is wrong. https://linuxcontainers.org/lxc/manpages//man1/lxc-snapshot.1.html

I tried doing lxc-image (lxc-snapshot) and nothing happened and nothing was created.
Here are all the binaries I have related to lxc (as far as I know):

Any direction and advice is appreciated. Please don’t tell me to install LXD on Debian. I’m attempting to do everything with vanilla distro and tools here.

Well, might a problem related to the version.
Recent version of lxc is 4.x so I guess that 3.0.3 might not have this feature, but it is only a guess.

I’m confused as to what the problem is, that manpage is for lxc-snapshot which is listed as a valid command on your system’s screenshot.

lxc-image isn’t a valid command, never has been but I also don’t see it mentioned anywhere on that manpage.

What am I missing?

The problem is I mistyped when I said lxc-image.
The next problem is I can’t figure how to create a snapshot using using only lxc. I can’t create snapshots for some reason.
I also can’t backup or restore using just lxc.

I’m ignorant and asking for some help with examples.

I just now found this: https://stackoverflow.com/questions/23427129/how-do-i-backup-move-lxc-containers but I don’t have lxc-clone. So it looks like lxc-clone is deprecated with lxc-copy.

Looks like I just needed to come here and look like a fool before I could find the answer - which appears to be: “Just use lxc-copy”

lxc-snapshot - you would make my day if I could see examples of how to use lxc-snapshot because it seems apparent I can’t read a manpage.

I haven’t used those tools in a long time, but indeed lxc-snapshot just creates a snapshot entry in /var/lib/lxc with behavior dependent on the storage backend. I don’t think I’ve ever used it myself.

lxc-copy is @brauner re-implementing lxc-clone in C (I wrote lxc-clone in python3 I believe), I think that all landed around LXC 2.0.

It could be just me but lxc-snapshot does nothing on my system. Nothing is generated @ /var/lib/lxc. Would someone provide an example of creating a snapshot? Maybe it’s me and I also don’t know where Debian dumps the snapshot?

Do this on new containers: Always use -B btrfs option or convert.

lxc-create -P /path/to/container -t download -n container_name -- -d debian -r buster -a amd64 --keyserver hkp://p80.pool.sks-keyservers.net:80 -B btrfs

Do this on existing containers: https://wiki.calculate-linux.org/working_with_lxc

#Stop the container:
lxc-stop container_name

#Rename the rootfs directory
cd /path/to/container
mv rootfs rootfs.old

#Create a Btrfs subvolume and move the contents of rootfs to it:
btrfs subvolume create rootfs
#su or sudo the mv or it won’t work
sudo mv rootfs.old/* rootfs/
rmdir rootfs.old

#Adjust the container config settings, namely by replacing dir with btrfs:
nano /path/to/container/config

#To make sure that the container is now located on the Btrfs subvolume, run:
btrfs subvolume list /path/to/container