General discussion

Locked

TAR Question

By Scarlet Christiaans ·
Hi, I'm new to Linux and appreciate your advice...

I need to restrict the size of a tar file. I'm running Red Hat 9.

There are about 30 dirs within the home dir that I need to tar, and backup to dvd on a weekly basis.

Is there a way to tell linux to start tarring the folders until the tar reaches a certain size, then start another tar file and so on?

I've also thought of telling linux to copy files in a range (like A* - M*), but the dash doesn't seem to work. Is that even possible?

Any thoughts are appreciated.

Thanks,

Scarlet

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by Nico Baggus In reply to TAR Question

Well no, not exactly.
There is the -M or --multi-volume option on the
gnu tar command/

HIH,
Kind regards,

Collapse -

by stress junkie In reply to TAR Question

If you can create the archive file on another disk and then break it up you could use the split command. The split command allows you to break up a file into pieces of a specified size. You can put them back together using the cat command.

You might want to look into using a backup application to help manage spreading your backups over different volumes. Something like Bacula might work.

http://sourceforge.net/search/?words=bacula&type_of_search=soft

Collapse -

by Scarlet Christiaans In reply to TAR Question

Thanks for the advice.

I'm burning the tar files to dvd from a Windows XP machine (across an xp/linux network via samba). Do you know if XP will prompt you for another dvd when using the multi-volume option? Will XP prompt for another dvd when extracting?

Thanks,

Scarlet

Collapse -

by vinchi007+ITmag In reply to TAR Question

Oh you mean the similar ability of the winrar, where you chose to split -> set size -> compress

As far as I know compressor doesn't have this ability, check this site, it has steps for compression and splitting if too big. You could simply write a little script combining 2 steps together.

http://www-rohan.sdsu.edu/doc/debian/ch-file_tools.html

Collapse -

by bichelmo In reply to TAR Question

cp -Rf [A-M]* /destination_directory/. would allow you to copy partial directories. Have verified this on RHES.

Collapse -

by bichelmo In reply to

tar -cMf /tar_destination/tarfilename.tar -L 45000000 /home/*
will allow you to create multiple 4.7G tar files but you will have to interact. When it prompts for the next volume you can enter another filename and accept. Example( Prepare volume #2 for `test.tar' and hit return: n test2.tar )


I don't think that I would do it this way. I believe that instead of creating a tar file I would use rsync "rsync -a /home/* /destination_dir/." to replicate my directory structure and then split it on my client while I was burning the DVD. This would also allow you to retrieve a single file without having to restore all segments of the Tar file.

Collapse -

by robert@residentialsrvcs In reply to TAR Question

I cannot help with your tar question, but I can help with your copy question.

You need to look into regular expressions, which is what Linux shells use to expand file list arguments. http://en.wikipedia.org/wiki/Regular_expression is a good source.

The short answer is that you are telling your terminal to copy any file(s) which begin with a capital 'A', and have a '-' followed by a capital 'M'. What you most likely want is: "[A-Ma-m]*", which says "any file(s) which begin with a capital 'A', 'B', ..., or 'M'; or which begin with a small 'a', 'b', ..., or 'm'. Don't forget, though, that this will *not* match dot-files (eg. .bashrc).

I hope that helps.

Collapse -

by robert@residentialsrvcs In reply to

QUOTE
Comment from bichelmo on 05/23/06:
tar -cMf /tar_destination/tarfilename.tar -L 45000000 /home/*
will allow you to create multiple 4.7G tar files but you will have to interact. When it prompts for the next volume you can enter another filename and accept. Example( Prepare volume #2 for `test.tar' and hit return: n test2.tar )
/QUOTE (sorry, I don't know if there is a better way to do this here)

You could use pipes for this. The easiest way I can think of is to determine the maximum number of chunks the tar file will be split into. Then:

for ((i = 2; i < NUM_FILES; i++)) ; do echo "n file$i.tar" ; done > foo

tar -cMf /tar_destination/tarfilename.tar -L 45000000 /home/* < foo

That will create a file "foo", which consists of a lot of lines of "n fileNUMBER.tar"s. Then, those lines will be treated as the standard input source for the tar command.

I should mention that there are probably better ways to do this. The following may work, too:

tar -cMf /tar_destination/tarfilename.tar -L 45000000 /home/* < ` for ((i = 2; i < NUM_FILES; i++)) ; do echo "n file$i.tar" ; done `

just be sure to use the backticks (under the tilde) rather than single quotes. I should note that I have not tried the latter lines.

Back to Linux Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums