Avatar of ppeiris
ppeiris
 asked on

tar multi volume

I have to write a script to tar and transfer about 20GB amount of data... I was planing to use the multi volume option in tar to create series of 1GB files and transfer individually. I can run the following command but it wait for user input to create the next (disk2.tar) file. How can I automate this to just create all the disk(n).tar files without user interaction.
tar -cM --tape-length=1024000 --file=disk1.tar backup.tar

Open in new window

Linux OS DevShell Scripting

Avatar of undefined
Last Comment
Julian Parker

8/22/2022 - Mon
Julian Parker

you havnt told it what to tar....

   tar -cM --tape-length=1024000 --file=disk1.tar backup.tar /backupdirectory
 
ppeiris

ASKER
sorry ... in my case backup.tar is 20GB tar file itself. I want to break that in to multiple 1GB files....
Julian Parker

you could use `split`...

If you use multi-volume you will also need to write a script to move the backup files or you will just have one disk1.tar file which is 1GB and holds the final slice of the backup.

Check out man split first. It may suit your needs...

If not I'll see if I can find an old multi volume tar script I used to use.

Can I ask.... why 1GB???

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ppeiris

ASKER
I will try to use split but I would like to use only the tar command. It seems like its a very default requirement what I am asking .... I am using 1GB  because I am transferring them over the internet using scp to diffident location. 1GB is convenion to me.
ASKER CERTIFIED SOLUTION
Julian Parker

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Julian Parker

oops; get rid of the ${NETHDD}/ reference on line 10.

You may need to tweak it for your setup...
Julian Parker

...or backup your stuff into one large tar then;

   split -a 2 -b 1024m backupfile.tar

Alas, it has also been a long time since I used split (about the same as the script). I found split does not copy well with gzipped tar archives.... though it may be better now.

... have even more fun :-)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.