0

My systemd timer is configured to run ever day at 3:00.

The timer gets triggered only on the first day at 3:00 and systemd list-timers says n/a in the Left or Next column.

borgbackup.timer:

[Unit]
Description=Run Borgbackup daily

[Timer]
OnCalendar=03:00:00
Unit=borgbackup.target

[Install]
WantedBy=timers.target

borgbackup.target

[Unit]
Description=Borgbackup group target
Wants=borgbackup-1.service borgbackup-2.service

[Install]
Also=borgbackup.timer

borgbackup-1.service

[Unit]
Description=Daily Borgbackup
After=network.target

[Service]
Type=simple
Environment=BORG_PASSPHRASE="..."
Environment=BORG_BASE_DIR="/home/borg"
Environment=BORG_REPO="..."
ExecStart=/bin/bash -c "/usr/bin/borg create ::$(date --iso-8601) ..."
ExecStopPost=/usr/bin/borg prune -s -d 1 -w 1 -m 1
WorkingDirectory=/home/borg

[Install]
WantedBy=default.target

The only difference between borgbackup-1 and borgbackup-2 is the repository.

2
  • 1
    AFAICT a target unit doesn't stop when the services it triggered do. And starting an already active unit seems to do nothing. Is there something in your setup meant to stop borgbackup.target? – fra-san Mar 1 at 20:14
  • That was indeed the issue. Adding StopWhenUnneeded=yes solved the issue, thanks! – Unkn0wn Mar 2 at 7:57
0

The OnCalendar needs to be changed right now it reads the next time 3:00 occurs you need to add day of the week, month, etc.. You can also just change it to Daily the syntax for the way you have it would be *-*-* 3:00:00 There is a good section in this link about it.

https://wiki.archlinux.org/index.php/Systemd/Timers#Timer_units

EDIT: You probably also want to look into the persistent option it will run the command the next time the system is booted if the last time it was supposed to run was missed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.