The Samba-Bugzilla – Bug 3824
Max-delete with percentage
Last modified: 2006-10-15 13:11:08 UTC
Max-delete currently takes a number of files as a bound on deletions. Would be nice that if a % character is on this number, then we have max delete as a percentage of files on the deleting side to be removed (eg, rsync -a source::dir/ dest/ --max-delete=10%).
A percentage --max-delete would be difficult to implement. The generator would need to know the total number of files in the target directory in order to decide whether to delete or skip deleting the first extraneous file. The files could be counted in a separate pass during startup and deleted during the main pass, or they could be counted during the main pass for deletion in a separate pass at the end of the transfer.
Do you have a specific case in which a percentage --max-delete would be useful? If not, the above sounds like a lot of mess for a minor improvement.
Instead, a numeric max-delete could be calculated from a percentage outside of rsync using a find command:
rsync <options> src/ dest/ \
--max-delete=$(($(find dest/ -printf x | wc -c)*$percent/100))
It would take more work to omit files protected from deletion by filters from the total.
I'd rather not add this. Thanks for the idea, though.