blob: 556ca394d29c43c8a10f33da6f4d2da358547207 [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
ramangrover294b345912013-04-02 10:44:26 +00006TXN_LOG_DIR_NAME=$6
7BACKUP_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 TXN_LOG_DIR=$nodeIODevice/$TXN_LOG_DIR_NAME
24 NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/
25
26 # make the destination directory
27 $HADOOP_HOME/bin/hadoop fs -mkdir $STORE_DIR $HDFS_URL/$NODE_BACKUP_DIR
28
29 # copy store directory
30 $HADOOP_HOME/bin/hadoop fs -copyFromLocal $STORE_DIR $HDFS_URL/$NODE_BACKUP_DIR/
31
32 # copy asterix root metadata directory and log directory from the primary(first) iodevice
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000033 if [ $index -eq 1 ];
34 then
ramangrover294b345912013-04-02 10:44:26 +000035 # copy asterix root metadata directory
36 $HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $HDFS_URL/$NODE_BACKUP_DIR/
37
38 # copy log directory
39 $HADOOP_HOME/bin/hadoop fs -copyFromLocal $TXN_LOG_DIR $HDFS_URL/$NODE_BACKUP_DIR/
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000040 fi
ramangrover294b345912013-04-02 10:44:26 +000041
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000042 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000043 done
44else
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000045 index=1
46 for nodeIODevice in $nodeIODevices
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000047 do
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000048 STORE_DIR=$nodeIODevice/$NODE_STORE
ramangrover294b345912013-04-02 10:44:26 +000049 TXN_LOG_DIR=$nodeIODevice/$TXN_LOG_DIR_NAME
50 NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID
51
52 # create the backup directory, if it does not exists
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000053 if [ ! -d $NODE_BACKUP_DIR ];
54 then
55 mkdir -p $NODE_BACKUP_DIR
56 fi
ramangrover294b345912013-04-02 10:44:26 +000057
58 # copy store directory
59 cp -r $STORE_DIR $NODE_BACKUP_DIR/
60
61 # copy asterix root metadata directory and log directory from the primary(first) iodevice
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000062 if [ $index -eq 1 ];
63 then
ramangrover294b345912013-04-02 10:44:26 +000064 cp -r $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $NODE_BACKUP_DIR/
65
66 # copy log directory
67 cp -r $TXN_LOG_DIR $NODE_BACKUP_DIR/
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000068 fi
ramangrover294b345912013-04-02 10:44:26 +000069
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000070 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000071 done
72fi