MIgrating from one Postgres to another?

Hello,

Just wanted to ask if there's a recommended way to move Foreman from one
PostgreSQL database to another? These will be on the same server, the
purpose is mostly just to ensure the indexes, table definitions and such
are correct since the current database was created during a migration from
MySQL to PostgreSQL, so it wasn't created entirely "cleanly".

Right now I'm thinking about setting up database.yml with the new database
and then letting Foreman create the basic DB structure, then taking a
backup of the current DB and restoring that into the newly created one,
then finally just switching over. Does this sound like a reasonable plan?
And speaking of that, I would guess there's a rake task that creates the
initial database, I looked through the docs but couldn't find this, can
anyone help here?

Regards
Johan Sunnerstig

That sounds sensible - just do a foreman-rake db:migrate to create the
database, tables and indexes.

Foreman :: Manual may be useful
as it talks about using pg_dump and pg_restore to backup/restore the
whole database. You might be able to find options to only move the
rows, allowing you to use the tables created by db:migrate.

··· On 20/01/15 09:06, Johan Sunnerstig wrote: > Hello, > > Just wanted to ask if there's a recommended way to move Foreman from one > PostgreSQL database to another? These will be on the same server, the > purpose is mostly just to ensure the indexes, table definitions and such > are correct since the current database was created during a migration > from MySQL to PostgreSQL, so it wasn't created entirely "cleanly". > > Right now I'm thinking about setting up database.yml with the new > database and then letting Foreman create the basic DB structure, then > taking a backup of the current DB and restoring that into the newly > created one, then finally just switching over. Does this sound like a > reasonable plan? > And speaking of that, I would guess there's a rake task that creates the > initial database, I looked through the docs but couldn't find this, can > anyone help here?


Dominic Cleal
Red Hat Engineering

Thanks for the reply. Yeah I was thinking of db:migrate, I just wasn't sure
since the name sounds like it would move something or some such. :slight_smile:
And yeah backing up only the data rather than the entire DB structure was
exactly what I had in mind since it sounds like it should "just work" to my
mind.

Regards
Johan

··· On Wednesday, January 21, 2015 at 1:07:03 PM UTC+1, Dominic Cleal wrote: > > On 20/01/15 09:06, Johan Sunnerstig wrote: > > Hello, > > > > Just wanted to ask if there's a recommended way to move Foreman from one > > PostgreSQL database to another? These will be on the same server, the > > purpose is mostly just to ensure the indexes, table definitions and such > > are correct since the current database was created during a migration > > from MySQL to PostgreSQL, so it wasn't created entirely "cleanly". > > > > Right now I'm thinking about setting up database.yml with the new > > database and then letting Foreman create the basic DB structure, then > > taking a backup of the current DB and restoring that into the newly > > created one, then finally just switching over. Does this sound like a > > reasonable plan? > > And speaking of that, I would guess there's a rake task that creates the > > initial database, I looked through the docs but couldn't find this, can > > anyone help here? > > That sounds sensible - just do a foreman-rake db:migrate to create the > database, tables and indexes. > > http://theforeman.org/manuals/1.7/index.html#5.5.1Backup may be useful > as it talks about using pg_dump and pg_restore to backup/restore the > whole database. You might be able to find options to only move the > rows, allowing you to use the tables created by db:migrate. > > -- > Dominic Cleal > Red Hat Engineering >

For Postgres, I'd also check the manual for the step on restoring the
psql sequence counters, otherwise the new db won't function correctly

  • you start from id=1 again on all your rows.

Greg