Recommended borgmatic.service settings for non-root use? #669

Closed
opened 2023-04-08 00:21:15 +00:00 by shervinsahba · 3 comments

What I'm trying to do and why

I've been running borgmatic as a non-root user on several systems, mainly to backup home directories. The borgmatic.service template is written for root.

I had set up a systemd timer for my user to run borgmatic, but I'm quite unsure about all the options in the above service file. Could we have some guidance on how to adopt that file for a user?

Other notes / implementation ideas

I had been using a very minimal service file to run as my user. It works, but am I missing anything important from the provided template? If I understand correctly, the security and capability settings probably aren't needed. However, I don't know if controlling things like CPU niceness or if using systemd-inhibit are things my non-root user can do.

In any case, this is what I am using. Am I missing anything crucial when compared to the template file? Thank you.

borgmatic.service:

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

[Service]
Type=oneshot

Restart=no
LogRateLimitIntervalSec=0
ExecStartPre=sleep 1m
ExecStart=borgmatic

Environment

borgmatic version: 1.7.11

borgmatic installation method: Arch community package

Borg version: 1.2.4

Python version: 3.10.10

Database version (if applicable): n/a

operating system and version: 6.2.9-arch1-1

#### What I'm trying to do and why I've been running borgmatic as a non-root user on several systems, mainly to backup home directories. The [borgmatic.service](https://projects.torsion.org/borgmatic-collective/borgmatic/raw/branch/master/sample/systemd/borgmatic.service) template is written for root. I had set up a systemd timer for my user to run borgmatic, but I'm quite unsure about all the options in the above service file. Could we have some guidance on how to adopt that file for a user? #### Other notes / implementation ideas I had been using a very minimal service file to run as my user. It works, but am I missing anything important from the provided template? If I understand correctly, the security and capability settings probably aren't needed. However, I don't know if controlling things like CPU niceness or if using systemd-inhibit are things my non-root user can do. In any case, this is what I am using. Am I missing anything crucial when compared to the template file? Thank you. borgmatic.service: ``` [Unit] Description=borgmatic backup Wants=network-online.target After=network-online.target ConditionACPower=true [Service] Type=oneshot Restart=no LogRateLimitIntervalSec=0 ExecStartPre=sleep 1m ExecStart=borgmatic ``` #### Environment **borgmatic version:** 1.7.11 **borgmatic installation method:** Arch community package **Borg version:** 1.2.4 **Python version:** 3.10.10 **Database version (if applicable):** n/a **operating system and version:** 6.2.9-arch1-1
Owner

Great question! I'm no systemd expert, but here's my take:

  • I think you are right about the security and capability settings.
  • systemd apparently doesn't support non-root niceness settings out of the box. There are workarounds though if that's something that's important to you. Personally I just run borgmatic at a time when I'm not likely to be using the computer.
  • systemd-inhibit just prevents system sleep/shutdown while borgmatic is running. If you want to use it from a systemd user service, it looks like you can. But it's up to you as to whether you want that functionality.
  • I don't think you're missing anything crucial. You might want to pass some verbosity flags to borgmatic though if the default verbosity isn't to your liking. For instance, increasing the syslog verbosity is probably a good idea.

Hope that helps.

Great question! I'm no systemd expert, but here's my take: * I think you are right about the security and capability settings. * systemd apparently doesn't support non-root niceness settings out of the box. There are [workarounds](https://superuser.com/questions/1447351/set-niceness-value-in-a-systemd-user-service) though if that's something that's important to you. Personally I just run borgmatic at a time when I'm not likely to be using the computer. * `systemd-inhibit` just prevents system sleep/shutdown while borgmatic is running. If you want to use it from a systemd user service, [it looks like you can](https://github.com/systemd/systemd/issues/20898#issuecomment-931350503). But it's up to you as to whether you want that functionality. * I don't think you're missing anything crucial. You might want to pass some verbosity flags to borgmatic though if the default verbosity isn't to your liking. For instance, increasing the syslog verbosity is probably a good idea. Hope that helps.
witten added the
question / support
label 2023-04-08 03:57:46 +00:00
Author

Thank you for the reply!

Interesting about the systemd-inhibit call. Since borg supports resumed backups, I'll keep it off the laptop at least.

Good call on the verbosity flags... I was wondering where my logs were recently!

Thank you for the reply! Interesting about the `systemd-inhibit` call. Since [borg supports resumed backups](https://borgbackup.readthedocs.io/en/stable/faq.html#checkpoints-parts), I'll keep it off the laptop at least. Good call on the verbosity flags... I was wondering where my logs were recently!
Owner

Sounds good! I'll close this for now, but feel free to post any followups including findings on using borgmatic with a non-root systemd service.

Sounds good! I'll close this for now, but feel free to post any followups including findings on using borgmatic with a non-root systemd service.
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#669
No description provided.