WP-DBManager Backup Failed Filesize 0 Bytes
UPDATE: Plugin developer Lester Chan has accepted my fix for this as a valid one, I forked his Github repo, added my changes and he accepted the pull request, so the official Git repo for WP-DBManager now contains the fixed code. You can either download it from there, or wait until it is released through WP. As the fix is now available from the main plugin author I am deleting my original Git repo previously linked below, but I will keep my fork of the main repo open. Note the issue only arises when a port is set in wp-config i.e.define('DB_HOST','localhost:3306').
If you are reading this post, there is a strong chance you are feeling pretty miserable. I know I was until about 5 minutes ago when I finally found my own solution to this seemingly common problem. I read dozens of posts of people who had similar issues with WP-DBManager – for the record my error message was Database Backup Failed – File Size 0Bytes, but there didn’t seem to be anyone offering any solutions, except for trying another plugin. I thought for ages it was the mysqldump path or the path to mysql as those were both red on the backup page, but I should have guessed it was due to a Plesk update (yes I have given it away) as the plugin had previously worked fine on my Plesk sites despite those being red. I finally came across something that helped, well 2 things actually. The plugin developer hadn’t used Plesk and to try a mysqldump query via SSH. I fired up SSH and ran the simplest mysqldump query mysqldump -u username –pasword=”password” > backupfilename.sql. It worked, this is when I knew it had to be something to do with the exec command that WP-DBManager was using. The WP-DBManager command is as follows:
$brace.$backup['mysqldumppath'].$brace.' --force --host="'.$backup['host'].'" --user="'.DB_USER.'" --password="'.$backup['password'].'"'.$backup['port'].$backup['sock'].' --add-drop-table --skip-lock-tables '.DB_NAME.' > '.$brace.$backup['filepath'].$brace;
The first thing I tried was taking out –skip-lock-tables as it looked the most likely to cause a problem. After trying the query with several things taken out I eventually found out that it was the .$backup['port'].$backup['sock'] that are causing the problem. I never bothered to find out what these variables are set to for my server, I simply removed them and the plugin worked fine.
UPDATE: on further investigation I have found that the problem is not down to Plesk or the inclusion of the port and sock in the command, rather that they are being setup incorrectly. In my original install of WP that I started using your plugin it was handrolled, it was when I moved from .co.uk to .com that I installed it from Plesk applications, and whereas I used only localhost as the host it had added :3306. The plugin checks for the port, but after exploding at : an if statement
is returning false because after being exploded it is being treated as a string – for example line 51 of database-backup.php. This causes the port to be used as sock instead.
I have now pushed a new version to Git (link at bottom of article updated) with the original command intact, but this fixed, so this makes it a widespread fix not related to Plesk.
For anyone technically minded the command is set in three files within the plugin database-backup.php, database-manage.php and wpdb-manager.php do a CTRL+F for command and you will find them. For those not so technically minded I have created a modified version of the plugin called WP-DBManager for Plesk, you can download it on Github.
To install the plugin you have two choices, delete the original and upload mine to wp-content/plugins in its place, or just upload the files mentioned above to the original wp-dbmanager folder. Both will work exactly the same. Let me know if you have any further problems after using my modification.