systemd timer doesn't work, followed instructions exactly as posted #428

Closed
opened 2021-06-27 19:38:29 +00:00 by jakec-dev · 4 comments

What I'm trying to do and why

Run borgmatic automatically every day

Steps to reproduce (if a bug)

Follow instructions exactly as posted: https://torsion.org/borgmatic/docs/how-to/set-up-backups/

Actual behavior (if a bug)

Running sudo borgmatic in terminal works as expected.

borgmatic.timer is set in systemctl correctly and listed under systemctl list-timers.

systemctl status borgmatic.service shows that it's triggered by the timer.

After the timer is triggered, no new backups are listed under sudo borgmatic --list. Checking systemctl status borgmatic.service returns errors:

× borgmatic.service - borgmatic backup
     Loaded: loaded (/etc/systemd/system/borgmatic.service; static)
     Active: failed (Result: exit-code) since Mon 2021-06-28 05:36:57 AEST; 37s ago
TriggeredBy: ● borgmatic.timer
    Process: 56296 ExecStartPre=sleep 1m (code=exited, status=0/SUCCESS)
    Process: 57005 ExecStart=systemd-inhibit --who=borgmatic --why=Prevent interrupting scheduled backup /root/.local/bin/borgmatic --s>
   Main PID: 57005 (code=exited, status=1/FAILURE)
        CPU: 38ms

Jun 28 05:35:57 JC-PC-ARCH systemd[1]: Starting borgmatic backup...
Jun 28 05:36:57 JC-PC-ARCH systemd-inhibit[57006]: Failed to execute : No such file or directory
Jun 28 05:36:57 JC-PC-ARCH systemd-inhibit[57005]: /root/.local/bin/borgmatic failed with exit status 1.
Jun 28 05:36:57 JC-PC-ARCH systemd[1]: borgmatic.service: Main process exited, code=exited, status=1/FAILURE
Jun 28 05:36:57 JC-PC-ARCH systemd[1]: borgmatic.service: Failed with result 'exit-code'.
Jun 28 05:36:57 JC-PC-ARCH systemd[1]: Failed to start borgmatic backup.

Expected behavior (if a bug)

Backup as normal

Other notes / implementation ideas

Environment

borgmatic version: 1.5.15

borgmatic installation method: sudo pacman -S borgmatic

Borg version: borg 1.1.16

Python version: Python 3.9.5

Database version (if applicable): N/A

operating system and version: Arch Linux (latest release, everything is up to date)

systemd version:

systemd 248 (248.3-2-arch)
+PAM +AUDIT -SELINUX -APPARMOR -IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT -QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified

#### What I'm trying to do and why Run borgmatic automatically every day #### Steps to reproduce (if a bug) Follow instructions exactly as posted: https://torsion.org/borgmatic/docs/how-to/set-up-backups/ #### Actual behavior (if a bug) Running `sudo borgmatic` in terminal works as expected. borgmatic.timer is set in systemctl correctly and listed under `systemctl list-timers`. `systemctl status borgmatic.service` shows that it's triggered by the timer. After the timer is triggered, no new backups are listed under `sudo borgmatic --list`. Checking `systemctl status borgmatic.service` returns errors: ``` × borgmatic.service - borgmatic backup Loaded: loaded (/etc/systemd/system/borgmatic.service; static) Active: failed (Result: exit-code) since Mon 2021-06-28 05:36:57 AEST; 37s ago TriggeredBy: ● borgmatic.timer Process: 56296 ExecStartPre=sleep 1m (code=exited, status=0/SUCCESS) Process: 57005 ExecStart=systemd-inhibit --who=borgmatic --why=Prevent interrupting scheduled backup /root/.local/bin/borgmatic --s> Main PID: 57005 (code=exited, status=1/FAILURE) CPU: 38ms Jun 28 05:35:57 JC-PC-ARCH systemd[1]: Starting borgmatic backup... Jun 28 05:36:57 JC-PC-ARCH systemd-inhibit[57006]: Failed to execute : No such file or directory Jun 28 05:36:57 JC-PC-ARCH systemd-inhibit[57005]: /root/.local/bin/borgmatic failed with exit status 1. Jun 28 05:36:57 JC-PC-ARCH systemd[1]: borgmatic.service: Main process exited, code=exited, status=1/FAILURE Jun 28 05:36:57 JC-PC-ARCH systemd[1]: borgmatic.service: Failed with result 'exit-code'. Jun 28 05:36:57 JC-PC-ARCH systemd[1]: Failed to start borgmatic backup. ``` #### Expected behavior (if a bug) Backup as normal #### Other notes / implementation ideas #### Environment **borgmatic version:** 1.5.15 **borgmatic installation method:** sudo pacman -S borgmatic **Borg version:** borg 1.1.16 **Python version:** Python 3.9.5 **Database version (if applicable):** N/A **operating system and version:** Arch Linux (latest release, everything is up to date) **systemd version:** systemd 248 (248.3-2-arch) +PAM +AUDIT -SELINUX -APPARMOR -IMA +SMACK +SECCOMP +GCRYPT +GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT -QRENCODE +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified
Author

I fixed it. The sample systemd service file (borgmatic.service) is incorrect and causes errors.

Remove/comment out the ExecStartPre line, and change the ExecStart line to:

ExecStart=/usr/bin/borgmatic --syslog-verbosity 1

/root/.local/bin/borgmatic doesn't exist, but even changing to the correct /usr/bin/borgmatic file doesn't fix it. You need to remove the whole systemd-inhibit part also or it won't work.

I also noticed that the service doesn't prune after it's done so I guess you'll need to modify the borgmatic.service file further to get that working too. I'll reply to this comment when I get that sorted too.

I fixed it. The sample systemd service file (borgmatic.service) is incorrect and causes errors. Remove/comment out the `ExecStartPre` line, and change the ExecStart line to: ``` ExecStart=/usr/bin/borgmatic --syslog-verbosity 1 ``` `/root/.local/bin/borgmatic` doesn't exist, but even changing to the correct `/usr/bin/borgmatic` file doesn't fix it. You need to remove the whole systemd-inhibit part also or it won't work. I also noticed that the service doesn't prune after it's done so I guess you'll need to modify the borgmatic.service file further to get that working too. I'll reply to this comment when I get that sorted too.
Owner

Based on the log Failed to execute : No such file or directory, that leads me to think that there's no borgmatic binary at /root/.local/bin/borgmatic. If you did install borgmatic via pacman, then borgmatic will be present at a different location, likely /usr/local/bin. So you may be able to swap the /root/.local/bin/borgmatic in the last line of the sample systemd service file for /usr/local/bin.

Please let me know if that works for you!

Based on the log `Failed to execute : No such file or directory`, that leads me to think that there's no borgmatic binary at `/root/.local/bin/borgmatic`. If you did install borgmatic via `pacman`, then borgmatic will be present at a different location, likely `/usr/local/bin`. So you may be able to swap the `/root/.local/bin/borgmatic` in the last line of the sample systemd service file for `/usr/local/bin`. Please let me know if that works for you!
Author

Ah ok, so it's due to pacman changing the installation directory (and some other issue with systemd-inhibit it seems)?

Perhaps adding a comment to the sample borgmatic.service file about changing the path to /usr/bin/borgmatic if you installed via pacman would be a good addition?

Ah ok, so it's due to pacman changing the installation directory (and some other issue with systemd-inhibit it seems)? Perhaps adding a comment to the sample borgmatic.service file about changing the path to /usr/bin/borgmatic if you installed via pacman would be a good addition?
Owner

The borgmatic package from Arch you installed with pacman actually includes its own systemd service file that refers to /usr/bin/borgmatic! But what I can do is update the borgmatic docs to mention this. Thanks!

The borgmatic package from Arch you installed with `pacman` actually includes its own systemd service file that refers to `/usr/bin/borgmatic`! But what I can do is update the borgmatic docs to mention this. Thanks!
witten added the
question / support
label 2021-06-30 00:54:17 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#428
No description provided.