For this blog I like to use a plugin called WP-DBManager. It's a great tool for easily maintaining your blog's database right from the administration console. Unfortunately, being on a Windows host, sometimes plugins don't work as intended, so you have to make some adjustments.
For this plugin I kept getting this error whenever I tried to run the backup script:
Warning: filesize(): Stat failed for (blah, blah)
Warning: unlink(blah, blah) no such file or directory
To fix it I had to do a few things:
1. The actual command to create the backup needs to be fixed, so it can run properly on the command prompt. Find the file named database-backup.php in the plugin's directory. Place double quotes around the path part of the command and remove all others. Lines 47 and 51.
$backup['command'] = '"' . $backup['mysqldumppath'].'" --host='.DB_HOST.' --user='.DB_USER.' --password='.DB_PASSWORD.' --add-drop-table --skip-lock-tables '.DB_NAME.' | gzip > '.$backup['filepath']; $backup['command'] = '"' . $backup['mysqldumppath'] . '" --host='.DB_HOST.' --user='.DB_USER.' --password='.DB_PASSWORD.' --add-drop-table --skip-lock-tables '.DB_NAME.' > '.$backup['filepath'];
2. The function that runs the command is called execute_packup(). This function is located in a file named wp-dbmanager.php in the plugin's directory. Find this function (line 205) and remove the if statement and leave only the passthru() command. Similar to this:
function execute_backup($command) {
$backup_options = get_option('dbmanager_options');
check_backup_files();
/*if(substr(PHP_OS, 0, 3) == 'WIN') {
$writable_dir = $backup_options['path'];
$tmpnam = $writable_dir.'/wp-dbmanager.bat';
$fp = fopen($tmpnam, 'w');
fwrite($fp, $command);
fclose($fp);
system($tmpnam.' > NUL', $error);
unlink($tmpnam);
} else {*/
passthru($command, $error);
//}
return $error;
}
3. If you want to have the gzip functionality you will need to download and place gzip.exe in the system32 folder of the server. You can download gzip from here.
NOTES:
- Make sure the the Internet Guest Account has write permissions to the backup-db directory.
- There is probably a better way to do this, perhaps using the exec() command in the if statement, but this one seems to work just fine.
- Not necessary - On my server I had to put @ symbols in front of the filesize() and unlink() functions in the database-backup.php file, so that the they would not throw the php warning message and continue through to show the actual error message on the plugin page.
