borgmatic.service 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. [Unit]
  2. Description=borgmatic backup
  3. Wants=network-online.target
  4. After=network-online.target
  5. ConditionACPower=true
  6. [Service]
  7. Type=oneshot
  8. # Security settings for systemd running as root
  9. # For more details about this settings check the systemd manuals
  10. # https://www.freedesktop.org/software/systemd/man/systemd.exec.html
  11. LockPersonality=true
  12. # Certain borgmatic features like Healthchecks integration need MemoryDenyWriteExecute to be off.
  13. # But you can try setting it to "yes" for improved security if you don't use those features.
  14. MemoryDenyWriteExecute=no
  15. NoNewPrivileges=yes
  16. PrivateDevices=yes
  17. PrivateTmp=yes
  18. ProtectClock=yes
  19. ProtectControlGroups=yes
  20. ProtectHostname=yes
  21. ProtectKernelLogs=yes
  22. ProtectKernelModules=yes
  23. ProtectKernelTunables=yes
  24. RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
  25. RestrictNamespaces=yes
  26. RestrictRealtime=yes
  27. RestrictSUIDSGID=yes
  28. SystemCallArchitectures=native
  29. SystemCallFilter=@system-service
  30. # Restrict write access
  31. # Change to 'ProtectSystem=strict' and uncomment 'ProtectHome' to make the whole file
  32. # system read-only be default and uncomment 'ReadWritePaths' for the required write access.
  33. # Add local repositroy paths to the list of 'ReadWritePaths' like '-/mnt/my_backup_drive'.
  34. ProtectSystem=full
  35. # ProtectHome=read-only
  36. # ReadWritePaths=-/root/.config/borg -/root/.cache/borg -/root/.borgmatic
  37. CapabilityBoundingSet=CAP_DAC_READ_SEARCH CAP_NET_RAW
  38. # Lower CPU and I/O priority.
  39. Nice=19
  40. CPUSchedulingPolicy=batch
  41. IOSchedulingClass=best-effort
  42. IOSchedulingPriority=7
  43. IOWeight=100
  44. Restart=no
  45. # Prevent rate limiting of borgmatic log events. If you are using an older version of systemd that
  46. # doesn't support this (pre-240 or so), you may have to remove this option.
  47. LogRateLimitIntervalSec=0
  48. # Delay start to prevent backups running during boot. Note that systemd-inhibit requires dbus and
  49. # dbus-user-session to be installed.
  50. ExecStartPre=sleep 1m
  51. ExecStart=systemd-inhibit --who="borgmatic" --why="Prevent interrupting scheduled backup" /root/.local/bin/borgmatic --syslog-verbosity 1