I was doing a big upgrade on some containers, so I created a pre-upgrade snapshot on each. I was expecting to keep them around for some weeks, just in case. But they got deleted after a day
Thanks to the forum, I’ve now found that I could have prevented this using:
incus snapshot create --no-expiry ...
But then I’d have to remember to come back in a few weeks to clean them up.
I believe that each snapshot already stores an explicit expires_at attribute (e.g. if I change snapshots.expiry in the profile, it doesn’t alter the expiry time of existing snapshots).
Therefore, here’s my feature suggestion:
At snapshot creation time, be able to specify an expiry time for that particular snapshot, either absolute or relative to now. e.g.
(or some other syntax, e.g. incus snapshot set… or whatever is most consistent)
Finally, if snapshots.expiry could be split into two settings, one for automatic and one for manual snapshots. then I could set snapshots.expiry.manual to 4w or never and avoid the surprises. That would allow changing the current behaviour, whilst remaining backwards compatible with existing users.
There’s an API for snapshot update that allows to update individual settings of snapshots, such as the expiry. If you were to click in there, the example is about updating the expires_at field.
The first question is whether the existing API is good enough to cover the two cases that you describe above.
If the answer is yes, then the second question is how to expose the API functionality into 1) the incus client, and 2) the Web UI. At least for the incus client it should be relatively easy, just add an incus snapshot update sub-command.
I presume null means "use the snapshots.expiry default, and the other is a sentinel value which means “do not expire”. But it should be able to calculate the desired expiry time.
I notice this post, Documentation of 'snapshots.expiry' semantics which was not answered. With a bit of trial and error it’s possible to answer the questions. Failing that, check the code.
I am not too familiar with the expiry functionality. From what has been discussed thus far, what’s missing is only the client-side support to update the snapshots.expiry field on a snapshot, after the snapshot has been created?
Also, to be able to select the expiry at snapshot creation time.
At the moment you only have two options when creating a snapshot: say nothing, in which case you get an expiry based on the global snapshots.expiry setting; or --no-expiry.
In fact, you can already pass an absolute expiry time in YAML to incus snapshot create, if you know how to do it (the documentation doesn’t include an example)
root@nuc3:~# echo "expires_at: 2025-06-30T01:00:00Z" | incus snapshot create sftp test1
root@nuc3:~# incus snapshot list sftp
+-------+----------------------+----------------------+----------+
| NAME | TAKEN AT | EXPIRES AT | STATEFUL |
+-------+----------------------+----------------------+----------+
| test1 | 2025/06/05 13:55 UTC | 2025/06/30 01:00 UTC | NO |
+-------+----------------------+----------------------+----------+