Skip to content

Commit c411bc2

Browse files
committed
snapper: keep 6 hourly + 10 numbered, drop daily/weekly/monthly
Shorter retention to align with other process changes. Hourly cap drops from 10 to 6, daily/weekly/monthly/yearly all disabled, and NUMBER_LIMIT pinned at 10 (was the snapper default of 50) so manual and pre-/post- snapshots have a known ceiling too. Applies to both the root and postgres snapper configs.
1 parent 655a61f commit c411bc2

4 files changed

Lines changed: 30 additions & 19 deletions

File tree

docs/GUIDE-IMAGES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Simple quotas are enabled to track per-subvolume disk usage.
117117

118118
Transparent filesystem compression is enabled system-wide.
119119

120-
The Snapper snapshot manager is enabled by default, which takes snapshots of the subvolumes hourly and retains them for default 10 hours / 7 days / 4 weeks / 12 months periods.
120+
The Snapper snapshot manager is enabled by default, which takes hourly snapshots of the subvolumes and retains the last 6 hourly snapshots, plus up to 10 numbered (manual / pre-/post-) snapshots.
121121
This provides a simple way to rollback a server or a file to an earlier configuration and protects against catastrophes.
122122

123123
The system partition can be grown or shrunk while online.

docs/spec/disk-images.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ A weekly cron job must be present to run `apt install -y tailscale`.
238238

239239
r[image.snapper.root]
240240
Snapper must be configured for the root subvolume (`/`) with timeline
241-
snapshots enabled and retention of 10 hourly, 7 daily, 4 weekly, and
242-
12 monthly snapshots.
241+
snapshots enabled and retention of 6 hourly snapshots, plus 10 numbered
242+
(non-timeline) snapshots. Daily, weekly, monthly, and yearly timeline
243+
retention must be disabled.
243244

244245
r[image.snapper.postgres]
245246
Snapper must be configured for the PostgreSQL subvolume

image/scripts/setup-snapper.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ snapper --no-dbus -c root set-config \
1111
TIMELINE_CREATE=yes \
1212
TIMELINE_CLEANUP=yes \
1313
NUMBER_CLEANUP=yes \
14-
TIMELINE_LIMIT_HOURLY=10 \
15-
TIMELINE_LIMIT_DAILY=7 \
16-
TIMELINE_LIMIT_WEEKLY=4 \
17-
TIMELINE_LIMIT_MONTHLY=12
14+
NUMBER_LIMIT=10 \
15+
TIMELINE_LIMIT_HOURLY=6 \
16+
TIMELINE_LIMIT_DAILY=0 \
17+
TIMELINE_LIMIT_WEEKLY=0 \
18+
TIMELINE_LIMIT_MONTHLY=0 \
19+
TIMELINE_LIMIT_YEARLY=0
1820

1921
# r[image.snapper.postgres]: Configure snapper for the PostgreSQL subvolume
2022
mkdir -p /var/lib/postgresql
@@ -23,10 +25,12 @@ snapper --no-dbus -c postgres set-config \
2325
TIMELINE_CREATE=yes \
2426
TIMELINE_CLEANUP=yes \
2527
NUMBER_CLEANUP=yes \
26-
TIMELINE_LIMIT_HOURLY=10 \
27-
TIMELINE_LIMIT_DAILY=7 \
28-
TIMELINE_LIMIT_WEEKLY=4 \
29-
TIMELINE_LIMIT_MONTHLY=12
28+
NUMBER_LIMIT=10 \
29+
TIMELINE_LIMIT_HOURLY=6 \
30+
TIMELINE_LIMIT_DAILY=0 \
31+
TIMELINE_LIMIT_WEEKLY=0 \
32+
TIMELINE_LIMIT_MONTHLY=0 \
33+
TIMELINE_LIMIT_YEARLY=0
3034

3135
# r[image.snapper.timers]: Enable snapper timers
3236
systemctl enable snapper-timeline.timer

tests/test-image-structure.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,13 @@ check "snapper root config exists" test -f "$SNAPPER_ROOT_CFG"
436436
if [ -f "$SNAPPER_ROOT_CFG" ]; then
437437
check "snapper root: TIMELINE_CREATE=yes" grep -q '^TIMELINE_CREATE="yes"' "$SNAPPER_ROOT_CFG"
438438
check "snapper root: TIMELINE_CLEANUP=yes" grep -q '^TIMELINE_CLEANUP="yes"' "$SNAPPER_ROOT_CFG"
439-
check "snapper root: TIMELINE_LIMIT_HOURLY=10" grep -q '^TIMELINE_LIMIT_HOURLY="10"' "$SNAPPER_ROOT_CFG"
440-
check "snapper root: TIMELINE_LIMIT_DAILY=7" grep -q '^TIMELINE_LIMIT_DAILY="7"' "$SNAPPER_ROOT_CFG"
441-
check "snapper root: TIMELINE_LIMIT_WEEKLY=4" grep -q '^TIMELINE_LIMIT_WEEKLY="4"' "$SNAPPER_ROOT_CFG"
442-
check "snapper root: TIMELINE_LIMIT_MONTHLY=12" grep -q '^TIMELINE_LIMIT_MONTHLY="12"' "$SNAPPER_ROOT_CFG"
439+
check "snapper root: NUMBER_CLEANUP=yes" grep -q '^NUMBER_CLEANUP="yes"' "$SNAPPER_ROOT_CFG"
440+
check "snapper root: NUMBER_LIMIT=10" grep -q '^NUMBER_LIMIT="10"' "$SNAPPER_ROOT_CFG"
441+
check "snapper root: TIMELINE_LIMIT_HOURLY=6" grep -q '^TIMELINE_LIMIT_HOURLY="6"' "$SNAPPER_ROOT_CFG"
442+
check "snapper root: TIMELINE_LIMIT_DAILY=0" grep -q '^TIMELINE_LIMIT_DAILY="0"' "$SNAPPER_ROOT_CFG"
443+
check "snapper root: TIMELINE_LIMIT_WEEKLY=0" grep -q '^TIMELINE_LIMIT_WEEKLY="0"' "$SNAPPER_ROOT_CFG"
444+
check "snapper root: TIMELINE_LIMIT_MONTHLY=0" grep -q '^TIMELINE_LIMIT_MONTHLY="0"' "$SNAPPER_ROOT_CFG"
445+
check "snapper root: TIMELINE_LIMIT_YEARLY=0" grep -q '^TIMELINE_LIMIT_YEARLY="0"' "$SNAPPER_ROOT_CFG"
443446
fi
444447

445448
# r[verify image.snapper.postgres]
@@ -448,10 +451,13 @@ check "snapper postgres config exists" test -f "$SNAPPER_PG_CFG"
448451
if [ -f "$SNAPPER_PG_CFG" ]; then
449452
check "snapper postgres: TIMELINE_CREATE=yes" grep -q '^TIMELINE_CREATE="yes"' "$SNAPPER_PG_CFG"
450453
check "snapper postgres: TIMELINE_CLEANUP=yes" grep -q '^TIMELINE_CLEANUP="yes"' "$SNAPPER_PG_CFG"
451-
check "snapper postgres: TIMELINE_LIMIT_HOURLY=10" grep -q '^TIMELINE_LIMIT_HOURLY="10"' "$SNAPPER_PG_CFG"
452-
check "snapper postgres: TIMELINE_LIMIT_DAILY=7" grep -q '^TIMELINE_LIMIT_DAILY="7"' "$SNAPPER_PG_CFG"
453-
check "snapper postgres: TIMELINE_LIMIT_WEEKLY=4" grep -q '^TIMELINE_LIMIT_WEEKLY="4"' "$SNAPPER_PG_CFG"
454-
check "snapper postgres: TIMELINE_LIMIT_MONTHLY=12" grep -q '^TIMELINE_LIMIT_MONTHLY="12"' "$SNAPPER_PG_CFG"
454+
check "snapper postgres: NUMBER_CLEANUP=yes" grep -q '^NUMBER_CLEANUP="yes"' "$SNAPPER_PG_CFG"
455+
check "snapper postgres: NUMBER_LIMIT=10" grep -q '^NUMBER_LIMIT="10"' "$SNAPPER_PG_CFG"
456+
check "snapper postgres: TIMELINE_LIMIT_HOURLY=6" grep -q '^TIMELINE_LIMIT_HOURLY="6"' "$SNAPPER_PG_CFG"
457+
check "snapper postgres: TIMELINE_LIMIT_DAILY=0" grep -q '^TIMELINE_LIMIT_DAILY="0"' "$SNAPPER_PG_CFG"
458+
check "snapper postgres: TIMELINE_LIMIT_WEEKLY=0" grep -q '^TIMELINE_LIMIT_WEEKLY="0"' "$SNAPPER_PG_CFG"
459+
check "snapper postgres: TIMELINE_LIMIT_MONTHLY=0" grep -q '^TIMELINE_LIMIT_MONTHLY="0"' "$SNAPPER_PG_CFG"
460+
check "snapper postgres: TIMELINE_LIMIT_YEARLY=0" grep -q '^TIMELINE_LIMIT_YEARLY="0"' "$SNAPPER_PG_CFG"
455461
fi
456462

457463
# ============================================================

0 commit comments

Comments
 (0)