MyBB Community Forums

Full Version: [F] Backup Bug
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I cant seem to download a backup
it downloads as a zip file but when i go to open it i receive an error saying it is damaged - i can backup database ok (i hope its ok) but could someone tell me how to fix this bug?
save the file with extension html and open it in a browser. See if there has been an error, which may be the most probable thing that had happened.

I had this problem too and was due to the configuration of PHP, which in my server it doesn't allow to take more than 8Mb of memory and the backup feature of MyBB uses a lot of more memory (it stores in memory the whole daba base before compressing it and send to donwload). I had to change the code in order to make the backup feature work correctly.
A possible solution it so flush the buffer every so often so for instance we could flush the buffer once it gets near the max memory set by the ini and send it in packets. I'm not sure if it'd work but it might.

Otherwise we'd be better of throwing an error saying you don't have enough memory to complete the operation or something like that.
Try changing the file name from .gz to tar.gz on the extension example.gz -> example.tar.gz and see if it opens.
Tikitiki Wrote:A possible solution it so flush the buffer every so often so for instance we could flush the buffer once it gets near the max memory set by the ini and send it in packets. I'm not sure if it'd work but it might.
What you have to do is flush the buffer every iteration of the loops.

Hoowever there's a problem because you can't do that if you choose the options download and gzip, because in that case the code is written in such way that it first creates the whole data to download and finally compresses it. It couldn't change that, but in the other combinations (download + text plain, or save at the server) i was able to do a workarround. You can find it in the attached file; feel free to use it in MyBB.

What I did is add a new option to do what i called a sequential backup. Then, in the code, each time you add something to the variable $contents you call a new function (seq_backup) which flushes its value it it's possible. In that way, the size of the variable $contents never exceeds a big size. In my board, with a 8 Mb limit, i don't get any error.

BTW, the option "optimise data base" doesn't work (it doesn't do anything at all) in the page of data base bakcup.
Thanks Choli. I've made a few changes to your dbtools.php. Please see if the following file fixes the reported backup bug. It works for me Smile
oh! :O yeah, it works perfectly. I tough that you couldn't concatenate the output of gzencode to create a single gz file, that's why I didn't add the option of sequential backup with download and gzip Smile good work.

Just one suggestion. Change the line
	makeyesnocode('Do a sequential backup?', 'sequential_backup');
so it uses the $lang->whatever, so people can translate it into any language. Wink
I was, I was just too lazy at the moment xD I didn't think you could use gzencode because of the crc32 string generated at the beginning but apparently you can.

Anyway, I'm glad we got this fixed & thanks for the help!
This bug has been fixed in the latest code.

Please note the latest code is not live on the site or for download. An update will be released which contains this fix.
Tikitiki Wrote:I didn't think you could use gzencode because of the crc32 string generated at the beginning but apparently you can.
yeah... you developers should be careful with that, and if someone complais about that remember that the problem may be at the gzencode Toungue
Quote: thanks for the help!
no problem Wink
Pages: 1 2