Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When syncing my remote backup I get the error rsync cannot delete non-empty directory.

I know the cause: I have excluded some files and when rsync tries to delete a remote directory because it doesn't exists locally, it can't since it is not empty. Without the exclusion the directory would be emptied.

I also know I could get rid of the problem by using --delete-excluded, but that is not want I want.

I would like to skip uploading certain files (because they are too big for my upload speed), but I want to keep those I have already uploaded some time ago if they exist locally. If they do not exist locally, they should be deleted. --delete-excluded would delete them all on the remote side.

That also means that if a directory doesn't exists anymore locally, it should be deleted even if it contains excluded files.

Is it possible to setup rsync to accomplish this?

share|improve this question

just use the '--max-size=xx' and '--delete' options of rsync. It will do everything automatically and meet all your requirements.

share|improve this answer
It would at most be a workaround. I want to skip mov, avi and cr2 files completely because they generally are very large. But those I have already uploaded on a faster line some time ago should be kept. Now the problem is that the largest JPG files are bigger than the smallest CR2 files, so this solution is not ideal. I would rather use the exclude feature to filter on filenames. – marlar Jan 30 '13 at 11:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.