- Home
- PostgreSQL
- Copy PostgreSQL Database to Another Machine
Copy PostgreSQL Database to Another Machine
Whether migrating to another database or server, there are a couple of ways to bring along your PostgreSQL database data.
On the first server that already has the data, we will want to get our data and COPY TO a text file:
pg_dump "MyDataBase" > /path/to/export/file.sql
Then we move the data file to the second server that needs the data, decide which database you want to import the data into and make sure it exists and is cleared out.
Then import the datafile into the database of your choice:
psql "MyDataBase" < /path/to/export/file.sql