Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: Synchronize remote -delete -mirror does not work as expected

Please attach a full log file showing the problem (using the latest version of WinSCP) on a single modified file.

Make sure you mention the name of the file in your response.

To generate log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
Miro

Synchronize remote -delete -mirror does not work as expected

Hi Team,

I'm using WinSCP (Version 5.7.5, Build 5665) automation and scripting to synchronize (local to remote) some Web Sites content (Windows, IIS). It works well but recently I noticed something, that I'd like to resolve. I perform the synchronization over FTP.

Settings are following:
option batch continue
option confirm off
option transfer binary


Synchronization is realized through this command
synchronize remote -delete C:\source_folder /destination_folder


Now, if add, delete or update existing file/folder in source_folder, synchronization works like a charm. But if I replace file/folder with the same file/folder which has a timestamp that is earlier than the same file on destination_folder, this one is not being transferred to remote folder. I checked the documentation to WinSCP and found, that in order to solve this, I need to use -mirror option:

With Synchronize files mode, the newer files in source directory are transferred to the opposite directory. Files in source directory not present in target directory can optionally be transferred as well (disable this using the option Existing files only). Files in target directory not present in source directory are optionally deleted (enable option Delete files). In Both mode (see above), file not present in an opposite directory is considered new, hence it is transferred (if allowed), but never deleted. In other words, in Both mode, no file is ever deleted.

With Mirror files mode, the different (both newer and older) files in source directory are transferred to the opposite directory. Otherwise the mode is the same as Synchronize files.


When I tested this, I noticed that WinSCP is actually synchronizing all files and folders with -mirror mode. I need to achieve, that only modified files/folders are being synchronized, no matter if file/folder on source_folder is newer or older than the same existing file/folder on destination_folder - this was the case when I used synchronize remote -delete without -mirror mode, but older files were not transferred.

Is there a way to achieve this without synchronizing all files? I can't allow this as some folders have gigs of data.
Thanks for help.

Regards
Miro