blob: fc6e3cc4a416dc4b7e675ad35d14471139aafdf6 [file] [log] [blame]
ramangrover29116eb972013-02-20 20:47:35 +00001WORKING_DIR=$1
2ASTERIX_INSTANCE_NAME=$2
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +00003ASTERIX_IODEVICES=$3
4NODE_STORE=$4
5ASTERIX_ROOT_METADATA_DIR=$5
ramangrover29fdfe15f2013-04-29 11:33:44 -07006TXN_LOG_DIR=$6
ramangrover294b345912013-04-02 10:44:26 +00007BACKUP_ID=$7
8BACKUP_DIR=$8
9BACKUP_TYPE=$9
10NODE_ID=${10}
ramangrover29116eb972013-02-20 20:47:35 +000011
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000012nodeIODevices=$(echo $ASTERIX_IODEVICES | tr "," "\n")
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000013
14if [ $BACKUP_TYPE == "hdfs" ];
15then
ramangrover294b345912013-04-02 10:44:26 +000016 HDFS_URL=${11}
17 HADOOP_VERSION=${12}
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000018 export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000019 index=1
20 for nodeIODevice in $nodeIODevices
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000021 do
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000022 STORE_DIR=$nodeIODevice/$NODE_STORE
ramangrover294b345912013-04-02 10:44:26 +000023 NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/
24
25 # make the destination directory
26 $HADOOP_HOME/bin/hadoop fs -mkdir $STORE_DIR $HDFS_URL/$NODE_BACKUP_DIR
27
28 # copy store directory
29 $HADOOP_HOME/bin/hadoop fs -copyFromLocal $STORE_DIR $HDFS_URL/$NODE_BACKUP_DIR/
30
31 # copy asterix root metadata directory and log directory from the primary(first) iodevice
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000032 if [ $index -eq 1 ];
33 then
ramangrover294b345912013-04-02 10:44:26 +000034 # copy asterix root metadata directory
35 $HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $HDFS_URL/$NODE_BACKUP_DIR/
36
37 # copy log directory
38 $HADOOP_HOME/bin/hadoop fs -copyFromLocal $TXN_LOG_DIR $HDFS_URL/$NODE_BACKUP_DIR/
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000039 fi
ramangrover294b345912013-04-02 10:44:26 +000040
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000041 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000042 done
43else
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000044 index=1
45 for nodeIODevice in $nodeIODevices
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000046 do
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000047 STORE_DIR=$nodeIODevice/$NODE_STORE
ramangrover294b345912013-04-02 10:44:26 +000048 NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID
49
50 # create the backup directory, if it does not exists
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000051 if [ ! -d $NODE_BACKUP_DIR ];
52 then
53 mkdir -p $NODE_BACKUP_DIR
54 fi
ramangrover294b345912013-04-02 10:44:26 +000055
56 # copy store directory
57 cp -r $STORE_DIR $NODE_BACKUP_DIR/
58
59 # copy asterix root metadata directory and log directory from the primary(first) iodevice
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000060 if [ $index -eq 1 ];
61 then
ramangrover294b345912013-04-02 10:44:26 +000062 cp -r $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $NODE_BACKUP_DIR/
63
64 # copy log directory
65 cp -r $TXN_LOG_DIR $NODE_BACKUP_DIR/
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000066 fi
ramangrover294b345912013-04-02 10:44:26 +000067
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000068 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000069 done
70fi