Solved

tar to mutiple files

Posted on 2012-04-05
3
621 Views
Last Modified: 2012-04-20
We have directory in solaris which has thousands of subdirectories and files.

We need to tar this directory and copy it over the WAN. Since this directory is quite big in size (around 600GB) we can't just create one tar file.
Is there a way to create mutiple tar files based on size, say 10GB each?

One approach could be to select a few files and directories and tar them one at a time but this could be error prone (as we could miss something) and requires lot of manual work.

Is there a command which enables to create tar files based on size (say 10GB each), so that as soon as 10Gb size is reached a new tar file is created and so on.
0
Comment
Question by:ank5
3 Comments
 
LVL 5

Accepted Solution

by:
Sjizzel earned 350 total points
Comment Utility
I found this article:

Sometimes when you want to store your backup or any other large set of files online or want to share them someone else you need to find a way to compress and split the files into chunks of 100 or more Megabytes. I felt the need for this as well recently when I wanted to store my backups online and the online storage service had a cap of 100 MB per file. I found a really neat solution based on the tar command. Using this method I split my backup of about 1 GB into 10 chunks of 100 MB each with incremental filenames.

The 1 GB file I wanted to split was called dbbackup.db. Here’s the command I ran to create multiple tar files of 100 MB each out of it:

# tar -cf – dbbackup.db | split -b 100m – db_backup.tar

This command took a long time to run. Once it was done running I was left with ten files, 100 MB each named db_backup.taraa, db_backup.tarab, db_backup.tarac, and so on and so forth.

Now I can copy these files to my external storage or ship them with ease. To stitch the 1GB file back together all I need to do is to run the following command:

# cat db_backup.tara* | (tar x)

And voila, I get my original file again.


http://www.simplehelp.net/2009/05/25/how-to-create-a-multi-part-tar-file-with-linux/
0
 
LVL 6

Assisted Solution

by:torakeshb
torakeshb earned 75 total points
Comment Utility
To create:

tar -cf - <path to tar> | split -b 1000m – test.tar

To extract

cat test.tara* | tar xvf
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 75 total points
Comment Utility
I think you missed the - in your command

cat test.tara* | tar xvf -
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

744 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

10 Experts available now in Live!

Get 1:1 Help Now