From 2a21d5994ea5d2c9a48c275644e975308ac95d89 Mon Sep 17 00:00:00 2001 From: Vitor Trovisco <vmt25@cam.ac.uk> Date: Fri, 22 Jul 2022 13:45:05 +0000 Subject: [PATCH] Update weekly_export.sh - remove time stamp from the archive export json and other changes a) copying the original canto_server_export_latest.json export file to within export-vm's archives folder b) remove time stamp from the archive export json (keeping the date stamp) c) simplification of the script d) better commenting --- weekly_export.sh | 54 ++++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/weekly_export.sh b/weekly_export.sh index 96405b4..c94643b 100755 --- a/weekly_export.sh +++ b/weekly_export.sh @@ -11,7 +11,7 @@ LOGS="logs" # Define log file LOGFILE="${CANTOSPACE}/${LOGS}/canto_weekly_export.log" -# Redirect all output to logfile +# Redirect all Terminal/command line output to logfile exec &>> "${LOGFILE}" # Function to log messages with date stamp @@ -22,7 +22,7 @@ function log () { /bin/echo "${DATESTAMP}: ${1}" } -# Define export directory filepath +# Define initial export directory filepath EXPORT_DIR="${CANTOSPACE}/import_export" #Define export filename @@ -33,49 +33,25 @@ EXPORTVM_EXPORT_ARCHIVE="/data/export/archives/canto_export_json" log "Starting" +#Export of 'APPROVED' sessions from Canto into json file +#this step also relabels those 'APPROVED' sessions as 'EXPORTED', so that they will not be exported again next time this is executed if ./canto/script/canto_docker --non-interactive ./script/canto_export.pl canto-json --export-curator-names --export-approved > "${EXPORT_DIR}/${EXPORT_FILENAME}"; then - log "Approved sessions exported into ${EXPORT_DIR} successful" + log "Approved sessions exported into ${EXPORT_DIR} successfully" - if [[ -e "${EXPORT_DIR}/${EXPORT_FILENAME}" ]]; then - - # Create archive directory in canto-space if required - ARCHIVE="${CANTOSPACE}/archive" - - if [[ ! -d "${ARCHIVE}" ]]; then - log "Creating ${ARCHIVE}" - mkdir "${ARCHIVE}" - fi - - #Define date-time-stamped filename for archiving - EXPORT_FILENAME_ARCHIVE="canto_server_export_$(date +"%Y-%m-%d-%T").json" - - - function archiving() - { - local FILENAME=${1} - - log "Archiving ${EXPORT_FILENAME} to ${FILENAME}" - - cp "${EXPORT_DIR}/${EXPORT_FILENAME}" "${FILENAME}" - - } + #Define date-time-stamped filename for archiving + EXPORT_FILENAME_ARCHIVE="canto_server_export_$(date +"%Y-%m-%d").json" - for FILE in "${ARCHIVE}/${EXPORT_FILENAME_ARCHIVE}" "${EXPORTVM_EXPORT_ARCHIVE}/${EXPORT_FILENAME_ARCHIVE}"; do - archiving ${FILE} - done - - log "Finished" + log "Archiving ${EXPORT_FILENAME} to "${ARCHIVE}/${EXPORT_FILENAME_ARCHIVE}"" + + #Copying the export file to within flybase-vm's archives, both as the generic 'canto_server_export_latest.json' file, which will be overwritten every week, as a date-stamped version + cp "${EXPORT_DIR}/${EXPORT_FILENAME}" "${ARCHIVE}/${EXPORT_FILENAME}" + cp "${EXPORT_DIR}/${EXPORT_FILENAME}" "${ARCHIVE}/${EXPORT_FILENAME_ARCHIVE}" + + log "Finished" - exit + exit - else - - log "But ${EXPORT_DIR}/${EXPORT_FILENAME} cannot be found - cannot continue" - - log "Finished" - - exit fi else -- GitLab