How to copy a PostgreSQL database to another server?
1. Using pg_dump command
pg_dump -C -h localhost -U localuser dbname | psql -h remotehost -U remoteuser dbname
pg_dump -C -h remotehost -U remoteuser dbname | psql -h localhost -U localuser dbname
2. With TablePlus
In TablePlus, you can copy a database to another server using the
- From welcome screen, click on the Backup button
- Choose your connection and database, and hit
TablePlus will export a
.dump file for you to save on your computer.
- From welcome screen, click on the Restore button
- Choose your dumb file, choose connection and database, then hit
TablePlus will import data from the dumb file to your selected database. You can import the dump file into an existing database or create a new database from this window.
New to TablePlus? TablePlus is a GUI client for multiple databases which is native, beautiful, and available for free. Check it out:
Download for macOS: Download TablePlus here.
Not on Mac? Download TablePlus for Windows.
On Linux? Download TablePlus for Linux
Need a quick edit on the go? Download TablePlus for iOS