forked from plesager/ece3-raw-backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_bckp.sh
executable file
·101 lines (86 loc) · 2.29 KB
/
check_bckp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
usage()
{
echo "Usage:"
echo " ${0##*/} [-r] [-f NB] EXP"
echo
echo "Check the backup of EVERY legs of one run, by listing"
echo "output and restart directories that are not empty."
echo
echo "Options are:"
echo " -r : list the [R]emote target dir"
echo " -f LEG_NUMBER : specify leg number, for which the output/restart [F]iles are listed"
echo
}
set -e
runs_dir="${SCRATCH}/ECEARTH-RUNS/"
ecfs_dir="ec:/${USER}/ECEARTH-RUNS/"
# -- options
while getopts "rf:h?" opt; do
case "$opt" in
h|\?)
usage
exit 0
;;
r) remote=1
;;
f) full=$OPTARG
esac
done
shift $((OPTIND-1))
# -- Arg
if [ "$#" -ne 1 ]; then
echo; echo " NEED ONE ARGUMENT, NO MORE, NO LESS!"; echo
usage
exit 0
fi
# -- Utils
not_empty_dir () {
[[ ! -d "$1" ]] && return 1
[ -n "$(ls -A $1)" ] && return 0 || return 1
}
# -- basic check
for model in ifs nemo
do
for ff in output restart
do
if [ -d ${runs_dir}/$1/${ff}/${model} ]
then
echo ; echo "*II* checking ${model} ${ff}" ; echo
cd ${runs_dir}/$1/${ff}/${model}
#quick-but-not-rigourous: du -sh * | grep -v "^4.0K"
for ddd in *
do
if not_empty_dir $ddd
then
du -sh $ddd
(( $full )) && [[ $(printf %03d $full) == $ddd ]] && \
ls ${runs_dir}/$1/${ff}/${model}/$(printf %03d $full)
fi
done
fi
done
done
if (( remote ))
then
echo ; echo "*II* checking top dir" ; echo
els -l $ecfs_dir/$1
for model in ifs nemo
do
for ff in output restart
do
echo ; echo "*II* checking ${model} ${ff}" ; echo
#els -l $ecfs_dir/$1/${ff}/${model}
for ddd in $(els $ecfs_dir/$1/${ff}/${model})
do
if (( $full )) && [[ $(printf %03d/ $full) = $ddd ]]
then
echo $ddd
els -l $ecfs_dir/$1/${ff}/${model}/$ddd
else
echo $ddd $(els $ecfs_dir/$1/${ff}/${model}/$ddd | wc -w)
fi
done
done
done
fi