Server backup fails if `dokploy-postgres` service is not found (but DATABASE_URL is)
To Reproduce
- Setup database on 3rd party server
- Provide DATABASE_URL to Dokploy
- Install Dokploy without default
dokploy-postgresservice - Configure server backup and run
Current vs. Expected behavior
Current
Dokploy backup fails, doesn't backup DB nor filesystem
Expected
Backup works correctly, backs up DB as it is setup via DATABASE_URL as well as filesystem
Provide environment information
Dokploy version: 0.25.5
Which area(s) are affected? (Select all that apply)
Installation
Are you deploying the applications where Dokploy is installed or on a remote server?
Same server where Dokploy is installed
Additional context
Dokploy configuration that allows to run it with 3rd party DB via DATABASE_URL env var:
https://github.com/Dokploy/dokploy/blob/ceb4cc453eed0dc017888cd09cc4b2b05724646c/apps/dokploy/server/db/index.ts#L9-L11
Backup configuration that fails automatically if dokploy-service is not found:
https://github.com/Dokploy/dokploy/blob/ceb4cc453eed0dc017888cd09cc4b2b05724646c/packages/server/src/utils/backups/web-server.ts#L39-L48
Backup restore configuration that fails automatically if dokploy-service is not found:
https://github.com/Dokploy/dokploy/blob/ceb4cc453eed0dc017888cd09cc4b2b05724646c/packages/server/src/utils/restore/web-server.ts#L86-L92
Will you send a PR to fix it?
No
@Siumauricio any chance this will be implemented?
I don't think this can be implemented @oskargargas . We would have to add an extra layer to be able to detect an external database and also figure out how to make a backup since it is remote. The web backup server expects everything to be on the same server unfortunately
I won't be proceeding with this feature for now, I'm very sorry.
I'll close it for now.
That's a shame, especially that you allow to run with a remote DB set via DATABASE_URL.
But to be clear @Siumauricio the main pain point is not about making a backup of remote server. It'd be nice but I understand it requires a copy of pg_dump which would be needed for the process. The pain point is the failure of dokploy filestructure backup.
It's something like
if (process.env.DATABASE_URL) {
console.out("WARNING: DB Backup skipped");
} else {
// First dump the database inside the container
const dumpCommand = `docker exec ${postgresContainerId} pg_dump -v -Fc -U dokploy -d dokploy -f /tmp/database.sql`;
writeStream.write(`Running dump command: ${dumpCommand}\n`);
await execAsync(dumpCommand);
// Then copy the file from the container to host
const copyCommand = `docker cp ${postgresContainerId}:/tmp/database.sql ${tempDir}/database.sql`;
writeStream.write(`Copying database dump: ${copyCommand}\n`);
await execAsync(copyCommand);
// Clean up the temp file in the container
const cleanupCommand = `docker exec ${postgresContainerId} rm -f /tmp/database.sql`;
writeStream.write(`Cleaning up temp file: ${cleanupCommand}\n`);
await execAsync(cleanupCommand);
}
In the https://github.com/Dokploy/dokploy/blob/ceb4cc453eed0dc017888cd09cc4b2b05724646c/packages/server/src/utils/backups/web-server.ts#L54
Anyway, I'll hack something for myself as I don't plan on running production setup with DB on the same server as Dokploy instance. It feels too insecure.