Solved

tar to mutiple files

Posted on 2012-04-05
3
629 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
ID: 37810219
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
ID: 37810223
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
ID: 37810480
I think you missed the - in your command

cat test.tara* | tar xvf -
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

839 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