Backing up grafana

I want to backup grafana configuration for following use cases

  1. setup/upgrade on new hardware/os/ami and potentially in different environment (dev, test, prod)
  2. in case of server crash - restore from backup
    I looked at backing up grafana.db and ini, but i was able to retrieve dashboard jason files if i need to restore a single dashboard for whatever reason.
    So I figure out way to backup dashboard and datasource using curl and bearer key - that worked well, but when curl post, it doesn’t respect dashboard original folder, it adds a new dashboard to general folder. Also, if i use UI to import already exported dashboard from above, I have to provide name, folder etc, but imported dashboard never works, blank screen.
    What is the correct way to import/export dashboard or is there a way to get individual dashboard.json from garafana.db and restore it, if needed?
    Thanks in advance.
    M

This is great question as there is no standard approach to this from grafana itself so you have to plan things carefully.

So what approach do you currently have for you grafana instances?

Dev/Test/Prod?

Backing up the grafana.db.

  • Pro:
    All you do is restore it from last backup
    Folder structure and all comes with it
  • Con: It is a nuclear restore as it will overwrite everything else that happened after the last backup.

Backing up individual dashboards

  • Pros:
    More granular
  • Cons:
    lose folder context
    Might still over write work done post extraction

Check this out for exporting dashboards. Maybe you can enhance it by creating another process that indicates which folder it came from.