BACKUP
======
+devices as well as mountpoints
+read/writebuffer buggy ?
+
would be nice someday
---------------------
+gz increms only
replace loaded with idformat
read/writebuffer setuid --mlock
whatsthis no cloneandhack
require IO::File;
+$nice='nice ' if !defined $nice;
+
sub printdate () {
print scalar(localtime),"\n";
}
# to be in $tf.
sub parsefsys () {
my ($dopts,$dopt);
- if ($tf =~ m#^(/\S*)\s+(\w+)([,0-9a-z]+)$#) {
+ if ($tf =~ m#^(/\S*)\s+(\w+)([,=0-9a-z]*)$#) {
# Line of form '/file/system dumptype[,options]'
$atf= $1;
$tm= $2;
stat $atf or die "stat $atf: $!";
-d _ or die "not a dir: $atf";
$rstr= '';
- } elsif ($tf =~ m#^(/\S*)\s+(\w+)([,0-9a-z]+)\s+(\w+)$#) {
+ } elsif ($tf =~ m#^(/\S*)\s+(\w+)([,=0-9a-z]*)\s+(\w+)$#) {
# Line of form '/file/system dumptype[,options] prefix'
# (used for remote backups)
$atf= $1;
$dopt{$dopt}= 'y';
} elsif ($dopt =~ m/\=/ && grep { $` eq $_ } qw(gz)) {
$dopt{$`}= $';
- } else {
- die "unknown option $dopt";
+ } elsif (length $dopt) {
+ die "unknown option $dopt (in $dopts $tf)";
}
}
+
+ if ($dopt{'gz'} eq 'y') {
+ $gz= '1';
+ } elsif ($dopt{'gz'} =~ m/^\d$/) {
+ $gz= $dopt{'gz'};
+ } elsif (defined $dopt{'gz'}) {
+ die "$tf bad gz";
+ } else {
+ $gz= 0;
+ }
}
sub openlog () {
sub closepipes () {
close(DUMPOR); close(TEEOR); close(BUFOR); close(FINDOR);
close(DUMPOW); close(TEEOW); close(BUFOW); close(FINDOW);
+ close(GZOR); close(GZOW);
}
# work out a find option string that will exclude the required files
# For each filesystem to be put on this tape:
for $tf (@fsys) {
printdate();
+ parsefsys();
+
pipe(FINDOR,FINDOW) or die $!;
pipe(DUMPOR,DUMPOW) or die $!;
pipe(TEEOR,TEEOW) or die $!;
+ pipe(BUFOR,BUFOW) or die $!;
+
$bufir='TEEOR';
+ $ddcmd= "dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape";
- if ($dopt{'gz'} eq 'y') {
- $gz= '3';
- } elsif ($dopt{'gz'} =~ m/^\d$/) {
- $gz= $dopt{'gz'};
- } elsif (defined $dopt{'gz'}) {
- die "$tf bad gz";
- } else {
- $gz= 0;
- }
if ($gz) {
$bufir='GZOR';
pipe(GZOR,GZOW) or die $!;
+ $ddcmd .= " conv=sync";
}
- pipe(BUFOR,BUFOW) or die $!;
- parsefsys();
-
# We can back up via dump or cpio or zafio
+ $dumpin= '</dev/null';
if ($tm eq 'dump') {
$dumpcmd= "dump 0bfu $softblocksizekb - $atf";
- $dumpin= '</dev/null';
} elsif ($tm eq 'cpio') {
startprocess '</dev/null','>&FINDOW',$rstr."find $atf -xdev -noleaf -print0";
$dumpcmd= "cpio -Hustar -o0C$softblocksizebytes";
# don't use verbose flag as this generates 2MB report emails :->
$dumpcmd = "afio -b $softblocksizebytes -Zo -";
$dumpin = '<&FINDOR';
+ } elsif ($tm eq 'ntfsimage') {
+# fixme have to find device rather than mountpoint (atf is mountpoint)
+ $dumpcmd= "ntfsimage -vvf --dirty $atf";
} else {
die "unknown method $tm for $prefix:$atf\n";
}
# to the exit status of all the commands in the pipeline.
# It is roughly equivalent to:
# md5sum <p >>this-md5sums
- # dump <$dumpin | tee p | writebuffer | dd >/dev/null
- startprocess '<p','>>this-md5sums','md5sum';
- startprocess $dumpin,'>&DUMPOW',$rstr.$dumpcmd;
- startprocess '<&DUMPOR','>&TEEOW','tee p';
+ # dump <$dumpin | tee p [| gzip] | writebuffer | dd >/dev/null
+ startprocess '<p','>>this-md5sums',"$nice md5sum";
+ startprocess $dumpin,'>&DUMPOW',"$nice ".$rstr.$dumpcmd;
+ startprocess '<&DUMPOR','>&TEEOW',"$nice tee p";
if ($gz) {
- startprocess '<&TEEOR','>&GZOW','gzip -v$gz';
+ startprocess '<&TEEOR','>&GZOW',"$nice gzip -v$gz";
}
- startprocess "<&$bufir",'>&BUFOW','writebuffer';
- startprocess '<&BUFOR','>/dev/null'
- ,"dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape";
+ startprocess "<&$bufir",'>&BUFOW',"$nasty writebuffer";
+ startprocess '<&BUFOR','>/dev/null',"$nasty $ddcmd";
closepipes();
endprocesses();
}
open S,"this-md5sums" or die $!;
for $tf (@fsys) {
printdate();
+ parsefsys();
chomp($orgsum= <S>); $orgsum =~ s/\ +\-?$//;
$orgsum =~ m/^[0-9a-fA-F]{32}$/i or die "orgsum \`$orgsum' ?";
- chomp($csum= `dd if=$ntape ibs=$blocksizebytes | readbuffer | md5sum`);
+ $cmd= "$nasty dd if=$ntape ibs=$blocksizebytes";
+ $cmd .= " | $nasty readbuffer";
+ $cmd .= " | $nice gzip -vd" if $gz;
+ $cmd .= " | $nice md5sum";
+ print LOG " $cmd\n" or die $!;
+ print " $cmd\n" or die $!;
+ chomp($csum= `$cmd`);
$csum =~ s/\ +\-?$//;
$orgsum eq $csum or die "MISMATCH $tf $csum $orgsum\n";
print "checksum ok $csum\t$tf\n" or die $!;
for $tf (@fsys) {
+ parsefsys();
+
+ $bufir='DUMPOR';
+ $ddcmd= "$nasty dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape";
+
pipe(DUMPOR,DUMPOW) or die $!;
pipe(BUFOR,BUFOW) or die $!;
- parsefsys();
- if ($tm ne 'dump') {
+
+ if ($gz) {
+ $bufir='GZOR';
+ pipe(GZOR,GZOW) or die $!;
+ $ddcmd .= " conv=sync";
+ }
+
+ if ($tm eq 'dump') {
+ $dumpcmd= "dump 1bfu $softblocksizekb - $atf";
+ } else {
print "Not dumping $atf ($prefix) - not \`dump'.\n" or die $!;
print LOG "Not dumping $atf ($prefix) - not \`dump'.\n" or die $!;
next;
# Same trick as full uses to do a pipeline whilst keeping track
# of all exit statuses:
# dump </dev/null | writebuffer | dd >/dev/null
- startprocess '</dev/null','>&DUMPOW',$rstr."dump 1bfu $softblocksizekb - $atf";
- startprocess '<&DUMPOR','>&BUFOW','writebuffer';
- startprocess '<&BUFOR','>/dev/null'
- ,"dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape";
+ startprocess '</dev/null','>&DUMPOW',"$nice ".$rstr.$dumpcmd;
+ if ($gz) {
+ startprocess '<&DUMPOR','>&GZOW',"$nice gzip -v$gz";
+ }
+ startprocess "<&$bufir",'>&BUFOW',"$nasty writebuffer";
+ startprocess '<&BUFOR','>/dev/null',"$nasty $ddcmd";
closepipes();
endprocesses();
# advance is a file counter, so it needs to be updated for each
run things on a remote machine:
prefix <prefix-name> <command-part>
Other lines should be of the form
- <directory name> <backup-type>
- for local backups, or
- <directory name> <backup-type> <prefix-name>
+ [<device name>:]<directory name> <backup-type>[,<options>]
+ for local backups, or
+ [<device name>:]<directory name> <backup-type>[,<options>] <prefix-name>
for remote backups.
The file (including any included files) must end with the word 'end'
on a line of its own.
Valid values for <backup-type> are `cpio' (uses cpio to produce
tar-format backups), `dump' (uses dump to dump entire filesystems;
-<directory name> should be a mount-point for this), and `zafio' (uses
-afio to compress each file as it is backed up). Only `dump' type
-backups perform incremental backups.
+<directory name> should be a mount-point for this), `zafio' (uses afio
+to compress each file as it is backed up), and `ntfsimage' (for NTFS
+volumes, requires device name). Only `dump' type backups perform
+incremental backups.
+
+<options> is a comma-separated list of <option> or <option>=<value>.
+The only currently support option is gz[=<compressionlevel>], to
+indicate that the whole stream should be compressed with gzip. The
+compression level defaults to 1.
expected-diffs is a config file to indicate which
filesystems should *not* be backed up. The scripts do a config
chiark-utils (3.0.3.99) unstable; urgency=low
* chiark-backup: full dumps have tapedesc in TAPEID
+ * compression support (gz as a style option).
+ * $nice and $nasty in settings.pl.
- -- Ian Jackson <ian@davenant.greenend.org.uk> Mon, 5 May 2003 17:09:40 +0100
+ --
chiark-utils (3.0.3) unstable; urgency=low