Mysql Dump 1.1 beta released

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Locked
mahjong

Mysql Dump 1.1 beta released

Post 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.
mahjong

Re: Mysql Dump 1.1 beta released

Post by mahjong »

Install with the Module Manager (prefered method)
or download here...
Der Rudi
Forum Members
Forum Members
Posts: 56
Joined: Wed May 17, 2006 7:42 pm

Re: Mysql Dump 1.1 beta released

Post 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
mahjong

Re: Mysql Dump 1.1 beta released

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Mysql Dump 1.1 beta released

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Der Rudi
Forum Members
Forum Members
Posts: 56
Joined: Wed May 17, 2006 7:42 pm

Re: Mysql Dump 1.1 beta released

Post 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.
mahjong

Re: Mysql Dump 1.1 beta released

Post 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.
Last edited by mahjong on Sun Aug 20, 2006 5:42 pm, edited 1 time in total.
mahjong

Re: Mysql Dump 1.1 beta released

Post 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.
Last edited by mahjong on Sun Aug 20, 2006 5:47 pm, edited 1 time in total.
Der Rudi
Forum Members
Forum Members
Posts: 56
Joined: Wed May 17, 2006 7:42 pm

Re: Mysql Dump 1.1 beta released

Post 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?
Last edited by Der Rudi on Tue Aug 29, 2006 7:51 am, edited 1 time in total.
mahjong

Re: Mysql Dump 1.1 beta released

Post 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.
Der Rudi
Forum Members
Forum Members
Posts: 56
Joined: Wed May 17, 2006 7:42 pm

Re: Mysql Dump 1.1 beta released

Post 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.
mahjong

Mysql Dump 1.2.0 released

Post 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
Der Rudi
Forum Members
Forum Members
Posts: 56
Joined: Wed May 17, 2006 7:42 pm

Re: Mysql Dump 1.2 beta released

Post 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 :)
Last edited by Der Rudi on Fri Sep 01, 2006 8:19 am, edited 1 time in total.
mahjong

Re: Mysql Dump 1.1 beta released

Post 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
Last edited by mahjong on Fri Sep 01, 2006 9:03 am, edited 1 time in total.
mahjong

Re: Mysql Dump 1.1 beta released

Post by mahjong »

Locking this thread. Discussion can be continued here.
Locked

Return to “Modules/Add-Ons”