Exporting and Importing PostgreSQL Databases
PostgreSQL is an open-source object-relational database management system..
This document shows how to export data from, and import data to, your PostgreSQL databases on Opalstack. The examples use mydb
as the database name, mydbuser
as the database username, and mydb.sql
as the filename for the imported/exported data - be sure to replace those values with the names of your own database and database user.
You can export a PostgreSQL database by executing the following command in a SSH session on your Opalstack server:
pg_dump -U mydbuser -f mydb.sql mydb
Enter your PostgreSQL database user password when prompted.
When the command is complete, the exported data will be stored in the file mydb.sql
in your SSH session's current working directory.
You can import a PostgreSQL database by executing the following command in a SSH session on your Opalstack server:
psql -U mydbuser mydb < mydb.sql
Enter your PostgreSQL database user password when prompted.
When the command is complete, the imported data will be stored in your mydb
PostgreSQL database.