Re: Finding the size of directory with multiply hardlinked files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2008-03-14 at 21:00 -0700, Dean S. Messing wrote:
> Patrick O'Callaghan wrote:
> > On Thu, 2008-03-13 at 19:48 -0700, Dean S. Messing wrote:
> > > I have a sequence of directories that have many multiply
> > > (cross)hardlinked files, and I'd like to see what their
> > > "true" sizes are.  These dirs are backup directories
> > > created with something like:
> > > 
> > > rsync -a --delete --link-dest=/mnt/bkup/backup_A/ \
> > >       /dir_to_back_up /mnt/bkup/backup_B/
> > > 
> > > By "true" sizes I mean this:
> > > 
> > > Say backup_A was created first.  If I do `du_true
> > > backup_A' I shd. see its size.  Now I delete some files
> > > in "/dir_to_back_up" and create some other new files.
> > > Now I create "backup_B" with the above rsync command.  I'd
> > > like for my mythical `du_true' to compute the
> > > incremental change in size from backup_A to backup_B.
> > > 
> > > This seems like a non-trivial problem but maybe I'm just
> > > missing something simple.
> > 
> > What's wrong with "subtract 'du -s backup_B' from 'du -s backup_A'"?
> 
> I don't think this works for what I want.  If backup_A and backup_B
> happened to be the same size but each file in each directroy was
> linked just once, your solution would give back 0 when, in fact, the
> amount of space occupied by the the two directories is their sum.
> 
> I think the solution requires simultaneous knowledge of both
> directories so that two files, one in backup_A and one in backup_B
> that are hardlinked together are counted just once.

You're right of course. In fact just after posting I thought "shouldn't
that be (du A+B)-(du A)?" but then I saw Roberto's solution so I left it
at that.

> > If this isn't what you mean, then you need to explain it better. The
> > concept of files being "in" a directory is just a convenient fiction.
> > Both backup_A and backup_B are just sets of hard links.
> 
> Appologies if I wasn't clear.  The post by Roberto Ragusa in this
> thread gives both the solution and a clear idea of what I was looking
> for.  Apparantly `du' has the smarts to figure out differential
> directory sizes, although it's not clear from the man page.

Believe it or not I actually experimented with this, but it didn't seem
to give the right result. I must have been half asleep because I just
tried it again and it does indeed work. Neat trick.

poc


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux