Skip to content

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

Closed

Description

@jzohrab

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)

Activity

  1. changed the title [-]DB backup and restore fails[/-] [+]DB backup and restore fails, bad exported file format (Mac, MAMP)[/+] on Nov 2, 2022
  2. HugoFara commented on Nov 4, 2022

    @HugoFara
    Owner

    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.

  3. added a commit that references this issue on Nov 5, 2022
    4c4ba1b
  4. HugoFara commented on Nov 5, 2022

    @HugoFara
    Owner

    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! 😆

  5. jzohrab commented on Nov 5, 2022

    @jzohrab
    Author

    great find, good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions