add export service
This commit is contained in:
parent
d01de238a7
commit
dbb78ed37f
7 changed files with 86 additions and 4 deletions
0
templates/backup-export.
Normal file
0
templates/backup-export.
Normal file
21
templates/backup-export.j2
Executable file
21
templates/backup-export.j2
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "Starting to export backups..."
|
||||
|
||||
{% if backup_backend == 'restic' %}
|
||||
# restic backend
|
||||
source /etc/backup-client/restic.env
|
||||
|
||||
{% for i in backups.export.destinations if i.type == "rsync" %}
|
||||
echo "exporting to {{ i.host }}"
|
||||
rsync -h -r -a --append-verify --delete --stats -e "ssh -p {{ i.port|d(22) }} -i {{ i.key|d('/etc/backup-client/id_ed25519') }}" "${RESTIC_REPOSITORY}/" "{{ i.user }}@{{ i.host }}:{{ i.remotepath }}"
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if not backup_backend %}
|
||||
echo "Noop, backup is handled external"
|
||||
{% endif %}
|
||||
|
||||
echo "done!"
|
||||
10
templates/backup-export.service.j2
Normal file
10
templates/backup-export.service.j2
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Export backups to an external host
|
||||
OnFailure=status-email-root@%n.service
|
||||
|
||||
[Service]
|
||||
Nice=19
|
||||
IOSchedulingClass=idle
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/backup-export
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue