docker-magento icon indicating copy to clipboard operation
docker-magento copied to clipboard

DB dump does not work as expected

Open nicolaspernot opened this issue 3 years ago • 5 comments

Hi and thanks for this amazing tool !

Description The documentation, states that we can perform a DB dump via the following command.

bin/mysqldump > ~/Sites/existing/magento.sql

I just try an that return an error

Steps To Reproduce

  1. Install the docker-magento through the automated way.
  2. Try to dump the DB : bin/mysqldump > ~/Sites/existing/magento.sql
  3. Do you have the error ?

Expected Result

Either an updated documentation for dump the DB or I should have my dump there ~/Sites/existing/magento.sql.

Actual Result

I got the error message following :

In ErrorHandler.php line 61:
                                                                                                                                                                                                                                 
  Deprecated Functionality: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in phar:///var/www/html/bin/n98-magerun2.phar/src/N98/Magento/Command/Database/Compressor/Uncompressed.php on line 49      

Some other inputs

  • As far as I understand the error message comes from the abscence of parameter. This command don't throw error : bin/mysqldump test.sql, but send the dump flow in test.sql in the container, so I can't have it on my host.
  • If someone need a quick fix :
cd <root_project>
make mysqldump dump.sql
make clinotty cat dump.sql > magento.sql
make clinotty rm dump.sql

nicolaspernot avatar Jun 19 '22 08:06 nicolaspernot

Ref: https://github.com/netz98/n98-magerun2/issues/999

rangerz avatar Jul 24 '22 09:07 rangerz

I'll keep this ticket open until the above is resolved, but it appears to be a prob with the n98 cli tool.

markshust avatar Jul 25 '22 13:07 markshust

Hello, same error here. The mysqldump process runs, but the contents of the resultant sql file are only:

Downloading n98-magerun2.phar, just a moment...
n98-magerun2.phar: OK

I tried @nicolaspernot 's alternate solution above, but I don't know where the sql file is being dumped to.

Any guidance would be most welcome and appreciated!

robert-j-peterson avatar Jul 28 '22 17:07 robert-j-peterson

@nicolas-medina @robert-j-peterson

My workaround is below:

cd <root_project>

# Dump SQL file in container
bin/n98-magerun2 db:dump magento.sql

# Copy SQL file from container to local
bin/copyfromcontainer magento.sql

# Remove SQL file in container
bin/cli rm magento.sql

# Your SQL file will be in local `src/magento.sql`
ls src/magento.sql

BTW: stripped some tables for speed up and smaller size db:dump

bin/n98-magerun2 db:dump --strip="@stripped" magento.sql

rangerz avatar Jul 28 '22 20:07 rangerz

ahhhh that copyfromcontainer command looks useful -- thank you!

robert-j-peterson avatar Jul 28 '22 21:07 robert-j-peterson

@nicolaspernot @markshust It's fixed in n98-magerun2 version 5.2

# Remove old n98-magerun2
bin/cli rm bin/n98-magerun2.phar

bin/n98-magerun2 --version
# Downloading n98-magerun2.phar, just a moment...
# n98-magerun2.phar: OK
# n98-magerun2 5.2.0 (commit: e11be34) by netz98 GmbH

# Works !!!
bin/mysqldump > ~/Sites/existing/magento.sql

rangerz avatar Aug 17 '22 22:08 rangerz

Ah thanks! n98 isn't baked into any image (see https://github.com/markshust/docker-magento/blob/master/compose/bin/n98-magerun2), so the above is the correct fix 👍

Going to close this one out, as I don't think there's really anything for me to do here? 🤷 If there is, please let me know and I'll reopen.

markshust avatar Aug 25 '22 18:08 markshust