SFTP: Monitor a remote folder and copy new files added using SFTP on Windows

I need to monitor a folder on a remote server and copy new files added using SFTP to a local folder on Windows. Is there a SFTP client which can be configured and scheduled to monitor a remote folder and copy files over automatically? OR Do i have to write a windows service to accomplish this using some third party SFTP library?

Thank you.

Upvotes: 1

Views: 6433

Answers (2)

user2284545
user2284545

Reputation:

The easiest way to accomplish this is to write a client program that pro-grammatically connects to the SFTP server and determines whether new files are present on the server. How the program determines whether new files are present can be done by using filename and optionally the time-stamp of the remote file.

The obvious difficulty her is that you don't want to download files from the server that are in the process of being written to disk on the server machine itself. (a large file may present this problem & you may end up downloading an incomplete file resulting in corrupt data). One way to circumvent this is to run the SFTP client at a specific time of the day where you are sure no new files are being written on the remote directory on the server.

To create a self running client you can either use .NET Framework to create a timer that runs at a schedule that you want. Alternatively you can simply write the code that detects the remote file in a C# program without worrying about timers AND you use the Windows Scheduled Tasks feature to execute the generate executable at a specific time interval.

Since you have not mentioned whether you want to use .NET Framework you may use any programming language of your choice. I would recommend either C# or Java using a 3rd party library of your choice. If you are looking for a commercial library please consider Ssh Factory for .NET or Secure FTP Factory. Documentation can be found here and here.

Upvotes: 1

The files can be copied from or to the SFTP server in two ways

  1. Create a custom .net service to monitor the folder on SFTP server and copy the files using a third party SFTP client library. The following are some of the libraries available.

    a. Open source library SSH.Net on CodePlex
    b. Rebex SFTP for .Net
    c. Ultimate SSH Expert package for .Net

  2. Install a third party SFTP client capable of monitoring folders and scheduling tasks. The following are some of the clients tools which seems to have these features

    a. CrushFTP

    b. JaSFtp

Upvotes: 1

Related Questions