LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-02-2012, 11:56 PM   #1
genese
Member
 
Registered: Feb 2006
Location: belgium
Posts: 76

Rep: Reputation: 20
rsync exclude pattern


Hello All,

Having 2 files named 'file' in two subdirectories './dir' and './dir2/dir2/dir'

Code:
ll -R
.:
total 8
drwx------ 2 root root 4096 03-12 06:21 dir
drwx------ 3 root root 4096 03-12 06:21 dir2
./dir:
total 0
-rw------- 1 root root 0 03-12 06:30 file
./dir2:
total 4
drwx------ 3 root root 4096 03-12 06:21 dir2
./dir2/dir2:
total 4
drwx------ 2 root root 4096 03-12 06:22 dir
./dir2/dir2/dir:
total 0
-rw------- 1 root root 0 03-12 06:30 file
I'd like rsync to exclude ./dir/file but not exclude ./dir2/dir2/dir/file

Here are my tentatives :

Both files are copied
Code:
touch dir/file dir2/dir2/dir/file ; rsync -av --exclude=./dir/file . /tmp/test2
sending incremental file list
dir/file
dir2/dir2/dir/file
sent 209 bytes  received 54 bytes  526.00 bytes/sec
total size is 0  speedup is 0.00
Both files are excluded
Code:
touch dir/file dir2/dir2/dir/file ; rsync -av --exclude=dir/file . /tmp/test2
sending incremental file list
sent 98 bytes  received 16 bytes  228.00 bytes/sec
total size is 0  speedup is 0.00
What's the correct exclude pattern ?
 
Old 12-03-2012, 02:40 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
rsync -av --include=*/dir/file --exclude=dir/file . /tmp/test2
 
Old 12-03-2012, 03:49 AM   #3
genese
Member
 
Registered: Feb 2006
Location: belgium
Posts: 76

Original Poster
Rep: Reputation: 20
Quote:
Originally Posted by colucix View Post
Code:
rsync -av --include=*/dir/file --exclude=dir/file . /tmp/test2
Thank you for your input colucix.

I'm afraid that it is not possible for me to add an --include for a specific file.

The command is used in a script whose purpose is to copy the whole hierarchy with a few exceptions.

The exceptions are dynamically put in a list just before invoking rsync with the --exclude-from option.

So it is possible for each file in the hierarchy to be excluded for a given run of the script.

The list is build with relative paths. I have a problem when ./dir/file is in the list. Any 'file' having a 'dir' parent is excluded.

I should have mentioned the context in my post. Sorry.
 
Old 12-03-2012, 04:26 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274Reputation: 7274
there are several possibilities, but it looks like all the solutions are unusable because of your restriction:
1. you can try the solution below (--include)
2. you can specify those file with full path
3. you can try the --filter option
4. you can try to rename/move those files
5. you can also try to execute a second rsync on the excluded dir
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync Include/exclude based on pattern & file size? Geremia Linux - Software 1 01-20-2012 08:49 PM
[SOLVED] how to exclude everything except a pattern with sed rafaeldeoliveiracosta Programming 12 07-23-2010 11:36 AM
Exclude file pattern from unzip command XeroXer Linux - Newbie 3 01-10-2009 07:10 AM
What files to exclude when using rsync TongueTied Linux - General 2 07-20-2006 08:39 PM
rsync exclude list steelhead79 Linux - Software 3 01-14-2005 12:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration