3 # Author: Joe Atzberger
12 usage: $0 db_host db_user db_name
14 Look for missing or failed DB updates in the update log.
16 ALL parameters are required to access the postgres database.
19 db_host - database host system (e.g. "localhost" or "10.121.99.6")
20 db_user - database username
21 db_name - database name
23 You will be prompted for the postgres password if necessary.
33 function usage_die() {
42 [ -z "$DB_HOST" -o -z "$DB_USER" -o -z "$DB_NAME" ] && usage_die "Need all DB parameters";
44 PSQL_ACCESS="-h $DB_HOST -U $DB_USER $DB_NAME";
50 psql -c "SELECT version FROM config.upgrade_log ORDER BY version" -t $PSQL_ACCESS | \
51 while read VERSION; do
52 [ -z $VERSION ] && break;
53 [ $VERSION ] || break;
55 # echo -n "Version: $VERSION ";
56 FILES[${#FILES[@]}]=$VERSION; # "push" onto FILES array
57 VERSION=$(echo $VERSION | sed -e 's/^ *0*//'); # This is a separate step so we can check $? above.
58 # echo $VERSION " (" ${#FILES[@]} " / " ${#MISSING[@]} ")";
59 while [[ $STEP -lt $VERSION ]] ; do
60 echo "MISSING:" $(printf "%0.4d" $STEP) "*******";
61 MISSING[${#MISSING[@]}]=$(printf "%0.4d" $STEP); # "push" onto FILES array
64 # [ $VERBOSE ] && echo RAW VERSION: $VERSION # TODO: for verbose mod
66 [ $? -gt 0 ] && die "Database access failed or was interrupted.";