Oracle DR: Fix backup retention and monitoring for new naming convention
Problem: Backups accumulated on DR (73 files, 4 days) instead of keeping only 2 days - transfer_incremental.ps1 had no cleanup function (ran 2x/day without cleanup) - transfer_to_dr.ps1 cleanup had poor logging - oracle-backup-monitor-proxmox.sh couldn't detect new L0/L1 backup format Changes: - Add cleanup to transfer_incremental.ps1 (delete backups older than 2 days) - Improve cleanup logging in transfer_to_dr.ps1 (shows count before/after) - Update oracle-backup-monitor-proxmox.sh to detect both naming conventions: * Old: *FULL*.BKP, *INCR*.BKP * New: L0_*.BKP (Level 0), L1_*.BKP (Level 1) - Remove temporary files from /input/ directory Result: Monitor now correctly reports backup age, cleanup runs after each transfer 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -294,7 +294,9 @@ check_backups() {
|
||||
[ -z "$total_size" ] && total_size="0G"
|
||||
total_size_label="$total_size"
|
||||
|
||||
local latest_full=$(find "$BACKUP_PATH" -maxdepth 1 -type f -name '*FULL*.BKP' -printf '%T@ %p\n' | sort -nr | head -1 | cut -d' ' -f2-)
|
||||
# Search for FULL backups (both old and new naming conventions)
|
||||
# Old format: *FULL*.BKP, New format: L0_*.BKP
|
||||
local latest_full=$(find "$BACKUP_PATH" -maxdepth 1 -type f \( -name '*FULL*.BKP' -o -name 'L0_*.BKP' \) -printf '%T@ %p\n' | sort -nr | head -1 | cut -d' ' -f2-)
|
||||
if [ -n "$latest_full" ]; then
|
||||
local full_timestamp=$(stat -c %Y "$latest_full")
|
||||
local current_timestamp=$(date +%s)
|
||||
@@ -310,7 +312,10 @@ check_backups() {
|
||||
errors+=("No FULL backup found")
|
||||
fi
|
||||
|
||||
local latest_cumulative=$(find "$BACKUP_PATH" -maxdepth 1 -type f \( -name '*INCR*.BKP' -o -name '*INCREMENTAL*.BKP' -o -name '*CUMULATIVE*.BKP' \) -printf '%T@ %p\n' | sort -nr | head -1 | cut -d' ' -f2-)
|
||||
# Search for INCREMENTAL backups (both old and new naming conventions)
|
||||
# Old format: *INCR*.BKP, *INCREMENTAL*.BKP, *CUMULATIVE*.BKP
|
||||
# New format: L1_*.BKP
|
||||
local latest_cumulative=$(find "$BACKUP_PATH" -maxdepth 1 -type f \( -name '*INCR*.BKP' -o -name '*INCREMENTAL*.BKP' -o -name '*CUMULATIVE*.BKP' -o -name 'L1_*.BKP' \) -printf '%T@ %p\n' | sort -nr | head -1 | cut -d' ' -f2-)
|
||||
if [ -n "$latest_cumulative" ]; then
|
||||
local cumulative_timestamp=$(stat -c %Y "$latest_cumulative")
|
||||
local current_timestamp=$(date +%s)
|
||||
@@ -323,10 +328,10 @@ check_backups() {
|
||||
fi
|
||||
fi
|
||||
|
||||
# Collect ALL FULL backups
|
||||
# Collect ALL FULL backups (both old and new naming conventions)
|
||||
local -a full_backups=()
|
||||
local -a full_backup_entries=()
|
||||
if readarray -t full_backups < <(find "$BACKUP_PATH" -maxdepth 1 -type f -name '*FULL*.BKP' -printf '%T@ %p\n' | sort -nr | cut -d' ' -f2-); then
|
||||
if readarray -t full_backups < <(find "$BACKUP_PATH" -maxdepth 1 -type f \( -name '*FULL*.BKP' -o -name 'L0_*.BKP' \) -printf '%T@ %p\n' | sort -nr | cut -d' ' -f2-); then
|
||||
for backup_file in "${full_backups[@]}"; do
|
||||
[ -z "$backup_file" ] && continue
|
||||
local backup_name=$(basename "$backup_file")
|
||||
@@ -337,10 +342,10 @@ check_backups() {
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect ALL INCREMENTAL backups
|
||||
# Collect ALL INCREMENTAL backups (both old and new naming conventions)
|
||||
local -a incr_backups=()
|
||||
local -a incr_backup_entries=()
|
||||
if readarray -t incr_backups < <(find "$BACKUP_PATH" -maxdepth 1 -type f \( -name '*INCR*.BKP' -o -name '*INCREMENTAL*.BKP' -o -name '*CUMULATIVE*.BKP' \) -printf '%T@ %p\n' | sort -nr | cut -d' ' -f2-); then
|
||||
if readarray -t incr_backups < <(find "$BACKUP_PATH" -maxdepth 1 -type f \( -name '*INCR*.BKP' -o -name '*INCREMENTAL*.BKP' -o -name '*CUMULATIVE*.BKP' -o -name 'L1_*.BKP' \) -printf '%T@ %p\n' | sort -nr | cut -d' ' -f2-); then
|
||||
for backup_file in "${incr_backups[@]}"; do
|
||||
[ -z "$backup_file" ] && continue
|
||||
local backup_name=$(basename "$backup_file")
|
||||
|
||||
Reference in New Issue
Block a user