Feature request: better snapshoting automation

Hi,
For a while (v3.18?), LXD has had an automated snapshoting system, which is great ( with snapshots.schedule). Even if we can set several schedules in it - something that few people know - it remains relatively basic. What is really missing is the classical rotation scheme used in so many organizations: to rotate with different retentions between daily, weekly, monthly and possibly hourly and yearly snapshots, with auto-deletion of those not in use.

Fortunately, Patryk has already implemented that in a nice and robust script: lxd-snapper (here on github: https://github.com/Patryk27/lxd-snapper). I have it running for a while and it runs very well.

=> Wouldn’t it be a nice thing to have this included by default in LXD (in addition to the existing snapshots.schedule way)?

Yeah, that should be possible but would require a fair amount of thought as it wouldn’t just be a fixed expiry on a snapshot so much as having a process looking at all snapshots and deciding what to keep and expire. So doesn’t really fit well with the current model.

Thanks for revealing this secret.
I have been requesting that for a while:

Though multi schedule seems to work now, there just need to be a multi pattern as well, so you can easily distinguish by name/pattern, which snapshots is child of schedule.

We could easily enough implement a snapshots.pattern.schedule or snapshots.pattern.manual to separate the patterns for scheduled vs manual, is that sufficient or do you expect the need to have a different pattern for each of the schedules too?

Thanks for your suggestions.
Lets say we let users create automated snapshots, to keep it simple, just offer Hourly, Daily, Weekly, Monthly.
By choosing the plan, plan is in place:
The pattern will be planname-%d i.e. Day-%d, Month-%d etc.

$pattern = $pattern.'-%d'; }
switch ($plan) {
        case 'Daily':
        $cron = '@daily';
        $expiry = "7d";
        break;
        case 'Weekly':
        $cron = '@weekly';
        $expiry = "30d";
        break;
        case 'Monthly':
        $cron = '@monthly';
        $expiry = "90d";
        break;
        case 'delete':
        $cron = "";
        $pattern = "";
        $status = "";
        break;
  }
  $newconfig = [
        'config' => [
            "snapshots.pattern" => $pattern,
    	"snapshots.schedule" => $cron,
    	"snapshots.expiry" => $expiry,
        "snapshots.schedule.stopped" => $status
    ]
  ];

Now I can push multiple plans by "comma separated list of schedule aliases <@hourly> <@daily> <@midnight> <@weekly> :
But later cant assign the created snapshot by name to its parent plan, as pattern is just given once.

Below, by listing the children of each plan, I cant assign them to the plan, which created it, missing the distinct pattern (name) for each snap.

Anything not matching to plan name, is assorted, manually created (Test8, test9) and by now doesnt need really an own pattern! Though would be nice to have too!

Snapshots:
±-------±----------------------±----------------------±---------+
| NAME | TAKEN AT | EXPIRES AT | STATEFUL |
±-------±----------------------±----------------------±---------+
| Day-10 | 2021/09/14 01:25 CEST | 2021/09/21 01:25 CEST | NO |
±-------±----------------------±----------------------±---------+
| Day-11 | 2021/09/15 01:25 CEST | 2021/09/22 01:25 CEST | NO |
±-------±----------------------±----------------------±---------+
| Day-12 | 2021/09/16 01:25 CEST | 2021/09/23 01:25 CEST | NO |
±-------±----------------------±----------------------±---------+
| Day-13 | 2021/09/19 01:25 CEST | 2021/09/26 01:25 CEST | NO |
±-------±----------------------±----------------------±---------+
| Day-14 | 2021/09/20 01:25 CEST | 2021/09/27 01:25 CEST | NO |
±-------±----------------------±----------------------±---------+
| Test8 | 2021/09/07 09:06 CEST | 2021/11/06 08:06 CET | NO |
±-------±----------------------±----------------------±---------+
| test9 | 2021/09/07 09:19 CEST | 2021/11/06 08:19 CET | NO |
±-------±----------------------±----------------------±---------+

auto_snap_1

Would that be passible for the above mentioned case?