简体   繁体   中英

How to backup and restore Sonarqube database in Postgresql

I want to rebuild a Sonarqube server with all projects and settings in origin server. The database is Postgresql. But I can't find some documentation for this.

Firstly I tried to backup it in Sonarqube's web UI: Settings -> System -> Backup, then backup it in a xml file. But when I restored it in a new Sonarqube server, all projects in origin server disappeared. It looks that this "backup" is only for settings, not including projects data.

Then I tried to backup database. When building the origin Sonarqube server I've created a database "sonar":

postgres-# create database sonar with owner sonar encoding 'UTF8';

So I tried to dump it:

$ sudo su - postgres
$ pg_dump sonar
pg_dump: [archiver (db)] connection to database "sonar" failed: FATAL:  database "sonar" does not exist

Trying to verify its existence:

$ psql -l

But there are only three item: postgres, template0 and template1. Where is the "sonar" database? I also tried to query with user "sonar" but failed:

$ psql -l -U sonar
psql: FATAL:  Peer authentication failed for user "sonar"

So how to rebuild the Sonarqube server with all old projects and settings?

Took me a while to see it but the answer is in fact quite obvious:

postgres-# create database sonar with owner sonar encoding 'UTF8';

You didn't create your database. Somehow you are on a continuation line and probably got an error. The first part of the line should read:

postgres=#

When that is not the case, press ctrl-C to return to a new fresh line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM