Example #1
0
 /**
  * @param \Cogeco\Build\Entity\Database $db
  * @param \Cogeco\Build\Entity\File $dumpFile
  * @param $dbName
  * @param array $tables
  * @throws \Cogeco\Build\Exception
  */
 public static function mysqlDump(Database $db, $dbName, array $tables = array(), File $dumpFile)
 {
     if (!is_array($tables) || count($tables) === 0) {
         $tablesParam = '';
     } else {
         $tablesParam = explode(' ', $tables) . ' ';
     }
     // Presentation
     self::log("- Getting dump of {$dbName}");
     if ($db->isRemote()) {
         Task::log(" from {$db->host->hostname}");
     }
     self::log("\n");
     // For use when converting a dump to SQLite
     // --compatible=ansi --skip-extended-insert --compact
     // Build the command
     $cmd = Config::get('mysqldump.bin') . " -vf -P {$db->port}";
     if ($db->isRemote()) {
         $cmd .= " -h {$db->host->hostname}";
     }
     // Create the folder if it doesn't exist already
     FileSystemTask::mkdir($dumpFile->dir->getPath());
     $cmd .= " -u {$db->account->username} -p{$db->account->password} {$dbName} {$tablesParam}| sed '/^\\/\\*\\!50013 DEFINER/d' > {$dumpFile->getPath()}";
     //$cmd .= " --result-file={$dumpFile->getPath()} -u {$db->account->username} -p{$db->account->password} {$dbName} {$tablesParam} 2>&1";
     self::runCmd($cmd);
     self::log("\n");
 }
Example #2
0
 /**
  * @param WorkingCopy $workingCopy
  * @throws Exception
  */
 public static function purgeIgnoredAndUnversioned($workingCopy)
 {
     // Remove unversioned and ignored files/folders
     self::log("- Removing ignored and unversioned files and folders\n");
     $cmd = Config::get('svn.bin') . " status --no-ignore " . "--username {$workingCopy->account->username} " . "--password {$workingCopy->account->password} " . "--non-interactive --trust-server-cert --no-auth-cache {$workingCopy->dir->getPath()} 2>&1";
     exec($cmd, $output, $err);
     if ($err !== 0) {
         throw new Exception("SVN deletion of ignored and unversioned files failed:\n\t" . implode("\n\t", $output) . "\n");
     }
     foreach ($output as $lineNumber => $line) {
         if (preg_match('/^(I|\\?)\\s{7}/', $line) === 1) {
             $file = mb_substr($line, 8);
             self::log("Deleting {$file}\n");
             if (file_exists($file)) {
                 if (is_dir($file)) {
                     FileSystemTask::rrmdir($file);
                 } else {
                     unlink($file);
                 }
             }
         }
     }
     self::log("\n");
 }