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 java.io.Closeable;
021import java.io.IOException;
022import java.util.List;
023import org.apache.hadoop.hbase.TableName;
024import org.apache.hadoop.hbase.backup.util.BackupSet;
025import org.apache.yetus.audience.InterfaceAudience;
026
027/**
028 * The administrative API for HBase Backup. Construct an instance and call {@link #close()}
029 * afterwards.
030 * <p>
031 * BackupAdmin can be used to create backups, restore data from backups and for other backup-related
032 * operations.
033 * @since 2.0
034 */
035@InterfaceAudience.Private
036public interface BackupAdmin extends Closeable {
037
038  /**
039   * Backup given list of tables fully. This is a synchronous operation. It returns backup id on
040   * success or throw exception on failure.
041   * @param userRequest BackupRequest instance
042   * @return the backup Id
043   */
044
045  String backupTables(final BackupRequest userRequest) throws IOException;
046
047  /**
048   * Restore backup
049   * @param request restore request
050   * @throws IOException exception
051   */
052  void restore(RestoreRequest request) throws IOException;
053
054  /**
055   * Restore the tables to specific time
056   * @param request Point in Time restore request
057   * @throws IOException exception
058   */
059  void pointInTimeRestore(PointInTimeRestoreRequest request) throws IOException;
060
061  /**
062   * Describe backup image command
063   * @param backupId backup id
064   * @return backup info
065   * @throws IOException exception
066   */
067  BackupInfo getBackupInfo(String backupId) throws IOException;
068
069  /**
070   * Delete backup image command
071   * @param backupIds array of backup ids
072   * @return total number of deleted sessions
073   * @throws IOException exception
074   */
075  int deleteBackups(String[] backupIds) throws IOException;
076
077  /**
078   * Merge backup images command
079   * @param backupIds array of backup ids of images to be merged The resulting backup image will
080   *                  have the same backup id as the most recent image from a list of images to be
081   *                  merged
082   * @throws IOException exception
083   */
084  void mergeBackups(String[] backupIds) throws IOException;
085
086  /**
087   * Retrieve info about the most recent backups.
088   * @param n number of backup infos desired
089   * @param f optional filters, only entries passing the filters will be returned
090   * @return a list of at most n entries, ordered from newest (most recent) to oldest (least recent)
091   * @throws IOException exception
092   */
093  List<BackupInfo> getHistory(int n, BackupInfo.Filter... f) throws IOException;
094
095  /**
096   * Backup sets list command - list all backup sets. Backup set is a named group of tables.
097   * @return all registered backup sets
098   * @throws IOException exception
099   */
100  List<BackupSet> listBackupSets() throws IOException;
101
102  /**
103   * Backup set describe command. Shows list of tables in this particular backup set.
104   * @param name set name
105   * @return backup set description or null
106   * @throws IOException exception
107   */
108  BackupSet getBackupSet(String name) throws IOException;
109
110  /**
111   * Delete backup set command
112   * @param name backup set name
113   * @return true, if success, false - otherwise
114   * @throws IOException exception
115   */
116  boolean deleteBackupSet(String name) throws IOException;
117
118  /**
119   * Add tables to backup set command
120   * @param name   name of backup set.
121   * @param tables array of tables to be added to this set.
122   * @throws IOException exception
123   */
124  void addToBackupSet(String name, TableName[] tables) throws IOException;
125
126  /**
127   * Remove tables from backup set
128   * @param name   name of backup set.
129   * @param tables array of tables to be removed from this set.
130   * @throws IOException exception
131   */
132  void removeFromBackupSet(String name, TableName[] tables) throws IOException;
133}