Update Grafana blog post to note persistence

Also introduce `homelab` tag
attemptAtTagsRenovation
Jack Jackson 2 years ago
parent 7a0ec20985
commit a3793a9bcc
  1. 2
      blog/content/posts/check-your-backups.md
  2. 8
      blog/content/posts/grafana-backup.md

@ -1,6 +1,8 @@
---
title: "Check Your Backups"
date: 2021-12-05T12:18:43-08:00
tags:
- homelab
---
I fully intend to write a full blog-post as a follow-up to my [previous post]({{< ref "/posts/my-first-post" >}}) at some point, detailing some of the quirks of this setup and issues that I ran into - but I just got a timely reminder of the importance of checking backups, and wanted to pass it on to you.
<!--more-->

@ -1,7 +1,15 @@
---
title: "Grafana Backup"
date: 2022-01-23T11:02:55-08:00
tags:
- homelab
---
**Update**: I'm preserving the post below for posterity, but I had the obvious solution in the final sentence - I changed my setup to [run Grafana from Docker and mount a folder from my external Hard Drive](https://github.com/scubbo/pi-tools/blob/main/scripts-on-pi/2_full_setup.sh#L236-L239) (I haven't saved up for a NAS yet!), and now my dashboard definition is persistent across restarts/re-images.
<!--more-->
---
I've [installed Grafana](https://github.com/scubbo/pi-tools/blob/main/scripts-on-pi/2_full_setup.sh#L229-L249) to monitor the Raspberry Pis in my homelab setup, but after a bit of poking around I couldn't find a file that contains the dashboard configuration that can be backed-up to prevent losing configuration if the image/Pi crashed (remember to [check your backups]({{< ref "/posts/check-your-backups" >}})!). To that end, I created a [backup script](https://github.com/scubbo/pi-tools/blob/main/backup-scripts/grafana_backup.py) that retrieves a JSON representation of the currently-saved dashboards, checks if there have been any updates against the previously-saved version (using a hash), and persists it if so. Cron-scheduling of the backup happens [here](https://github.com/scubbo/pi-tools/blob/main/scripts-on-pi/2_full_setup.sh#L256) in my general Pi-setup script.
It's not ideal to have the Grafana username and password persisted into a cron definition - one day I'll update it to use an [API Key](https://grafana.com/docs/grafana/latest/http_api/auth/#create-api-token) (though, before that, I'd like to automate the setup of Grafana itself, such as adding the Prometheus data source and the admin user). Honestly in hindsight I can't remember why I installed Grafana via `apt-get install` and `systemctl start` rather than with Docker as [here](https://grafana.com/docs/grafana/latest/administration/configure-docker/). That way, I could just mount a directory from my hard drive (or, one day, NAS) to persist configuration options.

Loading…
Cancel
Save