Rdiff-backup-size
From RdiffBackupWiki
This script is useful for estimating the size of backups when the source machine has many files.
For instance, if you're backing up a mail server that uses maildir format for mailboxes and the mail queue, rdiff-backup tends to make so many small increment and .dir files that listing the directory takes hours and causes commands like du and rdiff-backup --list-increment-sizes to eat all the available RAM.
Note that this script does not take into account filesystem overheads, so it is most effective on partitions that are devoted solely to being rdiff-backup targets (to work out what fraction of the total space is used by each machine backing up to there).
#!/usr/bin/perl
#usage: either give a directory that's an rdiff-backup target, as in
#rdiff-backup-size /home/backup/somemachine
#or just run it with no arguments and it'll use the current directory
$dir = shift @ARGV;
if ($dir) {
chdir($dir);
}
chdir("rdiff-backup-data");
$size_changes = `grep TotalDestinationSizeChange session_statistics* | gawk '{sum += \$2} END {printf("\%i",sum)}'`;
chomp $size_changes;
$last_stats_file = `ls session_statistics* | tail -n1`;
chomp $last_stats_file;
$mirror_size = `grep MirrorFileSize $last_stats_file`;
chomp $mirror_size;
@_ = split / / , $mirror_size;
$mirror_size = $_[1];
printf("Approx. \%0.f bytes\n", $mirror_size + $size_changes);
