3 # Do an incremental backup. We are invoked by full if the tape
4 # description file says that it is for an incremental backup.
5 # We expect a single commandline argument which is the ID string
10 require "$etc/settings.pl";
11 require 'backuplib.pl';
19 print "Running incremental (tape $tapeid) ...\n" or die $!;
21 # Just check that we weren't passed a bogus ID (the tape description
22 # file for incrementals is just 'incremental\nend\n')
23 open T,"$etc/tape.$tapeid" or die "Tape $tapeid not found: $!\n";
26 # This is only used for the 'next FULL backup is X' message at the end.
27 open NF,"next-full" or die $!;
31 setstatus "FAILED during incremental";
33 # Read the number of the incremental involved
34 # (ie, (how many files are already on the tape) - 1)
35 open A,"increm-advance" or die $!;
39 # better be a decimal number
40 $advance =~ m/^\d+$/ or die "$advance ?";
42 # Rewind the tape and if we are the first incremental on the tape then
43 # write the TAPEID record, otherwise skip forward to the correct point.
44 # (full will already have checked that this is the right tape before
45 # it invoked us, so no need to read the existing TAPEID record first.)
46 system "mt -f $ntape rewind"; $? and die $?;
48 open TI,">TAPEID" or die $!;
49 print TI "$tapeid" or die $!;
52 system "tar -b$blocksize -vvcf TAPEID.tar TAPEID"; $? and die $?;
53 system "dd if=TAPEID.tar of=$ntape bs=${blocksize}b count=10"; $? and die $?;
55 system "mt -f $ntape fsf $advance"; $? and die $?;
58 # Get a list of all filesystems
63 close(DUMPOR); close(BUFOR);
64 close(DUMPOW); close(BUFOW);
67 setstatus "PROBLEMS during incremental dump";
71 pipe(DUMPOR,DUMPOW) or die $!;
72 pipe(BUFOR,BUFOW) or die $!;
75 print "Not dumping $atf ($prefix) - not \`dump'.\n" or die $!;
76 print LOG "Not dumping $atf ($prefix) - not \`dump'.\n" or die $!;
79 # Same trick as full uses to do a pipeline whilst keeping track
80 # of all exit statuses:
81 # dump </dev/null | writebuffer | dd >/dev/null
82 startprocess '</dev/null','>&DUMPOW',$rstr."dump 1bfu $softblocksizekb - $atf";
83 startprocess '<&DUMPOR','>&BUFOW','writebuffer';
84 startprocess '<&BUFOR','>/dev/null'
85 ,"dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape";
88 # advance is a file counter, so it needs to be updated for each
93 # Rewind the tape, and increment the counter of incremental backups.
94 system "mt -f $tape rewind"; $? and die $?;
95 open IAN,">increm-advance.new" or die $!;
96 print IAN "$advance\n" or die $!;
98 rename 'increm-advance.new','increm-advance' or die $!;
100 print LOG "Next FULL dump tape is $next\n" or die $!;
101 print "Next FULL dump tape is $next\n" or die $!;
103 setstatus "INCREMENTAL successful (next full is $next)";