Skip to content

Latest commit

 

History

History
114 lines (94 loc) · 3.96 KB

dokploy.mdx

File metadata and controls

114 lines (94 loc) · 3.96 KB
title Dokploy
description Back up the Dokploy panel, its database, and your apps' Docker volumes.
icon rocket

Deploy with confidence, restore with even more.

On a Dokploy server nearly everything that matters lives in Docker: your apps, their volumes, and Dokploy's own database. The whole-server job deliberately skips /var/lib/docker, so on its own it backs up the OS and none of your apps. Add the two jobs below next to it.

The panel: config and database

Dokploy keeps its configuration under /etc/dokploy (applications, compose files, Traefik config and certificates, SSH keys) and its state in a Postgres service called dokploy-postgres. This job dumps that database from inside its container, the same way Dokploy's own web-server backup does, and archives both. No password is needed: the dump connects through the container's local socket.

- name: dokploy
  sources: [/etc/dokploy]
  exclude:
    - /etc/dokploy/volume-backups
    - /etc/dokploy/logs
  databases:
    - name: dokploy
      type: postgres
      container: dokploy-postgres
      user: dokploy
      database: dokploy
  destinations: [offsite]
  schedule: "0 3 * * *"
  encryption:
    passphrase: ${BACKUP_PASSPHRASE}
  retention: { keep_last: 14 }
Always encrypt this job. `/etc/dokploy` contains SSH keys, TLS certificates and app environment variables.

Your apps: Docker volumes

Named volumes hold your apps' data (uploads, files, and the data directories of databases you created in Dokploy).

- name: dokploy-volumes
  sources: [/var/lib/docker/volumes]
  exclude:
    - /var/lib/docker/volumes/dokploy-postgres
    - /var/lib/docker/volumes/backingFsBlockDev
  destinations: [offsite]
  schedule: "30 3 * * *"
  encryption:
    passphrase: ${BACKUP_PASSPHRASE}
  retention: { keep_last: 7, keep_days: 30 }

To see what's in there and how big each volume is:

docker volume ls
du -sh /var/lib/docker/volumes/* | sort -h

Databases you created in Dokploy

Volumes are copied while the containers run. That's fine for files, but a database's raw data directory can be caught mid-write. Dump each database you created in Dokploy instead, using the App Name from its Dokploy page as the container. Dokploy runs it as a Swarm service, and NoBackups matches the <app-name>.1.xyz container automatically.

- name: dokploy-databases
  databases:
    - type: postgres
      container: myapp-postgres-k1x2y3      # the database's App Name in Dokploy
      user: myapp                           # its Database User in Dokploy
      password: ${MYAPP_DB_PASSWORD}
    - type: mariadb
      container: blog-mariadb-a9b8c7
      password: ${BLOG_DB_ROOT_PASSWORD}
  destinations: [offsite]
  schedule: "0 */6 * * *"
  encryption:
    passphrase: ${BACKUP_PASSPHRASE}
  retention: { keep_last: 28 }

Then add those databases' volumes to the dokploy-volumes job's exclude. The credentials are on each database's page in Dokploy.

Restoring

Install Dokploy on the new server as usual and install NoBackups with the same config. Don't create any projects yet; they'd be overwritten. ```bash nobackups restore dokploy --target / c=$(docker ps --filter name=dokploy-postgres -q | head -n 1) docker exec -i "$c" pg_restore -U dokploy -d dokploy --clean --if-exists \ < /nobackups-databases/dokploy.dump docker service update --force dokploy rm -rf /nobackups-databases ``` Stop the app in Dokploy first, then:
```bash
nobackups restore dokploy-volumes --target / --path var/lib/docker/volumes/<volume-name>
```

Start the app again in Dokploy.
Rehearse this on a throwaway VPS once. Dokploy restores have a few moving parts, and you want to discover them on a quiet afternoon rather than during an outage.