Gentoo Archives: gentoo-user

From: Stroller <stroller@××××××××××××××××××.uk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] kernel notification of file system changes
Date: Thu, 06 May 2010 14:22:22
Message-Id: 20F546DD-F224-40CD-A4C0-7782D1D1C2A4@stellar.eclipse.co.uk
In Reply to: Re: [gentoo-user] kernel notification of file system changes by Iain Buchanan
1 On 6 May 2010, at 00:51, Iain Buchanan wrote:
2 > ...
3 >>> ... Inotify has two drawbacks which make it hard or even impossible
4 >>> to use for Iain's use case:
5 >>>
6 >>> a) It does not work recursively which means that you have to
7 >>> create a
8 >>> new handle for each subdirectory. Of course, this only means more
9 >>> work
10 >>> for the programmer but there is also the problem that
11 >>
12 >> Pardon me. I assumed that "files inside the directory" meant that foo
13 >> would be be changed when foo/bar changed, thus monitoring grunt would
14 >> reflect changes in grunt/foo/bar. I overlooked that a directory is
15 >> not
16 >> a file.
17 >
18 > isn't it? I thought a directory was just a file containing names (or
19 > inodes) of other files? Which would explain why monitoring grunt
20 > wouldn't show changes in grunt/foo/bar, since the directory/file
21 > called
22 > grunt remains the same (ie. contains the same list of inodes) even if
23 > grunt/foo/bar changes.
24
25 But if bar changes, the modification time of foo changes, which is a
26 change in grunt. Apparently not. :(
27
28 > Let me tell you what I actually want to do, which I may not have made
29 > clear originally:
30 >
31 > I want to backup root to an external drive (or that could be rephrased
32 > as "I want to backup any mount to any other mount), such that:
33 > 1. My backup is an hour or so out of date (at most)
34 > 2. I don't need to copy the entire filesystem every time
35 >
36 > To do that, I could either:
37 > * Run rsync every hour over the entire filesystem (I'm doing this
38 > now with ionice, takes about 10 minutes when there are no
39 > changes)
40 > * Use some file notification monitor to tell me which file was
41 > just changed, and only rsync that file
42 >
43 > The problems with rsync is that during the rsync process, the
44 > filesystem
45 > is changing, so I will end up with a slightly inconsistent backup.
46
47 I really appreciate where you're coming from, as I have the same
48 concerns regarding the backing up of emails. I have systems with gigs
49 of email on them - belonging to myself and to others - and in the time
50 taken to rsync the lot, more mail is sure to have arrived. All one can
51 do is rsync regularly - then you're only an hour or so out of date.
52
53 > I'm considering LVM for it's snapshot capability, but I'd still have
54 > to
55 > rsync root.
56
57 Indeed, snapshotting is ideal.
58
59 > I would prefer a file notification method as well, so I can
60 > just rsync the file that just changed.
61
62 I think you're unrealistic to expect your backup to be uptodate to
63 within minutes or seconds. I don't really see the benefit of that, to
64 be honest. As far as I'm concerned I don't really care if /bin, /sbin
65 &c are backed up or not, because I can reinstall Gentoo in a couple of
66 hours. Here /etc does not generally change on a daily basis - more
67 like a backup from last month would be fine! Your milage may vary, but
68 I really don't see a day-old backup of /etc as a problem. So we are
69 really only down to /home which needs backing up as frequently as
70 hourly.
71
72 I assume that you're aware that "live" backups require multiple
73 copies. This is the RAID-is-not-a-backup argument - if a file becomes
74 corrupt you don't want it overwriting your backup copy.
75
76 Having said that you're "unrealistic" and that "I don't see the
77 benefit", I do appreciate where you're coming from. It's the answer
78 that us perfectionists want - it's the answer that all Linux users
79 want. And thus, if there were a clean and elegant solution then it
80 would be a well-trodden path. I think that if there was a clean and
81 elegant solution to "the perfect backup" everyone would know what it
82 was, and everyone would be using it, and you wouldn't even have to
83 ask. This is why I stopped reading your thread early.
84
85 Having said all that, if the stumbling block is snapshotting of your /
86 partition, you might take a look at btrfs - it looks like it allows
87 you to do this. brrfs is probably good enough now for everyday use, as
88 long as you have a backup, and I think you could reasonably easily
89 backup your snapshots on some regular basis to some other "safe"
90 filesystem, such as ext[234].
91
92 I find it slightly interesting that none of the ionotify solutions do
93 what you want. The point of such tools is to "do something when a file
94 is written or changed", so they would seem an ideal fit to solve the
95 "perfect backup problem" - in that context it would seem trivial to
96 write a kernel module / userspace app to write a copy of each changed
97 file to /path/to/backup/$UID and record some information about the
98 original filename, $UID and the time of change. I imagine that some
99 types of changes to files - such as bittorrent downloads, in which a
100 binary file may change like A___E -> A_C_E -> ABCDE - are more
101 difficult to handle than others, so this will be left to the reader as
102 a practical programming exercise.
103
104 Stroller.