Rsync is a command line utility that provides fast and flexible file copying. It is commonly used for mirroring directories and synchronising backup servers. However, in certain situations, users may wish to sync only deleted files. To execute this, you must manipulate Rsync’s options cleverly. But it is important to note that while Rsync can help manage and recover deleted files, it does not inherently synchronize based solely on deletion.
To provide a workaround for this, you can utilize Rsync with the —delete option along with other options. The —delete option is used in Rsync to delete the files in the receiver side which don’t exist in the sender side.
Here is an example of Rsync command using —delete:
`rsync -av —delete source_directory/ destination_directory/`
In this case, ‘source_directory/’ is the directory which you want to sync, and ‘destination_directory/’ is the directory where you want to sync the source\_directory. The ‘-av’ option stands for ‘archive mode’ and ‘verbose’, where ‘archive mode’ ensures that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the sync, and ‘verbose’ provides detailed information of the operations performed.
Rsync checks between the source directory and destination directory, and any file that is in the destination directory but not in the source directory will be deleted, to make both directories identical.
Gary Sims explains on Gary Explains YouTube channel and Network World about the Rsync command and its options. For understanding directory synchronisation and file transfer basics, Rene Rubalcava explains clearly on O’Reilly Media.
However, ensure that you have backups and use this command judiciously, because if used incorrectly, it can result in unwanted file deletion. For instance, if there are files in the destination directory that you do not want deleted, but those files do not exist in the source directory, those files will be deleted when this command is run.
All these information are grounded on the Rsync man page, which is the most authoritative source when it comes to using the Rsync command. Hence, it is recommended to go through the man page thoroughly which provides detailed options and their usage examples before executing commands.
Sources:
1. “Rsync (Remote Sync): 10 Practical Examples of Rsync Command in Linux”. Tecmint.
2. Gary Sims. “How to use rsync command in Linux”, GaryExplains, YouTube.
3. Rene Rubalcava. “Directory Synchronization with Rsync”. O’Reilly Media.
4. Rsync man page.