Upgrading from 1.11 on CentOS 6 to 1.13 on CentOS 7

I need to upgrade to 1.13 so as to get support for Puppet 4. My upgrade
path is more complicated due to the fact that I am running on CentOS 6
currently and that isn't supported past 1.12.

My upgrade path is as follows:

  1. upgrade my current Foreman from 1.11 to 1.12.4
  2. backup the database following procedures outlined
    here. Foreman :: Manual
  3. build a new CentOS 7 machine and installed 1.12.4
  4. restore the backup obtained in 2

However, running the db_import results in many errors. Such as

Your backup is going to be imported from: /tmp/foreman.1483733976.sql
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 150; 1259 16503 TABLE
architectures foreman
pg_restore: [archiver (db)] could not execute query: ERROR: relation
"architectures" already e
xists
Command was: CREATE TABLE architectures (
id integer NOT NULL,
name character varying(255) DEFAULT NULL::character varying NOT NU…
pg_restore: [archiver (db)] Error from TOC entry 149; 1259 16501 SEQUENCE
architectures_id_seq
foreman
pg_restore: [archiver (db)] could not execute query: ERROR: relation
"architectures_id_seq" al
ready exists
Command was: CREATE SEQUENCE architectures_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;

And

pg_restore: [archiver (db)] Error from TOC entry 3163; 0 18774 TABLE DATA
host_status foreman
pg_restore: [archiver (db)] COPY failed for table "host_status": ERROR:
insert or update on ta
ble "host_status" violates foreign key constraint
"host_status_hosts_host_id_fk"
DETAIL: Key (host_id)=(1756) is not present in table "hosts".

Amongst many others. By the time it finishes it reports 616 errors.

When I try to start up Foreman after that I get

More than 1 row in migrator table (Sequel::Migrator::Error)

I tried running foreman-rake db:seed and db:migrate but they both result in the same error above.

In troubleshooting I tried dropping all the tables in the foreman DB but my errors actually went up (from 616 to 618). The second error above looks like it is trying to update the host_status table without first populating the hosts table (hence the FK violation).

Kind of stuck here. I need to get to 1.13 for Puppet 4 support.

Thanks

Hello,

I noticed today we execute the import twice, for some reason. Reported a
bug: Bug #17974: PostgreSQL restore task is executed twice - Foreman

You better use pg_restore directly on the dump. You may also need to
provide --data-only if you migrated the database.

··· On Fri, Jan 6, 2017 at 10:31 PM, Matthew Ceroni wrote:

I need to upgrade to 1.13 so as to get support for Puppet 4. My upgrade
path is more complicated due to the fact that I am running on CentOS 6
currently and that isn’t supported past 1.12.

My upgrade path is as follows:

  1. upgrade my current Foreman from 1.11 to 1.12.4
  2. backup the database following procedures outlined here.
    Foreman :: Manual.
    5Backup,RecoveryandMigration
  3. build a new CentOS 7 machine and installed 1.12.4
  4. restore the backup obtained in 2

However, running the db_import results in many errors. Such as

Your backup is going to be imported from: /tmp/foreman.1483733976.sql
pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 150; 1259 16503 TABLE
architectures foreman
pg_restore: [archiver (db)] could not execute query: ERROR: relation
"architectures" already e
xists
Command was: CREATE TABLE architectures (
id integer NOT NULL,
name character varying(255) DEFAULT NULL::character varying NOT NU…
pg_restore: [archiver (db)] Error from TOC entry 149; 1259 16501 SEQUENCE
architectures_id_seq
foreman
pg_restore: [archiver (db)] could not execute query: ERROR: relation
"architectures_id_seq" al
ready exists
Command was: CREATE SEQUENCE architectures_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;

And

pg_restore: [archiver (db)] Error from TOC entry 3163; 0 18774 TABLE DATA
host_status foreman
pg_restore: [archiver (db)] COPY failed for table “host_status”: ERROR:
insert or update on ta
ble “host_status” violates foreign key constraint
"host_status_hosts_host_id_fk"
DETAIL: Key (host_id)=(1756) is not present in table “hosts”.

Amongst many others. By the time it finishes it reports 616 errors.

When I try to start up Foreman after that I get

More than 1 row in migrator table (Sequel::Migrator::Error)

I tried running foreman-rake db:seed and db:migrate but they both result in the same error above.

In troubleshooting I tried dropping all the tables in the foreman DB but my errors actually went up (from 616 to 618). The second error above looks like it is trying to update the host_status table without first populating the hosts table (hence the FK violation).

Kind of stuck here. I need to get to 1.13 for Puppet 4 support.

Thanks


You received this message because you are subscribed to the Google Groups
"foreman-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Later,
Lukas @lzap Zapletal

I will give that a try.

As a stop gap I kept the DB on the old system and just pointed the new
system at that. Works for now.

··· On Monday, January 9, 2017 at 1:05:54 AM UTC-8, Lukas Zapletal wrote: > > Hello, > > I noticed today we execute the import twice, for some reason. Reported a > bug: http://projects.theforeman.org/issues/17974 > > You better use pg_restore directly on the dump. You may also need to > provide --data-only if you migrated the database. > > On Fri, Jan 6, 2017 at 10:31 PM, Matthew Ceroni > wrote: > >> I need to upgrade to 1.13 so as to get support for Puppet 4. My upgrade >> path is more complicated due to the fact that I am running on CentOS 6 >> currently and that isn't supported past 1.12. >> >> My upgrade path is as follows: >> >> 1) upgrade my current Foreman from 1.11 to 1.12.4 >> 2) backup the database following procedures outlined here. >> https://theforeman.org/manuals/1.13/index.html#5.5Backup,RecoveryandMigration >> 3) build a new CentOS 7 machine and installed 1.12.4 >> 4) restore the backup obtained in 2 >> >> >> However, running the db_import results in many errors. Such as >> >> Your backup is going to be imported from: /tmp/foreman.1483733976.sql >> pg_restore: [archiver (db)] Error while PROCESSING TOC: >> pg_restore: [archiver (db)] Error from TOC entry 150; 1259 16503 TABLE >> architectures foreman >> pg_restore: [archiver (db)] could not execute query: ERROR: relation >> "architectures" already e >> xists >> Command was: CREATE TABLE architectures ( >> id integer NOT NULL, >> name character varying(255) DEFAULT NULL::character varying NOT NU... >> pg_restore: [archiver (db)] Error from TOC entry 149; 1259 16501 SEQUENCE >> architectures_id_seq >> foreman >> pg_restore: [archiver (db)] could not execute query: ERROR: relation >> "architectures_id_seq" al >> ready exists >> Command was: CREATE SEQUENCE architectures_id_seq >> START WITH 1 >> INCREMENT BY 1 >> NO MAXVALUE >> NO MINVALUE >> CACHE 1; >> >> And >> >> pg_restore: [archiver (db)] Error from TOC entry 3163; 0 18774 TABLE DATA >> host_status foreman >> pg_restore: [archiver (db)] COPY failed for table "host_status": ERROR: >> insert or update on ta >> ble "host_status" violates foreign key constraint >> "host_status_hosts_host_id_fk" >> DETAIL: Key (host_id)=(1756) is not present in table "hosts". >> >> >> Amongst many others. By the time it finishes it reports 616 errors. >> >> When I try to start up Foreman after that I get >> >> More than 1 row in migrator table (Sequel::Migrator::Error) >> >> >> I tried running foreman-rake db:seed and db:migrate but they both result in the same error above. >> >> >> In troubleshooting I tried dropping all the tables in the foreman DB but my errors actually went up (from 616 to 618). The second error above looks like it is trying to update the host_status table without first populating the hosts table (hence the FK violation). >> >> >> Kind of stuck here. I need to get to 1.13 for Puppet 4 support. >> >> >> Thanks >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "foreman-dev" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to foreman-dev...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Later, > Lukas @lzap Zapletal >