Gentoo Archives: gentoo-user

From: Mick <michaelkintzios@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] How to exclude a directory from rsync
Date: Fri, 26 Nov 2010 18:29:49
Message-Id: 201011261828.07590.michaelkintzios@gmail.com
In Reply to: Re: [gentoo-user] How to exclude a directory from rsync by Renat Golubchyk
1 On Thursday 25 November 2010 21:51:36 Renat Golubchyk wrote:
2 > On Tue, 16 Nov 2010 23:01:51 +0000 Mick <michaelkintzios@×××××.com>
3 >
4 > wrote:
5 > > On Tuesday 16 November 2010 22:26:28 Stefan G. Weichinger wrote:
6 > > > Am 2010-11-16 22:24, schrieb Alan McKinnon:
7 > > > > Apparently, though unproven, at 23:12 on Tuesday 16 November
8 > > > > 2010, Mick did
9 > > > >
10 > > > > opine thusly:
11 > > > >> Excellent, it worked! :-)
12 > > > >
13 > > > > Glad to hear it.
14 > > > >
15 > > > > I could help because part of my job is running a rather big
16 > > > > public ftp mirror that management graciously pay for. And I went
17 > > > > down this rsync road a long time ago myself.
18 > > > >
19 > > > > You have no idea how many brain cells died in agony to figure out
20 > > > > this specific piece of rsync behaviour :-)
21 > > >
22 > > > ;-)
23 > > >
24 > > > I would like to know if my suggestion also works ;-)
25 > > >
26 > > > Yeah, include/exclude-patterns are rather hard to figure out
27 > > > sometimes ... nearly like regexes -> write once, read never ....
28 > >
29 > > Ha, ha! True!
30 > >
31 > > Stefan, I tried escaping the spaces (even tried \\ double and \\\
32 > > triple escapes in case it makes a difference because of using ssh)
33 > > but still did not work. In my head I couldn't see how the full path
34 > > would not work, but the relative path would, but I tried it out all
35 > > the same.
36 > >
37 > > I still don't understand why Alan's recommendation works ;-)
38 >
39 > I'm probably late with my reply, but I'll post it so it will be in the
40 > archives for future reference.
41 >
42 > The man page is actually pretty clear on this issue. Quote:
43 >
44 > if the pattern starts with a / then it is anchored to a particular
45 > spot in the hierarchy of files, otherwise it is matched against the
46 > end of the pathname. This is similar to a leading ^ in regular
47 > expressions. Thus "/foo" would match a name of "foo" at either the
48 > "root of the transfer" (for a global rule) or in the merge-file’s
49 > directory (for a per-directory rule). An unqualified "foo" would
50 > match a name of "foo" anywhere in the tree because the algorithm is
51 > applied recursively from the top down; it behaves as if each path
52 > component gets a turn at being the end of the filename. Even the
53 > unanchored "sub/foo" would match at any point in the hierarchy
54 > where a "foo" was found within a directory named "sub".
55 >
56 > "Root of the transfer" is the directory you want to sync. Thus, if you
57 > run e.g. "rsync /var/log/ /mnt/backups/ --exclude=/portage/" then root
58 > of the transfer is /var/log, and therefore the directory
59 > /var/log/portage will be excluded. If on the other hand you write
60 > --exclude=portage/ then a directory named portage anywhere in the tree
61 > under /var/log will be excluded. Without the trailing slash, i.e. just
62 > --exclude=portage any file (regular file, directory, link, whatever)
63 > named portage anywhere in the tree gets excluded. And finally
64 > --exclude=/portage would exclude a file only at the top of the tree that
65 > is going to be synchronsed.
66 >
67 > Hope it helps.
68
69 Yes it does! Thank you, it's clear to me now why it behaved so.
70
71 --
72 Regards,
73 Mick

Attachments

File name MIME type
signature.asc application/pgp-signature