public function backupSys() { $folder = Yii::$app->basePath . "/../"; if (file_exists(Yii::$app->basePath . "/tmp")) { unlink(Yii::$app->basePath . "/tmp"); } Zipper::zip($folder, Yii::$app->basePath . "/tmp"); return Yii::$app->basePath . "/tmp"; }
public function backup() { $folder = $this->getFilePath($this); $file = $folder . "db.sql"; $dumper = new dbMaster(); $handle = fopen($file, 'w'); fwrite($handle, $dumper->getDump(false, $this->prefix)); fclose($handle); Zipper::zip($folder, $folder . "tenant.zip", "backup"); $file = new Files(); $file->name = date("d-m-Y_H_i") . ".zip"; $file->path = 'backup' . DIRECTORY_SEPARATOR; $file->save(); if (!is_dir($folder . $file->path)) { mkdir($folder . $file->path); } rename($folder . "tenant.zip", $folder . $file->path . $file->id); return true; }