Skip to main content

Backup and restore

Regular backups protect your Grafana configuration, dashboards, and data from loss or corruption. This guide covers what to back up, backup procedures, and restoration processes.

What to back up

A complete Grafana backup includes several components:

Database

The Grafana database contains:
  • Dashboards and dashboard versions
  • Users, teams, and organizations
  • Data sources and their configurations
  • Alert rules and notification channels
  • Folders and permissions
  • Preferences and settings
  • Annotations
  • API keys and service accounts
Database types:
  • SQLite: Single file database (default)
  • PostgreSQL: External database server
  • MySQL: External database server

Configuration files

Back up your configuration files:
  • grafana.ini or custom.ini - Main configuration
  • ldap.toml - LDAP configuration (if used)
  • Environment files with sensitive settings

Provisioning files

If you use file-based provisioning, back up:
  • conf/provisioning/datasources/ - Data source definitions
  • conf/provisioning/dashboards/ - Dashboard providers
  • conf/provisioning/notifiers/ - Alert notification channels
  • conf/provisioning/plugins/ - Plugin configurations
  • conf/provisioning/alerting/ - Alert rules and policies

Plugin data

Some plugins store data in:
  • data/plugins/ - Plugin files and data
  • Custom plugin configuration directories

Backup procedures

SQLite database backup

For SQLite (default configuration), the database is a single file. Locate the database: The default location is defined in grafana.ini:
The path is relative to the data directory ([paths].data). Backup the database:
For online backups without stopping Grafana, use SQLite’s backup API or the .backup command in the SQLite CLI.

PostgreSQL database backup

Use pg_dump to create consistent backups:
Parameters:
  • -h localhost - Database host
  • -U grafana - Database user
  • -d grafana - Database name
  • -F c - Custom format (compressed)
  • -f <FILE> - Output file path
Automated daily backups:
Schedule with cron:

MySQL database backup

Use mysqldump to create backups:
Parameters:
  • -h localhost - Database host
  • -u grafana - Database user
  • -p - Prompt for password
  • --single-transaction - Consistent snapshot for InnoDB
  • --quick - Stream results without buffering

Configuration backup

Back up configuration files:

Complete backup script

Combine database and configuration backups:

Restore procedures

Restore SQLite database

Restore from a SQLite backup:

Restore PostgreSQL database

Restore from a PostgreSQL backup:

Restore MySQL database

Restore from a MySQL backup:

Restore configuration

Restore configuration files:

Disaster recovery

For disaster recovery, follow this sequence:
  1. Install Grafana with the same version as the backup
  2. Stop the Grafana service
  3. Restore the database
  4. Restore configuration files
  5. Restore provisioning files
  6. Restore plugins if needed
  7. Set correct file permissions
  8. Start Grafana and verify functionality

Backup best practices

  • Automate backups - Schedule regular automated backups
  • Test restores - Regularly test backup restoration procedures
  • Off-site storage - Store backups in a different location from your Grafana instance
  • Encryption - Encrypt backups containing sensitive data
  • Retention policy - Define and implement a backup retention policy
  • Version compatibility - Note the Grafana version when creating backups
  • Monitor backups - Alert on backup failures
  • Document procedures - Maintain up-to-date restoration documentation

Database-specific considerations

SQLite

  • Requires stopping Grafana for consistent backups (or use SQLite backup API)
  • Simple single-file backup and restore
  • Not recommended for high-availability deployments
  • Limited to single-instance deployments

PostgreSQL

  • Supports online backups with pg_dump
  • Point-in-time recovery with WAL archiving
  • Recommended for production deployments
  • Supports high-availability configurations

MySQL

  • Supports online backups with mysqldump --single-transaction
  • Binary log for point-in-time recovery
  • Suitable for production deployments
  • Supports replication for high availability
Refer to conf/defaults.ini:139 for database configuration options.

Next steps