/** * * @return Boolean */ public function restoreDatabaseBackup() { if (!Director::IsLive() || $this->Config()->get("allow_restores_in_live_environment")) { $fileLocation = $this->FullLocation; if (file_exists($fileLocation)) { $this->saveToSession(); global $databaseConfig; $compression = $this->Config()->get("compression"); if ($compression == "gzip") { $command = "gunzip < " . $fileLocation . " | mysql -u " . $databaseConfig["username"] . " -p" . $databaseConfig["password"] . " " . $databaseConfig["database"] . " "; } else { $command = "mysql -u " . $databaseConfig["username"] . " -p" . $databaseConfig["password"] . " " . $databaseConfig["database"] . " < " . $fileLocation; } exec($command); //reset list of backups ... $this->requireDefaultRecords(); $this->retrieveFromSession(); Controller::curr()->redirect("/admin/databasebackuplog/"); return true; } } return false; }