Layers for developers

Self-hosted Layers backup: database, files, keys

The self-hosted page answers “How do I make backups?” in three lines. Miss one and a restore is incomplete.

What to copy

Part Where it is
Database sudo docker compose exec -T db pg_dump -U layers -d layersdb -Fc -Z6 | sudo tee backup.dump >/dev/null
People's files /opt/layers/data/layers
Keys the .env file and /opt/layers/license

What the flags mean

PostgreSQL 16 docs: -Fc outputs a custom-format archive suitable for input into pg_restore; -Z sets the compression level. Run the command from /opt/layers, where the compose file is.

Example

Illustrative example only. Dump every night at 02:00, keep 7 daily and 4 weekly copies: 11 files. At 400 MB per dump that is 11 × 400 MB = 4.4 GB, so plan the copy target for it. Each Monday the admin writes in the status report: last dump date, its size, and whether the files and keys were copied too.

⚠️ Important

The page is clear: without .env the server cannot be restored from a backup. Keep the copies off the server itself, and treat .env as a secret: it holds the passwords.

Every week

  • ☐ Database dump made and copied off the server
  • ☐ /opt/layers/data/layers copied
  • ☐ .env and /opt/layers/license stored safely
  • ☐ Size and date written in the report

Weekly status report, ready: one row a week for the backup check 👇

Source: layers.md/self-hosted (FAQ “How do I make backups?”); PostgreSQL 16 documentation, pg_dump.

Source