Add CIFS remount retry for Tomedo rsync
This commit is contained in:
@@ -89,6 +89,8 @@ TOMEDO_LAST_FILE="${TOMEDO_SRC_ROOT}/lastFilesBackup"
|
|||||||
TOMEDO_DEST_ROOT="${CIFS_MOUNTPOINT}/TomedoBackup"
|
TOMEDO_DEST_ROOT="${CIFS_MOUNTPOINT}/TomedoBackup"
|
||||||
TOMEDO_MACOS_EXCLUDES="${TOMEDO_DEST_ROOT}/macos.excludes"
|
TOMEDO_MACOS_EXCLUDES="${TOMEDO_DEST_ROOT}/macos.excludes"
|
||||||
TOMEDO_FILES_EXCLUDES="${TOMEDO_DEST_ROOT}/files.excludes"
|
TOMEDO_FILES_EXCLUDES="${TOMEDO_DEST_ROOT}/files.excludes"
|
||||||
|
TOMEDO_RSYNC_MAX_RETRIES=3
|
||||||
|
TOMEDO_RSYNC_RETRY_SLEEP=5
|
||||||
|
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
# Hilfsfunktionen
|
# Hilfsfunktionen
|
||||||
@@ -269,6 +271,45 @@ ensure_cifs() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_rsync_with_cifs_retry() {
|
||||||
|
local label="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
local attempt rc=0
|
||||||
|
for ((attempt=1; attempt<=TOMEDO_RSYNC_MAX_RETRIES; attempt++)); do
|
||||||
|
ensure_cifs
|
||||||
|
log "rsync ${label}: Versuch ${attempt}/${TOMEDO_RSYNC_MAX_RETRIES}"
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rsync "$@"
|
||||||
|
rc=$?
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ "$rc" -eq 0 ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$rc" -eq 11 || "$rc" -eq 12 || "$rc" -eq 30 || "$rc" -eq 35 ]]; then
|
||||||
|
if [[ "$attempt" -lt "$TOMEDO_RSYNC_MAX_RETRIES" ]]; then
|
||||||
|
log "WARNUNG: rsync ${label} fehlgeschlagen (rc=$rc). Remount und Retry in ${TOMEDO_RSYNC_RETRY_SLEEP}s."
|
||||||
|
if mountpoint -q "$CIFS_MOUNTPOINT"; then
|
||||||
|
umount "$CIFS_MOUNTPOINT" 2>/dev/null || umount -l "$CIFS_MOUNTPOINT" || true
|
||||||
|
fi
|
||||||
|
sleep "$TOMEDO_RSYNC_RETRY_SLEEP"
|
||||||
|
mount_cifs
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
log "FEHLER: rsync ${label} nach ${TOMEDO_RSYNC_MAX_RETRIES} Versuchen fehlgeschlagen (rc=$rc)."
|
||||||
|
return "$rc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "FEHLER: rsync ${label} fehlgeschlagen (rc=$rc)."
|
||||||
|
return "$rc"
|
||||||
|
done
|
||||||
|
|
||||||
|
return "$rc"
|
||||||
|
}
|
||||||
|
|
||||||
copy_to_paperless_flat_if_allowed_ext() {
|
copy_to_paperless_flat_if_allowed_ext() {
|
||||||
local src="$1"
|
local src="$1"
|
||||||
local rel="$2"
|
local rel="$2"
|
||||||
@@ -414,15 +455,16 @@ rsync_tomedo_backup() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$dst_snapshot" "$dst_files"
|
mkdir -p "$dst_snapshot" "$dst_files"
|
||||||
|
local tomedo_rsync_opts=(-r -l -t -O --info=progress2 --temp-dir=/tmp)
|
||||||
|
|
||||||
log "== rsync Tomedo Snapshot: $src_snapshot -> $dst_snapshot =="
|
log "== rsync Tomedo Snapshot: $src_snapshot -> $dst_snapshot =="
|
||||||
rsync -r -l -t -O --info=progress2 \
|
run_rsync_with_cifs_retry "Tomedo Snapshot" "${tomedo_rsync_opts[@]}" \
|
||||||
--exclude-from "$TOMEDO_MACOS_EXCLUDES" \
|
--exclude-from "$TOMEDO_MACOS_EXCLUDES" \
|
||||||
"$src_snapshot" \
|
"$src_snapshot" \
|
||||||
"$dst_snapshot"
|
"$dst_snapshot"
|
||||||
|
|
||||||
log "== rsync Tomedo Files: $src_files -> $dst_files =="
|
log "== rsync Tomedo Files: $src_files -> $dst_files =="
|
||||||
rsync -r -l -t -O --info=progress2 \
|
run_rsync_with_cifs_retry "Tomedo Files" "${tomedo_rsync_opts[@]}" \
|
||||||
--exclude-from "$TOMEDO_MACOS_EXCLUDES" \
|
--exclude-from "$TOMEDO_MACOS_EXCLUDES" \
|
||||||
--exclude-from "$TOMEDO_FILES_EXCLUDES" \
|
--exclude-from "$TOMEDO_FILES_EXCLUDES" \
|
||||||
"$src_files" \
|
"$src_files" \
|
||||||
|
|||||||
Reference in New Issue
Block a user