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 15:58:51 +01:00
|
|
|
echo "Source: {{ item.src }}"
|
|
|
|
echo "Destination: {{ item.dest.split(':') | last }}"
|
2024-10-29 15:26:18 +01:00
|
|
|
{# Mount check source #}
|
2024-10-31 11:07:01 +01:00
|
|
|
if [[ "$(/usr/sbin/zfs get mounted -H {{ item.src | regex_replace('^/', '') }} | cut -f3)" = "yes" ]] ; then
|
2024-10-29 15:26:18 +01:00
|
|
|
{# Mount check destination #}
|
2024-10-31 11:08:54 +01:00
|
|
|
if [[ "$(ssh -i /etc/rsync_mirror/.ssh/id_rsync_mirror -o StrictHostKeyChecking=no {{ item.dest.split(':') | first }} /usr/sbin/zfs get mounted -H {{ item.dest.split(':') | last | regex_replace('^/', '') }} | cut -f3)" = "yes" ]] ; then
|
2024-10-29 16:26:27 +01:00
|
|
|
rsync -e "ssh -i /etc/rsync_mirror/.ssh/id_rsync_mirror -o StrictHostKeyChecking=no" --bwlimit={{ rsync_mirror_bw_limit }} --archive --verbose --inplace --itemize-changes --omit-dir-times --human-readable --stats --compress --fuzzy --force --partial --delete-after --recursive {{ item.src }}/ {{ item.dest }}/
|
2024-10-29 16:00:37 +01:00
|
|
|
{# "/" am Ende von Src+Dest ist Wichtig und notwendig, sonst wird in Unterordner kopiert #}
|
2024-10-29 15:26:18 +01:00
|
|
|
else
|
|
|
|
echo "Destination-Dataset not mounted!"
|
2024-10-31 11:09:27 +01:00
|
|
|
exit 1
|
2024-10-29 15:26:18 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Source-Dataset not mounted!"
|
2024-10-31 11:09:27 +01:00
|
|
|
exit 1
|
2024-10-29 15:26:18 +01:00
|
|
|
fi
|
2024-10-28 18:52:56 +01:00
|
|
|
{% endfor %}
|