ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello, I am making a script to backup all my information on the server and send it to my email. I tried recently, but it didnīt let me because the resulting targz file was bigger than the maximum file size allowed. In order to solve that problem I figured out on making several targz files of a predefined size.
How can I find out or estimate the size of the tar file of that directory before taring it?
Each type of file will compress differently. That is to say that ASCII files will compress very well while JPEG file will not compress at all. So if you know how much space is occupied by each type of file then you can make a formula. For example: (space of ASCII files)/12 + (space of JPEG files) + (space of binary executables)/2.
Or you could use the multi-volume feature of tar which will split the tar file up into parts of a size that you specify. So you could just tell tar that the maximum file size of a partial tar file is 12 MB and it will split the tar output into 12 MB files.
Or you could make one large backup file and use the split utility to split it into segments of a size that you specify. It makes more sense to force tar to split up the archive file, though, so that you don't have to recreate the single archive file in order to restore files from the archive.
Of course it's a little bit suspicious that you want to use email to transport the files to their destination. I hope that you aren't copying things from work. Use your power for good and not for evil.
Last edited by stress_junkie; 07-18-2008 at 06:06 PM.
Not easily, at least not with any accuracy. Gzip compression ratios vary very widely depending on what is to be compressed. English text can be compressed a lot - the compressed size might be 10% of the original. However, mp3 or jpeg files won't get compressed very much, if at all.
Why do you want to know. Why not just make the file, and then use split to chop it into chunks, and then cat the together at the other end?
Its even more difficult than this. Attachments will need to be MIME-encoded, so will be inflated by a certain percentage during this process. Be sure to take this into consideration.
Thanks to all of you for your information. I didnīt know tar command has a multi volume feature and it would certainly be very useful to me, would you tell me how to use it?
I prefer this rather than using the split command because I donīt have to restore small files to get the original one. I am also intrested in this because I want to make a zip utility in the future just to find out how things work.
I know my question might sound suspiciuous, but Iīm a trainee in IT and I have a lot of hard work and information on the server of all my subjects and I have wondered that it is possible that my information could be unavailable or accidentaly deleted. Anyway, due to permision restrictions I can only backup my own information.
Thanks
I was wondering whether he NEEDS to use email or just did that way because it seems the obvious/easy way if he hasn't messed much with this level of usage before.
Depends where the target system is...
use the info page instead for tar, you'll find out why...
Something to consider, tar will increase the initial file size. Using the standard block size (512), will produce a 512b header for each file or directory and will round each filesize upto 512. Then it will also want to be a minimum of a multiple of blocks, which if I remember correctly is 20 as default...
For example if you have a single file of 3 bytes:
header: 512
file: 512
= 1024
yet it must be a multiple of 20 blocks, so fill with zeros until 10240 bytes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.