日期:2014-05-16 浏览次数:20507 次
import time import datetime from datetime import date import sys import os tablename=sys.argv[1] backupDst=sys.argv[2] today=date.today() if today.day == 15: //every month, we do a full backup backupSubFolder=backupDst+today.isoformat()+"-full" cmd="hbase org.apache.hadoop.hbase.mapreduce.Export %s %s"%(tablename,backupSubFolder) else: yesterday=datetime.date.today()- datetime.timedelta(days=1) todayTimeStamp=time.mktime(today.timetuple()) yesTimeStamp=time.mktime(yesterday.timetuple()) backupSubFolder=backupDst+today.isoformat() cmd="hbase org.apache.hadoop.hbase.mapreduce.Export %s %s %s"%(tablename,backupSubFolder,str(int(todayTimeStamp)*1000) print cmd os.system(cmd)
hbase org.apache.hadoop.hbase.mapreduce.Import tablename restorefolder
export HADOOP_CLASSPATH="/usr/lib/hadoop-hbase/hbaseXXX.jar:/usr/lib/hadoop-hbase/lib/zookeeperXXX.jar:/etc/hadoop-hbase/conf"