Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

rsync issue

  • 08-07-2011 08:55PM
    #1
    Registered Users, Registered Users 2 Posts: 3,692 ✭✭✭


    I'm using rsync to copy files from a folder on my PC to an External Hard drive.
    I don't want to copy all the folders within the source folder so am using --exclude-from to exclude the sub-folders I don't want copied thus my command looks like this:
    rsync -avz /path_to_source_directory/  /path_to_target_directory/ --exclude-from list.txt
    
    where list.txt is a simple listing of the sub-folders I want rsync to ignore.

    However rysnc does ignore some of the sub-folders but not all. It continues to copy about half the folders across.
    Can anyone help figure out why this is happening?


Comments

  • Registered Users, Registered Users 2 Posts: 13,947 ✭✭✭✭Johnboy1951


    Only reason I can think of is that some of the paths are not complete or are somehow incorrect ....


  • Registered Users, Registered Users 2 Posts: 3,692 ✭✭✭DeepBlue


    I use the following to pipe out the directory list (and then manually delete from the list the folders I want to copy.)
    find . -maxdepth 1 -mindepth 1 -type d -printf %P\\n | sort -d >list.txt
    
    It shouldn't treat some folder names in a different fashion to others yet for some folders rsync recognises the pattern and excludes them and for others it doesn't. :confused:


  • Registered Users, Registered Users 2 Posts: 3,692 ✭✭✭DeepBlue


    Ok, slightly solved.

    The only difference between the sub-folders that weren't ignored as they should have been and the ones that were correctly ignored is that the ones that weren't ignored had a square bracket '' in the folder name. i.e. Holiday Photos [2007]
    For some reason this throws off the pattern matching. Once those were removed all the sub-folders were ignored correctly.

    Ideally I'd prefer not to have to rename the files so will continue looking for a solution rather than a workaround.


  • Registered Users, Registered Users 2 Posts: 13,947 ✭✭✭✭Johnboy1951


    I guess you could try quoting the filenames in the list or maybe the -s option would work ..... that was for spaces in names but it may work I suppose for the brackets ....


  • Registered Users, Registered Users 2 Posts: 3,692 ✭✭✭DeepBlue


    OSI wrote: »
    Did you remember to escape special characters?
    No, I didn't realise that '[' has a special meaning for rsync.

    I imagine that replacing the '[' with a '?' may allow rsync to copy the file.


  • Advertisement
  • Closed Accounts Posts: 18,966 ✭✭✭✭syklops


    DeepBlue wrote: »
    No, I didn't realise that '[' has a special meaning for rsync.

    I imagine that replacing the '

    No, just 'escape it' by putting a \ in front of it.


  • Registered Users, Registered Users 2 Posts: 3,692 ✭✭✭DeepBlue


    syklops wrote: »
    No, just 'escape it' by putting a \ in front of it.
    From brief testing both methods work. It's good to have choice. :D


Advertisement