Skip to content

Instantly share code, notes, and snippets.

@ILMostro
Created April 13, 2020 06:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ILMostro/e55b53a909eeffe45f932acd3db8a68d to your computer and use it in GitHub Desktop.
Save ILMostro/e55b53a909eeffe45f932acd3db8a68d to your computer and use it in GitHub Desktop.
Borg backup systemd timer, service, and logging config
# cat /etc/systemd/system/borgitup.service
[Unit]
Description=Create a backup using borg
[Service]
Type=oneshot
Environment=BORG_LOGGING_CONF=/etc/borg/logging.conf
; ExecStart=/usr/local/bin/borgitup
; 20200413 -- preprend a hyphen (-) to ignore error return value
; ExecStart=-/usr/local/bin/borgitup
;
; Alternatively, list the specific signals to consider as successful exit status
SuccessExitStatus=TEMPFAIL 250 SIGUSR1 1
ExecStart=/usr/local/bin/borgitup
# cat /etc/systemd/system/borgitup.timer
[Unit]
Description=Create a weekly backup with borg
[Timer]
OnCalendar=weekly
Persistent=true
[Install]
WantedBy=timers.target
# cat /etc/borg/logging.conf
[loggers]
keys=root
[handlers]
keys=logfile
[formatters]
keys=logfile
[logger_root]
level=NOTSET
handlers=logfile
[handler_logfile]
class=FileHandler
level=INFO
formatter=logfile
args=('/var/log/borg.log', 'w')
[formatter_logfile]
format=%(asctime)s %(levelname)s %(message)s
datefmt=
class=logging.Formatter
@ILMostro
Copy link
Author

Executes a simple bash script (/usr/local/bin/borgitup) to create weekly backup with borg; implemented via systemd timer and service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment