FAQ | This is a LIVE service | Changelog

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

Update weekly_export1.sh

routes logfile to newly create sub-folder 'logs'
removes if loop to stop/start canto
parent 130fa832
No related branches found
No related tags found
1 merge request!6Testing
...@@ -5,12 +5,20 @@ ...@@ -5,12 +5,20 @@
# Define canto-space root # Define canto-space root
CANTOSPACE="/data/export/canto-space" CANTOSPACE="/data/export/canto-space"
# Define logs folder inside canto-space
LOGS="logs"
# Define log file # Define log file
LOGFILE="${CANTOSPACE}/canto_weekly_export.log" LOGFILE="${CANTOSPACE}/${LOGS}/canto_weekly_export.log"
# Redirect all output to logfile # Redirect all output to logfile
exec &>> "${LOGFILE}" exec &>> "${LOGFILE}"
# Create archive directory if required
EXPORT_DIR="${CANTOSPACE}/import_export"
EXPORT_FILENAME=canto_server_export_latest.json
# Function to log messages with date stamp # Function to log messages with date stamp
# e.g. log "Canto script completed successfully" generates something like 2020-05-20 10:24:37: Canto script completed successfully # e.g. log "Canto script completed successfully" generates something like 2020-05-20 10:24:37: Canto script completed successfully
...@@ -26,56 +34,47 @@ EXPORT_FILENAME=canto_server_export_latest.json ...@@ -26,56 +34,47 @@ EXPORT_FILENAME=canto_server_export_latest.json
log "Starting" log "Starting"
if /etc/init.d/canto stop; then if ./canto/script/canto_docker ./script/canto_export.pl canto-json --export-curator-names --export-approved > "${EXPORT_DIR}/${EXPORT_FILENAME}"; then
sleep 10
log "Canto stop successful" log "Approved sessions exported into ${EXPORT_DIR} successful"
if ./canto/script/canto_docker ./script/canto_export.pl canto-json --export-curator-names --export-approved > "${EXPORT_DIR}/${EXPORT_FILENAME}"; then
log "Export of approved sessions into ${EXPORT_DIR} successful"
if [[ -e "${EXPORT_DIR}/${EXPORT_FILENAME}" ]]; then if [[ -e "${EXPORT_DIR}/${EXPORT_FILENAME}" ]]; then
# Create archive directory if required # Create archive directory if required
ARCHIVE="${CANTOSPACE}/archive" ARCHIVE="${CANTOSPACE}/archive"
if [[ ! -d "${ARCHIVE}" ]]; then if [[ ! -d "${ARCHIVE}" ]]; then
log "Creating ${ARCHIVE}" log "Creating ${ARCHIVE}"
mkdir "${ARCHIVE}" mkdir "${ARCHIVE}"
fi fi
EXPORT_FILENAME_ARCHIVE="canto_server_export_$(date +"%Y-%m-%d-%T").json" EXPORT_FILENAME_ARCHIVE="canto_server_export_$(date +"%Y-%m-%d-%T").json"
# Copying canto_server_export_latest.json to archive # Copying canto_server_export_latest.json to archive
log "Copying ${EXPORT_FILENAME} to ${ARCHIVE}/${EXPORT_FILENAME_ARCHIVE}" log "Copying ${EXPORT_FILENAME} to ${ARCHIVE}/${EXPORT_FILENAME_ARCHIVE}"
cp "${EXPORT_DIR}/${EXPORT_FILENAME}" "${ARCHIVE}/${EXPORT_FILENAME_ARCHIVE}" cp "${EXPORT_DIR}/${EXPORT_FILENAME}" "${ARCHIVE}/${EXPORT_FILENAME_ARCHIVE}"
else
log "${EXPORT_DIR}/${EXPORT_FILENAME} cannot be found - cannot continue"
log "Finished"
exit
fi
else
log "Export failed."
log "Finished" log "Finished"
exit
exit
else
log "But ${EXPORT_DIR}/${EXPORT_FILENAME} cannot be found - cannot continue"
log "Finished"
exit
fi fi
/etc/init.d/canto start
log "Finished"
else else
log "Canto could not stop. Cannot continue."
log "Export failed."
log "Finished" log "Finished"
exit
fi fi
exit exit
\ No newline at end of file
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