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 |
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. |
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 |
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 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. |
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 |
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.
|
Quote:
tar cvf - files | gzip -c > archive.tgz gunzip -c archive.tgz | tar cvf - |
All times are GMT -5. The time now is 05:45 PM. |