Step 1
Create a backup of the database using pg_dump
:
- Open the command prompt or terminal on the server with the source PostgreSQL cluster.
- Run the following command to create a backup of the database. Replace
dbname
with the name of your database anddumpfile.sql
with the name of the file where you want to save the backup.
pg_dump -U username -d dbname -f dumpfile.sql
Replace username
with the username of the database in the -U username
parameter. Replace dbname
with the name of your database in the -d dbname
parameter. Replace dumpfile.sql
with the path and name of the backup file in the -f dumpfile.sql
parameter. 3. Enter the password of the database user if prompted.
Step 2
Transfer the backup file to the server with the new cluster:
- Copy the backup file (
dumpfile.sql
) to the server with the new PostgreSQL cluster using file transfer tools such asscp
,rsync
, or any other convenient method.
Step 3
Restore the created dump.
First, you need to create databases and users, and provide all the required grants for the users as described here: https://docs.qameta.io/allure-testops/faq/ext-db/#creating-the-databases
Restore the database using pg_restore
:
- Open the command prompt or terminal on the server with the new PostgreSQL cluster.
- Run the following command to restore the database from the backup.
pg_restore -U username -d newdb dumpfile.sql
Replace username
with the username of the database in the -U username
parameter. Replace newdb
with the name of the new database in the -d newdb
parameter. Specify the correct backup file name in the dumpfile.sql
parameter. 3. Enter the password of the database user if prompted.
After completing this process, your database will be restored on the new PostgreSQL cluster.
Make sure that all applications and settings related to the database are also transferred to the new server.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article