rsync cannot delete non-empty directory

I had a rsync backup script that suddenly came with the error message:
cannot delete non-empty directory

This reason why this error occurs is that a dir is deleted or renamed on the source AND you are using the option --exclude.

The solution is to add the option --delete-excluded.

As the manuals says:
--delete-excluded also delete excluded files from dest dirs