How to copy a hidden directory recursively and preserving its permissions

command linecpfiles

mkdir backupcache    
cp -rp .cache backupcache # or cp -rp \.cache backupcache does not work

nothing gets copied and directory backupcache remains empty

Best Answer

Don't specify the files or Directory

Lets say you created the new folder (or are going to create one) and want to copy the files to it after the folder is created

mkdir /test/folder
cp -rp /path/to/copy/. /test/folder

This will copy all files/folder recursively from /path/from/copy in to the already existing folder created on the first line.

Another approach is tar. For example:

$cd foo
$tar cf - . | tar -C /path/to/bar -x

Using rsync :

rsync -av src dest
Related Question