rsync: cannot delete non-empty directory


sonofdbn

Recommended Posts

I'm trying to use rsync to backup from one unRAID server to another, just using the terminal. I've mounted the destination share using Unassigned Devices, and the command is basically:

rsync -avP --delete /mnt/user/Nextcloud/username/files/ /mnt/remotes/Backup_server/Nextcloud/username/files

 

It largely works, but I ran into a problem with an error message saying "cannot delete non-empty directory". Previously I had backed up a sub-directory a few levels down in a folder called custom_banners/__MACOSX (if this looks familiar it's from SpaceInvader). I subsequently deleted this sub-directory on my main server, and now when I run the rsync command above I get the non-empty directory error message, saying it can't delete this directory and its sub-directories.

 

I tried --delete-during as a parameter, but that didn't make a difference.

 

I also get some error messages like this:

rsync: [receiver] rename "/mnt/remotes/Backup_server/Nextcloud/username/files/Documents/2021/moroccan-flower/__MACOSX/._moroccan-flower.jM0wjF" -> "Documents/2021/moroccan-flower/__MACOSX/._moroccan-flower": No such file or directory (2)

 

When I check the destination server, that directory does exist, so not sure what's happening here. I don't know if it's just coincidental that both issues involve a "__MACOSX" directory.

 

I think what I'm trying to do is quite simple; I'm not doing anything with Nextcloud when running rsync - and I've tried various times and always get the same issues with the same files and directories.

 

How can I fix this?

Link to comment

I don't have a definitive answer, but I think the problem might have been self-inflicted. I deleted the MACOSX folder on the server, rather than on the PC, and since the files were still on the PC, Nextcloud might have tried to sync them back before the rsync. Hence the files, or maybe temporary Nextcloud sync ones, were still there in the directory on the server, and some files there were still synced to the backup by rsync, resulting in the non-empty directories that couldn't be deleted.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.