/**
  * Dump database to the local filesystem via mysqldump command and optionally gzipping output.
  *
  * @SideEffects:
  *  Dumps database to local filesystem.
  *
  * @return bool true on success, false on fail
  * @throws PermissionFailureException
  */
 public function execute()
 {
     $fullPath = FileSystemTools::build_path($this->Path, $this->FileName) . ($this->UseGZIP ? ".gz" : '');
     $this->step("Dumping database '{$this->Database}' to '{$fullPath}'");
     // local server dump requested, create paths and dump the file.
     if (!is_dir($this->Path)) {
         // path doesn't exist, create it recursively
         $this->step("Creating folder '{$this->Path}'");
         if (!FileSystemTools::make_path($this->Path)) {
             $this->failed("Failed to create path '{$this->Path}'");
             return false;
         }
     }
     $excludeTables = '';
     if (count(Replicant::config()->get('exclude_tables'))) {
         $excludeTables = " --ignore-table={$this->Database}." . implode(" --ignore-table={$this->Database}.", Replicant::config()->get('exclude_tables')) . " ";
     }
     $command = sprintf("%s --host=%s --user=%s --password=%s %s %s %s %s", Replicant::config()->get('path_to_mysqldump'), DatabaseTools::getDBCredential('Server'), DatabaseTools::getDBCredential('UserName'), DatabaseTools::getDBCredential('Password'), $excludeTables, $this->Database, $this->UseGZIP ? " | gzip > " : " > ", $fullPath);
     $ok = $this->system($command, $retval);
     if ($ok) {
         $this->success("Dumped Database to {$fullPath}");
     } else {
         $this->failed("Execute returned #{$retval}");
     }
     return $ok;
 }