HBase regular backup

Source: Internet
Author: User

For more information about how to use the Export and Import functions of HBase to complete backup, see my previous HBase Incremental backup.
 
Reprint the Python code that regularly backs up data using Export and Import. Complete backup is performed on the 15th day of every month, and Incremental backup is performed on a daily basis.

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" % (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" % (tablename, backupSubFolder, str (int (todayTimeStamp) * 1000)

Print cmd

OS. system (cmd)

Note that the last cmd string is constructed, and the version number is added to the corresponding location according to the HBase version.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.