LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-26-2006, 11:59 AM   #1
sharathksin
LQ Newbie
 
Registered: Feb 2006
Posts: 12

Rep: Reputation: 0
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

Last edited by sharathksin; 02-26-2006 at 12:00 PM.
 
Old 02-26-2006, 09:46 PM   #2
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
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.
 
Old 02-26-2006, 11:26 PM   #3
sharathksin
LQ Newbie
 
Registered: Feb 2006
Posts: 12

Original Poster
Rep: Reputation: 0
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
 
Old 02-27-2006, 12:19 AM   #4
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
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.
 
Old 03-05-2006, 11:13 PM   #5
sharathksin
LQ Newbie
 
Registered: Feb 2006
Posts: 12

Original Poster
Rep: Reputation: 0
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
 
Old 03-06-2006, 03:56 AM   #6
CroMagnon
Member
 
Registered: Sep 2004
Location: New Zealand
Distribution: Debian
Posts: 900

Rep: Reputation: 33
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.
 
Old 03-06-2006, 05:00 AM   #7
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
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 -
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I password tar.gz archives? Cyberian Linux - Security 11 10-20-2010 06:11 PM
Removing directory path from tar archives haddad Linux - Software 1 01-18-2006 08:02 AM
Tar gives error when creating a tar file archive davidas Linux - Newbie 10 04-13-2004 12:35 AM
Extracting multivolume tar Cichlid Linux - Software 3 12-21-2003 01:54 AM
tar archives of type tgz dalraidia Linux - Newbie 3 12-13-2002 09:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration