From b506b4499a8a57cf778a0f6b6e87ad486059f545 Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 30 Aug 2026 19:17:50 +0200 Subject: [PATCH] fix: resilient DB backups and Dragonfly detection in health/status --- update-Nitrov3.sh | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/update-Nitrov3.sh b/update-Nitrov3.sh index c388a288..cb773d3e 100755 --- a/update-Nitrov3.sh +++ b/update-Nitrov3.sh @@ -799,6 +799,18 @@ service_active() { fi } +# Redis protocol server name: classic redis-server or Dragonfly (drop-in +# replacement that also speaks the redis protocol, e.g. in production hotels). +redis_backend() { + if service_active redis-server; then echo redis-server + elif service_active dragonfly; then echo dragonfly + else echo redis-server; fi +} + +redis_active() { + service_active redis-server || service_active dragonfly +} + format_size() { local bytes="${1:-0}" if command -v numfmt &>/dev/null; then @@ -2768,7 +2780,18 @@ cmd_backup() { local sz=$(stat -c%s "$bf" 2>/dev/null || echo 0); spinner_stop ok ok "Backup: %s — %s" "$(format_size "$sz")" "$(basename "$bf")" else - spinner_stop fail; die "Backup failed" + # The DB user may lack routine/trigger/event privileges (common on + # restricted MySQL accounts). Retry data-only instead of failing, and + # never leave a half-written dump behind. + rm -f "$bf" 2>/dev/null || true + if $MYSQL_DUMP $MYSQL_CRED --force --skip-lock-tables "$DB_NAME" > "$bf" 2>/dev/null; then + local sz2=$(stat -c%s "$bf" 2>/dev/null || echo 0); spinner_stop ok + warn "Routines/triggers/events skipped (insufficient privileges)" + ok "Backup: %s — %s" "$(format_size "$sz2")" "$(basename "$bf")" + else + rm -f "$bf" 2>/dev/null || true + spinner_stop fail; die "Backup failed" + fi fi } @@ -2829,7 +2852,7 @@ cmd_status() { box_kv "Database:" "${dbs}MB / ${dbt} tables" 56; box_bottom 56 echo "" box_top "SERVICES" 56 - for svc in nginx mariadb redis-server "$EMULATOR_SERVICE" php-fpm cron; do + for svc in nginx mariadb "$(redis_backend)" "$EMULATOR_SERVICE" php-fpm cron; do local st="${C_DIM}N/A${C_RESET}" service_active "$svc" && st="${C_GREEN}ACTIVE${C_RESET}" printf " ${C_CYAN}║${C_RESET} %-20s %b${C_CYAN} ║${C_RESET}\n" "$svc" "$st" @@ -2904,7 +2927,7 @@ cmd_health() { checkw "Emulator" test -d "$EMULATOR_MODULE"; checkw "Octane" test -d "$NITRO_CLIENT"; checkw "Renderer" test -d "$NITRO_RENDERER" checkw "$(_t "Gamedata config")" test -d "$GAMEDATA_CONF_DIR"; checkw "$(_t "Backup dir")" test -d "$BACKUP_DIR" echo -e "\n ${C_BOLD}$(_t "Services:")${C_RESET}" - checkw "MariaDB" service_active mariadb; checkw "Nginx" service_active nginx; checkw "Redis" service_active redis-server + checkw "MariaDB" service_active mariadb; checkw "Redis" redis_active; checkw "Nginx" service_active nginx checkw "$EMULATOR_SERVICE" service_active "$EMULATOR_SERVICE" echo -e "\n ${C_BOLD}$(_t "Network:")${C_RESET}" checkw "$(_t "Nginx config")" nginx -t 2>/dev/null