refactor(cleanup): generalize cleanup beyond logs

Rename configuration variables and functions to reflect broader
functionality beyond just log files. Updates include renaming
LOG_DIRS_FOR_CLEANUP to DIRS_FOR_AUTODELETE and
clean_log_files to clean_directory_files. Adds safety warnings
to prevent deletion of critical HANA system logs.

BREAKING CHANGE: Config keys renamed from LOG_DIRS_FOR_CLEANUP to
DIRS_FOR_AUTODELETE and MAX_LOG_FILE_AGE_DAYS to MAX_FILE_AGE_DAYS
This commit is contained in:
2026-03-12 20:49:37 +01:00
parent a5553067b6
commit 8e0ba1878f
2 changed files with 37 additions and 34 deletions

View File

@@ -28,22 +28,25 @@ DIRECTORIES_TO_MONITOR=(
"/usr/sap"
)
# --- Log Directories for Auto-Cleanup ---
# --- Directories for Auto-Delete ---
# These directories will be automatically cleaned when disk space is low
# Format: "mount_point:log_directory_path"
# Format: "mount_point:directory_path"
# The script will check if a monitored directory is on the same mount point
# as a log directory and can clean the log directory to free up space
LOG_DIRS_FOR_CLEANUP=(
"/hana/log:/hana/log"
# as an auto-delete directory and can clean it to free up space
# NOTE: Do NOT include HANA system logs like /hana/log - only include
# directories with safe-to-delete files like backup logs, temp files, etc.
DIRS_FOR_AUTODELETE=(
"/hana/log:/hana/log/backups"
"/hana/data:/hana/data/temp"
"/usr/sap:/usr/sap/trans/log"
"/usr/sap:/usr/sap/hostctrl/work/log"
)
# --- Disk Cleanup Configuration ---
# --- Disk Auto-Delete Configuration ---
# Minimum free space percentage to maintain after cleanup
MIN_FREE_SPACE_AFTER_CLEANUP=5
# Maximum age of log files to delete (in days)
MAX_LOG_FILE_AGE_DAYS=7
# Maximum age of files to delete (in days)
MAX_FILE_AGE_DAYS=7
# Enable automatic cleanup when disk usage exceeds threshold
AUTO_CLEANUP_ENABLED=true