mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Enhance PostgreSQL backup command in web server utility
- Added error handling to check for the existence of the PostgreSQL container before executing the backup command. - Updated the backup command to use the retrieved container ID, ensuring the command runs correctly.
This commit is contained in:
parent
f4cd617107
commit
8e8bc3e71e
@ -23,7 +23,17 @@ export const runWebServerBackup = async (backup: BackupSchedule) => {
|
|||||||
try {
|
try {
|
||||||
await execAsync(`mkdir -p ${tempDir}/filesystem`);
|
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(postgresCommand);
|
||||||
|
|
||||||
await execAsync(`cp -r ${BASE_PATH}/* ${tempDir}/filesystem/`);
|
await execAsync(`cp -r ${BASE_PATH}/* ${tempDir}/filesystem/`);
|
||||||
|
Loading…
Reference in New Issue
Block a user