Help - Search - Members - Calendar
Full Version: How to tar to individual smaller .tar files
The Planet Forums > Operating Systems > Red Hat Linux > Red Hat HOWTOs
z0diac
I'm backing up my httpdocs directory to back up my web site, but is there a tar command that will put the archive into say 1GB individual tar files isntead of just one huge (12GB) file?

I tried the tar help from the command line but couldn't see anything on it ??
xerophyte
man split
man cat

you can make the big tar file and split and then join them together

hope that helps
z0diac
Nice - works great! Now, it creates its own filenames (xaa, xab, xac, etc) with no extensions. I did a man split but it doesn't seem to say anything about joining them back together... the file that was split was a .tar file

(??)
James Jhurani
to put them back together just consecutively cat them into one file

ex:

cat xaa >> file.tar
cat xab >> file.tar
cat xac >> file.tar

then untar... i suggest trying this once before depending on it... there may be easier
ways, but i wouldnt trust
cat xa* >> file.tar to do it in order... if its out of order then the file will be corrupt.

-James
Catalyst
CODE
for $FILE in `ls x??`; do cat $FILE >> filename.tar; done


Let's do one better ...

CODE
tar -zc filename.tar.gz /some/path/and/mask | split -b1024m - filename.tar.gz.
Now it'll make "filename.tar.gz.??" instead of just x??. A little more unwieldly to work with, and they're compressed to boot.

Decompression will work a little better that way, as well --- at least you know what you're trying to decompress.
z0diac
QUOTE (Catalyst)
CODE
for $FILE in `ls x??`; do cat $FILE >> filename.tar; done

 
Let's do one better ...  
 
CODE
tar -zc filename.tar.gz /some/path/and/mask | split -b1024m - filename.tar.gz.
Now it'll make "filename.tar.gz.??" instead of just x??. A little more unwieldly to work with, and they're compressed to boot.
 
Decompression will work a little better that way, as well --- at least you know what you're trying to decompress.


Hmm.. the latter just made 2 large files.. (I thought it would split them into 1GB files).

I'm in a subdir just above httpdocs, which I have the subdirs httpdocs and backup, and am using the command..

tar -zc backup/web.tar.gz httpdocs | split -b1024m - backup/web.tar.gz

basically I want a bunch of 1GB files here:

backup/web1.tar.gz
backup/web2.tar.gz
backup/web3.tar.gz
..etc... each 1GB in size

(??)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.