1832780 Members
3150 Online
110045 Solutions
New Discussion

copy files question..!?

 
SOLVED
Go to solution
Warren_9
Honored Contributor

copy files question..!?

Hi,

I would like to copy all the files in the root filesystem "/" to a new directory, and which need to exclude the /stand, /var, /opt ...etc.

i.e. /etc --> /new/etc, /bin --> /new/bin and /.profile --> /new/.profile

any idea?

Warren

4 REPLIES 4
Robert-Jan Goossens_1
Honored Contributor
Solution

Re: copy files question..!?

Hi Warren,

# cd /
# mkdir new
# find . -xdev | cpio -pcmudv /new

the -xdev option will prevent find to cross looking on other filesystems.

Regards,
Robert-Jan
Joakim Brosten
Frequent Advisor

Re: copy files question..!?

Hi Warren,

1 - mkdir /new
2 - cd /
3 - tar -cf --exclude /stand --exclude /var --exclude /opt . | (cd /new && tar -xvf -)

Instead of repeating option "--exclude", you can create a file with the files and directories you want to exclude (exclude.lst) and use option "-X exclude.lst".

This makes a tar ball directed to stdout, piped to stdin and un-tared after change to directory "new".

Good luck! /JB
Warren_9
Honored Contributor

Re: copy files question..!?

Hi JB,

I tried you method but it created a "--X" file in the source dir and didn't copy any file.
I cannot find the tar option exclude OR -X...

following is my command, and
# cd /tmp/test/source
# tar -cf --X exclude.lst . | (cd /tmp/test/target | tar -xf -)

thanks,
Warren
Warren_9
Honored Contributor

Re: copy files question..!?

thx for the reply!!