The simplest way to move a PostgreSQL database in is a dump and restore.
Steps
- Create your Phluit database in the same or a newer PostgreSQL version than the old one.
- Add the address of the computer that runs the copy to Trusted sources.
- Make a dump of the old database:
pg_dump --format=custom --no-owner --no-privileges "OLD-CONNECTION-STRING" -f mydb.dump - Restore it into the new one:
Use the connection string from the Connect tab (it includespg_restore --no-owner --no-privileges -d "NEW-CONNECTION-STRING" mydb.dumpsslmode=require). To restore into a new database, create it first withCREATE DATABASEand change the database name in the string. - Point your app to the new host and password, then check it works before you switch off the old database.
Tips
- Stop writes to the old database during the copy, or plan a short maintenance window, so nothing is lost.
--no-owner --no-privilegesavoids errors about roles that don't exist on the new server.- Extensions the old database used must be supported here;
pg_restoretells you if one isn't.
Prefer us to do it? Open a ticket and tell us where the database is now.
Was this article helpful? Thanks for your feedback!
