Skip to content

Instantly share code, notes, and snippets.

@mr-stringer
Last active September 29, 2022 21:17
Show Gist options
  • Select an option

  • Save mr-stringer/385b659b752b30cd8183906df0995cc6 to your computer and use it in GitHub Desktop.

Select an option

Save mr-stringer/385b659b752b30cd8183906df0995cc6 to your computer and use it in GitHub Desktop.
Get the size of the last full backup and the size of log backups for the last 24hours on SAP HANA. The queries do not currently calculate the size of the backup catalogue files.
SELECT
C.BACKUP_ID AS BACKUP_ID,
SUM(ROUND(TO_DOUBLE(F.BACKUP_SIZE)/1024/1024/1024, 2)) AS LAST_FULL_BACKUP_GiB
FROM
M_BACKUP_CATALOG_FILES AS F
JOIN
M_BACKUP_CATALOG AS C ON C.BACKUP_ID = F.BACKUP_ID
WHERE
C.ENTRY_TYPE_NAME = 'complete data backup'
AND
C.BACKUP_ID = (SELECT BACKUP_ID FROM M_BACKUP_CATALOG WHERE ENTRY_TYPE_NAME = 'complete data backup' ORDER BY UTC_START_TIME DESC LIMIT 1)
GROUP BY
C.BACKUP_ID;
SELECT
SUM(ROUND(TO_DOUBLE(F.BACKUP_SIZE)/1024/1024/1024, 2)) AS LAST_24H_LOG_BACKUPS_GiB
FROM
M_BACKUP_CATALOG_FILES AS F
JOIN
M_BACKUP_CATALOG AS C ON C.BACKUP_ID = F.BACKUP_ID
WHERE
C.ENTRY_TYPE_NAME = 'log backup'
AND
C.UTC_START_TIME > (ADD_DAYS(NOW(),-1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment