Well, this is also strange. I let the PowerShell script continue to run. Almost 9.5 hours later, the WinSCP session log resumes logging activity with the
tar
command that is next in my script, but it errors out before proceeding to download the compressed file. The relevant code from my script is below.
$session.MoveFile("$remoteFileDirectory/*","$archiveFolder/")
$archiveFileName = "archive_$fileDate.tar.gz"
$archiveCommand = 'cd "' + $archiveFolder + '/" ; tar -czvf "' + $archiveFileName + '" "' + $archiveFolder + '/"'
log "Archive Command: $archiveCommand"
$result = $session.ExecuteCommand($archiveCommand)
$result.Check()
log $result.ErrorOutput
log $result.Output
$transferResult = $session.GetFiles("$archiveFolder/$archiveFileName", "$stagingDirectoryFull\", $false, $transferOptions)
$transferResultJson = ConvertTo-Json $transferResult
Expand-Tar "$stagingDirectoryFull\$archiveFileName" $stagingDirectoryFull -targzExtract
log "Download Complete. Archiving Downloaded Files..."
Below is the section of the WinSCP Session log where the log pauses at 14:07:56.358 and then resumes at 23:32:19:187 on line 134105 by connecting to the FTP server again.
. 2020-10-30 14:07:56.286 Moving file "/home/<redacted>-prod/outbound/<file name redacted>.json" to "/home/<redacted>-prod/archive/2020/10/30/<file name redacted>.json".
> 2020-10-30 14:07:56.286 Type: SSH_FXP_RENAME, Size: 105, Number: 5755922
< 2020-10-30 14:07:56.357 Type: SSH_FXP_STATUS, Size: 24, Number: 5755922
< 2020-10-30 14:07:56.357 Status code: 0
< 2020-10-30 14:07:56.358 Script: /home/<redacted>-prod/outbound/<file name redacted>.json
> 2020-10-30 23:32:19.187 Script: call cd "/home/<redacted>-prod/archive/2020/10/30/" ; tar -czvf "archive_20201030_131927.tar.gz" "/home/<redacted>-prod/archive/2020/10/30/"
< 2020-10-30 23:32:19.188 Script: Searching for host...
. 2020-10-30 23:32:19.189 [Shell] Looking up host "<url redacted>" for SSH connection
. 2020-10-30 23:32:19.248 [Shell] Connecting to <IP Address redacted> port 22
< 2020-10-30 23:32:19.319 Script: Connecting to host...
I have attached the Session Log. Unfortunately, even with the debug log level set at 0, the size of the debug log is still over 25GB, so I cannot upload it or open it.
I received the following error in the PowerShell session.
2020-10-30 23:32:16 - Archive Command: cd "/home/<redacted>-prod/archive/2020/10/30/" ; tar -czvf "archive_20201030_131927.tar.gz" "/home/<redacted>-prod/archive/2020/10/30/"
PS D:\Temp\Script\Miscellaneous> TerminatingError(archive.ps1): "Exception calling "Check" with "0" argument(s): "Network error: Software caused connection abort
Error changing directory to '/home/<redacted>-prod/archive/2020/10/30'.""
D:\Temp\Script\Miscellaneous\archive.ps1 : Exception calling "Check" with "0" argument(s): "Network
error: Software caused connection abort
Error changing directory to '/home/<redacted>-prod/archive/2020/10/30'."
At line:1 char:1
+ D:\Temp\Script\Miscellaneous\archive.ps1 `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [archive.ps1], MethodInvocationException
+ FullyQualifiedErrorId : SessionRemoteException,archive.ps1
D:\Temp\Script\Miscellaneous\archive.ps1 : Exception calling "Check" with "0" argument(s): "Network
error: Software caused connection abort
Error changing directory to '/home/<redacted>-prod/archive/2020/10/30'."
At line:1 char:1
+ D:\Temp\Script\Miscellaneous\archive.ps1 `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [archive.ps1], MethodInvocationException
+ FullyQualifiedErrorId : SessionRemoteException,archive.ps1