diff --git a/zfs-nfs-replica.sh b/zfs-nfs-replica.sh index 1ea6494..297084a 100644 --- a/zfs-nfs-replica.sh +++ b/zfs-nfs-replica.sh @@ -1162,20 +1162,6 @@ replicate_pool() { # Syncoid utilise les options SSH via la variable d'environnement SSH export SSH="ssh -i ${SSH_KEY}" - # Configuration de la limitation de bande passante via mbuffer - if command -v mbuffer &>/dev/null && [[ -n "${BANDWIDTH_LIMIT_MBS}" ]] && [[ "${BANDWIDTH_LIMIT_MBS}" -gt 0 ]]; then - # -r: rate limit (débit max en MB/s) - # -m: taille du buffer (128MB par défaut) - export MBUFFER="mbuffer -r ${BANDWIDTH_LIMIT_MBS}M -m 128M" - log "info" "Limitation de bande passante activée: ${BANDWIDTH_LIMIT_MBS} MB/s" - else - if [[ -n "${BANDWIDTH_LIMIT_MBS}" ]] && [[ "${BANDWIDTH_LIMIT_MBS}" -gt 0 ]]; then - log "warning" "mbuffer non disponible - limitation de bande passante désactivée" - log "warning" "Installer mbuffer: apt install mbuffer" - fi - unset MBUFFER - fi - local syncoid_opts # Déterminer si c'est une première synchronisation if check_common_snapshots "$remote_ip" "$pool"; then @@ -1201,6 +1187,14 @@ replicate_pool() { syncoid_opts="--recursive --force-delete" fi + # Configuration de la limitation de bande passante (option native syncoid) + if [[ -n "${BANDWIDTH_LIMIT_MBS}" ]] && [[ "${BANDWIDTH_LIMIT_MBS}" -gt 0 ]]; then + # Convertir MB/s en bytes/s pour syncoid (--source-bwlimit attend des bytes) + local bandwidth_bytes=$((BANDWIDTH_LIMIT_MBS * 1024 * 1024)) + syncoid_opts="${syncoid_opts} --source-bwlimit=${bandwidth_bytes}" + log "info" "Limitation de bande passante activée: ${BANDWIDTH_LIMIT_MBS} MB/s" + fi + # Lister les datasets de premier niveau sous le pool local first_level_datasets first_level_datasets=$(zfs list -H -o name -r "$pool" -t filesystem,volume -d 1 | grep -v "^${pool}$")