# Restore a PostgreSQL database

This is a quick example of how to restore a PostgreSQL database dump.

# Step 1

Create a PostgreSQL backup for sampleDatabase (as an example).

# Step 2a

Go to your backup page, under the "Backup History" section click the little "i" on the right, click "Database Backup", then click "Raw Download Link" and copy the output. Download Backup

# Step 2b

Under the backup restore section on the modal that just popped up, click on "Click to generate a signed download link" then copy the resulting link

# Step 3

On your server download and extract the backup by runnig the following command, and use the signed download link you obtained in the previous step (ensure you enclose it in double quotes as shown):

wget -O - "PasteTheSignedDownloadLinkHereBetweenTheQuotes" | gunzip -c > postgresql-backup.pgsql

This will output a single SQL file in this format sampleDatabase.sql in the same directory.

# Step 4

Note: the following command will restore newDatabaseName content to sampleDatabase content. It is a good practice to inspect the backup first before the restore.

Restore the downloaded backup as shown below by running:

PGPASSWORD=database-password-here pg_restore -U database-user-here -h your-database-host-or-ip-here -p database-port-here -d newDatabaseName < sampleDatabase.pgsql

If you need any help in any of these steps, let us know, and we can help you with the restore.

Last Updated: 9/23/2022, 4:15:20 PM