td211
(A. Ismail)
August 9, 2022, 12:49pm
1
I have a systemd timer set to take snapper snapshots daily (snapper defaults to hourly so I disabled timeline snapshots). The problem is that snapper cleanup doesn’t seem to be working, the number of snapshots increases beyond the limit I set and I have to remove old snapshots manually.
Relevant info:
snapper config file:
# subvolume to snapshot
SUBVOLUME="/"
# filesystem type
FSTYPE="btrfs"
# btrfs qgroup for space aware cleanup algorithms
QGROUP=""
# fraction or absolute size of the filesystems space the snapshots may use
SPACE_LIMIT="0.5"
# fraction or absolute size of the filesystems space that should be free
FREE_LIMIT="0.2"
# users and groups allowed to work with config
ALLOW_USERS=""
ALLOW_GROUPS=""
# sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots
# directory
SYNC_ACL="no"
# start comparing pre- and post-snapshot in background after creating
# post-snapshot
BACKGROUND_COMPARISON="yes"
# run daily number cleanup
NUMBER_CLEANUP="yes"
# limit for number cleanup
NUMBER_MIN_AGE="1800"
NUMBER_LIMIT="7"
NUMBER_LIMIT_IMPORTANT="10"
# create hourly snapshots
TIMELINE_CREATE="no"
# cleanup hourly snapshots after some time
TIMELINE_CLEANUP="yes"
# limits for timeline cleanup
TIMELINE_MIN_AGE="1800"
TIMELINE_LIMIT_HOURLY="10"
TIMELINE_LIMIT_DAILY="10"
TIMELINE_LIMIT_WEEKLY="0"
TIMELINE_LIMIT_MONTHLY="10"
TIMELINE_LIMIT_YEARLY="10"
# cleanup empty pre-post-pairs
EMPTY_PRE_POST_CLEANUP="yes"
# limits for empty pre-post-pair cleanup
EMPTY_PRE_POST_MIN_AGE="1800"
Output of systemctl status snapper-cleanup.service
:
○ snapper-cleanup.service - Daily Cleanup of Snapper Snapshots
Loaded: loaded (/usr/lib/systemd/system/snapper-cleanup.service; static)
Active: inactive (dead) since Tue 2022-08-09 15:36:22 EEST; 8min ago
TriggeredBy: ● snapper-cleanup.timer
Docs: man:snapper(8)
man:snapper-configs(5)
Process: 6807 ExecStart=/usr/libexec/snapper/systemd-helper --cleanup (code=exited, status=0/SUCCESS)
Main PID: 6807 (code=exited, status=0/SUCCESS)
CPU: 11ms
Aug 09 15:36:22 <hostname> systemd[1]: Started snapper-cleanup.service - Daily Cleanup of Snapper Snapshots.
Aug 09 15:36:22 <hostname> systemd-helper[6807]: running cleanup for 'Root_snapshot'.
Aug 09 15:36:22 <hostname> systemd-helper[6807]: running number cleanup for 'Root_snapshot'.
Aug 09 15:36:22 <hostname> systemd-helper[6807]: running timeline cleanup for 'Root_snapshot'.
Aug 09 15:36:22 <hostname> systemd-helper[6807]: running empty-pre-post cleanup for 'Root_snapshot'.
Aug 09 15:36:22 <hostname> systemd[1]: snapper-cleanup.service: Deactivated successfully.
Also the list of current snapshots:
sudo snapper -c Root_snapshot list
# | Type | Pre # | Date | User | Cleanup | Description | Userdata
----+--------+-------+----------------------------------+------+---------+-------------+---------
0 | single | | | root | | current |
7 | single | | Mon 01 Aug 2022 06:50:04 PM EEST | root | | 01-08-2022 |
8 | single | | Tue 02 Aug 2022 05:45:32 PM EEST | root | | 02-08-2022 |
9 | single | | Wed 03 Aug 2022 04:04:59 PM EEST | root | | 03-08-2022 |
10 | single | | Thu 04 Aug 2022 06:24:00 PM EEST | root | | 04-08-2022 |
11 | single | | Fri 05 Aug 2022 06:39:01 PM EEST | root | | 05-08-2022 |
12 | single | | Sat 06 Aug 2022 07:40:02 PM EEST | root | | 06-08-2022 |
13 | single | | Sun 07 Aug 2022 08:42:56 AM EEST | root | | 07-08-2022 |
14 | single | | Mon 08 Aug 2022 11:36:25 AM EEST | root | | 08-08-2022 |
15 | single | | Tue 09 Aug 2022 09:04:27 AM EEST | root | | 09-08-2022 |
9 snapshots while I want 7 and running snapper-cleanup manually is doing nothing.
vwbusguy
(Scott Williams)
August 11, 2022, 4:37am
2
I wonder if these are considered “important”, since you have that set to a limit of 10?
remyabel
(Tommy Nguyen)
August 11, 2022, 2:18pm
3
The snapper cleanup algorithm is kind of confusing. These two issues seem to clarify some things but still confusing nonetheless:
opened 02:01PM - 19 Jul 17 UTC
Hello
I'm trying Snapper 0.5 on Debian Testing.
Unfortunately I'm unable to … leverage it fully as it is unable to cleanup old snapshots based on the number algorithm.
Here is some details :
```
sudo snapper list-configs
Config | Subvolume
--------+----------
tv_root | /
sudo snapper -c tv_root get-config
Key | Value
-----------------------+----------
ALLOW_GROUPS |
ALLOW_USERS |
BACKGROUND_COMPARISON | no
EMPTY_PRE_POST_CLEANUP | yes
EMPTY_PRE_POST_MIN_AGE | 1800
FSTYPE | lvm(ext4)
NUMBER_CLEANUP | yes
NUMBER_LIMIT | 2
NUMBER_LIMIT_IMPORTANT | 1
NUMBER_MIN_AGE | 0
QGROUP |
SPACE_LIMIT | 0
SUBVOLUME | /
SYNC_ACL | no
TIMELINE_CLEANUP | yes
TIMELINE_CREATE | yes
TIMELINE_LIMIT_DAILY | 4
TIMELINE_LIMIT_HOURLY | 4
TIMELINE_LIMIT_MONTHLY | 0
TIMELINE_LIMIT_WEEKLY | 2
TIMELINE_LIMIT_YEARLY | 0
TIMELINE_MIN_AGE | 0
```
I've then created a bunch of snapshots. After that I've tried to clean them up :
```
sudo snapper -v -c tv_root cleanup number
```
(no output)
snapper.log :
```
2017-07-19 15:51:02 MIL libsnapper(5931) snapperd.cc(main):275 - Requesting DBus name
2017-07-19 15:51:02 MIL libsnapper(5931) snapperd.cc(main):279 - Loading snapper configs
2017-07-19 15:51:02 MIL libsnapper(5931) Snapper.cc(getConfigs):269 - Snapper get-configs
2017-07-19 15:51:02 MIL libsnapper(5931) Snapper.cc(getConfigs):270 - libsnapper version 0.5.0
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(reload):114 - loading file /etc/default/snapper
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(getValue):235 - key:SNAPPER_CONFIGS value:tv_root
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(reload):114 - loading file /etc/snapper/configs/tv_root
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(getValue):235 - key:SUBVOLUME value:/
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(getValue):235 - key:ALLOW_USERS value:
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(getValue):235 - key:ALLOW_GROUPS value:
2017-07-19 15:51:02 MIL libsnapper(5931) snapperd.cc(main):283 - Listening for method calls and signals
2017-07-19 15:51:02 MIL libsnapper(5931) Snapper.cc(Snapper):91 - Snapper constructor
2017-07-19 15:51:02 MIL libsnapper(5931) Snapper.cc(Snapper):92 - libsnapper version 0.5.0
2017-07-19 15:51:02 MIL libsnapper(5931) Snapper.cc(Snapper):93 - config_name:tv_root disable_filters:false
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(reload):114 - loading file /etc/snapper/configs/tv_root
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(getValue):235 - key:SUBVOLUME value:/
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(getValue):235 - key:FSTYPE value:lvm(ext4)
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(SystemCmd):46 - constructor SystemCmd:"/sbin/lvm version"
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(execute):82 - SystemCmd Executing:"/sbin/lvm version"
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 1 " LVM version: 2.02.168(2) (2016-11-30)"
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 2 " Library version: 1.02.137 (2016-11-30)"
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 3 " Driver version: 4.35.0"
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(getUntilEOF):487 - pid:5933 added lines:3 stderr:false
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(doExecute):267 - stopwatch 0.002684s for "/sbin/lvm version"
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(doExecute):287 - system() Returns:0
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(SystemCmd):46 - constructor SystemCmd:"/sbin/lvs --noheadings -o lv_name,lv_attr,segtype 'CASSIOPEE_VG1'"
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(execute):82 - SystemCmd Executing:"/sbin/lvs --noheadings -o lv_name,lv_attr,segtype 'CASSIOPEE_VG1'"
< MANUALLY DELETED LINES >
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 23 " THIN_POOL twi-aot--- thin-pool"
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 24 " TV_HOME Vwi-aot--- thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 25 " TV_ROOT_TESTING Vwi-aot--- thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 26 " TV_ROOT_TESTING-snapshot1 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 27 " TV_ROOT_TESTING-snapshot10 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 28 " TV_ROOT_TESTING-snapshot11 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 29 " TV_ROOT_TESTING-snapshot12 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 30 " TV_ROOT_TESTING-snapshot13 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 31 " TV_ROOT_TESTING-snapshot14 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 32 " TV_ROOT_TESTING-snapshot2 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 33 " TV_ROOT_TESTING-snapshot3 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 34 " TV_ROOT_TESTING-snapshot4 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 35 " TV_ROOT_TESTING-snapshot5 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 36 " TV_ROOT_TESTING-snapshot6 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 37 " TV_ROOT_TESTING-snapshot7 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 38 " TV_ROOT_TESTING-snapshot8 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 39 " TV_ROOT_TESTING-snapshot9 Vri---t--k thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(addLine):523 - Adding Line 40 " TV_SWAP Vwi-aot--- thin "
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(getUntilEOF):487 - pid:5935 added lines:40 stderr:false
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(doExecute):267 - stopwatch 0.012132s for "/sbin/lvs --noheadings -o lv_name,lv_attr,segtype 'CASSIOPEE_VG1'"
2017-07-19 15:51:02 MIL libsnapper(5931) SystemCmd.cc(doExecute):287 - system() Returns:0
2017-07-19 15:51:02 MIL libsnapper(5931) AsciiFile.cc(getValue):235 - key:SYNC_ACL value:no
2017-07-19 15:51:02 MIL libsnapper(5931) Snapper.cc(Snapper):125 - subvolume:/ filesystem:lvm(ext4)
2017-07-19 15:51:02 MIL libsnapper(5931) Snapper.cc(loadIgnorePatterns):174 - number of ignore patterns:8
2017-07-19 15:51:02 MIL libsnapper(5931) Snapshot.cc(read):245 - found 15 snapshots
2017-07-19 15:51:32 MIL libsnapper(5931) Snapper.cc(~Snapper):136 - Snapper destructor
2017-07-19 15:52:02 MIL libsnapper(5931) snapperd.cc(main):287 - Exiting
```
I then tried to express the limit in a different way but this time I got another error :
```
sudo snapper -v -c tv_root set-config NUMBER_LIMIT=2-10
sudo snapper -v -c tv_root cleanup number
quota not working (quota only supported with btrfs)
```
snapper.log :
```
2017-07-19 15:57:02 MIL libsnapper(6006) Snapper.cc(Snapper):125 - subvolume:/ filesystem:lvm(ext4)
2017-07-19 15:57:02 MIL libsnapper(6006) Snapper.cc(loadIgnorePatterns):174 - number of ignore patterns:8
2017-07-19 15:57:02 MIL libsnapper(6006) Snapshot.cc(read):245 - found 15 snapshots
2017-07-19 15:57:02 WAR libsnapper(6006) Snapper.cc(prepareQuota):692 - THROW: quota only supported with btrfs
2017-07-19 15:57:02 WAR libsnapper(6006) Client.cc(dispatch):1670 - CAUGHT: quota only supported with btrfs
2017-07-19 15:57:32 MIL libsnapper(6006) Snapper.cc(~Snapper):136 - Snapper destructor
```
The timeline cleanup algorithm is however apparently doing fine.
dud
opened 06:18AM - 29 Nov 17 UTC
Hello
This is probably related to #350.
Evidence:
```
# snapper -c home … get-config | grep HOURLY
TIMELINE_LIMIT_HOURLY | 10
# snapper -c home ls | tail -n15
single | 9229 | | Tue Nov 28 07:00:22 2017 | root | timeline | timeline |
single | 9230 | | Tue Nov 28 08:00:01 2017 | root | timeline | timeline |
single | 9231 | | Tue Nov 28 09:00:02 2017 | root | timeline | timeline |
single | 9232 | | Tue Nov 28 10:00:01 2017 | root | timeline | timeline |
single | 9233 | | Tue Nov 28 11:00:01 2017 | root | timeline | timeline |
single | 9234 | | Tue Nov 28 12:00:02 2017 | root | timeline | timeline |
single | 9235 | | Tue Nov 28 13:00:01 2017 | root | timeline | timeline |
single | 9236 | | Tue Nov 28 14:00:01 2017 | root | timeline | timeline |
single | 9237 | | Tue Nov 28 15:00:01 2017 | root | timeline | timeline |
single | 9238 | | Tue Nov 28 16:00:01 2017 | root | timeline | timeline |
single | 9239 | | Tue Nov 28 17:00:01 2017 | root | timeline | timeline |
single | 9240 | | Tue Nov 28 19:15:01 2017 | root | timeline | timeline |
single | 9241 | | Tue Nov 28 20:15:02 2017 | root | timeline | timeline |
single | 9242 | | Tue Nov 28 21:15:01 2017 | root | timeline | timeline |
single | 9243 | | Tue Nov 28 22:15:01 2017 | root | timeline | timeline |
```
Note how there are 15 snapshots on this config limited to 10 hourly snapshots.
It gets worse:
```
# snapper -c data get-config | grep HOURLY
TIMELINE_LIMIT_HOURLY | 10
# snapper -c data ls | tail -n33
single | 41 | | Mon Nov 27 14:00:02 2017 | root | timeline | timeline |
single | 42 | | Mon Nov 27 15:00:02 2017 | root | timeline | timeline |
single | 43 | | Mon Nov 27 16:00:02 2017 | root | timeline | timeline |
single | 44 | | Mon Nov 27 17:00:02 2017 | root | timeline | timeline |
single | 45 | | Mon Nov 27 18:00:03 2017 | root | timeline | timeline |
single | 46 | | Mon Nov 27 19:00:03 2017 | root | timeline | timeline |
single | 47 | | Mon Nov 27 20:00:10 2017 | root | timeline | timeline |
single | 48 | | Mon Nov 27 21:00:02 2017 | root | timeline | timeline |
single | 49 | | Mon Nov 27 22:00:01 2017 | root | timeline | timeline |
single | 50 | | Mon Nov 27 23:00:02 2017 | root | timeline | timeline |
single | 51 | | Tue Nov 28 00:00:03 2017 | root | timeline | timeline |
single | 52 | | Tue Nov 28 01:00:02 2017 | root | timeline | timeline |
single | 53 | | Tue Nov 28 02:00:02 2017 | root | timeline | timeline |
single | 54 | | Tue Nov 28 03:00:02 2017 | root | timeline | timeline |
single | 55 | | Tue Nov 28 04:00:02 2017 | root | timeline | timeline |
single | 56 | | Tue Nov 28 05:00:01 2017 | root | timeline | timeline |
single | 57 | | Tue Nov 28 06:00:02 2017 | root | timeline | timeline |
single | 58 | | Tue Nov 28 07:00:02 2017 | root | timeline | timeline |
single | 59 | | Tue Nov 28 08:00:02 2017 | root | timeline | timeline |
single | 60 | | Tue Nov 28 09:00:02 2017 | root | timeline | timeline |
single | 61 | | Tue Nov 28 10:00:02 2017 | root | timeline | timeline |
single | 62 | | Tue Nov 28 11:00:02 2017 | root | timeline | timeline |
single | 63 | | Tue Nov 28 12:00:02 2017 | root | timeline | timeline |
single | 64 | | Tue Nov 28 13:00:02 2017 | root | timeline | timeline |
single | 65 | | Tue Nov 28 14:00:02 2017 | root | timeline | timeline |
single | 66 | | Tue Nov 28 15:00:03 2017 | root | timeline | timeline |
single | 67 | | Tue Nov 28 16:00:02 2017 | root | timeline | timeline |
single | 68 | | Tue Nov 28 17:00:02 2017 | root | timeline | timeline |
single | 69 | | Tue Nov 28 18:00:02 2017 | root | timeline | timeline |
single | 70 | | Tue Nov 28 19:00:02 2017 | root | timeline | timeline |
single | 71 | | Tue Nov 28 20:00:11 2017 | root | timeline | timeline |
single | 72 | | Tue Nov 28 21:00:02 2017 | root | timeline | timeline |
single | 73 | | Tue Nov 28 22:00:02 2017 | root | timeline | timeline |
```
This one has 33 snapshots and does not even have the excuse of a daily cron job not yet run.
```
# snapper get-config | grep HOURLY
TIMELINE_LIMIT_HOURLY | 6
# snapper ls | tail -n29
single | 84 | | Mon Nov 27 18:00:02 2017 | root | timeline | timeline |
single | 85 | | Mon Nov 27 19:00:02 2017 | root | timeline | timeline |
single | 86 | | Mon Nov 27 20:00:02 2017 | root | timeline | timeline |
single | 87 | | Mon Nov 27 21:00:01 2017 | root | timeline | timeline |
single | 88 | | Mon Nov 27 22:00:01 2017 | root | timeline | timeline |
single | 89 | | Mon Nov 27 23:00:01 2017 | root | timeline | timeline |
single | 90 | | Tue Nov 28 00:00:01 2017 | root | timeline | timeline |
single | 91 | | Tue Nov 28 01:00:01 2017 | root | timeline | timeline |
single | 92 | | Tue Nov 28 02:00:01 2017 | root | timeline | timeline |
single | 93 | | Tue Nov 28 03:00:01 2017 | root | timeline | timeline |
single | 94 | | Tue Nov 28 04:00:01 2017 | root | timeline | timeline |
single | 95 | | Tue Nov 28 05:00:01 2017 | root | timeline | timeline |
single | 96 | | Tue Nov 28 06:00:01 2017 | root | timeline | timeline |
single | 97 | | Tue Nov 28 07:00:01 2017 | root | timeline | timeline |
single | 98 | | Tue Nov 28 08:00:01 2017 | root | timeline | timeline |
single | 99 | | Tue Nov 28 09:00:02 2017 | root | timeline | timeline |
single | 100 | | Tue Nov 28 10:00:01 2017 | root | timeline | timeline |
single | 101 | | Tue Nov 28 11:00:01 2017 | root | timeline | timeline |
single | 102 | | Tue Nov 28 12:00:01 2017 | root | timeline | timeline |
single | 103 | | Tue Nov 28 13:00:01 2017 | root | timeline | timeline |
single | 104 | | Tue Nov 28 14:00:01 2017 | root | timeline | timeline |
single | 105 | | Tue Nov 28 15:00:02 2017 | root | timeline | timeline |
single | 106 | | Tue Nov 28 16:00:01 2017 | root | timeline | timeline |
single | 107 | | Tue Nov 28 17:00:01 2017 | root | timeline | timeline |
single | 108 | | Tue Nov 28 18:00:01 2017 | root | timeline | timeline |
single | 109 | | Tue Nov 28 19:00:01 2017 | root | timeline | timeline |
single | 110 | | Tue Nov 28 20:00:01 2017 | root | timeline | timeline |
single | 111 | | Tue Nov 28 21:00:01 2017 | root | timeline | timeline |
single | 112 | | Tue Nov 28 22:00:01 2017 | root | timeline | timeline |
```
This one also has more than a full day and is configured for only 6 snapshots.
td211
(A. Ismail)
August 11, 2022, 3:05pm
4
I think I will either switch to btrbk or make my own snapper cleanup script.