I'm attempting to find and copy files that have been modified within the last day. While doing that I'm trying maintain folder structures under dir1. There are many subdirectories under dir1 and data files within those.
Below is what I cobbled together so far but apparently mtime is not updated on directories if the contents of a file is updated. Also I believe this cp command will copy all of the files in a directory rather than just those that have changed.
find /NAS/data/dir1 -type d -mtime -1 -exec cp -at /mnt/databackup/dir1 {} +
If I used -type f it would not retain the folder structure.
rsyncthe tool you're really looking for?rsyncis the simpler and more robust solution here. And I wouldn't rely onmtime(and file size) and use option--checksumeven if it takes longer.