Welcome to part 4 of the Supporting Promote series. In this series, we will tackle some common issues and questions, and provide best practices for troubleshooting. This article will demonstrate backing up and restoring your Promote PostgreSQL database.
It seems our PostgreSQL database is corrupted. How can we restore the database?
Start by reviewing the backup databases that are available.
In order to verify the available bundles, run:
sudo yum install tree
When prompted (y/n) to install, enter y
Next, run the command below on the original Master node. It should produce a tree of sub-directories:
tree /var/promote

Now that we can see all of the db-backups that are available. In this case, we will restore the database based on the ".tar.gz" file that is available.
promote-2018.02.25-05.00.01.tar.gz
In the unlikely event that the promote_db-data volume gets corrupted, you can restore your database using the following commands:
First, SSH into the master node:
ssh user@IP_address_of_master
Copy the DB password:
cat /var/promote/credentials/db.txt
9eaa546rc418d87904f04314a
Run pg_restore on the promote database and use your restoration file:
pg_restore -c -h $(ifconfig | grep inet | head -n1 |awk '{print $2}') -d promote -p 5432 -U promote -W -v /var/promote/db-backups/postgres/promote-2018.03.25-05.00.01.tar.gz
Your database should now be restored! Keep calm and Promote on!