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-29 15:58:51 +01:00
|
|
|
if /usr/sbin/zfs get mounted -H {{ item.src }} 2>&1 > /dev/null ; then
|
2024-10-29 15:26:18 +01:00
|
|
|
{# Mount check destination #}
|
2024-10-29 15:58:51 +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 }} | cut -f3)" -eq "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!"
|
|
|
|
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
|
|
|
|
2024-10-29 15:52:40 +01:00
|
|
|
{# Beispiel
|
|
|
|
echo "-----------------------"
|
|
|
|
echo "Source: /hdd_data/tmp/"
|
|
|
|
if /usr/sbin/zfs get mounted -H /hdd_data/tmp/ 2>&1 > /dev/null ; then
|
|
|
|
if [[ "$(ssh -i /etc/rsync_mirror/.ssh/id_rsync_mirror -o StrictHostKeyChecking=no rsync_mirror@pbs.mgrote.net /usr/sbin/zfs get mounted -H /backup/pve5/tmp | cut -f3)" -eq "yes" ]] ; then
|
|
|
|
rsync -e "ssh -i /etc/rsync_mirror/.ssh/id_rsync_mirror -o StrictHostKeyChecking=no" --itemize-changes --bwlimit=2m --verbose --omit-dir-times --archive --human-readable --stats --compress --fuzzy --force --delete-after --recursive /hdd_data/tmp/ rsync_mirror@pbs.mgrote.net:/backup/pve5/tmp/
|
|
|
|
else
|
|
|
|
echo "Destination-Dataset not mounted!"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Source-Dataset not mounted!"
|
|
|
|
fi#}
|