Re: postgres pg_restore append data

From: Melvin Davidson <melvin6925(at)gmail(dot)com>
To: dhanuj hippie <dhanuj(dot)hippie(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: postgres pg_restore append data
Date: 2016-12-05 14:19:30
Message-ID: CANu8Fiyh4bwE+H80GOx0OCFjDM7p3C4WjJG3G09iv3Q4KFo7Lw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Dec 5, 2016 at 4:36 AM, dhanuj hippie <dhanuj(dot)hippie(at)gmail(dot)com>
wrote:

> Hi,
> I have a pg backup created using pg_dump custom format. I'm trying to
> restore into a DB which already has some data, using pg_restore data-only.
> This fails in scenarios where same data (some rows) is present in DB as
> well as dump. Is there a way to ignore such rows and proceed with restoring
> the rest of data ? I don't want to lose the present data in DB. I need to
> append the backup onto current content in DB.
>
> Thanks,
> Dhanuj
>

*The best I can advise you is this.1. Create a new database x.2. Restore
the backup to the new database.3. Rename the table to something like
table_old.4. Rename the primary index and any other index so that they
will not be the same as ones in the original table.5. Dump table_old only
-> pg_dump -t table_old x > table_old.sql6. Restore table_old to your
database with your original table (table_orig).Then you can:INSERT INTO
table_orig SELECT * FROM table_old WHERE your_primary_key NOT IN
(SELECT your_primary_key FROM table_orig );*

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message basti 2016-12-05 15:23:10 Re: Postgres Traffic accounting
Previous Message Rich Shepard 2016-12-05 13:42:27 Re: Postgres and LibreOffice's 'Base'