Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i am using the following command to backup and sql file:


i want to make sure the compressed file wont be larger then 300mb, if it exceeds 300mb, split it into several files.

any thoughts?

share|improve this question

migrated from Aug 19 '11 at 22:10

This question came from our site for professional and enthusiast programmers.

up vote 8 down vote accepted

I don't think tar has functionality built-in to split at an arbitrary size (there is -M for multi-volume, but this relies on the destination media detecting an out-of-space condition), but there are two things you could do:

  1. Generate a single tar.gz file in the usual way, then use the split command to divide it into sections (and cat to join them back together for decompression).
  2. Use dar instead of tar, since this has splitting functionality built in (amongst a lot of other features that tar doesn't have). For example

    $ dar -c "$BACKUPNAME" -g "$INPUTFILE.sql" -s300M -z

share|improve this answer
dar sounds interesting, how would i run this command in dar? – Ran Jul 14 '11 at 16:09
how about using tar with --tape-length and -M ? – Ran Jul 14 '11 at 16:12
I added an example dar command. I just tested --tape-length and it doesn't work with compressed archives, repeatedly overwrites the same .tar file without changing the name, and requires you to hit ENTER after each "slice". – user89061 Jul 14 '11 at 16:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.