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.
Can I selectively create a backup of Postgres database, with only certian tables?
Asked Answered
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)'
postgresql.org/docs/8.3/interactive/backup-dump.html, but add the '-t' option (see pg_dump --help). –
Hynda
I don't think older versions of PostgreSQL allow the '-t' option. –
Quarto
Actually, I think in 8.0, it allowed only one -t option, so you could only dump one table at a time. –
Quarto
@Paul "the table parameter is interpreted as a pattern according to the same rules used by psql's \d commands" –
Lineberry
is it possible to apply where condition to fetch only selective records in all the 10 tables? –
Allative
© 2022 - 2024 — McMap. All rights reserved.