50 lines
1.2 KiB
Django/Jinja
50 lines
1.2 KiB
Django/Jinja
[Unit]
|
|
Description=Kopia backup service
|
|
Wants=network-online.target
|
|
After=network-online.target
|
|
|
|
[Service]
|
|
User=kopia
|
|
Group=kopia
|
|
|
|
Type=oneshot
|
|
|
|
# logging
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
|
|
CapabilityBoundingSet=CAP_DAC_READ_SEARCH
|
|
AmbientCapabilities=CAP_DAC_READ_SEARCH
|
|
|
|
ProtectSystem=strict
|
|
ProtectHome=tmpfs
|
|
InaccessiblePaths=/boot /root
|
|
|
|
{% if node['name'] == 'infra' %}
|
|
BindReadOnlyPaths=%h/containers/postgresql/backups
|
|
{% elif node['name'] == 'app' %}
|
|
BindReadOnlyPaths=%h/data
|
|
{% endif %}
|
|
# In root namescope, %u always bring 0
|
|
BindPaths=/etc/kopia
|
|
BindPaths=/etc/secrets/{{ kopia_uid }}
|
|
BindPaths=/var/cache/kopia
|
|
EnvironmentFile=/etc/secrets/{{ kopia_uid }}/kopia.env
|
|
|
|
ExecStartPre=/usr/bin/kopia repository connect server \
|
|
--url=https://{{ services['kopia']['domain'] }}.{{ domain['internal'] }}:{{ services['kopia']['ports']['https'] }} \
|
|
--override-username={{ node['name'] }} \
|
|
--override-hostname={{ node['name'] }}.{{ domain['internal'] }}
|
|
|
|
{% if node['name'] == 'infra' %}
|
|
ExecStart=/usr/bin/kopia snapshot create \
|
|
/home/infra/containers/postgresql/backups
|
|
{% elif node['name'] == 'app' %}
|
|
ExecStart=/usr/bin/kopia snapshot create \
|
|
/home/app/data
|
|
{% endif %}
|
|
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|