Topic "Sync with files exclusions"

Author Message
ehm01
[View user's profile]

Joined: 2016-10-30
Posts: 8
Location: USA
I'm having a hard to time to figure this out using the resources here, so, if I overlook something, bear with me.
Using WinSCP 5.9.2

I need to copy the whole web site back to my PC, with exclusion of couple folders that are 'sessions' on a database. If I try to sync everything, include that /sessions folder, sometimes I get error when a user leaves the database, so I figure out that the best option will be to EXCLUDE that.

This is my .txt file:
synchronize local c:\MySites\Site1\

/public_html -delete -preservetime -filemask=""*/*|*/sessions""

This work on the sense that /sessions IS NOT being copied, but also, any sub-folder from my root. What I'm doing wrong?
I have this structure:
/
index.html
manyfiles.html
/folder1
/folder1/index.html
/folder1/manyfiles.html
/folder2
/folder2/index.html
/sessions/
/sessions/manysessions.html

Using the instructions above, I copy all files under / but none under any /folder1 or /folder2

So, what is wrong?
Thank you very much
Advertisements
jrp78
[View user's profile]

Joined: 2016-10-07
Posts: 18
Location: SoVA
Try:

/public_html -delete -preservetime -filemask=""| sessions/""
ehm01
[View user's profile]

Joined: 2016-10-30
Posts: 8
Location: USA
jrp78 wrote:
Try:

/public_html -delete -preservetime -filemask=""| sessions/""


Try it.
the return was:
all sub-folder (included /sessions)
but any file. The sub-folders are empty on my PC (and they are not on the server)
and any file from the root was downloaded too.

Just to make easy, this is what I already try:
-filemask=""|*/sessions/""
-filemask=""|/sessions/""
-filemask=""*/|*/sessions/""
-filemask=""*.*/|*/sessions/""
-filemask=""*/*|*/sessions/""

The results vary, but any gives me ALL files from root, All folder, All sub-folders, All files from sub-folders BUT not /sessions.

Other ideas please?
jrp78
[View user's profile]

Joined: 2016-10-07
Posts: 18
Location: SoVA
No, I do not unfortunately. The code I sent should work. You can use the GUI to build a filemask and that's what I did for you in my example. I'm not sure why it's still syncing the sessions folder. Also, "*/" means to not sync any subfolders so you don't want that.

ehm01
[View user's profile]

Joined: 2016-10-30
Posts: 8
Location: USA
jrp78 wrote:
No, I do not unfortunately. The code I sent should work. You can use the GUI to build a filemask and that's what I did for you in my example. I'm not sure why it's still syncing the sessions folder. Also, "*/" means to not sync any subfolders so you don't want that.



Where did you find this 'File Mask Edit'???
jrp78
[View user's profile]

Joined: 2016-10-07
Posts: 18
Location: SoVA
ehm01
[View user's profile]

Joined: 2016-10-30
Posts: 8
Location: USA
That is very odd.

I use the mask tool you point to create this:

-filemask=""*.*; *.*/|/sessions/""

and then I got error:
"too many parameters for command 'synchroniza'."

maybe I have a defective version? let me download again...
ehm01
[View user's profile]

Joined: 2016-10-30
Posts: 8
Location: USA
one more info:
if I use the "sync' from the program, and not from my script, IT WORKS!!!!!!!!!!!!!!!

so, what could be wrong???
jrp78
[View user's profile]

Joined: 2016-10-07
Posts: 18
Location: SoVA
I'm not sure. I don't use the txt file method so I have no experience with it. I will say I don't think you need the *.* part of the filemask. I just leave it blank on mine and I have just the exclusions set. I sync tons of folders and subfolders and have no issues. I'll look through the forums. There should be an example of what you need somewhere.
ehm01
[View user's profile]

Joined: 2016-10-30
Posts: 8
Location: USA
jrp78 wrote:
I'm not sure. I don't use the txt file method so I have no experience with it. I will say I don't think you need the *.* part of the filemask. I just leave it blank on mine and I have just the exclusions set. I sync tons of folders and subfolders and have no issues. I'll look through the forums. There should be an example of what you need somewhere.


You were right again. If I just place the exclusion, on the GUI version (| sessions/ ), works exactly the way I need.
It just do not work on the Script:

synchronize local c:\MySites\Site1\ /public_html -delete -preservetime -filemask=""| sessions/""

Give me the Too Many Parameters err.

Sad
ehm01
[View user's profile]

Joined: 2016-10-30
Posts: 8
Location: USA
O GOT IT!!!!!!!!!!


synchronize local c:\MySites\Site1\ /public_html -delete -preservetime -filemask="| sessions/"

ONLY ONE quotation mark on each side.

All info on the forum always mention that you have to have two cotations!
The manual says two (double)
It's working.
THank you for pointing the Mask File Editor. That was a key for me to find the right way.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
ehm01 wrote:
All info on the forum always mention that you have to have two cotations!
The manual says two (double)

Only, if you provide commands on command line (as opposite to a script file).
jrp78
[View user's profile]

Joined: 2016-10-07
Posts: 18
Location: SoVA
ehm01 wrote:
O GOT IT!!!!!!!!!!


synchronize local c:\MySites\Site1\ /public_html -delete -preservetime -filemask="| sessions/"

ONLY ONE quotation mark on each side.

All info on the forum always mention that you have to have two cotations!
The manual says two (double)
It's working.
THank you for pointing the Mask File Editor. That was a key for me to find the right way.


Good deal. I use command line instead of a script file which requires the double quotes so why I would not have guessed that Very Happy
Guest




OK. I was to fast.
I was doing tests in a demo base, since the real one is about 1.2Gb large.
What happens with that code:
synchronize local c:\MySites\Site1\ /public_html -delete -preservetime -filemask="| sessions/"
is that if the '/sessions' is empty, they will not transfer.
if it's not, then it will try to read files and transfer it, even do it's marked as not to.
end then the error happens.
I found it after about 4 hours downloading the site.
Back to the testing mode... Sad
Any other help people?
PS: if I use the GUI version, it works. Only on the Script it's not.
ehm01
[View user's profile]

Joined: 2016-10-30
Posts: 8
Location: USA
Double cheked and this is real:
If I use the GUI, with this command:
*; */ | sessions/

All files and folders are copied to my PC, but the files and folders under /sessions.

If I use the Script with this command:
synchronize local c:\MySites\Site1\ /public_html -delete -preservetime -filemask="*; */ | sessions/"

All files and folder are copied to my PC, including Sessions folder and files underneet
jrp78
[View user's profile]

Joined: 2016-10-07
Posts: 18
Location: SoVA
You could try a different format. I use a windows batch file(.bat)

Here is an example of my code inside the .bat file which works without issue. One caveat, if you copy this code, you must remove any blank spaces AFTER the ^ symbol. The ^ must be the final character on each line.

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\scripts\WinSCP-5.9.1-Portable\log_!Y_!M_!D_!T.log" /loglevel=0 /ini=nul ^
/command ^
"open sftp://username@serverip/ -hostkey=""ssh-rsa 2048 xx:xx:xx:xx"" -privatekey=""C:\scripts\Puttygen\privkey.ppk""" ^
"option batch abort" ^
"option transfer binary" ^
"option synchdelete on" ^
"synchronize local d:\inetpub\web\ /web/ -criteria=both -filemask=""| alert.xml; emergency.xml; .htaccess; notice.xml; sitemap.xml; web.config; wincache.php; fileshare/; xml-sitemap-generator/""" ^
"close" ^
"quit" ^
"exit"
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
ehm01 wrote:
Double cheked and this is real:
If I use the GUI, with this command:
*; */ | sessions/

All files and folders are copied to my PC, but the files and folders under /sessions.

If I use the Script with this command:
synchronize local c:\MySites\Site1\ /public_html -delete -preservetime -filemask="*; */ | sessions/"

All files and folder are copied to my PC, including Sessions folder and files underneet

Your code works for me.
Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session 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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
jrp78 wrote:
You could try a different format. I use a windows batch file(.bat)

Using a different format does not change a meaning of the commands.
Advertisements

You can post new topics in this forum






Search

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