On Thu, Mar 28, 2024 at 2:27 PM arun chirappurath <arunsnm...@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.