blob: ec28b598033fae6bdcfb403fe0de17c409f17384 [file] [log] [blame]
Till Westmannea8ab392013-06-05 15:17:08 -07001#/*
2# Copyright 2009-2013 by The Regents of the University of California
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# you may obtain a copy of the License from
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#*/
ramangrover29116eb972013-02-20 20:47:35 +000015WORKING_DIR=$1
16ASTERIX_INSTANCE_NAME=$2
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000017ASTERIX_IODEVICES=$3
18NODE_STORE=$4
19ASTERIX_ROOT_METADATA_DIR=$5
ramangrover29fdfe15f2013-04-29 11:33:44 -070020TXN_LOG_DIR=$6
ramangrover294b345912013-04-02 10:44:26 +000021BACKUP_ID=$7
22BACKUP_DIR=$8
23BACKUP_TYPE=$9
24NODE_ID=${10}
ramangrover29116eb972013-02-20 20:47:35 +000025
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000026nodeIODevices=$(echo $ASTERIX_IODEVICES | tr "," "\n")
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000027
28if [ $BACKUP_TYPE == "hdfs" ];
29then
ramangrover294b345912013-04-02 10:44:26 +000030 HDFS_URL=${11}
31 HADOOP_VERSION=${12}
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000032 export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000033 index=1
34 for nodeIODevice in $nodeIODevices
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000035 do
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000036 STORE_DIR=$nodeIODevice/$NODE_STORE
ramangrover294b345912013-04-02 10:44:26 +000037 NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/
38
39 # make the destination directory
40 $HADOOP_HOME/bin/hadoop fs -mkdir $STORE_DIR $HDFS_URL/$NODE_BACKUP_DIR
41
42 # copy store directory
43 $HADOOP_HOME/bin/hadoop fs -copyFromLocal $STORE_DIR $HDFS_URL/$NODE_BACKUP_DIR/
44
45 # copy asterix root metadata directory and log directory from the primary(first) iodevice
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000046 if [ $index -eq 1 ];
47 then
ramangrover294b345912013-04-02 10:44:26 +000048 # copy asterix root metadata directory
49 $HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $HDFS_URL/$NODE_BACKUP_DIR/
50
51 # copy log directory
52 $HADOOP_HOME/bin/hadoop fs -copyFromLocal $TXN_LOG_DIR $HDFS_URL/$NODE_BACKUP_DIR/
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000053 fi
ramangrover294b345912013-04-02 10:44:26 +000054
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000055 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000056 done
57else
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000058 index=1
59 for nodeIODevice in $nodeIODevices
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000060 do
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000061 STORE_DIR=$nodeIODevice/$NODE_STORE
ramangrover294b345912013-04-02 10:44:26 +000062 NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID
63
64 # create the backup directory, if it does not exists
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000065 if [ ! -d $NODE_BACKUP_DIR ];
66 then
67 mkdir -p $NODE_BACKUP_DIR
68 fi
ramangrover294b345912013-04-02 10:44:26 +000069
70 # copy store directory
71 cp -r $STORE_DIR $NODE_BACKUP_DIR/
72
73 # copy asterix root metadata directory and log directory from the primary(first) iodevice
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000074 if [ $index -eq 1 ];
75 then
ramangrover294b345912013-04-02 10:44:26 +000076 cp -r $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $NODE_BACKUP_DIR/
77
78 # copy log directory
79 cp -r $TXN_LOG_DIR $NODE_BACKUP_DIR/
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000080 fi
ramangrover294b345912013-04-02 10:44:26 +000081
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000082 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000083 done
84fi