Solved

Create Tar file in unix and split it to smaller segments

Posted on 2014-09-04
6
1,230 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now