Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #8589

Re: rsync: exclude all, then include only specified, wildcard problems..

From dave.gma+news002@googlemail.com.invalid (Dave Gibson)
Newsgroups uk.comp.os.linux, comp.os.linux.misc
Subject Re: rsync: exclude all, then include only specified, wildcard problems..
Followup-To comp.os.linux.misc
Date 2013-06-25 19:23 +0100
Organization A noiseless patient Spider
Message-ID <bq3p9axde1.ln2@perseus.wenlock-data.co.uk> (permalink)
References <kpsi1n$37d$1@dont-email.me> <28rb9axqm3.ln2@perseus.wenlock-data.co.uk> <kqc7pd$d44$1@dont-email.me>

Cross-posted to 2 groups.

Followups directed to: comp.os.linux.misc

Show all headers | View raw


[ Followup-To: set to colm ]

In comp.os.linux.misc, David
<david@55952163-3189045.bogus.domain.invalid> wrote:
> Dave Gibson wrote, on 2013-06-20:
>> [ Followup-To: set to colm ]
> 
> [Noted, but I have un-set the followup,

Tin's quite naggy about setting the header when cross-posting.  I've
done it again, by the way.  Feel free to ignore it.

>>> --include='/webs/web1/php_includes/'
>>> --include='/webs/web1/php_snippets/'
>>> --include='/webs/web2/php/'

[ rsync -a --include=... --include=... src tgt ]

>> You have
>>
>>  "$SRCROOT"/webs/web1/php_includes/
>>  "$SRCROOT"/webs/web1/php_snippets/
>>  "$SRCROOT"/webs/web1/irrelevant_things
>>  "$SRCROOT"/webs/web2/php/
>>  "$SRCROOT"/webs/web2/something_to_be_ignored
>>  "$SRCROOT"/webs/other/stuff
>>
>> You want
>>
>>  "$DSTROOT"/webs/web1/php_includes/
>>  "$DSTROOT"/webs/web1/php_snippets/
>>  "$DSTROOT"/webs/web2/php/
> 
> 
> Sort of :-)
> 
> There should (for now), in $SRCROOT, only exist the three folders
> listed immediately above, and I want to be sure to sync *only* those
> into $DSTROOT.
>
> There may (probably unlikely, but possibly), inadvertently, be other
> files/folders that have found their way into $SRCROOT, and if so,
> these must somehow expressly *not* be synced.

If they're not named on rsync's command line they won't be synced.

My suggestion is to drop the use of --include and --exclude and to
specify the "include" subdirectories as sources to be sync'd (rather
than the whole $SRCROOT).

This

  rsync -a --include=/want/this --include=/and/thisone $SRCROOT/ $DSTROOT

Becomes

  rsync -a -R $SRCROOT/./want/this $SRCROOT/./and/thisone $DSTROOT


> I have to say, I didn't really understand the section of the manual
> about -R!! My previous uses of rsync have been rather simpler, and
> I didn't need to worry about it, one way or another.. :-(

When -R is used rsync will include the source's leading path in the
target rather than just the basename.

  rsync -a /a/b/c foo

copies "/a/b/c" to "foo/c"

  rsync -a -R /a/b/c foo

copies "/a/b/c" to "foo/a/b/c"

Using a './' in a source name tells rsync to retain only from that point
forward in the target name.

  rsync -R /a/./b/c foo

copies "/a/b/c" to "foo/b/c"

[snip]

>>   RS_INCLUDE=(
>>     --include='/webs/we 1/php includes/'
>>     --include='/webs/we 1/php snippets/'
>>     --include='/webs/web2/php/'
>>   )
>>   printf '%s\n' "${RS_INCLUDE[@]}"

> Thanks. I wasn't aware of shell arrays. Is this bash-specific or
> applicable to sh as well?

Not sh.  Bash, ksh93, zsh and mksh.  Possibly also openbsd's ksh.

> So, if I understand that correctly, each line inside the ( ..... ) is
> a separate entry in the array?

Each distinct string becomes an entry:

  a=( "first entry" "second entry"
      third )

  a[0]="first entry"
  a[1]="second entry"
  a[2]="third"

Back to comp.os.linux.misc | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-19 15:17 +0000
  Re: rsync: exclude all, then include only specified, wildcard problems.. Rikishi42 <skunkworks@rikishi42.net> - 2013-06-20 00:49 +0200
    Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-25 11:50 +0000
      Re: rsync: exclude all, then include only specified, wildcard problems.. Rikishi42 <skunkworks@rikishi42.net> - 2013-06-26 01:59 +0200
  Re: rsync: exclude all, then include only specified, wildcard problems.. Richard Kettlewell <rjk@greenend.org.uk> - 2013-06-20 10:16 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. The Natural Philosopher <tnp@invalid.invalid> - 2013-06-20 14:19 +0100
      Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-25 11:17 +0000
  Re: rsync: exclude all, then include only specified, wildcard problems.. Chris Davies <chris-usenet@roaima.co.uk> - 2013-06-20 10:57 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-25 11:40 +0000
      Re: rsync: exclude all, then include only specified, wildcard problems.. Chris Davies <chris-usenet@roaima.co.uk> - 2013-06-25 21:00 +0100
  Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-20 18:37 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-25 14:00 +0000
      Re: rsync: exclude all, then include only specified, wildcard problems.. Richard Kettlewell <rjk@greenend.org.uk> - 2013-06-25 15:24 +0100
      Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-25 19:23 +0100
  Re: rsync: exclude all, then include only specified, wildcard problems.. Chick Tower <c.tower@deadspam.com> - 2013-06-20 18:04 +0000
  Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-25 23:37 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-26 01:54 +0100
    Re: rsync: exclude all, then include only specified, wildcard problems.. David <david@55952163-3189045.bogus.domain.invalid> - 2013-06-28 16:12 +0000
      Re: rsync: exclude all, then include only specified, wildcard problems.. dave.gma+news002@googlemail.com.invalid (Dave Gibson) - 2013-06-29 01:30 +0100
      Re: rsync: exclude all, then include only specified, wildcard problems.. Chris Davies <chris-usenet@roaima.co.uk> - 2013-07-01 09:51 +0100

csiph-web