Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I use the following command to copy data and it is working as expected.

cp -pr --reply=yes /db-nfs/mysql3/* /db-nfs/mysql5/

1) Is there a better way?

2) I want to copy the same data to /db-nfs/mysql7 as well. Is it possible in single command?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

If you are repeatedly copying the same data over to the folders rather than a one time copy to a blank target, consider using rsync instead:

rsync -av /db-nfs/mysql3/ /db-nfs/mysql5/
rsync -av /db-nfs/mysql3/ /db-nfs/mysql7/

(Note the trailing slashes are important!)

share|improve this answer

1) This won't preserve hard links and extended attributes, so you may be better off using -a instead of -p.

2) Depends what you mean by a single command! You could write a script which runs multiple cp commands and then that script itself would be a single command.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.