swisstech.net

tech and photography

Migrating Sonar to a different host

2014-01-30

Just a few notes on how to move your sonar installation to another machine without loosing any of your config and/or history. Some of that include the normal installation steps too. This list is specific to debian.

Add the sonar debian repo to your machine (/etc/apt/sources.list.d/sonar)

1
deb http://downloads.sourceforge.net/project/sonar-pkg/deb binary/

Update and install sonar (sonar pkg is not signed):

1
aptitude update && aptitude install sonar

Install postgresql and set up an account for your sonar:

1
2
3
4
5
aptitude install postgresql
su - postgres
psql
# CREATE DATABASE sonar;
# CREATE ROLE sonar WITH NOSUPERUSER NOCREATEDB NOCREATEROLE LOGIN PASSWORD 's3cr3t';

Dump the database on the old machine, copy to the new one and import there:

1
2
oldhost: pg\_dump sonar > sonar.sql
newhost: psql -U sonar -h localhost sonar < sonar.sql

Copy a bunch of other files/directories from old to new:

1
2
/opt/sonar/data/sonar.h2.db
/opt/sonar/extensions

Start your new sonar and have a look at the log if everything’s ok:

1
service  sonar restart ; tail -F /opt/sonar/logs/sonar.log