Search code examples
ruby-on-railspostgresqlcloud9-ide

How to create dump file from Cloud 9 PostgreSQL database?


I am now working on Cloud 9 and need to see my PostgreSQL database. So I hope to know the below two methods.

  1. How to create dump file from PostgreSQL database when you know database name in Cloud 9?

  2. Which tool can I use to see the tables of PostgreSQL database dump?


Solution

  • Use pg_dump. It looks like Cloud9 doesn't permit remote PostgreSQL connections, so you'll need to run it within the workspace, then transfer the dump file to your computer. Use pg_dump -Fc to make a PostgreSQL-custom-format dump, which is the recommended format.

    To list tables in the dump use pg_restore -l to list the dump's table of contents. Generally it's easier to work with dumps by restoring them to a local PostgreSQL install (again, using pg_restore) though.

    For more detail see the PostgreSQL manual