S3Sync.net
February 02, 2014, 01:36:10 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: --exclude and regular expressions.  (Read 5853 times)
Glyn
Newbie
*
Posts: 6


View Profile
« on: October 27, 2007, 03:49:53 AM »

Hi,

I am trying to get my head around how regular expressions work, perhaps I'm being a bit stupid, but I haven't got my head around them properly yet.  Can someone give me a hand in setting this up?  I think I have a common situation, where I want to exclude the following:

all contents in directories that end in __XB
all directories and their contents called @eaDir (ok, just the contents is fine)
all files with the extension .CR2
all files called thumbs.db

so, with the help of the previous topic regarding multiple excludes, I end up with:

--delete --exclude "(?:__XB/|@eaDir/|*.CR2|thumbs.db)"

but I get an error message (due to the *),so I then read up a bit more on regex's and tried this:

"(?:__XB/|@eaDir/|thumbs.db|<[A-Za-z0-9]+><.>CR2)"

however, this still backups my CR2 files, can someone advise me where I'm going wrong?

Thanks in advance,
Glyn.

PS, I have the --delete so that if I rename a directory with __XB then it will be excluded from the backup and removed from s3
« Last Edit: October 27, 2007, 03:51:41 AM by Glyn » Logged
maelcum
Newbie
*
Posts: 43



View Profile
« Reply #1 on: October 27, 2007, 03:21:49 PM »

Hi Glyn,  Cheesy

leave out the "*".
Try: --exclude "(?:__XB|@eaDir|.CR2|thumbs.db)"

Cheers.

maelcum
Logged
Glyn
Newbie
*
Posts: 6


View Profile
« Reply #2 on: October 29, 2007, 09:49:48 AM »

Yep, hi, I guess this was a natural progression from the synology forum!

I think that I tried that without success (can't test now, as at work at present).  Is this something that you have working?

Cheers,
Glyn.
Logged
maelcum
Newbie
*
Posts: 43



View Profile
« Reply #3 on: October 29, 2007, 04:58:20 PM »

Yes, it works for me. That way I'm not saving files that have a .log-ending.
Logged
ferrix
Sr. Member
****
Posts: 363


(I am greg13070 on AWS forum)


View Profile
« Reply #4 on: October 30, 2007, 02:06:46 AM »

Hi guys.  I like regularexpressions.info for a good reference.  There is also software that can test a regex against a particular string to see what it will do.

For example online: http://makedatamakesense.com/regex_debug/

Next I will try to look at your regex to see what it does.
Logged
ferrix
Sr. Member
****
Posts: 363


(I am greg13070 on AWS forum)


View Profile
« Reply #5 on: October 30, 2007, 02:18:21 AM »

"(?:__XB/|@eaDir/|thumbs.db|<[A-Za-z0-9]+><.>CR2)"

I'm not sure what you are trying to do above with all the angle brackets... Maybe you were looking at some strange dialed of regex.  Wink

In regex dot "." means any character.  * means "zero or more of"

I think what you might have wanted to say at first was ".*CR2"
which says "zero or more of any character followed by CR2"

maelcum's example will exclude anything that contains the characters CR2 preceded by one wildcard character.  What he should probably do for his log files is like "[.]log"

Because when you put period inside character class brackets it means really dot.  You can also escape stuff with backslashes
so like
\.log

If your command shell is complaining or doing bad things with all these special characters like * $ etc. try using single quotes for wrapping the regex string instead of doubles.  In many interpreters, single quotes mean "leave this string alone"
Logged
Glyn
Newbie
*
Posts: 6


View Profile
« Reply #6 on: October 30, 2007, 03:04:35 AM »

Thank you both for your articulate  Grin replies.

.CR2 now appears to work, although I could have sworn that it didn't the other day (another case of self healing software!  Smiley )

Thanks for the links Ferrix, I will be making my exclude command more comprehensive so this will be very helpful in setting up more complex regex's

Glyn.

PS, the angled brackets came from some web site that I was using as a guide to regex's - I'd never encountered them before.
Logged
maelcum
Newbie
*
Posts: 43



View Profile
« Reply #7 on: October 30, 2007, 04:46:16 AM »


Wow! Thanks Ferrix. Thats a good site!   Cool
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!