# How to Schedule LXD Snapshots

**URL:** https://discussion.scottibyte.com/t/how-to-schedule-lxd-snapshots/214
**Category:** Uncategorized
**Created:** [March 30, 2023, 11:48pm UTC](https://discussion.scottibyte.com/t/how-to-schedule-lxd-snapshots/214 "2023-03-30T23:48:07Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![scott](https://discussion.scottibyte.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://discussion.scottibyte.com/u/scott)
#### Post date: [March 30, 2023, 11:48pm UTC](https://discussion.scottibyte.com/t/how-to-schedule-lxd-snapshots/214/1 "2023-03-30T23:48:07Z")

</div>

LXD Snapshots are point in time images that are stored as a part of a container. In my “LXD Custom Images” tutorial a year ago, I showed how to create images from snapshots. In this tutorial, we learn how you can schedule container snapshots to occur on a schedule and also how to expire them according to rules you establish.

We created a simple Ubuntu a simple Ubuntu 22.04 container.

```auto
lxc launch ubuntu:22.04 test --profile default -c boot.autostart=true

```

Create a snapshot of that container:

```auto
lxc snapshot test first-shot

```

We can even create an “image” from the snapshot. Images can be used to create future containers based upon the image.

```auto
lxc publish test/first-shot --alias mycoolimage description="Ubuntu 22.04 with goodies"

```

Examine the image you just created:

```auto
lxc image info mycoolimage

```

Launch a new container based on that image:

```auto
lxc launch mycoolimage test2

```

Snapshots can be created on an automated schedule.  
In the tutorial, I create an hourly schedule:

```auto
lxc config set test snapshots.schedule "@hourly"

```

You can set a pattern for the naming of your Snapshots:

```auto
lxc config set test snapshots.pattern "Snapshot-{{ creation_date|date:'01-02-2006_15:04' }}"

```

The command above is a template and does not refer to the year 2006 as I mentioned in the video. The formatting of the pattern is based upon the Pongo2 template engine which is similar to the Django template design. The documentation is very scant, but the example about works to insert the current date as a part of the snapshot name.

You can also specify how long a snapshot will stick around before it is automatically deleted. In the video, I set the expiration to be two hours:

```auto
lxc config set test snapshots.expiry "2H"

```

I also showed that you can create a profile or edit an existing profile to include a snapshot schedule. This policy will be applied to all containers that have the profile as a part of their configuration.

```auto
lxc profile create snap-hourly
lxc profile set snap-hourly snapshots.schedule "@hourly"
lxc profile set snap-hourly snapshots.pattern "Hourly-{{ creation_date|date:'01-02-2006_15:04' }}"
lxc profile set snap-hourly snapshots.expiry "2H"

```

To add the above profile to a container:

```auto
lxc profile add test3 snap-hourly

```

To examine a container settings as well as see if it has any snapshots:

```auto
lxc info test

```

To examine the currently set parameters on a given container:

```auto
lxc config show test

```
