Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OSUG
RESIF
datadump
Commits
8820b699
Commit
8820b699
authored
Jul 05, 2019
by
Jonathan Schaeffer
Browse files
Script testable
parent
7cb557ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/datadump.sh
View file @
8820b699
#!/bin/bash
# Auteur: Jonathan Schaeffer <jonathan.schaeffer@univ-grenoble-alpes.fr>
# Tests de l'environnement
# Il faut que les variables d'environnements suivantes soient positionnées sur des valeurs valides
# - RESIFDD_DATADIR
# - RESIFDD_WORKDIR
#
# This script dumps precious RESIF data to an IRODS server
#
# Print a message using logger
# Arguments:
...
...
@@ -16,13 +14,18 @@ log(){
logger
-t
resifdd
-p
local3.
$severity
$1
}
####################
#
# Preliminary tests
#
####################
# Test for working directory
if
[[
!
-w
$RESIFDD_WORKDIR
]]
;
then
log
"RESIFDD_WORKDIR
$RESIFDD_WORKDIR
not writable. Check permissions"
exit
1
fi
# Go to the data directory where to dump everything from
# test the data directory where to dump everything from
if
[[
-z
$RESIFDD_DATADIR
]]
;
then
log
"Variable RESIFDD_DATADIR must be set to the RESIF mountpoint"
"error"
exit
1
...
...
@@ -42,26 +45,58 @@ if [[ ! -d $SNAPSHOT_DIR ]]; then
fi
# Checking IRODS environment
# TODO
if
[[
!
-r
~/.irods/irodsA
]]
;
then
log
"The irods scrambled password file is not present. Please run iinit and provide the password"
exit
1
fi
####################
#
# Start dumping validated data
#
####################
DATADIR
=
${
RESIFDD_DATADIR
}
/validated_seismic_data/
${
SNAPSHOT_DIR
}
cd
$DATADIR
for
dir
in
$(
find
.
-type
d
-maxdepth
3
)
;
do
IFS
=
'/'
read
-r
-a
YNS
<<<
$dir
[
!
${#
distro
[@]
}
-eq
3
]
&&
continue
YEAR
=
YNS[0]
NETWORK
=
YNS[1]
STATION
=
YNS[2]
logger
"Going to tar data from
$YEAR
$NETWORK
.
$STATION
"
tar
cf
$RESIFDD_WORKDIR
/
$YEAR_$NETWORK_$STATION
.tar
-C
$DATADIR
$dir
KEY
=
$YEAR_$NETWORK_$STATION
log
"Going to tar data from
$KEY
"
tar
cf
$RESIFDD_WORKDIR
/
$KEY
.tar
$dir
# Check if file exists on irods server
ils
-l
$KEY
/latest.tar
if
[[
$?
-ne
0
]]
;
then
# Check hash on irods server
# Check hash on irods server
# Compare to local hash
# If the hashes differs, then move distant file and push this one
# Compare to local hash
# If the hashes differs, then move distant file and push this one
if
[[
"
$local_hash
"
=
"
$irods_hash
"
]]
;
then
log
"[
$KEY
] The archive on irods is already there. Skipping."
continue
fi
log
"[
$KEY
] Local checksum differs from last dump. Let's dump it"
info
irm
$KEY
/previous.tar
>
/dev/null 2>&1
# Silently remove previous.tar, ignore errors
imv
$KEY
/latest.tar
$KEY
/previous.tar
# Rename latest distant dump tp "previous"
fi
# Send file to IRODS
log
"[
$KEY
] Sending file to iRODS"
imkdir
-p
$KEY
iput
\
--lfrestart
$RESIFDD_WORKDIR
/
$KEY
.lfrestart
\
-X
$RESIFDD_WORKDIR
/
$KEY
.restart
\
--retries
5
\
-T
\
# reconnects after 10 minutes \
-b
\
# bulk upload to reduce overhead \
-K
\
# verify checksums \
$RESIFDD_WORKDIR
/
$KEY
.tar
$KEY
/latest.tar
log
"[
$KEY
] iput returned
$?
"
logger
"Cleaning generated tar
$RESIFDD_WORKDIR
/
$YEAR_$NETWORK_$STATION
.tar"
log
"Cleaning generated tar
$RESIFDD_WORKDIR
/
$YEAR_$NETWORK_$STATION
.tar"
rm
$RESIFDD_WORKDIR
/
$KEY
.tar
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment