ansible-restic/templates/restic-backup.service.j2
2019-03-22 16:00:46 +01:00

28 lines
859 B
Django/Jinja

[Unit]
Description=Restic backup
[Service]
Type=oneshot
User={{ restic_user }}
Environment="RESTIC_REPOSITORY=sftp:{{ restic_ssh_host }}:{{ restic_repository_name }}"
Environment="RESTIC_PASSWORD={{ restic_password}}"
{% if restic_check %}
ExecStartPre={{ restic_path }} check
{% endif -%}
{% for folder in restic_folders_combined %}
ExecStart={{ restic_path }} backup --verbose {{ folder.path }} {{ folder.exclude if folder.exclude is defined else '' }}
{% endfor -%}
{% for database in restic_databases %}
ExecStart=/bin/sh -c "{{ database.dump_command }} | {{ restic_path }} backup --verbose --stdin --stdin-filename {{ database.name }}.sql"
{% endfor -%}
{% if restic_forget %}
ExecStartPost={{ restic_path }} forget --keep-within {{ restic_forget_keep_within }}
{% endif -%}
{% if restic_prune %}
ExecStartPost={{ restic_path }} prune
{% endif -%}