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