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?
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.
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!)