src/commands/DumpController.php
public function actionCreate()
    {
        $model = new Dump($this->getModule()->dbList);
        if (ArrayHelper::isIn($this->db, $this->getModule()->dbList)) {
            $dbInfo = $this->getModule()->getDbInfo($this->db);
            $dumpOptions = $model->makeDumpOptions();
            if ($this->gzip) {
                $dumpOptions['isArchive'] = true;
            }
            $manager = $this->getModule()->createManager($dbInfo);
            $dumpPath = $manager->makePath($this->getModule()->path, $dbInfo, $dumpOptions);
            $dumpCommand = $manager->makeDumpCommand($dumpPath, $dbInfo, $dumpOptions);
            Yii::trace(compact('dumpCommand', 'dumpPath', 'dumpOptions'), get_called_class());
            $process = new Process($dumpCommand);
            $process->run();
            if ($process->isSuccessful()) {
                if ($this->storage) {
                    if (Yii::$app->has('backupStorage')) {
                        $dumpText = fopen($dumpPath, 'r+');
                        Yii::$app->backupStorage->writeStream(StringHelper::basename($dumpPath), $dumpText);
                        fclose($dumpText);
                    } else {
                        Console::output('Storage component is not configured.');
                    }
                }
                Console::output('Dump successfully created.');
            } else {
                Console::output('Dump failed create.');
            }
        } else {
            Console::output('Database configuration not found.');
        }
    }
public function actionCreate()
    {
        $model = new Dump($this->getModule()->dbList);
        if (ArrayHelper::isIn($this->db, $this->getModule()->dbList)) {
            $dbInfo = $this->getModule()->getDbInfo($this->db);
            $dumpOptions = $model->makeDumpOptions();
            if ($this->gzip) {
                $dumpOptions['isArchive'] = true;
            }
            $manager = $this->getModule()->createManager($dbInfo);
            $dumpPath = $manager->makePath($this->getModule()->path, $dbInfo, $dumpOptions);
            $dumpCommand = $manager->makeDumpCommand($dumpPath, $dbInfo, $dumpOptions);
            Yii::trace(compact('dumpCommand', 'dumpPath', 'dumpOptions'), get_called_class());
            $process = new Process($dumpCommand);
            $process->run();
            if ($process->isSuccessful()) {
                if ($this->storage) {
                    if (Yii::$app->has('backupStorage')) {
                        $dumpText = fopen($dumpPath, 'r+');
                        Yii::$app->backupStorage->writeStream(StringHelper::basename($dumpPath), $dumpText);
                        fclose($dumpText);
                    } else {
                        Console::output('Storage component is not configured.');
                    }
                }
                Console::output('Dump successfully created.');
            } else {
                Console::output('Dump failed create.');
            }
        } else {
            Console::output('Database configuration not found.');
        }
    }
public function actionCreate ( ) { $ model = new Dump ( $ this -> getModule ( ) -> dbList ) ; if ( ArrayHelper :: isIn ( $ this -> db , $ this -> getModule ( ) -> dbList ) ) { $ dbInfo = $ this -> getModule ( ) -> getDbInfo ( $ this -> db ) ; $ dumpOptions = $ model -> makeDumpOptions ( ) ; if ( $ this -> gzip ) { $ dumpOptions [ 'isArchive' ] = true ; } $ manager = $ this -> getModule ( ) -> createManager ( $ dbInfo ) ; $ dumpPath = $ manager -> makePath ( $ this -> getModule ( ) -> path , $ dbInfo , $ dumpOptions ) ; $ dumpCommand = $ manager -> makeDumpCommand ( $ dumpPath , $ dbInfo , $ dumpOptions ) ; Yii :: trace ( compact ( 'dumpCommand' , 'dumpPath' , 'dumpOptions' ) , get_called_class ( ) ) ; $ process = new Process ( $ dumpCommand ) ; $ process -> run ( ) ; if ( $ process -> isSuccessful ( ) ) { if ( $ this -> storage ) { if ( Yii :: $ app -> has ( 'backupStorage' ) ) { $ dumpText = fopen ( $ dumpPath , 'r+' ) ; Yii :: $ app -> backupStorage -> writeStream ( StringHelper :: basename ( $ dumpPath ) , $ dumpText ) ; fclose ( $ dumpText ) ; } else { Console :: output ( 'Storage component is not configured.' ) ; } } Console :: output ( 'Dump successfully created.' ) ; } else { Console :: output ( 'Dump failed create.' ) ; } } else { Console :: output ( 'Database configuration not found.' ) ; } }
Create database dump.
Create database dump .