Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

3 Answers

up vote 3 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\WinSCP.com" My_Stored_WinSCP_Session /command "synchronize local X:\Local\Target\Directory /the/remote/directory" exit –  Andrew Russell May 10 '10 at 1:29
add comment

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

share|improve this answer
add comment

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? –  stefan.at.wpf Jul 11 '12 at 16:13
    
@stefan.at.wpf 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
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.