One reason that you might want to restore a database from a SQL-dump is to update the DEV database with the contents of the PROD database. These instructions describe how to restore the DEV and QA databases with the latest daily backup from PROD.
...
- Find a new or updated EAS address that is in the PROD database but not the DEV or QA databases. Hint: To find a new address see the daily automated email containing a list of recent address changes.
- Copy the SQL-dump files from the daily PROD backups to DEV or QA server.
- FTP the daily backup from PROD to a local computer (e.g. your desktop computer).
- See the 'FTP Using FileZilla' section below for one method of transferring files.
- FTP the SQL-dump backup files from your local computer to the DEV or QA server.
- For consistency with the steps below upload the files to '
/var/tmp/'
on the DEV or QA server.
- Log in to the target EAS database server using SSH.
- See also PuTTY and SSH Instructions
Copy the database restore shell script from your home directory to the target directory. This is only necessary the very first time that you do this.
Code Block cp restore_dbs.sh /var/tmp
Move to the target directory.
Code Block cd /var/tmp
Change the ownership of the database restore shell script. This is only necessary the very first time that you do this.
Code Block sudo chown postgres:postgres restore_dbs.sh
Change the ownership of the SQL-dump file(s). The following examples use the SQL-dump files from 2a above.
Code Block language text sudo chown postgres:postgres easproddb.sfgov.org-eas_prod-20170613.dmp sudo chown postgres:postgres easproddb.sfgov.org-sfmaps_prod-20170613.dmp
Become the user
postgres
.Code Block sudo -u postgres -i
While logged in as the user
postgres
, move into the target directory.Code Block cd /var/tmp
Restore the database(s). This normally just takes a couple of minutes to finish.
Code Block language text ./restore_dbs.sh DEV easproddb.sfgov.org-eas_prod-20170613.dmp ./restore_dbs.sh DEV easproddb.sfgov.org-sfmaps_prod-20170613.dmp OR ./restore_dbs.sh DEV easproddb.sfgov.org-eas_prod-20170613.dmp easproddb.sfgov.org-sfmaps_prod-20170613.dmp OR ./restore_dbs.sh QA easproddb.sfgov.org-eas_prod-20170613.dmp easproddb.sfgov.org-sfmaps_prod-20170613.dmp
The restoration order of the two dmp files matters. The *eas_prod* dump must be restored before the *sfmaps_prod* dump. Otherwise a 'Data Retrieval Error' will occur.
- Exit out of both shells to close the SSH session to the target EAS database server.
- You should confirm that your database(s) have been restored by following these steps:
- Check Database
- Establish your SSH tunnel to the target EAS database server.
- Invoke pgAdmin.
- Navigate to a restored database and verify that its contents are what you expect.
- Check Web App
- Confirm by browsing the the DEV or QA web versions of EAS and verifying that the address from Step 1 is now on the map of the updated server.
- Check Database
...