rsync -aAX --exclude='*' src_dir/ dst_dir
where dst_dir - is a target dir. Or:
rsync -dADXgot src_dir dst_dir
where dst_dir - is a dir containing target dir, or a non-existing target dir.
From rsync man page:
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
--exclude=PATTERN exclude files matching PATTERN
-d, --dirs transfer directories without recursing
-p, --perms preserve permissions
-A, --acls preserve ACLs (implies -p)
-X, --xattrs preserve extended attributes
-o, --owner preserve owner (super-user only)
-g, --group preserve group
--devices preserve device files (super-user only)
--specials preserve special files
-D same as --devices --specials
-t, --times preserve modification times
-r
, so it is ignoring directories. But I guess you want to copy only the attributes, not the contents? I can think of only ugly hacks. Also note thatinstall
can preserve SELinux contexts.