It is necessary to organize the copying of files over the network from one server to another.

At the same time, you need to copy files to different folders on the target machine, depending on the format of the file name.

** C: / Program Files / aProgram / files / FILENAME__15122018.ext1 ===> / home / work / sourcedir1

C: / Program Files / aProgram / files / 15122018_FILENAME.ext2 ===> / home / work / sourcedir2 **

In C: / Program Files / aProgram / files / there is a set of files and is regularly updated and this is a Windows machine ( PC1 ) There is PC2 where you need to copy files and this is a Unix machine ( PC2 )

At the same time, copying should take place on a secure channel regularly (once a day)

From what I could think of, having no experience with such tasks:

Raise a self-written go SPTP server on PC1 on the desired folder, organize SSH-keys authentication. On PC2, the client can read the folder and copy files according to the folder by the right folder ..

Maybe someone had experience of this and can tell

  • one
    The rsync over ssh is best suited for this, which will be run once a day via cron. - Oleg Utkin
  • one
    Instructions . - Oleg Utkin
  • If everything works - the normal option. - hardsky
  • @OlegUtkin thanks, it would be nice to get rid of rsync but 1) can rsyncom realize copying by mask? that is, files of one type in one directory and another in another? 2) Is it possible to synchronize files from Windows machines to Linux? (seen by reference about cwRsync but not sure if he will be able to give files to the native Linux rsync?) - Nikita Bulanakov February
  • 1) Yes, the article has an example with --include, --exclude; 2) cwRsync is compatible with Linux rsync - Oleg Utkin

1 answer 1

Thanks to all for the help , unfortunately we could not get rid of rsync tools, although for a very wide range of rsync tasks, probably the best choice. The rsync commands to which I came allowed me to copy files to the correct directories

rsync.exe -a -m --include='*.ext1' --exclude='*' backup@127.0.0.1::local_copying /cygdrive/d/rsync_in/ext1files 

But as it turned out, it was necessary to implement additional logic where rsync is not enough - archiving copied files, etc. Also, leave space for the expansion of developments on similar copy tasks. As a result, I wrote a program on golang with a configuration file where I indicated what to copy and where. Using the following packages:

 "github.com/micro/go-config" "github.com/pkg/sftp" "golang.org/x/crypto/ssh"