Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Sep 2002 20:19:14 +0200 (CEST)
From:      Oliver Fromme <olli@secnetix.de>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: automating backups of files
Message-ID:  <200209201819.g8KIJEOe039543@lurza.secnetix.de>
In-Reply-To: <200209201745.g8KHjZ521770@splat.grant.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Michael Grant <mg-fbsd3@grant.org> wrote:
 > I'd like to write something to automatically backup files as they
 > change on disk.  Perhaps not every byte, but say at reasonable
 > intervals and especially when a file is closed.
 > 
 > Does anyone know of any way I could get an indication in a userland
 > process when an arbitrary file has been opened, closed, or modified?
 > 
 > I can imagine a special device which I read which just feed me things
 > like:
 > 
 > /foo/bar  modified
 > /bar/baz  close

That's technically impossible, because such file system
operations don't happen on file names, but they happen on
file descriptors, which are tied to inodes.

An inode is an "object" on a filesystem which holds file
data.  It does not have a name, but only a number ("ls -i"
displays them in the first column).  An inode can have an
arbitrary number of names in the filesystem -- usually one,
but it can have zero (no name at all), two or more.

There are of course ways to insert your own code to watch
file system operations.  If you do that at the filesystem
level, you'll get inode numbers.  If you do it at the sys-
call level, you'll get PID and file descriptor numbers.

The latter could be achieved by hacking FreeBSD's ktrace(2)
facility, I guess.

 > So, I'd like to create something somewhat close.  What I want to do
 > today is backup a file in many different states rather than just once
 > per day.

That sounds like you want snapshots.  I know the snapshot
feature from NetApp files -- it is extremely useful.  It
enables you to have, well, virtual snapshots of the file
system at arbitrary intervals (say, every hour for the
last 12 hours, and daily for the last 2 weeks).  It has
very little overhead, because only copies of the same data
exist only once on the physical disk.

FreeBSD -current is supposed to support snapshots, too, but
I haven't tried those myself yet, so I don't know details.

 > I realize that there's going to be some overhead to do this, but I
 > suspect that the amount of overhead isn't going to be that much
 > greater than say using RAID to mirror.

Snapshots have almost zero overhead.

Regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"All that we see or seem is just a dream within a dream" (E. A. Poe)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200209201819.g8KIJEOe039543>