The `rsync` feature in Unix is incredibly efficient and useful for synchronizing files among different systems or in a single system. However, it doesn’t inherently support syncing only files modified after a specified date. For such instances, `find` command, which can locate files modified at/on/after/before a particular date, can be combined with `rsync` so your command becomes customized corresponding to your needs.
The `find` command possesses an option ‘mtime’ that allows you to find files that are n days older. For instance, the command `find /source/directory -mtime -1` will list all files from `/source/directory` that were modified within the last 24 hours. The ‘’ before ‘1’ indicates less than 1 day.
Here is an example of how to combine `rsync` and `find`:
```
find /source/directory -mtime -1 -exec rsync -R {} /destination/directory/ \;
```
In the given command:
- `/source/directory` is the directory where the files you want to sync reside.
- `-mtime -1` finds files modified within the last 24 hours
- `-exec` allows the passing of the found files to `rsync`.
- `-R` option instructs `rsync` to use relative file names. This ensures that the hierarchical structure between source and destination directories remains exact.
- `{}` is where `find` inserts the file name found into the `rsync` command.
- `/destination/directory/` is the directory where you want to transfer the files.
- `\;` informs `find` that the `-exec` command is concluded.
This combination (find and rsync) will sync only files that changed in the last 24 hours. However, ensure to adjust `-mtime -1` according to your requirements.
It should be carefully noted that this command won’t delete any files in the destination that were deleted from the source. If you want `rsync` to delete files at the destination no longer existing at the source, you will need to run a second `rsync` command with the `—delete` option. This will delete extraneous files from destination directories. Example:
```
rsync -a —delete /source/directory/ /destination/directory/
```
Remember: understanding and customizing `rsync` parameters to fit your needs are vital. So, check the manual page with `man rsync`, ‘man find’ to get more details about these commands.
Sources:
1. Rsnapshot (rsync utility exposure) – https://www.rsnapshot.org/
2. Unix find command with examples – https://www.geeksforgeeks.org/find-command-in-unix/
3. Using Rsync and SSH – https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps
4. Man page rsync command – https://linux.die.net/man/1/rsync
5. Man page find command – https://linux.die.net/man/1/find