Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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


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.