Question

Migrate PostgreSQL DB from docker contaier to Digital Ocean Managed DB

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.


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
August 7, 2024

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

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.