Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit c168bae1 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Traitement des erreurs sur chaque commande irods

parent b9723934
......@@ -15,7 +15,7 @@ exec 1> >(logger -s -t $(basename $0)) 2>&1
# Test for working directory
if [[ ! -w $RESIFDD_WORKDIR ]] ; then
echo "RESIFDD_WORKDIR $RESIFDD_WORKDIR not writable. Check permissions. Exit 1"
echo "RESIFDD_WORKDIR \"$RESIFDD_WORKDIR\" not writable. Check permissions. Exit 1"
exit 1
fi
# test the data directory where to dump everything from
......@@ -24,7 +24,7 @@ if [[ -z $RESIFDD_DATADIR ]]; then
exit 1
fi
if [[ ! -d $RESIFDD_DATADIR ]]; then
echo "Variable RESIFDD_DATADIR set to $RESIFDD_DATADIR must be a directory. Exit 1"
echo "Variable RESIFDD_DATADIR set to \"$RESIFDD_DATADIR\" must be a directory. Exit 1"
exit 1
fi
......@@ -33,19 +33,52 @@ MONTH=$(date +%Y-%m)
SNAPSHOT_DIR=$RESIFDD_DATADIR/validated_seismic_seismic_metadata/.snapshot/monthly.${MONTH}-01_0000
echo "Starting dump of metadata from ${SNAPSHOT_DIR}"
tar cf $RESIFDD_WORKDIR/validated_seismic_metadata.tar -C $SNAPSHOT_DIR $SNAPSHOT_DIR
if [[ $? -ne 0 ]]; then
echo "Error creating tar archive. Exit 1"
exit 1
fi
# Creating remote directory if not exist
imkdir -p validated_seismic_metadata
imv validated_seismic_metadata/previous.tar validated_seismic_metadata/previous_to_delete.tar
imv validated_seismic_metadata/latest.tar validated_seismic_metadata/previous.tar
if [[ $? -ne 0 ]]; then
echo "Error creating remote directory validated_seismic_metadata Exit 1"
exit 1
fi
# If previous.tar exist, move it around but keep it safe
ils validated_seismic_metadata/previous.tar && imv validated_seismic_metadata/previous.tar validated_seismic_metadata/previous_to_delete.tar
if [[ $? -ne 0 ]]; then
echo "Error $? moving previous.tar around Exit 1"
exit 1
fi
# If latest.tar exist, move it to previous.tar
ils validated_seismic_metadata/latest.tar && imv validated_seismic_metadata/latest.tar validated_seismic_metadata/previous.tar
if [[ $? -ne 0 ]]; then
echo "Error $? moving latest.tar to previous.tar Exit 1"
exit 1
fi
iput $RESIFDD_WORKDIR/validated_seismic_metadata.tar validated_seismic_metadata/latest.tar
if [[ $? -ne 0 ]]; then
# Something went wrong, roll back
echo "Error $? Something went wrong pushing validated metadata, Roll back"
imv validated_seismic_metadata/previous.tar validated_seismic_metadata/latest.tar
if [[ $? -ne 0 ]]; then
echo "Error $? recovering latest.tar Exit 1"
exit 1
fi
imv validated_seismic_metadata/previous_to_delete.tar validated_seismic_metadata/previous.tar
if [[ $? -ne 0 ]]; then
echo "Error $? recovering previous.tar Exit 1"
exit 1
fi
fi
# Cleaning
irm validated_seismic_metadata/previous_to_delete.tar
rm $RESIFDD_WORKDIR/validated_seismic_metadata.tar
echo "Dump of metadata done"
SNAPSHOT_DIR="${RESIFDD_DATADIR}/validated_seismic_data/.snapshot/monthly.${MONTH}-01_0000"
if [[ ! -d $SNAPSHOT_DIR ]]; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment