0

I have a folder with about 50 files. I want to create small tar.gz files (10 mb each) out of these 50 files.

I tried the split command

tar cvzf - /dir | split --bytes=10MB - backup.tar.gz

This does split the files into smaller tar.gz files, but they are no longer extractible. (backup.tar.gzaa, backup.tar.gzab etc)

How can I split them into multiple tar.gz files where each one is self-extractible ?

I would like to have something like backup.tar.gz, backup1.tar.gz so that I can copy individual files to windows machine as and when required.

Thanks in advance.

0

I want to create small tar.gz files (10 MB each)

I tried the split command tar cvzf - /dir | split --bytes=10MB - backup.tar.gz

Split splits a file. That works just fine. However gzip needs all the information. So you would need to concattenate all previous files again in order to uncompress.

What you could do it create tars of about 20 MB, then gzip each of these. Vary the size until they get down the 10 MB compressed.

Since compression varies with the contents this is trail and error.

I would like to have something like backup.tar.gz, backup1.tar.gz so that I can copy individual files to windows machine as and when required.

Best solution I can thing of: Select about 20MB of files. Then tar them into one undle, then compress (with with -z for gzip) or any other program.

And that assumes all files are small enough that you can select wisely from them.

  • Thanks @Hennes. The thing is I already have a script that creates this tar.gz file, which I want to avoid changing. So, I was trying to split an existing tar.gz file to smaller tar.gz. – user616666 Jul 13 '16 at 13:49
  • Spliiting is not hard (as you already found out). But gzip needs all previous data. – Hennes Jul 13 '16 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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