Fix: SQL import exclude backup dir, vervang process substitution door pipe, error handling in loop

This commit is contained in:
root
2026-06-05 23:20:12 +02:00
parent d26e9330ed
commit 506c48ba73
+4 -4
View File
@@ -58,13 +58,13 @@ echo "--> Creating automatic database backup before update..."
mkdir -p "$BACKUP_DIR" mkdir -p "$BACKUP_DIR"
mariadb-dump $MYSQL_CRED --force --skip-lock-tables "$DB_NAME" > "$BACKUP_DIR/backup_$(date +%Y%m%d_%H%M%S).sql" || echo "--> Backup heeft ontbrekende tabellen (niet kritisch) — update gaat verder" mariadb-dump $MYSQL_CRED --force --skip-lock-tables "$DB_NAME" > "$BACKUP_DIR/backup_$(date +%Y%m%d_%H%M%S).sql" || echo "--> Backup heeft ontbrekende tabellen (niet kritisch) — update gaat verder"
# --- Automatic SQL Import --- # --- Automatic SQL Import (exclusief backup dir) ---
echo "--> Checking for new SQL files..." echo "--> Checking for new SQL files..."
if [ -d "$SQL_DIR" ]; then if [ -d "$SQL_DIR" ]; then
while IFS= read -r -d '' sql_file; do find "$SQL_DIR" -name "*.sql" -mmin -10 -not -path "$BACKUP_DIR/*" -print0 2>/dev/null | while IFS= read -r -d '' sql_file; do
echo "--> Importing new SQL file: $(basename "$sql_file")" echo "--> Importing new SQL file: $(basename "$sql_file")"
mariadb $MYSQL_CRED --force "$DB_NAME" < "$sql_file" mariadb $MYSQL_CRED --force "$DB_NAME" < "$sql_file" || echo "--> Fout bij importeren $(basename "$sql_file"), naar volgende..."
done < <(find "$SQL_DIR" -name "*.sql" -mmin -10 -print0 2>/dev/null) done
else else
echo "--> SQL directory not found, skipping SQL import." echo "--> SQL directory not found, skipping SQL import."
fi fi