Search code examples
postgresqldatabase-administration

Clone selected schemas from postgres database to new server


I have a postgres database with +150 almost identical shemas that contains + 1 tb data. We are about to full clone the database, BUT with only with 3 selected schemas (admin, postgres, master) including their data, functions, ect to another database on another server.

How do I do this the most easy way, if a full pg_dump including all the data from all the irrelevant schemas is not an option?


Solution

  • There are some useful informations if you run pg_dump --help .

      -n, --schema=SCHEMA          dump the named schema(s) only
      -N, --exclude-schema=SCHEMA  do NOT dump the named schema(s)
    

    And the option above would be what you want.

    Hope it works for you.