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

Aperta Adatta ai principianti
#6,022 1 commento 1 reazione 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@PAtreju ci sta già lavorando.

Dal 17/11/2026.

  • #6059 di @PAtreju — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, typescript
Ambito
backend, devops

Direzione di ricerca

Inizia in packages/server/src/utils/volume-backups/backup.ts, dove viene assemblato il comando docker run --rm -v ${volumeName}:/volume_data ... e il suo output viene trasmesso nel log di backup. Aggiungi un controllo docker volume inspect "$VOLUME" (o --mount type=volume,src=...,volume-nocopy) prima dell'esecuzione e indirizza l'errore verso lo stesso percorso di errore usato dai rami di errore esistenti, così che l'esecuzione venga contrassegnata come fallita invece di registrare Volume backup done ✅. Fatto significa che un nome di volume inesistente produce un errore chiaro e nessun tar caricato, mentre un volume valido viene comunque sottoposto a backup; il codice adiacente di backup del database è un riferimento utile per capire come vengono esposti gli errori.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
38.8k
Fork
3.2k
Merge medio
1g 8h
PR unite (30g)
117

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Dokploy/dokploy

Tutte le issue di Dokploy/dokploy

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.