# Migrating from sqlite to postgres

**URL:** <https://community.grafana.com/t/migrating-from-sqlite-to-postgres/110408>\
**Category:** Grafana\
**Tags:** sqlite\
**Created:** [December 19, 2023, 10:31pm UTC](https://community.grafana.com/t/migrating-from-sqlite-to-postgres/110408 "2023-12-19T22:31:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![royk](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/royk/32/40789_2.png) [@royk](https://community.grafana.com/u/royk)\
**Post date:** [December 19, 2023, 10:31pm UTC](https://community.grafana.com/t/migrating-from-sqlite-to-postgres/110408/1 "2023-12-19T22:31:55Z")

</div>

We have a Grafana 10.2.2 installation originally installed on sqlite and I want to move that over to our postgresql cluster. I’ve looked around for solutions, but I can’t find anything that works. I tried with [GitHub - percona/grafana-db-migrator: Grafana SQLite to Postgres Database Migrator](https://github.com/percona/grafana-db-migrator) and it rewrites a lot of stuff but doesn’t work at the end. Any idea how I can accomplish this? I really don’t want to remake all the dashboards.

PS: Data is fetched from other sources, so that’s fine.

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [December 19, 2023, 10:33pm UTC](https://community.grafana.com/t/migrating-from-sqlite-to-postgres/110408/2 "2023-12-19T22:33:26Z")

</div>

is it the same as this one? Do you have a lot of stuff going on in your grafana? including alerts?

> **[GitHub - grafana/database-migrator: Code to export grafana.db (sqlite) to...](https://github.com/grafana/database-migrator)**
>
> Code to export grafana.db (sqlite) to MySQL-compatible SQL file, to assist in migration of Grafana data to MySQL-compatible DB. - GitHub - grafana/database-migrator: Code to export grafana.db (sqli...

---

<div class="post-metadata">

**Author:** ![royk](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/royk/32/40789_2.png) [@royk](https://community.grafana.com/u/royk)\
**Post date:** [December 20, 2023, 11:15am UTC](https://community.grafana.com/t/migrating-from-sqlite-to-postgres/110408/3 "2023-12-20T11:15:16Z")

</div>

Not the same, but looks like I may be able to use it with some work. It’s made for MySQL/MariaDB, but as I said, I’m using PostgreSQL, so the SQL syntax is a wee bit different.

One other thing - I have setup the new grafana server with the same plugins, but the old one has a total of 84 tables in the db, whereas the new one only has 64. One has been excluded, but specifically, these are missing in the new db

dashboard\_public\_email\_share  
dashboard\_public\_magic\_link  
dashboard\_public\_session  
dashboard\_public\_usage\_by\_day  
dashboard\_usage\_by\_day  
dashboard\_usage\_sums  
data\_source\_acl  
data\_source\_cache  
data\_source\_usage\_by\_day  
license\_token  
recording\_rules  
remote\_write\_targets  
report  
report\_dashboards  
report\_settings  
setting  
team\_group  
user\_dashboard\_views  
user\_stats

---

<div class="post-metadata">

**Author:** ![royk](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/royk/32/40789_2.png) [@royk](https://community.grafana.com/u/royk)\
**Post date:** [December 20, 2023, 11:56am UTC](https://community.grafana.com/t/migrating-from-sqlite-to-postgres/110408/4 "2023-12-20T11:56:43Z")

</div>

And now, what is this?

INSERT INTO dashboard\_version (“id”,“dashboard\_id”,“parent\_version”,“restored\_from”,“version”,“created”,“created\_by”,“message”,“data”) VALUES (372,29,10,0,11,‘2023-07-07 10:21:39’,52,**replace(‘Lagt til terskelverdier:\nRød 0 - 35\nGul 35 - 40\nGrønn 40 -50\nRød 50 -\>’,‘\n’,char(10))**,'{“annotations”:{“list”:[{“builtIn”:1,“datasource”:{“type”:“grafana”,“uid”:“-- Grafana --”},“enable”:true,“hide”:true,“iconColor”:“rgba(0, 211, 255, 1)”,“name”:“Annotations \u0026 Alerts”,“target”:{“limit”:100,“matchAny”:false,“tags”:,“type”:“dashboard”},“type”:“dashboard”}]},“editable”:true,“fiscalYearStartMonth”:0,“graphTooltip”:0,“id”:29,“links”:,“liveNow”:false,“panels”:[{“datasource”:{“type”:“alexanderzobnin-zabbix-datasource”

That’s a function call in the dump - should it be there?

---

<div class="post-metadata">

**Author:** ![royk](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/royk/32/40789_2.png) [@royk](https://community.grafana.com/u/royk)\
**Post date:** [December 20, 2023, 11:59am UTC](https://community.grafana.com/t/migrating-from-sqlite-to-postgres/110408/5 "2023-12-20T11:59:25Z")

</div>

Btw, the text just means ‘Added threashold values:\nRed 0 - 35\nYellow 35-40\nGreen 40-50\nRed 50 -\>’
