/** * exports this workspace database to the specified path * * This function is used mainly for backup purposes. * * @param string $path the directory where to create the sql files */ public function exportDatabase($path) { $dbInfo = $this->getDBInfo(); $databases = array("wf", "rp", "rb"); $dbNames = array(); foreach ($databases as $db) { $dbInfo = $this->getDBCredentials($db); $oDbMaintainer = new DataBaseMaintenance($dbInfo["host"], $dbInfo["user"], $dbInfo["pass"]); CLI::logging("Saving database {$dbInfo["name"]}\n"); $oDbMaintainer->connect($dbInfo["name"]); $oDbMaintainer->lockTables(); $oDbMaintainer->setTempDir($path . "/"); $oDbMaintainer->backupDataBase($oDbMaintainer->getTempDir() . $dbInfo["name"] . ".sql"); $oDbMaintainer->unlockTables(); $dbNames[] = $dbInfo; } return $dbNames; }
function backupDB($host, $user, $passwd, $dbname, $tmpDir) { $oDbMaintainer = new DataBaseMaintenance($host, $user, $passwd); //stablishing connetion with host $oDbMaintainer->connect($dbname); //set temporal dir. for maintenance for oDbMaintainer object $oDbMaintainer->setTempDir($tmpDir . $dbname . PATH_SEP); //create the backup $oDbMaintainer->backupDataBaseSchema($oDbMaintainer->getTempDir() . "{$dbname}.sql"); $oDbMaintainer->backupSqlData(); }