LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   cp command, problems with archiving from only one file system... (https://www.linuxquestions.org/questions/linux-general-1/cp-command-problems-with-archiving-from-only-one-file-system-765834/)

s2cuts 10-31-2009 01:19 PM

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.

wfh 10-31-2009 02:30 PM

Quote:

Originally Posted by s2cuts (Post 3739312)
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.

s2cuts 10-31-2009 04:20 PM

Quote:

Originally Posted by wfh (Post 3739381)
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?

colucix 10-31-2009 04:39 PM

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.

wfh 11-01-2009 02:49 AM

Quote:

Originally Posted by s2cuts (Post 3739473)
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.

s2cuts 11-02-2009 07:58 AM

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.


All times are GMT -5. The time now is 01:51 AM.