Report this

What is the reason for this report?

Migrate PostgreSQL DB from docker contaier to Digital Ocean Managed DB

Posted on August 1, 2024

tried to migrate a PostgreSQL database from a Docker container to a DigitalOcean Managed Database, but when I tested the connection to the source database, it failed to connect.

I followed the migration guide by preparing the source database for migration with the following steps:

  • Allow remote connections
  • Enable logical replication
  • Change max replication slots

However, it still fails to connect to the source database.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Rather than using the live replication migration, have you considered using pg_dump and then importing that dump to your managed database?

You can do that by following the steps here:

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

To use pg_dump, you need specify the connection details (like admin username and database) and redirect the output of the command to save the database dump. The command will look like this:

pg_dump -h <your_host> -U <your_username> -p 25060 -Fc <your_database> > <path/to/your_dump_file.pgsql>

Then once you have the dump, to import it to the new source database, ensure that you can connect to your target database with psql. Then, you need to find the connection URI for the target database you want to add the existing data into.

To import a source database in custom format, use the pg_restore command:

pg_restore -d <your_connection_URI> --jobs 4 <path/to/your_dump_file.pgsql>

If you prefer the live migration, can you share the exact changes that you’ve made to your Docker Postgres instance? And also share the conf file here.

- Bobby

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.