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

Re: [Sheflug] Scripting backups to cdrom.y



On Wed, Jun 18, 2003 at 02:54:04PM +0100, Rob Keeling wrote:
> Ah, I can follow your logic, but I have no idea how to write said scripts.

Well, script 1 would be something like:

#!/usr/bin/perl 
use strict;
use warnings;

my $home_dir = '/home';

opendir (HOMES, $home_dir) or die "Cannot read from /home..";
my @homes = grep { $_!~/\./; } readdir (HOMES);
closedir (HOMES);

sub return_size {
	my ($size) = @_;
	my ($num, $quan) = ($size =~ /^(\d+)([KMG])/);
	$num *= 1000 if ($quan eq 'G');
	$num /= 1000 if ($quan eq 'K');
	return $num;
}
my ($cdrom, $size) = (1);

print "CDROM$cdrom\n";
foreach my $home ( [at] homes) {
	my $size = `du -hs
	my ($dir_size) = ($size =~ /^(\d+[KMG])/);
	my $meg_size = return_size ($dir_size);
	if (($size + $meg_size) > 700) {
		# adding this home would overflow a CD
		$size = $meg_size;
		$cdrom++;
		print "CDROM$cdrom\n";
	} else {
		# we're okay to just add this 
		$size += $meg_size;
	}
	print "$home_dir/$home\n";
}

As for the making of ISOs, I could probably do it, but don't know the format
of the mkisofs command (don't have any burners here ;)

Some Perl person on this list could probably do it if sufficiently poked.
Alternatively, you could tell me the arguments to mkisofs ;)

Cheers,

Alex.
___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.