From dean-list-rdiff-backup@arctic.org Sat May 11 11:28:50 2002 From: dean gaudet To: rdiff-backup@keywest.Stanford.EDU Subject: script for determining space consumed by increments X-comment: visit http://arctic.org/~dean/legal for information regarding copyright and disclaimer. List-Subscribe: , List-Archive: Date: Sat, 11 May 2002 11:23:45 -0700 (PDT) here's a script i wrote which can find out what directories are taking up space in an increment... useful for determining what you may want to exclude from future backups. it's similar to du, except not sorted in any particular order... i usually run it something like: incdu /home/backup/twinlark/root 2002-05-09T01:38:39-07:00 | sort -nr -dean #!/usr/bin/perl -w # hack of a script to print the amount of disk space used # by a particular rdiff-backup increment # # -- dean gaudet # XXX: could get this from the filesystem my $blocksize = 4096; use strict; if ($#ARGV != 1) { die "usage: $0 rdiff-backup-mirror-dir timestamp\n"; } my $mirror = shift; my $timestamp = shift; -d "$mirror/rdiff-backup-data/increments" or die "$mirror/rdiff-backup-data/increments does not exist\n"; -f "$mirror/rdiff-backup-data/increments.$timestamp.dir" or die "$mirror/rdiff-backup-data/increments.$timestamp.dir does not exist\n"; # i could do this more efficiently -- it's only necessary to # keep sizes for the ancestors of the current directory... # but i was lazy. my %du; open(FIND, "-|") || exec 'find', "$mirror/rdiff-backup-data/increments", '-depth', '-regex', ".*$timestamp\.[a-z.]+", '-printf', '%s %P\n'; while () { my ($size, $dir) = m#^(\d+) (.*)/[^/]+\.$timestamp\.[a-z.]+$#o; # ignore the .dir files in the toplevel next unless defined($dir); # round size up to the next block $size = $blocksize * (($size + ($blocksize-1)) / $blocksize); $dir = "/$dir"; do { if (!defined($du{$dir})) { $du{$dir} = 0; } $du{$dir} += $size; ($dir) = ($dir =~ m#^(.*)/[^/]+$#); } while (defined($dir)); } # nicer view of the top-level component $du{'/'} = $du{''}; delete $du{''}; my $dir; foreach $dir (keys %du) { print "$du{$dir}\t$dir\n"; } _______________________________________________ Rdiff-backup mailing list Rdiff-backup@keywest.Stanford.EDU http://keywest.Stanford.EDU/mailman/listinfo/rdiff-backup From dean-list-rdiff-backup@arctic.org Sat May 11 11:28:50 2002 From: dean gaudet To: rdiff-backup@keywest.Stanford.EDU Subject: Re: script for determining space consumed by increments X-comment: visit http://arctic.org/~dean/legal for information regarding copyright and disclaimer. List-Subscribe: , List-Archive: Date: Sat, 11 May 2002 11:27:22 -0700 (PDT) p.s. on linux, this script, and rdiff-backup will run faster if you mount your backup partition with the "noatime" mount option. i know other unixes have similar options, but i don't know the syntax. noatime disables the update of atime every time a file is accessed -- it causes vast amount of disk write traffic to update metadata when you are iterating over an entire filesystem. _______________________________________________ Rdiff-backup mailing list Rdiff-backup@keywest.Stanford.EDU http://keywest.Stanford.EDU/mailman/listinfo/rdiff-backup