Skip to main content
DNZ keeps zones, records, users, settings and logs in one database. Which one is picked by the scheme of database.url (DNZ_DATABASE_URL): DNZ works the same on all three; only where the data is kept changes. It creates and upgrades its own tables at startup, so give it an empty database and a user that may create tables in it.
Run one DNZ server per database. Each server keeps the zones in memory and reloads them when they change through it, so two servers sharing a database wouldn’t see each other’s changes. For more DNS servers, use replication: secondaries keep their own database.

Postgres

1

Create the database

2

Point DNZ at it

Or in dnz.toml:
3

Check and start

It prints database: Postgres at postgres://dnz:***@db.internal:5432/dnz. Start DNZ; it creates its tables and logs the same line.
  • TLS: add ?sslmode=require, or ?sslmode=verify-full&sslrootcert=/etc/dnz/db-ca.pem to check the server’s certificate.
  • Unix socket: postgres://dnz@localhost/dnz?host=/var/run/postgresql.
  • DNZ creates a case-insensitive ICU collation named nocase. Standard Postgres builds have ICU, including the Docker images and managed services.

MySQL

1

Create the database

2

Point DNZ at it

3

Check and start

It prints database: MySQL at mysql://dnz:***@db.internal:3306/dnz. Start DNZ; it creates its tables.
  • TLS: add ?ssl-mode=required, or ?ssl-mode=verify_identity&ssl-ca=/etc/dnz/db-ca.pem.
  • DNZ’s connections use ANSI_QUOTES, PIPES_AS_CONCAT and NO_BACKSLASH_ESCAPES, set per connection; the server’s own sql_mode can stay as it is. Tables are InnoDB with utf8mb4.

Connections and files

  • Characters such as @, : or / in the password go percent-encoded: p%40ss for p@ss.
  • DNZ keeps up to 16 connections to Postgres or MySQL open.
  • The password never shows up in dnz config show, dnz config check or the log.
  • Files DNZ keeps besides the database, the GeoIP database and the local dnz-proxy’s state, go in database.data_dir (DNZ_DATA_DIR). With SQLite that’s the database file’s folder. With Postgres or MySQL it’s the working directory: /var/lib/dnz with the systemd unit, /data in the Docker image.
  • The dashboard’s Server tab shows which database DNZ uses and how big it is.

Docker with Postgres

Save this as docker-compose.yml:
docker-compose.yml
Then start it with a password of your own:

Move an existing install from SQLite

dnz db migrate-from-sqlite copies a SQLite install into an empty Postgres or MySQL database. It copies every table in an order that keeps the foreign keys intact, sets the id sequences past the copied ids, and compares the row counts at the end.
Then set the new database in /etc/dnz/dnz.env and start DNZ:
/etc/dnz/dnz.env
The copy prints each table with its rows, then:
Stop DNZ before copying: changes made during the copy would be lost.
  • Without --to, the target is database.url / DNZ_DATABASE_URL.
  • The target must have no users or zones yet. The rows are copied in one transaction, so a copy that fails leaves the target empty to try again.
  • The SQLite file is first brought up to this version’s schema, as starting this version of DNZ on it would, and otherwise left alone. Going back is a matter of pointing DNZ_DATABASE_URL at it again.

Backups

With Postgres or MySQL, back up the database with its own tools:
For SQLite, see Backups and updates.