Thursday, January 30, 2014

Migrating Sonar to a different host

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)

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

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

aptitude update && aptitude install sonar

Install postgresql and set up an account for your sonar:

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:

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:

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

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

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