Ejemplo n.º 1
0
 public function actionIndex()
 {
     $hash = time();
     $cacheFolder = Yii::getAlias('@runtime/exporter/' . $hash);
     FileHelper::createDirectory($cacheFolder);
     $dump = new Mysqldump\Mysqldump(Yii::$app->db->dsn, Yii::$app->db->username, Yii::$app->db->password);
     $dump->start($cacheFolder . '/mysql.sql');
     FileHelper::copyDirectory(Yii::getAlias('@web/public_html/storage'), $cacheFolder . '/storage');
     $save = Yii::getAlias($this->module->downloadFile);
     @unlink($save);
     ZipHelper::dir($cacheFolder . '/', $save);
 }
 /**
  * Create a zip file with database dump and storage files/images and stores the zip in
  * the runtime folder.
  *
  * @return void
  */
 public function actionIndex()
 {
     $hash = time();
     $cacheFolder = Yii::getAlias('@runtime/exporter/' . $hash);
     $this->verbosePrint("cache folder {$cacheFolder}");
     FileHelper::createDirectory($cacheFolder, 0777);
     $dump = new Mysqldump\Mysqldump(Yii::$app->db->dsn, Yii::$app->db->username, Yii::$app->db->password);
     $dump->start($cacheFolder . '/mysql.sql');
     $source = Yii::getAlias('@web/public_html/storage');
     $this->verbosePrint("storage source folder {$source}");
     if (is_link($source)) {
         $source = readlink($source);
         $this->verbosePrint("source is a symlink, readlink output: " . $source);
     }
     FileHelper::copyDirectory($source, $cacheFolder . '/storage', ['dirMode' => 0777, 'fileMode' => 0775]);
     $save = Yii::getAlias($this->module->downloadFile);
     if (file_exists($save)) {
         $this->verbosePrint("a exporter file does already exists, unlink file: " . $save);
         @unlink($save);
     }
     ZipHelper::dir($cacheFolder . '/', $save);
 }
Ejemplo n.º 3
0
 public function testZipDir()
 {
     ZipHelper::dir(__DIR__, Yii::getAlias('@runtime/test.zip'));
 }