Merge pull request #1723 from Dokploy/1682-dokploy-backup-fails

Enhance PostgreSQL backup command in web server utility
This commit is contained in:
Mauricio Siu 2025-04-17 01:59:05 -06:00 committed by GitHub
commit 8eaa006f0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,7 +23,17 @@ export const runWebServerBackup = async (backup: BackupSchedule) => {
try {
await execAsync(`mkdir -p ${tempDir}/filesystem`);
const postgresCommand = `docker exec $(docker ps --filter "name=dokploy-postgres" -q) pg_dump -v -Fc -U dokploy -d dokploy > ${tempDir}/database.sql`;
// First get the container ID
const { stdout: containerId } = await execAsync(
"docker ps --filter 'name=dokploy-postgres' -q",
);
if (!containerId) {
throw new Error("PostgreSQL container not found");
}
// Then run pg_dump with the container ID
const postgresCommand = `docker exec ${containerId.trim()} pg_dump -v -Fc -U dokploy -d dokploy > '${tempDir}/database.sql'`;
await execAsync(postgresCommand);
await execAsync(`cp -r ${BASE_PATH}/* ${tempDir}/filesystem/`);