Bug #17474

db:import_dump does not clean existing database prior to re-importing

Added by Ohad Levy 6 months ago. Updated 6 months ago.

Status:Closed
Priority:Normal
Assigned To:Ohad Levy
Category:Database
Target version:-
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/4046
Story points-
Velocity based estimate-
Release1.14.0Release relationshipAuto

Description

It might be lack of my understanding / docs, but trying to use backup and restore on another server, the sequence that I've done was:

1. backup old server (as described in the manual)
2. create a new server, run foreman installer (so new database gets created) followed by a db restore (and recovering /etc/foreman and puppet ssl dir).

at that point, the recovery fails, as the existing database already is migrated (even if its the same version) so fk errors are present, for example:

pg_restore: [archiver (db)] could not execute query: ERROR:  constraint "tokens_host_id_fk" for relation "tokens" already exists
    Command was: ALTER TABLE ONLY tokens
    ADD CONSTRAINT tokens_host_id_fk FOREIGN KEY (host_id) REFERENCES hosts(id);

the solution was to add --clean to the backup rake task prior.


Related issues

Related to Foreman - Bug #17488: Add confirmation step to db:import task Closed 11/25/2016

Associated revisions

Revision d39ced29
Added by Ohad Levy 6 months ago

fixes #17474 - DROP db prior to restore on postgres

when using postgres as a database, and restoring and
existing db dump, clean the target database prior to restore.

this allow the usage case when installing a new server,
running foreman-installer and then restoring the database.

History

#1 Updated by The Foreman Bot 6 months ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Ohad Levy
  • Pull request https://github.com/theforeman/foreman/pull/4046 added

#2 Updated by Daniel Lobato Garcia 6 months ago

  • Related to Bug #17488: Add confirmation step to db:import task added

#3 Updated by Ohad Levy 6 months ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#4 Updated by Dominic Cleal 6 months ago

  • Release set to 1.14.0

Also available in: Atom PDF