Incus Container Snapshots

Snapshots are point in time backups of a container that can be used to roll back a container to a state when the backup was made. Incus Snapshots are stored inside of a container and make the container larger.

Incus Snapshots are functionally equivalent to LXD Snapshots, but the commands are different.

In the video, I create a sample container:

incus launch images:ubuntu/22.04 container1

To take a snapshot and call it “snapshot1”:

incus snapshot create container1 snapshot1 

In contrast, the command in LXD is:

lxc snapshot container1 snapshot1

To delete an incus snapshot:

incus snapshot delete container1 snapshot1

In LXD, this command is:

lxc delete container1/snapshot1

We created the snapshot again in the video for example purposes:

incus snapshot create container1 snapshot1 

The command to list all of the information on a container including snapshots is:

incus info container1

Incus has a new command that LXD does not to list all the snapshots on a container:

incus snapshot list container1

image

You can set snapshots to occur automatically according to a schedule with commands like the following:

incus config set container1 snapshots.schedule @daily
incus config set container1 snapshots.schedule "0 6 * * *"

I have a tutorial on “How to Schedule LXD Snapshots” that goes into depth on LXD Snapshots schedules that is applicable to incus as well.

We can rename an incus snapshot:

incus snapshot rename container1 snapshot1 snapshot2

In contrast to that, the LXD command is:

lxc rename container1/snapshot1 container1/snapshot2

To verify that the snapshot was renamed:

incus snapshot list container1

image

There is also a “snapshot show” command that gives a verbose listing of all of the attributes of a snapshot:

incus snapshot show container1 snapshot2

It’s also possible to take a new snapshot that overwrites a current snapshot. This is useful and does the same as deleting and creating a new snapshot of the same name, but with a single step.

incus snapshot create container1 snapshot2 --reuse

image

You can change some parameters associated with a snapshot like the expiration date by editing it with the following command:

incus config edit container1/snapshot2

Lets rename snapshot2 to snapshot1:

incus snapshot rename container1 snapshot2 snapshot1

Now if we list the snapshots:

You can restore from a snapshot to revert a container back to the state when the snapshot was taken:

incus snapshot restore container1 snapshot1

In LXD, that command is:

lxc restore container1 snapshot1

Images can be created in both LXD and Incus. I have covered images before. When you launch a new container, you are doing so using the image as a starting point.

You can create your own custom images which you can use to create containers from.

For the purpose of this tutorial, we are able to also create an image from a snapshot:

incus publish container1/snapshot1 --alias mycoolimage description="My Stuff"

You can list the images stored on your server (the use space in your storage pool):

incus image list

To create a new container with this image:

incus launch mycoolimage container2

image