I don't think I saw one on the documentation but maybe I just didn't
look right.
We're planning on using Pgsql and can dump and then restore but not
sure if any gotchas or any other steps that would help simplify our
needs.
I've just barely got my first Gerrit Install completed to test my
experience prior to going onto our production servers...
-Regards,
Gibran
Are you talking about *moving* the installation from one system to another?
Or are you talking about upgrading an existing installation to a newer
version of Gerrit Code Review?
Yes we have an existing Gerrit server running for some time, but many
factors which make it slow. Going to setup Gerrit on a new dedicated
server, but would like to get everything setup, then migrate it over
to the new server. Would probably need to completely backup the DB
(pgdump) then import into the new server.
The old server also has a /git/project_name/ <all git repos here>/
structure. And so we'd like to allow for this Gerrit or migration to
allow for having capability to have something like:
/git/project1/
/git/project2/
/git/project3/
Andy any other projects created under /git/.
OK. Yes, dump the database with pgdump and restore it on the
new server. I do this all of the time to help debug issues with
a production installation. Its basically just:
pg_dump -O -Fc reviewdb >dump
scp dump target:
createdb -E UTF-8 -O gerrit2 reviewdb
pg_restore -d reviewdb dump
Also make sure you completely copy over the Git repositories from the
source system to the destination. Its safest to do both the database
dump and the repository copy while the source server is shutdown.
> The old server also has a /git/project_name/ <all git repos here>/
> structure. And so we'd like to allow for this Gerrit or migration to
> allow for having capability to have something like:
> /git/project1/
> /git/project2/
> /git/project3/
>
> Andy any other projects created under /git/.
I think this is easy. Just edit your gerrit.config file on the
new server to point to /git/ instead of /git/project_name/.
But don't rename any existing Gerrit projects. To rename them you
have to do some surgery on the database records, as a lot of the
records are keyed by the project's name below that gerrit.basePath
variable in gerrit.config.
Another question, which gots me confused...
>
>> The old server also has a /git/project_name/ <all git repos here>/
>> structure. And so we'd like to allow for this Gerrit or migration to
>> allow for having capability to have something like:
>> /git/project1/
>> /git/project2/
>> /git/project3/
>>
>> Andy any other projects created under /git/.
>
> I think this is easy. Just edit your gerrit.config file on the
> new server to point to /git/ instead of /git/project_name/.
>
> But don't rename any existing Gerrit projects. To rename them you
> have to do some surgery on the database records, as a lot of the
> records are keyed by the project's name below that gerrit.basePath
> variable in gerrit.config.
>
(sorry to change the name but think this may help clarify my question)
So as I mentioned our existing Gerrit server/setup like so:
/git/projectsA/*
/git/projectsB/*
/git/projectsC/* <-- Gerrit only using/displaying these.
/git/projectsD/*
* = lots of git repos.
I thought I would find /git/projectsC under gerrit.config but it's actually has:
[gerrit]
basepath = /git
How is it that Gerrit is only displaying and using the git repos
inside of /git/projectsC/ (based on its gerrit.config)?
Maybe you would know of another way this was accomplished or some
other file to check.
I'm assuming that only projects under C will be moved to the new
server since Gerrit has it on its page, but not sure what the DB will
have if gerrit.config has /git/.
Hope that was easy to follow.
Check your server's projects table.
A repository called /git/projectsC/awesome/widgets.git will have
project name of 'projectsC/awesome/widgets' given that your basepath
is already '/git'.
My guess is that your projects table simply does not have records
for the projectsA/, projectsB/ and projectsD/ subdirectories, so
those are not displayed in the web UI.
Probably not.
> Basically the developers don't want to see
> "projectsC/<all_git_repos_here> inside of Gerrit and would like for
> Gerrit to show "/git/*".
Huh. They want Gerrit to show /git/ in front of everything?
I'm fairly certain you can't do this, Gerrit won't accept "/"
in the first position of a project name. But you can do "git/".
> Since our gerrit basepath is /git inside of gerrit.config (old server)
> I'm suspecting dump and restore needs a bit of changing (perhaps not a
> biggie but will require the change)???
If you want "git/" in front of each project name, you need to set
gerrit.basePath to just "/".
You will also need to update all of the records to use that
new prefix. Completely untested, so try this on a backup of the
database, but its something like:
UPDATE projects SET name = 'git/' || SUBSTR(name, LENGTH('projectsC/'))
WHERE name <> (SELECT wild_project_name FROM system_config);
UPDATE ref_rights SET project_name = 'git/' || SUBSTR(project_name, LENGTH('projectsC/'))
WHERE project_name <> (SELECT wild_project_name FROM system_config);
UPDATE changes SET dest_project_name = 'git/' || SUBSTR(dest_project_name, LENGTH('projectsC/'));
UPDATE account_project_watches SET project_name = 'git/' || SUBSTR(project_name, LENGTH('projectsC/'));
I think that's it. Just the 4 tables need updating.
Was this done right cause here's my results:
RESULTS:
========
1).reviewdb=> SELECT MAX(project_id) + 1 FROM projects;
?column?
----------
733
(1 row)
reviewdb=> ALTER SEQUENCE project_id RESTART WITH 733;
ALTER SEQUENCE
2).reviewdb=> SELECT MAX(account_id) + 1 FROM accounts;
?column?
----------
1000104
(1 row)
reviewdb=> ALTER SEQUENCE account_id RESTART WITH 1000104;
ALTER SEQUENCE
3).reviewdb=> SELECT MAX(account_group_id) + 1 FROM account_groups;
ERROR: column "account_group_id" does not exist
Then re-tried the java -jar gerrit-2.1.2.4 -d review_site:
======================================
Scanning /android1/android/git
Exception in thread "main"
com.google.gwtorm.client.OrmDuplicateKeyException: projects
at com.google.gwtorm.schema.sql.DialectPostgreSQL.convertError(DialectPostgreSQL.java:53)
at com.google.gwtorm.jdbc.JdbcAccess.convertError(JdbcAccess.java:331)
at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:178)
at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:35)
at com.google.gwtorm.client.impl.AbstractAccess.insert(AbstractAccess.java:56)
at com.google.gerrit.server.git.GitProjectImporter.importProjects(GitProjectImporter.java:103)
at com.google.gerrit.server.git.GitProjectImporter.importProjects(GitProjectImporter.java:106)
at com.google.gerrit.server.git.GitProjectImporter.run(GitProjectImporter.java:59)
at com.google.gerrit.pgm.Init$SiteRun.importGit(Init.java:241)
at com.google.gerrit.pgm.Init.run(Init.java:86)
at com.google.gerrit.pgm.util.AbstractProgram.main(AbstractProgram.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gerrit.launcher.GerritLauncher.invokeProgram(GerritLauncher.java:155)
at com.google.gerrit.launcher.GerritLauncher.mainImpl(GerritLauncher.java:89)
at com.google.gerrit.launcher.GerritLauncher.main(GerritLauncher.java:47)
at Main.main(Main.java:25)
Caused by: java.sql.BatchUpdateException: Batch entry 0 INSERT INTO
projects(description,use_contributor_agreements,use_signed_off_by,submit_type,name)VALUES(NULL,'N','N','M','tools/repo')
was aborted. Call getNextException to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2569)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1796)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2708)
at com.google.gwtorm.jdbc.JdbcAccess.execute(JdbcAccess.java:293)
at com.google.gwtorm.jdbc.JdbcAccess.doInsert(JdbcAccess.java:171)
... 16 more
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key
violates unique constraint "projects_project_id_key"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
... 20 more
-FuRoSh...
=/
Oooh! This is a schema mismatch going on. You didn't drop all of
the objects you needed to. At a minimum you need to still do:
DROP SEQUENCE project_id;
ALTER TABLE projects DROP project_id;