private void removeTableFromBackupImage(BackupInfo info, TableName tn, BackupSystemTable sysTable)
    throws IOException {
    List<TableName> tables = info.getTableNames();
    LOG.debug(
      "Remove " + tn + " from " + info.getBackupId() + " tables=" + info.getTableListAsString());
    if (tables.contains(tn)) {
      tables.remove(tn);

      if (tables.isEmpty()) {
        LOG.debug("Delete backup info " + info.getBackupId());

        sysTable.deleteBackupInfo(info.getBackupId());
        // Idempotent operation
        BackupUtils.cleanupBackupData(info, conn.getConfiguration());
      } else {
        info.setTables(tables);
        sysTable.updateBackupInfo(info);
        // Now, clean up directory for table (idempotent)
        cleanupBackupDir(info, tn, conn.getConfiguration());
      }
    }
  }
Delete single backup and all related backups <br>
Algorithm:<br>
Backup type: FULL or INCREMENTAL <br>
Is this last backup session for table T: YES or NO <br>
For every table T from table list 'tables':<br>
if(FULL, YES) deletes only physical data (PD) <br>
if(FULL, NO), deletes PD, scans all newer backups and removes T from backupInfo,<br>
until we either reach the most recent backup for T in the system or FULL backup<br>
which includes T<br>
if(INCREMENTAL, YES) deletes only physical data (PD) if(INCREMENTAL, NO) deletes physical data
and for table T scans all backup images between last<br>
FULL backup, which is older than the backup being deleted and the next FULL backup (if exists)
<br>
or last one for a particular table T and removes T from list of backup tables.
@param backupId backup id
@param sysTable backup system table
@return total number of deleted backup images
@throws IOException if deleting the backup fails
hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/impl/BackupAdminImpl.java