From 092d41a74ad2e2ea2411cc42e70eb066ab1cfffd Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Wed, 15 Oct 2014 17:38:07 -0400 Subject: [PATCH] Adding export/ftp script for pushing periodic updates to GALILEO/EDS. --- galileo/bib_ids/.gitignore | 0 galileo/export_and_ftp.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++++ galileo/get_ids.sql | 20 +++++++++++++++++ galileo/out/.gitignore | 0 4 files changed, 74 insertions(+) create mode 100644 galileo/bib_ids/.gitignore create mode 100755 galileo/export_and_ftp.sh create mode 100644 galileo/get_ids.sql create mode 100644 galileo/out/.gitignore diff --git a/galileo/bib_ids/.gitignore b/galileo/bib_ids/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/galileo/export_and_ftp.sh b/galileo/export_and_ftp.sh new file mode 100755 index 0000000..739ca2a --- /dev/null +++ b/galileo/export_and_ftp.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +WORKDIR="$PWD" +PSQL="/usr/bin/psql" +PSQL_USER="mydbuser" +SQL_FILE="get_ids.sql" +DB_HOST="mydbhostname" +DB_NAME="mydbname" +OUTDIR="bib_ids" +OUTFILE="bib_ids_`date +%F`.out" +BIBDATE=`cat last_export_date` +EXPORT="pines_bib_update_`date +%F`.mrc" +EXPORT_DIR="out" +FTP_HOST="tld.example.com" +FTP_USER="myftpuser" +FTP_PASS="myftppath" +FTP_PATH="myftpremotedirectory" +ADMIN_EMAIL="my-sys-admins@example.com" + +CreateBibList () { +if [ -z $BIBDATE ]; then + read -p "No last export date known. Please provide the date at which you want to begin export (YYYY-MM-DD): " BIBDATE + echo "$BIBDATE" | egrep '^20[0-9][0-9]-[0-1][0-9]-[0-3][0-9]$' > /dev/null + if [ $? -ne 0 ]; then + echo "$BIBDATE is not a valid date. Please start over." + exit 1; + fi +fi + +$PSQL -U $PSQL_USER -h $DB_HOST -A -t -o $OUTDIR/$OUTFILE -v bibdate="'$BIBDATE'" -f $SQL_FILE $DB_NAME +} + + +ExportBibs () { +cat $OUTDIR/$OUTFILE | /openils/bin/marc_export --items --encoding UTF-8 > $EXPORT_DIR/$EXPORT +date +%F > last_export_date +} + +FTPBibFile () { +cd $EXPORT_DIR +pftp -n -v $FTP_HOST < :bibdate + ) or ( + -- ...and bibs for items deleted since bibdate + acp.deleted + and acp.edit_date > :bibdate + ) + ) + ) + where bre.id > 0 -- we don't want -1 + and not bre.deleted + order by id; diff --git a/galileo/out/.gitignore b/galileo/out/.gitignore new file mode 100644 index 0000000..e69de29 -- 2.11.0