I've developed my own system for making full backups to cdr, and use perl of course. A problem arises when restoring to a blank system, in that there is no perl available to run the restore script. Well I was thinking about using a shell script (kind of clunky with strings), or a C program(since it's a pretty simple operation). Then I came across a node which pointed me to microperl, which comes with 5.8. It fills the bill! It is only 908k on my system, which easily fits on a cdrom. So with microperl and my 2 small scripts, I get a bootstrap perl restore system. The backup system relies on multi-volume tar archives, which are made for each second level sub-directory, then gunzipped and written to a ext2 image mounted via loop. When the image gets filled, it gets written to cdr, and the next iso is started. I delve 2 layers into /usr since it's so big. So I end up with a bunch of files named:
_etc-1.tar.gz _root-1.tar.gz _root-2.tar.gz _root-3.tar.gz _lib-1.tar.gz _lib-2.tar.gz _usr_lib-1.tar.gz _usr_lib-2.tar.gz etc.. etc..Now I just throw a copy of microperl, and my 2 scripts on to each cd, and I can boot with any floppy, mount my cd's and restore. Microperl dosn't do it all, and seems to have some small peculiarities compared to full perl. Notably, I needed to use `ls` and grep to simulate a glob or readdir.
First you make microperl, by "make -f Makefile.micro" in the perl58 distribution. The first thing I noticed was it didn't include alot of standard functions like opendir, so you need to use backticks and system alot. BUT you do get grep,arrays,hashes, and regexes; so it eliminates the need for awk,sed,expr, and the other apps usually needed by shell scripts. So it's actually a space saver at 908k. Also the system calls seemed to like double quotes, to pass parameters.
#!microperl #to substitute for a readdir or glob #I needed to ls then grep my @files = `ls`; @files = grep($_ =~ /.tar.gz$/,@files); foreach(@files){print "\ngunzipping->$_\n"; system("gunzip $_")} my @files = `ls`; @files = grep($_ =~ /.tar$/,@files); (@bases) = map{$_ =~ m/^(.*)-\d+.tar$/ }@files; print "@bases\n"; my %hash; $hash{$_}++ foreach (@bases); print "$_: $hash{$_}\n " foreach (sort {$hash{$a} <=> $hash{$b}} keys +%hash); foreach $basename (keys %hash){ #initialize first file if (-e "$basename-1.tar"){ $old= "$basename-1.tar"; $new= "$basename.tar"; rename $old,$new or warn $!; } #the restore-rotate.pl script just swaps files like they were tapes system ('tar','-x','-M',"-F ./restore-rotate.pl $basename","-f$basenam +e.tar"); unlink "$basename.tar"; #cleanup print "----------------------------------\n"; } system("mkdir proc"); system("mkdir tmp"); system("mkdir home"); exit;
update (broquaint): s{^#+$}(<hr/>)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: bootstrapping with microperl
by rob_au (Abbot) on Jan 18, 2003 at 23:17 UTC | |
by zentara (Cardinal) on Jan 19, 2003 at 14:27 UTC | |
by rob_au (Abbot) on Jan 19, 2003 at 21:08 UTC | |
by zentara (Cardinal) on Jan 20, 2003 at 13:28 UTC | |
|
Re: bootstrapping with microperl
by zentara (Cardinal) on Jan 20, 2003 at 19:34 UTC |