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

31 lines
1.2 KiB
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:46:55 +01:00
echo "Destination: {{ item.dest.split(':') | last }}"
2024-10-29 15:26:18 +01:00
{# Mount check source #}
2024-10-29 15:35:58 +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:35:58 +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 15:38:51 +01:00
rsync -e "ssh -i /etc/rsync_mirror/.ssh/id_rsync_mirror -o StrictHostKeyChecking=no" --dry-run --bwlimit={{ rsync_mirror_bw_limit }} --archive --human-readable --stats --compress --fuzzy --force --delete-after --recursive {{ item.src }} {{ item.dest }}
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
# --checksum ; https://serverfault.com/questions/211005/rsync-difference-between-checksum-and-ignore-times-options
2024-10-29 15:31:37 +01:00
# beispiel cmd hier rein
2024-10-29 15:43:06 +01:00
# --itemize-changes
2024-10-29 15:46:37 +01:00
# rsync: [generator] failed to set times on "/backup/pve5/tmp/.": Operation not permitted (1)