How to download a database from Managed Database Cluster?

July 10, 2019 187 views
DigitalOcean Databases Ubuntu 18.04

How to download a database from Managed Database Cluster (PostgreSQL)?

And

How to upload existing database to Managed Database Cluster (PostgreSQL)?

2 Answers
MattIPv4 MOD July 12, 2019
Accepted Answer

Hi there @Motash,

You should be able to achieve both of these by using the pg_dump and pg_restore command-line tools.

A command similar to the following should allow you to dump all the data from your remote PostgreSQL database to a single dump file:

  • pg_dump -h use_your_host -U use_your_username -Fc use_your_dbname > dbdump.pgsql

You can restore a dump file to the default database and user by running a command similar to this:

  • pg_restore -d 'use_your_connnectionURI' --jobs 4 use_your_dump_file

We cover both importing and exporting databases more detail in our product documentation for our managed databases (PostgreSQL):

https://www.digitalocean.com/docs/databases/how-to/postgresql/import-databases/

Hope that helps!
- Matt.

Thank you. For pgdump I had to also add:
-p my
port_number
(in my case 25060).

Have another answer? Share your knowledge.