ansible-collection-duplicity/roles/duplicity_server/templates/backup-script.j2
2024-02-11 16:29:29 +01:00

24 lines
968 B
Django/Jinja

#!/bin/bash
# Cleanup old backups
duplicity remove-all-inc-of-but-n-full 2 --force file://{{ duplicity_server_storage_root }}/{{item}}
duplicity remove-all-but-n-full 3 --force file://{{ duplicity_server_storage_root }}/{{item}}
# Prepare mount directory
rm -rf {{ duplicity_server_mount_root }}/{{ item }}
mkdir -p {{ duplicity_server_mount_root }}/{{ item }}
cd {{ duplicity_server_mount_root }}/{{ item }}
# mount the client directories through sshfs
{% for path in hostvars[item].duplicity_client_backup_paths %}
mkdir -p .{{ path }}
sshfs {{ hostvars[item].duplicity_client_user | default(duplicity_client_user) }}@{{ item }}:{{path}} .{{ path }}
{% endfor %}
# Perform the backup
duplicity --full-if-older-than 1W --encrypt-key C05AD49B790BAC8E3B573B697B25171F921B9E57 . file://{{ duplicity_server_storage_root }}/{{item}}
# Unmount the directories
{% for path in hostvars[item].duplicity_client_backup_paths %}
fusermount -u .{{ path }}
{% endfor %}