{"record":{"id":"0f9b6ecad5e58b7d","repo":"Dokploy/dokploy","slug":"error-instanceof-error-error-message-error-re-0f9b6e","errorCode":null,"errorMessage":"error instanceof Error ? error.message : \"Error restoring mariadb backup\"","messagePattern":"error instanceof Error \\? error\\.message : \"Error restoring mariadb backup\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/server/src/utils/restore/mariadb.ts","lineNumber":58,"sourceCode":"\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\n\t\t\t\t\t? error.message\n\t\t\t\t\t: \"Error restoring mariadb backup\"\n\t\t\t}`,\n\t\t);\n\t\tthrow new Error(\n\t\t\terror instanceof Error ? error.message : \"Error restoring mariadb backup\",\n\t\t);\n\t}\n};\n","sourceCodeStart":40,"sourceCodeEnd":63,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/utils/restore/mariadb.ts#L40-L63","documentation":"restoreMariadbBackup catches any failure in the execAsync-based mariadb restore (docker exec into the mariadb container, gunzip, mysql client) and rethrows error.message or the generic fallback. The true cause is visible in the console.error/emit lines preceding the throw.","triggerScenarios":"mysql client rejects the dump (SQL syntax/version mismatch, charset issues), container name not found, backup file corrupt/truncated, or wrong credentials inside the container.","commonSituations":"Restoring a dump made on a newer MariaDB/MySQL into an older container; gzip stream truncated during download; root password mismatch in the target container.","solutions":["Check the emitted 'Error: ...' line and container logs (docker logs mariadb) for the SQL-level cause","Confirm backup file integrity (gunzip -t) and retry the download/restore","Match MariaDB/MySQL major versions between backup source and target container","Verify container name and credentials used by the exec command"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"execSync('gunzip -t backup.sql.gz'); // validate archive first","typeGuard":null,"tryCatchPattern":"try {\n  await restoreMariadbBackup(...);\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e);\n  // inspect mariadb container logs for the SQL error, fix dump, retry\n}","preventionTips":["Strip DEFINER clauses from dumps for portability","Match MariaDB versions between environments"],"tags":["backup","restore","mariadb","mysql"],"backgroundTag":"backup-restore-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}