Project

General

Profile

Actions

Bug #17474

closed

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

Added by Ohad Levy over 7 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Database
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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 1 (0 open1 closed)

Related to Foreman - Bug #17488: Add confirmation step to db:import taskClosedDaniel Lobato Garcia11/25/2016Actions
Actions

Also available in: Atom PDF