© copyright 01.Oct.2004 by Paul Bradley filed under TAR
In a recent tutorial I demonstrated how to backup your data files using Tar, but what happens when the resulting file is too big to fit onto your chosen backup media (e.g. Zip disk or CD-ROM). Well you can use Tar to split up the file into manageable sizes that will fit onto your media, and span the file across multiple media volumes.
The two extra command line options you need to use over and above the standard syntax are
-M (--multi-volume) which tells Tar you want to split the file over multiple media disks. You then need to tell Tar how big that media is, so that it can create files of the correct size. To do this you use the
--tape-length option, where the value you pass is
number x 1024 bytes.
The example below shows the syntax used. Lets say the
largefile.tgz is 150 Meg and we need to fit the file on two 100 Meg Zip drives.
tar -c -M --tape-length=102400 --file=disk1.tar largefile.tgz
102400 is 1024 x 100, which will create a 100 Meg file called
disk1.tar and then Tar will prompt for volume 2 like below :-
Prepare volume #2 for disk1.tar and hit return:
In the time of tape drives you would have taken the first tape out of the machine and inserted a new tape, and pressed return to continue. As we want Tar to create the remaining 50 Meg in a separate file, we issue the following command :-
This instructs Tar to continue writing the remaining 50 Meg of
largefile.tgz to a file named
disk2.tar. You will then be prompted with the line below, and you can now hit return to continue.
Prepare volume #2 for disk2.tar and hit return:
You would repeat this process until your large file has been completely processed, increasing the disk number in the filename each time you are prompted.
The process is similar when putting the large file back together from its split-up files. Below is the syntax used to re-create the large file from the
C:\tar>tar -x -M --file=disk1.tar largefile.tgz Prepare volume #2 for disk1.tar and hit return: n disk2.tar Prepare volume #2 for disk2.tar and hit return:
About the Author
Paul Bradley is a VB.NET software developer living and working in Cumbria. He has over 20 years programming experience. He also produces e-learning videos at Linux by Example