dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Server backup fails if `dokploy-postgres` service is not found (but DATABASE_URL is)

Open oskargargas opened this issue 3 months ago • 2 comments

To Reproduce

  1. Setup database on 3rd party server
  2. Provide DATABASE_URL to Dokploy
  3. Install Dokploy without default dokploy-postgres service
  4. 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

oskargargas avatar Oct 18 '25 16:10 oskargargas

@Siumauricio any chance this will be implemented?

oskargargas avatar Nov 08 '25 11:11 oskargargas

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

Siumauricio avatar Nov 26 '25 06:11 Siumauricio

I won't be proceeding with this feature for now, I'm very sorry.

I'll close it for now.

Siumauricio avatar Dec 07 '25 00:12 Siumauricio

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.

oskargargas avatar Dec 11 '25 13:12 oskargargas