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
- SQLite: Single file database (default)
- PostgreSQL: External database server
- MySQL: External database server
Configuration files
Back up your configuration files:grafana.iniorcustom.ini- Main configurationldap.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 definitionsconf/provisioning/dashboards/- Dashboard providersconf/provisioning/notifiers/- Alert notification channelsconf/provisioning/plugins/- Plugin configurationsconf/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 ingrafana.ini:
[paths].data).
Backup the database:
.backup command in the SQLite CLI.
PostgreSQL database backup
Usepg_dump to create consistent backups:
-h localhost- Database host-U grafana- Database user-d grafana- Database name-F c- Custom format (compressed)-f <FILE>- Output file path
MySQL database backup
Usemysqldump to create backups:
-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:- Install Grafana with the same version as the backup
- Stop the Grafana service
- Restore the database
- Restore configuration files
- Restore provisioning files
- Restore plugins if needed
- Set correct file permissions
- 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
conf/defaults.ini:139 for database configuration options.
Next steps
- Configure monitoring to track backup success
- Review high availability for production deployments
- Plan upgrade procedures before major version changes