Skip to content

Commit 49dcbfe

Browse files
authored
Merge pull request #2 from GOCDB/ssh
Use ssh instead of wget to fetch the dmp file
2 parents 640f43d + 2f9278a commit 49dcbfe

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This repo contains the service and cron scripts used to run a failover gocdb ins
77
* autoEngageFailover/
88
* Contians a Service script (```gocdb-autofailover.sh```) and child scripts that monitors the main production instance. If a prolonged outage is detected, the GOCDB top DNS alias 'goc.egi.eu' is swtiched from the production instance to the failover instance. This switch can also be performed manually when needed.
99
* importDBdmpFile/
10-
* Contains a sript that should be invoked by cron hourly (```1_runDbUpdate.sh```) to download and install a .dmp of the production DB into the local failover DB. This runs separtely from the autoEngageFailover process.
10+
* Contains a script that should be invoked by cron hourly (```1_runDbUpdate.sh```) to fetch and install a .dmp of the production DB into the local failover DB. This runs separtely from the autoEngageFailover process.
1111
* nsupdate_goc/
1212
* Scripts for switching the DNS to/from the production/failover instance.
1313
* archiveDmpDownload/
@@ -21,14 +21,13 @@ This repo contains the service and cron scripts used to run a failover gocdb ins
2121
|_ gocdb-autofailover.sh# MAIN SERVICE SCRIPT to mon production instance
2222
|_ engageFailover.sh # Child script, run if prolonged outage is detected
2323
24-
importDBdmpFile/ # Scripts download/install a .dmp of the prod data
24+
importDBdmpFile/ # Scripts fetch/install a .dmp of the prod data
2525
|_ 1_runDbUpdate.sh # MAIN SCRIPT that can be called from cron, invokes child scripts below
2626
|_ ora11gEnvVars.sh # Setup oracle env
27-
|_ getDump.sh # Download a .dmp of the production data
27+
|_ getDump.sh # Fetch a .dmp of the production data
2828
|_ dropGocdbUser.sh # Drops the current DB schema
29-
|_ loadData.sh # Load the last successfully downloaded DB dmp into the RDBMS
29+
|_ loadData.sh # Load the last successfully fetched DB dmp into the RDBMS
3030
|_ gatherStats.sh # Oracle gathers stats to re-index
31-
|_ pass_wgetrc_exemplar.txt # Sample pwd file for getDump.sh (rename to pass_wgetrc)
3231
|_ pass_file_exemplar.txt # Sample pwd file for DB (rename to pass_file)
3332
3433
nsupdate_goc/ # Scripts for switching the DNS to the failover
@@ -51,15 +50,15 @@ following:
5150
* the gocdb admins are emailed,
5251
* the age of the last successfully imported dmp file is
5352
checked to see that it is current,
54-
* the hourly cron that downloads the dmp file is stopped (see
53+
* the hourly cron that fetches the dmp file is stopped (see
5554
importDBdmpFile below),
5655
* <strike>symbolic links to the server cert/key are updated so they
5756
point to the 'goc.egi.eu' cert/key</strike> (note, no longer needed as cert contains dual SAN)
5857
* the dnscripts are invoked to change the dns (see
5958
nsupdate_goc below).
6059

6160
## /root/importDBdmpFile/
62-
Contains scripts that download the .dmp file and install this
61+
Contains scripts that fetches the .dmp file and install this
6362
dmp file into the local Oracle XE instance. The master script
6463
is '1_runDbUpdate.sh' which needs to be invoked from an hourly
6564
cron:
@@ -71,10 +70,11 @@ cron:
7170
/root/importDBdmpFile/1_runDbUpdate.sh
7271
```
7372

74-
You will also need to modify the two password files to specify
75-
your own pw ('pass_wgetrc' and 'pass_file'). These contain the
76-
pw for the secure download of dmp file and the pw of the DB
77-
system user.
73+
You will also need to:
74+
* generate a public/private key pair using `ssh-keygen` and ensure the public
75+
key is present on the host with the database dmp file.
76+
* populate `importDBdmpFile/failover_TEMPLATE.sh` with
77+
appropriate values and copy it to `/etc/gocdb/failover.sh`
7878

7979
## /root/nsupdate_goc/
8080
Contains the nsupdate keys and nsupdate scripts for switching
@@ -138,7 +138,7 @@ failover so the dns points back to the production instance
138138
and restore/restart the failover process. This includes:
139139
* <strike>restore the symlinks to the goc.dl.ac.uk server cert and key
140140
(see details below)</strike> (no longer needed as cert contains dual SAN)
141-
* restore the hourly cron to download the dmp of the DB
141+
* restore the hourly cron to fetch the dmp of the DB
142142
* run nsupdate procedure to repoint 'goc.egi.eu' back to
143143
'gocdb-base.esc.rl.ac.uk'
144144
MUST read /root/nsupdate_goc/nsupdateReadme.txt.

importDBdmpFile/failover_TEMPLATE.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file is a template for /etc/gocdb/failover.sh.
2+
# Copy this file to that location and set the variables as appropriate.
3+
4+
# Set the user@host:path to copy the DB dump file from.
5+
DB_DUMP_FROM=user@hostname:/path/to/db/dump
6+
7+
# Set the local location to copy the DB dump file to.
8+
DB_DUMP_TO=/tmp

importDBdmpFile/getDump.sh

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
#!/bin/bash
22

3-
# seems that curl don't return a 0 exit code when it fails to download successfully, see:
4-
# http://superuser.com/questions/590099/can-i-make-curl-fail-with-an-exitcode-different-than-0-if-the-http-status-code-i
5-
#
6-
#curl --capath /etc/grid-security/certificates -u failover:kugA7Rer https://goc.egi.eu/dbDump/goc5dump.dmp -o /tmp/goc5dump.dmp
3+
# Set some things that cause this script to exit on a failure,
4+
# rather than carry on blindly.
5+
# -e Exit on any error
6+
# -u Classify unset variables as errors
7+
set -eu
78

8-
# therefore use wget which does return 0 exit code if downloaded ok
9-
# /usr/bin/wget -O /tmp/goc5dump.dmp --user failover --password u_LK28_B2fv_dm --no-check-certificate https://goc.egi.eu/dbDump/goc5dump.dmp
9+
# Get useful variables to refer to later in this script.
10+
source /etc/gocdb/failover.sh
1011

11-
DUMPDIR=/tmp
12-
BASEDIR=/root/importDBdmpFile
12+
# Copy the DB dump file.
13+
/usr/bin/scp $DB_DUMP_FROM $DB_DUMP_TO
1314

14-
export WGETRC=$BASEDIR/pass_wgetrc
15-
16-
/usr/bin/wget --no-check-certificate \
17-
--ca-directory /etc/grid-security/certificates \
18-
-O $DUMPDIR/goc5dump.dmp \
19-
https://goc.egi.eu/dbDump/goc5dump.dmp
15+
# unset things to not affect the rest of the Failover process.
16+
set +eu

importDBdmpFile/pass_wgetrc_exemplar.txt

-5
This file was deleted.

0 commit comments

Comments
 (0)