Grafana Backup and Restore

Dashboards represent hours of careful work. A failed disk, a bad upgrade, or a mistaken delete can erase all of it in a second. With a backup plan, that disaster shrinks to a short inconvenience. Untested backups remain a hope, so a good plan includes both saving and restoring.

The Spare Key Analogy

Most people keep a spare house key with a neighbour. The key sits unused for years, and on the day you lock yourself out, it saves the afternoon. Backups work the same way. You rarely need them, and the value arrives all at once on a bad day. Check that the spare key still fits the door, and test your restore as well.

Grafana server  --backup-->  Safe storage (other disk or cloud)
                                      |
New server      <--restore--+---------+

What to Save

ItemTypical LocationContains
Database/var/lib/grafana/grafana.db (SQLite)Dashboards, users, folders, alert rules, data sources
Configuration file/etc/grafana/grafana.iniServer settings
Provisioning folder/etc/grafana/provisioningData sources and dashboards defined as code
Plugins folder/var/lib/grafana/pluginsInstalled plugins
Secret keyInside grafana.iniThe key that decrypts saved passwords

The secret key deserves special care. Without it, a restored database cannot decrypt data source passwords. Store a copy of the key with the configuration backup, and keep that backup private.

Back Up an SQLite Database

Copying the file while Grafana writes to it can produce a damaged copy. Use the SQLite backup command, which creates a consistent snapshot even on a running server.

sqlite3 /var/lib/grafana/grafana.db ".backup '/backup/grafana-2026-03-01.db'"

A simpler route stops the service, copies the file, and starts the service again. Choose it when a short pause suits your team.

sudo systemctl stop grafana-server
cp /var/lib/grafana/grafana.db /backup/
sudo systemctl start grafana-server

Back Up PostgreSQL or MySQL

Servers that use an external database rely on that database's own tools.

pg_dump -U grafana grafana > /backup/grafana.sql

mysqldump -u grafana -p grafana > /backup/grafana.sql

Back Up Configuration and Provisioning

tar czf /backup/grafana-config.tar.gz \
  /etc/grafana/grafana.ini \
  /etc/grafana/provisioning

Store provisioning files in a Git repository as well. Version control gives you history and easy comparison on top of the backup.

Back Up a Docker Volume

docker run --rm \
  -v grafana-storage:/data \
  -v $(pwd):/backup \
  busybox tar czf /backup/grafana-volume.tar.gz -C /data .

The command mounts the Grafana volume and a local folder in a short-lived helper container. Inside the helper, tar packs the volume into one archive file, and the helper exits.

Export Dashboards as JSON

A database backup restores everything together. JSON exports let you save and restore single dashboards. Open a dashboard, choose Export, and save it as JSON. The HTTP API can export every dashboard in a loop, which suits scheduled jobs.

curl -H "Authorization: Bearer YOUR_TOKEN" \
  "http://localhost:3000/api/dashboards/uid/DASHBOARD_UID" \
  > dashboard-backup.json

Restore Step by Step

  1. Install the same Grafana version on the new server.
  2. Stop the Grafana service.
  3. Copy the database backup into place, such as /var/lib/grafana/grafana.db.
  4. Restore the configuration file, the provisioning folder, and the secret key.
  5. Fix file ownership so the grafana user can read the files.
  6. Start the service and open the web page.
  7. Check dashboards, data sources, users, and alert rules.
sudo chown -R grafana:grafana /var/lib/grafana

Plan a Schedule

ItemFrequency
DatabaseDaily
Configuration and provisioningAfter every change
Dashboard JSON exportsWeekly
Restore testEvery quarter

Automate the jobs with a scheduler such as cron. Keep several generations of backups, such as seven daily copies and four weekly copies, so you can step back past a problem you notice late.

Store Backups Safely

  • Keep a copy on a different machine or in cloud storage.
  • Encrypt backups that contain secrets.
  • Restrict who can read the backup location.
  • Write the restore steps in a short document that anyone on the team can follow.