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.
views:
290answers:
1
+7
A:
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)'
vartec
2009-03-02 15:27:12
http://www.postgresql.org/docs/8.3/interactive/backup-dump.html, but add the '-t' option (see pg_dump --help).
Jarret Hardie
2009-03-02 15:29:14
I don't think older versions of PostgreSQL allow the '-t' option.
Paul Tomblin
2009-03-02 15:30:44
Actually, I think in 8.0, it allowed only *one* -t option, so you could only dump one table at a time.
Paul Tomblin
2009-03-02 15:31:25
@Paul "the table parameter is interpreted as a pattern according to the same rules used by psql's \d commands"
vartec
2009-03-02 15:34:49