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 * Describe backup image command 056 * @param backupId backup id 057 * @return backup info 058 * @throws IOException exception 059 */ 060 BackupInfo getBackupInfo(String backupId) throws IOException; 061 062 /** 063 * Delete backup image command 064 * @param backupIds array of backup ids 065 * @return total number of deleted sessions 066 * @throws IOException exception 067 */ 068 int deleteBackups(String[] backupIds) throws IOException; 069 070 /** 071 * Merge backup images command 072 * @param backupIds array of backup ids of images to be merged The resulting backup image will 073 * have the same backup id as the most recent image from a list of images to be 074 * merged 075 * @throws IOException exception 076 */ 077 void mergeBackups(String[] backupIds) throws IOException; 078 079 /** 080 * Show backup history command 081 * @param n last n backup sessions 082 * @return list of backup info objects 083 * @throws IOException exception 084 */ 085 List<BackupInfo> getHistory(int n) throws IOException; 086 087 /** 088 * Show backup history command with filters 089 * @param n last n backup sessions 090 * @param f list of filters 091 * @return list of backup info objects 092 * @throws IOException exception 093 */ 094 List<BackupInfo> getHistory(int n, BackupInfo.Filter... f) throws IOException; 095 096 /** 097 * Backup sets list command - list all backup sets. Backup set is a named group of tables. 098 * @return all registered backup sets 099 * @throws IOException exception 100 */ 101 List<BackupSet> listBackupSets() throws IOException; 102 103 /** 104 * Backup set describe command. Shows list of tables in this particular backup set. 105 * @param name set name 106 * @return backup set description or null 107 * @throws IOException exception 108 */ 109 BackupSet getBackupSet(String name) throws IOException; 110 111 /** 112 * Delete backup set command 113 * @param name backup set name 114 * @return true, if success, false - otherwise 115 * @throws IOException exception 116 */ 117 boolean deleteBackupSet(String name) throws IOException; 118 119 /** 120 * Add tables to backup set command 121 * @param name name of backup set. 122 * @param tables array of tables to be added to this set. 123 * @throws IOException exception 124 */ 125 void addToBackupSet(String name, TableName[] tables) throws IOException; 126 127 /** 128 * Remove tables from backup set 129 * @param name name of backup set. 130 * @param tables array of tables to be removed from this set. 131 * @throws IOException exception 132 */ 133 void removeFromBackupSet(String name, TableName[] tables) throws IOException; 134}