Till Westmann | ea8ab39 | 2013-06-05 15:17:08 -0700 | [diff] [blame] | 1 | #/* |
| 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 | #*/ |
ramangrover29 | 116eb97 | 2013-02-20 20:47:35 +0000 | [diff] [blame] | 15 | WORKING_DIR=$1 |
| 16 | ASTERIX_INSTANCE_NAME=$2 |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 17 | ASTERIX_IODEVICES=$3 |
| 18 | NODE_STORE=$4 |
| 19 | ASTERIX_ROOT_METADATA_DIR=$5 |
ramangrover29 | fdfe15f | 2013-04-29 11:33:44 -0700 | [diff] [blame] | 20 | TXN_LOG_DIR=$6 |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 21 | BACKUP_ID=$7 |
| 22 | BACKUP_DIR=$8 |
| 23 | BACKUP_TYPE=$9 |
| 24 | NODE_ID=${10} |
ramangrover29 | 116eb97 | 2013-02-20 20:47:35 +0000 | [diff] [blame] | 25 | |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 26 | nodeIODevices=$(echo $ASTERIX_IODEVICES | tr "," "\n") |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 27 | |
| 28 | if [ $BACKUP_TYPE == "hdfs" ]; |
| 29 | then |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 30 | HDFS_URL=${11} |
| 31 | HADOOP_VERSION=${12} |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 32 | export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 33 | index=1 |
| 34 | for nodeIODevice in $nodeIODevices |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 35 | do |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 36 | STORE_DIR=$nodeIODevice/$NODE_STORE |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 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 | 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.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 65 | if [ ! -d $NODE_BACKUP_DIR ]; |
| 66 | then |
| 67 | mkdir -p $NODE_BACKUP_DIR |
| 68 | fi |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 69 | |
| 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.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 74 | if [ $index -eq 1 ]; |
| 75 | then |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 76 | 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.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 80 | fi |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 81 | |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 82 | index=`expr $index + 1` |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 83 | done |
| 84 | fi |