Sometimes we need to duplicate a directory with subfolders into a new location on the same server and we have to make sure that these directories are exactly the same.
Normally – but not best – we use the cp -pr command.
The result is that our softlinks aren’t links anymore and the timestamps of some directorys are not the same as they are in the source directory. To partially solve this, you can use tar to create an archive and untar it in the destination – the better way is a combination of find and cpio. You will be save to get all files and directories with links, timestamps and rights in destination like they are in the source location.
example:
change to the directory you want to copy from and invoke the following command
find . -depth -print | cpio -pdmv /destination/