{"record":{"id":"9543840f1c33693c","repo":"Dokploy/dokploy","slug":"error-instanceof-error-error-message-error-re-954384","errorCode":null,"errorMessage":"error instanceof Error ? error.message : \"Error restoring mongo backup\"","messagePattern":"error instanceof Error \\? error\\.message : \"Error restoring mongo backup\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/server/src/utils/restore/mongo.ts","lineNumber":56,"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 mongo backup\"\n\t\t\t}`,\n\t\t);\n\t\tthrow new Error(\n\t\t\terror instanceof Error ? error.message : \"Error restoring mongo backup\",\n\t\t);\n\t}\n};\n","sourceCodeStart":38,"sourceCodeEnd":61,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/utils/restore/mongo.ts#L38-L61","documentation":"restoreMongoBackup catches failures of the mongorestore-based flow (docker exec into the mongo container with a gunzipped archive) and rethrows error.message or a generic fallback. Root cause is logged via console.error and emitted to the restore event stream.","triggerScenarios":"mongorestore version mismatch with the archive format (e.g. archive from newer mongodump), corrupt gzip stream, wrong mongo container name, or auth failure inside the container.","commonSituations":"Restoring a dump from MongoDB 6 into a 4.4 container; archive truncated mid-transfer; container stopped mid-restore.","solutions":["Inspect the emitted error and docker logs on the mongo container for mongorestore output","Validate the archive (gunzip -t, mongorestore --archive --dryRun if available)","Align mongodump/mongorestore and server versions between backup and restore targets","Ensure the mongo container is running and credentials are correct"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"execSync('gunzip -t archive.gz');","typeGuard":null,"tryCatchPattern":"try {\n  await restoreMongoBackup(...);\n} catch (e) {\n  // read emitted error lines, check mongorestore version compatibility\n}","preventionTips":["Use matching mongodump/mongorestore major versions","Validate archives before restore"],"tags":["backup","restore","mongodb","mongorestore"],"backgroundTag":"backup-restore-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}