There is a folder with copies of dir2 files (a lot of files), there is also a folder with the originals of these files dir1 . Sometimes, files located in the dir1 folder are modified, which are displayed in the file property (for example: changed on 12/16/2016 at 16:40). From time to time , a copy of all files from dir1 to dir2 is made , it takes a very long time. How to write a bash script that would check if the original file has changed in dir1 and rewrite it in dir2 , and the file that has not been changed - skip it? Can this be realized through normal cp ? I did not find a pass key in it, if the same "ON DATE OF CHANGE" files are found. Thank.
- If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky ♦
|
2 answers
|
You can use the rsync utility.
rsync -a / dir1 / / dir2
the first time will create an exact copy of the directory, all subsequent times will only copy files that have changed since the last synchronization
- you can add recursive copying and saving modifications --recursive --times - Hellseher
|