LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Creating multivolume archives using tar (https://www.linuxquestions.org/questions/programming-9/creating-multivolume-archives-using-tar-419761/)

sharathksin 02-26-2006 12:59 PM

Creating multivolume archives using tar
 
Here is my problem,
I want to create a multivolume archive using tar.I want each volume to be of specific size.
for example if I have 1.5 GB file and if I want 650MB volumes of tar archive how to do that?
All these has to be done from a shell script, please guide me

CroMagnon 02-26-2006 10:46 PM

You could look into the split command...

for example:
tar c [files to tar] | split -b 681574400 - archivepiece

would create 650MB files called archivepieceaa, archivepieceab etc etc. You can use -d to split to tell it to use 01, 02 instead of aa, ab, and -a to specify how long the suffix should be.

sharathksin 02-27-2006 12:26 AM

Thanks for help
But I want each of the output split files to be individual tar archive which I can extract individually without using cat to combine files.
I want help regarding the usage of the -M option & also to feed a shell script to change the name of the archive file once the specified file size limits, like to change the name of archive for eaxample vol1 is created then the shell script should provide a name vol2 for the next volume being created.please help.
Thanks in advance

CroMagnon 02-27-2006 01:19 AM

Sorry, when you said you had a 1.5GB file, I assumed you meant a large movie or something that needed splitting for archive onto CD. I assume now you meant the tar file is 1.5GB, not the contents?

One way I've found that works is to create a file beforehand (you could generate this file within a script fairly easily) that contains lines like this
Code:

n archive02.tar
y
n archive03.tar
y

Then you run a command like this:
tar cf archive01.tar -M -L 665600 < names.list

the contents of names.list replace the text you would need to type manually to continue the archive.

These tar files are partially extractable. As long as a file is fully contained within the piece you are working with, it should extract fine. If you want to restrict files so they cannot create archive boundaries, that will be more complicated.

sharathksin 03-06-2006 12:13 AM

thanks for the help,
It works fine with normal tar archiving, when I use same thing with -z or -j option it gives some error message.
Can I use -M option along with -z or -j options?
please help

CroMagnon 03-06-2006 04:56 AM

I believe if you use -j or -z it will compress the entire tar file, which means you can't uncompress one of the pieces. To get around it, you could have your script compress the files individually with gzip or bzip2. The compression ratios may alter slightly because of this, but it shouldn't be too significant.

bigearsbilly 03-06-2006 06:00 AM

Quote:

Originally Posted by sharathksin
thanks for the help,
It works fine with normal tar archiving, when I use same thing with -z or -j option it gives some error message.
Can I use -M option along with -z or -j options?
please help

how about?

tar cvf - files | gzip -c > archive.tgz
gunzip -c archive.tgz | tar cvf -


All times are GMT -5. The time now is 06:04 AM.