diff --git src/main/docbkx/ops_mgt.xml src/main/docbkx/ops_mgt.xml index eb5c98c..b97eb8c 100644 --- src/main/docbkx/ops_mgt.xml +++ src/main/docbkx/ops_mgt.xml @@ -1702,6 +1702,40 @@ false $ ./bin/hbase shell hbase> snapshot 'myTable', 'myTableSnapshot-122112' + + Take a Snapshot From a Bash Script + To take a snapshot from a Bash script, use HBase Shell's non-interactive mode + ( or ). If the snapshot is + successful, the command will return 0. Hoswever, a non-zero value is not necessarily + indicative of failure. For instance, the snapshot may succeed but the client loses network + connection, which would look like a failure to the client. The only way to definitively + know that a snapshot succeeded is to check whether it exists. Following is a simple + (non-robust) example script to take a snapshot. + +#!/bin/bash +# Take a snapshot of the table passed as an argument + +# Parse the arguments +if [ -z $1 ]||[$1 == '-h' ]; then + echo "Usage: $0 <table>" + echo " $0 -h" + exit 1 +fi + +export HBASE_PATH=/home/user/git/hbase +export DATE=`date +"%Y%m%d"` +echo "snapshot '$1', 'snapshot-$DATE'" | $HBASE_PATH/bin/hbase shell -n +status=$? +if [$status -ne 0]; then + echo "Snapshot may have failed: $status" +fi +exit $status + + You could run such a script on a regular basis using a cron or + at job, or using another batch scheduler. + You can script other snapshot operations as well. For more information about shell + scripting with HBase, see . +