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

Wrap dump command in an if when using compression, fixes #89 #100

Merged
merged 5 commits into from May 10, 2019

Conversation

riasvdv
Copy link
Member

@riasvdv riasvdv commented May 10, 2019

This wraps the dump command in an if, for example:

if output=$('mysqldump' --defaults-extra-file="credentials.txt" --skip-comments --extended-insert dbname);
then
  echo "$output" | gzip > "/save/to/new (directory)/dump.sql"
else
  echo "Dump was not succesful." >&2
  exit 1
fi

If the dump command fails for some reason, it will output the right exit code and no dump will be created.

@riasvdv riasvdv changed the title Wrap dump command in an if when using compression Wrap dump command in an if when using compression, fixes #89 May 10, 2019
tests/MongoDbTest.php Show resolved Hide resolved
src/DbDumper.php Outdated Show resolved Hide resolved
@freekmurze
Copy link
Member

Like said in real life, drop support for anything below PHP 7.3 (and disable style ci for now)

@riasvdv riasvdv merged commit b4904c7 into master May 10, 2019
@freekmurze freekmurze deleted the fix-pipe-error branch May 10, 2019 09:24
@aaronhuisinga
Copy link

aaronhuisinga commented Jul 2, 2019

@freekmurze @riasvdv For some reason this has broken our backups on both our Homestead box and production servers (both on Ubuntu 18.04/PHP 7.3/MySQL 5.7).

We're using the built in Gzip Compression class for commands, and this PR broke it for us. Downgrading to DB Dumper 2.4.0 or not using compression fixes it for us immediately.

While using DB Dumper >= 2.4.1 and compression, and DB dump outputs a ~20 byte file. I've tried running the command being output by the package and it does the same thing. Running the command without the if/else statement does work properly.

I'm not sure what the actual cause is, but there definitely seems to be something wrong here.

@freekmurze
Copy link
Member

Did you get an error message?

@aaronhuisinga
Copy link

I do not get an error message. The resulting database dump is just ~20 bytes. The backup package believes it worked successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants