SSH fails when started as systemd service #188
Labels
No Label
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: borgmatic-collective/borgmatic#188
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi,
if I run
borgmatic -v 2
in the shell, everything is working fine:But it fails when I run
systemctl start borgmatic.service
:My service file looks like this:
# cat /etc/systemd/system/borgmatic.service
[Unit]
Description=borgmatic backup
What makes the actual difference, why is it not working as a systemd service?
Thanks for reporting this! My guess is that systemd is not running borgmatic as the correct user, and therefore you're getting permission denied. Assuming that you want to run borgmatic as root, can you try something like this in your service file?
Let me know if that helps.
We should document this! It's always a pain to setup and I do appreciate when I see doucmentation that lays out how to integrate into Systemd, which is most of the time about losing >= 1 hour configuring it ...
So, I figured it out since yesterday and it was my mistake. I used
su
to get root, which took all my environmental variables from my local user terminal session. Usingssh-copy-id
to setup the ssh connection to my NAS was then probably done for the normal user, not for root. But if I run borgmatic with systemd, it doesn't have my user environmental variables. Actually, you can even get it run with systemd if you applysystemd import-environment
during the session (which helped me figuring out the problem...).I opened a new shell to login with root (and without my user environmental variables) and checked the ssh connection - which was not working, contrary to the
su
case... Usingssh-copy-id
in this shell, I could setup my ssh connection for root. Now it's also working fine for the systemd.serviceThank you for your support! And @decentral1se, yes, this cost me more than an hour figuring it out :D
Glad to hear you worked it out, and sorry you wasted an hour on this! If either of you have suggestions for what would have been helpful in the documentation to avoid this sort of problem, please let me know. I'm guessing that the relevant section is here: https://torsion.org/borgmatic/docs/how-to/set-up-backups/#autopilot .. Thanks.
Aha, it's already there! Then I blame Systemd ;)
Still, I'm always open to ways to improve the docs!