Skip to content

replace cronjob with systemd timer#4

Merged
missytake merged 12 commits intomainfrom
systemd-timer
Dec 9, 2025
Merged

replace cronjob with systemd timer#4
missytake merged 12 commits intomainfrom
systemd-timer

Conversation

@missytake
Copy link
Contributor

@missytake missytake commented Nov 12, 2025

This PR enables us to better inspect if the last backup job went wrong, and why.

  • it replaces cronjobs with systemd units + timers
  • fixes the return code handling in both backup.sh and the backup-pre.py template
  • gets rid of the second backup destination, it was never really supported or used anyway
  • uses the BORG_REPO env variable, which is used implicitly by borgbackup
  • adds a CI job for linting

@missytake
Copy link
Contributor Author

Also, we can now just query for the systemd status in grafana to create alerts:

image

We don't even need an instance-specific alert anymore.

@missytake missytake requested a review from link2xt November 17, 2025 10:31
@missytake
Copy link
Contributor Author

Ugh, borg exits with rc 1 on a warning: https://borgbackup.readthedocs.io/en/stable/usage/general.html#return-codes

do we want to get alerted by a warning already? In this case it was:

Nov 17 12:04:06 b1 backup.sh[2439766]: /home/link2xt/src/chatmail/core/.flake.nix.swp: stat: [Errno 2] No such file or directory: '.flake.nix.swp'
Nov 17 12:28:41 b1 backup.sh[2439766]: /var/log/journal/1ec4b78cfcad4e9395e37efdeee1f9f6/system.journal: file changed while we backed it up
Nov 17 12:29:34 b1 backup.sh[2439766]: /var/log/syslog: file changed while we backed it up
Nov 17 12:33:00 b1 backup.sh[2439766]: /var/lib/prometheus/metrics2/wal/00006937: file changed while we backed it up

@hpk42
Copy link

hpk42 commented Nov 17, 2025 via email

@link2xt
Copy link

link2xt commented Nov 17, 2025

If current alerting based on time since last successful backup works fine, then we can keep it and not worry about warnings.

@missytake
Copy link
Contributor Author

No, warnings should not cause alerts IMO.

yeah, after the alerts of last night I agree.

@missytake missytake requested a review from link2xt November 18, 2025 10:16
@missytake
Copy link
Contributor Author

If current alerting based on time since last successful backup works fine, then we can keep it and not worry about warnings.

It doesn't work atm, and systemd-based alerting is much better in any case, as we don't need to configure an alert for every single host. We literally just need to deploy this with pyinfra on more hosts now, and then we get an alert if a backup failed.

And I wrote a wrapper function in bash to not fail if borg has return code 1.

@missytake missytake requested a review from j4n December 7, 2025 08:42
Copy link
Contributor

@j4n j4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, we should really remove the set -x in backup.sh.j2 though, see above comment. Test run worked fine here.

@missytake missytake merged commit 974395a into main Dec 9, 2025
1 check passed
This was referenced Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants