How to Exclude Folders and Set size+timestamp for sync?

Advertisement

tuhinbhuiyan
Joined:
Posts:
4
Location:
Dhaka

How to Exclude Folders and Set size+timestamp for sync?

Hi, Winscp is really a great tool for syncing remote files as backup. At present I have this info or doing synchronization remote > local .. Which working great.

option batch on
option confirm off
open user@sftp.example.com
cd
option transfer binary
get /* i:\backups\domain\*
synchronize local i:\backups\domain\ /
exit

But I am having trouble to add Synchronization criteria for last folder/file modified time and size.

Also Wanted to exclude some directories/subfolders/files by Using option exclude "folder/file" ??.

/backups*
/dev*
/boot*
/media*
/mnt*
/proc*
/sys*
/tmp*
/run*


I tried doing this by | pipes for excluding but I might have done something wrong. :oops:

Please suggest.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: How to Exclude Folders and Set size+timestamp for sync?

It's like get /* i:\backups\domain\* -filemask="| /backups*;/dev*;..."

Also note that option transfer binary is deprecated, use get -transfer=binary ...

Reply with quote

tuhinbhuiyan
Joined:
Posts:
4
Location:
Dhaka

Missing parameter for get command

Hi, Thanks for your response!!!

I Tried the above filemask and made out into this script as a test:

option batch on
# Disable overwrite confirmations that conflict with the previous 
option confirm off
# Reconnect at each failure.
option reconnecttime 15
# SFTP/FTP Account
open root@sftp.example.com
# Directory to switch
cd /
# Force binary mode transfer 
get -transfer=binary
# Download file to the local directory with get -filemask rule
get remote -filemask="| /testremote/exclude*;/backups*;/dev*;/boot*;/media*;/mnt*;/proc*;/sys*;/tmp*;/run*;" /testremote* i:\backups\domain\testlocal\*
# Synchronize Local < Remote based on last modified time
synchronize local -criteria=time i:\backups\domain\testlocal /testremote
# Exit WinSCP 
exit


But I am getting missing parameter for get command within log file.. Also Fils and folder get duplicate multiple times like this below,

Correct, will add all sub directories into this: /testremote*
But non correct, will add all sub directories into this but also adds copy of everything of main directory within this: testremote/testremote/*

And for some reason it is doing the 2nd one.


Log file attached.

I would appreciate your help into this. Thanks :)
  • log.txt (82.38 KB, Private file)

Reply with quote

tuhinbhuiyan
Joined:
Posts:
4
Location:
Dhaka

I need to make it work like below.... but still giving me missing parameter error and duplicate/same directory folder inside of folder.

1. Connect to remote
2. Changes directory as specified on script
3. Transfer File from remote to local (except excluded file/folder from remote followed by -filemask="| ....", If no changes has been made in remote then no file/folder will be transferred to local which will follow sync last modification -criteria=time for remote)

This script will be run through win task scheduler.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Missing parameter for get command

tuhinbhuiyan wrote:

# Force binary mode transfer
get -transfer=binary
# Download file to the local directory with get -filemask rule
get remote -filemask="| /testremote/exclude*;/backups*;/dev*;/boot*;/media*;/mnt*;/proc*;/sys*;/tmp*;/run*;" /testremote* i:\backups\domain\testlocal\*
You probably want to do:

get -transfer=binary -filemask="| /testremote/exclude*;/backups*;/dev*;/boot*;/media*;/mnt*;/proc*;/sys*;/tmp*;/run*;" /testremote* i:\backups\domain\testlocal\*

Though I do not understand a point of downloading a folder and synchronizing the same folder immediately after.

Reply with quote

Advertisement

You can post new topics in this forum