My current works involves working on scripts running on a Ubuntu VM.
For multiple reasons, I'm editing and committing project files on a local computer running Windows, and running them on a remote server through a SSH connection (using MobaXTerm). My build process when developing is roughly as follows:
-
Write the changes in my local text editor.
-
Open the right directory in MobaXTerm's SFTP UI.
-
Click "Upload file", and select the right directory and file in the Windows file browser.
-
Run
systemctl restart apache2.service
or whatever I need on the VM.
(obviously the build process for production builds is much more thorough and automatized)
Steps 2 and 3 feel pretty redundant. They're repetitive, easy to forget, easy to get wrong, and I'm generally giving the computer information it should know better than me.
Is there a standardized, safe way to automatically synchronize a local folder with a remote SSH folder from Windows?
Essentially, what I want is some utility that goes File myDirectory/foo/bar/X
has changed! Uploading file X to someUrl/theirDirectory/foo/bar/X
with minimum configuring.
Best Answer
There is no "standardized way".
You have these options:
You can implement the first two options with WinSCP SFTP client.
Watching for changes
Use "Keep remote directory up to date" function of WinSCP.
It can be used both in command-line/console mode using the
keepuptodate
command, like:Or in a graphical/GUI mode. You can launch the graphical mode in WinSCP GUI (after logging in) or from a command-line using the
/keepuptodate
switch like:Scheduling
To synchronize changes in a local directory to a remote directory, use the WinSCP
synchronize
script command from a batch file like:And schedule the batch file to be run frequently using Windows scheduler.
For details see also a guide to automating file transfers (or synchronization) to SFTP server.
(I'm the author of WinSCP)