LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-02-2009, 02:18 PM   #1
alkos333
Member
 
Registered: Dec 2006
Posts: 271

Rep: Reputation: 31
Can't remove non-empty directory with rsync


So here's a little rockbox synchronization script that I have come up with:

Code:
#!/bin/bash 

# Copyright (c) 2008  alkos333 <me@alkos333.net>
# All rights reserved. 
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
#   notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


SOURCE="/home/me/media/music/"
DESTINATION="/mnt/ipod/music"


# Synchronizing just the music files (mp3 and ogg in my case)
rsync -vrptgou --delete --force --modify-window=1 --exclude="cover.*" "$SOURCE" "$DESTINATION"

# Find all covers and run a conversion function on them
find "$SOURCE" -type f -name cover.jpg -print0 | while read -d $'\0' jpg_cover
do
        echo "Checking $jpg_cover"
        
        # Convert jpeg cover path to bmp path
        bmp_cover=${jpg_cover##$SOURCE}
        bmp_cover=${bmp_cover%.*}
        bmp_cover="$DESTINATION/$bmp_cover.bmp"


        # Check if bmp cover exists and if it's up-to-date
        if [ ! -f "$bmp_cover" ] || \
                [ \( $( stat --printf=%Y "$jpg_cover" ) -gt $( stat --printf=%Y "$bmp_cover" ) \) ]
        then
                # Convert to 100x100 bmp cover if either condition fails
                convert "$jpg_cover" -resize 100x100 "$bmp_cover"       
                echo "  --> Converting and saving to $bmp_cover"
        fi
done
For some reason rsync complains that it can't delete non-empty directories despite the fact that there is a recursive flag, --delete and --force supplied as well.

If I change the --exclude to "cover.jpg" since all covers are in jpg on my laptop, then it's not complaining. Looks like all of bmp covers which are present on my ipod are ignored thoughout despite delete and force flags. How do I around this?

Last edited by alkos333; 01-02-2009 at 02:24 PM.
 
Old 01-02-2009, 03:39 PM   #2
jiobo
Member
 
Registered: Nov 2008
Posts: 180

Rep: Reputation: 36
You have mounted the ipod. What mount options are you using? What permissions?
 
Old 01-02-2009, 05:16 PM   #3
alkos333
Member
 
Registered: Dec 2006
Posts: 271

Original Poster
Rep: Reputation: 31
Well it removes the files alright if I don't user the --exclude flag with "cover.*"

Here's what the problem is. I tell rsync to exclude the cover.* files because I take care of them afterward. However, when rsync wants to remove certain directory which no longer exist in SOURCE (due to --delete flag), it can't because they contain cover.bmp in them which are covered by the --exclude pattern.

Here's the entry for /mnt/ipod in fstab:

Code:
/dev/ipod               /mnt/ipod       vfat            noatime,noauto,user,umask=077,shortname=winnt           0       0

Basically, I want rsync to leave cover.bmp files alone, but if it's removing a directory that no longer exist in the source directory, I want it removed along with cover.bmp even though it's supposed to be excluded. I thought --force would get that done, but apparently it isn't working :/

Last edited by alkos333; 01-02-2009 at 05:18 PM.
 
Old 01-18-2009, 11:15 PM   #4
Red Squirrel
Senior Member
 
Registered: Dec 2003
Distribution: Kubuntu 20.04 on workstation, CentOS 6.x on servers
Posts: 1,181

Rep: Reputation: 47
I'm having the exact same issue. This is my script:

Code:
sourcepath="/raid1/applications/remote/ravagerapplications/RunUO/aovalor_test/"


datefile=`date +%a`
pathname="/raid1/backups/servers/ravager/${datefile}_daily/"


mkdir -p ${pathname} > /dev/null
#mkdir -p ${pathname2} > /dev/null


#backup to cur directory

rsync -rbuv --delete-after ${sourcepath}backups ${pathname}
rsync -rbuv --delete-after ${sourcepath}data ${pathname}
rsync -rbuv --delete-after ${sourcepath}scripts ${pathname}
rsync -rbuv --delete-after ${sourcepath}runuo_core ${pathname}

umount /mnt/ravager_applications/ >/dev/null 2>&1

date > ${pathname}date.txt
It's weird as I've never had this issue before, it just started today. Doing this over a sshfs connection that is connecting to a mount.cifs mount on a remote server. (can't do mount.cifs directly as there is a NAT)
 
Old 01-19-2009, 12:04 AM   #5
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 2,482

Rep: Reputation: 1103Reputation: 1103Reputation: 1103Reputation: 1103Reputation: 1103Reputation: 1103Reputation: 1103Reputation: 1103Reputation: 1103
You can use --delete-excluded BUT that might not be what you want.
 
Old 01-20-2009, 06:31 PM   #6
alkos333
Member
 
Registered: Dec 2006
Posts: 271

Original Poster
Rep: Reputation: 31
--delete-excluded removes all of cover.bmp files and I want those excluded unless the folder they are in is being removed entirely because let's say that album/artist has been removed from my source directory
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rm: cannot remove directory `ff': Directory not empty blancs Linux - General 17 08-29-2011 01:47 PM
Remove a non-empty directory nc3b Programming 13 08-14-2007 03:34 AM
Command to remove a non-empty directory ? wlaw Linux - General 6 10-23-2006 10:02 AM
How do you remove a non empty directory aaronruss Linux - Newbie 3 06-05-2004 08:26 PM
RMDIR - how to remove a non-empty directory?? jacksmash Linux - Newbie 15 11-23-2003 12:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration