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 two commandline argument which is the ID string
6 # of the tape to use, and the description (which includes ID
11 require "$etc/settings.pl";
12 require 'backuplib.pl';
18 ($tapeid,$tapedesc)= @ARGV;
20 print "Running incremental onto $tapedesc ...\n" or die $!;
22 # Just check that we weren't passed a bogus ID (the tape description
23 # file for incrementals is just 'incremental\nend\n')
24 open T,"$etc/tape.$tapeid" or die "Tape $tapeid not found: $!\n";
27 # This is only used for the 'next FULL backup is X' message at the end.
28 open NF,"next-full" or die $!;
32 setstatus "FAILED during incremental";
34 # Read the number of the incremental involved
35 # (ie, (how many files are already on the tape) - 1)
36 open A,"increm-advance" or die $!;
40 # better be a decimal number
41 $advance =~ m/^\d+$/ or die "$advance ?";
43 # Rewind the tape and if we are the first incremental on the tape then
44 # write the TAPEID record, otherwise skip forward to the correct point.
45 # (full will already have checked that this is the right tape before
46 # it invoked us, so no need to read the existing TAPEID record first.)
47 system "mt -f $ntape rewind"; $? and die $?;
49 open TI,">TAPEID" or die $!;
50 print TI "$tapeid\n$tapedesc\n" or die $!;
53 system "tar -b$blocksize -vvcf TAPEID.tar TAPEID"; $? and die $?;
54 system "dd if=TAPEID.tar of=$ntape bs=${blocksize}b count=10"; $? and die $?;
56 system "mt -f $ntape fsf $advance"; $? and die $?;
59 # Get a list of all filesystems
64 close(DUMPOR); close(BUFOR);
65 close(DUMPOW); close(BUFOW);
68 setstatus "PROBLEMS during incremental dump";
72 pipe(DUMPOR,DUMPOW) or die $!;
73 pipe(BUFOR,BUFOW) or die $!;
76 print "Not dumping $atf ($prefix) - not \`dump'.\n" or die $!;
77 print LOG "Not dumping $atf ($prefix) - not \`dump'.\n" or die $!;
80 # Same trick as full uses to do a pipeline whilst keeping track
81 # of all exit statuses:
82 # dump </dev/null | writebuffer | dd >/dev/null
83 startprocess '</dev/null','>&DUMPOW',$rstr."dump 1bfu $softblocksizekb - $atf";
84 startprocess '<&DUMPOR','>&BUFOW','writebuffer';
85 startprocess '<&BUFOR','>/dev/null'
86 ,"dd ibs=$softblocksizebytes obs=$blocksizebytes of=$ntape";
89 # advance is a file counter, so it needs to be updated for each
94 # Rewind the tape, and increment the counter of incremental backups.
95 system "mt -f $tape rewind"; $? and die $?;
96 open IAN,">increm-advance.new" or die $!;
97 print IAN "$advance\n" or die $!;
99 rename 'increm-advance.new','increm-advance' or die $!;
101 print LOG "Next FULL dump tape is $next\n" or die $!;
102 print "Next FULL dump tape is $next\n" or die $!;
104 setstatus "INCREMENTAL successful: $tapedesc, next full is $next";