Export Dashboards programmatically

Hi.

I need to export the JSON models of all my dashboards that were made with the GUI in order to import them in another Grafana instance.
I tried with the dashboard API - api/dashboards/ using curl with the dashboard uuid or uri (db/).
but for some reason I always get the message not found

The uids and uris I found with

$URL/api/search?query=&

Then I tried to get the models or any data

curl -k -H “Authorization: Bearer $KEY” $URL/api/dashboards/db/$dash_name

or

curl -k -H “Authorization: Bearer $KEY” $URL/api/dashboards/uid/$uid

the result is the same.

Does anyone know why is that? I couldn’t find any info anywhere else.

Thanks in advance.

Hi @simonbeltram

There are a handful of good third-party tools for downloading and exporting dashboards, and other grafana data like settings. Here is a list I’ve started compiling. I’d check out the dashboard export section:

3 Likes

Thanks for the answer. It solved my problem.

1 Like

I have created a tool that can help a lot in all bulk actions of grafana you can find it here

please if you have any more ideas to add, share with me :wink:

Isn’t it easier to just backup and restore database?

1 Like

I think that you will not get the flexibility you get from the apis, for example if you want to export all dashboards that uses specific job or specific datasource
that will not be easy from the database, but withe apis, its just few clicks away

That is exactly what a db backup does with 0 code writen.