@Test
  public void testBackupMultipleDeletes() throws Exception {
    // #1 - create full backup for all tables
    LOG.info("create full backup image for all tables");
    List<TableName> tables = Lists.newArrayList(table1, table2);
    Connection conn = ConnectionFactory.createConnection(conf1);
    Admin admin = conn.getAdmin();
    BackupAdmin client = new BackupAdminImpl(conn);
    BackupRequest request = createBackupRequest(BackupType.FULL, tables, BACKUP_ROOT_DIR);
    String backupIdFull = client.backupTables(request);
    assertTrue(checkSucceeded(backupIdFull));
    // #2 - insert some data to table table1
    Table t1 = conn.getTable(table1);
    Put p1;
    for (int i = 0; i < NB_ROWS_IN_BATCH; i++) {
      p1 = new Put(Bytes.toBytes("row-t1" + i));
      p1.addColumn(famName, qualName, Bytes.toBytes("val" + i));
      t1.put(p1);
    }
    Assert.assertEquals(TEST_UTIL.countRows(t1), NB_ROWS_IN_BATCH * 2);
    t1.close();
    // #3 - incremental backup for table1
    tables = Lists.newArrayList(table1);
    request = createBackupRequest(BackupType.INCREMENTAL, tables, BACKUP_ROOT_DIR);
    String backupIdInc1 = client.backupTables(request);
    assertTrue(checkSucceeded(backupIdInc1));
    // #4 - insert some data to table table2
    Table t2 = conn.getTable(table2);
    Put p2 = null;
    for (int i = 0; i < NB_ROWS_IN_BATCH; i++) {
      p2 = new Put(Bytes.toBytes("row-t2" + i));
      p2.addColumn(famName, qualName, Bytes.toBytes("val" + i));
      t2.put(p2);
    }
    // #5 - incremental backup for table1, table2
    tables = Lists.newArrayList(table1, table2);
    request = createBackupRequest(BackupType.INCREMENTAL, tables, BACKUP_ROOT_DIR);
    String backupIdInc2 = client.backupTables(request);
    assertTrue(checkSucceeded(backupIdInc2));
    // #6 - insert some data to table table1
    t1 = conn.getTable(table1);
    for (int i = NB_ROWS_IN_BATCH; i < 2 * NB_ROWS_IN_BATCH; i++) {
      p1 = new Put(Bytes.toBytes("row-t1" + i));
      p1.addColumn(famName, qualName, Bytes.toBytes("val" + i));
      t1.put(p1);
    }
    // #7 - incremental backup for table1
    tables = Lists.newArrayList(table1);
    request = createBackupRequest(BackupType.INCREMENTAL, tables, BACKUP_ROOT_DIR);
    String backupIdInc3 = client.backupTables(request);
    assertTrue(checkSucceeded(backupIdInc3));
    // #8 - insert some data to table table2
    t2 = conn.getTable(table2);
    for (int i = NB_ROWS_IN_BATCH; i < 2 * NB_ROWS_IN_BATCH; i++) {
      p2 = new Put(Bytes.toBytes("row-t1" + i));
      p2.addColumn(famName, qualName, Bytes.toBytes("val" + i));
      t2.put(p2);
    }
    // #9 - incremental backup for table1, table2
    tables = Lists.newArrayList(table1, table2);
    request = createBackupRequest(BackupType.INCREMENTAL, tables, BACKUP_ROOT_DIR);
    String backupIdInc4 = client.backupTables(request);
    assertTrue(checkSucceeded(backupIdInc4));
    // #10 full backup for table3
    tables = Lists.newArrayList(table3);
    request = createBackupRequest(BackupType.FULL, tables, BACKUP_ROOT_DIR);
    String backupIdFull2 = client.backupTables(request);
    assertTrue(checkSucceeded(backupIdFull2));
    // #11 - incremental backup for table3
    tables = Lists.newArrayList(table3);
    request = createBackupRequest(BackupType.INCREMENTAL, tables, BACKUP_ROOT_DIR);
    String backupIdInc5 = client.backupTables(request);
    assertTrue(checkSucceeded(backupIdInc5));
    LOG.error("Delete backupIdInc2");
    client.deleteBackups(new String[] { backupIdInc2 });
    LOG.error("Delete backupIdInc2 done");
    List<BackupInfo> list = client.getHistory(100);
    // First check number of backup images before and after
    assertEquals(4, list.size());
    // then verify that no backupIdInc2,3,4
    Set<String> ids = new HashSet<String>();
    ids.add(backupIdInc2);
    ids.add(backupIdInc3);
    ids.add(backupIdInc4);
    for (BackupInfo info : list) {
      String backupId = info.getBackupId();
      if (ids.contains(backupId)) {
        assertTrue(false);
      }
    }
    // Verify that backupInc5 contains only table3
    boolean found = false;
    for (BackupInfo info : list) {
      String backupId = info.getBackupId();
      if (backupId.equals(backupIdInc5)) {
        assertTrue(info.getTables().size() == 1);
        assertEquals(table3, info.getTableNames().get(0));
        found = true;
      }
    }
    assertTrue(found);
    admin.close();
    conn.close();
  }
Create multiple backups for two tables: table1, table2 then perform 1 delete
hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupMultipleDeletes.java