chriselswede / hanacleaner

A house keeping script for SAP HANA
76 stars 44 forks source link

Suggestion: Option to control Backup Type to be considered in retention calculation #14

Open PHS123 opened 4 years ago

PHS123 commented 4 years ago

is it possible to implement a option (e.g. -bt) to control the backup type to be considdered as "full backup" in retention calculation. Something like ... -bt 0 (default) -> complete data backups and data snapshots are considdered as full backup -bt 1 -> only complere data backups are selected -bt 2 -> only snaps are selected

We are faced with the Situation that we have full VM backups with Veeam on a dayli basis. To insure Hana consistent backups the Hana is set to snapshot mode while the backup is done. But these snapshots are not valid for point in time DB revocery in a SAP supported way.

as workaround we edited the SQL in the skript to considder only complete data backups, but we want to go further with "offical hanacleaner" to be consitent for future updates and changes.

def sql_for_backup_id_for_min_retained_days(minRetainedDays): oldestDayForKeepingBackup = datetime.now() + timedelta(days = -int(minRetainedDays)) return "SELECT TOP 1 ENTRY_ID, SYS_START_TIME from sys.m_backup_catalog where ENTRY_TYPE_NAME = 'complete data backup' and STATE_NAME = 'successful' and SYS_START_TIME < '" + oldestDayForKeepingBackup.strftime('%Y-%m-%d')+" 00:00:00' order by SYS_START_TIME desc"

def sql_for_backup_id_for_min_retained_backups(minRetainedBackups): return "SELECT ENTRY_ID, SYS_START_TIME from (SELECT ENTRY_ID, SYS_START_TIME, ROW_NUMBER() OVER(ORDER BY SYS_START_TIME desc) as NUM from sys.m_backup_catalog where ENTRY_TYPE_NAME = 'complete data backup' and STATE_NAME = 'successful' order by SYS_START_TIME desc) as B where B.NUM = "+str(minRetainedBackups)

Regards Philipp