Page 1 of 1
Mysql Dump 1.1 beta released
Posted: Tue Aug 15, 2006 4:30 am
by mahjong
Mysql Dump 1.1, with automated locator of MySQL binaries
- Backup with 'myslqldump'
- Restore with 'mysql'
- Backups can be erased
- GUI with Tango icons
- Beautified source code
- Proven stable on CMSMS 1.0
- Greatly improved locator (new)
- Help messages on install/first run (new)
- Bug fixes (new)
Mysql Dump is an interface for the 'mysqldump' backup tool. It can be used to dump the CMSMS database for backup or for transferring the data to another server (not necessarily a MySQL server).
In other words, it allows you to dump the contents of your CMSMS database into a text file, and restore from such a file. This text file can be easily saved locally or sent to remote server.
THIS MODULE IS VERY POWERFUL. PLEASE TEST IN A SAFE ENVIRONMENT AND MAKE BACKUPS OF YOUR ALL DATABASES *BEFORE* LEARNING HOW TO USE MYSQL DUMP.
Re: Mysql Dump 1.1 beta released
Posted: Tue Aug 15, 2006 4:32 am
by mahjong
Install with the
Module Manager (prefered method)
or
download here...
Re: Mysql Dump 1.1 beta released
Posted: Sun Aug 20, 2006 2:10 pm
by Der Rudi
When installing mysql dump 1.1.0 with Module Manager under cmsms10b5 this happens:
Error!
SOAP Error: Response not of type text/xml
Re: Mysql Dump 1.1 beta released
Posted: Sun Aug 20, 2006 4:59 pm
by mahjong
I just checked. There seems to be a bug with CMSMS Forge. The xml file is served as Content: application/binary. Until this is fixed, you can download the XML directly.
Thank you for the bug report.
Re: Mysql Dump 1.1 beta released
Posted: Sun Aug 20, 2006 5:07 pm
by calguy1000
you may want to try re-uploading the file and setting the filetype as xml.
that seems to work for all of the other modules in the forge.
Re: Mysql Dump 1.1 beta released
Posted: Sun Aug 20, 2006 5:12 pm
by Der Rudi
Ok, uploading xml file from pc works fine.
Just a note: I'm using severall tables in my mysql database, and it seems that you make a complete backup, not just limited to the table with the prefix as defined in config.php. Would it be possible to select the table/prefix is to be backuped/restored (more then one if there are more)? That would make it even better.
Re: Mysql Dump 1.1 beta released
Posted: Sun Aug 20, 2006 5:31 pm
by mahjong
The prefix isn't taken in account. All the tables in the CMSMS database are saved. You can even limit the backup to specific tables by specifying the tables names. See the online mysqldump manual (link in Preferences tab)
The only thing the module doesn't do is to backup other databases.
Re: Mysql Dump 1.1 beta released
Posted: Sun Aug 20, 2006 5:38 pm
by mahjong
calguy1000 wrote:
you may want to try re-uploading the file and setting the filetype as xml.
Tried it. Still no go.
I checked other modules. All XML files are sent as application/binary. This a site wide problem.
Re: Mysql Dump 1.1 beta released
Posted: Tue Aug 29, 2006 7:49 am
by Der Rudi
Have been trying to limit backup to one table in database but no luck sofar. Running 10beta6.
According to mysqldump manual the --tables command can be used for this:
--tables
Override the --databases or -B option. All name arguments following the option are regarded as table names.
However, if I give '--tables cms?' as additional command in the dump parameters in Preferences tab, it comes out as '--tables', without the 'cms?' and a complete database backup is made, not just from the table name given.
Questions:
- is this the correct way to get mysqldump to use only one table in a database?
- if not, how can one do that?
- if yes, why is mysqldump ignoring the table name?
Re: Mysql Dump 1.1 beta released
Posted: Wed Aug 30, 2006 1:51 am
by mahjong
- is this the correct way to get mysqldump to use only one table in a database?
Yes.
- if yes, why is mysqldump ignoring the table name?
It doesn't ignore it. It never receives it from the Mysql Dump module. This a safety feature to prevent arbitrary code injection. You cannot use Mysql Dump to back up individual tables, because arbitrary words are deleted from the command string.
Maybe, if I get a lot of requests for this specific feature, I'll add it in a future version. But, sorry, for the time being, you'll need to use mysqldump without the assistance of the Mysql Dump module or write your own module to suit your special needs.
Re: Mysql Dump 1.1 beta released
Posted: Thu Aug 31, 2006 5:49 pm
by Der Rudi
Ok, had a go at this myself
In MysqlDump.module.php around line 370
Replace
Code: Select all
$command = sprintf(
'%s --user=%s --password=%s %s %s>>%s 2>%s',
$executable,
$config['db_username'],
$config['db_password'],
$options,
$config['db_name'],
$output_file,
$output_capture );
with
Code: Select all
// Start Der Rudi mod
$tb_prfx = str_replace("_", "\_", $config['db_prefix']); //Get prefix set in config.php and escape the '_'
$db =& $this->cms->GetDb();
$query = "SHOW TABLES LIKE '".$tb_prfx."%'"; //get all tables that match prefix
$result=$db->Execute($query);
if ($result) {
$tables='';
while ($dbr = $result->FetchRow()) {
$tabarr = array_values($dbr);
$tables .= "'".$tabarr[0]."' "; //build list of table names to backup
}
}
else {
echo 'Error fetching table names';
return;
}
$result->Close();
$tables = rtrim($tables); //remove trailing space
$command = sprintf(
'%s --user=%s --password=%s %s %s %s>>%s 2>%s', //added tables section
$executable,
$config['db_username'],
$config['db_password'],
$options,
$config['db_name'],
$tables, //added Der Rudi
$output_file,
$output_capture );
// End Der Rudi mod
The above code works for me, but I am not really an experienced programmer. So if anyone has suggestions for improvements please do.
Mysql Dump 1.2.0 released
Posted: Fri Sep 01, 2006 7:37 am
by mahjong
I completely misunderstood what you were asking for. I taught you wanted to choose individual tables.
Thank you for submitting your patch. A job well done!
I only had to make very minor corrections to your code :
- Used mysql_real_escape_string() instead of str_replace to escape not only _ but all special characters
- Added a configuration switch for enabling/disabling the prefix selection
- Internationalised the error messages
The module will be released as 1.2.0
Re: Mysql Dump 1.2 beta released
Posted: Fri Sep 01, 2006 8:16 am
by Der Rudi
Great, your modifications are good to have. Shows lack of experience on my side
Glad it made it into a release version, is really helpfull to me and hopefully others also.
Note1
Wouldn't this be something to put into the core? Backup and restore are very common things to do, I think. Anyone would like to comment on this?
Note2
This version deals with mysql databases, a similar one for postgresql databases could be handy to have also. Should be easy for mahjong to do so

Re: Mysql Dump 1.1 beta released
Posted: Fri Sep 01, 2006 8:41 am
by mahjong
Comment 1.
I don't know what CMSMS gods have in plan for us. But, since not all Web hosting compagnies give access to MySQL binaries on which the Mysql Dump module relies on, this module is not the ideal, universal, backup system. And as you noted, this module deals only with MySQL databases. Therefore, I think the module should remain optional, even though, at this moment, it's the only reliable module to do backups.
Comment 2.
I've committed an alpha build of Postgres Dump in svn a month ago. See
http://forum.cmsmadesimple.org/index.ph ... 043.0.html
Re: Mysql Dump 1.1 beta released
Posted: Fri Sep 01, 2006 8:46 am
by mahjong
Locking this thread. Discussion can be continued
here.