Appearance
NAS log retention
Issue #258, ADR 0026: app logs are kept for no more than 30 days. Docker rotates the containers' logs by size only, so infra/nas/logs/getmy-books-log-retention runs every night as root. For each container in the getmy-books compose project, it reads the oldest log line. Once that line is 29 days old, it empties all of that container's logs: the live log is truncated in place, and the rotated files are deleted. Each run prints one line per container (kept, emptied or empty).
So at any time a container holds between 0 and 29 days of logs, and up to 29 days go at once, including the refused-email lines ADR 0026 mentions. Anything that needs action is alerted through ntfy when it happens (docs/plans/alerting.md), so nothing depends on old log lines. A container whose log can't be read is reported as error and left as it is; the run carries on with the others and then fails, so the task shows the failure.
Install (owner, once)
The script runs as root, so a NAS administrator installs it.
Copy the script to the NAS and install it root-owned, from a checkout of main:
bashscp infra/nas/logs/getmy-books-log-retention nas:/tmp/ ssh nas 'sudo install -o root -g root -m 0755 /tmp/getmy-books-log-retention /usr/local/sbin/getmy-books-log-retention && rm /tmp/getmy-books-log-retention'Run it once by hand and check the output:
bashssh nas 'sudo /usr/local/sbin/getmy-books-log-retention'Expect one line for each of
getmy-books-app-1,getmy-books-postgres-1andgetmy-books-cloudflared-1. Postgres sayskeptuntil its oldest line, from 29 Sept 2026, is 29 days old (28 Oct 2026). From then on it saysemptied.In DSM, open Control Panel → Task Scheduler → Create → Scheduled Task → User-defined script:
General: task name
GetMy Books log retention, user root, enabled.Schedule: daily, first run at 03:15, after the 02:30 backup.
Task Settings: under "Send run details by email", tick "only when the script terminates abnormally" if mail is set up. Run command:
bash/usr/local/sbin/getmy-books-log-retentionDSM keeps each run's output under Action → View result, so nothing else needs to hold it.
Click OK, then select the task and click Run once. Check the result under Action → View result.
Updating
When the script changes on main, repeat step 1. The scheduled task keeps pointing at /usr/local/sbin/getmy-books-log-retention.