private List<BackupInfo> getAffectedBackupSessions(BackupInfo backupInfo, TableName tn,
    BackupSystemTable table) throws IOException {
    LOG.debug("GetAffectedBackupInfos for: " + backupInfo.getBackupId() + " table=" + tn);
    long ts = backupInfo.getStartTs();
    List<BackupInfo> list = new ArrayList<>();
    List<BackupInfo> history = table.getBackupHistory(backupInfo.getBackupRootDir());
    // Scan from most recent to backupInfo
    // break when backupInfo reached
    for (BackupInfo info : history) {
      if (info.getStartTs() == ts) {
        break;
      }
      List<TableName> tables = info.getTableNames();
      if (tables.contains(tn)) {
        BackupType bt = info.getType();
        if (bt == BackupType.FULL) {
          // Clear list if we encounter FULL backup
          list.clear();
        } else {
          LOG.debug("GetAffectedBackupInfos for: " + backupInfo.getBackupId() + " table=" + tn
            + " added " + info.getBackupId() + " tables=" + info.getTableListAsString());
          list.add(info);
        }
      }
    }
    return list;
  }
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