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

Author Message
tuhinbhuiyan
[View user's profile]

Joined: 2015-04-08
Posts: 4
Location: Dhaka
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.

Code:
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. Embarassed

Please suggest.
Advertisements
tuhinbhuiyan
[View user's profile]

Joined: 2015-04-08
Posts: 4
Location: Dhaka
can I get a reply to this, please? @prikryl
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
It's like get /* i:\backups\domain\* -filemask="| /backups*;/dev*;..."

Also note that option transfer binary is deprecated, use get -transfer=binary ...
tuhinbhuiyan
[View user's profile]

Joined: 2015-04-08
Posts: 4
Location: Dhaka
Hi, Thanks for your response!!!

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

Code:
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 Smile
log.txt (82.38 KB) Private file

Description: (none)

tuhinbhuiyan
[View user's profile]

Joined: 2015-04-08
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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
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.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License