Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I am trying to do is mirror a directory (recursively) from a server I can SSH/SFTP to, to a Windows machine. I want to do this as part of a script, so it can be automated.

I only want to copy new or modified files. I don't want to have to download all the files every time the script runs.

In other words, I'm trying to get the equivalent of RoboCopy /MIR that will work using SFTP as a source.

What would you recommend?

share|improve this question
up vote 5 down vote accepted

WinSCP can synchronize directories using /synchronize or with a script.

share|improve this answer
Worked for me, thanks. The command I used: "C:\Program Files (x86)\WinSCP\" My_Stored_WinSCP_Session /command "synchronize local X:\Local\Target\Directory /the/remote/directory" exit – Andrew Russell May 10 '10 at 1:29

Mount your SFTP server as a drive using SFTPNetDrive then robocopy as regular (probably with /Z).

share|improve this answer

If you only want to get the files that have changed, I would recommend rsync (under cygwin).

share|improve this answer
My impression is that rsync also needs to be installed on the server I am connecting to? Is this correct? – Andrew Russell May 9 '10 at 1:24
Yes, rsync would need to be installed on the server as well. When given a remote file path, it will connect via SSH and run and rsync daemon on the server. – Brian May 10 '10 at 15:05
hmm and I guess rsync is then running privileged and so I can access even root only files using rsync? – Jul 11 '12 at 16:13 No, the rsync daemon runs as the user who connected by SSH. It would only have root privileges if root started it as a service on the server (and then you would use the rsync protocol to connect instead of SSH). But even in this mode, the rsync daemon can be configured to run as a less-privileged user. – Brian Jul 11 '12 at 19:10
For rsync to work well it needs to be installed in both locations. In my experience, rsync on Windows doesn't work so well. DeltaSync hides some of the cygwin. Unison does an even better job, but is overkill for what you are doing. – Russell S. Pierce Jul 14 '12 at 5:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .