Preparing hbase release 2.4.2RC0; tagging and updates to CHANGES.md and RELEASENOTES.md
[hbase.git] / bin / master-backup.sh
blobfeca4ab865728c01f3ca9ce5fc5f081c1dfb6df3
1 #!/usr/bin/env bash
3 #/**
4 # * Licensed to the Apache Software Foundation (ASF) under one
5 # * or more contributor license agreements. See the NOTICE file
6 # * distributed with this work for additional information
7 # * regarding copyright ownership. The ASF licenses this file
8 # * to you under the Apache License, Version 2.0 (the
9 # * "License"); you may not use this file except in compliance
10 # * with the License. You may obtain a copy of the License at
11 # *
12 # * http://www.apache.org/licenses/LICENSE-2.0
13 # *
14 # * Unless required by applicable law or agreed to in writing, software
15 # * distributed under the License is distributed on an "AS IS" BASIS,
16 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # * See the License for the specific language governing permissions and
18 # * limitations under the License.
19 # */
21 # Run a shell command on all backup master hosts.
23 # Environment Variables
25 # HBASE_BACKUP_MASTERS File naming remote hosts.
26 # Default is ${HBASE_CONF_DIR}/backup-masters
27 # HADOOP_CONF_DIR Alternate conf dir. Default is ${HADOOP_HOME}/conf.
28 # HBASE_CONF_DIR Alternate hbase conf dir. Default is ${HBASE_HOME}/conf.
29 # HBASE_SLAVE_SLEEP Seconds to sleep between spawning remote commands.
30 # HBASE_SSH_OPTS Options passed to ssh when running remote commands.
32 # Modelled after $HADOOP_HOME/bin/slaves.sh.
34 usage="Usage: $0 [--config <hbase-confdir>] command..."
36 # if no args specified, show usage
37 if [ $# -le 0 ]; then
38 echo $usage
39 exit 1
42 bin=`dirname "${BASH_SOURCE-$0}"`
43 bin=`cd "$bin">/dev/null; pwd`
45 . "$bin"/hbase-config.sh
47 # If the master backup file is specified in the command line,
48 # then it takes precedence over the definition in
49 # hbase-env.sh. Save it here.
50 HOSTLIST=$HBASE_BACKUP_MASTERS
52 if [ "$HOSTLIST" = "" ]; then
53 if [ "$HBASE_BACKUP_MASTERS" = "" ]; then
54 export HOSTLIST="${HBASE_CONF_DIR}/backup-masters"
55 else
56 export HOSTLIST="${HBASE_BACKUP_MASTERS}"
61 args=${@// /\\ }
62 args=${args/master-backup/master}
64 if [ -f $HOSTLIST ]; then
65 for hmaster in `cat "$HOSTLIST"`; do
66 ssh $HBASE_SSH_OPTS $hmaster $"$args --backup" \
67 2>&1 | sed "s/^/$hmaster: /" &
68 if [ "$HBASE_SLAVE_SLEEP" != "" ]; then
69 sleep $HBASE_SLAVE_SLEEP
71 done
72 fi
74 wait