Best practices to migrate containerized Grafana

What is the recommended way to migrate a containerized Grafana .

I have a Grafana 6 and I want to migrate all the dashboards, configuration etc to a new Grafana 7 instance.

I was wondering if besides exporting all the desired resources via API is there another approach like “fork and lift”, maybe connecting the new instance to the old instance’s database ?
Thx

Are you using the default SQLite data store for Grafana? If so, where is this stored…in your existing container or outside of it?

All you need to do in principle is:

  1. Copy that SQLite DB (the default location is /var/lib/grafana/grafana.db - see also https://grafana.com/docs/grafana/latest/installation/upgrading/) and point your new container to it.
  2. Copy your Grafana config file(s)
  3. Copy over and plugins from /var/lib/grafana/plugins (though you can also just re-install them on the new container)
1 Like

Hi @svetb , yes I’m using the default db

file /var/lib/grafana/grafana.db
/var/lib/grafana/grafana.db: SQLite 3.x database

Concerning grafana config file, it’s suffice to copy /etc/grafana/grafana.ini or there are other config files ?

Thx.

I think that should be sufficient, unless you made edits to other config files (e.g. defaults.ini or the LDAP config, etc).

Note that I’d say best practices for running Grafana in docker (along the lines of https://grafana.com/docs/grafana/latest/installation/docker/) are:

  • Mount the grafana.db file from a local volume, so it’s not built into the container.
  • Pass configuration options via environment variables rather than by editing the grafana.ini file
  • Install plugins via the GF_INSTALL_PLUGINS environment variable

In other words, don’t make any actual changes to files in the container. This will give you infinite flexibility to upgrade to new versions in the future.

1 Like