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.
Because all EAS developers log into the various EAS Linux servers using the same login credentials, the information below could be (re-)derived at any time by examining the complete shared history by running the |
Each EAS database in each of the environments is backed up every night, so there is always a SQL-dump file available for database restoration.
/mnt/backup/pg/daily
easproddb.sfgov.org-eas_prod-YYYYMMDD.dmp
easproddb.sfgov.org-sfmaps_prod-YYYYMMDD.dmp
easproddb.sfgov.org-eas_prod-20170613.dmp
easproddb.sfgov.org-sfmaps_prod-20170613.dmp
Each EAS environment has a shell script named 'restore_dbs.sh
' that is located in the dev user's home directory.
When the script is run with the correct arguments it performs the entire EAS database restoration process for the given server.
Step-by-Step EAS Database Restoration Guide
/var/tmp/'
on the DEV or QA server.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.
cp restore_dbs.sh /var/tmp |
Move to the target directory.
cd /var/tmp |
Change the ownership of the database restore shell script. This is only necessary the very first time that you do this.
sudo chown postgres:postgres restore_dbs.sh |
If the database restore shell script is not executable, then modify this permission for the file owner.
sudo chmod u+x restore_dbs.sh |
Change the ownership of the SQL-dump file(s). The following examples use the SQL-dump files from 2a above.
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
.
sudo -u postgres -i |
While logged in as the user postgres
, move into the target directory.
cd /var/tmp |
Restore the database(s). This normally just takes a couple of minutes to finish. If the one-argument example below does not work, then use the two-argument example.
./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.
Download and install FileZilla from https://filezilla-project.org/