help required for passing parameters to rsync within a script - Tools

This is a discussion on help required for passing parameters to rsync within a script - Tools ; I'm attempting to write a short script to copy all 'CONC*' files in any subdir under ./ using rsync and filters but I can't get the correct quoting/escaping... any ideas? eg cmd line (all on a single line): /home/horace/mccssmb2/src/rsync-2.6.9__icc/rsync --times ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: help required for passing parameters to rsync within a script

  1. help required for passing parameters to rsync within a script

    I'm attempting to write a short script to copy all 'CONC*' files in any
    subdir under ./ using rsync and filters but I can't get the correct
    quoting/escaping... any ideas?

    eg cmd line (all on a single line):

    /home/horace/mccssmb2/src/rsync-2.6.9__icc/rsync --times --links -z
    --progress --stats -v -rP --filter='+ */' --filter='+ CONC*' --filter='-
    *' . michael@ratty.phy.umist.ac.uk:/data_hdd1/michael/`basename $PWD`


    but I can't see how to sort FILTER in this bash script such that + and
    */ all work properly... ta, Michael

    # cmd - need newer than system rsync
    RSYNC_EXE=${HOME}/src/rsync-2.6.9__icc/rsync
    RSYNC_CMDS='--times --links -z --progress --stats -v --dry-run -rP'
    # source top-level
    SRC=. # from here down
    # dest (remote)
    DEST=michael@ratty.phy.umist.ac.uk:/data_hdd1/michael/`basename $PWD` #
    ensure in same dir on remote

    # filter: all subdirs but only CONC* files
    FILTER="--filter=+ \* --filter=+ CONC\* --filter=- \*"
    echo $FILTER
    set -x
    ${RSYNC_EXE} ${RSYNC_CMDS} ${FILTER} ${SRC} ${DEST}


    --
    Please use reply-all for most replies to avoid omitting the mailing list.
    To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
    Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html


  2. Re: help required for passing parameters to rsync within a script

    On Tue, 2008-09-23 at 22:22 +0100, michael wrote:
    > I'm attempting to write a short script to copy all 'CONC*' files in any
    > subdir under ./ using rsync and filters but I can't get the correct
    > quoting/escaping... any ideas?


    > # filter: all subdirs but only CONC* files
    > FILTER="--filter=+ \* --filter=+ CONC\* --filter=- \*"
    > echo $FILTER
    > set -x
    > ${RSYNC_EXE} ${RSYNC_CMDS} ${FILTER} ${SRC} ${DEST}


    The trouble is that, when you expand ${FILTER} outside of double quotes,
    bash will split on all spaces in the value, which cuts each filter rule
    in two. To fix this, you can use an underscore instead of a space to
    separate the +/- symbol from the pattern, or you can switch to bash
    arrays as shown here (but omit the colon before "${COMMAND[@]}" !):

    http://lists.samba.org/archive/rsync...st/021580.html

    Matt

    --
    Please use reply-all for most replies to avoid omitting the mailing list.
    To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
    Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html


  3. Re: help required for passing parameters to rsync within a script

    On Tue, 2008-09-23 at 20:39 -0400, Matt McCutchen wrote:
    > On Tue, 2008-09-23 at 22:22 +0100, michael wrote:
    > > I'm attempting to write a short script to copy all 'CONC*' files in any
    > > subdir under ./ using rsync and filters but I can't get the correct
    > > quoting/escaping... any ideas?

    >
    > > # filter: all subdirs but only CONC* files
    > > FILTER="--filter=+ \* --filter=+ CONC\* --filter=- \*"
    > > echo $FILTER
    > > set -x
    > > ${RSYNC_EXE} ${RSYNC_CMDS} ${FILTER} ${SRC} ${DEST}

    >
    > The trouble is that, when you expand ${FILTER} outside of double quotes,
    > bash will split on all spaces in the value, which cuts each filter rule
    > in two. To fix this, you can use an underscore instead of a space to
    > separate the +/- symbol from the pattern, or you can switch to bash
    > arrays as shown here (but omit the colon before "${COMMAND[@]}" !):
    >
    > http://lists.samba.org/archive/rsync...st/021580.html


    aha, the underscore, rather than space, for +/- helped (missed that in
    the doc before... esp since there's no examples with it!)

    M

    --
    Please use reply-all for most replies to avoid omitting the mailing list.
    To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
    Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html


+ Reply to Thread