feat : debbug more easy

This commit is contained in:
2026-03-17 16:23:43 +01:00
parent 41df83fe32
commit f6e66e7bff

View File

@@ -98,6 +98,18 @@ require_cmd() {
command -v "$1" >/dev/null 2>&1
}
download_remote_file() {
local remote_path="$1"
local local_path="$2"
if scp "${SSH_OPTS[@]}" "${REMOTE_SSH}:${remote_path}" "$local_path" >>"$LOG_FILE" 2>&1; then
return 0
fi
log "Téléchargement scp standard échoué, tentative avec scp -O"
scp -O "${SSH_OPTS[@]}" "${REMOTE_SSH}:${remote_path}" "$local_path" >>"$LOG_FILE" 2>&1
}
to_bool_yes_no() {
local v="${1:-}"
v="${v,,}"
@@ -338,14 +350,14 @@ LOCAL_DB_DUMP_FILE="${LOCAL_RESTORE_DIR}/$(basename "$LAST_REMOTE_DB_DUMP")"
LOCAL_ROLES_FILE=""
log "Téléchargement du dump principal"
scp "${SSH_OPTS[@]}" "${REMOTE_SSH}:${LAST_REMOTE_DB_DUMP}" "$LOCAL_DB_DUMP_FILE" \
>>"$LOG_FILE" 2>&1 || fail "échec téléchargement du dump principal"
download_remote_file "$LAST_REMOTE_DB_DUMP" "$LOCAL_DB_DUMP_FILE" \
|| fail "échec téléchargement du dump principal"
if [[ -n "$LAST_REMOTE_ROLES_FILE" ]]; then
LOCAL_ROLES_FILE="${LOCAL_RESTORE_DIR}/$(basename "$LAST_REMOTE_ROLES_FILE")"
log "Téléchargement du fichier des rôles"
scp "${SSH_OPTS[@]}" "${REMOTE_SSH}:${LAST_REMOTE_ROLES_FILE}" "$LOCAL_ROLES_FILE" \
>>"$LOG_FILE" 2>&1 || fail "échec téléchargement du fichier des rôles"
download_remote_file "$LAST_REMOTE_ROLES_FILE" "$LOCAL_ROLES_FILE" \
|| fail "échec téléchargement du fichier des rôles"
fi
DB_EXISTS="$(
@@ -469,4 +481,4 @@ Log : ${LOG_FILE}"
send_discord_message "$SUCCESS_MESSAGE"
log "Restauration terminée avec succès pour ${DB}"
print_json_and_exit "success" "restauration terminée avec succès" 0
print_json_and_exit "success" "restauration terminée avec succès" 0