Yii 1.1: yii-dump-db

Another extension that allows to create backups of mysql database (structure and data)
9 followers

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

  1. Download the extension on bitbucker: https://bitbucket.org/rodzadra/yii-dump-db/downloads
  2. 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();

Resources

  1. https://bitbucket.org/rodzadra/yii-dump-db

  2. http://www.yiiframework.com/extension/database-dumper/

Total 6 comments

#15777 report it
Nathan at 2013/12/16 12:44pm
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

#14232 report it
Anil Konsal at 2013/07/29 04:38am
Good Work!

Hi,

I appreciate your work on this extension. Helped me.

Anil

#10522 report it
nucreativa at 2012/11/02 05:41am
$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

#8104 report it
rodzadra at 2012/05/10 08:30am
Thank you, aidai524

Thank you, aidai524.

I have corrected it.

#8101 report it
aidai524 at 2012/05/10 05:36am
The Usage has a error

the code '$dumper = new dbBackup();' is wrong, the correct code should be '$dumper = new dumpDB();'

#7906 report it
bennouna at 2012/04/25 02:50pm
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?

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet