...
Note |
---|
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 |
Step-by-step Guide
- 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.
- Before an EAS database can be restored, the SQL-dump file must be available on the target EAS database server. One way to do this is to copy the SQL-dump file from the source EAS database server to the target EAS database server by way of your desktop personal computer (PC). One way to do this is to use FileZilla.
- These are example SQL-dump files for the
eas_prod
and thesfmaps_prod
databases:easproddb.sfgov.org-eas_prod-20170613.dmp
easproddb.sfgov.org-sfmaps_prod-20170613.dmp
- Copy the SQL-dump file(s)
- FROM: source EAS database server (
/mnt/backup/pg/daily
) - TO: desktop PC
- FROM: source EAS database server (
- Copy the SQL-dump file(s)
- FROM: desktop PC
- TO: target EAS database server (
/var/tmp
)
- These are example SQL-dump files for the
- Log in to the target EAS database server using SSH.
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 into 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
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
- 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 the following steps:
- Establish your SSH tunnel to the target EAS database server.
- Invoke pgAdmin.
- Navigate to a restored database and verify that its contents are what they should be.