If Zigbee2MQTT restarts with an empty device list, preserve its data before trying another restart or re-pairing the mesh. A missing, empty or truncated database.db is one possible explanation. A different data directory, an unmounted Docker volume, permissions problems or a coordinator that started a new network can produce a similar incident. An empty frontend alone does not identify the cause.
The useful distinction is between the device records on the host and the network state on the coordinator. Losing the former does not necessarily erase the latter, so there may be a recovery path that avoids resetting every device. This guide combines the reported incidents below with the database and controller code shipped in Zigbee2MQTT 2.14.2; it does not claim a reproduced database-wipe test. Our ghost device troubleshooting and last_seen guides cover related symptoms that need their own diagnosis.
Save a dated copy of the entire actual data directory, including logs and any database.db.backup, database.db.tmp or older copies, outside that directory. Do this before shutdown as well as before startup: a running process can write its in-memory state when it stops. Treat these copies as sensitive because configuration and coordinator backups can contain credentials and keys.
What database.db actually stores, and how it differs from a coordinator backup
database.db is the host-side zigbee-herdsman database used by Zigbee2MQTT. Its device and group records include identities, endpoints, cluster information and interview state. It is a line-oriented JSON file despite the .db extension; SQLite recovery commands do not apply. Friendly names and device-specific settings also depend on configuration.yaml or its referenced device/group files, while cached published values can live in state.json. Restoring only one file is not the same as restoring the complete application.
coordinator_backup.json is separate. On supported adapters it contains network parameters and security state, including identifiers, channel and key material, plus adapter/device information. It does not contain a complete replacement for every endpoint and interview record in database.db. The coordinator also has persistent state of its own. A healthy radio can therefore retain the network when the host has forgotten its device records, and a good database cannot by itself repair an erased coordinator.
Zigbee2MQTT’s adapter documentation currently limits coordinator backup support to zStack and EmberZNet adapters. Do not assume every installation will have that JSON file, or that backups can be restored interchangeably across every adapter. Our coordinator firmware update guide covers the network-side planning.
Back up the whole data directory and record the Zigbee2MQTT version, adapter type and firmware. Host device records, configuration and coordinator state serve different purposes and should describe the same network.
Known triggers: which restarts have been reported to wipe it
| Source and environment | What was reported | What it establishes |
|---|---|---|
| Issue #28657, September 2025, systemd/LXC | Devices disappeared after an update and frontend restart. The reporter also reproduced loss after systemctl restart; the live file was 561 bytes beside a 16 KB saved copy. |
A particular installation lost records across restarts. The pasted recovery copy is named database.db.BAK; this is not proof that every normal restart creates a rolling backup. |
| Discussion #19924, Zigbee2MQTT 1.33.2 in Docker | The reporter said frontend restart, automatic container restart and docker restart emptied the file; separate docker stop and docker start did not. |
A historical workaround for that environment, not a guarantee that stop/start prevents loss on other systems. |
| Issue #19988, Zigbee2MQTT 1.34.0 and network-connected coordinators | The initial ZB-GW03 report and later comments describe intermittent device loss, including around network or service restarts; some recovered from saved data. | A network-connected coordinator is part of those reports. That is different from a network-mounted data directory, and the thread does not establish storage mounts as the cause. |
These reports are valuable incident records, but similar symptoms do not establish one bug that persisted unchanged across all releases. Issue closure as stale or not planned also does not establish either a fix or a continuing defect in the version you run. Keep the exact version, adapter startup log and host/container configuration with your own incident record.
A restart can reveal a problem that happened earlier: the old process knew devices in memory, while the new process reads an empty or different file. Conversely, restoring a file while the old process is still running lets that process overwrite the replacement from memory. Establish which process and directory you are examining before drawing conclusions about the restart command.
Is this corruption, or a different root cause entirely?
First compare Zigbee2MQTT’s configured data location with the directory or volume you expected it to use. For Docker, check the host-to-container mount and whether the intended storage was mounted before startup. Check ownership, write access, free space and host logs for I/O or filesystem errors. These are diagnostic checks, not a finding that any particular filesystem caused the reports above. Preserve the startup log, especially whether the adapter resumed, restored or formed/reset a network.
A tiny file containing only a coordinator record is different from a file with invalid JSON lines, and both differ from a full database that the frontend cannot display. In issue #19645, the report concerned devices gradually becoming uncontrollable and a later comment associated an extra endpoint with the symptom. That record does not substantiate a near-full EXT4 volume or journal-error diagnosis. Do not treat every use of the word “corrupt” as a whole-file wipe.
The released database code reads the file one JSON record per line. It logs parse failures and skips those lines; it does not automatically load database.db.backup if records are missing. A missing or empty file starts with no stored records. Current writes use a temporary file, synchronize it and rename it into place, so historical reports of truncation are not a reason to describe every current write as directly truncating the live file.
The controller code makes a more important distinction: it copies the live database to the configured database.db.backup path when adapter startup reports a network reset, before clearing the database. That file is not a guaranteed, regularly refreshed copy of a healthy database. Normal periodic saves and shutdown save the current database, while coordinator backup follows a separate path. Repeated startup with a reset can replace a useful saved database with the wrong state.
Issue #24612 requested reconstruction after database loss and includes a contributor’s best-effort Python prototype based on coordinator backup and configuration. It is now closed as not planned. The prototype is not built-in automatic repair and cannot be assumed to recover all original device information.
Recovery: check the backup file first
Start with the preserved copies, not their filenames or sizes alone. Find a dated full backup or candidate database.db.backup/.BAK from the same network. Check that its nonempty lines parse as JSON and that it contains the expected device IEEE addresses and plausible endpoint/interview records. File size is a useful warning sign, not proof of integrity or recency. Keep the untouched copies even if you later inspect or repair a working copy.
The following is an illustrative Linux systemd sequence, with /opt/zigbee2mqtt/data as an example only. Substitute the actual path and service name and use an account with the required access. For an add-on or container, use its own stop control and actual data mount. Do not run a second instance against the same coordinator or data directory.
# Preserve existing evidence before a graceful stop can write to it. umask 077 recovery_dir="$HOME/z2m-recovery-$(date +%Y%m%d-%H%M%S)" mkdir -p "$recovery_dir" cp -a /opt/zigbee2mqtt/data "$recovery_dir/before-stop" systemctl stop zigbee2mqtt.service # Confirm the service is stopped before proceeding. systemctl is-active zigbee2mqtt.service # Keep the shutdown result separately as well. cp -a /opt/zigbee2mqtt/data "$recovery_dir/after-stop" # Inspect saved copies while stopped. Only if this candidate was verified: cp "$recovery_dir/before-stop/database.db.backup" /opt/zigbee2mqtt/data/database.db # Check that ownership and permissions still allow the service to read/write it. ls -l /opt/zigbee2mqtt/data/database.db systemctl start zigbee2mqtt.service
systemctl is-active should report inactive before replacement; it returns a nonzero status for an inactive service. If it is still active or restarting, resolve that first. The initial copy captures the available on-disk evidence while the process may be running, so it is not guaranteed to be an application-consistent backup. The separate stopped copy is useful for comparison, and a known-good offline backup is preferable when available.
Do not copy a repaired database into a running service and then restart it. Shutdown can save the old in-memory database over your replacement. If startup reports a new network reset or immediately clears the restored records, preserve that log and investigate coordinator/configuration mismatch before repeating the restore.
After one controlled start, verify the expected devices and groups in Zigbee2MQTT, then check actual commands and fresh readings. A device list returning does not prove that every endpoint, binding or automation is restored. If no usable database survives, the prototype in #24612 is an advanced, incomplete recovery possibility to examine on copies; re-interviewing/re-pairing may still be necessary. Avoid factory resetting the entire mesh simply because the frontend is empty. If removal is needed, our remove, force remove and factory reset guide explains the different effects.
Prevention: backup cadence and restart-path choice
Keep dated generations of the whole data directory on separate storage and take a consistent backup while stopped before major changes. Include any device/group files referenced outside that directory. The frontend backup download and MQTT backup request provide a data-folder archive excluding logs; coordinator backup availability still depends on the adapter. Store logs separately when investigating an incident.
Verify persistence after deployment changes: the same mount should be present, the service user should retain access, and storage should have free space. Prefer reliable storage and investigate I/O errors promptly. If your own installation reproduces the Docker restart distinction in #19924, separate stop/start may help during diagnosis, but it is not a substitute for backups or a demonstrated universal fix. Network-connected coordinators also need reliable transport; the adapter guide warns about packet loss and latency over Wi-Fi.
FAQ
Why did every device disappear after a restart? Check the actual data path, mount, permissions and startup log before assuming corruption. Then inspect preserved database copies for the expected records. A missing device list can reflect lost host records, a different directory, a display problem or a changed coordinator network.
Is database.db the same as a coordinator backup? No. The first stores host device/group records; the second stores supported coordinator network/security state. Neither replaces the complete data directory and the other side’s state.
Does Docker protect the database? Only a correctly configured persistent mount preserves data across container replacement. Docker itself neither proves nor prevents the reported incident. One 1.33.2 report found separate stop/start helpful; that remains a report about that setup.
Can an empty database be repaired without re-pairing? A verified backup may restore it. A partially damaged line-JSON file may retain recoverable records, and #24612 offers an experimental reconstruction approach. No complete built-in recovery from coordinator backup is established by the released code checked here. Preserve originals and avoid promising recovery before examining them.
How often should backups run? Often enough that losing changes since the last copy is acceptable, with additional backups before upgrades or network changes. Retain several generations off the host; do not rely on the incidental .backup file as your schedule.
What this piece verified, and what to check yourself
The incident descriptions come from their original reports. Current file parsing, temporary-file writes, reset-triggered database backup and shutdown saves were checked against zigbee-herdsman 10.10.0, the dependency pinned by Zigbee2MQTT 2.14.2. Documentation confirms data-folder backup support and the adapter limits on coordinator backup. No real coordinator was operated for this guide.
The reports do not establish one universal restart-wipe cause. On your installation the decisive evidence is the actual data directory, the saved file contents, the adapter startup result and the version in use. Preserve those before the next restart changes them.
