Postgresql – Merging Postgresql dump with production database

postgresql

I have a postgresql database that lost some records. I want to take a pg_dump SQL dump of the database from a few days ago and merge it with the current production database. A lot of the records are going to be duplicates so it can skip the duplicates. What is the best way to do this?

Best Answer

patch could be you friend could try creating a new dump, we'll call it current_dump and do a diff against old_dump then use

   diff old_dump new_dump > patch.input
    (copy the new_dump) to another file at this point new.db.dump)
    patch new.db.dump patch.input

You might have to sort the sort the dump files before you do the diff and depending on how big your database is this might not really be practical.

Also be very careful and do this against a backup until you are sure its right.

Otherwise, maybe there are ETL type tools that can do this.