1 #!/usr/bin/perl
2 # Written by Michael Howe, in a desparate attempt to get tar to backup a 63GB
3 # partition onto a filesystem that has a maximum size of 4GB (FAT32, we hate
4 # you).
5 # Usage:
6 # Symlink 'file.tar' to 'file.00.tar'. Set $filename and $dir appropriately.
7 # Run tar:
8 # tar -tvM -F /path/to/script.pl -f ./file.tar # lists
9 # tar -xvM -F /path/to/script.pl -f ./file.tar # extracts
10 #
11 # NOTE: you should remove (or relink) file.tar after each operation, as it
12 # will be left pointing to the last file in the archive.
13 #
14 # IMPORTANT:
15 # This may well eat your data, and could also fry your hardware, or (worst
16 # case) lead to an alien invasion. I claim no responsibility - use at your
17 # own risk (and remember to backup).
18
19 use strict;
20 use warnings;
21
22 my $filename = "src";
23 my $dir = "/tmp/tartest";
24 my ( $cur, $num, $next );
25
26 if ( -l "$dir/$filename.tar" ) {
27 $cur = readlink( "$dir/$filename.tar" );
28 ( $num ) = $cur =~ m{.*$filename\.(\d+).*};
29 $num++;
30 unlink( "$dir/$filename.tar" ) or die "Can't unlink $dir/$filename.tar: $!";
31 } else {
32 $num = 0;
33 }
34 $next = sprintf( "%s/%s.%02d.tar", $dir, $filename, $num );
35 print "Continuing with archive $num\n";
36 symlink( $next, "$dir/$filename.tar" ) && exit 0;
syntax highlighted by Code2HTML, v. 0.9.1