copiere backup

This commit is contained in:
Marius
2025-10-31 01:05:31 +02:00
parent 13a7cd6d96
commit 63bcdf5c7f

View File

@@ -44,10 +44,8 @@ function Test-SSHConnection {
} }
function Get-TodaysBackups { function Get-TodaysBackups {
Write-Log "Searching for today's backup files..." Write-Log "Searching for backup files..."
$today = Get-Date
$cutoffDate = $today.Date # Only today (after midnight)
$backupFiles = @() $backupFiles = @()
$searchPaths = @( $searchPaths = @(
@@ -57,10 +55,9 @@ function Get-TodaysBackups {
foreach ($path in $searchPaths) { foreach ($path in $searchPaths) {
if (Test-Path $path) { if (Test-Path $path) {
# Get files created TODAY only (exclude old backups) # Get ALL backup files (duplicates will be skipped during transfer)
$files = Get-ChildItem -Path $path -Recurse -File -ErrorAction SilentlyContinue | $files = Get-ChildItem -Path $path -Recurse -File -ErrorAction SilentlyContinue |
Where-Object { Where-Object {
$_.LastWriteTime -gt $cutoffDate -and
$_.Name -notlike "*__TAG_*" # Exclude old uncompressed backups $_.Name -notlike "*__TAG_*" # Exclude old uncompressed backups
} | } |
Sort-Object LastWriteTime -Descending Sort-Object LastWriteTime -Descending
@@ -70,7 +67,7 @@ function Get-TodaysBackups {
} }
if ($backupFiles.Count -eq 0) { if ($backupFiles.Count -eq 0) {
Write-Log "No backup files found for today!" "WARNING" Write-Log "No backup files found!" "WARNING"
return @() return @()
} }