diff --git a/remote/copy.ps1 b/remote/copy.ps1 old mode 100644 new mode 100755 index 764d43f..a24fe8b --- a/remote/copy.ps1 +++ b/remote/copy.ps1 @@ -14,7 +14,22 @@ pscp.exe -l root -scp -pw $PASSWD -r 192.168.100.1:/etc/ldlda_help $PSScriptRoot pscp.exe -l root -scp -pw $PASSWD 192.168.100.1:/etc/rc.local $PSScriptRoot pscp.exe -l root -scp -pw $PASSWD -r 192.168.100.1:/etc/wakey-agent $PSScriptRoot -Remove-Item -Recurse (Join-Path $PSScriptRoot "root") +$uciDir = Join-Path $PSScriptRoot 'uci-config' +New-Item -ItemType Directory -Force -Path $uciDir | Out-Null +# This ignored backup contains credentials; do not add it to version control. +pscp.exe -l root -scp -pw $PASSWD 192.168.100.1:/etc/config/wakey (Join-Path $uciDir 'wakey') + +$rootBackup = Join-Path $PSScriptRoot 'root' +if (Test-Path -LiteralPath $rootBackup) { + # Router backups include hidden/read-only files. Fail once if deletion is + # genuinely blocked rather than merging a fresh copy into a partial backup. + try { + Remove-Item -LiteralPath $rootBackup -Recurse -Force -ErrorAction Stop + } + catch { + throw "Cannot remove previous router backup '$rootBackup': $($_.Exception.Message)" + } +} pscp.exe -l root -scp -pw $PASSWD -r 192.168.100.1:/root $PSScriptRoot