winscp script failing to locate file with put command

Advertisement

mnaveen
Joined:
Posts:
12
Location:
India

winscp script failing to locate file with put command

I have a batch file scheduled task to take DB backup and upload it to ftp server. First back will be taken and copied local D drive. Then from D drive it will be uploaded to FTP server with winscp put command. However, i am able to run script manually works fine.

Log:
2021-03-03 02:09:47.769 Startup conversation with host finished.
< 2021-03-03 02:09:47.769 Script: Active session: [1] test/support@test.com@test.sharefileftp.com
> 2021-03-03 02:09:47.769 Script: put D:\ITECH_BACKUP\PITR\DATABASE\BASE_BACKUP\MDR2_BASEBACKUP_20210303_013000.zip
. 2021-03-03 02:09:47.769 Copying 1 files/directories to remote directory "/MDR2/PITR/BASE_BACKUP"
. 2021-03-03 02:09:47.769   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask: 
. 2021-03-03 02:09:47.769   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; InclM: ; ResumeL: 0
. 2021-03-03 02:09:47.769   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
* 2021-03-03 02:09:47.785 (EOSError) System Error.  Code: 2.
 
* 2021-03-03 02:09:47.785 The system cannot find the file specified
. 2021-03-03 02:09:47.785 Asking user:
. 2021-03-03 02:09:47.785 File or folder 'D:\ITECH_BACKUP\PITR\DATABASE\BASE_BACKUP\MDR2_BASEBACKUP_20210303_013000.zip' does not exist. ("System Error.  Code: 2.
 
. 2021-03-03 02:09:47.785 The system cannot find the file specified")
< 2021-03-03 02:09:47.785 Script: File or folder 'D:\ITECH_BACKUP\PITR\DATABASE\BASE_BACKUP\MDR2_BASEBACKUP_20210303_013000.zip' does not exist.
< 2021-03-03 02:09:47.785 Script: System Error.  Code: 2.
 
< 2021-03-03 02:09:47.785 The system cannot find the file specified
* 2021-03-03 02:09:47.785 (EScpSkipFile) File or folder 'D:\ITECH_BACKUP\PITR\DATABASE\BASE_BACKUP\MDR2_BASEBACKUP_20210303_013000.zip' does not exist.
* 2021-03-03 02:09:47.785 System Error.  Code: 2.
* 2021-03-03 02:09:47.785 The system cannot find the file specified
. 2021-03-03 02:09:47.785 Script: Failed
. 2021-03-03 02:09:47.785 Script: Exit code: 1
. 2021-03-03 02:09:47.785 Disconnected from server
Script
REM TO FETCH THE CLIENT NAME FROM TEXT FILE "Client_Name.txt"
SET /p CLIENT=<D:\BATCH_FILES\Client_Name.txt
 
REM TO FETCH THE PASSWORD FROM TEXT FILE "Citrix_PWD.txt"
SET /p CITRIXPWD=<D:\BATCH_FILES\Citrix_PWD.txt
 
REM TO FETCH THE PASSWORD FROM TEXT FILE "ZIP_PWD.txt"
SET /p ZIPPWD=<D:\BATCH_FILES\ZIP_PWD.txt
 
REM UPLOAD APPLICATION WINSCP PATH AND FILENAME
SET WINSCPPATH="D:\Program Files\WinSCP"
SET WINSCPLOGPATH="D:\eCP\winscp_log"
SET WINSCPLOGFILENAME="basebackup_winscp_%yyyymmdd%.log"
 
REM DECLARE DATE AND TIME VARIABLES
SET hh=%time:~0,2%
IF "%time:~0,1%"==" " (SET hh=0%time:~1,1%)
SET yyyymmdd=%date:~10,4%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2%
SET yyyymmdd_hhmmss=%date:~10,4%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2%
SET yymmdd_hhmmss=%date:~10,4%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2%
SET ZIP_FILE_EXTENSION=.zip
 
SET BASEBACKUP_FOLDERNAME=D:\test\PITR\DATABASE\BASE_BACKUP\%CLIENT%_BASEBACKUP_%yyyymmdd_hhmmss%
SET BASEBACKUP_FOLDERNAME_AND_FILENAME=D:\test\PITR\DATABASE\BASE_BACKUP\%CLIENT%_BASEBACKUP_%yyyymmdd_hhmmss%\base.tar.gz
 
REM COPY THE LOG FOLDER AND FILE NAMES
ECHO %BASEBACKUP_FOLDERNAME% >> %WINSCPLOGPATH%\%WINSCPLOGFILENAME%
ECHO %BASEBACKUP_FOLDERNAME_AND_FILENAME% >> %WINSCPLOGPATH%\%WINSCPLOGFILENAME%
 
REM Create Base Backup Folder
MD %BASEBACKUP_FOLDERNAME%
 
REM To create postgresql base backup with compression
REM To create base.tar.gz in BASEBACKUP_FOLDERNAME using Postgresql inbuilt pg_basebackup
 
pg_basebackup -h localhost -U postgres -D %BASEBACKUP_FOLDERNAME% -Ft -x -z -P -v
 
 
SET BASEBACKUP_ZIPFILENAME=%BASEBACKUP_FOLDERNAME%%ZIP_FILE_EXTENSION%
 
REM CREATE ZIP FILE WITH PASSWORD FOR CITRIX UPLOAD 
SET PWD=%CLIENT%_%yymmdd_hhmmss%_%ZIPPWD%
REM 7z a -tzip -p%PWD% %FILE_BACKUP_ZIP_FILE_PATH% %CURRENT_FILE_BACKUP_PATH%
REM echo %BASEBACKUP_ZIPFILENAME% 
REM echo %BASEBACKUP_FOLDERNAME%
 
REM pause
7z a -tzip -p%PWD%  %BASEBACKUP_ZIPFILENAME% %BASEBACKUP_FOLDERNAME%
 
REM Install WINSCP for sharefile upload
REM WINSCP command line to upload zip to citrix sharefile account
 
 
%WINSCPPATH%\winscp.com /log="%WINSCPLOGPATH%\%WINSCPLOGFILENAME%" /command "option batch abort" "open ftps://test%%2Fsupport@test.com:%CITRIXPWD%@test.sharefileftp.com/%CLIENT%/PITR/BASE_BACKUP" "put %BASEBACKUP_ZIPFILENAME%" "exit"
 
RD %BASEBACKUP_FOLDERNAME% /S/Q
 
EXIT

Reply with quote E-mail

Advertisement

martin
Site Admin
martin avatar

Re: winscp script failing to locate file with put command

Add dir %BASEBACKUP_ZIPFILENAME% before and after you call WinSCP and post what you get.

Reply with quote

Advertisement

You can post new topics in this forum