Extension that allows to create backups of mysql database (structure, data and FK's)
Requirements ¶
Yii 1.1 or above.
History ¶
v0.2 - dumping of views, dump of remote mysql DB;
v0.1 - inicial version;
Usage ¶
- Download the extension on bitbucker: https://bitbucket.org/rodzadra/yii-dump-db/downloads
- Extract yii-dump-db to extensions directory
On controller:
(to download the generated sql file)
Yii::import('ext.dumpDB.dumpDB');
$dumper = new dumpDB();
echo $dumper->getDump();
(to show the generated sql)
Yii::import('ext.dumpDB.dumpDB');
$dumper = new dumpDB();
echo $dumper->getDump(false);
(to save a dump file)
Yii::import('ext.dumpDB.dumpDB');
$dumper = new dumpDB();
$bk_file = 'FILE_NAME-'.date('YmdHis').'.sql';
$fh = fopen($bk_file, 'w') or die("can't open file");
fwrite($fh, $dumper->getDump(FALSE));
fclose($fh);
(dumping an remote mysql db)
Yii::import('ext.dumpDB.dumpDB');
$dumper = new dumpDB('mysql:host=[HOTS];dbname=[DATABASE]','[USERNAME]','[PASSWORD]');
$dumper = new dumpDB();
$dumper->setRemoveViewDefinerSecurity(TRUE);
echo $dumper->getDump();
Can you explain the difference with database-dumper?
It has just been released 5 days ago, and you've listed it in "Resources" on this page. What's the difference between the two?
The Usage has a error
the code '$dumper = new dbBackup();' is wrong, the correct code should be '$dumper = new dumpDB();'
Thank you, aidai524
Thank you, aidai524.
I have corrected it.
$dumper->getDump(); not work
Hi, thanks for your extension. But I found there is something wrong. when I want to generate as sql file, it doesn't work. It always return 0 size file sql (without contain). but I made some changes to make it work.
public function getDump($download = TRUE) { ob_start(); foreach($this->getTables() as $key=>$val) $this->dumpTable($key); $result = $this->setHeader(); $result.= ob_get_contents(); $result.= $this->getConstraints(); $result.= $this->setFooter(); ob_end_clean(); if($download){ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); header("Content-type:application/sql"); header("Content-Disposition:attachment;filename=downloaded.sql"); echo $result;exit;// I adding this line } return $result; }
sorry for my bad english :D
Good Work!
Hi,
I appreciate your work on this extension. Helped me.
Anil
VIEWS
Is this project still alive?
If not - would love a recommended alternative.
My issue: I think it doesn't work with "views". When it reaches a View it gets the error: Undefined index: Create Table
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.