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 78647ff8 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Error numbers

parent 1590a76e
......@@ -14,7 +14,7 @@ exec 1> >(logger -s -t $(basename $0)) 2>&1
###################
zabbix(){
zabbix_sender -k resifdatadump.failed -s $(hostname -a) -o $1 -z monitoring.osug.fr
}
......@@ -52,6 +52,12 @@ irods_rollback(){
#
####################
# Checking IRODS environment
if [[ ! -f ~/.irods/.irodsA ]] ; then
echo "The irods scrambled password file is not present. Please run iinit and provide the password. Exit 1"
exit 1
fi
# Test for working directory
if [[ ! -w $RESIFDD_WORKDIR ]] ; then
echo "RESIFDD_WORKDIR \"$RESIFDD_WORKDIR\" not writable. Check permissions. Exit 1"
......@@ -70,60 +76,60 @@ fi
# Get the snapshot name for this month
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}"
if [[ ! -d $SNAPSHOT_DIR ]]; then
echo "Error 000 Snapshot directory $SNAPSHOT_DIR does not exist"
exit 1
fi
echo "[METADATA] Starting dump from ${SNAPSHOT_DIR}"
tar cf $RESIFDD_WORKDIR/validated_seismic_metadata.tar --exclude portalproducts -C $SNAPSHOT_DIR $SNAPSHOT_DIR
if [[ $? -ne 0 ]]; then
echo "Error creating tar archive. Exit 1"
echo "[METADATA] Error 001 while creating tar archive. Exit 1"
exit 1
fi
# Creating remote directory if not exist
imkdir -p validated_seismic_metadata
if [[ $? -ne 0 ]]; then
echo "Error creating remote directory validated_seismic_metadata Exit 1"
echo "[METADATA] Error 002 creating remote directory validated_seismic_metadata. Exit 1"
exit 1
fi
echo "If previous.tar exist, move it around but keep it safe"
echo "[METADATA] If previous.tar exists, 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"
echo "[METADATA] Error 003 moving previous.tar around Exit 1"
exit 1
fi
)
echo "If latest.tar exist, move it to previous.tar"
echo "[METADATA] 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"
echo "[METADATA] Error 004 moving latest.tar to previous.tar Exit 1"
exit 1
fi
)
echp "Push metadata archive"
echo "Push metadata archive"
iput -N1 $RESIFDD_WORKDIR/validated_seismic_metadata.tar validated_seismic_metadata/latest.tar
if [[ $? -ne 0 ]]; then
echo "Error $? Something went wrong pushing validated metadata, Roll back"
echo "[METADATA] Error 005 Something went wrong pushing validated metadata, Roll back"
irods_rollback validated_seismic_metadata
fi
# Cleaning
irm validated_seismic_metadata/previous_to_delete.tar
rm $RESIFDD_WORKDIR/validated_seismic_metadata.tar
echo "Dump of metadata done"
echo "[METADATA] Dump terminate :"
ils -l validated_seismic_metadata
SNAPSHOT_DIR="${RESIFDD_DATADIR}/validated_seismic_data/.snapshot/monthly.${MONTH}-01_0000"
SNAPSHOT_DIR="${RESIFDD_DATADIR}/validated_seismic_data/.snapshot/monthly.${MONTH}-01_0000"
if [[ ! -d $SNAPSHOT_DIR ]]; then
echo "Error: Snapshot directory $SNAPSHOT_DIR does not exist"
exit 1
fi
# Checking IRODS environment
if [[ ! -f ~/.irods/.irodsA ]] ; then
echo "The irods scrambled password file is not present. Please run iinit and provide the password. Exit 1"
echo "Error 006 Snapshot directory $SNAPSHOT_DIR does not exist"
exit 1
fi
......@@ -149,7 +155,7 @@ for dir in $(find . -maxdepth 3 -type d | sort); do
tar cf $RESIFDD_WORKDIR/$KEY.tar $dir
if [[ $? -ne 0 ]]; then
# Something went wrong creating archive. Exit
echo "[$KEY] Error creating tar"
echo "[$KEY] Error 007 creating tar"
# Send key to zabbix
zabbix $KEY
continue
......@@ -173,9 +179,10 @@ for dir in $(find . -maxdepth 3 -type d | sort); do
echo "[$KEY] Local checksum differs from last dump. Let's dump it"
# Put previous.tar aside in case we need to revover it.
ils $KEY/previous.tar && (
irm -f $KEY/previous_to_delete.tar
imv $KEY/previous.tar $KEY/previous_to_delete.tar
if [[ $? -ne 0 ]]; then
echo "[$KEY] Error putting previous.tar aside. $KEY archive will not be sent"
echo "[$KEY] Error 008 putting previous.tar aside. $KEY archive will not be sent"
zabbix $KEY
continue
fi
......@@ -183,11 +190,11 @@ for dir in $(find . -maxdepth 3 -type d | sort); do
imv $KEY/latest.tar $KEY/previous.tar # Rename latest distant dump tp "previous"
if [[ $? -ne 0 ]]; then
# Something wrong moving remote file arround
echo "[$KEY] Error, something wrong moving $KEY/previous.tar, cancel iput."
echo "[$KEY] Error 009 something wrong moving $KEY/previous.tar, cancel iput."
ils $KEY/previous_to_delete.tar && (
imv $KEY/previous_to_delete.tar $KEY/previous.tar
if [[ $? -ne 0 ]]; then
echo "[KEY] Error restoring previous.tar"
echo "[KEY] Error 010 restoring previous.tar"
fi
)
zabbix $KEY
......@@ -202,7 +209,7 @@ for dir in $(find . -maxdepth 3 -type d | sort); do
--retries 5 -T -K -f \
$RESIFDD_WORKDIR/$KEY.tar $KEY/latest.tar
if [[ $? -ne 0 ]]; then
echo "[$KEY] Error sending file to irods. The command was: iput --lfrestart $RESIFDD_WORKDIR/$KEY.lfrestart --retries 5 -T -K -f $RESIFDD_WORKDIR/$KEY.tar $KEY/latest.tar"
echo "[$KEY] Error 011 sending file to irods. The command was: iput --lfrestart $RESIFDD_WORKDIR/$KEY.lfrestart --retries 5 -T -K -f $RESIFDD_WORKDIR/$KEY.tar $KEY/latest.tar"
# Roll back
irods_rollback $KEY
# Alert to zabbix
......
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