systemd service used for scheduling does not work #329

Closed
opened 2020-06-17 07:25:12 +00:00 by flistell · 3 comments

What I'm trying to do and why

I followed the guide to install systemd borgmatic.service and borgmatic.timer by installing the following service unit:

[Unit]
Description=borgmatic backup
Wants=network-online.target
After=network-online.target
ConditionACPower=true

[Service]
Type=oneshot
Nice=19
CPUSchedulingPolicy=batch
IOSchedulingClass=best-effort
IOSchedulingPriority=7
#IOWeight=100

Restart=no
# Prevent rate limiting of borgmatic log events. If you are using an older version of systemd that
# doesn't support this (pre-240 or so), you may have to remove this option.
#LogRateLimitIntervalSec=0
SyslogIdentifier=borgmatic
StandardOutput=journal
StandardError=journal

# Delay start to prevent backups running during boot. Note that systemd-inhibit requires dbus and
# dbus-user-session to be installed.
ExecStartPre=/usr/bin/sleep 1m
ExecStart=/usr/bin/systemd-inhibit --who="borgmatic" --why="Prevent interrupting scheduled backup" /root/.local/bin/borgmatic -v 2 --log-file /tmp/borgmatic.log --log-file-verbosity 2

If I run the command sudo /usr/bin/systemd-inhibit --who="borgmatic" --why="Prevent interrupting scheduled backup" /root/.local/bin/borgmatic -v 2 --log-file /tmp/borgmatic.log --log-file-verbosity 2 on command line, everythin works fine.

If I run sudo systemctl start borgmatic it fails. The journal shows these messages:

giu 17 09:04:20 myhost systemd[12377]: Executing: /usr/bin/systemd-inhibit --who="borgmatic" --why="Prevent interrupting scheduled backup" /root/.local/bin/borgmatic -v 2 --log-file /tmp/borgmatic.log --log-file-verbosity 2
giu 17 09:04:20 myhost systemd[1]: Got message type=signal sender=org.freedesktop.DBus destination=n/a object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameOwnerChanged cookie=64 reply_cookie=0 error=n/a
giu 17 09:04:20 myhost borgmatic[12377]: Failed to execute interrupting: No such file or directory
giu 17 09:04:20 myhost borgmatic[12377]: interrupting failed with error code 1.
giu 17 09:04:20 myhost systemd[1]: Received SIGCHLD from PID 12377 (systemd-inhibit).
giu 17 09:04:20 myhost systemd[1]: Child 12377 (systemd-inhibit) died (code=exited, status=1/FAILURE)
giu 17 09:04:20 myhost systemd[1]: Child 12377 belongs to borgmatic.service
giu 17 09:04:20 myhost systemd[1]: Unwatching 12377.
giu 17 09:04:20 myhost systemd[1]: borgmatic.service: main process exited, code=exited, status=1/FAILURE
giu 17 09:04:20 myhost systemd[1]: borgmatic.service changed start -> failed
giu 17 09:04:20 myhost systemd[1]: Job borgmatic.service/start finished, result=failed
giu 17 09:04:20 myhost systemd[1]: Failed to start borgmatic backup.
-- Subject: Unit borgmatic.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit borgmatic.service has failed.
-- 
-- The result is failed.
giu 17 09:04:20 myhost systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobRemoved cookie=14 reply_cookie=0 error=n/a
giu 17 09:04:20 myhost systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobRemoved cookie=1258 reply_cookie=0 error=n/a
giu 17 09:04:20 myhost systemd[1]: borgmatic.timer: Realtime timer elapses at Thu 2020-06-18 00:00:00 CEST.
giu 17 09:04:20 myhost systemd[1]: Unit borgmatic.service entered failed state.
giu 17 09:04:20 myhost systemd[1]: borgmatic.timer: Realtime timer elapses at Thu 2020-06-18 00:00:00 CEST.
giu 17 09:04:20 myhost systemd[1]: borgmatic.service failed.
giu 17 09:04:20 myhost systemd[1]: borgmatic.service: cgroup is empty

This error appears:

Failed to execute interrupting: No such file or directory

Environment

borgmatic version: 1.5.6

borgmatic installation method: sudo pip3 install --user

Borg version: [version here]

Use sudo borg --version

Python version:

# /usr/bin/python3 --version
Python 3.6.8

operating system and version: oracle-linux 7.8

#### What I'm trying to do and why I followed the guide to install systemd borgmatic.service and borgmatic.timer by installing the following service unit: ``` [Unit] Description=borgmatic backup Wants=network-online.target After=network-online.target ConditionACPower=true [Service] Type=oneshot Nice=19 CPUSchedulingPolicy=batch IOSchedulingClass=best-effort IOSchedulingPriority=7 #IOWeight=100 Restart=no # Prevent rate limiting of borgmatic log events. If you are using an older version of systemd that # doesn't support this (pre-240 or so), you may have to remove this option. #LogRateLimitIntervalSec=0 SyslogIdentifier=borgmatic StandardOutput=journal StandardError=journal # Delay start to prevent backups running during boot. Note that systemd-inhibit requires dbus and # dbus-user-session to be installed. ExecStartPre=/usr/bin/sleep 1m ExecStart=/usr/bin/systemd-inhibit --who="borgmatic" --why="Prevent interrupting scheduled backup" /root/.local/bin/borgmatic -v 2 --log-file /tmp/borgmatic.log --log-file-verbosity 2 ``` If I run the command `sudo /usr/bin/systemd-inhibit --who="borgmatic" --why="Prevent interrupting scheduled backup" /root/.local/bin/borgmatic -v 2 --log-file /tmp/borgmatic.log --log-file-verbosity 2` on command line, everythin works fine. If I run `sudo systemctl start borgmatic` it fails. The journal shows these messages: ``` giu 17 09:04:20 myhost systemd[12377]: Executing: /usr/bin/systemd-inhibit --who="borgmatic" --why="Prevent interrupting scheduled backup" /root/.local/bin/borgmatic -v 2 --log-file /tmp/borgmatic.log --log-file-verbosity 2 giu 17 09:04:20 myhost systemd[1]: Got message type=signal sender=org.freedesktop.DBus destination=n/a object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=NameOwnerChanged cookie=64 reply_cookie=0 error=n/a giu 17 09:04:20 myhost borgmatic[12377]: Failed to execute interrupting: No such file or directory giu 17 09:04:20 myhost borgmatic[12377]: interrupting failed with error code 1. giu 17 09:04:20 myhost systemd[1]: Received SIGCHLD from PID 12377 (systemd-inhibit). giu 17 09:04:20 myhost systemd[1]: Child 12377 (systemd-inhibit) died (code=exited, status=1/FAILURE) giu 17 09:04:20 myhost systemd[1]: Child 12377 belongs to borgmatic.service giu 17 09:04:20 myhost systemd[1]: Unwatching 12377. giu 17 09:04:20 myhost systemd[1]: borgmatic.service: main process exited, code=exited, status=1/FAILURE giu 17 09:04:20 myhost systemd[1]: borgmatic.service changed start -> failed giu 17 09:04:20 myhost systemd[1]: Job borgmatic.service/start finished, result=failed giu 17 09:04:20 myhost systemd[1]: Failed to start borgmatic backup. -- Subject: Unit borgmatic.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit borgmatic.service has failed. -- -- The result is failed. giu 17 09:04:20 myhost systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobRemoved cookie=14 reply_cookie=0 error=n/a giu 17 09:04:20 myhost systemd[1]: Sent message type=signal sender=n/a destination=n/a object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=JobRemoved cookie=1258 reply_cookie=0 error=n/a giu 17 09:04:20 myhost systemd[1]: borgmatic.timer: Realtime timer elapses at Thu 2020-06-18 00:00:00 CEST. giu 17 09:04:20 myhost systemd[1]: Unit borgmatic.service entered failed state. giu 17 09:04:20 myhost systemd[1]: borgmatic.timer: Realtime timer elapses at Thu 2020-06-18 00:00:00 CEST. giu 17 09:04:20 myhost systemd[1]: borgmatic.service failed. giu 17 09:04:20 myhost systemd[1]: borgmatic.service: cgroup is empty ``` This error appears: ``` Failed to execute interrupting: No such file or directory ``` #### Environment **borgmatic version:** 1.5.6 **borgmatic installation method:** `sudo pip3 install --user` **Borg version:** [version here] Use `sudo borg --version` **Python version:** ``` # /usr/bin/python3 --version Python 3.6.8 ``` **operating system and version:** oracle-linux 7.8
Owner

Thanks for reporting this. I'm really not sure what's going on here though. It appears that systemd is parsing the systemd-inhibit line incorrectly and treating part of the Prevent interrupting ... string as the command to run! Really odd. For what it's worth, this does not reproduce on my machine (Manjaro Linux).

I checked the list of systemd compatibility limitations for Oracle 7, but I don't see anything obvious there that might cause this. One thing you could try is removing the whole --why="..." flag, in case that's tripping it up. Then if that's still not working, you can remove the whole systemd-inhibit and arguments, so the line reads more like:

ExecStart=/root/.local/bin/borgmatic -v 2 --log-file /tmp/borgmatic.log --log-file-verbosity 2

That would lose the systemd lock that prevents sleep/shutdown/etc. during a backup, but that may not even be a feature you need.

Thanks for reporting this. I'm really not sure what's going on here though. It appears that systemd is parsing the `systemd-inhibit` line incorrectly and treating part of the `Prevent interrupting ...` string as the command to run! Really odd. For what it's worth, this does not reproduce on my machine (Manjaro Linux). I checked the list of [systemd compatibility limitations for Oracle 7](https://docs.oracle.com/en/operating-systems/oracle-linux/7/relnotes7.0/section-f3l-hjk-4n.html), but I don't see anything obvious there that might cause this. One thing you could try is removing the whole `--why="..."` flag, in case that's tripping it up. Then if that's still not working, you can remove the whole `systemd-inhibit` and arguments, so the line reads more like: ```text ExecStart=/root/.local/bin/borgmatic -v 2 --log-file /tmp/borgmatic.log --log-file-verbosity 2 ``` That would lose the systemd lock that prevents sleep/shutdown/etc. during a backup, but that may not even be a feature you need.
witten added the
question / support
label 2020-06-17 17:36:21 +00:00
Author

You're right, after removing the --why="WORD1 WORD2" argument, now the service can be run via systemctl.

Thank you

You're right, after removing the --why="WORD1 WORD2" argument, now the service can be run via systemctl. Thank you
Owner

Awesome, glad to hear it! Let me know if you run into any other problems.

Awesome, glad to hear it! Let me know if you run into any other problems.
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#329
No description provided.