Solved

Create Tar file in unix and split it to smaller segments

Posted on 2014-09-04
6
1,321 Views
Last Modified: 2014-09-04
I need to split a large tar file for backup purposes on a unix system. I need to tar the /u/appl directory and then split into chunks less the 2gb in size. The following command is what I'm using now, but I get an error "Split: cannot open input".

tar cvf - /u/appl | split -b 1500m /u/backup/appl.backup.tar.gz

I'm sure there's a syntax error, as I can run the tar command by itself with no issue. I've tried to resolve but haven't been able to.
0
Comment
Question by:sdholden28
  • 2
  • 2
  • 2
6 Comments
 
LVL 23

Assisted Solution

by:nemws1
nemws1 earned 250 total points
ID: 40303517
You need to provide an input file parameter to split.  In this case, you want STDIN, so you just need a hyphen:

 tar cvf - /u/appl | split -b 1500m - /u/backup/appl.backup.tar.gz

Open in new window

0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 250 total points
ID: 40303534
You must tell split which input to read. In your case it's stdin, expressed as "-"

tar czvf - /u/appl | split -d -b 1500m - /u/backup/appl.backup.tar.gz

"-d" tells split to use numeric suffixes. Use the "-z" flag of tar to compress.

Please be aware that you must concatenate the single input files before feeding them to tar for extracting!

cat /u/backup/appl.backup.tar.gz* | tar -xzvf -

tar is also able to create multi-volume archives.

If you know roundabout how big your input data will be you can do

tar -c -M -L 1536000 --file =/u/backup/appl.backup.tar1 --file =/u/backup/appl.backup.tar2 --file= /u/backup/appl.backup.tar3 --file =/u/backup/appl.backup.tar4

Note: You cannot use compression when the "-L" flag is in effect.

You can repeat the "--file" parameter as often as needed. "-L" specifies the chunk size in K.

You can also specify just one filename. tar will prompt you for the name of the next file once the amount of data specified by "-L" (in K) has been archived.. Answer the question "Prepare volume #n for 'archive' and hit return:" with "n new_file_name".

Finally, you can use a "new volume" script to get rid of the prompts. Here is how it works: http://www.gnu.org/software/tar/manual/tar.html#Using-Multiple-Tapes
0
 

Author Comment

by:sdholden28
ID: 40303985
does stdin use temp space on /dev/root? That looks to be the case as I'm running into a space issue in my test environment. Can I direct the temp storage to /u somehow?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40303987
stdin/stdout  do not use intermediate (temporary) disk space.
0
 
LVL 23

Assisted Solution

by:nemws1
nemws1 earned 250 total points
ID: 40304102
split *might* be using temp space (I kinda doubt it, though).

Maybe just try this (make sure both tar and split use the temporary TMP location).

mkdir /u/tmp
chmod 700 /u/tmp
TMP=/u/tmp tar cvf - /u/appl | TMP=/u/tmp split -b 1500m - /u/backup/appl.backup.tar.gz

Open in new window

0
 

Author Closing Comment

by:sdholden28
ID: 40304890
Thanks gentlemen, got it sorted. Could've solved my problem with the info from nemws1 alone, but I greatly appreciate the extra info from woolmilkporc and I used it to implement a better solution, so I split the points. Thanks again.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
A short article about a problem I had getting the GPS LocationListener working.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question