Synchronize files to an SFTP server
What about making your WinSCP script easier to maintain?
I suppose all you need is to put one synchronize
command per directory to your script. That does not sound too difficult to maintain.
I.e. your script (script.txt
) would be like:
open sftp://user:[email protected] -hostkey="server_hostkey"
# one synchronize command per directory
synchronize remote C:\local_directory1 /home/user/remote_directory1
synchronize remote C:\local_directory2 /home/user/remote_directory2
...
synchronize remote C:\local_directoryN /home/user/remote_directoryN
exit
And you add a task to Windows Scheduler with command-line like:
"C:\Program Files\WinSCP\WinSCP.exe" "/script=path_to_script\script.txt" "/log=path_to_script\script.log"
Ideally also add the /ini=nul
to command-line to isolate your script from environment.
Related videos on Youtube
user277244
Updated on September 18, 2022Comments
-
user277244 over 1 year
Other than WinSCP, is there a program that can do an SFTP file synchronization of folders in Windows? I'd like to find a simple way to add directories to be backed up to my SFTP server. I'd like to run it as a scheduled task each night.
I am able to do this with WinSCP, but since my scripting is horrible, I have about 10 configuration files for each transfer and adding new ones is a paid in the neck.
-
wingedsubmariner over 10 yearsDo you have
rsync
on the server (many Linux servers do)? If so, try using something like this. It's likely to be considerably faster and possibly easier to setup. -
user277244 over 10 yearsYes, I've tried it but it has a 260 or so character limit and this causes major issues. It's hard for me to believe that people rely on this program when it has such an obvious limitation. You just can't trust it.
-