forked from deapplegate/wtgpipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup_reg.sh
executable file
·45 lines (31 loc) · 1.06 KB
/
backup_reg.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
#!/bin/bash
SUBARUDIR=/nfs/slac/g/ki/ki05/anja/SUBARU
curdate=`date +%y-%m-%d_%H-%M`
REPOSITORY=${SUBARUDIR}/regionbackup_${curdate}
if [ -d ${REPOSITORY} ]; then
echo "Backup Dir Exists!?"
exit 1
fi
mkdir ${REPOSITORY}
dirs=`ls -1 $SUBARUDIR`
runs=`echo "$dirs" | awk -v ORS=' ' '(/^[[:digit:]][[:digit:]][[:digit:]][[:digit:]]-/) {print}'`
for run in $runs; do
if [ -d $SUBARUDIR/$run/reg ]; then
if [ ! -d $REPOSITORY/$run ]; then
mkdir $REPOSITORY/$run
fi
cp $SUBARUDIR/$run/reg/*.reg $REPOSITORY/$run/
fi
done
clusters=`echo "$dirs" | awk -v ORS=' ' '(!/^[[:digit:]][[:digit:]][[:digit:]][[:digit:]]-/) {print}'`
for cluster in $clusters; do
filters=`ls -1 $SUBARUDIR/$cluster/`
for filter in $filters; do
if [ -d $SUBARUDIR/$cluster/$filter/SCIENCE/reg ]; then
mkdir -p $REPOSITORY/$cluster/$filter
cp $SUBARUDIR/$cluster/$filter/SCIENCE/reg/*.reg $REPOSITORY/$cluster/$filter
fi
done
done
tar -zcvf ${SUBARUDIR}/regionbackup_${curdate}.tar.gz ${REPOSITORY}
chmod 444 ${SUBARUDIR}/regionbackup_${curdate}.tar.gz