Backup/restore grafana server

We could do with a mechanism that would allow a restored copy of grafana.db to successfully run on a new/different server.
This would also be useful for running a mirror without the need to manually import dashboards between servers.

Is there a good way to acheive this?

Thanks.

If you copy grafana.db to a new instance and restart grafana-server it should work. You also need to make sure the grafana.ini settings are the same.

1 Like

I get the following migration error when starting grafana on the new server.
I’ve confirmed the versions and configs are matching.

t=2017-03-17T13:40:43+0000 lvl=info msg=“Starting Grafana” logger=main version=4.2.0-pre1 commit=9efb6e7 compiled=2017-03-07T15:03:54+0000
t=2017-03-17T13:40:43+0000 lvl=info msg=“Config loaded from” logger=settings file=/usr/share/grafana/conf/defaults.ini
t=2017-03-17T13:40:43+0000 lvl=info msg=“Config loaded from” logger=settings file=/etc/grafana/grafana.ini
t=2017-03-17T13:40:43+0000 lvl=info msg=“Config overriden from command line” logger=settings arg="default.paths.data=/var/lib/grafana"
t=2017-03-17T13:40:43+0000 lvl=info msg=“Config overriden from command line” logger=settings arg="default.paths.logs=/var/log/grafana"
t=2017-03-17T13:40:43+0000 lvl=info msg=“Config overriden from command line” logger=settings arg="default.paths.plugins=/var/lib/grafana/plugins"
t=2017-03-17T13:40:43+0000 lvl=info msg=“Path Home” logger=settings path=/usr/share/grafana
t=2017-03-17T13:40:43+0000 lvl=info msg=“Path Data” logger=settings path=/var/lib/grafana
t=2017-03-17T13:40:43+0000 lvl=info msg=“Path Logs” logger=settings path=/var/log/grafana
t=2017-03-17T13:40:43+0000 lvl=info msg=“Path Plugins” logger=settings path=/var/lib/grafana/plugins
t=2017-03-17T13:40:43+0000 lvl=info msg=“Initializing DB” logger=sqlstore dbtype=sqlite3
t=2017-03-17T13:40:43+0000 lvl=info msg=“Starting DB migration” logger=migrator
t=2017-03-17T13:40:43+0000 lvl=eror msg=“Fail to initialize orm engine” logger=sqlstore error=“Sqlstore::Migration failed err: unable to open database file\n”

Ah, the ownership was wrong, it looks to be working!

After you copy the grafana.db file you need to make sure it has the right permissions.

chown grafana:grafana grafana.db

I trried copying /etc/grafana with file grafana.ini and /var/lib/grafana folder with grafana.db and provided 777 permission , I am able to login to grafana but not able to find any of my dashboards or DB config

Sounds like Grafana created a new database somewhere. Which OS are you on and how did you install Grafana?

Package details for the Ubuntu/Debian package - http://docs.grafana.org/installation/debian/#package-details
which says the grafana.db should be located at /var/lib/grafana/grafana.db so not sure why it is not working for you if you are on Ubuntu/Debian.

Can you check the database name and the paths section in your server settings:

image

and

image