Problem:
Sync a local directory with a remote directory via SFTP on schedule
Solution:
- Create a .txt file to store your steps
- Note: host key you will get from logging in once using the WinSCP UI.
- Create a .txt file for your steps
- Create a .bat file to execute perhaps using windows scheduler or the like.
#Loginto SFTP
open sftp://USERNAME:PASSWORD@IP/ -hostkey="[hostkey]"
# 1. Cd into remote dir
cd /srv/users/test/apps/super-folder/
# 2. Pull down Files && Delete files once downloaded
get -delete *.json C:\mydata\
https://winscp.net/eng/docs/ui_generateurl
https://winscp.net/eng/docs/faq_delete_synchronized_files
BAT file will look something like this
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /log="inSCP.log" /ini=nul /script="mc-script-json.txt"