001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.backup;
019
020import org.apache.hadoop.hbase.HConstants;
021import org.apache.hadoop.hbase.NamespaceDescriptor;
022import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
023import org.apache.yetus.audience.InterfaceAudience;
024
025/**
026 * BackupRestoreConstants holds a bunch of HBase Backup and Restore constants
027 */
028@InterfaceAudience.Private
029public interface BackupRestoreConstants {
030  /*
031   * Backup/Restore constants
032   */
033  String BACKUP_SYSTEM_TABLE_NAME_KEY = "hbase.backup.system.table.name";
034  String BACKUP_SYSTEM_TABLE_NAME_DEFAULT =
035    NamespaceDescriptor.BACKUP_NAMESPACE_NAME_STR + ":system";
036
037  String BACKUP_SYSTEM_TTL_KEY = "hbase.backup.system.ttl";
038
039  int BACKUP_SYSTEM_TTL_DEFAULT = HConstants.FOREVER;
040  String BACKUP_ENABLE_KEY = "hbase.backup.enable";
041  boolean BACKUP_ENABLE_DEFAULT = false;
042
043  String BACKUP_MAX_ATTEMPTS_KEY = "hbase.backup.attempts.max";
044  int DEFAULT_BACKUP_MAX_ATTEMPTS = 10;
045
046  String BACKUP_ATTEMPTS_PAUSE_MS_KEY = "hbase.backup.attempts.pause.ms";
047  int DEFAULT_BACKUP_ATTEMPTS_PAUSE_MS = 10000;
048
049  /*
050   * Drivers option list
051   */
052  String OPTION_OVERWRITE = "o";
053  String OPTION_OVERWRITE_DESC = "Overwrite data if any of the restore target tables exists";
054
055  String OPTION_CHECK = "c";
056  String OPTION_CHECK_DESC =
057    "Check restore sequence and dependencies only (does not execute the command)";
058
059  String OPTION_SET = "s";
060  String OPTION_SET_DESC = "Backup set name";
061  String OPTION_SET_RESTORE_DESC = "Backup set to restore, mutually exclusive with -t (table list)";
062  String OPTION_SET_BACKUP_DESC = "Backup set to backup, mutually exclusive with -t (table list)";
063  String OPTION_DEBUG = "d";
064  String OPTION_DEBUG_DESC = "Enable debug loggings";
065
066  String OPTION_TABLE = "t";
067  String OPTION_TABLE_DESC =
068    "Table name. If specified, only backup images, which contain this table will be listed.";
069
070  String OPTION_LIST = "l";
071  String OPTION_TABLE_LIST_DESC = "Table name list, comma-separated.";
072  String OPTION_BACKUP_LIST_DESC = "Backup ids list, comma-separated.";
073
074  String OPTION_BANDWIDTH = "b";
075  String OPTION_BANDWIDTH_DESC = "Bandwidth per task (MapReduce task) in MB/s";
076
077  String OPTION_WORKERS = "w";
078  String OPTION_WORKERS_DESC = "Number of parallel MapReduce tasks to execute";
079
080  String OPTION_IGNORECHECKSUM = "i";
081  String OPTION_IGNORECHECKSUM_DESC =
082    "Ignore checksum verify between source snapshot and exported snapshot."
083      + " Especially when the source and target file system types are different,"
084      + " we should use -i option to skip checksum-checks.";
085
086  String OPTION_RECORD_NUMBER = "n";
087  String OPTION_RECORD_NUMBER_DESC = "Number of records of backup history. Default: 10";
088
089  String OPTION_PATH = "p";
090  String OPTION_PATH_DESC = "Backup destination root directory path";
091
092  String OPTION_KEEP = "k";
093  String OPTION_KEEP_DESC = "Specifies maximum age of backup (in days) to keep during bulk delete";
094
095  String OPTION_TABLE_MAPPING = "m";
096  String OPTION_TABLE_MAPPING_DESC = "A comma separated list of target tables. "
097    + "If specified, each table in <tables> must have a mapping";
098  String OPTION_YARN_QUEUE_NAME = "q";
099  String OPTION_YARN_QUEUE_NAME_DESC = "Yarn queue name to run backup create command on";
100  String OPTION_YARN_QUEUE_NAME_RESTORE_DESC = "Yarn queue name to run backup restore command on";
101
102  String OPTION_ENABLE_CONTINUOUS_BACKUP = "cb";
103  String LONG_OPTION_ENABLE_CONTINUOUS_BACKUP = "continuous-backup-enabled";
104  String OPTION_ENABLE_CONTINUOUS_BACKUP_DESC =
105    "Flag indicating that the full backup is part of a continuous backup process.";
106
107  String OPTION_FORCE_DELETE = "fd";
108  String LONG_OPTION_FORCE_DELETE = "force-delete";
109  String OPTION_FORCE_DELETE_DESC =
110    "Flag to forcefully delete the backup, even if it may be required for Point-in-Time Restore";
111
112  String OPTION_TO_DATETIME = "td";
113  String LONG_OPTION_TO_DATETIME = "to-datetime";
114  String OPTION_TO_DATETIME_DESC = "Target date and time up to which data should be restored";
115
116  String OPTION_PITR_BACKUP_PATH = "bp";
117  String LONG_OPTION_PITR_BACKUP_PATH = "backup-path";
118  String OPTION_PITR_BACKUP_PATH_DESC =
119    "Specifies a custom backup location for Point-In-Time Recovery (PITR). "
120      + "If provided, this location will be used exclusively instead of deriving the path from the system table.";
121
122  String JOB_NAME_CONF_KEY = "mapreduce.job.name";
123
124  String BACKUP_CONFIG_STRING = BackupRestoreConstants.BACKUP_ENABLE_KEY + "=true\n"
125    + "hbase.master.logcleaner.plugins="
126    + "YOUR_PLUGINS,org.apache.hadoop.hbase.backup.master.BackupLogCleaner\n"
127    + "hbase.procedure.master.classes=YOUR_CLASSES,"
128    + "org.apache.hadoop.hbase.backup.master.LogRollMasterProcedureManager\n"
129    + "hbase.procedure.regionserver.classes=YOUR_CLASSES,"
130    + "org.apache.hadoop.hbase.backup.regionserver.LogRollRegionServerProcedureManager\n"
131    + CoprocessorHost.REGION_COPROCESSOR_CONF_KEY + "=YOUR_CLASSES,"
132    + BackupObserver.class.getSimpleName() + "\n" + CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY
133    + "=YOUR_CLASSES," + BackupMasterObserver.class.getSimpleName() + "\nand restart the cluster\n"
134    + "For more information please see https://hbase.apache.org/docs/backup-restore\n";
135  String ENABLE_BACKUP = "Backup is not enabled. To enable backup, " + "in hbase-site.xml, set:\n "
136    + BACKUP_CONFIG_STRING;
137
138  String VERIFY_BACKUP = "To enable backup, in hbase-site.xml, set:\n " + BACKUP_CONFIG_STRING;
139
140  /*
141   * Delimiter in table name list in restore command
142   */
143  String TABLENAME_DELIMITER_IN_COMMAND = ",";
144
145  String CONF_STAGING_ROOT = "snapshot.export.staging.root";
146
147  String BACKUPID_PREFIX = "backup_";
148
149  String CONTINUOUS_BACKUP_REPLICATION_PEER = "continuous_backup_replication_peer";
150
151  String DEFAULT_CONTINUOUS_BACKUP_REPLICATION_ENDPOINT =
152    "org.apache.hadoop.hbase.backup.replication.ContinuousBackupReplicationEndpoint";
153
154  String CONF_CONTINUOUS_BACKUP_WAL_DIR = "hbase.backup.continuous.wal.dir";
155
156  String CONF_CONTINUOUS_BACKUP_PITR_WINDOW_DAYS = "hbase.backup.continuous.pitr.window.days";
157  long DEFAULT_CONTINUOUS_BACKUP_PITR_WINDOW_DAYS = 30;
158
159  String CONTINUOUS_BACKUP_OFFSET_UPDATE_INTERVAL_MS =
160    "hbase.backup.continuous.offset.update.interval.ms";
161  String CONTINUOUS_BACKUP_OFFSET_UPDATE_SIZE_THRESHOLD =
162    "hbase.backup.continuous.offset.update.size.threshold";
163  long DEFAULT_CONTINUOUS_BACKUP_OFFSET_UPDATE_INTERVAL_MS = 5 * 60 * 1000L; // 5 minutes
164  long DEFAULT_CONTINUOUS_BACKUP_OFFSET_UPDATE_SIZE_THRESHOLD = 128 * 1024 * 1024L; // 128 MB
165
166  enum BackupCommand {
167    CREATE,
168    CANCEL,
169    DELETE,
170    DESCRIBE,
171    HISTORY,
172    STATUS,
173    CONVERT,
174    MERGE,
175    STOP,
176    SHOW,
177    HELP,
178    PROGRESS,
179    SET,
180    SET_ADD,
181    SET_REMOVE,
182    SET_DELETE,
183    SET_DESCRIBE,
184    SET_LIST,
185    REPAIR
186  }
187}