Beispiel #1
0
 /**
  * The main entry point method.
  */
 public function main()
 {
     $command = null;
     $execTask = new ExecTask();
     $execTask->setProject($this->getProject());
     $backupPath = $this->dir . DIRECTORY_SEPARATOR . $this->taoDbConfig->getDbName() . '.gz';
     switch ($this->taoDbConfig->getDbDriver()) {
         case 'pdo_pgsql':
             $command = vsprintf("pg_dump --clean --host=%s --username=%s --no-password --dbname=%s | gzip > %s", [$this->taoDbConfig->getDbHost(), $this->taoDbConfig->getDbUser(), $this->taoDbConfig->getDbName(), $backupPath]);
             break;
         case 'pdo_mysql':
             $command = vsprintf("mysqldump -u%s -p%s %s --add-drop-table | gzip > %s", [$this->taoDbConfig->getDbUser(), $this->taoDbConfig->getDbPass(), $this->taoDbConfig->getDbName(), $backupPath]);
             break;
         default:
             throw new BuildException('DB Driver is not supported');
             break;
     }
     if ($command) {
         $execTask->setCommand($command);
         $execTask->main();
         $this->log(sprintf('Backup for %s created at %s', $this->taoDbConfig->getDbName(), $backupPath));
     }
 }
 /**
  * The main entry point method.
  */
 public function main()
 {
     $command = null;
     $execTask = new ExecTask();
     $execTask->setProject($this->getProject());
     $restoreGZ = $this->getDir() . DIRECTORY_SEPARATOR . $this->taoDbConfig->getDbName() . '.gz';
     switch ($this->taoDbConfig->getDbDriver()) {
         case 'pdo_pgsql':
             $command = vsprintf("gunzip -c %s | psql %s --host=%s --username=%s --no-password", [$restoreGZ, $this->taoDbConfig->getDbName(), $this->taoDbConfig->getDbHost(), $this->taoDbConfig->getDbUser()]);
             break;
         case 'pdo_mysql':
             $command = vsprintf("gunzip -c %s | mysql -u %s -p%s %s", [$restoreGZ, $this->taoDbConfig->getDbUser(), $this->taoDbConfig->getDbPass(), $this->taoDbConfig->getDbName()]);
             break;
         default:
             throw new BuildException('DB Driver is not supported');
             break;
     }
     if ($command) {
         $execTask->setCommand($command);
         $execTask->main();
         $this->log(sprintf('Backup for %s restored at %s', $this->taoDbConfig->getDbName(), $restoreGZ));
     }
 }
Beispiel #3
0
 /**
  * The main entry point method.
  */
 public function main()
 {
     $command = null;
     $execTask = new ExecTask();
     $execTask->setProject($this->getProject());
     switch ($this->taoDbConfig->getDbDriver()) {
         case 'pdo_pgsql':
             $command = vsprintf("createdb %s --host=%s --username=%s --no-password", [$this->taoDbConfig->getDbName(), $this->taoDbConfig->getDbHost(), $this->taoDbConfig->getDbUser()]);
             break;
         case 'pdo_mysql':
             $command = vsprintf("echo 'create database %s ' | mysql -u%s -p%s", [$this->taoDbConfig->getDbName(), $this->taoDbConfig->getDbUser(), $this->taoDbConfig->getDbPass()]);
             break;
         default:
             throw new BuildException('DB Driver is not supported');
             break;
     }
     if ($command) {
         $execTask->setCommand($command);
         $execTask->main();
         $this->log(sprintf('Database %s has been created', $this->taoDbConfig->getDbName()));
     }
 }
Beispiel #4
0
 public function toArray()
 {
     $returnValue = array("user_login" => $this->login, "user_pass1" => $this->pass, "user_email" => "", "user_firstname" => "", "user_lastname" => "", "import_local" => true);
     return array_merge($this->taoDbConfig->toArray(), $this->generisConfig->toArray(), $returnValue);
 }