Closed jcatello closed 3 years ago
I know what the problem is: I'm using stream_get_contents()
on the stream to fetch the entire STDOUT
output at once, and in that case, the STDOUT
output happens to be the entire database content.
What the code should do instead is chunk the stream_get_contents()
and yield
it to the caller. However, the caller will then be responsible to iterate over the return value, so it's probably a breaking change...
As a work-around in the mean time if you need to provide the DB to the STDIN
of another tool, you can do so by exporting into a file first and then using cat
to send that file to STDOUT
:
wp db export /tmp/my-db.sql
cat /tmp/my-db.sql | tool-that-needs-stdin
rm -f /tmp/my-db.sql
Since upgrading to 2.5 seeing a lot of memory issues specifically with db export when exporting to STDOUT
^ This failed within 10 seconds of running it, the database is very large.. 20GB but when exporting with 2.4.0 it has no issues.
# php wp-cli-2.4.0.phar ${WPCLIFLAGS} db export - --path="${DOCROOT}" --quiet --single-transaction --quick --lock-tables=false --max_allowed_packet=1G --default-character-set=utf8mb4 --routines --triggers --events | wp ${WPCLIFLAGS} --quiet db import - --path="${DOCROOT}" --ssh="${REMOTEHOST}":"${REMOTEPORT}" --quiet --force --max_allowed_packet=1G
Exporting to file is fine:
STDOUT: