Re: Table level restore in postgres - Mailing list pgsql-general

From Ron Johnson
Subject Re: Table level restore in postgres
Date
Msg-id CANzqJaD+pt75S32hknd7ChrKGR40=kS04ZJyMN0c5RKxNvhz8w@mail.gmail.com
Whole thread Raw
In response to [MASSMAIL]Table level restore in postgres  (arun chirappurath <arunsnmimt@gmail.com>)
List pgsql-general
On Thu, Mar 28, 2024 at 2:27 PM arun chirappurath <arunsnmimt@gmail.com> wrote:
Dear all, 

I am a new bie in postgres world....

Suppose I have accidently deleted a table or deleted few rows ,is it safe to drop this table and restore just this table from custom backup to same database?

By "custom backup", do you mean a dump file created by "pg_dump --format=custom"?
 
Or should I create a new database and restore it there and then migrate the data?

What is the general methodology used?

If you backup the database using "pg_dump --format=custom", then yes, you can use 
pg_restore --format=custom --table=${sometable} --database=$yourdatabase

I'd test it first, though, in a scratch database (with scratch tables and scratch data), just to ensure that the command doesn't first drop the database.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Table level restore in postgres
Next
From: Bruce Momjian
Date:
Subject: Re: Inquiry on Participating in the Korean Translation Project for PostgreSQL Documentation