blob: fff6c6c25c4fd9a8eefc03ccd43541fb03476a16 [file] [log] [blame]
Ian Maxond8071ee2015-06-24 17:39:05 -07001#!/usr/bin/env bash
Till Westmannea8ab392013-06-05 15:17:08 -07002#/*
Ian Maxon928bbd12015-09-14 17:12:48 -07003# 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 Maxond8071ee2015-06-24 17:39:05 -070019
20
ramangrover29116eb972013-02-20 20:47:35 +000021WORKING_DIR=$1
22ASTERIX_INSTANCE_NAME=$2
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000023ASTERIX_IODEVICES=$3
24NODE_STORE=$4
25ASTERIX_ROOT_METADATA_DIR=$5
ramangrover29fdfe15f2013-04-29 11:33:44 -070026TXN_LOG_DIR=$6
ramangrover294b345912013-04-02 10:44:26 +000027BACKUP_ID=$7
28BACKUP_DIR=$8
29BACKUP_TYPE=$9
30NODE_ID=${10}
ramangrover29116eb972013-02-20 20:47:35 +000031
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000032nodeIODevices=$(echo $ASTERIX_IODEVICES | tr "," "\n")
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000033
34if [ $BACKUP_TYPE == "hdfs" ];
35then
ramangrover294b345912013-04-02 10:44:26 +000036 HDFS_URL=${11}
37 HADOOP_VERSION=${12}
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000038 export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000039 index=1
40 for nodeIODevice in $nodeIODevices
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000041 do
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000042 STORE_DIR=$nodeIODevice/$NODE_STORE
ramangrover294b345912013-04-02 10:44:26 +000043 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.com7575caf2013-04-01 09:33:45 +000052 if [ $index -eq 1 ];
53 then
ramangrover294b345912013-04-02 10:44:26 +000054 # 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.com7575caf2013-04-01 09:33:45 +000059 fi
ramangrover294b345912013-04-02 10:44:26 +000060
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000061 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000062 done
63else
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000064 index=1
65 for nodeIODevice in $nodeIODevices
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000066 do
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000067 STORE_DIR=$nodeIODevice/$NODE_STORE
ramangrover294b345912013-04-02 10:44:26 +000068 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.com73bf75e2013-03-11 01:41:42 +000071 if [ ! -d $NODE_BACKUP_DIR ];
72 then
73 mkdir -p $NODE_BACKUP_DIR
74 fi
ramangrover294b345912013-04-02 10:44:26 +000075
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.com7575caf2013-04-01 09:33:45 +000080 if [ $index -eq 1 ];
81 then
ramangrover294b345912013-04-02 10:44:26 +000082 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.com7575caf2013-04-01 09:33:45 +000086 fi
ramangrover294b345912013-04-02 10:44:26 +000087
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000088 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000089 done
90fi