Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB backup and restore fails, bad exported file format (Mac, MAMP) #55

Closed
jzohrab opened this issue Nov 2, 2022 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@jzohrab
Copy link

jzohrab commented Nov 2, 2022

To Reproduce

  1. http://localhost:8888/lwt/backup_restore.php
  2. click "download lwt backup", file is created and downloaded (eg lwt-backup-exp_version-2022-11-02-19-28-54.sql.gz)
  3. on same page, "restore" section, choose that file, and click "restore from lwt backup"
  4. *** Error: Invalid Database Restore file (possibly not created by LWT backup) ***

If I try to gunzip the file, I get an error:

MacBook-Air-2:Downloads jeff$ gunzip lwt-backup-exp_version-2022-11-02-19-28-54.sql.gz
gunzip: lwt-backup-exp_version-2022-11-02-19-28-54.sql.gz: not in gzip format

setup:

Mac, MAMP

Web Server	localhost:8888
Server Software	Apache/2.4.46
PHP Version	7.4.21
MySQL Version	5.7.34
This is LWT Version 2.5.2-fork (September 27 2022)

Tested on master branch:

MacBook-Air-2:lwt jeff$ git log -n 1
commit 3c10d17115616a5dcba51e16c0d19501cbc550cb (HEAD -> master, upstream/master, upstream/HEAD, origin/master)
@jzohrab jzohrab changed the title DB backup and restore fails DB backup and restore fails, bad exported file format (Mac, MAMP) Nov 2, 2022
@HugoFara HugoFara added the bug Something isn't working label Nov 3, 2022
@HugoFara
Copy link
Owner

HugoFara commented Nov 4, 2022

I tested and reproduced your issue. There is something wrong with the generated gzip file, but I think the issue is quite small. I should be able to fix it tomorrow.

@HugoFara
Copy link
Owner

HugoFara commented Nov 5, 2022

Hi Jeff!

I managed to find the issue, I think I got a good a specimen from the pandemonium of bugs. It was basically the following:

  • backup_restore.php include inc/database_connect.php.
  • inc/database_connect.php starts with \n<?php.
  • PHP interprets it a valid HTML texts node, and starts to echo output \n in plain text.
  • When the code starts outputting the downloadable database backup, it adds this plain text \n to the gzip-encoded content.
  • → File is corrupted.

It took me three hours to remove a "\n", but now there are now longer pesky data when loading pages. I also updated the headers, that can be a potential cause for download failure.

So now you should be able to break and restore you database without much risk. Enjoy! 😆

@jzohrab
Copy link
Author

jzohrab commented Nov 5, 2022

great find, good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants