homeserver/roles/mgrote_rsync/templates/rsync_mirror.sh.j2

23 lines
905 B
Text
Raw Normal View History

2024-10-28 18:24:29 +01:00
#!/bin/bash
{{ file_header | default () }}
2024-10-28 18:52:56 +01:00
{% for item in rsync_mirror_dirs %}
2024-10-29 15:26:18 +01:00
{# Header #}
2024-10-29 14:22:28 +01:00
echo "-----------------------"
2024-10-29 14:21:45 +01:00
echo "Source: {{ item.src }}"
2024-10-29 15:26:18 +01:00
{# Mount check source #}
2024-10-29 15:28:56 +01:00
if /usr/sbin/zfs get mounted -H {{ item.src }} ; then
2024-10-29 15:26:18 +01:00
{# Mount check destination #}
if [ $(ssh {{ item.dest.split(':') | first }} /usr/sbin/zfs get mounted -H {{ item.dest.split(':') | last }} | cut -f3) -eq "yes" ] ; then
rsync -e "ssh -i /etc/rsync_mirror/.ssh/id_rsync_mirror -o StrictHostKeyChecking=no" --dry-run --bwlimit={{ rsync_mirror_bw_limit }} --archive --verbose --human-readable --stats --compress --fuzzy --force --delete-after --recursive {{ item.src }} {{ item.dest }}
else
echo "Destination-Dataset not mounted!"
fi
else
echo "Source-Dataset not mounted!"
fi
2024-10-28 18:52:56 +01:00
{% endfor %}
2024-10-29 14:31:59 +01:00
# --checksum ; https://serverfault.com/questions/211005/rsync-difference-between-checksum-and-ignore-times-options