ses
ses

Reputation: 13352

Is it possible to restore only new changes from latest PostgreSQL dump

Now to restore from the a back-up/dump takes about 20 minutes,

pg_restore  --create --exit-on-error --verbose  -U postgres --dbname=postgres  --verbose --clean -F directory mydb.dump

Q: Is it possible to restore only new changes (to save time) from latest PostgreSQL dump, whenever someone has changed the db or added new data?

--

I know usually ppl use sql scripts and apply them on their db. But if there are not scripts. Because the db is altered from the outside.

Upvotes: 0

Views: 2406

Answers (2)

jjanes
jjanes

Reputation: 44305

No, pg_restore has no way of knowing what are new changes. Perhaps it could rely on timestamps you keep inside your tables, but it wouldn't know how to do this, you would have to write code to teach it.

It sounds like what you really are looking for is to use a physical backup, and then WAL replay.

Upvotes: 1

Laurenz Albe
Laurenz Albe

Reputation: 247270

There is no support for that in pg_restore, but from PostgreSQL v12 on you can use pg_dump with the options --inserts --on-conflict-do-nothing. Such a dump will restore only those rows that do not violate a primary key or unique constraint on the table to which you restore.

Upvotes: 1

Related Questions