Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I selectively create a backup of Postgres database, with only certian tables?

Can I programatically(or whichever way works fine) create the backup of a database, with only the tables I want? I have around 100 tables in my database and I want only 10 tables backup(ofcourse all are interdependant). How can I achieve this? And by the way I have a postgresql database.

like image 758
None-da Avatar asked Jan 27 '26 22:01

None-da


1 Answers

Of course. pg_dump lets you pass list of tables with parameter -t

To clear some doubts. True, the -t parameter accepts only one pattern. But it's a pattern very similar to regular expression, so if you want to dump tables A, B & C you can do:

pg_dump -t '(A|B|C)' 
like image 195
vartec Avatar answered Jan 29 '26 12:01

vartec