scc: Session save and push from ACG-M-L5090 at 2026-03-14 08:45
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -185,6 +185,22 @@ function Import-ToDatabase {
|
|||||||
# Main Script
|
# Main Script
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
|
# -- Log rotation: cap at 10 MB, keep 5 archives --
|
||||||
|
$LOG_MAX_BYTES = 10 * 1024 * 1024
|
||||||
|
if (Test-Path $LOG_FILE) {
|
||||||
|
$logSize = (Get-Item $LOG_FILE).Length
|
||||||
|
if ($logSize -gt $LOG_MAX_BYTES) {
|
||||||
|
$archiveName = $LOG_FILE -replace '\.log$', "-$(Get-Date -Format 'yyyy-MM-dd-HHmmss').log"
|
||||||
|
Copy-Item $LOG_FILE $archiveName -Force
|
||||||
|
Clear-Content $LOG_FILE
|
||||||
|
# Keep only 5 most recent archives
|
||||||
|
$archives = Get-ChildItem (Split-Path $LOG_FILE) -Filter "sync-from-nas-*.log" | Sort-Object LastWriteTime -Descending
|
||||||
|
if ($archives.Count -gt 5) {
|
||||||
|
$archives | Select-Object -Skip 5 | Remove-Item -Force
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Write-Log "=========================================="
|
Write-Log "=========================================="
|
||||||
Write-Log "Starting sync (rsync mode)"
|
Write-Log "Starting sync (rsync mode)"
|
||||||
if ($DryRun) { Write-Log "DRY RUN - no changes will be made" }
|
if ($DryRun) { Write-Log "DRY RUN - no changes will be made" }
|
||||||
@@ -290,7 +306,7 @@ foreach ($station in $nasStations) {
|
|||||||
# Lines starting with ">f" indicate a file was received
|
# Lines starting with ">f" indicate a file was received
|
||||||
foreach ($line in $result.Output) {
|
foreach ($line in $result.Output) {
|
||||||
$lineStr = "$line".Trim()
|
$lineStr = "$line".Trim()
|
||||||
if ($lineStr -match '^>f.*\s(\S+\.DAT)$') {
|
if ($lineStr -match '(?i)^>f[\S.+]+\s+(\S+\.DAT)$') {
|
||||||
$fileName = $Matches[1]
|
$fileName = $Matches[1]
|
||||||
$localFile = Join-Path $localDir $fileName
|
$localFile = Join-Path $localDir $fileName
|
||||||
Write-Log " Pulled: $station/LOGS/$logType/$fileName"
|
Write-Log " Pulled: $station/LOGS/$logType/$fileName"
|
||||||
|
|||||||
Reference in New Issue
Block a user