FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 2a21d599 authored by Vitor Trovisco's avatar Vitor Trovisco
Browse files

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
parent 76fb690b
No related branches found
No related tags found
1 merge request!20Update weekly_export.sh - remove time stamp from the archive export json and other changes
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment