Grafana is an awesome tool to create graphs from whatever data you have. It doesn’t have an option to export all dashboards at once, though. You could select each dashboard and export it to JSON at a time, but that’s toil.

There’s a better way: Use grafcli. It’s a feature-rich Grafana command line tool written in Python. (Python3, of course.) Install it using pip3: pip3 install grafcli

Now create a config file grafcli.conf. As long as it’s in your working directory, you’re fine:

editor = vim
verbose = off


type = api
url = https://$GRAFANA_URL:$PORT
ssl = on
user = admin

data-dir = ~/.grafcli

If you have a token, you do not need user/password and vice versa.

To verify if your configuration file is valid, try grafcli ls remote. It should show the Grafana URL you have configured.

To create a backup of all dashboards, use this command: grafcli backup remote/$GRAFANA_URL/ backup.tgz

Restoring from a backup is simple as well: grafcli restore backup.tgz remote/$GRAFANA_URL/

Check out the docs for more options.

Daniel Heitmann

Another opinionated Systems Engineer. Hi!

dictvm dictvm