1

I am trying to synchronise three VPS servers. My idea is something like this:

  1. Download all files from server A
  2. Upload downloaded files to server B and C

This does not need to happen automatically (making a couple of clicks to trigger it would be nice). Is this possible using FileZilla or some other similar client?

Due to a restriction, the servers can't open sockets to each other so using another device (my computer) to transfer the files seems like the only possible solution to me.

Is what I'm trying to do possible? Can I automate this in a .sh file or a .bat file to run on my Windows 10 or Fedora 31 PC so I only have to run the script?


Edit: So far, using a WinSCP script example, I have done this:

open sftp://username:pass@hostA:2022
synchronize local E:\SFTP_Sync\hubs /

open sftp://username:pass@hostB:2022
synchronize remote E:\SFTP_Sync\hubs /

open sftp://username:pass@hostC:2022
synchronize remote E:\SFTP_Sync\hubs /

exit

Before I run this and mess everything up, is this going to do the following?

  1. Update the local directory from server A
  2. Wait for the local sync to finish
  3. Update the remote directories of server B and server C
Martin Prikryl
  • 21,071
  • 9
  • 77
  • 157

1 Answers1

0

Your can use WinSCP. It supports synchronization both in its GUI and in script.

For GUI, see FileZilla - How to synchronize two-way (newest file wins)? (which also explains that FileZilla does not support synchronization).

For scripting, see Synchronize files to an SFTP server – It's for SFTP, but it's not different to FTP, except for the connection info.

(I'm the author of WinSCP)

Martin Prikryl
  • 21,071
  • 9
  • 77
  • 157
  • I saw an example on how to synchronise different folders on the same SFTP. Is it possible to sync between 3 different SFTP servers in 1 script? Is there also some sort of "await" so that it waits that first the local directory is synced, then syncs the other 2 remote servers? If I have saved a connection (including the password), can I use that somehow? I am not sure what the host key is. – user10398534 Apr 29 '20 at 06:50
  • Sorry, that's too many questions without any context. Are we talking about the GUI or the script? – Martin Prikryl Apr 29 '20 at 07:06
  • The script. Check my question edit: I have written a script that I am not sure will work – user10398534 Apr 29 '20 at 07:07
  • Yes, that looks good. Try it first with the first sync only. You can even first try it with [`-preview` switch](https://winscp.net/eng/docs/scriptcommand_synchronize#preview) to see what will happen. – Martin Prikryl Apr 29 '20 at 07:15
  • I have a suspicion that if I delete a file on server A, it doesn't delete the file on the local directory and from there it doesn't delete it on B and C as well. Is this possible? – user10398534 May 01 '20 at 09:16
  • If you want to delete orphan files, you have to add [`-delete` switch](https://winscp.net/eng/docs/scriptcommand_synchronize#delete). – Martin Prikryl May 01 '20 at 17:23