BUG #16732: pg_dump creates broken backups - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16732: pg_dump creates broken backups
Date
Msg-id 16732-f34c8da8c206c290@postgresql.org
Whole thread Raw
Responses Re: BUG #16732: pg_dump creates broken backups
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16732
Logged by:          Zsolt Ero
Email address:      zsolt.ero@gmail.com
PostgreSQL version: 12.4
Operating system:   Ubuntu 16.04
Description:

On a production server (12.4) backups are created by the following
command:
pg_dump --dbname=app --format=custom --file=$BACKUP_DIR/app.dump

Then on any other machine (can be the same server, can be a my macOS laptop
running 12.5), this command always fails (or it'd fail with
--single-transaction):
pg_restore --dbname=maphub_web --format=custom $BACKUP_FILE

The error is always:
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 2976; 0 63529 TABLE DATA map_versions app
pg_restore: error: COPY failed for table "map_versions": ERROR:  insert or
update on table "map_versions" violates foreign key constraint
"fk_map_versions_map_id_maps"
DETAIL:  Key (map_id)=(112664) is not present in table "maps".

The target database is cleaned with dropdb + createdb before pg_restore. I
compared the backups by md5, the file is not-corrupt.

This is quite shocking in a way, meaning that right now I couldn't restore
my prod server in case I'd need to.


pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: vacuumdb -Z can't find function declared on functional index with inline sql function
Next
From: Zsolt Ero
Date:
Subject: Re: BUG #16732: pg_dump creates broken backups