# Upgrade sonarqube to psql without data loss from h2 database

**URL:** <https://community.sonarsource.com/t/upgrade-sonarqube-to-psql-without-data-loss-from-h2-database/70572>\
**Category:** SonarQube Server / Community Build\
**Created:** [August 28, 2022, 9:09am UTC](https://community.sonarsource.com/t/upgrade-sonarqube-to-psql-without-data-loss-from-h2-database/70572 "2022-08-28T09:09:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajkumar\_choppari](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rajkumar_choppari/32/36608_2.png) [@rajkumar\_choppari](https://community.sonarsource.com/u/rajkumar_choppari)\
**Post date:** [August 28, 2022, 9:09am UTC](https://community.sonarsource.com/t/upgrade-sonarqube-to-psql-without-data-loss-from-h2-database/70572/1 "2022-08-28T09:09:08Z")

</div>

Hi i want upgrade sonarqube db to psql from existing h2 db without any data loss how should i get my h2 data into psql db please need correct way to chnage db withou any data loss from h2 db.

---

<div class="post-metadata">

**Author:** ![felipebz](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/felipebz/32/32739_2.png) [@felipebz](https://community.sonarsource.com/u/felipebz)\
**Post date:** [August 28, 2022, 2:33pm UTC](https://community.sonarsource.com/t/upgrade-sonarqube-to-psql-without-data-loss-from-h2-database/70572/2 "2022-08-28T14:33:12Z")

</div>

There’s no supported way to migrate the data from the h2 database.

> [@Migrate H2 database for SonarQube version upgrade](https://community.sonarsource.com/t/migrate-h2-database-for-sonarqube-version-upgrade/57779/2):
>
> Hey there. On every page, while using the embedded database, there is a big warning that it is not suitable for production use and not possible to migrate to a newer version. You will need to start from scratch.

---

<div class="post-metadata">

**Author:** ![rajkumar\_choppari](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rajkumar_choppari/32/36608_2.png) [@rajkumar\_choppari](https://community.sonarsource.com/u/rajkumar_choppari)\
**Post date:** [January 27, 2023, 8:44am UTC](https://community.sonarsource.com/t/upgrade-sonarqube-to-psql-without-data-loss-from-h2-database/70572/3 "2023-01-27T08:44:37Z")

</div>

So We have a huge data in existing sonarqube h2 db is any alternative way to get that data backup migration possible

---

<div class="post-metadata">

**Author:** ![mgonzalez](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mgonzalez/32/25404_2.png) [@mgonzalez](https://community.sonarsource.com/u/mgonzalez)\
**Post date:** [August 23, 2023, 11:51am UTC](https://community.sonarsource.com/t/upgrade-sonarqube-to-psql-without-data-loss-from-h2-database/70572/4 "2023-08-23T11:51:06Z")

</div>

I don´t know if it is works for all versions but I have managed to migrate from H2 to PostgreSQL using 8.9.10 LTS CE version.

What I did was to use Squirrel SQL client and use the Embedded H2 and PostgreSQL drivers and copy the data from one database to the other.

The “trick” for connecting to the Embedded H2 database from Squirrel SQL was to start Sonarqube and connect as follows with the URL

`jdbc:h2:tcp://localhost:9092/sonar`

![H2_Embedded](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/6/0/60e9656c4fa9d51471226888551317e9765fe802.png)

After copying the data, make sure you delete the content under data\es7 (or es8) folder so the indices from ElasticSearch are regenerated
