Help Rsync cannot delete non-empty directories on NAS

Discussion about using NAS on Linux and Unix OS.
Post Reply
Budgie
Know my way around
Posts: 242
Joined: Wed Feb 27, 2008 7:57 am

Help Rsync cannot delete non-empty directories on NAS

Post by Budgie »

I am using rsync to copy over multimedia files from linux workstation to my Qnap NAS TS-559 Pro II. I have been editing many of the files within album directories and deleting some. I am getting the error messages "cannot delete empty directory," which would be OK except that when I go to the directories in question using NAs web interface and File Station, the directories are empty. I thought perhaps there were hidden files like thumbnails causing the problem but the directories show empty even with "show hidden files" enabled.

What is happening and how may I overrule this behavior please?

Budgie
User avatar
OneCD
Guru
Posts: 12163
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Help Rsync cannot delete non-empty directories on NAS

Post by OneCD »

Budgie wrote:I am using rsync to copy over multimedia files from linux workstation to my Qnap NAS TS-559 Pro II. I have been editing many of the files within album directories and deleting some. I am getting the error messages "cannot delete empty directory," which would be OK except that when I go to the directories in question using NAs web interface and File Station, the directories are empty. I thought perhaps there were hidden files like thumbnails causing the problem but the directories show empty even with "show hidden files" enabled.
Martin Höger wrote:Did you try to add --delete-excluded?

Message cannot delete non-empty directory happens easily if delete a directory on the source side and then you want to run rsync --delete. Rsync will not let you delete the excluded files in the directory.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
Budgie
Know my way around
Posts: 242
Joined: Wed Feb 27, 2008 7:57 am

Re: Help Rsync cannot delete non-empty directories on NAS

Post by Budgie »

OneCD wrote:
Budgie wrote:I am using rsync to copy over multimedia files from linux workstation to my Qnap NAS TS-559 Pro II. I have been editing many of the files within album directories and deleting some. I am getting the error messages "cannot delete empty directory," which would be OK except that when I go to the directories in question using NAs web interface and File Station, the directories are empty. I thought perhaps there were hidden files like thumbnails causing the problem but the directories show empty even with "show hidden files" enabled.
Martin Höger wrote:Did you try to add --delete-excluded?

Message cannot delete non-empty directory happens easily if delete a directory on the source side and then you want to run rsync --delete. Rsync will not let you delete the excluded files in the directory.
Hi and many thanks for your quick reply. I am a bit out of my depth here but believe I understand your suggestion. However here is my command line:-

Code: Select all

rsync -h --progress --stats -r -tgo -p -D --update --delete-after --filter=protect .@__thumb --delete-excluded --exclude=**/*tmp*/ --exclude=**/*cache*/ --exclude=**/*Cache*/ --exclude=/mnt/*/** --exclude=/media/*/** --exclude=**/lost+found*/ --exclude=/var/run/** --exclude=/run/** --exclude=/proc/** --exclude=/dev/** --exclude=/sys/** --exclude=**/*Trash*/ --exclude=**/*trash*/ --exclude=.@__thumb --protect-args /home/alastair/mastermedia/Music/ admin@192.168.169.130:/share/Multimedia/Music/
You can see --delete-excluded is there so I don't know what to try next. All suggestions gratefully received.
User avatar
OneCD
Guru
Posts: 12163
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Help Rsync cannot delete non-empty directories on NAS

Post by OneCD »

Budgie wrote:

Code: Select all

rsync -h --progress --stats -r -tgo -p -D --update --delete-after --filter=protect .@__thumb --delete-excluded --exclude=**/*tmp*/ --exclude=**/*cache*/ --exclude=**/*Cache*/ --exclude=/mnt/*/** --exclude=/media/*/** --exclude=**/lost+found*/ --exclude=/var/run/** --exclude=/run/** --exclude=/proc/** --exclude=/dev/** --exclude=/sys/** --exclude=**/*Trash*/ --exclude=**/*trash*/ --exclude=.@__thumb --protect-args /home/alastair/mastermedia/Music/ admin@192.168.169.130:/share/Multimedia/Music/
You can see --delete-excluded is there so I don't know what to try next. All suggestions gratefully received.
I've not used filters myself (never had to), so I may be entirely wrong on this, but I think your argument syntax needs to be changed. I'm looking at the section of your argument string immediately preceding the --delete-excluded option.

Code: Select all

--filter=protect .@__thumb
Every example I've seen of filter shows single-quotes around the filter rule. e.g.

Code: Select all

--filter='protect .@__thumb'
Only a wild guess here - maybe your current syntax is affecting rsync's (or getopts) parsing of the argument string? So it's not seeing the --delete-excluded part? :wink:

Suggest trying it with single quotes as shown. :geek:

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
Budgie
Know my way around
Posts: 242
Joined: Wed Feb 27, 2008 7:57 am

Re: Help Rsync cannot delete non-empty directories on NAS

Post by Budgie »

Hi, and thanks. No time right now but surely command is filter=protect so single quotes should go thus:- '.@_thumb'
Will try it as soon as I get time.
Thanks again,
Budgie
User avatar
OneCD
Guru
Posts: 12163
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Help Rsync cannot delete non-empty directories on NAS

Post by OneCD »

Budgie wrote:No time right now but surely command is filter=protect so single quotes should go thus:- '.@_thumb'
Nope, the literal quotes need to include the whitespace char. ;)

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
Budgie
Know my way around
Posts: 242
Joined: Wed Feb 27, 2008 7:57 am

Re: Help Rsync cannot delete non-empty directories on NAS

Post by Budgie »

But not, afaik the word protect which must be before the quote.
User avatar
OneCD
Guru
Posts: 12163
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: Help Rsync cannot delete non-empty directories on NAS

Post by OneCD »

Budgie wrote:But not, afaik the word protect which must be before the quote.
(sigh!) :roll:

http://www.computerhope.com/unix/rsync.htm
--filter ’protect emptydir/’
--filter='dir-merge /.rsync-filter'
--filter='- .rsync-filter'
http://blog.mudflatsoftware.com/blog/20 ... ter-rules/
--filter='P /some/dir'
--filter='-p .DS_Store'
--filter='H /some/dir'
https://lists.samba.org/archive/rsync/2 ... 16178.html
--filter='+ /rsync-filter' --filter=': ./rsync-filter'
http://serverfault.com/questions/150269 ... with-rsync
--filter='+ /var/' \
--filter='+ /var/backups/' \
--filter='- /var/*' \
I picked four Google results at random from the first search results page for "rsync filter syntax" (something you could have done).

I think it would be easier (and a lot less typing for both of us) if you just tried your rsync again with the single quotes as I suggested. :geek:

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
Budgie
Know my way around
Posts: 242
Joined: Wed Feb 27, 2008 7:57 am

Re: Help Rsync cannot delete non-empty directories on NAS

Post by Budgie »

Hi and apologies, I stand corrected. Can't try it now as I have sorted problem directories one at a time using File Station web controls. I found it was only a few but I have more editing to do in future so will try it then.
Many thanks again.
Post Reply

Return to “Linux & Unix (NFS)”