Schnapps deletes old snapshots

Hi,
after I switched my storage to SSD (This topic) , now I got a problem with the schnapps snapshots.

Every week schnapps - triggerd by the cronjob - deletes the last snapshot, even the schnapps config is set to option max_single '-1'.

root@FW:/# schnapps list
    # | Type      | Size        | Date                      | Description
------+-----------+-------------+---------------------------+------------------------------------
    6 | time      |     7.92MiB | 2023-12-03 01:05:02 +0100 | Snapshot created by cron

This are the config of my Turris, which seams to be default settings:

root@FW:/# cat /etc/config/schnapps 
config keep 'keep'
        option max_single '-1'
        option max_time '5'
        option max_updater '5'
        option max_rollback '3'

config remote 'remote'
#        option url 'nextcloud://cloud.example.com'|'webdav://dav.example.com'
#        option path '/turris/backups'
#        option user 'myself'
#        option password 'password'
        option sync_types 'single,time'

#config encrypt 'encrypt'
#        option pass 'password'

root@FW:/# cat /etc/cron.d/schnapps 
MAILTO=""
# m h    dom mon dow  user  command
  5 */12  *   *   *   root  schnapps cleanup
  5 1     *   *   0   root  schnapps create -t time "Snapshot created by cron"
  5 2     *   *   0   root  schnapps cleanup --compare

The syslog tells that previous snapshot got deleted:

Dec  3 00:05:01 FW crond[23308]: (root) CMD (schnapps create -t time "Snapshot created by cron")
Dec  3 00:05:02 FW crond[23305]: (root) CMDOUT (There is no message to send.)
Dec  3 00:05:02 FW crond[23305]: (root) CMDEND (/usr/bin/notifier)
Dec  3 00:05:02 FW crond[23306]: (root) CMDOUT (Snapshot number 6 created)
Dec  3 00:05:02 FW crond[23306]: (root) CMDEND (schnapps create -t time "Snapshot created by cron")
....
Dec  3 01:05:01 FW crond[29413]: (root) CMD (schnapps cleanup --compare)
Dec  3 01:05:01 FW crond[29410]: (root) CMDOUT (There is no message to send.)
Dec  3 01:05:01 FW crond[29411]: (root) CMDOUT (Searching for snapshots without any change.)
Dec  3 01:05:01 FW crond[29411]: (root) CMDOUT (This can take a while, please be patient.)
Dec  3 01:05:01 FW crond[29411]: (root) CMDOUT ()
Dec  3 01:05:01 FW crond[29410]: (root) CMDEND (/usr/bin/notifier)
Dec  3 01:05:01 FW crond[29411]: (root) CMDOUT ( * checking snaphot 6...)
Dec  3 01:05:20 FW crond[29411]: (root) CMDOUT (   - Snapshot 5 deleted.)
Dec  3 01:05:20 FW crond[29411]: (root) CMDOUT (Looking for old snapshots...)
Dec  3 01:05:20 FW crond[29411]: (root) CMDEND (schnapps cleanup --compare)

After the storage switch to SSD I created the first snapshot manually:

root@FW:/# schnapps list
    # | Type      | Size        | Date                      | Description
------+-----------+-------------+---------------------------+------------------------------------
    1 | single    |    16.00KiB | 2023-11-01 11:03:47 +0100 | Clean-Default-Post-Uboot-Update-Setup-20231101

I’m wondering why schnapps deletes the snapshots?
Is there something I miss?

Hi, I tried to create multiple single (manual) snapshots and then to run schnapps delete --compare and it worked as expected. If a snapshot didn’t contain any change, the previous one was deleted if favor the newer one. If any changes were there the previous snapshot wasn’t deleted.

Your snapshot 5 was deleted probably due to absence of any changes in 6. The max_single option has no effect in this case. But the information provided by schnapps help (or schnapps) is misleading and should be changed - schnapps deletes older snapshots in such cases. I’ll create an issue or a patch for this.

2 Likes

Hi Lukáš,
that seems logical. Since the switch to SSD and the manually snapshot I haven’t changed anything at config level. So it is likely that there was no changes between.

I done the same test like you and all the previous snaphots got deleted:

root@FW:~# schnapps list
    # | Type      | Size        | Date                      | Description
------+-----------+-------------+---------------------------+------------------------------------
    6 | time      |     7.97MiB | 2023-12-03 01:05:02 +0100 | Snapshot created by cron
    7 | single    |     7.97MiB | 2023-12-06 11:30:18 +0100 | Snapshot-Backup-Custom-20231206
    8 | single    |    16.00KiB | 2023-12-06 11:34:06 +0100 | Snapshot-Backup-Custom-20231206-2
root@FW:~# schnapps cleanup --compare
Searching for snapshots without any change.
This can take a while, please be patient.

 * checking snaphot 7...
   - Snapshot 6 deleted.
 * checking snaphot 8...
   - Snapshot 7 deleted.
Looking for old snapshots...
root@FW:~# schnapps list
    # | Type      | Size        | Date                      | Description
------+-----------+-------------+---------------------------+------------------------------------
    8 | single    |     7.92MiB | 2023-12-06 11:34:06 +0100 | Snapshot-Backup-Custom-20231206-2

In case of time snapshots. This option max_time '5' get triggered only, when there are differences between the snapshots?

I wonder, because I remember - before the switch to SSD - snapshots created by cron wasn’t deleted every week. Even there was no config changes or updates made. Sometimes there where 3-4 weekly time snapshots in a row. I haven’t saved any screenshot or console output of this to show, but I deleted such snapshot frequently.

In case of time snapshots. This option max_time '5' get triggered only, when there are differences between the snapshots?

Yes, regardless of snapshot types, these limits apply only when there are differences.

I wonder, because I remember - before the switch to SSD - snapshots created by cron wasn’t deleted every week. Even there was no config changes or updates made.

I don’t know whether the switch can change the behavior. It surely doesn’t affect the schnapps itself but may affect the files that are snapshotted.

Maybe the uBoot update from U-Boot SPL 2015.10-rc2 to U-Boot SPL 2022.10-rc4-OpenWrt-r16653+119-44ce70f0e2 had an affect.

Anyway. I can live with this scenario now. My schnapps list looks like this now. Just changed the config lightly after the first snapshot.

root@FW:~# schnapps list
    # | Type      | Size        | Date                      | Description
------+-----------+-------------+---------------------------+------------------------------------
    1 | single    |     7.98MiB | 2023-12-06 13:04:54 +0100 | Clean-Default-Post-Uboot-Update-Setup-20231206
    3 | time      |     7.92MiB | 2023-12-10 01:05:01 +0100 | Snapshot created by cron

I also mark snapshots as clean after something and then I delete all previous…

But then I regret. There is plenty of space to keep more than a few. Just in case

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.