Re: Table level restore in postgres

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: arun chirappurath <arunsnmimt(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Table level restore in postgres
Date: 2024-03-28 19:09:24
Message-ID: 23a55a12-f7cb-496a-82a1-e9811ee2e483@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/28/24 11:27, arun chirappurath 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?

1) You can though depending on when you took the backup it might not be
up to date.

2) Do you have replication(logical or binary) set up?

3) Do you know what was deleted?

>
> Or should I create a new database and restore it there and then migrate
> the data?

That is overkill for a single table.

>
> What is the general methodology used?

One way, create a new table that has the same structure as the one you
want to restore, do a data only dump from the backup, rename the table
name in the dump output to the new table name and restore the data to
the new table, verify the data and then transfer all or part of the to
existing table.

>
>
> I tried it in a smaller database and it worked in same database..however
> dbeaver was throwing a warning saying database may get corrupted?

1) DBeaver thinks a lot of things are wrong that are not, I would use
the tools that ship with Postgres; psql, pg_dump, pg_restore, etc.

2) If you want to stay with DBeaver post the actual complete error
message here.

>
> Thanks,
> Arun
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2024-03-28 19:41:14 Re: Table level restore in postgres
Previous Message arun chirappurath 2024-03-28 18:27:39 Table level restore in postgres