{"record":{"id":"89f4e14d810b6d6c","repo":"Dokploy/dokploy","slug":"error-instanceof-error-error-message-error-re-89f4e1","errorCode":null,"errorMessage":"error instanceof Error ? error.message : \"Error restoring mysql backup\"","messagePattern":"error instanceof Error \\? error\\.message : \"Error restoring mysql backup\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/server/src/utils/restore/mysql.ts","lineNumber":55,"sourceCode":"\t\temit(\n\t\t\t`Restoring database: ${backupInput.databaseName} from ${backupInput.backupFile}`,\n\t\t);\n\n\t\tif (serverId) {\n\t\t\tawait execAsyncRemote(serverId, command);\n\t\t} else {\n\t\t\tawait execAsync(command);\n\t\t}\n\n\t\temit(\"Restore completed successfully!\");\n\t} catch (error) {\n\t\tconsole.error(error);\n\t\temit(\n\t\t\t`Error: ${\n\t\t\t\terror instanceof Error ? error.message : \"Error restoring mysql backup\"\n\t\t\t}`,\n\t\t);\n\t\tthrow new Error(\n\t\t\terror instanceof Error ? error.message : \"Error restoring mysql backup\",\n\t\t);\n\t}\n};\n","sourceCodeStart":37,"sourceCodeEnd":60,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/utils/restore/mysql.ts#L37-L60","documentation":"restoreMySqlBackup catches any failure in the mysql restore flow (docker exec, gunzip, mysql client import) and rethrows error.message or the generic fallback. The underlying reason appears in console.error and the emit stream right before the throw.","triggerScenarios":"SQL dump incompatible with target MySQL version, DEFINER clauses referencing missing users, corrupt backup file, container/credentials wrong, or disk full during import.","commonSituations":"Importing a dump with DEFINER=`olduser`@`%` clauses into a fresh container; restoring a truncated gzip; mysql client OOM on huge dumps.","solutions":["Check the emitted message and docker logs for the failing SQL statement","Strip or rewrite DEFINER clauses if users don't exist on target (sed on the dump)","Verify archive integrity and MySQL version compatibility","Increase container memory/disk and retry"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"execSync('gunzip -t dump.sql.gz');","typeGuard":null,"tryCatchPattern":"try {\n  await restoreMySqlBackup(...);\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  if (/DEFINER/.test(msg)) stripDefinersAndRetry();\n}","preventionTips":["Normalize dumps (--set-gtid-purged=OFF, strip DEFINER)","Version-align MySQL between backup and restore"],"tags":["backup","restore","mysql"],"backgroundTag":"backup-restore-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}