After hardening the unit with `ProtectSystem=strict`, the backup fails with `tar: /var/backups/opskit/etc-20261109.tar.gz: Cannot open: Read-only file system`.
AdvancedTroubleshootingTroubleshooting: cron and systemd timers
Answer
Likely causes → ProtectSystem=strict mounts the entire filesystem read-only for the service, except /dev, /proc and /sys and paths you explicitly allow. The script's output and state directories were not whitelisted. ProtectHome=yes and PrivateTmp=yes cause similar surprises for /home and /tmp.
Diagnose →
systemctl show opskit-backup -p ProtectSystem -p ReadWritePaths -p PrivateTmp
systemd-analyze security opskit-backup.service | head -20
Fix → Grant write access only where the script writes:
[Service]
ProtectSystem=strict
ReadWritePaths=/var/backups/opskit
StateDirectory=opskit # creates /var/lib/opskit, writable, owned by User=
LogsDirectory=opskit # /var/log/opskit
PrivateTmp=yes
Prevent → Add sandboxing incrementally and run the job manually after each change with systemctl start (not by calling the script directly, which bypasses the sandbox).
More on Troubleshooting: cron and systemd timers
A new job in `/etc/cron.d/opskit` never runs. Syslog shows `cron[812]: (*system*opskit) ERROR (Missing newline before EOF, this crontab file will be ignored)`.BeginnerYou copied a line from `crontab -e` into `/etc/cron.d/backup`, and syslog shows `Error: bad username; while reading /etc/cron.d/backup`. Meanwhile a teammate's user crontab mails `/bin/sh: 1: root: not found` every night.BeginnerA script works when you run it, but the cron log email says `/opt/opskit/bin/backup.sh: line 22: aws: command not found`.BeginnerThis crontab line never produces a log file, and cron mails `/bin/sh: 1: Syntax error: end of file unexpected (expecting ")")`: `0 2 * * * /opt/backup.sh > /var/log/backup-$(date +%F).log 2>&1`IntermediateA cron job fails intermittently, but there are no emails and no logs. Syslog shows `(CRON) info (No MTA installed, discarding output)`.BeginnerA cron job that runs `docker exec -it db pg_dumpall` fails with `the input device is not a TTY`.Intermediate