Ian Maxon | d8071ee | 2015-06-24 17:39:05 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Till Westmann | ea8ab39 | 2013-06-05 15:17:08 -0700 | [diff] [blame] | 2 | #/* |
| 3 | # Copyright 2009-2013 by The Regents of the University of California |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # you may obtain a copy of the License from |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | #*/ |
Ian Maxon | d8071ee | 2015-06-24 17:39:05 -0700 | [diff] [blame] | 16 | |
| 17 | |
ramangrover29 | 116eb97 | 2013-02-20 20:47:35 +0000 | [diff] [blame] | 18 | WORKING_DIR=$1 |
| 19 | ASTERIX_INSTANCE_NAME=$2 |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 20 | ASTERIX_IODEVICES=$3 |
| 21 | NODE_STORE=$4 |
| 22 | ASTERIX_ROOT_METADATA_DIR=$5 |
ramangrover29 | fdfe15f | 2013-04-29 11:33:44 -0700 | [diff] [blame] | 23 | TXN_LOG_DIR=$6 |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 24 | BACKUP_ID=$7 |
| 25 | BACKUP_DIR=$8 |
| 26 | BACKUP_TYPE=$9 |
| 27 | NODE_ID=${10} |
ramangrover29 | 116eb97 | 2013-02-20 20:47:35 +0000 | [diff] [blame] | 28 | |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 29 | nodeIODevices=$(echo $ASTERIX_IODEVICES | tr "," "\n") |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 30 | |
| 31 | if [ $BACKUP_TYPE == "hdfs" ]; |
| 32 | then |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 33 | HDFS_URL=${11} |
| 34 | HADOOP_VERSION=${12} |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 35 | export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 36 | index=1 |
| 37 | for nodeIODevice in $nodeIODevices |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 38 | do |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 39 | STORE_DIR=$nodeIODevice/$NODE_STORE |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 40 | NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/ |
| 41 | |
| 42 | # make the destination directory |
| 43 | $HADOOP_HOME/bin/hadoop fs -mkdir $STORE_DIR $HDFS_URL/$NODE_BACKUP_DIR |
| 44 | |
| 45 | # copy store directory |
| 46 | $HADOOP_HOME/bin/hadoop fs -copyFromLocal $STORE_DIR $HDFS_URL/$NODE_BACKUP_DIR/ |
| 47 | |
| 48 | # 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] | 49 | if [ $index -eq 1 ]; |
| 50 | then |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 51 | # copy asterix root metadata directory |
| 52 | $HADOOP_HOME/bin/hadoop fs -copyFromLocal $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $HDFS_URL/$NODE_BACKUP_DIR/ |
| 53 | |
| 54 | # copy log directory |
| 55 | $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] | 56 | fi |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 57 | |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 58 | index=`expr $index + 1` |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 59 | done |
| 60 | else |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 61 | index=1 |
| 62 | for nodeIODevice in $nodeIODevices |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 63 | do |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 64 | STORE_DIR=$nodeIODevice/$NODE_STORE |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 65 | NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID |
| 66 | |
| 67 | # create the backup directory, if it does not exists |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 68 | if [ ! -d $NODE_BACKUP_DIR ]; |
| 69 | then |
| 70 | mkdir -p $NODE_BACKUP_DIR |
| 71 | fi |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 72 | |
| 73 | # copy store directory |
| 74 | cp -r $STORE_DIR $NODE_BACKUP_DIR/ |
| 75 | |
| 76 | # 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] | 77 | if [ $index -eq 1 ]; |
| 78 | then |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 79 | cp -r $nodeIODevice/$ASTERIX_ROOT_METADATA_DIR $NODE_BACKUP_DIR/ |
| 80 | |
| 81 | # copy log directory |
| 82 | cp -r $TXN_LOG_DIR $NODE_BACKUP_DIR/ |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 83 | fi |
ramangrover29 | 4b34591 | 2013-04-02 10:44:26 +0000 | [diff] [blame] | 84 | |
ramangrover29@gmail.com | 7575caf | 2013-04-01 09:33:45 +0000 | [diff] [blame] | 85 | index=`expr $index + 1` |
ramangrover29@gmail.com | 73bf75e | 2013-03-11 01:41:42 +0000 | [diff] [blame] | 86 | done |
| 87 | fi |