ramangrover29 | 116eb97 | 2013-02-20 20:47:35 +0000 | [diff] [blame] | 1 | WORKING_DIR=$1 |
| 2 | ASTERIX_INSTANCE_NAME=$2 |
ramangrover29@gmail.com | 5f248e1 | 2013-04-11 01:03:09 +0000 | [diff] [blame] | 3 | <<<<<<< .working |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 4 | ASTERIX_IODEVICES=$3 |
| 5 | NODE_STORE=$4 |
| 6 | ASTERIX_ROOT_METADATA_DIR=$5 |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 7 | TXN_LOG_DIR_NAME=$6 |
| 8 | BACKUP_ID=$7 |
| 9 | BACKUP_DIR=$8 |
| 10 | BACKUP_TYPE=$9 |
| 11 | NODE_ID=${10} |
ramangrover29@gmail.com | 5f248e1 | 2013-04-11 01:03:09 +0000 | [diff] [blame] | 12 | ======= |
| 13 | ASTERIX_DATA_DIR=$3 |
| 14 | BACKUP_ID=$4 |
| 15 | BACKUP_DIR=$5 |
| 16 | BACKUP_TYPE=$6 |
| 17 | NODE_ID=$7 |
| 18 | >>>>>>> .merge-right.r1677 |
ramangrover29 | 116eb97 | 2013-02-20 20:47:35 +0000 | [diff] [blame] | 19 | |
ramangrover29@gmail.com | 5f248e1 | 2013-04-11 01:03:09 +0000 | [diff] [blame] | 20 | <<<<<<< .working |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 21 | nodeIODevices=$(echo $ASTERIX_IODEVICES | tr "," "\n") |
ramangrover29@gmail.com | 5f248e1 | 2013-04-11 01:03:09 +0000 | [diff] [blame] | 22 | ======= |
| 23 | nodeStores=$(echo $ASTERIX_DATA_DIR | tr "," "\n") |
| 24 | >>>>>>> .merge-right.r1677 |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 25 | |
ramangrover29@gmail.com | 5f248e1 | 2013-04-11 01:03:09 +0000 | [diff] [blame] | 26 | <<<<<<< .working |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 27 | if [ $BACKUP_TYPE == "hdfs" ]; |
| 28 | then |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 29 | HDFS_URL=${11} |
| 30 | HADOOP_VERSION=${12} |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 31 | export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 32 | index=1 |
| 33 | for nodeIODevice in $nodeIODevices |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 34 | do |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 35 | STORE_DIR=$nodeIODevice/$NODE_STORE |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 36 | TXN_LOG_DIR=$nodeIODevice/$TXN_LOG_DIR_NAME |
| 37 | 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.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 46 | if [ $index -eq 1 ]; |
| 47 | then |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 48 | # 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.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 53 | fi |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 54 | |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 55 | index=`expr $index + 1` |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 56 | done |
| 57 | else |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 58 | index=1 |
| 59 | for nodeIODevice in $nodeIODevices |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 60 | do |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 61 | STORE_DIR=$nodeIODevice/$NODE_STORE |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 62 | TXN_LOG_DIR=$nodeIODevice/$TXN_LOG_DIR_NAME |
| 63 | NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID |
| 64 | |
| 65 | # create the backup directory, if it does not exists |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 66 | if [ ! -d $NODE_BACKUP_DIR ]; |
| 67 | then |
| 68 | mkdir -p $NODE_BACKUP_DIR |
| 69 | fi |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 70 | |
| 71 | # copy store directory |
| 72 | cp -r $STORE_DIR $NODE_BACKUP_DIR/ |
| 73 | |
| 74 | # copy asterix root metadata directory and log directory from the primary(first) iodevice |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 75 | if [ $index -eq 1 ]; |
| 76 | then |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 77 | cp -r $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $NODE_BACKUP_DIR/ |
| 78 | |
| 79 | # copy log directory |
| 80 | cp -r $TXN_LOG_DIR $NODE_BACKUP_DIR/ |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 81 | fi |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 82 | |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 83 | index=`expr $index + 1` |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 84 | done |
| 85 | fi |
ramangrover29@gmail.com | 5f248e1 | 2013-04-11 01:03:09 +0000 | [diff] [blame] | 86 | ======= |
| 87 | if [ $BACKUP_TYPE == "hdfs" ]; |
| 88 | then |
| 89 | HDFS_URL=$8 |
| 90 | HADOOP_VERSION=$9 |
| 91 | export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION |
| 92 | for nodeStore in $nodeStores |
| 93 | do |
| 94 | MANGLED_DIR_NAME=`echo $nodeStores | tr / _` |
| 95 | NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$MANGLED_DIR_NAME |
| 96 | echo "$HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/ $HDFS_URL/$NODE_BACKUP_DIR/" >> ~/backup.log |
| 97 | $HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/ $HDFS_URL/$NODE_BACKUP_DIR/ |
| 98 | done |
| 99 | else |
| 100 | for nodeStore in $nodeStores |
| 101 | do |
| 102 | MANGLED_DIR_NAME=`echo $nodeStores | tr / _` |
| 103 | NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/$MANGLED_DIR_NAME |
| 104 | if [ ! -d $NODE_BACKUP_DIR ]; |
| 105 | then |
| 106 | mkdir -p $NODE_BACKUP_DIR |
| 107 | fi |
| 108 | echo "cp -r $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/* $NODE_BACKUP_DIR/" >> ~/backup.log |
| 109 | cp -r $nodeStore/$NODE_ID/$ASTERIX_INSTANCE_NAME/* $NODE_BACKUP_DIR/ |
| 110 | done |
| 111 | fi |
| 112 | >>>>>>> .merge-right.r1677 |