Penguin

Differences between current version and previous revision of TarNotes.

Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History

Newer page: version 3 Last edited on Tuesday, October 14, 2003 12:26:06 pm by AristotlePagaltzis
Older page: version 2 Last edited on Tuesday, October 14, 2003 10:56:50 am by MichaelBordignon Revert
@@ -1,29 +1,22 @@
-!!Multiple Tar Files  
+!!! Multivolume [TarBall]s  
  
-Sometimes it is necessary to split a tar archive over several volumes, or files. 
+Sometimes it is necessary to split a TarBall into several files, ie volumes . The simplest approach is to use split(1):  
  
-If you specify several archive files, tar will use them in the order given . Try something like this:  
+ tar cvzf - dirs/ | split --bytes 1m - archive. tar.gz.part-  
  
- tar -c -L 50000 -f archive1 -f archive2 -f archive3 ... path  
+Should you need to, you can achieve this goal without split(1) using tar(1)'s __ -L__ switch, which sets a volume size limit. While the poorly organized info page for tar(1) mentions this, the man page contains no hint that you must also specify a list of filenames for tar(1) to use by passing more than one __ -f__ switch:  
  
-Be sure to specify enough archive files to hold the entire data
+ tar c -L 50000 -f archive1 -f archive2 -f archive3 [[ ... ] path/  
  
-You won 't find this use of multiple -f options mentioned in the  
-man page , but it is in the info page. (You have to hunt around  
-to find it, though--the GNU tar info page is poorly organized.)  
-  
-Here is my crackin bash script to backup stuff into 1gig volumes
+Make sure to specify enough archive files to hold the entire data. If you don 't want to be bothered with math the computer can do for you , this script should help
  
  #!/bin/bash 
+ VOL_SIZE_KB=1000000  
+ BASENAME=archive  
  
- cd /test/archive/  
- each_archivesize =1000000  
- totalkbytes=` du -s . | cut -d "." -f 1`  
- num _volumes =`expr $totalkbytes / $each _archivesize + 1`  
- tar_args=`for i in $(seq 1 $num_volumes ) ; do echo -n "-f archive$i.tar "; done`  
-  
- tar -cvL $each_archivesize $tar_args --totals *  
+ TOTAL =$( du -s . | cut -d $'\t' -f 1 )  
+ NUM _VOLUMES =$(( $TOTAL / $VOL _SIZE_KB + 1 ))  
  
-Another approach is to use split, ie  
+ tar cv -L $VOL_SIZE $( seq -f "-f $BASENAME-%03g.tar" 1 $NUM_VOLUMES_KB ) --totals *  
  
-$ tar cvzf - dirs | split --bytes=1m - archive .tar.gz.part-  
+The example will create 1GB [TarBall]s of the current directory named __archive -*__