LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-31-2009, 01:19 PM   #1
s2cuts
Member
 
Registered: Mar 2007
Posts: 61

Rep: Reputation: 18
cp command, problems with archiving from only one file system...


Hello all,

I'm trying to figure out how to copy all files recursively from a certain point, but I need to avoid following a bind mount in that structure. The bind mount is from another part of the same structure I'm copying. I've tried -x and --one-file-system, but it still follows the bind mount.

HELP!

PS: I'm working on an uptodate (as of this writing) version of CentOS4.

Last edited by s2cuts; 11-02-2009 at 07:56 AM. Reason: Resolved
 
Old 10-31-2009, 02:30 PM   #2
wfh
Member
 
Registered: Sep 2009
Location: Northern California
Distribution: Ubuntu Debian CentOS RHEL Suse
Posts: 164

Rep: Reputation: 44
Quote:
Originally Posted by s2cuts View Post
I'm trying to figure out how to copy all files recursively from a certain point, but I need to avoid following a bind mount in that structure.

tar cf <path_to_source_dir> | tar xf - -C <path_to_new_dir>

Tar does not follow symbolic links by default.
 
Old 10-31-2009, 04:20 PM   #3
s2cuts
Member
 
Registered: Mar 2007
Posts: 61

Original Poster
Rep: Reputation: 18
Quote:
Originally Posted by wfh View Post
tar cf <path_to_source_dir> | tar xf - -C <path_to_new_dir>

Tar does not follow symbolic links by default.
Yeah, unfortunately symbolic links aren't the problem. The problem is a the hard link created through mounting another directory with the bind option. Maybe I wasn't clear.

The correct behavior can sort of be seen with "find /somewhere -mount". Here "find" will not follow hard links underneath /somewhere. I need to do the same thing with a recursive copy. Does anyone have any experience with the -x option of the cp command?
 
Old 10-31-2009, 04:39 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Most likely bind mounts are treated by cp as being on the same filesystem (as rsync does) so that the -x, --one-file-system option doesn't take effect. Using rsync instead, you can easily skip the bind mount point using an explicit --exclude option.
 
Old 11-01-2009, 02:49 AM   #5
wfh
Member
 
Registered: Sep 2009
Location: Northern California
Distribution: Ubuntu Debian CentOS RHEL Suse
Posts: 164

Rep: Reputation: 44
Quote:
Originally Posted by s2cuts View Post
The problem is a the hard link...Maybe I wasn't clear.
You were clear...I didn't focus. Sorry.

As colucix says, the --exclude directive might be your best bet.
 
Old 11-02-2009, 07:58 AM   #6
s2cuts
Member
 
Registered: Mar 2007
Posts: 61

Original Poster
Rep: Reputation: 18
I'm marking this thread solved because I don't think the cp command will do what I was asking. Also the solution suggested will do exactly what I needed it to do, that is use rsync with the --exclude option.

Thanks to all.
 
  


Reply

Tags
archive, cp


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Log file and command output archiving software harry edwards Linux - Server 2 11-01-2008 06:28 PM
Long Term File Archiving with Linux chaoswings Linux - Software 1 11-01-2008 06:24 PM
Is this possible (file archiving/tidying script) mrgreaper Linux - Newbie 3 07-25-2008 12:25 PM
which i386 rpm is the archiving command 'ar' found in?? newguy21 Programming 2 10-07-2004 11:32 AM
Ark (Archiving Tool) Problems blmartin777 Debian 5 04-29-2004 09:41 PM


All times are GMT -5. The time now is 05:36 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration