2016-07-04 18:19:34 +02:00
|
|
|
[Unit]
|
|
|
|
Description=borgmatic backup
|
2019-09-24 19:16:30 +02:00
|
|
|
Wants=network-online.target
|
|
|
|
After=network-online.target
|
2021-06-09 19:03:35 +02:00
|
|
|
# Prevent borgmatic from running unless the machine is plugged into power. Remove this line if you
|
|
|
|
# want to allow borgmatic to run anytime.
|
2019-09-24 19:43:30 +02:00
|
|
|
ConditionACPower=true
|
2016-07-04 18:19:34 +02:00
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
2019-09-24 19:16:30 +02:00
|
|
|
|
2020-12-09 19:08:07 +01:00
|
|
|
# Security settings for systemd running as root, optional but recommended to improve security. You
|
|
|
|
# can disable individual settings if they cause problems for your use case. For more details, see
|
|
|
|
# the systemd manual: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
2020-08-22 15:41:25 +02:00
|
|
|
LockPersonality=true
|
2020-08-23 23:11:19 +02:00
|
|
|
# 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.
|
2020-08-22 22:37:34 +02:00
|
|
|
MemoryDenyWriteExecute=no
|
2020-08-22 15:41:25 +02:00
|
|
|
NoNewPrivileges=yes
|
|
|
|
PrivateDevices=yes
|
|
|
|
PrivateTmp=yes
|
|
|
|
ProtectClock=yes
|
|
|
|
ProtectControlGroups=yes
|
|
|
|
ProtectHostname=yes
|
|
|
|
ProtectKernelLogs=yes
|
|
|
|
ProtectKernelModules=yes
|
|
|
|
ProtectKernelTunables=yes
|
|
|
|
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
|
|
|
|
RestrictNamespaces=yes
|
|
|
|
RestrictRealtime=yes
|
|
|
|
RestrictSUIDSGID=yes
|
|
|
|
SystemCallArchitectures=native
|
|
|
|
SystemCallFilter=@system-service
|
2020-12-01 07:14:28 +01:00
|
|
|
SystemCallErrorNumber=EPERM
|
2020-08-22 15:41:25 +02:00
|
|
|
# Restrict write access
|
|
|
|
# Change to 'ProtectSystem=strict' and uncomment 'ProtectHome' to make the whole file
|
|
|
|
# system read-only be default and uncomment 'ReadWritePaths' for the required write access.
|
|
|
|
# Add local repositroy paths to the list of 'ReadWritePaths' like '-/mnt/my_backup_drive'.
|
|
|
|
ProtectSystem=full
|
|
|
|
# ProtectHome=read-only
|
|
|
|
# ReadWritePaths=-/root/.config/borg -/root/.cache/borg -/root/.borgmatic
|
|
|
|
|
|
|
|
CapabilityBoundingSet=CAP_DAC_READ_SEARCH CAP_NET_RAW
|
|
|
|
|
2019-09-24 19:16:30 +02:00
|
|
|
# Lower CPU and I/O priority.
|
|
|
|
Nice=19
|
|
|
|
CPUSchedulingPolicy=batch
|
|
|
|
IOSchedulingClass=best-effort
|
|
|
|
IOSchedulingPriority=7
|
|
|
|
IOWeight=100
|
|
|
|
|
|
|
|
Restart=no
|
2020-01-02 19:05:32 +01:00
|
|
|
# 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.
|
2019-06-12 02:03:40 +02:00
|
|
|
LogRateLimitIntervalSec=0
|
2019-09-24 19:16:30 +02:00
|
|
|
|
2020-05-22 04:56:32 +02:00
|
|
|
# Delay start to prevent backups running during boot. Note that systemd-inhibit requires dbus and
|
|
|
|
# dbus-user-session to be installed.
|
2020-01-22 01:03:24 +01:00
|
|
|
ExecStartPre=sleep 1m
|
|
|
|
ExecStart=systemd-inhibit --who="borgmatic" --why="Prevent interrupting scheduled backup" /root/.local/bin/borgmatic --syslog-verbosity 1
|