Volume backup silently uploads an empty tar when the volume does not exist on the host (stack prefix missing / service on swarm worker)

Open Beginner friendly
#6,022 1 comment 1 reaction 1 assignee View on GitHub

Maintainers usually reply within 1 day

@PAtreju is already working on this.

Since Nov 17, 2026.

  • #6059 by @PAtreju — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, typescript
Domain
backend, devops

Research direction

Start in packages/server/src/utils/volume-backups/backup.ts, where the docker run --rm -v ${volumeName}:/volume_data ... command is assembled and its output streamed into the backup log. Add a docker volume inspect "$VOLUME" (or --mount type=volume,src=...,volume-nocopy) check before the run and route the failure into the same error path the existing failure branches use, so the run is marked failed instead of logging Volume backup done ✅. Done means a nonexistent volume name produces a clear error and no uploaded tar, while a valid volume still backs up; the sibling database-backup code is a useful reference for how errors are surfaced.

Written by the indexing model from the issue text.

Description

bug
To Reproduce
  1. Create a Docker Compose service of type Stack (swarm) with a named volume, e.g. pgdata. Docker creates it as <appName>_pgdata.
  2. Add a volume backup with volume name pgdata, i.e. without the stack prefix. The UI accepts any string.
  3. Alternative way to trigger it: use the correct full name, but pin the service to a worker node. The backup command always runs on the Dokploy/manager server, so the volume does not exist there.
  4. Run the volume backup, manually or on its schedule.
Current vs. Expected behavior

Current: The backup runs docker run --rm -v ${volumeName}:/volume_data ... ubuntu tar cvf ... (packages/server/src/utils/volume-backups/backup.ts). If no volume with that name exists on the host, docker run silently creates a new empty volume, and an empty tar of 10240 bytes is uploaded. The log ends with Volume backup done ✅ / Upload to S3 done ✅, so nothing tells you the backup is useless.

We only found out when we needed a restore. A Postgres volume had been "backed up" every night for two months, and all 60 retained files were empty tars. Seven of our 17 volume backups were affected:

  • some because the stack prefix was missing from the configured name,
  • some because the service runs on a swarm worker.

Each run also leaves an empty stray volume with the configured name on the manager.

Expected:

  • The backup fails with a clear error if the volume does not exist on the host where the command runs. For example, check docker volume inspect "$VOLUME" before the docker run, or use --mount type=volume,src=...,volume-nocopy. Plain -v auto-creates the volume, so it does not help here.
  • Optionally, the UI validates or suggests the real volume name (including the <appName>_ prefix for stacks).
  • Optionally, a warning when the backed-up volume is empty.

The swarm worker case is the broader limitation tracked in #2692, and #3516 covers it for database backups. Database backups at least fail with Container not found there. Volume backups report success instead, which is the dangerous part.

Provide environment information
Dokploy version: v0.31.1 (code checked against v0.31.2, same behavior)
OS: Debian 13
Setup: 2-node Docker Swarm (Dokploy on the manager, services on manager and worker), Compose type "Stack"
Destination: S3-compatible
Which area(s) are affected? (Select all that apply)

Docker Compose, Docker

Are you deploying the applications where Dokploy is installed or on a remote server?

Both

Additional context

Minimal demonstration of the root cause:

docker volume ls -q | grep -x does-not-exist   # nothing
docker run --rm -v does-not-exist:/volume_data ubuntu bash -c 'cd /volume_data && tar cf - . | wc -c'
# 10240  -> empty tar, exit code 0
docker volume ls -q | grep -x does-not-exist   # now exists (created by the run)
Will you send a PR to fix it?

No

Dominant language
TypeScript
Stars
38.8k
Forks
3.2k
Avg merge
1d 8h
Merged PRs (30d)
117

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Dokploy/dokploy

All issues in Dokploy/dokploy

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.