Date: Wed, 17 Dec 2008 11:37:04 +0100 From: Bernard Dugas <bernard@dugas-family.org> To: Mel <fbsd.questions@rachie.is-a-geek.net> Cc: freebsd-questions@freebsd.org Subject: Re: Extracting changed files list from snapshot Message-ID: <4948D650.8040603@dugas-family.org> In-Reply-To: <200812170947.12794.fbsd.questions@rachie.is-a-geek.net> References: <4947B8AB.7000304@dugas-family.org> <200812170947.12794.fbsd.questions@rachie.is-a-geek.net>
next in thread | previous in thread | raw e-mail | index | archive | help
Mel wrote: > On Tuesday 16 December 2008 15:18:19 Bernard Dugas wrote: >>I want to extract the list of files changed between 2 snapshots, to be >>able to do efficient backups. > > Just use dump(8)? Yes in first step, may be. But for fast replication of changes ? Imagine i have a 1TB drive with 1 partition on serverA, and i want it duplicated on another 1TB drive serverB, with 1Gbps network between them, so network speed is not a problem. I begin with dump or any copy mean to have the 2 drives having the partitions in the same state, from a first "snapshot image 0" which is the reference on serverA, made with mksnap_ffs. A user change only 1 small file on serverA. After 1mn, i create "snapshot0+1" file on serverA. To find the files changed on serverA between snapshot0 and snapshot0+1, any current dump or equivalent will have to read all file records of 1TB partition, inside snapshot0+1 complete view of partition, to find 1 changed file. Even on nice day, it may take more than 1mn. But the beauty and efficiency of snapshot concept is that snapshot0 file (internal structure) contains a reference to all data blocks changed between snapshot0 and snapshot0+1 : this is why a snapshot file is so small and efficient. It is certainly possible to find in snapshot0 file inside structure the list of blocks changed until snapshot0+1 was made, and then find which file is the owner of the changed blocks. Then it will appear that only 1 file has been changed on whole partition and we just have to send this changed file from snapshot0+1 view to serverB. So using the internal structure of snapshots file is far more efficient than reading all directory records for last change time... Please note that i try to use the expressions "snapshot file" and "snapshot view" very cautiosly, because they don't mean the same at all :-) > And what snapshots do you mean? As in mksnap_ffs? Cause that's described > in /usr/src/sys/ufs/ffs/ffs_snapshot.c: > 127 TAILQ_HEAD(snaphead, inode); > 128 > 129 struct snapdata { > 130 struct snaphead sn_head; > 131 daddr_t sn_listsize; > 132 daddr_t *sn_blklist; > 133 struct lock sn_lock; > 134 }; > 135 > > and not exposed to userland. Thanks, this is a good hint ! Just needing some doc and help to understand how to use it : i'm more in design now, programmation skills are far away :-( Best regards, -- Bernard DUGAS Mobile +33 615 333 770
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4948D650.8040603>