vinayakb | 5ee049d | 2013-04-06 21:21:29 +0000 | [diff] [blame^] | 1 | WORKING_DIR=$1 |
| 2 | ASTERIX_INSTANCE_NAME=$2 |
| 3 | ASTERIX_IODEVICES=$3 |
| 4 | NODE_STORE=$4 |
| 5 | ASTERIX_ROOT_METADATA_DIR=$5 |
| 6 | TXN_LOG_DIR_NAME=$6 |
| 7 | BACKUP_ID=$7 |
| 8 | BACKUP_DIR=$8 |
| 9 | BACKUP_TYPE=$9 |
| 10 | NODE_ID=${10} |
| 11 | |
| 12 | nodeIODevices=$(echo $ASTERIX_IODEVICES | tr "," "\n") |
| 13 | |
| 14 | if [ $BACKUP_TYPE == "hdfs" ]; |
| 15 | then |
| 16 | HDFS_URL=${11} |
| 17 | HADOOP_VERSION=${12} |
| 18 | export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION |
| 19 | index=1 |
| 20 | for nodeIODevice in $nodeIODevices |
| 21 | do |
| 22 | STORE_DIR=$nodeIODevice/$NODE_STORE |
| 23 | 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 |
| 33 | if [ $index -eq 1 ]; |
| 34 | then |
| 35 | # 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/ |
| 40 | fi |
| 41 | |
| 42 | index=`expr $index + 1` |
| 43 | done |
| 44 | else |
| 45 | index=1 |
| 46 | for nodeIODevice in $nodeIODevices |
| 47 | do |
| 48 | STORE_DIR=$nodeIODevice/$NODE_STORE |
| 49 | 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 |
| 53 | if [ ! -d $NODE_BACKUP_DIR ]; |
| 54 | then |
| 55 | mkdir -p $NODE_BACKUP_DIR |
| 56 | fi |
| 57 | |
| 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 |
| 62 | if [ $index -eq 1 ]; |
| 63 | then |
| 64 | cp -r $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $NODE_BACKUP_DIR/ |
| 65 | |
| 66 | # copy log directory |
| 67 | cp -r $TXN_LOG_DIR $NODE_BACKUP_DIR/ |
| 68 | fi |
| 69 | |
| 70 | index=`expr $index + 1` |
| 71 | done |
| 72 | fi |