<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/raspberry-pi-follow-up-backing-up-zigbee2mqtt-ixdliwwxn" -->

---
title: Raspberry Pi Follow-Up: Backing Up Zigbee2MQTT | daily.dev
description: A practical guide to backing up Zigbee2MQTT data on a Raspberry Pi after an SD card failure scare. The approach uses a shell script that creates daily .tar.gz...
canonical: https://daily.dev/posts/raspberry-pi-follow-up-backing-up-zigbee2mqtt-ixdliwwxn
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Raspberry Pi Follow-Up: Backing Up Zigbee2MQTT | daily.dev
og:description: A practical guide to backing up Zigbee2MQTT data on a Raspberry Pi after an SD card failure scare. The approach uses a shell script that creates daily .tar.gz...
og:url: https://daily.dev/posts/raspberry-pi-follow-up-backing-up-zigbee2mqtt-ixdliwwxn
og:image: https://api.daily.dev/og/posts/ixdLIwWXN.png
og:image:alt: Raspberry Pi Follow-Up: Backing Up Zigbee2MQTT
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Raspberry Pi Follow-Up: Backing Up Zigbee2MQTT

**[apalrd's adventures](https://daily.dev/sources/apalrd)** · 2 min read · 0 upvotes · 0 comments

## Summary

A practical guide to backing up Zigbee2MQTT data on a Raspberry Pi after an SD card failure scare. The approach uses a shell script that creates daily .tar.gz archives of the Zigbee2MQTT data directory (including configuration.yaml and database.db), stores them on a NAS mounted via autofs, and rotates through 7 days of backups using day-of-week filename suffixes. A cron job runs the script nightly at midnight.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.apalrd.net/posts/2021/zigbee_backup>

## Questions this post answers

### Where does Zigbee2MQTT store its data when installed with npm on a Raspberry Pi?

When installed with npm on a Raspberry Pi, Zigbee2MQTT stores its data in /opt/zigbee2mqtt/data. This directory contains configuration.yaml and internal files such as database.db, which hold the network configuration and device state that would be lost if the SD card fails.

_Developers managing Zigbee2MQTT home setups track tips like these on daily.dev._

### How do I rotate Zigbee2MQTT backups to keep only the last 7 days?

Append the day of the week to each backup filename so that each day's backup overwrites the one from seven days prior. Store the backup script on the NAS mount point rather than locally, so if the NAS is unavailable the script cannot run and the SD card is not filled with local backup files.

_Home automation developers dealing with SD card reliability find practical recovery strategies on daily.dev._

## Similar posts on daily.dev

- [My Raspberry Pi now fixes itself when services die, and I haven't SSHed in weeks](https://daily.dev/posts/my-raspberry-pi-now-fixes-itself-when-services-die-and-i-haven-t-sshed-in-weeks-vadmi1qoi) · XDA Developers · 2 upvotes · 1 comments
- [The death and rebirth of my home server](https://daily.dev/posts/the-death-and-rebirth-of-my-home-server-dfkvsryip) · Hacker News · 3 upvotes · 0 comments
- [How to build automated Linux backups that don’t silently fail](https://daily.dev/posts/how-to-build-automated-linux-backups-that-don-t-silently-fail-wvogdetgj) · All Things Open · 0 upvotes · 0 comments
- [I moved my Zigbee coordinator off a Raspberry Pi after a year and everything got better](https://daily.dev/posts/i-moved-my-zigbee-coordinator-off-a-raspberry-pi-after-a-year-and-everything-got-better-djnlpbqrp) · XDA Developers · 0 upvotes · 0 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#raspberry-pi](https://daily.dev/tags/raspberry-pi)

[View this post on daily.dev](https://daily.dev/posts/raspberry-pi-follow-up-backing-up-zigbee2mqtt-ixdliwwxn)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Raspberry Pi Follow-Up: Backing Up Zigbee2MQTT","url":"https://daily.dev/posts/raspberry-pi-follow-up-backing-up-zigbee2mqtt-ixdliwwxn","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/raspberry-pi-follow-up-backing-up-zigbee2mqtt-ixdliwwxn"},"datePublished":"2026-08-11T08:56:43.062Z","dateModified":"2026-08-11T09:18:00.876Z","description":"A practical guide to backing up Zigbee2MQTT data on a Raspberry Pi after an SD card failure scare. The approach uses a shell script that creates daily .tar.gz...","image":"https://media.daily.dev/image/upload/s--0_ODbtD2--/f_auto/v1722860399/public/Placeholder%2008","thumbnailUrl":"https://media.daily.dev/image/upload/s--0_ODbtD2--/f_auto/v1722860399/public/Placeholder%2008","isAccessibleForFree":true,"articleSection":"apalrd's adventures","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"apalrd's adventures","logo":"https://media.daily.dev/image/upload/s--4zkx8dRj--/f_auto,q_auto/v1786438309/logos/apalrd?_a=BAMAMicg0","url":"https://daily.dev/sources/apalrd"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/raspberry-pi-follow-up-backing-up-zigbee2mqtt-ixdliwwxn","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"general-programming,raspberry-pi","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"apalrd's adventures","item":"https://daily.dev/sources/apalrd"},{"@type":"ListItem","position":3,"name":"Raspberry Pi Follow-Up: Backing Up Zigbee2MQTT"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/raspberry-pi-follow-up-backing-up-zigbee2mqtt-ixdliwwxn#faq","mainEntity":[{"@type":"Question","name":"Where does Zigbee2MQTT store its data when installed with npm on a Raspberry Pi?","acceptedAnswer":{"@type":"Answer","text":"When installed with npm on a Raspberry Pi, Zigbee2MQTT stores its data in /opt/zigbee2mqtt/data. This directory contains configuration.yaml and internal files such as database.db, which hold the network configuration and device state that would be lost if the SD card fails. Developers managing Zigbee2MQTT home setups track tips like these on daily.dev."}},{"@type":"Question","name":"How do I rotate Zigbee2MQTT backups to keep only the last 7 days?","acceptedAnswer":{"@type":"Answer","text":"Append the day of the week to each backup filename so that each day's backup overwrites the one from seven days prior. Store the backup script on the NAS mount point rather than locally, so if the NAS is unavailable the script cannot run and the SD card is not filled with local backup files. Home automation developers dealing with SD card reliability find practical recovery strategies on daily.dev."}}]}
```

