2023-07-28 13:33:18 +00:00
|
|
|
[Unit]
|
|
|
|
Description={{ restic_job_description }}
|
|
|
|
|
|
|
|
[Service]
|
2024-04-14 13:14:02 +00:00
|
|
|
Type=simple
|
2023-07-28 13:33:18 +00:00
|
|
|
User={{ restic_user }}
|
|
|
|
WorkingDirectory={{ restic_systemd_working_directory }}
|
|
|
|
SyslogIdentifier={{ restic_systemd_syslog_identifier }}
|
|
|
|
|
|
|
|
Environment=RESTIC_REPOSITORY={{ restic_repo_url }}
|
|
|
|
Environment=RESTIC_PASSWORD={{ restic_repo_password }}
|
|
|
|
{% if restic_s3_key_id and restic_s3_access_key %}
|
|
|
|
Environment=AWS_ACCESS_KEY_ID={{ restic_s3_key_id }}
|
|
|
|
Environment=AWS_SECRET_ACCESS_KEY={{ restic_s3_access_key }}
|
|
|
|
{% endif %}
|
2024-05-05 14:19:10 +00:00
|
|
|
{% if restic_unlock_before_backup | default(false) %}
|
|
|
|
ExecStartPre=-/bin/sh -c '/usr/bin/restic unlock'
|
|
|
|
{% endif %}
|
2023-07-28 13:33:18 +00:00
|
|
|
|
|
|
|
ExecStartPre=-/bin/sh -c '/usr/bin/restic snapshots || /usr/bin/restic init'
|
2024-05-05 14:19:10 +00:00
|
|
|
{% if restic_backup_pre_hook | default(false) %}
|
|
|
|
ExecStart=-{{ restic_backup_pre_hook }}
|
|
|
|
{% endif %}
|
2023-07-28 13:33:18 +00:00
|
|
|
{% if restic_backup_stdin_command %}
|
|
|
|
ExecStart=/bin/sh -c '{{ restic_backup_stdin_command }} | /usr/bin/restic backup --verbose --stdin --stdin-filename {{ restic_backup_stdin_command_filename }}'
|
|
|
|
{% else %}
|
|
|
|
ExecStart=/usr/bin/restic --verbose backup {{ restic_backup_paths | join(' ') }}
|
|
|
|
{% endif %}
|
|
|
|
ExecStartPost=/usr/bin/restic forget --prune --keep-within={{ restic_policy.keep_within }} --keep-hourly={{ restic_policy.hourly }} --keep-daily={{ restic_policy.daily }} --keep-weekly={{ restic_policy.weekly }} --keep-monthly={{ restic_policy.monthly }}
|
|
|
|
ExecStartPost=-/usr/bin/restic snapshots
|
2024-05-05 14:19:10 +00:00
|
|
|
{% if restic_backup_post_hook | default(false) %}
|
2024-04-14 13:14:02 +00:00
|
|
|
ExecStartPost=-{{ restic_backup_post_hook }}
|
|
|
|
{% endif %}
|
2023-07-28 13:33:18 +00:00
|
|
|
ExecStartPost=/usr/bin/restic check
|