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
Wrong MySQL username/password doesn't generate error #180
Comments
I will have a look at this asap, in the meantime you can add a check, checking the size of the backup, if you have a zero byte file the check will fail. |
The problem here is that for efficiency if possible I pipe the mysqldump output directly to the compression like bzip2. The default behavior of piping is that just the last exit code is relevant. In order to change this I have to `set -o pipefail;' so if any command in the pipeline fails the whole pipeline fails. The thing is that not all shells support the |
In order to determine if a command in a command pipeline failed the 'set -o pipefail' option has to be set. Sadly not all shells support it. But the most public ones do and since nothing breaks if it is not available we should be fine using it. Issue #180
oh hey, i see you looked into it some more and determined thanks for the quick response/fix. |
I just released version 5.2.0 with the new |
Thanks for reporting the issue :) |
so i just downloaded 5.2 and get this error running it with a configuration file that was working in 5.1.11.
|
if it helps, i'm using phpbu on a digitalocean machine running ubuntu 18.04. |
Can you paste you configuration. Off course without any passwords you might have in there |
These warnings...
...are a new |
I deactivated the |
<?xml version="1.0" encoding="UTF-8"?>
<phpbu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpbu.de/5.1/phpbu.xsd">
<adapters>
<adapter type="dotenv" name="ENV">
<option name="file" value=".env"/>
</adapter>
</adapters>
<backups>
<backup name="REDACTED-db">
<crypt type="openssl">
<option name="password" value="adapter:ENV:PHPBU_ENCRYPTION_KEY"/>
<option name="algorithm" value="aes-256-cbc"/>
</crypt>
<source type="mysqldump">
<option name="user" value="REDACTED"/>
<option name="password" value="adapter:ENV:ATO_DB_PASSWORD"/>
</source>
<target dirname="backups/databases" filename="ato-%Y-%m-%d_%H%i.sql" compress="bzip2"/>
<cleanup type="quantity">
<option name="amount" value="7"/>
</cleanup>
<sync type="dropbox">
<option name="token" value="adapter:ENV:DROPBOX_SECRET_KEY"/>
<option name="path" value="databases"/>
<option name="cleanup.type" value="quantity"/>
<option name="cleanup.amount" value="7"/>
</sync>
<check type="SizeDiffPreviousPercent" value="10"/>
</backup>
<backup name="REDACTED-db">
<crypt type="openssl">
<option name="password" value="adapter:ENV:PHPBU_ENCRYPTION_KEY"/>
<option name="algorithm" value="aes-256-cbc"/>
</crypt>
<source type="mysqldump">
<option name="user" value="REDACTED"/>
<option name="password" value="adapter:ENV:OAP_DB_PASSWORD"/>
</source>
<target dirname="backups/databases" filename="oap-%Y-%m-%d_%H%i.sql" compress="bzip2"/>
<cleanup type="quantity">
<option name="amount" value="7"/>
</cleanup>
<sync type="dropbox">
<option name="token" value="adapter:ENV:DROPBOX_SECRET_KEY"/>
<option name="path" value="databases"/>
<option name="cleanup.type" value="quantity"/>
<option name="cleanup.amount" value="7"/>
</sync>
<check type="SizeDiffPreviousPercent" value="10"/>
</backup>
<backup name="REDACTED-db">
<crypt type="openssl">
<option name="password" value="adapter:ENV:PHPBU_ENCRYPTION_KEY"/>
<option name="algorithm" value="aes-256-cbc"/>
</crypt>
<source type="mysqldump">
<option name="user" value="REDACTED"/>
<option name="password" value="RSH_DB_PASSWORD"/>
</source>
<target dirname="backups/databases" filename="rsh-%Y-%m-%d_%H%i.sql" compress="bzip2"/>
<cleanup type="quantity">
<option name="amount" value="7"/>
</cleanup>
<sync type="dropbox">
<option name="token" value="adapter:ENV:DROPBOX_SECRET_KEY"/>
<option name="path" value="databases"/>
<option name="cleanup.type" value="quantity"/>
<option name="cleanup.amount" value="7"/>
</sync>
<check type="SizeDiffPreviousPercent" value="10"/>
</backup>
</backups>
<logging>
<log type="mail">
<option name="sendOnlyOnError" value="true"/>
<option name="transport" value="mail"/>
<option name="recipients" value="REDACTED"/>
<option name="sender.name" value="phpbu"/>
<option name="sender.mail" value="REDACTED"/>
</log>
</logging>
</phpbu> |
It looks like you are using Bourne-Shell (sh) to execute <check type="size" value="1M" /> |
my server uses bash. $ echo $0
-bash although, i do see the log referencing sh. that's curious. is the way you're invoking commands forcing sh instead of the server's default? also, after playing around more, it appears as if the schema definition requires elements in a specific order. i moved elements around to match the schema order and it validates properly. but i would suggest updating the schema using |
Changing the In order of execution, I'm not forcing anything special. I would expect php to call the default shell of the user it runs under. |
i dug in a little more. it appears dash (which doesn't support however, when executing commands from php, sh is the shell used (which is symlinked to dash). $ php -a
Interactive shell
php > echo `echo $0`;
sh
php > given all that, i don't know what the best solution is for this. is there a way to detect which shells are available and tell php to use one that supports FWIW, i think it's worth exploring a solution. login typos are fairly common. and if a user isn't vigilant about verifying their backup, they might be stuck with worthless backups when they need a valid backup the most. pointing out login errors would also increase the authority of phpbu (i.e. when phpbu says a backup succeeded, you can be confident it actually did.) anyway, your |
You are absolutely right, I think the best way to do this is either trying to detect if pipefail is available and put out a warning if it is not, or defaulting to pipefail active with the option to deactivate it manually. |
What about trying to connect to database before making a backup, perform simple select, like |
That could be done, but it wouldn't solve the problem completely. |
After getting my first configuration properly backing up files, I added email logging for errors only. In order to test the settings, I entered wrong MySQL credentials expecting an error email. However, instead of that, phpbu created a "successful" backup. Instead of the actual SQL dump, it was a zero-byte file.
Basically, I believe an error should be triggered in this case.
The text was updated successfully, but these errors were encountered: