Oracle DR: Fix backup retention to keep exactly 2 days instead of 3
Changed -mtime logic from +$RetentionDays to +($RetentionDays - 1) to correctly implement 2-day retention. Previously kept 3 days (today + 2 previous), now keeps exactly 2 days (today + yesterday). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -124,7 +124,9 @@ function Cleanup-OldBackupsOnDR {
|
||||
Write-Log "Backups before cleanup: $countBefore"
|
||||
|
||||
# Cleanup: șterge fișiere mai vechi de $RetentionDays zile - Linux find command
|
||||
$cleanupCmd = "find '$DRPath' -name '*.BKP' -type f -mtime +$RetentionDays -delete 2>&1"
|
||||
# -mtime +N înseamnă "mai vechi de N zile", deci pentru a păstra RetentionDays zile, folosim +($RetentionDays - 1)
|
||||
$mtimeDays = $RetentionDays - 1
|
||||
$cleanupCmd = "find '$DRPath' -name '*.BKP' -type f -mtime +$mtimeDays -delete 2>&1"
|
||||
$result = & ssh -n -p $DRPort -i $SSHKeyPath "${DRUser}@${DRHost}" $cleanupCmd 2>&1
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
|
||||
Reference in New Issue
Block a user