vm-ansible/roles/backupscript/templates/backupscript.sh

17 lines
634 B
Bash
Raw Normal View History

2022-04-16 17:13:16 +02:00
#!/usr/bin/env bash
# {{ansible_managed}}
2022-04-16 17:16:52 +02:00
{{backup.prearecommand}}
2022-04-16 17:13:16 +02:00
2022-04-16 19:09:47 +02:00
{% if backup.internal %}
2022-04-16 17:13:16 +02:00
2022-04-16 19:09:47 +02:00
time ( rsync -azP --delete {{backup.folder}} backup@{{backup.host}}:{{backup.basedir}}/{{servicename}}/staging )
time ( ssh backup@{{backup.host}} 'tar -zcvf {{backup.basedir}}/{{servicename}}/{{servicename}}-$(date +"%Y-%m-%d").tar.gz -C {{backup.basedir}}/{{servicename}}/staging {{backup.tarfolder}}' )
{% else %}
time ( rsync -azPr --delete --prune-empty-dirs --include "*/" --include="*.tar.gz" --include="*.sql" --include="*.zip" --exclude="*" {{backup.basedir}}/ backup@{{backup.host}}:/mnt/backup/{{servicename}} )
{% endif %}