Im currently using the tool pg_dump to dump tables from my database. I would like to automate this process, however, i have not found a way to specify pg_dump to dump multiple databases that have the same prefix.
Any help in this matter would be greatly appreciated
Examples from the manual:
To dump all tables whose names start with emp in the detroit schema, except for the table named employee_log:
$ pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb > db.sql
To dump all schemas whose names start with east or west and end in gsm, excluding any schemas whose names contain the word test:
$ pg_dump -n 'east*gsm' -n 'west*gsm' -N 'test' mydb > db.sql
The same, using regular expression notation to consolidate the switches:
$ pg_dump -n '(east|west)*gsm' -N 'test' mydb > db.sql
To dump all database objects except for tables whose names begin with ts_:
$ pg_dump -T 'ts_*' mydb > db.sql
You can use parameter "-t" multiple times if you want to dump more than one table.
$ pg_dump -t table1 -t table2 mydb > dump.sql
-t table --table=table
Dump only tables (or views or sequences) matching table. Multiple
tables can be selected by writing multiple -t switches.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With