How to copy directories and their contents in Linux
Yesterday evening I did a fatal mistake where do modifications to the website but are simply by doing a backup copy directory only. My assumption with "cp name_dir" never mind enough and if there is a problem staying direname or restored the contents. It turns out wrong. Somehow I miss if there is a warning message "cp: omitting directory 'name_dir' " and because of this I know that by default not all contents are included.
Somewhat fatal circumstance, and just what am doing (update site manually) partial fail. Automatically for an hour I tried to restore from a backup source more. Fortunately successful and functioned normally.
In conclusion my method wrong and I forget if there are additional parameters on his orders. If you want to do the same thing then we need to execute with parameters:
cp -R dir_from dir_to
Where the parameter "-R" meaning is recursive. If the folder does not exist it will be created automatically. Thank so just the end.
And there is also the alternative:
cp -a dir_from/. dir_to/
Where the parameter "-a" similar to the above but the parameter file attributes will still be kept as the original. And the point at the end of file indicates the location of the hidden will be copied as well.
Of course the name is not a Linux if no solution is not the standard. Use rsync can create local:
rsync -r dir_from/* dir_to
And I just realized it when it used to be the way I have ever discussed at a glance but his name rarely used eventually forget. I discussed this time also more explained.