Jul 2, 2026, 9:39 AM

This commit is contained in:
Paweł Domański
2026-07-02 07:39:13 +00:00
parent 9a57a3b3cc
commit 1542c34779
+10 -13
View File
@@ -102,29 +102,26 @@ foreach ($folder in $FoldersToProcess) {
$S3Destination = "$S3DestinationParent/$CurrentYear"
Write-Host "`n[$(Get-Date -Format 'HH:mm:ss')] Przetwarzanie: $folder ..." -ForegroundColor Yellow
Write-Host " Sprawdzanie istnienia docelowego folderu na S3: $S3DestinationParent/$CurrentYear/" -ForegroundColor Gray
Write-Host " Sprawdzanie i przygotowywanie docelowego folderu na S3: $S3DestinationParent/$CurrentYear/" -ForegroundColor Gray
# Walidacja obecności folderu (roku) po stronie S3 za pomocą rclone lsf (wypisuje tylko foldery)
$s3Dirs = & $RcloneExePath lsf --dirs-only "$S3DestinationParent/" 2>$null
if ($s3Dirs -notcontains "$CurrentYear/") {
$errMsg = "Brak wymaganego folderu '$CurrentYear/' w lokalizacji '$S3DestinationParent/' na S3. Pomijam transfer."
Write-Host " Błąd: $errMsg" -ForegroundColor Red
Write-AppEventLog -Type Warning -Id 1002 -Message $errMsg
$GlobalExitCode = 1
continue
}
# 1. Tworzenie folderu na S3 (rclone mkdir upewni się, że struktura istnieje)
& $RcloneExePath mkdir "$S3Destination"
Write-Host " Folder '$CurrentYear/' znaleziony. Rozpoczynam transfer danych..." -ForegroundColor Green
Write-Host " Folder gotowy. Rozpoczynam transfer danych..." -ForegroundColor Green
$LogFile = Join-Path $LogDir "rclone_backup_$($folder)_$(Get-Date -Format 'yyyyMMdd_HHmmss').log"
# 2, 3, 4. Pokazywanie progresu, wypisywanie plików i logowanie
# --progress (-P) - pokazuje interaktywny pasek postępu i prędkość
# --verbose (-v) - wypisuje nazwy przenoszonych plików
$RcloneArgs = @(
"move", $SourceDir, $S3Destination,
"--checksum",
"--retries", "5",
"--retries-sleep", "15s",
"--delete-empty-src-dirs",
"--log-file=$LogFile",
"--log-level=INFO"
"--progress",
"--verbose",
"--log-file=$LogFile"
)
# Uruchomienie rclone