Is there some way to tell pg_restore
to only append rows that don't already exist?
Background: I'm trying to restore an archive-db from a main-db. Both are using PostgreSQL 12.
The catch is I don't want to keep lots of the table entries on my main-db. I generally only care about entries in the last few hours, but need everything to be pretty fast so I want to drop old data on the main-db.
There is a small use case to keep old data around though, so for that I'd like to run pg_dump
on the main-db to dump my data to a file before I drop old data. Then on the archive-db I want to use pg_restore
to add the new stuff without loosing any old rows that existed on the main-db in previous iterations of this workflow.
I don't see an append option in the pg_restore
docs but it seems like something that should exist, so other suggestions for how to approach this problem are welcome. Thanks!