{"record":{"id":"06d4773768f083a6","repo":"Dokploy/dokploy","slug":"database-file-not-found-after-extraction","errorCode":null,"errorMessage":"Database file not found after extraction","messagePattern":"Database file not found after extraction","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/server/src/utils/restore/web-server.ts","lineNumber":86,"sourceCode":"\n\t\t\t// Now handle database restore\n\t\t\temit(\"Starting database restore...\");\n\n\t\t\t// Check if database.sql.gz exists and decompress it\n\t\t\tconst { stdout: hasGzFile } = await execAsync(\n\t\t\t\t`ls ${tempDir}/database.sql.gz || true`,\n\t\t\t);\n\t\t\tif (hasGzFile.includes(\"database.sql.gz\")) {\n\t\t\t\temit(\"Found compressed database file, decompressing...\");\n\t\t\t\tawait execAsync(`cd ${tempDir} && gunzip database.sql.gz`);\n\t\t\t}\n\n\t\t\t// Verify database file exists\n\t\t\tconst { stdout: hasSqlFile } = await execAsync(\n\t\t\t\t`ls ${tempDir}/database.sql || true`,\n\t\t\t);\n\t\t\tif (!hasSqlFile.includes(\"database.sql\")) {\n\t\t\t\tthrow new Error(\"Database file not found after extraction\");\n\t\t\t}\n\n\t\t\tconst { stdout: postgresContainer } = await execAsync(\n\t\t\t\t`docker ps --filter \"name=dokploy-postgres\" --filter \"status=running\" -q | head -n 1`,\n\t\t\t);\n\n\t\t\tif (!postgresContainer) {\n\t\t\t\tthrow new Error(\"Dokploy Postgres container not found\");\n\t\t\t}\n\n\t\t\tconst postgresContainerId = postgresContainer.trim();\n\n\t\t\t// Drop and recreate database\n\t\t\temit(\"Disconnecting all users from database...\");\n\t\t\tawait execAsync(\n\t\t\t\t`docker exec ${postgresContainerId} psql -U dokploy postgres -c \"SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'dokploy' AND pid <> pg_backend_pid();\"`,\n\t\t\t);\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/utils/restore/web-server.ts#L68-L104","documentation":"During web-server backup restore, after extracting the archive the code expects tempDir/database.sql to exist; if `ls` output doesn't contain it, the backup is considered incomplete. This guards before dropping/recreating the Dokploy Postgres database.","triggerScenarios":"Backup archive lacks database.sql (config-only backup), extraction failed silently, archive is corrupt, or the file has a different name/path layout than expected.","commonSituations":"Uploading an old or partial backup file; a backup taken while the DB dump step failed; archive created by a different Dokploy version with a different layout.","solutions":["Open the backup archive and confirm database.sql exists at the expected path","Re-create the backup ensuring the database dump step succeeded","Match the Dokploy version that produced the backup","Check extraction logs for errors before this check"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const list = execSync(`tar -tzf ${backupFile}`).toString();\nif (!list.includes('database.sql')) {\n  throw new Error('Backup is missing the database dump — do not restore');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inspect archive contents before initiating a restore","Never restore archives from unknown/partial sources"],"tags":["backup","restore","postgres","validation"],"backgroundTag":"backup-restore-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}