blob: 350e79530a48e42920e620dd42014139ff719ab3 [file] [log] [blame]
Ian Maxond8071ee2015-06-24 17:39:05 -07001#!/usr/bin/env bash
Till Westmannea8ab392013-06-05 15:17:08 -07002#/*
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 Maxond8071ee2015-06-24 17:39:05 -070016
17
ramangrover29116eb972013-02-20 20:47:35 +000018WORKING_DIR=$1
19ASTERIX_INSTANCE_NAME=$2
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000020ASTERIX_IODEVICES=$3
21NODE_STORE=$4
22ASTERIX_ROOT_METADATA_DIR=$5
ramangrover29fdfe15f2013-04-29 11:33:44 -070023TXN_LOG_DIR=$6
ramangrover294b345912013-04-02 10:44:26 +000024BACKUP_ID=$7
25BACKUP_DIR=$8
26BACKUP_TYPE=$9
27NODE_ID=${10}
ramangrover29116eb972013-02-20 20:47:35 +000028
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000029nodeIODevices=$(echo $ASTERIX_IODEVICES | tr "," "\n")
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000030
31if [ $BACKUP_TYPE == "hdfs" ];
32then
ramangrover294b345912013-04-02 10:44:26 +000033 HDFS_URL=${11}
34 HADOOP_VERSION=${12}
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000035 export HADOOP_HOME=$WORKING_DIR/hadoop-$HADOOP_VERSION
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000036 index=1
37 for nodeIODevice in $nodeIODevices
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000038 do
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000039 STORE_DIR=$nodeIODevice/$NODE_STORE
ramangrover294b345912013-04-02 10:44:26 +000040 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.com7575caf2013-04-01 09:33:45 +000049 if [ $index -eq 1 ];
50 then
ramangrover294b345912013-04-02 10:44:26 +000051 # 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.com7575caf2013-04-01 09:33:45 +000056 fi
ramangrover294b345912013-04-02 10:44:26 +000057
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000058 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000059 done
60else
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000061 index=1
62 for nodeIODevice in $nodeIODevices
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000063 do
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000064 STORE_DIR=$nodeIODevice/$NODE_STORE
ramangrover294b345912013-04-02 10:44:26 +000065 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.com73bf75e2013-03-11 01:41:42 +000068 if [ ! -d $NODE_BACKUP_DIR ];
69 then
70 mkdir -p $NODE_BACKUP_DIR
71 fi
ramangrover294b345912013-04-02 10:44:26 +000072
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.com7575caf2013-04-01 09:33:45 +000077 if [ $index -eq 1 ];
78 then
ramangrover294b345912013-04-02 10:44:26 +000079 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.com7575caf2013-04-01 09:33:45 +000083 fi
ramangrover294b345912013-04-02 10:44:26 +000084
ramangrover29@gmail.com7575caf2013-04-01 09:33:45 +000085 index=`expr $index + 1`
ramangrover29@gmail.com73bf75e2013-03-11 01:41:42 +000086 done
87fi