Solutions for backup to CD-R

Drake Diedrich dld at
Sun Feb 16 17:41:20 EST 2003

   Did someone mention my script?  The config file is the script (don't
encrypt your backups to me, I won't be around to decrypt them..), and you
need to write the last CD by hand (I never did get around to fixing that,
though the comment near the bottom may work). Does cute dueling fifos to
keep tar from locking up and to avoid a race that I still don't think should
happen.  One argument: the directory to back up to CDs.  The backups are
compressed and encrypted.  A decompressor would be trivial to write on the
day you need it (please post me a copy when you do..).  A GUI too, if you
wouldn't mind.  :)  Just increase the blocksize to write DVDs ( I guess,
don't have a DVD writer here), or replace the mkisofs/cdrecord commands with
whatever is necessary to write files to you backup device (like those 1.1G
tape libraries).

   FIX: And I know I should not use fifos in /tmp, but I'm lazy, and it's
primarily for my laptop, not a multiuser system.  Someone should fix that
too, probably move them to ~/.fifo1 and ~/.fifo2

   Now, on to the reason I checked in: I'm in Tacoma, WA and just attended
the local Linux users group (TACLUG).  They want me to talk about yall next
month..  So, could someone shoot some pics at the next CLUG and send them to
me.  And I really need that photo with the glowing eyes of Rusty.  It'll
explain a lot. (Ed?) If anyone else has good photos you'd like to have

   The Seattlewireless group has their *own* (rented) clubhouse, permanently
wired, and weekly working meetings/monthly public meetings.  Meetings are
almost as packed as CLUG meetings, and all about wireless.  They're even
running a conference. I've already drilled a hole in my Jeep's roof and
permanently mounted a 5dBi antenna on it.  It's pouring right now (of
course) so this should be a good test of the O-ring seals.  I'm still
debating how to get a high gain directional in it, only NMO mounts are
waterproof (I hope at least), and configuring a 12V industrial PC with dual
PCMCIA slots (and the old battery isloator and a new deep cycle battery) to
keep them both active at all times.  If you're in Puget Sound, look for
signal going across the Narrows bridge, I should have the 12 dBi omni
covering that later this week.



use POSIX;

# user configurables, should make options or config file
my $cdsize = (360000-1000) * 2048;
# my $compress = "gzip -3 %*s";
my $encrypt = "gpg --always-trust -e -r Drake.Diedrich -z 0 --set-filename %s";
my $compress = "gzip -6";
my $mkisofs = "mkisofs -v";
my $device = "0,0,0";
my $cdrecord = "cdrecord  fs=2m dev=$device speed=8 -eject -v -";
my $buffer = "buffer -s 512k -m 4m -p 75";
my $dir = $ARGV[0];
#my $ext="tgz";
my $ext="gpg";
my $extar="tar";

my @fifo = ( "/tmp/fifo0","/tmp/fifo1");
my $length = 50000;  		# 10000 * 1K

$rv = mkfifo $fifo[0],0600;
if (!defined $rv) {
	print STDERR "$fifo[0] rv $rv\n";

$rv = mkfifo $fifo[1],0600;
if (!defined $rv) {
	print STDERR "$fifo[1] rv $rv\n";

sleep 1;

my $child=fork;

if ($child) {
	system("tar cvff $fifo[0] $fifo[1] --multi-volume --tape-length $length --new-volume-script /bin/true $dir");
	print STDERR "tar done\n";
	sleep 10;
	print STDERR "kill $child now\n";
	kill 15,$child;
} elsif (defined($child)) {
	my $cd=0;
	my $n=0;
	my $bytes=0;
	mkdir "cd";

	while (1) {
		my $file = sprintf("%08d.$ext",$n);
		my $fn = ($n & 1);
		sleep 1;
		print STDERR "writing $file\n";
		system(sprintf("$compress < $fifo[$fn] | $encrypt | $buffer > cd/$file",
		$bytes += (-s "cd/$file");
		if ($bytes > $cdsize) {
			$bytes = (-s "cd/$file");
			rename "cd/$file",$file;
			print STDERR "Insert CD and press Enter:\n";
			my $dummy = <STDIN>;
			system("$mkisofs cd | $buffer | $cdrecord");
			system("rm -rf cd");
			mkdir "cd";
			rename $file,"cd/$file";
} else {
	die "cannot fork: $!";

# this should write the last CD after tar finishes.  Maybe add another
# pause.  Would be smarter to delete the fifos, and detect that in the child
# (that there are no more pieces of multitarball).  untested -dld	
#			system("$mkisofs cd | $buffer | $cdrecord");
#			system("rm -rf cd");

print "unlink $fifo\n";
unlink $fifo[0];
unlink $fifo[1];

More information about the linux mailing list