#!/bin/bash {{ file_header | default () }} {% for item in rsync_mirror_dirs %} {# Header #} echo "-----------------------" echo "Source: {{ item.src | regex_replace('\\/$', '') }}" echo "Destination: {{ item.dest.split(':') | last | regex_replace('\\/$', '') }}" {# Mount check source #} if /usr/sbin/zfs get mounted -H {{ item.src | regex_replace('\\/$', '') }} 2>&1 > /dev/null ; then {# Mount check destination #} 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)" -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 --itemize-changes --omit-dir-times --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 {% endfor %} {# 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#}