Warning This document has not been updated for a while now. It may be out of date.Last updated: 5 Apr 2022
Restore an Individual Postgres Production Database in AWS RDS
If you need to restore an entire RDS instance please see this manual page instead.
Restoring From S3 Backups
We take nightly database backups and save them to the
govuk-<environment>-database-backups S3 bucket inside a folder named after the RDS instance (for example
To restore a backup from the most recent copy follow the steps below:
How To Run the Sync Script
- SSH into the db_admin machine. If you are using GDS CLI you can run the following command to ssh into the correct machine:
gds govuk connect ssh -e <environment> db_admin
- To find the command you need to run to restore a specific database, list the govuk-backup user’s cronjobs, then grep for the database name you need:
sudo -iu govuk-backup crontab -l | grep <database_name>
sudo -iu govuk-backup crontab -l | grep publishing_api
- Copy the command that starts with “pull”. For example, if you were restoring the publishing_api database you’d need this line:
/usr/bin/ionice -c 2 -n 6 /usr/local/bin/with_reboot_lock /usr/bin/envdir /etc/govuk_env_sync/env.d /usr/local/bin/govuk_env_sync.sh -f /etc/govuk_env_sync/pull_publishing_api_production_daily.cfg
- Start a tmux session as the govuk-backup user:
sudo -iu govuk-backup tmux
Then run the command you copied previously.
The script will inform you when it’s complete. To switch between tmux windows, press
n. To disconnect from tmux, press
d. To reconnect, run
sudo -iu govuk-backup tmux a
govuk-env-sync manual page for more information.