What exactly will --delete-excluded do for rsync?
The --delete-excluded
option in rsync
specifies that you want to delete files from the destination that are excluded from the synchronization. It has a specific behavior when combined with the --exclude
option, which allows you to specify patterns or rules for excluding files or directories from the synchronization.
When you use --delete-excluded
with rsync
, the following happens:
- Exclusion Rules - You may have specified exclusion rules using the
-exclude
option in yourrsync
command. These rules define what files or directories should be excluded from the synchronization. - Synchronization -
rsync
performs the synchronization according to your command, including copying files and directories from the source to the destination. - Deletion - After the synchronization is complete,
-delete-excluded
comes into play. It instructsrsync
to go through the destination directory and delete any files or directories that were excluded in the source during the synchronization process.
This means that if there were files or directories in the destination that matched the exclusion rules set in the source, rsync
will remove them, effectively mirroring the exclusions from the source to the destination.
For example, if you have a command like this:
rsync -av --exclude='*.log' source_directory/ destination_directory/
And you use --delete-excluded
, any files with a .log
extension in the destination directory will be deleted if they exist there but are excluded from the source_directory.
Keep in mind that the --delete-excluded
option should be used with caution, as it can lead to data loss if not used carefully. Make sure your exclusion rules are well-defined and that you have a clear understanding of what will be deleted. Always take extra precautions when working with the --delete-excluded
option to avoid unintentional data loss.
-
How to keep the full path with rsync?
When using rsync to back up data, you can preserve the full directory structure of your source data by using the -a (or --archive) option. The -a option is a shorthand for several other rsync optio...
Questions -
Can I make rsync output only the summary?
Yes, you can make rsync output only a summary of the transfer by using the --stats option. This option provides a summary of the files transferred, the amount of data transferred, and the transfer ...
Questions
Make your mark
Join the writer's program
Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.
Write for usBuild on top of Better Stack
Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.
community@betterstack.comor submit a pull request and help us build better products for everyone.
See the full list of amazing projects on github