Skip to content

Commit a158726

Browse files
committed
docs: backup/restore section in README
1 parent 417b822 commit a158726

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,52 @@ INSERT INTO lux_settings (name, value) VALUES ('pv_max_power', '10000')
288288
ON DUPLICATE KEY UPDATE value = '10000';
289289
```
290290

291+
## Backup and Restore
292+
293+
`scripts/backup.sh` creates a single compressed archive containing everything
294+
needed to rebuild your lux-mon system on new hardware:
295+
296+
- MariaDB dump (`luxmon` database)
297+
- InfluxDB v2 bucket backup
298+
- Grafana provisioning files and dashboard JSON
299+
- `.env` configuration
300+
- Runtime settings from `/api/settings`
301+
302+
Run manually:
303+
304+
```bash
305+
# Must run as root to read Grafana provisioning files
306+
sudo bash scripts/backup.sh
307+
```
308+
309+
Configure via `.env`:
310+
311+
```bash
312+
LUX_BACKUP_DIR=/var/backups/lux-mon
313+
LUX_BACKUP_KEEP_DAYS=30
314+
# Optional off-device copy:
315+
LUX_BACKUP_REMOTE=user@nas:/backups/lux-mon
316+
```
317+
318+
The included systemd timer runs the backup automatically every night at 02:00:
319+
320+
```bash
321+
sudo cp scripts/lux-mon-backup.service /etc/systemd/system/
322+
sudo cp scripts/lux-mon-backup.timer /etc/systemd/system/
323+
sudo systemctl daemon-reload
324+
sudo systemctl enable --now lux-mon-backup.timer
325+
```
326+
327+
Restore from an archive on a fresh install:
328+
329+
```bash
330+
sudo LUX_BACKUP=/var/backups/lux-mon/luxmon-backup-YYYYMMDD-HHMMSS.tar.gz bash scripts/restore.sh
331+
```
332+
333+
`scripts/prune.sh` deletes detail data older than 90 days while keeping hourly
334+
energy rollups for one year, keeping the MariaDB database small.
335+
336+
291337
### MQTT setting control
292338

293339
lux-mon also accepts setting changes over MQTT. The collector subscribes to:

0 commit comments

Comments
 (0)