This commit is contained in:
fhausmann 2025-08-21 15:04:47 +00:00 committed by GitHub
commit 654c8e961a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View File

@ -51,4 +51,5 @@ borg_user: "root"
borg_group: "root"
backup_user_info:
home: "/home/{{ borg_user }}"
borgmatic_run_as_root: false
...

View File

@ -207,3 +207,7 @@ argument_specs:
type: str
required: false
description: Comment added to the SSH public key.
borgmatic_run_as_root:
type: bool
required: false
description: If the variable is set, systemd will run borgmatic using sudo.

View File

@ -12,7 +12,7 @@ ConditionACPower=true
[Service]
Type=oneshot
User={{ borg_user }}
ExecStart=borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} {{ borgmatic_timer_flags }}
ExecStart={{ 'sudo ' if borgmatic_run_as_root}}borgmatic -c /etc/borgmatic/{{ borgmatic_config_name }} {{ borgmatic_timer_flags }}
# Source: https://projects.torsion.org/borgmatic-collective/borgmatic/raw/branch/master/sample/systemd/borgmatic.service
# Security settings for systemd running as root, optional but recommended to improve security. You
@ -22,7 +22,7 @@ LockPersonality=true
# Certain borgmatic features like Healthchecks integration need MemoryDenyWriteExecute to be off.
# But you can try setting it to "yes" for improved security if you don't use those features.
MemoryDenyWriteExecute=no
NoNewPrivileges=yes
NoNewPrivileges={{ 'no' if borgmatic_run_as_root else 'yes'}}
PrivateDevices=yes
PrivateTmp=yes
ProtectClock=yes