A script to automate Synchronization and downloading files/folder from sFTP server to a local server

Advertisement

Lily
Joined:
Posts:
2

A script to automate Synchronization and downloading files/folder from sFTP server to a local server

Hello, need your help!

I have an sFTP server from the vendor side that they uploading all transaction logs of medical records in a zip folder named as 'xxxx_yyyymmdd.zip' while the date stamp is for current day.

I have installed the WinSCP app and I used to synchronize the files between my local server and remote server then downloading the folders that are not in my local server just manually using the GUI.
But now I want to schedule this process on windows event scheduler and couldn't able to write the WinSCP script for synchronization and downloading the daily uploaded files from the sFTP server to my local server.

I have tried to see if similar posts here but didn't find exactly the way I need, please help!

Thank you in advance,

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
28,658
Location:
Prague, Czechia

Re: A script to automate Synchronization and downloading files/folder from sFTP server to a local server

Start with these links:
https://winscp.net/eng/docs/guide_automation
https://winscp.net/eng/docs/scriptcommand_synchronize
https://winscp.net/eng/docs/guide_schedule

You can also have WinSCP GUI generate a download script for you. And then, you just replace get command with synchronize command.
https://winscp.net/eng/docs/ui_generateurl#script

Reply with quote

Lily
Joined:
Posts:
2

Re: A script to automate Synchronization and downloading files/folder from sFTP server to a local server

Hi Martin,
Thank you very much for the response!
I was trying according to the guides you sent me and did the following but not working.
- On windows task scheduler of 'Action tab' I chose to start a program and execute the 'WinSCP.exe' and on 'add an argument section I used the script that I think will be used to save log files, establish connection and synchronize local to remote server as:
<< /log=c:\path\winscp.log /command "open sftp://xxxx:14001/ -hostkey="ssh-hrsa 2048 ...=" -privatekey="E:\AAA.ppk" -rawsettings ProxyPort=0"
"synchronize local|remote|both [ E:\DailyLogs [ cd /BBBB ] ]"
"exit" >>
However this didn't work as I expected and wondering if you can identify for me where my mistake is or any other ideas?

Thanks again,
Lily

WinSCP_Schedule.PNG

Reply with quote

Advertisement

You can post new topics in this forum